Clearing one stencil bit?

Started by
2 comments, last by Dentoid 21 years, 2 months ago
Hi Is there some way to clear just one stencil buffer bit? I want to do some clipping with the stencilbuffer and stencil shadow volumes at the same time. I was thinking about using one bit for the clipping, and the rest for shadows. The problem is that the clipper changes when the shadows aren''t, so I want to be able to clear the bit used for the clipper, but leaving the other bits. Is this possible somehow? I guess a fullscreen quad writing that stencil bit would do the trick, but I don''t want to waste more fillrate than I''m already doing. Appreciate tips and ideas.
Advertisement
You can use glStencilMask() to protect certain bits in the stencilbuffer from being overwritten. glStencilOp() also has a mask parameter that is AND´ed with the value read out of the stencilbuffer before applying the stencil function on it.

skynet
Ah, thanks a lot. I think glStencilMask is what I was looking for (if it also masks glClear). I''ll look into it. Thanks.
If it doesnt mask for glClear, you could always draw a quad over the screen, width colour & depth writes disabled

-----------------------
"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else''s drivers, I assume it is their fault" - John Carmack
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack

This topic is closed to new replies.

Advertisement