Texture Environment Modes

Just a quick question - what’s the difference between GL_DECAL, GL_MODULATE, and the other texture environment mode? What do they do?


They specify how a texture will appear when it is rendered on a poly.

For instance, in GL_DECAL, the original color of the poly is ignored and the texture is slapped on the poly as if it were a sticker (or a decal!). In GL_MODULATE and GL_BLEND, the color of the underlying polygon is merged with the color of the texture. The difference between the two is explained in the Red Book, but I would recommend you perform a test of your own to get an idea of what each does.

When I use GL_MODULATE, the texture is ‘tinted’ with the color of the underlying poly. I haven’t used GL_BLEND much, but from what I remember, it caused the texture to be darkened. This would make sense if the poly color and the texture color are averaged in GL_MODULATE and added together in GL_BLEND.

just look in the red book. You can get it online. Just looks on nehe’s page.

I don’t remeber what gl_decal does, but

GL_MODULATE multiplies the color of the fragment(f) with the incoming texture(t) pixel.

Cpoly = (RfRt, GfGt, Bf*Bt)

The most obvious example of that is a lightmap.

You first apply a color or a texture to your polygon and then you modulate the lightmap with the present color giving the effect of light. So if you your lightmap is 0, the color of the polygon will be zero.

GL_REPLACE simply does

Cpoly = Ct