More Info on Texture Mapping


If you have the following combination, your white cat may turn red.

Why is that? It is because the modulate function (or mode) is set for the texture.

There are four possible functions for computing the final RGB value shown in your texture-mapped image:

  1. Decal mode--where the texture is painted on top of the object (as a decal would be applied)
  2. Replace mode--which responds the same as Decal mode for RGB
  3. Modulate mode--where the texture modulates or scales the object's color
  4. Blend mode--where a specified constant color can be blended with that of the object, based on the texture value.

To specify which mode or function you want to use to calculate your final RGB values, you would use the glTexEnv*() function. For instance, to specify that you are using Decal mode, you would use the following statement:

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

To change to the other modes, you would replace GL_DECAL with GL_REPLACE, GL_MODULATE, or GL_BLEND.

The following table represents what happens (with RGB) when the kitten picture is combined with the red object using these different modes. An additional column provides the function used to calculate the final color (RGB). The color is represented by C. A subscript of t indicates a texture value, f indicates the fragment (or object) value, c indicates the value assigned with GL_TEXTURE_ENV_COLOR, and no subscript indicates the final, computed value.

Mode Function Resulting Image
GL_DECAL C=Ct
GL_REPLACE C=Ct
GL_MODULATE C=CfCt
GL_BLEND C=Cf(1-Ct) + CcCt

Back to CS 405 Texture Mapping Lab