Ocean rendering & z-fighting

Started by
2 comments, last by phr34k9 12 years, 5 months ago
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?
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.

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.
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]

This topic is closed to new replies.

Advertisement