View Full Version : Framebuffer see through

10-31-2006, 08:40 AM
I have a frame buffer where I draw a opaque object then a semi-transparent object over it. This works fine, when I send it to a frame buffer to show through a card. That semi-transparent object makes my opaque object semi-transparent. I think what it is doing is reading the alpha value in that spot as of the semi-transparent object and setting those pixels to that value and ignoring that it has an opaque object. Is there anything I can do to fix this?

10-31-2006, 01:43 PM
1. Before rendering, clear the stencil buffer
2. When rendering opaque objects set stencil func to GL_ALWAYS and stencil op to 3x GL_REPLACE
3. When rendering transparent set stencil func to GL_NEVER
4. Finally draw a fullscreen quad with alpha=255, stencil func set to GL_EQUAL and color mask set to GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE - this will replace alpha values for all pixels on the screen that had opaque object drawn.