Write Test

The write test takes generated fragment information as reference values to determine whether to actually write the fragment data to the framebuffer. This is carried out on each fragment separately

Criteria are set for the evaluation of fragments, and those that do not fully meet the conditions are excluded from rendering.

Table 1 Types of Write Tests

Type Description
Alpha test An alpha test compares a fragment's alpha value with the reference value set for the alpha test.
Stencil test A stencil test compares the value set here for the fragment stencil test with the value in the stencil buffer to write to.
If the fragment passes, the value in the stencil buffer is overwritten with the fragment value.
Depth test A depth test compares the per-fragment depth value indicating the distance from the camera with the value in the depth buffer to write to.
If the fragment passes, the value in the depth buffer is overwritten with the fragment value.

Note: Write tests are carried out in order of Alpha test → Stencil test → Depth test.

Note: Using write tests increases processor load. Consequently, all fragment tests and operations are disabled by default.

Alpha test

The Alpha test compares the alpha value of a fragment against the Alpha test reference value to determine whether to use that fragment.

Usage:
This is used to express translucency in textures and other images that use alpha values.

Alpha Test Comparison Functions

The Alpha test involves equations that are used to compare the alpha value with a reference value.

With CreativeStudio, you can select from eight different comparison functions.

Table 2 The different Alpha test comparison functions

Comparison function Function Name Description
Alpha value < Reference value LESS Passes test if the fragment alpha value is less than the reference value.
Alpha value ≦ Reference value L_EQUAL Passes test if the fragment alpha value is less than or equal to the reference value.
Alpha value = Reference value EQUAL Passes test if the fragment alpha value is equal to the reference value.
Alpha value ≧ Reference value G_EQUAL Passes test if the fragment alpha value is greater than or equal to the reference value.
Alpha value > Reference value GREATER Passes test if the fragment alpha value is greater than the reference value.
Alpha value ≠ Reference value NOT_EQUAL Passes test if the fragment alpha value is not equal to the reference value.
Pass-through all ALWAYS Always passes the test.
Pass-through none NEVER Never passes the test.

Fig. 1 The Alpha test process

Alpha test

Stencil test

The Stencil test compares the stencil buffer value against a reference stencil value to determine whether to use that fragment.

Note: In CreativeStudio, the Stencil test settings are configured on the material Properties panel in Details mode.

If a fragment has passed through, its value can be used to update the stencil buffer.

Usage:
The stencil test is primarily used for masking to limit the region being rendered.

Stencil Test Comparison Functions

The Stencil test involves equations that are used to compare the stencil buffer value with a reference value.

With CreativeStudio, you can select from eight different comparison functions.

Table 3 The different Stencil test comparison functions

Comparison function Function Name Description
All fail NEVER Never passes.
All pass ALWAYS Always passes.
Pass if less than the stencil buffer value LESS Passes if the reference value is less than the stencil buffer value.
Pass if less than or equal to stencil buffer value L_EQUAL Passes if the reference value is less than or equal to the stencil buffer value.
Pass if equal to stencil buffer value EQUAL Passes if the reference value is equal to the stencil buffer value.
Pass if greater than or equal to stencil buffer value G_EQUAL Passes if the reference value is greater than or equal to the stencil buffer value.
Pass if greater than stencil buffer value GREATER Passes if the reference value is greater than the stencil buffer value.
Pass if not equal to stencil buffer value NOT_EQUAL Passes if the reference value is not equal to the stencil buffer value.

Fig. 2 The Stencil test process

Stencil test

Detailed Control of the Stencil Test

Test mask

You can specify a range of values for the Stencil test by using a test mask.

The default value is 255, which specifies the entire range.

Process for Stencil test and Depth test results

You can configure which processes to run on the Stencil test and Depth test results.

Table 4 Results of Stencil test and Depth test

Item Description
When the stencil test fails This is the processing when a fragment fails the stencil test. Subsequent depth test processing is not carried out.
When the depth test fails This is the processing when a fragment has been determined for use by the stencil test, but fails the depth test.
When the depth test succeeds This is the processing when a fragment has been determined for use by both the stencil test and depth test.

When the above applies for the test results, CreativeStudio lets you select from the following eight functions to operate on the stencil value.

Table 5 Functions that can operate on stencil values

Item Function Name Description
Store current value KEEP This is the default setting. Stores the current stencil value. The stencil buffer value is not updated.
Replace with zero ZERO Updates the stencil buffer value to 0.
Replace with reference value REPLACE Updates the stencil buffer value using the stencil test reference value.
Increase (extreme: clamp) INCR Increases the stencil buffer value by 1.
The stencil value is clamped to 0 or 1 less than the nth power of 2. (Where n is the number of bits of the stencil buffer.)
Increase (extreme: wraparound) INCR_WRAP Increases the stencil buffer value by 1.
However, if the stencil buffer value exceeds 1 and is increased, the value is wrapped.
Decrease (extreme: clamp) DECR Decreases the stencil buffer value by 1.
The stencil value is clamped to 0 or 1 less than the nth power of 2. (Where n is the number of bits of the stencil buffer.)
Decrease (extreme: wraparound) DECR_WRAP Decreases the stencil buffer value by 1.
However, if the stencil buffer value exceeds 0 and is decreased, the value is wrapped.
Invert all bits INVERT Inverts the stencil buffer value at the bit unit level.

Depth test

The Depth test compares the depth value of a fragment against a depth value in the depth buffer to determine whether to use that fragment.

Fragments that have passed through the Depth test undergo a blender process and are written to the framebuffer.

If depth mask has been enabled, the depth buffer can be updated using the depth value of a fragment that has passed through.

Usage:
This is usually used for hidden surface removal, in which hidden polygons are excluded from processing.

Depth Test Comparison Functions

The Depth test involves equations that are used to compare the Depth value with the value in the depth buffer.

With CreativeStudio, you can select from eight different comparison functions.

Table 6 The different Depth test comparison functions

Comparison function Function Name Description
Depth value < Depth buffer value LESS Passes test if the depth value of the fragment is less than the depth buffer value.
Depth value ≦ Depth buffer value L_EQUAL Passes test if the depth value of the fragment is less than or equal to the depth buffer value.
Depth value = Depth buffer value EQUAL Passes test if the depth value of the fragment is equal to the depth buffer value.
Depth value ≧ Depth buffer value G_EQUAL Passes test if the depth value of the fragment is greater than or equal to the depth buffer value.
Depth value > Depth buffer value GREATER Passes test if the depth value of the fragment is greater than the depth buffer value.
Depth value ≠ Depth buffer value NOT_EQUAL Passes test if the depth value of the fragment is not equal to the depth buffer value.
Pass-through all ALWAYS Always passes the test.
Pass-through none NEVER Never passes the test.

Fig. 3 The Depth test process

Depth test

CONFIDENTIAL