Table of Contents Glide Programming Guide


Configuring the Texture Pipeline for Composite Texturing



Download 6.22 Mb.
Page68/106
Date03.02.2023
Size6.22 Mb.
#60547
1   ...   64   65   66   67   68   69   70   71   ...   106
GLIDEPGM

4Configuring the Texture Pipeline for Composite Texturing


When a bilinear-filtered texture-mapped surface is viewed closely, the resulting image may be blurry and overly soft. A technique known as composite texturing can remedy this blurriness. Composite texturing blends two textures together based on their LOD values. One texture represents the overall texture look, and the other texture represents the details that should be seen when the texture is viewed closely. For example, brick can be represented with a tiled brick pattern. As the viewer moves closer to the wall, pits and cracks in the bricks could begin to appear by blending a separate “pits and cracks” texture into the brick based on the LOD value.
The Glide function grTexDetailControl() manages the various parameters involved when performing composite texture mapping.
void grTexDetailControl( GrChipID_t tmu, int detailBias, FxU8 detailScale, float detailMax )

The first argument specifies the TMU to modify; valid values are GR_TMU0, GR_TMU1, and GR_TMU2. The second argument, detailBias, controls where the blending between the two textures begins and is an integer in the range [–32..31]. The detailScale argument controls the steepness of the blend; valid values are [0..7]. The scale is computed as 2detail_scale. The detailMax argument specifies the maximum blending that will occur and is in the range [0..1].


Detail texturing refers to the effect where the blend between two textures in a texture combine unit is a function of the LOD calculated for each pixel. grTexDetailControl() controls how the detail blending factor, b, is computed from LOD. The detailBias parameter controls where the blending begins; the detailScale parameter controls how fast the detail shows up; and the detailMax parameter controls the maximum blending that occurs.
b = min( detailMax, max( 0, (detailBias–LOD) << detailScale ) / 255.0 )
where LOD is the calculated LOD before grTexLodBiasValue() is added. The detail blending factor is utilized by calling grTexCombine() with an rgbFunction of GR_COMBINE_FUNCTION_BLEND and an rgbFactor of GR_COMBINE_FACTOR_DETAIL_FACTOR to compute:
cout = b(cdetail texture) + (1–b)(cmain_texture)
An LOD of n is calculated when a pixel covers approximately 22n texels. For example, when a pixel covers approximately one texel, the LOD is 0; when a pixel covers four texels, the LOD is 1; when a pixel covers 16 texels, the LOD is 2.
Detail blending occurs in the downstream TMU. Since the detail texture and main texture typically have very different computed LODs, the detail texturing control settings depend on which texture is in the downstream TMU.
Example Texture Mapping.4 Creating a composite texture.
The code segment below creates a composite texture by adding details to the primary texture as the viewer approaches. The primary texture is loaded onto TMU0 while the detail texture is upstream on TMU1. The scale factor GR_COMBINE_FACTOR_DETAIL_FACTOR creates the composite on TMU0, while TMU1 does decal mapping.
grTexCombine( GR_TMU0,
GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL,
GR_COMBINE_FACTOR_DETAIL_FACTOR,
GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL,
GR_COMBINE_FACTOR_DETAIL_FACTOR,
FXFALSE, FXFALSE);

grTexCombine( GR_TMU1, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE,


GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE,
FXFALSE, FXFALSE );
Example .5 Creating a composite texture, part II.
multiply RGB, add alpha ; show how to compose the AI88 texture
normal on tmu1
composed one on tmu0
RGB factor local, function scale other add local alpha
A factor zero, invert


Download 6.22 Mb.

Share with your friends:
1   ...   64   65   66   67   68   69   70   71   ...   106




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

    Main page