I have a question for you: Is it possible to do a stencil test with an FBO when drawing geometry to the main framebuffer? I’m trying this so I can draw a skybox in my deferred renderer, I’ve read some of the forum postst on the subject, but they were not helping a lot.
My best guess would be to blit the fbo to the backbuffer and then perform the stencil test but it doesn’t seem to be working out for me. any ideas / solutions?
You should be able to blit just the stencil buffer from
the FBO to the backbuffer’s stencil buffer, provided they
are both in the same format.
Completely dodging your question, you should be able to render your skybox by simply checking against the depthbuffer.
So for example:
- clear depth+color
- render g-buffers
- calculate lighting from g-buffers, outputting into colorbuffer1
- render your skybox to colorbuffer1 (checking against your original depthbuffer)
- post-process colorbuffer1
Hope this was helpful.