When should you use multiple texture units?

When should I use multiple texture units through the glActiveTexture command (TEXTURE 0 and TEXTURE 1)? From the examples I saw, several textures can be used on the TEXTURE0 texture block.

+4
source share
2 answers

You need to texture a lot, for example, when you use: normal display, parallax display, terrain texturing.

In the details for a normal display, you need a diffuse texture unit for the model, but also a normal map, and you need to try both textures, however you cannot activate the same channel for both textures, you need to activate TEXTURE0 and TEXTURE1 and bind them to corresponding id textures.

After you activate them and draw a model using these textures in the color buffer, you can use them for other textures.

Think of them as flags for activating various texture channels on the GPU.

+5
source

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 an object A with textures X and Y. The resulting color is based on different states of the texture environment (or shaders if you use them); this state tells OpenGL how to combine values ​​from two textures into one color.

If you use a fixed function, then each texture has its own set of texture coordinates. The final color value is calculated based on the colors obtained by these texture coordinates on their respective textures. These texture colors are served through a texture environment, which is a sequence of operations applied to those colors that calculate the final color.

If you use shaders, you can do whatever you want. Make texture coordinates "on the fly", use arbitrary operations to combine texture "colors", etc.

Texture units are designed for multitexturing.

+6
source

All Articles