f * (cother – clocal) + clocal º f * cother + (1 – f) * clocal
f * (aother – alocal) + alocal º f * aother + (1 – f) * alocal
SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL_ALPHA
f * (cother – clocal) + alocal
f * (aother – alocal) + alocal
SCALE_MINUS_LOCAL_ADD_LOCAL
BLEND_LOCAL
f * (– clocal) + clocal º (1 – f) * clocal
f * (– alocal) + alocal º (1 – f) * alocal
SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA
f * (– clocal) + alocal
f * (–alocal) + alocal
Table Texture Mapping.5 Scale factors for texture color generation.
ThergbFactorandalphaFactorargumentstogrTexCombine()cantakeonanyofthevalueslistedinthefirstcolumn. Thesecondandthirdcolumnsshowthescalefactorthatwillbeused. clocal and alocal represent the color components generated by indexing and filtering from the mipmap stored on tmu; cother and aother represent the incoming color components from the neighboring TMU (refer to Figure Texture Mapping.1). If GR_COMBINE_FACTOR_DETAIL_FACTOR or GR_COMBINE_FACTOR_ONE_MINUS_DETAIL_FACTOR is specified, the scale factor employs the detail blend factor, called b in the table. See the discussion of grTexDetailControl() in the next section for more information. If GR_COMBINE_FACTOR_LOD_FRACTION or GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION is specified, the scale factor employs the fractional part of the computed LOD, called l in the table. See the discussion about computing an LOD earlier in this chapter for more information.
texture combine factor (prefixed with GR_COMBINE_FACTOR_)
scale factor f if specified as rgbFactor
scale factor f if specified as alphaFactor
NONE
unspecified
unspecified
ZERO
0
0
LOCAL
clocal / 255
alocal / 255
OTHER_ALPHA
aother / 255
aother / 255
LOCAL_ALPHA
alocal / 255
alocal / 255
DETAIL_FACTOR
b
b
LOD_FRACTION
l
l
ONE
1
1
ONE_MINUS_LOCAL
1 – clocal / 255
1 – alocal / 255
ONE_MINUS_OTHER_ALPHA
1 – aother / 255
1 – aother / 255
ONE_MINUS_LOCAL_ALPHA
1 – alocal / 255
1 – alocal / 255
ONE_MINUS_DETAIL_FACTOR
1 – b
1 – b
ONE_MINUS_LOD_FRACTION
1 – l
1 – l
13Examples of Configuring the Texture Pipeline
The following code examples illustrate how to configure the texture pipeline for different texture mapping effects. The examples all assume that appropriate textures have been loaded and the addressing mechanism in the TMU points to the right place. This process is described in detail in the next chapter; the examples will be repeated there, with the texture loading segments filled in. The examples also assume that grColorCombine() and/or grAlphaCombine() utilize texture mapping by setting the scale factor to GR_COMBINE_FACTOR_TEXTURE_ALPHA or GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA.
The examples in this chapter attempt to cover most of the texture mapping techniques of interest. Table Texture Mapping.6 shows the principle texture mapping algorithms and describes the implementation in terms of available TMUs. We show examples utilizing one or two TMUs, mipmaps split across two TMUs, and a two-pass application.
Table Texture Mapping.6 The number of TMUs affects texture mapping functionality.
The number of texture mapping units determines the performance of advanced texture mapping rendering. The table below describes the number of passes required to implement the texture mapping techniques supported by the Voodoo Graphics subsystem. Note that in a system with three TMUs, only the most complicated algorithm (trilinear filtering with mipmapping, projected, and detail textures) requires more than one pass.
Bilinear filtering with mipmapping and detail textures
two pass
one pass
one pass
Bilinear filtering with mipmapping, projected and detail textures
not supported
two pass
one pass
Trilinear filtering with mipmapping
two pass
one pass
one pass
Trilinear filtering with mipmapping and projected textures
not supported
two pass
one pass
Trilinear filtering with mipmapping and detail textures
not supported
two pass
one pass
Trilinear filtering with mipmapping, projected, and detail textures
not supported
two pass
two pass
1Configuring the Texture Pipeline for Decal Texture Mapping
The simplest texture mapping technique is decal mapping, which applies a texture to a polygon without modification. The first two entries in Table Texture Mapping.6 are decal mapping, differing only in the choice of minification and magnification filters. Decal mapping is a single pass operation on all Voodoo Graphics configurations.
Example Texture Mapping.1 Setting up simple (decal) texture mapping. The following code sets up the texture pipeline so that a texel is placed into the pixel pipeline without modification. The code assumes that there is a single TMU, that a texture has already been loaded into texture memory with the texture base address pointing to it, and that the color combine unit is configured to use the texture color and/or alpha value. grTexCombine( GR_TMU0, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE,
GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE,
FXFALSE, FXFALSE );
2Configuring the Texture Pipeline for Projected Texture Mapping
Interesting spotlight effects are possible by multiplying two texture maps against each other. For example, one texture map can be an intensity map (e.g. a spotlight) and the other can be a source texture. Recall that the texture RGBA values from the “upstream” TMU1 become the other input to the “downstream” TMU0. In Example Texture Mapping.2, the spotlight texture is upstream, the source texture is downstream and the resulting RGBAtexture = RGBAspotlight × RGBAsource.
Example Texture Mapping.2 Applying a modulated (projected) texture. The code segment below assumes that the texture maps have already been loaded: an intensity map for the spotlight in TMU0 and a source texture in TMU1. The resulting texture RGBA is a product of the texels chosen from the two textures. The color combine unit must be configured to use the output from the texture pipeline. grTexCombine( GR_TMU0,
GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL,
GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL,
FXFALSE, FXFALSE );