I´m trying to use a screen quad to display the contents of a texture cube (instead of rendering a cube mesh in front of the view).

I´m passing to my shader the camera view matrix. The pixel shader looks like this:

void main()
    vec2 uv = gl_FragCoord.xy / u_viewRect.zw;
    uv.y = 1.0 - uv.y;
    uv = uv * 2.0 - 1.0;
    mat3 v;
    v[0] = uView[0].xyz;
    v[1] = uView[1].xyz;
    v[2] = uView[2].xyz;
    vec3 dir = normalize(mul(v,vec3(uv.xy,1.0)).xyz);
    gl_FragData[0] = textureCube(uEnvTex,dir);

As far as I know, taking the 3x3 matrix of a 4x4 view matrix removes the translation part. This is nor properly working as the displayed image is heavily distorted: res

I´m using bgfx as my rendering backend. Thanks!


This shows the uvs: uvs

This shows view * uv: https://i.gyazo.com/b48da7041470459b88a9575adb209a67.mp4


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.