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
:
- If the early depth test is applied, it eliminates fragments with depth larger than the current value before the fragment shader.
- If the early depth test is not applied, the fragment will be processed by the fragment shader. Since it's guaranteed that the fragment shader will only make the value larger, it will still be larger than the current depth value, and will be eliminated by the depth test after the fragment shader.
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.