# problem with refraction/texture lookup

## Recommended Posts

dacredens    128
hey I'm trying to implement a refraction water effect using this approach: http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter19.html 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 http://dacredens.googlepages.com/untitled.JPG http://dacredens.googlepages.com/untitled2.JPG 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 on other sites
Viik    252
Post a code where you calculate and use refrection and how your scene looks with/without water.

##### Share on other sites
dacredens    128
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 * tsB.xyz) - 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 = vBumpTex.xyz * half3(0.075,0.075,1.0);	half3 vReflBump = vBumpTex.xyz * 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 on other sites
dacredens    128
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 on other sites
Viik    252
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 on other sites
dacredens    128
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 :)