setStencil method

  1. @override
void setStencil(
  1. StencilState front, {
  2. StencilState? back,
})
override

The stencil test for the draws that follow.

front applies to front-facing triangles and, when back is null, to back-facing ones as well — which is what every caller in this engine wants, and why the second is optional rather than required. A pass starts with StencilState.disabled on both faces, whatever the previous pass left, and a caller that turned the test on says setStencil(StencilState.disabled) when it is done: on a backend whose setters are global context state, the next draw inherits this one's.

Meaningful only against a depth attachment whose format TextureFormatStencil.hasStencil says carries one. Ask GraphicsDevice.supportsStencil before configuring it at all.

Implementation

@override
void setStencil(StencilState front, {StencilState? back}) {
  stencilFront = front;
  stencilBack = back ?? front;
  commands.add(RecordedStencil(front, back));
}