tg-clr-persp
Description
The Graphics Processor's vertex color interpolation is not perspective-correct. However, the texture coordinate interpolation is perspective-correct. This demo shows how to use the texture coordinate rasterizer to perform vertex color rasterization with the color texgen hardware.

Figure 1: Using the default color rasterization

Figure 2: Using texgen to rasterize vertex colors with texture unit.
Figure 2 illustrates the algorithm used to interpolate vertex colors using the texture unit. The color texgen hardware can convert the output of the color channels into texture coordinates. The red component is used as S, and the green component is used as T. The resulting colors are then looked up with an identity ramp texture. Because the color texgen unit only converts the red and green channels, the blue and alpha channels need to be done in another texgen. * Please note that the BA vertex color information must be piped through the red and green channels.
Advantages:
- Perspective-correct color interpolation.
- Avoids the rasterized-color clipping bug (incorrectly calculated clip values when vertices cross W=0).
Disadvantages:
For perspective-correct RGBA from lighting with vertex-color input:
- Requires 2 color lighting channels (the alpha channels are not needed).
- Requires 2 TEV stages and 2 texture look-ups.
- Requires 2 hardware lights per desired full-color light effect.
- Requires 2 sets of vertex colors. One for RG, and one for BA where BA are translated into the RG components.
Optimizations:
- Mono- or bichromatic lighting only requires 1 color channel and 1 TEV stage (and 1 hardware light per effect).
- Look-up textures can be smaller than 256x256. Note that there is a small error due to the sub-texel adjustment in the look-up using the linear filter. This can be overcome by adjusting the input colors.
- Non-lit vertex colors can be passed directly as texture coordinates, bypassing the color texgen hardware.
Using the Demo
- A button: Toggles between the following modes:
- Mode 1: color rasterization vs. texture vertex color rasterization.
- Stick: Controls models.
- Left/Right Buttons: Zoom in/out
- Up button: Toggles base texture.
- Left button: Toggles alpha modes.
- Mode 2: texture vertex color rasterization with hardware lighting.
- Mode 3: illustrates perspective correction and color clipping bug.
- Camera Stick: Controls camera.
- X Button: Changes size of look-up textures.
- B Button: Toggles rotation.
Snapshot
Mode 1

Mode 2

Mode 3

Required Data Files
$REVOLUTION_SDK_ROOT/dvddata/gxTests/tg-pc.tpl
Revision History
2006/03/01 Initial version.
CONFIDENTIAL