Archived

This topic is now archived and is closed to further replies.

Depth stencil buffers, z-buffers, stencil bits, and alot of confusion

This topic is 5147 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can someone explain what a stencil bit is? and what significance it has with regard to z-buffers, or depth buffers in general. What is the difference between a depth stencil buffer and a z-buffer? [edited by - quant on November 9, 2003 7:34:20 AM]

Share this post


Link to post
Share on other sites
There are 2 things that link a z-buffer to the stencil buffer.
- they share the same bits. When you have a 32bit buffer, often this is shared by 24bits for depth, and 8bit for the stencil. This is only important when setting up your window.
- the stencil operation.

If you''re new to the stencil buffer. It''s actually a hidden buffer you cannot see. Its more special than a depth buffer because you can do more complex operations on the stencil.
Check glStencilFunc(), glStencilOp(), glStencilMask() in your help.
I believe NeHe has some clear and simple stencil-ing stuff

Share this post


Link to post
Share on other sites
As baskuenen said,NeHe has some great tutorials concerning stencil buffers.

Stencil buffers are used for many special effects, like shadow volume or reflections. Look for those tutorials on NeHe''s site and you should be able understand the use of z-buffers and stencil buffers.

Share this post


Link to post
Share on other sites
Unfortunately, this is a DirectX forum, so I doubt those will help tremendously Anyway, the stencil buffer is basically an integer buffer (as opposed to the depth buffer with is a real [float] buffer) that coincides with the depth buffer. It is updated at a pixel level (like the depth buffer) but it is made for programmer use. Therefore, you control the operations performed on the buffer as you render primitives (like ''increment the buffer'' or ''clear to zero'') to perform other more complicated expressions like ''render this pixel iff the stencil buffer is set to one''. You would use the stencil buffer in a stencil shadow algorithm (duuuuh...) and a decal system (iff stencil == 0, render wall, otherwise render decal), though the possibilities are endless.

Chris Pergrossi
My Realm | "Good Morning, Dave"

Share this post


Link to post
Share on other sites