Skip to main content
13 votes

Uses for Stencil Buffer

The original use for the stencil buffer was for non-3D content. Say you're making a 3D game. Most of the screen is the 3D content, but you also have some GUI around the outside which is not drawn ...
Dan Hulme's user avatar
  • 6,810
7 votes

Uses for Stencil Buffer

Another use, that I think Dan didn't mention, is for filling non-convex polygons, e.g, and The stencil can be used to implement the fill rule which is typically either odd/even (as used in these ...
Simon F's user avatar
  • 4,241
3 votes

Is it possible to fill in Stencil Buffer programmatically via fragment shader?

There are a few confusing statements in your question. However, I'll still assume you're largely aware of how the stencil buffer and the stencil test actually work. I'll also talk about OpenGL, based ...
Christian Rau's user avatar
2 votes

Are stencil buffer dimensions required to match render target dimensions?

When the framebuffer attachment sizes differ, rendering will only happen to the smallest size supported by all attachments (i.e. a rectangle of minimal width & height among all the attachments). ...
lisyarus's user avatar
  • 225
2 votes

Incorrect values written in stencil buffer

OK, so this not really an answer, rather just sharing what I have learned. To clarify, shape of the object has nothing to do with this problem at all. Be it a triangle or rectangle, and wherever you ...
Sayan Pal's user avatar
  • 263
1 vote

Problem using Decaling with Stencil to avoid Z-fighting

It sounds like this code is using the stencil buffer to mask off the locations to draw the line. This isn't a "typical" decal approach. Normally the decal is draw directly into the scene and ...
pmw1234's user avatar
  • 3,219
1 vote

Layer rendering in Vulkan

I think you may be overcomplicating things with your idea of using the stencil. In 2D graphics layers, we usually do not need to use the depth buffer to resolve depth order between 2D elements (their ...
Nathan Reed's user avatar
1 vote

Fast clipping without clearing stencil buffer

It sounds like what you need is a scissor test. It's specifically designed for clipping against an unrotated rectangle, and should be faster than messing about with the stencil buffer.
russ's user avatar
  • 2,392

Only top scored, non community-wiki answers of a minimum length are eligible