Note: Control of high level rendering functions is managed by three functions, grColorCombine(), grAlphaCombine()(see Chapter Chapter 6. ), andgrTexCombine()(described in Chapter Chapter 9. ). While the three routines will be presented individually, settings for one function can potentially affect the inputs to the other routines.
The color combine unit computes an RGB color for each pixel as it is rendered. User-selected inputs are added, blended, and/or scaled to produce flat or smooth (Gouraud) shading with optional lighting effects. The color combine unit computes each RGB color component separately, but all three are computed using the same formula. The alpha combine unit computes the alpha component and is discussed in the next chapter.
The color combine unit computes a color component as
c = f * a + b where c is the red, green, or blue color component, f is a scale factor, and a and b are sums and differences of the various input choices.
The Glide routine that configures the color combine unit is grColorCombine(). It specifies the function that computes the color and selects the inputs.
void grColorCombine( GrCombineFunction_t func,
GrCombineFactor_t factor,
GrCombineLocal_t local,
GrCombineOther_t other,
FxBool invert )
Fourteen combining functions are defined in the GrCombineFunction_tenumerated type; one is selected with func, the first argument to grColorCombine(). Table Color and Lighting.1 gives the symbolic names and formulas for each color combine function.
The f variable in the combining formulas is defined by factor, the second argument to grColorCombine(). The choices for this scale factor are given in Table Color and Lighting.2. Note that alpha values from the texture combine unit (atexture) or specified by grAlphaCombine() arguments (alocal and aother) appear in some of the scale factors.
Table Color and Lighting.1 Configuring the color combine unit.