Planar reflection help


I have a water shader where I’ve added a cloudy texture to simulate reflections.
It works well as it follows the camera, but when I turn the camera the texture follows the rotation.
How can I stop the rotation?

[video=youtube_share;qOB7f5olcFs]- YouTube

From vertex shader:

vec3 vEyeNormal = gl_NormalMatrix * gl_Normal;

vec4 vVert4 = gl_ModelViewMatrix * gl_Vertex;
vec3 vEyeVertex = normalize( / vVert4.w);
vec4 vCoords = vec4(reflect(vEyeVertex, vEyeNormal), 0.0); =normalize(;

From frag shader:

vec4 refImage = texture2D(refMap, vec2(RefTexcoord.x, RefTexcoord.y));


By reflecting a world-space vector rather than an eye-space vector.


vec3 eye_w = gl_ModelViewMatrixInverse[3].xyz;
vec3 incident = - eye_w;
vec3 reflected = reflect(incident, gl_Normal);
vec3 RefTexcoord =normalize(reflected);

That did the trick!
Thank you!!

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