PDA

View Full Version : Nothing written to FBO depth



aph3x
12-02-2010, 05:18 AM
Hi all,

I have some FBO shadow code that works fine in my game. On integrating the code into another game (same machine) it's failing to write anything to the FBO depth buffer (all vals exactly 1.0 == far val).
I've dumped the FBO colour buffer and that has the expected geometry rendered on it - but nothing is getting written to the depth attachment.
The code definitely works fine in the other app.

Have checked:
- GL window PIXELFORMATDESCRIPTOR - all same.
- Call glDisable(GL_DEPTH_TEST), glDepthMask(GL_TRUE) & glDisable(GL_CULL_FACE) before rendering.
- Set glDepthFunc(GL_LEQUAL)

Been tearing hair out for a few days now :(
Can anyone think of any GL settings this other app may be meddling with to result in this problem?!

BionicBytes
12-02-2010, 07:40 AM
Aren't you suposed to enable depth test otherwise nothing is written to depth texture.

aph3x
12-02-2010, 09:00 AM
Bloody hell! And there's me thinking I knew exactly what disabling GL_DEPTH_TEST did. Apparently not :eek:
[ed] Although the red book doesn't make it clear at all :(

Dark Photon
12-02-2010, 06:02 PM
Bloody hell! And there's me thinking I knew exactly what disabling GL_DEPTH_TEST did. Apparently not :eek:
[ed] Although the red book doesn't make it clear at all :(
Yeah, I agree with you. Been there. :p That feature is just odd. Intuitively, seems like DEPTH_TEST and DepthMask should be independent, not chained.

Alfonse Reinheart
12-02-2010, 09:02 PM
They are independent. Disabling depth test should not disable depth writing. This is more than likely some kind of driver bug or just user error.

mfort
12-02-2010, 11:55 PM
They are independent. Disabling depth test should not disable depth writing. This is more than likely some kind of driver bug or just user error.

They are not independent. OGL specification is quite clear:

GL_DEPTH_TEST - If enabled, do depth comparisons and update the depth buffer. Note that even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled.

Alfonse Reinheart
12-03-2010, 12:26 AM
OGL specification is quite clear

Well you're right that the spec does require this (though you're quoting from the man-pages, which are not normative). The 3.2 core specification says, in section 4.1.5:


When disabled, the depth comparison and subsequent possible updates to the depth buffer value are bypassed and the fragment is passed to the next operation. The stencil value, however, is modified as indicated below as if the depth buffer test passed. If enabled, the comparison takes place and the depth buffer and stencil value may subsequently be modified.

And I have to agree with Dark Photon that this is stupid. It may explain why GL_ALWAYS exists, but that's no excuse.

mfort
12-03-2010, 01:52 AM
Reference pages are not normative but very informative. I agree the wording in OGL Spec is quite complicated.