Jump to content
  • Advertisement
Sign in to follow this  
Jossos

Issues with comparing depth textures

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

I'm following a tutorial, trying to blur the edges of water, but I'm getting weird jaggies which I just can't seem to get rid of:

 

nhZGCQy.jpg

 

This is caused by the depth texture ("depthMap") having a lower resolution than the screen, which I want for optimization. Here is the shader: http://pastebin.com/QfZHBttT

 

Noteable parts:

    float depth = texture2D(depthMap, refractUV).r;
    float floorDistance = 2.0 * near * far / (far + near - (2.0 * depth - 1.0) * (far - near));
    if (depth >= 1.0)
        discard;  // This never works
       
    depth = gl_FragCoord.z;
    float waterDistance = 2.0 * near * far / (far + near - (2.0 * depth - 1.0) * (far - near));
    float waterDepth = floorDistance - waterDistance;




FragColor.r = waterDepth;  // using this to show what's going on.

I am not sure how to fix this. I just need those edge pixels to be invisible. They appear at any time the resolution of the depth texture is lower than the screen.

 

Any help is appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Could you describe your pipeline? I can only gather so much from what you have but it seems like this is what you are doing.

1. Render underwater geometry at a lower resolution off screen
2. Render world geometry at full resolution
3. Render water at full resolution using off screen data from stage 1

Is this correct?

Share this post


Link to post
Share on other sites

Could you describe your pipeline? I can only gather so much from what you have but it seems like this is what you are doing.

1. Render underwater geometry at a lower resolution off screen
2. Render world geometry at full resolution
3. Render water at full resolution using off screen data from stage 1

Is this correct?

 

I think so. I have refraction/reflection textures rendered at 1/4 of the screen resolution, as well as the depth. I then render full screen at full resolution, comparing gl_fragcoords.z with the depth texture (which is at 1/4 resolution)

Share this post


Link to post
Share on other sites

This sounds like it could be fixed by a cross bilateral-upsample shader.

 

see http://docs.nvidia.com/gameworks/content/gameworkslibrary/graphicssamples/opengl_samples/particleupsamplingsample.htm

for how a similar low-res/high-res buffer composition system works.

 

This technique helped with these artifacts when I composited a lower-resolution volume lighting buffer with a full resolution scene rendering.

 

- CStone

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!