5
votes

When should I use multiple texture units via the glActiveTexture command (TEXTURE 0 and TEXTURE 1)? From the examples I've seen multiple textures can be used on the texture unit TEXTURE0.

2

2 Answers

5
votes

You need multi-texturing for example when you use: normal mapping, parallax mapping, terrain texturing.

In detail for normal mapping you need the diffuse texture unit for the model, but also the normal map and you need to sample both textures, however you can't activate the same channel for both textures, you need to activate TEXTURE0 and TEXTURE1 and bind them to the respective id textures.

After you activate them and drew the model using those textures in the color buffer you can use them for other textures.

Think of them as flags to activate different textures channels on the GPU.

6
votes

There is a difference between using multiple textures (draw object A with texture X, draw object B with texture Y) and multitexturing. Multitexturing means drawing object A with textures X and Y. The resulting color is based on various "texture environment" state (or shaders if you're using them); this state tells OpenGL how to combine the values from the two textures into one color.

If you're using fixed-function, then each texture has its own set of texture coordinates. The final color value computed is based on the colors fetched by those texture coordinates on their corresponding textures. These texture colors are fed through the texture environment, which is a sequence of operations applied to those colors that compute a final color.

If you're using shaders, then you can do pretty much whatever you want. Make up texture coordinates on the fly, use arbitrary operations to combine texture "colors", etc.

Texture units are for doing multitexturing.