openglframebufferrender-to-texturedepth-bufferdeferred-shading

How to use texture as depth attachment?


I have a framebuffer with multiple render targets. All of them are textures and not renderbuffers. How can I use the A component of a RGBA texture as depth attachment? I want to use the default depth test.


Solution

  • The alpha is not a depth component. And only images who's formats have a depth component can be bound to GL_DEPTH_ATTACHMENT.

    And before you ask, there is no RGB_DEPTH_COMPONENT format.

    There's no reason you can't create a texture with GL_DEPTH_COMPONENT24.