modified depth and early-z-cull

Started by
3 comments, last by Zelcious 16 years, 2 months ago
A most intricate problem that seems to show up again and again for me: I need to draw lots and lots of small objects. In the fragment shader I could modify the fragments depth so it could be deaper into the scene but will never move the closer to the camera. If the hardware would know this it could use early-z-cull but in reality as soon as you modify the depth of a fragment you shut down early-z-cull. Is there some way to emulate this functionality, because I really need the speed early-z-cull would provide. (Potentially have very large amount of overdraw) /David
Advertisement
I'm 99% sure you can't force early Z-culling on, because that would require two depth tests in the worst case - one for early Z-culling, and a second after you modify the depth -- and I'm fairly certain the pipeline doesn't handle that.

If you can, maybe try using a Z pre-pass instead. That way you only encounter the heavy overdraw when writing depth (which is really fast, since framebuffer writes seem to be the big bottleneck).
Quote:Original post by Zipster
If you can, maybe try using a Z pre-pass instead. That way you only encounter the heavy overdraw when writing depth (which is really fast, since framebuffer writes seem to be the big bottleneck).


Don't think that will be possible for me. I do a expensive raymarching inside the shader, don't want to do that twice.
In the z-pre pass you don't do anything complex, just write the linear eye-depth into a render target (if necessary at all, just something for pre-filling the depth buffer)
Quote:Original post by FoxHunter2
In the z-pre pass you don't do anything complex, just write the linear eye-depth into a render target (if necessary at all, just something for pre-filling the depth buffer)


What will that help me, in the later more complex pass when I modify depth I still won't be using early-z-cull, per definition. Also I need to place a limit on how much I can add to the depth (Takes some thought)
If I do the raymarching in the z-pre pass I will get no early-z-cull, even if store the depth in second render target and reuse it I probably will get worse performance.


To better explain the problem. I need to render lots of small objects. The objects polygonal mesh will provide a bounding box for a raytrace so, depth for each fragment on the hull could be offset an amount into to object thereby adding an POSITIVE offset to the depth for each fragment. I need to write this depth to the depth buffer so that the objects will intersect correctly but I also want to use early-z-cull to avoid any unecessary raymarching.

This topic is closed to new replies.

Advertisement