Jump to content
  • Advertisement
Sign in to follow this  
phr34k9

Ocean rendering & z-fighting

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

Recently I've finished an implementation of ocean-rendering using a projected-grid. The implementation is based on a paper by Claes Johanson published in 2004. The algorithm thus far seems to working out as intended and shows promising results. However from high-altitudes my landscape renderer is plagued by z-fighting artefact's i.e. the landscape bleeds through the water-plane. Naturally I've also tried out other forms of ocean rendering i.e. world-aligned grids but is also plagued by a similar forms of bleeding.

Needless to say the artifacts are bit of a deal-breaker and I would appreciate it if somebody could explain how you can circumvent or minimize the bleeding. So far I've attempted a few things such as dynamic rescaling of the vanishing points, performing depth comparison in linear-space, soft edge saturation. But none of these techniques thus far showed any 'significant' potential to remedy the bleeding. Any thoughts/pointers of
things i should (re)consider?

Share this post


Link to post
Share on other sites
Advertisement
if you look top-down from far distance, render the water first without writing to the zbuffer and while rendering your terrain, use 'clip'/'kill' to reject all pixels <water level in the pixelshader using the worldspace height.

this way you avoid all the projection related issues.

Share this post


Link to post
Share on other sites
Yeah depth buffer precision can be a bitch. If you manually output depth from the fragment shader you can use whatever depth distribution you want, and completely avoid most precision-related issues. But this means no early z-cull, which is bad is you care about performance. Another trick is to use a floating point depth buffer, and flip the near and far planes when creating your projection. This causes the natural distribution of precision in floating point values to (somewhat) cancel out the non-linear distribution you get from a perspective projection.

Share this post


Link to post
Share on other sites
Thanks for your advice. After researching that far-/near- swap trick I ended up reading an old post of MJP regarding depth-buffer related techniques. That thread eventually lead me to a blog-post of Outerra http://outerra.blogs.../depth%20buffer and I think that's an quite appropriate technique.


Yeah depth buffer precision can be a bitch. If you manually output depth from the fragment shader you can use whatever depth distribution you want, and completely avoid most precision-related issues. But this means no early z-cull, which is bad is you care about performance. Another trick is to use a floating point depth buffer, and flip the near and far planes when creating your projection. This causes the natural distribution of precision in floating point values to (somewhat) cancel out the non-linear distribution you get from a perspective projection.
[/quote]

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!