# 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.

## 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 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".

ah thx :-)

now it works

1. 1
Rutin
25
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633311
• Total Posts
3011306
• ### Who's Online (See full list)

There are no registered users currently online

×