Public Group

# Cube environment mapping GLSL (and WebGL)

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

## 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 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...

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633660
• Total Posts
3013221
×