Z-Buffering Texture Rectangles

Normally, sprites are rendered in a Z sorted list and rendered from back to front. The Z of each sprite must be maintained by the application and the application must do the sort each frame. Another technique is to use the z-buffer to determine priority.

Primitive Z
The texture rectangle has no Z value associated with it directly, however you can use the primitive Z register (g*DPSetPrimDepth( )). To force the z-buffer logic to use primitive Z rather than pixel Z, you must use the following command:

gsDPSetDepthSource(G_ZS_PRIM)

You must also use a RenderMode that enables z-buffering, such as G_RM_ZB_OPA_SURF. To z-buffer sprites, you would have to insert a g*DPSetPrimDepth() command before the rectangle command of each sprite. Because the primitive Z is explicitly buffered in the pipeline, it is not necessary to insert pipe sync commands before setting the register.

Note that z-buffering can only be used in 1 and 2-cycle mode. In copy and fill mode, you should use the RenderMode G_RM_NOOP to effectively disable z-buffering and put the pipeline logic in a safe state.

Copyright © 1999
Nintendo of America Inc. All Rights Reserved
Nintendo and N64 are registered trademarks of Nintendo
Last Updated January, 1999