Graphics Reference
In-Depth Information
Figure 3.81. The bit registers for each of the arguments of the stencil test.
Because this test is highly configurable, it can be difficult to visualize how it operates.
To help clarify this functionality, we will provide a small example scenario for a single
fragment being passed through the stencil test. In this case, the stencil reference value will
have bits 0, 1, and 3 set, while the stencil buffer has bits 1 and 2 set. The stencil mask has
bits 0 and 1 set. These values are depicted in Figure 3.81.
Depending on which comparison function is chosen, a different result can be found
for the stencil test. For example, if D3D11_COMPARIS0N_LESS is used, the stencil test would
fail since the left side of the equation is greater than the right side. Of course, this function
could be reversed if D3D11_C0MPARIS0N_GREATER were used instead. The available com-
parison functions are shown in Listing 3.28.
enum D3Dll_COMPARISON_FUNC {
D3D11_C0MPARIS0N_NEVER,
D3D11_C0MPARIS0N_LESS,
D3Dll_COMPARISON_EQUAL,
D3Dll_COMPARISON_LESS_EQUAL,
D3Dll_COMPARISON_GREATER,
D3Dll_COMPARISON_NOT_EQUAL,
D3D11_C0MPARIS0N_GREATER_EQUAL,
D3D11_C0MPARIS0N_ALWAYS
}
Listing 3.28. The D3D11_COMPARISON_FUNC enumeration.
Considering the ability to specify the stencil reference value, the stencil mask, and
the comparison function, the developer has more or less complete control over how the
stencil test will operate. After the test has completed, some action needs to be taken, de-
pending on if the test has passed or failed. In fact, the action taken relies on both the stencil
test result and the depth test result (which we will discuss in the next section). In keeping
Search WWH ::




Custom Search