Skip to content

Stencil

King Arthur edited this page May 20, 2019 · 1 revision

Stencils

can be used as a general purpose per pixel mask for saving or discarding pixels. The stencil buffer is usually an 8 bit integer per pixel. The value can be written to, increment or decremented. Subsequent draw calls can test against the value, to decide if a pixel should be discarded before running the pixel shader.

Stencil Reference Value

The value to be compared against (if Comp is anything else than always) and/or the value to be written to the buffer (if either Pass, Fail or ZFail is set to replace). 0–255 integer.


Stencil ReadMask Value

An 8 bit mask as an 0–255 integer, used when comparing the reference value with the contents of the buffer (referenceValue & readMask) comparisonFunction (stencilBufferValue & readMask). Default: 255.


Stencil WriteMask Value

An 8 bit mask as an 0–255 integer, used when writing to the buffer. Note that, like other write masks, it specifies which bits of stencil buffer will be affected by write (i.e. WriteMask 0 means that no bits are affected and not that 0 will be written). Default: 255.


Stencil Pass Op

What to do with the contents of the buffer if the stencil test (and the depth test) passes. Default: keep.


Stencil Fail Op

What to do with the contents of the buffer if the stencil test fails. Default: keep.


Stencil ZFail Op

What to do with the contents of the buffer if the stencil test passes, but the depth test fails. Default: keep.


Stencil Compare Function

The function used to compare the reference value to the current contents of the buffer. Default: always.


Outline Stencil

Same as above but only effects outlines.