PDA

View Full Version : Shader help



bracer
12-03-2019, 09:04 PM
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?


https://youtu.be/qOB7f5olcFs


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!

SilverWarior
13-03-2019, 05:37 PM
It works well as it follows the camera, but when I turn the camera the texture follows the rotation.

To me it seems that it doesn't works well at all. To me the cloud reflection didn't seem correct at any point in the video. But then again it is hard to se properly because you are already combining it with wave effects.
So my suggestion is that you temporary remove waves so that you have smooth water surface on which you can clearly see if reflection of the cloud is as it needs to be. Only when you make reflection work correctly should you add waves back.

Any way I don't have much experience with shaders but looking at your shader code I can't seem to figure out where are you feeding the information about camera orientation in.

davido
29-09-2019, 01:19 PM
I also think that you have to temporarily remove the waves.


VPN (https://downloader.vip/vpn/) Sai Mannat (https://flatwow.in/sai-mannat/) AnyDesk (https://anydesk.vip/)