1
votes

I'm trying to render the stencil buffer texture via GLSL, but I can not find it possible. The stencil texture is packed together with the depth texture using the GL_DEPTH24_STENCIL8 format. I found out that you can not render that texture, at least not the stencil data but the depth data was okey to render using the x/y/z value of the texture. So I came up with the super idea of trying to blit the stencil buffer into a GL_RED texture. Is that possible in some way?

Here's how you would blit the stencil buffer from FBO1 into FBO2:

glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, FBO1 );
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, FBO2 );
glBlitFramebufferEXT(0, 0, X, Y, 0, 0, X, Y, GL_STENCIL_BUFFER_BIT, GL_NEAREST );
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);

And here is where I'm stuck. Any ideas?

1

1 Answers

2
votes

You can only blit one type of data into its own type of data. You can't blit color data into the GL_DEPTH_COMPONENT, nor can you blit the depth data into a color. And neither can you blit the stencil into a color.

The only way to do what you're wanting is with ARB_stencil_texturing, which is part of GL 4.3. Whether it may become available for your hardware depends on your hardware.