Texture Types
Intensity (I) Textures
Example 14-19 Intensity Texture Modulating Primitive Color
Intensity textures are useful because they are quite compact and should be used in cases where a large number of colors is not necessary. For example, a 4-bit I texture can be as large as 128x64 texels. Normally, the user would like the primitive to have some specific color, and the I texture should modulate that color. For example, to create a tree you could use two I textures, one for the brown trunk and one for the green treetop. You can use one of the many register colors in the color combiner to define the primitive color. In Example 14-19 we use primitive color to define the colors of the trunk and treetop.
gsDPSetCombineMode(G_CC_MODULATEI_PRIM, G_CC_MODULATEI_PRIM),
gsDPSetPrimColor(0, 0, 205, 51, 51, 255), /* brown */
gsDPLoadTextureTile_4b(trunk, G_IM_FMT_I, 16, 40,
0, 0, 15, 39,
0,
G_TX_MIRROR, G_TX_CLAMP,
4, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD),
gsSPTextureRectangle(50 << 2, 100 << 2, 82 << 2, 140 << 2,
G_TX_RENDERTILE,
0, 0,
1 << 10, 1 << 10),
gsDPSetPrimColor(0, 0, 0, 139, 0, 255), /* green */
gsDPLoadTextureTile_4b(treetop, G_IM_FMT_I,32, 32,
0, 0, 15, 39,
0,
G_TX_MIRROR, G_TX_CLAMP,
5, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD),
gsSPTextureRectangle(44 << 2, 68 << 2, 108 << 2, 100 << 2,
G_TX_RENDERTILE,
0, 0,
1 << 10, 1 << 10),
By interpolating between two different colors using the intensity as the parameter, it is possible to achieve two-color textures. The combine mode G_CC_BLENDPEDECALA interpolates between primitive color and environment color using an I texture. For this combine mode, when the texture is 0 the pixel will be environment color, when the texel is all ones, the pixel will be primitive color. Example 14-20 assumes an I texture has already been loaded into Tmem.
Example 14-20 Two-Color Texture
gsDPSetCombineMode(G_CC_BLENDPEDECALA, G_CC_BLENDPEDECALA), gsDPSetPrimColor(0, 0, 205, 51, 51, 255), /* brown */ gsDPSetEnvColor(0, 0, 0, 200, 0, 255), /* green */ gsSPTextureRectangle(50 << 2, 100 << 2, 82 << 2, 140 << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10),
Since for intensity textures the texel value is also copied onto the alpha channel, you can achieve transparency using an intensity texture. For example, if you define a 4-bit texture of some text to have an intensity of 0xf for the characters and a value of 0 elsewhere, and then render using the combine mode G_CC_BLENDPEDECALA and the render mode G_RM_TEX_EDGE, the text will have the primitive color and be transparent elsewhere.
Note that if the edges of the text are filtered to give smooth edges, then the text will have an intensity ramp at the edges. If you use an antialiased render mode, such as G_RM_AA_TEX_EDGE, then the text will look smoother than if a 1-bit alpha texture like 4-bit IA or 16-bit RGBA were used.
Intensity Alpha (IA) Textures
This texture type defines an intensity (I) channel and a separate alpha channel (A). This type is convenient where the transparency of the texture must be defined separately from the intensity. The sizes include 4-bit (3 bits of I and 1 bit of A), 8-bit (4 bits of I and 4 bits of A), 16-bit (8 bits of I and 8 bits of A). Keep in mind when using 1-bit alphas that the pixel will be either written or not, depending on the alpha bit. Therefore, the transparency channel is not antialiased (the texture filter cannot �create data� to smooth the edge). Scaling a 1-bit alpha texture can result in blocky-looking outlines.
Color (RGBA) Textures
There are two sizes of RGBA textures: 16-bit (5 bits R, 5 bits G, 5 bits B, 1 bit A), and 32-bit (8 bits R, 8 bits G, 8 bits B, 8 bits A). While 16-bit RGBA textures are popular because they are easy to create and model with, they have the disadvantage of only a 1-bit alpha channel. This can be overcome in certain cases, as discussed in �Combining Types," below.
Color Index (CI) Textures
Color index textures come in two sizes, 8-bit and 4-bit. When using color index textures only half the Tmem is used for textures (2KBytes). The other half is used to store the lookup table (TLUT) that converts the index texel into either 16-bit RGBA or 16-bit IA types. It is also possible to copy 8-bit CI textures directly to an 8-bit framebuffer as discussed in Section 14.6, �Color Index Frame Buffer�.
4-bit CI textures must select one of 16 possible palettes. Each palette has 16 entries. The g*DPLoadTLUT_pal16 can be used to load an individual palette. The palette to use is defined in the tile descriptor (normally you would define the palette in the g*DPLoadTexture* command), so different tiles can select different palettes.
You can use a 4-bit CI texture to provide more alpha bits than is possible with the 4-bit IA type, because the TLUT can hold 16-bit IA values. Therefore, you could look up 16 levels of alpha with a 4-bit CI sprite as compared to 1 level for a 4-bit IA sprite.
Copyright © 1999 Nintendo of America Inc. All Rights Reserved Nintendo and N64 are registered trademarks of Nintendo Last Updated January, 1999 |