46
Chapter 3: Specifying the Appearance of Geometries
Texture Environment Settings
Texture environment variables specify how texture colors are blended with the colors of
a geometry; the texture color can replace, blend with, or subtract from the colors already
on the geometry.
To specify how texture colors are blended with the colors of a geometry, use the
setTexEnv() method with one of the following csContext::TexEnvEnum values as an
argument:
MODULATE_TENV
multiplies the shaded color of the geometry by the texture color. If the
texture has an alpha component, the alpha value modulates the
geometry’s transparency, for example, if a black and white texture, such
as text, is applied to a green polygon, the polygon remains green and the
writing appears as dark green lettering. MODULATE is the default
value.
BLEND_TENV
uses the texture color to blend together the blend color and the
underlying geometry’s color. In the above example, the lettering would
be a mixture of green, white, and black.
REPLACE_TENV
replaces the underlying geometry’s color with the texture color. If the
texture has an alpha component, the alpha value specifies the texture’s
transparency, allowing the geometry’s color to show through the
texture. In the above example, the lettering would be white and black.
ADD_TENV adds the underlying geometry’s color with the texture color.
DECAL_TENV replaces the underlying geometry’s color with the color of the texture.
When this token is used with RGBA values, the alpha value determines
the blending between the shape’s and texture’s color: when the alpha
value is 1.0, the color is only the texture’s; when the value is 0.0, the color
is only that of the shape’s.
Tip: If you use MODULATE, consider surrounding your texture images with a one-pixel
border of white pixels and set csTexture::setRepeatS() and csTexture::setRepeatT() to
CLAMP so the geometry’s color is used where the texture runs out.