Sign in to follow this  
dacredens

problem with refraction/texture lookup

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

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