Jump to content
  • Advertisement
Sign in to follow this  

Water Bumpmapping

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, i got a problem with my water bumpmap shader: that are not the complete shaders, to have a quick overview i only poste the important parts: vertex shader:

    float3x3 otts; //WorldToTangenteSpace
    //only one big quad lying in the xz plane
    otts[0] = mul(float4(1,0,0,1),glstate.matrix.modelview[0]).xyz;
    otts[1] = mul(float4(0,0,1,1),glstate.matrix.modelview[0]).xyz;
    otts[2] = mul(float4(0,1,0,1),glstate.matrix.modelview[0]).xyz;

    //vertex displacement
    OUT.pos = mul(glstate.matrix.modelview[0],IN.pos);

    OUT.lightvec = normalize(mul(otts,glstate.light[0].position.xyz - OUT.pos.xyz));

    OUT.halfway = normalize(mul(otts,OUT.lightvec - normalize(OUT.pos.xyz)));



 float3 norm = 2.0f * (tex2D(IN.texture1,IN.texcoord0.xy).rgb - 0.5f);
 IN.light = normalize(IN.light);
 IN.halfway = normalize(IN.halfway);

 float diffuse  = dot(IN.light,norm);
 float specular = dot(IN.halfway, norm);

 float4 temp = lit(diffuse,specular,32);

 color.rgb =  temp.y + temp.z;

so i dont get a specular effect.. dunno why, does anybody see an error? thx Chicki

Share this post

Link to post
Share on other sites
The halfway vector calculation in the vertex shader looks odd to me. The halfway vector is the normalized sum of the light vector and the view vector. You seem to be missing a view vector in tangent space. Also, OUT.lightvec is in tangent space so the halfway vector (L+V) should not be transformed into tangent space "again".

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!