DarkAngel wrote:
My problem is that I need to preserve the depth buffer from the geometry stage, so that glow geometry isn't drawn in places where it should be hidden. I haven't looked at the code yet, but it seems that if my temporary glow RenderTarget has depthBuf set to true, then it will use it's own depth buffer, and if it is set to false then it won't use any depth buffer.
Is this correct? And is there a way to use the main depth buffer when rendering to my RenderTarget?
Funnily I was thinking about a similar issue very recently. It would make sense in several scenarios to share a depth buffer between render targets. Currently that is not possible with the pipelines. From GL side I also don't think that it works to share the main framebuffer depth data with a FBO. But as swift states it should be possible to share depth attachments between several FBOs. We just would need a
nice way of exposing that feature to the pipeline (call for proposals
)
A workaround for your problem could be to bind the depth texture of your temporary render target and draw a fullscreen quad to the main buffer that copies over the depth values by setting gl_FragDepth in a very small fragment shader.