Texture Mapping Table


Related topics include:

For an overview and a list of lookup tables, see Lookup Tables.

Each entry of a texture mapping table binds a set of attributes to a referenced texture map resource. The same texture map resource may be referenced by multiple texture mapping table entries.

---------------------------------------------------------------------------------------------------------------------
Table Value                                    Description                    Fallback                            PEX
Mask
---------------------------------------------------------------------------------------------------------------------
PEXLUTVTMIDs                                                                                                      5.2
                                               number of resources (n)        0
                                               unused
                                               list of texture map resources
PEXLUTVTMRenderingControl                                                                                         5.2
                                               rendering control              PEXTMRCPostLight
PEXLUTVTMParameterizationMethod                                                                                   5.2
                                               parameterization method        PEXTMPMReflectionSphereVRC
PEXLUTVTMFPDataIndex(a)                                                                                                   5.2
                                               floating-point data index      0
PEXLUTVTMReflectionMatrix(b)                                                                                              5.2
                                               reflection matrix              Identity
                                               reflection matrix hints        Identity
PEXLUTVTMOrientationMatrix                                                                                        5.2
                                               orientation matrix             Identity
                                               orientation matrix hints       Identity
PEXLUTVTMCompositionMethod                                                                                        5.2
                                               composition method             PEXTMCMReplace
PEXLUTVTMChannelSelector(c)                                                                                               5.2
                                               channel selector               PEXTMChannelRed
PEXLUTVTMEnvironmentColor(d)                                                                                              5.2
                                               environment color              {PEXColorTypeRGB, (0.0, 0.0, 0.0)}
PEXLUTVTMBackgroundColor(e)                                                                                               5.2
                                               background color               {PEXColorTypeRGB, (0.0, 0.0, 0.0)}
PEXLUTVTMSampleMethod                                                                                             5.2
                                               minification sample method     PEXTMSMSingleBase
                                               magnification sample method    PEXTMSMSingleBase
PEXLUTVTMBoundaryConditions                                                                                       5.2
                                               t0 boundary condition          PEXTMBCWrap
                                               t1 boundary condition          PEXTMBCWrap
                                               t2 boundary condition          PEXTMBCWrap
                                               unused
PEXLUTVTMClampMethod(f)                                                                                                   5.2
                                               boundary clamp method          PEXTMBCMDiscontinue
PEXLUTVTMClampColor(g)                                                                                                    5.2
                                               boundary clamp color           {PEXColorTypeRGB, (0.0, 0.0, 0.0)}
PEXLUTVTMSamplingHints                                                                                            5.2
                                               depth sampling bias hint       0.0
                                               t0 frequency hint              1.0
                                               t1 frequency hint              1.0
                                               t2 frequency hint              1.0
PEXLUTVTMAll5_2 (selects entire table entry)                                                                             5.2
 
---------------------------------------------------------------------------------------------------------------------

(a)
Value fp data index is ignored unless value parameterization method selects method FloatData.
(b)
Value reflection matrix is ignored unless value parameterization method selects method ReflectionSphereVRC or ReflectionSphereWC.
(c)
Value channel number is ignored unless value composition method selects method BlendEnvColor.
(d)
Value environment color is ignored unless value composition method selects method BlendEnvColor.
(e)
Value background color is ignored unless value composition method selects method DecalBackground.
(f)
Value clamping method is ignored unless value boundary conditions selects condition ClampExplicitMethod.
(g)
Value clamp color is ignored unless value boundary conditions selects condition ClampExplicitMethod and value clamping method selects method Color.

Selecting and Applying a Texture

Related topics include:

The texture mapping table is accessed when rendering surface primitives if the pipeline state's interior style is PEXInteriorStyleTexture and the pipeline state's active textures field is non-empty. If the pipeline state's facet distinguish flag is True, then the implementation accesses the texture mapping table when rendering back-facing facets if the pipeline state's bf interior style is PEXInteriorStyleTexture and the pipeline state's bf active textures field is non-empty. The active textures lists select entries of the texture mapping table which each represent a texture map and an associated set of attributes. If the number of entries in the active textures list exceeds the maximum number of texture maps which can be applied to a single facet, then the implementation ignores the texture maps beyond the first MaxTextureMaps indices. Invoke request PEXGetImpDepConstants to inquire MaxTextureMaps. If the active textures list is empty, then the default table values are used to apply the single default texture map.

Not every texture map applies all of the texture mapping table fields. The descriptions of the values below indicate if, and how, the values are applied to the texture map.

Texture mapping table value texture map ids is used to reference the texture map resources which define the texture map. Texture map resources are discussed in Texture Mapping. The number of texture map resources needed to define a single texture map is determined by the texture mapping table's parameterization method field. All currently defined parameterization methods use a single texture map resource to define a texture map.

If the texture map ids fallback (an empty list) is used, then the implementation uses the default texture map; a black and white checkerboard of 8x8 squares. The checkerboard is defined by a 2D array of 16x16 texels, with each square defined by 2x2 texels. The square at t0=t1=0.0 is white.

rendering control:
The texture mapping table's rendering control value controls where in the rendering pipeline the texture map is applied. The currently defined values, shown below, interact heavily with the composition method, surface interpolation method and texture mapping sample frequency. This controls whether the texture colors change the effect of lighting on a surface primitive, or if the lighting is performed on the textured surface. When a texture is applied post-light, it can reduce or obliterate any specular highlight; but if texture is applied pre-light, then the specular highlight is retained.

PEXTMRenderingControlPreLight -
applies the texture map to the primitive before the reflectance calculations.

PEXTMRenderingControlPostLight -
applies the texture map to the primitive after the reflectance calculations.
See Composition Controls.

Parameterization Controls

Related topics include:

The parameterization attributes control how the texture map coordinates are derived. There are texture map coordinates associated with each point on the surface for which a texture map value is sampled. They are used to select the point within the texture map which is sampled. There is one texture map coordinate for each dimension of the texture map. For example, three texture map coordinates, represented as (t0, t1, t2), are used to sample a 3D texture map. The texture coordinates are normalized, that is, they range from 0.0 to 1.0 across the texture map.

parameterization method:
The parameterization method field of the texture mapping table defines how texture map coordinates are derived: whether explicitly defined by the primitive's data, calculated through a projection mapping, or determined through some other means. PEXlib defines the following parameterization methods:
PEXTMParamReflectionSphereVRC and PEXTMParamReflectionSphereWC
are projection mapping parameterization methods which project a reflection vector (the 3D source texture map coordinates) onto a sphere (the projection object) to determine the 3D texture map coordinates (t0, t1, t2=0.0).

The spheres have fixed orientations. The position of the reflection vectors relative to these orientations may be modified through the multiplication of the reflection vectors by the reflection matrix from the texture mapping lookup table. The reflection vectors are always multiplied by the reflection matrix before the reflection is performed. For best results, the reflection transformation should utilize only rotations. The reflection matrix hints provide an opportunity for optimizing this transformation. See PEXOCCSetGlobalTransform for an explanation of matrix hints.

PEXTMParamVertexMCCoord (3) -
Sets the texture map coordinate values equal to the MC space values of the vertex coordinates: t0 = x; t1 = y; t2 = z.

PEXTMParamVertexWCCoord(3)-
Sets the texture map coordinate values equal to the WC space values of the vertex coordinates: t0 = x'; t1 = y'; t2 = z'.

PEXTMParamVertexMCNormal(3) -
Sets the texture map coordinates equal to the MC space value of the vertex normal. If a normal is not explicitly supplied with the vertex, then the calculated geometric normal is used instead. t0 = nx; t1 = ny; t2 = nz.

PEXTMParamVertexWCNormal(3) -
Sets the texture map coordinates equal to the WC space value of the vertex normal. If a normal is not explicitly supplied with the vertex, then the calculated geometric normal is used instead. t0 = nx'; t1 = ny'; t2 = nz'.

PEXTMParamNURBUV -
Sets the texture map coordinates equal to the u and v parameters of the non-uniform b-spline surface: t0 = u; t1 = v; t2 = 0.0.

If the primitive is not a non-uniform b-spline surface, then the texture map coordinates are set to: t0 = t1 = t2 = 0.0.

PEXTMParamFloatData -
The texture map coordinates are members of the vertex's floating-point data list. The fp data index value of the texture mapping table is the index into the floating-point data list of the value which is assigned to t0. The subsequent values in the floating-point data list are assigned to t1 and t2:

  t0 = vertex_fp_data[fp data index]
  t1 = vertex_fp_data[fp data index + 1] (if 2D map)
  t2 = vertex_fp_data[fp data index + 2] (if 3D map)

If the primitive is a non-uniform b-spline surface, then the values are obtained from the spline's data splines:

 
  t0 = first value of the data spline selected by the
    fp data index
  t1 = first value of the data spline selected by
    fp data index + 1
  t2 = first value of the data spline selected by
    fp data index + 2
 

If the number of floating-point data values is insufficient for the dimension of the texture map, then the texture coordinate values used are implementation-dependent.

PEXTMParamReflectionSphereVRC -
The infinite sphere has (0,0,0) as its origin and the +y axis as its axis of revolution. The texture seams lie on the positive and negative x axes. The source texture map coordinates are a reflection vector (s0, s1, s2), computed to determine a point on the interior of the sphere.

The reflection vector is calculated as follows:

where s is the reflection vector, n is the vertex normal (explicit or calculated), and i is the unit vector from the eyepoint (computed as described in View Table) to the vertex. This calculation is performed in VRC space, after the vertex and its normal have been transformed to VRC space. After this, the texture coordinates are derived as follows:

where:

PEXTMParamReflectionSphereWC -
The source texture map coordinates, a reflection vector (s0,s1,s2), are normalized and conceptually projected onto the infinite sphere (with (0,0,0) as its origin) projection object. The axis of revolution of the sphere is the +y axis (in WC space). The texture seam sweeps from the +x axis (in WC space) in a counterclockwise direction: [0..2PI].

The reflection vector is calculated as follows:

where s is the reflection vector, n is the vertex normal (explicit or calculated), and i is the unit vector from the eyepoint (computed as described in View Table to the vertex. This calculation is performed in WC space, after the vertex and its normal have been transformed to WC space. This parameterization method is primarily intended for use with a perspective, as opposed to orthogonal, view projection. After the reflection vector is calculated, the texture coordinates are derived as follows.

Orientation Transformation, Interpolation, and Perspective Correction

Related topics include:

Once the texture map coordinates are determined, independent of which parameterization method was used, they are transformed by the orientation matrix field of the texture mapping table. The orientation matrix hints provide an opportunity to optimize the transformation. See PEXOCCSetGlobalTransform for an explanation of matrix hints. The orientation transformation occurs before any interpolation of the texture map coordinates across the facet that may be required before the coordinates are used to sample the texture map. If the projection is perspective, then the interpolated texture map coordinates are also adjusted according to the pipeline state's tm perspective correction before the sampling is done. The following provides a graphical description of parameterization.

Texture Parameterization

Composition Controls

Related topics include:

The currently defined composition attributes control how the texture map color interacts with the primitive's color to determine the primitive's color after the texture map is applied.

The texture mapping table composition method value specifies how the texture map is blended with the primitive's existing data. The currently defined composition methods assume:

For each composition method, equations are given. The equations given are for the input into each texture map i and show the Cout and Aout for each texture map i. The output of each texture map i becomes the input of the next texture map i+1. The final output of the texture mapping stage is the output of texture map n, where there are n texture maps active for the stage. In some PreLight rendering control cases there are additional values used as input into each texture map i (e.g., CW) and used as output from the texture mapping stage (e.g., CS). The following table defines the symbols used to define the composition methods.

Symbols Used in Defining the Composition Methods
--------------------------------------------------------------------------------------------------------------
Symbol  Description
--------------------------------------------------------------------------------------------------------------
in      Primitive color components input into texture i of a texture mapping stage.
out     Primitive color components output from texture i of a texture mapping stage.
R       The red component.
B       The blue component.
G       The green component.
C       R, G, and B considered together.
A       The alpha component.
L       The luminance component.
CW      A portion of primitive color input into the PreLight texture mapping stage. CW is derived in the pre
        ceding lighting stage by applying ambient and diffuse terms of the reflectance equation assuming
        the primitive's color is white.
        The same value of CW is input into each texture i of the texture mapping stage; it is not modified by
        texture mapping.
CD      Another portion of primitive color input into the PreLight texture mapping stage. CD is the ambient
        and diffuse components of color derived in the preceding lighting stage by applying the reflectance
        equation using the primitive's color (as opposed to assuming the primitive is white).
CS      A third portion of primitive color input into the PreLight texture mapping stage. CS is the specular
        component of color derived in the preceding lighting stage by applying the ambient and diffuse terms
        of the reflectance equation using the primitive's color (as opposed to assuming the primitive is
        white).
        CS is not affected by the texture mapping stage. It is combined with the CD output from the texture
        mapping stage to form the RGB components of the primitive color output from the texture mapping
        stage.
CT      R, G, and B of the texture map color considered together. If the texels have a luminance component
        instead of RGB components, (fig)l
AT      The alpha component of the texture map color.
CE      When the composition method is BlendEnvColor, CE is taken from the environment color field of the
        texture mapping lookup table.
CB      When the composition method is DecalBackground, CB is taken from the background color field of
        the texture mapping lookup table.
Γ       When the composition method is Decal, Γ is taken from the texture map color. For texels defined
        with RGB or RGBA components:
             if the texture mapping lookup table's channel number is TMChannelRed, (fig);
             if channel number is TMChannelGreen, (fig);
             if channel number is TMChannelBlue, (fig), and
             if there is an alpha component and channel number is TMChannelAlpha, (fig).
        For texels defined with a luminance component: (fig)
        The channel number constants are defined in Channel Selection Constant Values
--------------------------------------------------------------------------------------------------------------

PEXlib defines the following composition methods:

PEXTMCompReplace -
The texture map replaces the primitive's existing data. The texture map data unconditionally replaces the primitive's color. See Composition Method BlendEnvColor. for more details.

Composition Method Replace
-----------------------------------------------------------------------------
Texel       Rendering Control  Interpolation   Sample     Cout          Aout
Components                     Method          Frequency
-----------------------------------------------------------------------------
RGB, L      PreLight           None, Color     pixel      (fig) and Cs  (fig)
                               None, Color     InterpDep  (fig)         (fig)
                               DotProduct,     (any)
                               Normal
            PostLight          (any)           (any)
RGBA, LA    PreLight           None, Color     pixel      (fig) and Cs  (fig)
                               None, Color     InterpDep  (fig)         (fig)
                               DotProduct,     (any)
                               Normal
            PostLight          (any)           (any)
-----------------------------------------------------------------------------
PEXTMCompModulate -
The texture map color and primitive color are blended. See Composition Method BlendEnvColor. for more details.

Composition Method Modulate
-----------------------------------------------------------------------------
Texel       Rendering Control  Interpolation   Sample     Cout          Aout
Components                     Method          Frequency
-----------------------------------------------------------------------------
RGB, L      PreLight           None, Color     pixel      (fig) and Cs  (fig)
                               None, Color     InterpDep  (fig)         (fig)
                               DotProduct,     (any)
                               Normal
            PostLight          (any)           (any)
RGBA, LA    PreLight           None, Color     pixel      (fig) and Cs  (fig)
                               None, Color     InterpDep  (fig)         (fig)
                               DotProduct,     (any)
                               Normal
            PostLight          (any)           (any)
 
-----------------------------------------------------------------------------

PEXTMCompBlendEnvColor -
The texture map blends with the primitive's existing environment color. The primitive color and a constant environment color are blended by the texture map color. The primitive alpha is blended with the texture map alpha, if the texture map has alpha. See Composition Method BlendEnvColor. for more details.

Composition Method BlendEnvColor
---------------------------------------------------------------------------
Texel       Rendering Control  Interpolation   Sample     Cout        Aout
Components                     Method          Frequency
---------------------------------------------------------------------------
RGB, L      PreLight           None, Color     pixel      (fig) and   (fig)
                                                          Cs
                               None, Color     InterpDep  (fig)       (fig)
                               DotProduct,     (any)
                               Normal
            PostLight          (any)           (any)
RGBA, LA    PreLight           None, Color     pixel      (fig) and   (fig)
                                                          Cs
                               None, Color     InterpDep  (fig)       (fig)
                               DotProduct,     (any)
                               Normal
            PostLight          (any)           (any)
---------------------------------------------------------------------------

PEXTMCompDecal -
The texture map color and primitive color are blended by the texture map alpha. If the texture map doesn't contain alpha, then the texture map color replaces the primitive color. In either case, the primitive's alpha is unchanged. See Composition Method BlendEnvColor. for more details.

Composition Method Decal
-----------------------------------------------------------------------------
Texel       Rendering Control  Interpolation   Sample     Cout          Aout
Components                     Method          Frequency
-----------------------------------------------------------------------------
RGB, L      PreLight           None, Color     pixel      (fig) and Cs  (fig)
                               None, Color     InterpDep  (fig)         (fig)
                               DotProduct,     (any)
                               Normal
            PostLight          (any)           (any)
RGBA, LA    PreLight           None, Color     pixel      (fig)         (fig)
                                                          and Cs
                               None, Color     InterpDep  (fig)         (fig)
                               DotProduct,     (any)
                               Normal
            PostLight          (any)           (any)
-----------------------------------------------------------------------------

PEXTMCompDecalBackground -
The texture map color and background color are blended according to the texture map alpha, and this blend replaces the primitive color. If the texture map doesn't contain alpha, then the texture map color replaces the primitive color. In either case, the primitive's alpha is unchanged. See Composition Method BlendEnvColor for more details.

Composition Method DecalBackground
-----------------------------------------------------------------------------
Texel       Rendering Control  Interpolation   Sample     Cout          Aout
Components                     Method          Frequency
-----------------------------------------------------------------------------
RGB, L      PreLight           None, Color     pixel      (fig) and Cs  (fig)
                               None, Color     InterpDep  (fig)         (fig)
                               DotProduct,     (any)
                               Normal
            PostLight          (any)           (any)
RGBA, LA    PreLight           None, Color     pixel      (fig)         (fig)
                                                          and Cs
                               None, Color     InterpDep  (fig)         (fig)
                               DotProduct,     (any)
                               Normal
            PostLight          (any)           (any)
 
-----------------------------------------------------------------------------

Channel Selection Constant Values

Related topics include:

PEXlib defines the following channel selectors:

PEXTMChannelRed -
selects the red channel, channel 0.

PEXTMChannelGreen -
selects the green channel, channel 1.

PEXTMChannelBlue -
selects the blue channel, channel 2.

PEXTMChannelAlpha -
selects the alpha channel, channel 3.

Sampling Controls

Related topics include:

The sampling attributes are used to determine how a texture map color is derived when the texture map is sampled.

Minification and Magnification Sample Methods

Related topics include:

The sample min and mag field of the texture mapping table defines the minification and magnification sample methods. These methods specify how texels are sampled from the texture map and mapped to primitive pixels when the area covered by a texel and pixel differ.

In the case of a pixel overlapping more than one texture map texel, the texture minification method indicates how the sample value is derived for that pixel.

In the case of a pixel overlapping less than one texture map texel, the texture magnification method indicates how the sample value is derived for that pixel.

PEXlib defines the following sample methods:

PEXTMSampleSingleBase -
The closest single texel selected by the texture coordinate(s) is sampled from the base texture map level.

PEXTMSampleWeightedBase -
The 2n (where n is the dimension of the texture map) closest texels selected by the texture coordinate(s) are sampled from the base texture map level. Their weighted average is used.

PEXTMSampleSingleInMipmap -
The closest single texel selected by the texture coordinate(s) is sampled from the closest texture map level to the sample depth.

PEXTMSampleWeightedInMipmap -
The 2n (where n is the dimension of the texture map) closest texels selected by the texture coordinate(s) are sampled from the closest texture map level to the sample depth. Their weighted average is used.

PEXTMSampleSingleBetweenMipmaps -
The closest texel selected by the texture coordinate(s) is sampled from the two closest texture map levels to the sample depth. The texel found at the exact sample depth by interpolation between these two sampled texels is used. If the sample depth is beyond the base or pinnacle texture map levels, that level is used and this method behaves the same as PEXTMSampleSingleInMipmap.

PEXTMSampleWeightedBetweenMipmaps -
The 2n (where n is the dimension of the texture map) closest texels selected by the texture coordinate(s) are sampled from the two closest texture map levels to the sample depth. A weighted average is taken of these 2n texels on each of the texture map levels. The texel found at the exact sample depth by interpolation between these two calculated texels is used. If the sample depth is beyond the base or pinnacle texture map levels, that level is used and this method behaves the same as PEXTMSampleWeightedInMipmap.

Boundary Conditions

Related topics include:

The boundary conditions field of the texture mapping table specifies the texturing to be applied to the primitive when the texture coordinates (t0, t1, t2) select a point beyond a boundary of the texture map. That is, the calculated texture coordinates are outside the range [0.0,1.0]. The boundary condition in each direction is independently controlled.

PEXlib defines the following boundary conditions:

PEXTMBoundaryClampExplicit -
applies the method specified by the clamping method field of the texture mapping table.

PEXTMBoundaryClampBorder -
applies the closest boundary texel.

PEXTMBoundaryWrap -
texel sampling wraps back to the opposite texture map border, creating a "tiling" or "repeating" effect of the texture map across the primitive.

PEXTMBoundaryMirror -
texel sampling is reversed across the texture map, creating a "mirrored alternating" pattern of the texture map across the primitive.

Clamping Method

Related topics include:

The clamping method field of the texture mapping table specifies whether to discontinue texturing or to use an explicit color when boundary condition ClampExplicitMethod is selected. Although these are seemingly really additional boundary conditions, they are controlled through a separate field of the texture mapping table by design. With this level of direction, it is always clear what the behavior should be when a location is beyond the texture map in more than one direction, even if the boundary conditions for those directions differ.

PEXlib defines the following boundary clamp methods:

PEXTMBoundaryClampExplicitDiscontinue -
discontinues texturing. That is, it maintains the primitive's appearance before applying the current texture map.

PEXTMBoundaryClampExplicitColor -
applies the color specified by the clamp color field of the texture mapping table.

Sampling Hints

Related topics include:

Use the texture mapping table sampling hints value to adjust the selected sampling location. The depth bias hint is used to adjust the sampling depth. A bias of -1.0 moves the sampling depth one level toward the texture map's base level, effectively making the texturing more detailed, or jaggy, than it would otherwise have been. A bias of 2.0, for example, moves the sampling depth away from the texture map's base level by two levels, effectively blurring the texturing. The following are the suggested formulae for implementations; PEX implementations may use other formulae which produce a similar effect.

The extension of the suggested formulae to three-dimensional texture maps is left unspecified.

The suggested depth bias formulae utilize the frequency hints. There is a frequency hint corresponding to each direction of the texture map. A frequency hint is set to something less than 1.0, but greater than 0.0, if blurring in that direction would be unacceptably high due to low spatial frequency. A value of 1.0 for the corresponding texture map coordinate's frequency hint indicates the spatial frequency isn't high. If the spatial frequency of the texture map data is unknown, then it is best to set the values to 1.0.

Inquire TMSamplingHintsUsed with request PEXGetImpDepConstants to determine if the sampling hints are used.

Restrictions and Errors

For general information about texture mapping lookup tables, see Texture Mapping Table.

The superseded requests PEXSetTableEntries, PEXGetTableEntries, PEXGetTableEntry, and PEXGetPredefinedEntries do not operate on texture mapping tables.

Valid texture mapping table indices are in the range [1, 65535]. The fallback entry is entry 1.