Hey,
I got a water reflection that stretches over a big quad made by two triangles. What I want to do now is distort the pixels on the water to make it look like the water is moving (waves). How can I do this using a vertexshader/pixelshader (HLSL)?
My vertexshader looks like this:
vertexOutput VS_TransformAndTexture(vertexInput IN)
{
vertexOutput OUT;
// This does projective texturing
OUT.pos = mul(float4(IN.position.xyz , 1.0), worldViewProj);
OUT.project.x = 0.5 * (OUT.pos.w + OUT.pos.x);
OUT.project.y = 0.5 * (OUT.pos.w - OUT.pos.y);
OUT.project.z = OUT.pos.w;
OUT.color = IN.diffuseColor;
return OUT;
}
... and my pixelshader looks like this:
float4 PS_Textured( vertexOutput IN): COLOR
{
float2 projcoord = (IN.project.xy / IN.project.z);
float4 reflect = tex2D(TextureSampler, projcoord);
return reflect;
}
The result I would like to make it look something like this:
Water sample
Thanks in advance!
[Edited by - kobingo on May 9, 2006 12:29:14 PM]