4
\$\begingroup\$

I'm working on a GLSL raytracer, and I need to be able to edit gl_FragDepth in the FS. However, doing so disables early-z culling. The scene is rendered front-to-back and the FS can only push points further away, so the results of the z-test shouldn't affect the final render, even with a long pipeline.

Is there anyway to force early-z culling to run, or otherwise get around the "no fragdepth" restriction? I suppose I could do a z-test in the FS, but I'd rather let the hardware take care of it if possible.

\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

I think what you're looking for is called "Conservative Depth". There is an AMD OpenGL extension at least: GL_AMD_conservative_depth But there is also a DX11 semantic which I have used in the past and works on both vendors, although it is poorly documented. It's described here on slide 81.

As for OpenGL on NVIDIA, I'm not sure. There is GL_ARB_depth_clamp, but I don't think that will help with your situation.

EDIT: Oops, looks like AMD_conservative_depth has become ARB_conservative_depth since I last looked. So you should be good to go for most cards.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .