Your application can customize the operation of the stencil buffer. It can set the comparison function, the stencil mask, and the stencil reference value. it can also control the action that Direct3D takes when the stencil test passes or fails. For more information, see Stencil Buffer State.