Stenciling,
like depth-buffering, enables and disables drawing on a per-fragment
basis.
- A
stencil is first created, usually by rendering primitives
- Subsequent
rendering uses the stencil to mask out portions of the screen
- Stenciling
is often used in multi-pass rendering
Source: Down to Earth StyleSimilar
to how a painter might limit drawing to a defined region using a stencil.
The
stencil buffer is stored as an additional buffer on the graphics card. Storage
is associated with each framebuffer pixel. If
enabled, the stencil buffer can be written to during rendering.
When
rendering other geometry, each fragment can be tested against the stencil
buffer
- Fragments
that pass the test are rendered
- Fragments
that fail the test are discarded
Example: Create a mask in the stencil buffer and only draw objects in the masked area.
Mirror-like
reflection off the ground plane, by multi-pass rendering.
Source: O'Reilly