Cubemap reflection mapping

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[2].xyz ) ) * (1.0 - alpha);
		// Skybox (this works fine)
		//gl_FragColor = gl_FragColor * alpha + textureCube( cubemap, gl_TexCoord[2].xyz ) * (1.0 - alpha);

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.

By copying some code from a generated ShaderGen shader, I was able to calculate the reflection vector in the vertex shader. It works perfectly. Thank you, 3DLabs.

There is still the matter of modulating the cubemap lookup by the bump vector, for EMBM, but the hard part is done.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.