Reputation: 2593
OpenGL says that if depth function is GL_LESS and layout qualifier is depth_less, then OpenGL will perform the early depth test.
Now if the original value in buffer is 0.5 and if the depth for particular pixel is 0.8, it will fail the early depth test. But if we are modifying the value to 0.4 then it should not fail. How does this work in this case?
Upvotes: 3
Views: 1316
Reputation: 54642
I don't think the combination of values in your question makes sense. With the (default) GL_LESS
depth comparison function, you need to use:
layout (depth_greater) out float gl_FragDepth;
to still allow for early depth testing. With this declaration, you guarantee that, if you change the depth value in the shader, you will only make it larger.
With the GL_LESS
comparison function, fragments that fail the depth test will have depth values larger than the current value in the depth buffer. This means that the early depth test can be used without affecting the result with depth_greater
:
It's perfectly legal to use any layout qualifier with any depth function. But if you use:
layout (depth_less) out float gl_FragDepth;
with GL_LESS
, it really does not help, and early depth testing will not be used.
Upvotes: 6