Skip to main content
Version: 10.0

Stencil

The Stencil section gives access to the Stencil buffer and it's associated capabilities. The Stencil buffer can be used to create effects where one shader can only draw where another has rendered, or cannot render where another has already rendered.

To learn more about Stencils, visit the Unity Documentation .

Documentation info

Outline Stencil will also be visible here containing the same settings as described below. This allows you to control the Stencil behavior of the Outlines separate from the base Stencil.

Stencil Type​

Type
Dropdown
Options
SimpleFront Face vs Back Face

This controls the type of Stencil to use, whether to keep it simple or to compare it to the Front Face against the Back Face of the mesh. For the most part, this is usually set to Simple.

Stencil Reference Value​

Type
Integer
Range
0to255
Default
0

What reference value to use for the stencil test. This is the value that the stencil buffer is compared to or written from.

Stencil ReadMask Value​

Type
Integer
Range
0to255
Default
255

Value used to mask what bits of the stencil buffer are read from. This is best thought of as a binary number, which is bitwise ANDed with the stencil buffer value to determine if the read tests true.

Stencil WriteMask Value​

Type
Integer
Range
0to255
Default
255

Value used to mask what bits of the stencil buffer are read from. This is best thought of as a binary number, which is bitwise ANDed with the stencil buffer value to determine if the write tests true.

For a reference on stencil read/write masks, this thread provides some useful information.

Stencil Pass Op​

Type
Dropdown
Options
KeepZeroReplaceIncrementDecrementInvertIncrementWrapDecrementWrap

Defines the operation that the GPU performs on the Stencil buffer when a pixel passes both the Stencil test and the Depth test.

Stencil Fail Op​

Type
Dropdown
Options
KeepZeroReplaceIncrementDecrementInvertIncrementWrapDecrementWrap

Defines the operation that the GPU performs on the Stencil buffer when a pixel fails the Stencil test.

Stencil ZFail Op​

Type
Dropdown
Options
KeepZeroReplaceIncrementDecrementInvertIncrementWrapDecrementWrap

Defines the operation that the GPU performs on the Stencil buffer when a pixel passes the Stencil test, but fails the Depth test.

Stencil Compare Function​

Type
Dropdown
Options
DisabledNeverLessEqualLessEqualGreaterNotEqualGreaterEqualAlways

What comparison function to use for the stencil test. This is the function that is used to compare the reference value and the value in the stencil buffer. This can be used to create effects where the stencil buffer is used to determine if a pixel should be drawn or not.