NiStencilProperty

From GECK
Jump to: navigation, search

NiStencilProperty allows you to enable a stencil buffer for your object, enabling you to draw objects over others that are between it and the camera, as well as allowing you to disable backface culling.

A typical example of a NiStencilProperty.



Specifics

Its fields are:

  • Name: The name of this NiStencilProperty.
  • Num Extra Data List: Total number of Extra Data blocks.
  • Extra Data List: Extra Data blocks can go here.
  • Controller: A controller could go here, but none seem applicable.
  • Flags: If the stencil buffer is enabled, what happens when pixels pass or fail the stencil test, how the test is checked, and the draw mode of the geometry.
  • Stencil Ref: The stencil reference value, which is compared against the stencil value per pixel to determine whether or not it passes the test.
  • Stencil Mask: The stencil buffer mask value, which is combined with the reference and stencil values prior to comparing with the contents of the buffer.

Flags

Pixels that fail or pass the stencil test can have different results depending on the action chosen.

Action Description
Keep Keeps the current value in the stencil buffer.
Zero Writes zero to the stencil buffer.
Replace Writes the reference value to the stencil buffer.
Increment Increments the value in the stencil buffer.
Decrement Decrements the value in the stencil buffer.
Invert Inverts the value bit-wise in the stencil buffer.

How the values pass the test is determined by the stencil function.

Function Description
Never The test is never passed.
Less The test is passed if the reference value is lesser than the buffer value.
Equal The test is passed if the reference value is equal to the buffer value.
Less or Equal The test is passed if the reference value is less or equal to the buffer value.
Greater The test is passed if the reference value is greater than the buffer value.
Not Equal The test is passed if the reference value is not equal to the buffer value.
Greater or Equal The test is passed if the reference value is equal or greater than the buffer value.
Always The test is always passed.

Additionally, how the triangles are drawn can be determined. Gamebryo really wants geometry to be made counter-clockwise and most programs export it as such, so you shouldn't ever really need to set it to draw clockwise.

Draw Mode Description
Counter clock wise or Both Draws geometry whose vertices are ordered counter-clockwise with respect to the viewer or without care of orientation, effectively double-siding geometry.
Draw counter clock wise Only draws geometry whose vertices are ordered counter-clockwise with respect to the viewer.
Draw clock wise Only draws geometry whose vertices are ordered clockwise with respect to the viewer.
Draw Both Disables backface culling, drawing both sides of the geometry.

Notes

  • In order to use the Zbuffer with a stencil, both the object with the NiStencilProperty and the object(s) you wish to test against must have BSNoLightingShaderProperties with the Zbuffer_Test flag enabled.

See Also