Table of Contents Glide Programming Guide



Download 6.22 Mb.
Page32/106
Date03.02.2023
Size6.22 Mb.
#60547
1   ...   28   29   30   31   32   33   34   35   ...   106
GLIDEPGM

4The Color Combine Unit


Note: Control of high level rendering functions is managed by three functions, grColorCombine(), grAlphaCombine() (see Chapter Chapter 6. ), and grTexCombine() (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_t enumerated 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.

  1. Table Color and Lighting.1 Configuring the color combine unit.

The first argument to grColorCombine(), func, specifies the color combine function; its value is chosen from among the symbols list in the left hand column of the table below. The right hand column gives the combining function that corresponds to each symbolic name. F is a scale factor and is defined by the factor argument to grColorCombine(). Clocal and cother are specified by the third and fourth arguments. Some of the formulas specify an alpha value, alocal, that is defined in the grAlphaCombine() function described in the next chapter.



Color combine function

computed color

GR_COMBINE_FUNCTION_ZERO

0

GR_COMBINE_FUNCTION_LOCAL


Download 6.22 Mb.

Share with your friends:
1   ...   28   29   30   31   32   33   34   35   ...   106




The database is protected by copyright ©ininet.org 2024
send message

    Main page