15.4 Z Stepper

The Z-stepper calculates an 18-bit fixed point depth value (Z) for each pixel of a primitive. The value is of Z is normally zero at the near plane and maximum at the far plane, assuming a proper g*SPViewport() command. By manipulating the g*SPViewport() command, it is possible to split the Z buffer into separate Z-planes, as shown in Figure 15-6.

Figure 15-6 Z-Buffer Planes
[Figure 15-6]

No attempt will be made to justify why one would do this, only that it is possible. Also, note that the g*SPPerspNormalize() command can be used to maximize Z precision. Please see Figure 11-2 "Perspective Normalization Calculation" for further details about g*SPPerspNormalize().

There is also a source of constant Z (from a register) that can set using the g*DPSetPrimDepth() command. To select the constant depth, use the g*DPSetDepthSource() command. This may be useful when Z buffering sprites, for example.

The Z value is subpixel-corrected so that it is always calculated on the primitive. To see why this is necessary, consider the Figure 15-7.

Figure 15-7 Subpixel Correction of Z
[Figure 15-7]

In this case, if you calculate Z at the center of the pixel, the Z value will be negative because Z will be projected behind the viewpoint. A better solution is to calculate the Z value at the subpixel, just below the center of the pixel in this case, which intersects the primitive.

UP