• Advertisement
Sign in to follow this  

Cube environment mapping GLSL (and WebGL)

This topic is 2894 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I am trying to set up cubic environment mapping using GLSL. I pproceeded as suggested here ozone3d or here cg tutorials Now, the problem is that the cube map gets flipped udside down when moving the camera. For example, if I rotate the camera around the x-axis by 180 degrees the cube map gets upside down. Here the pictures rotated sphere Here (part of) my vertex shader
vTransformedNormal = uNMatrix * vec4(aVertexNormal, 1.0);
vec3 N = normalize(vTransformedNormal.xyz);
vec3 transformedPosition = (uNMatrix  * vec4(aVertexPosition, 1.0)).xyz;
vec3 I = normalize(transformedPosition - uEyePosition);    

vReflectionVector = reflect(I,N);

where uNMatrix is the normal matrix (equals the inverse transformed of the modelview matrix) and uEyePosition is a vector computed by multiplying the normal matrix by a zero vector. The cube map texture should be put together right as the flipping happens "inside" a texture. By the way, the project uses WebGL (and not OpenGL). Thanks in advance, I am working on this bug just tooo long...

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement