I want to only let those pixels be shaded which are in the bounding volume of my light. To do that I'm planing on using a stencil test.
As suggestet in the leadwerks engine article im rendering the depth into an depth buffer texture with a fbo. If I want to compare the volume with the current depth I need to bind the depth buffer texture to the fbo depth buffer. If I want to do a deferred lighting pass I have to bind it to the shader as texture. The problem now is, that this is not possible simultaniously.
What should I do? Copy the depth buffer texture into another depth buffer texture? Or first bind the depth buffer texture as depth buffer and then to the shader? Which would result in 2 fbo changes per light. Or is it somehow possible to set the depth buffer as read-only and use it for the shader and depth buffer simultaniously?
Does someone know how they do it in the leadwerks engine?



