Jump to content
  • Advertisement
Sign in to follow this  

problem with refraction/texture lookup

This topic is 3440 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

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 this post

Link to post
Share on other sites
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 can add more screenshots if required

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 for refraction. 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
ok problem solved - if you are trying to implement refraction, you may have to do this:

create the texture of your back buffer RT with the parameter "D3DUSAGE_AUTOGENMIPMAP" so that the device can properly sample the texture at different distances

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!