I got my cubemaps set up so they work with a “skybox” style mapping mode. Then I attempted to do a reflection in the fragment shader. Here is the result:
As you can see, there is an odd vertical line where the cubemap gets flipped. This line moves with the camera.
I have packaged up the demo here:
If anyone can identity what is wrong with the shader, I would appreciate it. The section you should look at is line 91 of main.frag:
#ifdef LW_CUBEMAP // Reflection gl_FragColor = gl_FragColor * alpha + textureCube( cubemap, reflect( N,gl_TexCoord.xyz ) ) * (1.0 - alpha); // Skybox (this works fine) //gl_FragColor = gl_FragColor * alpha + textureCube( cubemap, gl_TexCoord.xyz ) * (1.0 - alpha); #endif
It should be noted that I scale my modelview matrix by (0,0,-1) before doing anything, in order to switch the coordinate system to a left-handed one.