GXSetZTexture

Syntax

#include <revolution/gx.h>

void GXSetZTexture( 
    GXZTexOp    op, 
    GXTexFmt    fmt, 
    u32         bias );

Arguments

op Specifies the Z texture operation. Accepted values are:
Name Z Texture Mode
GX_ZT_DISABLE Disables Z textures.
GX_ZT_ADD The Z texture is added to the original reference Z.
GX_ZT_REPLACE The Z texture replaces the original reference Z.
fmt The format for Z. Accepted values are:
Name Z Texture Format
GX_TF_Z8 8-bit Z
GX_TF_Z16 16-bit Z
GX_TF_Z24X8 24-bit Z
bias The bias. The format is u24, right-aligned.

Return Values

None.

Description

This function controls Z texture operations. Z textures can be used to implement image-based rendering algorithms. A composite image consisting of color and depth image planes can be merged into the embedded frame buffer (EFB).

Normally, the Z for a quad (2x2) of pixels is calculated as a reference Z and two slopes. Once Z texturing is enabled, the Z value is calculated by adding a Z texel to the reference Z value (op = GX_ZT_ADD), or by replacing the reference Z value with the Z texel value (op = GX_ZT_REPLACE).

When enabled, Z textures are always the output from the last active texture environment (TEV) stage (see the GXSetNumTevStages function). When Z texturing is enabled, the texture color of the last TEV stage is not available, but all other color inputs and operations are. The pixel color is always output from the last active TEV stage. TEV processes cannot be used on Z textures. Z textures are handed directly to the Z texture logic.

Z texel formats can be unsigned 8-bit (GX_TF_Z8), 16-bit (GX_TF_Z16) or 24-bit (GX_TF_Z24X8 (32-bit texture)). The graphics processor converts Z-textures to 24-bit values by placing the texel value in the least-significant bits and zeroing any remaining higher bits. The 24-bit constant bias is added to the Z texture. If the pixel format is GX_PF_RGB565_Z16, the 24-bit result is converted to the current 16-bit Z format before comparison against the EFB Z value.

Z-texture calculations are done before fog range interpolations.

The GXInit function disables Z texturing.

See Also

GXSetNumTevStages, GXSetTevOrder, GXInitTexObj

Revision History

2008/05/12 Corrected the old function name, GXSetTevStages, to the new name, GXSetNumTevStages.

2006/03/01 Initial version.


CONFIDENTIAL