Results 1 to 3 of 3

Thread: Shader help

  1. #1

    Shader 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?




    From vertex shader:
    Code:
    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:
    Code:
    vec4 refImage = texture2D(refMap, vec2(RefTexcoord.x, RefTexcoord.y));
    Cheers!

  2. #2
    Quote Originally Posted by bracer View Post
    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.

  3. #3
    I also think that you have to temporarily remove the waves.
    Last edited by davido; 28-08-2024 at 04:21 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •