Jump to content
  • Advertisement
Sign in to follow this  
tri_media_k

Cube environment mapping GLSL (and WebGL)

This topic is 3084 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!