Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Texture Environment (TEV)

The texture environment (TEV) is responsible for blending vertex colors and textures through a fixed function pipeline of at most 16 stages. These stages are the closest thing to shaders in the GX.

Stages

A TEV stage performs a configurable operation on some color inputs and generates an output color that can be fed into the next stage. Stages are executed sequentially. The output of the last stage is the final color.

The TEV has a set of 4 registers, called R0, R1, R2 and R3 (also called PREV), which are shared between all stages and can be used as either input or output of each one of them. Since the color and alpha components are computed separatedly, they can be referred to as R0C, R0A, R1C, R1A, etc.

TEV stages operate on normalized floating-point RGBA color values (i.e. each channel has a value in [0, 1]). The alpha channel is special and can be configured separatedly.

Each TEV stage has 4 input values A, B, C and D. It has only one output, which will be called OUT. The operation of a TEV stage is always of the following form:

value = [sign * (A * (1.0 - C) + B * C) + D + bias] * scale
if (clamp)
    OUT = clamp(value)
else
    OUT = value

In the operation, sign, bias, scale and clamp are configurable:

VariablePossible values
Sign1 and -1
Bias0, 0.5 and -0.5
Scale0.5, 1, 2 and 4
Clamp0 and 1 (boolean)

Inputs

Each input value (A, B, C and D) can be configured to be sourced from one of the following values for the color operation:

CodeValue
0x0R3C
0x1R3A
0x2R0C
0x3R0A
0x4R1C
0x5R1A
0x6R2C
0x7R2A
0x8Texture Color
0x9Texture Alpha
0xARasterizer Color
0xBRasterizer Alpha
0xCOne
0xDOne half
0xEConstant
0xFZero

And one of the following values for the alpha operation:

CodeValue
0x0R3A
0x1R0A
0x2R1A
0x3R2A
0x4Texture Alpha
0x5Rasterizer Alpha
0x6Constant
0x7Zero

The texture and rasterizer colors available to a given stage are also configurable.

Outputs

The output value (OUT) can only be put into one of the 4 TEV registers (R0, R1, R2 and R3).

Register formats

TEV Stage Color

This is the format of the GX registers for TEV stages color configuration:

BitsNameDescription
0..4Input DSource of input D
4..8Input CSource of input C
8..12Input BSource of input B
12..16Input ASource of input A
16..18BiasBias value (see below)
18NegateSign is -1 if set, +1 otherwise
19ClampEnables clamping
20..22ScaleScale value (see below)
22..24OutDestination register of output value (see below)

Bias value selection:

CodeValue
0b000
0b01+0.5
0b10-0.5
0b11Reserved

Scale value selection:

CodeValue
0b001
0b012
0b104
0b110.5

Destination register selection:

CodeValue
0b00R3
0b01R0
0b10R1
0b11R2

TEV Stage Alpha

This is the format of the GX registers for TEV stages alpha configuration:

BitsNameDescription
0..2Rasterizer swapIndex of swap table to use for rasterizer inputs
2..4Texture swapIndex of swap table to use for texture inputs
4..7Input DSource of input D
7..10Input CSource of input C
10..13Input BSource of input B
13..16Input ASource of input A
16..18BiasBias value (see color format)
18NegateSign is -1 if set, +1 otherwise
19ClampEnables clamping
20..22ScaleScale value (see color format)
22..24OutDestination register of output value (see color format)