Sign in to follow this  

problem with refraction/texture lookup

Recommended Posts

hey I'm trying to implement a refraction water effect using this approach: the trouble I'm having is this; when I sample the normal map for the water, i use components from the color vector to offset my lookup into the render target that represents my underwater geometry. It half works in that portions of the effect work but other areas just show horrible white sections with black stripes I've captured two screenshots showing use of different normal maps i suspect this has something to do with the way I setup or use certain RT's - any other ideas or solutions to this problem are welcome :)

Share this post

Link to post
Share on other sites
Hi, this is what my pixel shader for the refract effect looks like:
(note Ive modified it within my internet browser so there *could* be a syntax error lurking around in it)

PS_OUTPUT ps_ShadeA( VS_OUTPUT input)
PS_OUTPUT output = (PS_OUTPUT)0;

float3 camDir = input.camDir;

float3 surNorm = input.normal + (.5 * - 1;

camDir = normalize(camDir);
surNorm = normalize(surNorm);

float3 indexNorm = reflect(camDir, surNorm);

.... //other stuff

half3 vBumpTexA = tex2D(TSB, input.texCoordA).xyz; //TSB in the wave normal map
half3 vBumpTex = (.5 * vBumpTexA) - 1;

half3 vRefrBump = * half3(0.075,0.075,1.0);
half3 vReflBump = * half3(0.2,0.2,1.0);
half2 vProj = ScreenProjToTexCoord(input.position);

half4 vRefraction = tex2D(TSUnderWaterGeometry, vProj.xy + vRefrBump.xy);

output.color = vRefraction;
output.color.w = 0;

return output;

I will try and get some screenshots as requested asap

Share this post

Link to post
Share on other sites
ok I've played around a bit more and have reached this stage. I am unhappy with the horrible artifacts that appear on the water - these seem similar to the previously mentioned artifacts

Scene without water:

Scene with water, note the artifacts that are appearing at certian parts all over the water

Share this post

Link to post
Share on other sites
Your vRefrBump.xy values might be too big, so white background is samlped from refraction texture.
Just for test use a sinple black and white cheker texture for ground you'll see how much refraction it gets.

Share this post

Link to post
Share on other sites
hi - this seems to be a complicated problem to do with sampling. Here I have used a checker texture. As you can see, the problems occour on high contrast boundries in the texture. Elsewhere it seems correct. Any help is much appreciated :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this