Z-Testing

Z-Testing This node modifies the depth information that is written by geometries into the depth buffer (Z-Buffer).

The Z-Buffer (also called Depth Buffer) is used to determine object occlusion during Rasterization. During rendering of a triangle, the Z-value of a given pixel is compared to the value stored in the Z-Buffer. Based on the Z-testing function, the triangle either is allowed to overdraw the pixel or not.

The default behavior is to accept pixel that have a Z-value that is smaller or the same as the value in the Z-Buffer, making objects closer to the camera occlude objects which are farther away. While it may seem weird at first to ever use something that is different from the default (and in the majority of cases this is the best option), using different comparison functions can be used to create interesting rendering effects.

The Z-Testing Node can influence the above decision in multiple ways. The Enabled property can be deactivated to do no Z-testing at all for all child nodes. The Write property can be deactivated to just perform the Z-test but not update the values in the Z-buffer once a pixel is rendered. Even the function itself can be changed to one of the following settings:

In certain situations like rendering a wireframe overlay over a solid object, visual artifacts due to Z-fighting problems can be avoided by adding a small offset to the Z value calculated for a pixel. This offset is only used for the Z-testing comparison. If the pixel is drawn and updates the Z-Buffer, the original Z-value will be used.
This offset is specified by a fixed offset called Bias and a variable offset called Slope that is multiplied with the maximum depth value of the triangle being rendered. The latter can be used to adapt the offset with the distance from the camera, countering Z-Buffer resolution issues.