CHAPTER 9 ADVANCED TEXTURE MAPPING



9.1 Tiles

The RDP's TMEM has a memory capacity of 4KB, but this can be thought of as being divided into a number of blocks. Each block is called a tile, and up to 8 tiles can be utilized. Each tile can take parameters describing such things as the texture's starting position in TMEM, the texture format and the size. Together, these parameters are called the texture tile descriptor.

Figure 9-1 Tile descriptors and TMEM

The N64 can perform advanced texture processes like positioning two highlight light sources, and texture mapping with mipmaps corresponding to the model's LOD. However, to realize these kinds of processes you need to understand the concept of tiles. Thus far, all of the sample programs have made use of only one texture, so we could put programs together without paying any attention to texture tiles. Next, we will look at ways of expressing images with texture tiles, but before that we will explain a little about tiles.

You set the tile descriptor using the gDPSetTile command.

 
gDPSetTile(
  Gfx *gdl,
u32 fmt,
u32 siz,
u32 line,
u32 tmem,
u32 tile,
u32 palette,
u32 cmt,
u32 cms,
u32 maskt,
u32 masks,
u32 shiftt,
u32 shifts)

gdl   Display list pointer

fmt   Texture image format
   G_IM_FMT_RGBA(RGBA format)
 G_IM_FMT_YUV(YUV*5Format)
 G_IM_FMT_CI(CI Format)
 G_IM_FMT_IA(IA format)
 G_IM_FMT_I(I format)
  *5 The operation of YUV textures cannot be guaranteed at this time.

siz   Size of pixel components
   G_IM_SIZ_4b(4bits/1texel)
 G_IM_SIZ_8b(8bits/1texel)
 G_IM_SIZ_16b(16bits/1texel)
 G_IM_SIZ_32b (32bits/1texel)

line   Size of 1 line (s-axis) of texture tile (9bit precision, 0 - 511)

tmem   Address of texture tile origin (9bit precision, 0 - 511)

tile   Index of parameter-setting tile descriptor (3bit precision, 0 - 7)

palette   Position of palette for 4bit color index textures (4bit precision, 0 - 15)

cms   s-axis mirror, wrap, clamp flags
   G_TX_MIRROR(Enable mirroring)
 G_TX_NOMIRROR(Disable mirroring)
 G_TX_WRAP(Enable wrapping)
 G_TX_CLAMP(Enable clamping)

cmt   t-axis mirror, wrap, clamp flags
   G_TX_MIRROR(Enable mirroring)
 G_TX_NOMIRROR(Disable mirroring)
 G_TX_WRAP(Enable wrapping)
 G_TX_CLAMP(Enable clamping)

masks   s-axis mask (4bit precision, 0 - 15)
   G_TX_NOMASK (Do not mask, 0)
 Numerical value n (Mask, 1 - 15)

maskt   t-axis mask (4bit precision, 0 - 15)
   G_TX_NOMASK (Do not mask, 0)
 Numerical value n (Mask, 1 - 15)

shifts   s-coordinate shift value
   (For low-level detail textures, 4bit precision, 0 - 15)
 G_TX_NOLOD (Do not shift, 0)
 Numerical value n (Shift, 1 - 15)

shiftt   t-coordinate shift value
   (For low-level detail textures, 4bit precision, 0 - 15)
 G_TX_NOLOD(Do not shift, 0)
 Numerical value n (Shift, 1 - 15)

Many different arguments were set in the gDPLoadTextureBlock and gDPLoadTextureTile commands used in the sample programs we have seen up to now, but items like the wrapping flag and the mask value and shift value are actually set as tile descriptors.