7.4 Depth Source

There is an internal color register in the RDP called the primitive color. A similar thing can be done with the Z value, setting a uniform depth for the entire primitive. This value is called the primitive depth. By using the primitive depth, you can render texture rectangles at a specific depth.

The primitive depth is set using the gDPSetPrimDepth command, which takes the Z value and the DeltaZ value as arguments.

 
gDPSetPrimDepth(Gfx *gdl, s32 z, s32 dz)
  gdl -- Display list pointer
z -- Z value
dz -- DeltaZ value

Use the gDPSetDepthSource command to update the Z value input source for Z values computed during rendering. When you specify G_ZS_PIXEL as the source in this command, the Z value of the polygon is utilized. When you specify G_ZS_PRIM, the primitive depth is utilized.

 
gDPSetDepthSource(Gfx *gdl, u32 source)
  gdl -- Display list pointer
source -- Depth source value
  G_ZS_PIXEL (Use each pixel's Z value and DeltaZ value)
G_ZS_PRIM (Use primitive depth register's Z value and DeltaZ value)