Writting to the Stencil of a Depth buffer on a FBO

Hey everyone!

I have a FBO with an attached 32-bit depth buffer. From what i know, that depth buffer “includes” an 8-bit stencil buffer as well. What i want to accomplish, is to be able to access and write to the stencil buffer from inside a shader (i want to use the space for non-stencil purposes).

Is that possible in any way if the depth buffer is attached to a GL_DEPTH_ATTACHMENT point?

If not, the other possiblity would be to attach the “depth buffer” to a GL_COLOR_ATTACHMENT point. If i do that, how do i access the depth value and stencil value? Also, what sort of depth value do i have to store in the buffer for proper usage as a shadow map later on (through shadow2DProj etc)? Does it have to be the fragment’s Z-value, Z/W value or something else?

Thanks in advance!

You can’t read or write stencil data from the shader.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.