Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 1

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.