Planar reflection help

Hi!

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.xyz / vVert4.w);
vec4 vCoords = vec4(reflect(vEyeVertex, vEyeNormal), 0.0);
RefTexcoord.xyz =normalize(vCoords.xyz);

From frag shader:

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

Cheers!

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

E.g.


vec3 eye_w = gl_ModelViewMatrixInverse[3].xyz;
vec3 incident = gl_Vertex.xyz - 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.