Type:StencilOperation

From Resonite Wiki
Revision as of 21:29, 15 January 2024 by LuxKitty (talk | contribs) (Created Type:StencilOperation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

StencilOperation is an Enum which describes the operation that is performed during a Stencil test.

It can take on the following possible values:

  • Keep - (Default) Keep the currently stored stencil value
  • Zero - Set the stencil value to 0
  • Replace - Set the stencil value to the given StencilID
  • IncrementSaturate - Increment the stencil value up to its maximum 255, after which the value will stay 255
  • DecrementSaturate - Decrement the stencil value down to its minimum 0, after which the value will stay 0
  • Invert - Perform a bitwise inversion on the current stencil value
  • IncrementWrap - Increment the stencil value, wrapping back around to 0 once it reaches 255
  • DecrementWrap - Decrement the stencil value, wrapping back around to 255 once it reaches 0

Usage

There are many modes of operation which allow for very complex behavior.

The simplest operations are Keep, Zero, and Replace:

  • Keep is often used in order to preserve an existing stencil value. This is the default behavior, however when used in conjunction with other StencilComparison modes, it can be used to stack materials/filters in the same region.
  • Zero is often used to prevent overlapping materials.
  • Replace is used to immediately set an exact known stencil value. This is used for creating an exact mask area which another material will exist in.

The other more complex modes are less common, however their uses are much more varied.