Multitexturing

Multitexturing allows the use of multiple textures at one time.

It is a standard feature of OpenGL 1.3 and later.

An ordinary texture combines the base color of a polygon with color from the texture image. In multitexturing, this result of the first texturing can be combined with color from another texture.

Each texture can be applied with different texture coordinates.






Multitexturing

+ +
=





Texture Units

Multitexturing uses multiple texture units.
A texture unit is a part of the rendering pipeline that applies one texture to whatever is being drawn.
Each unit has a texture, a texture environment, and optional texgen mode.

Most current hardware has from 2 to 8 texture units.

To get the number of units available: glGetIntegerv(GL_MAX_TEXTURE_UNITS)







Texture Units

Texture units are named GL_TEXTURE0, GL_TEXTURE1, etc.

The unit names are used with two new functions.

glActiveTexture(texture_unit)
selects the current unit to be affected by texture calls (such as glBindTexture, glTexEnv, glTexGen).

glMultiTexCoord2f(texture_unit, s, t)
Sets texture coordinates for one unit





OpenGL 1.2

In OpenGL 1.2 (including PyOpenGL), multitexturing is an ARB extension.
In this case, the names are slightly different.

Texture units:
GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, etc.
Functions:
glActiveTextureARB(texture_unit)
glMultiTexCoord2fARB(texture_unit, s, t)

To use the multitexture extension in PyOpenGL:

    from OpenGL.GL.ARB.multitexture import *
    ...
    glInitMultitextureARB()





Example

glActiveTextureARB(GL_TEXTURE0_ARB)
glEnable(GL_TEXTURE)
glBindTexture(texid1)
glActiveTextureARB(GL_TEXTURE1_ARB)
glEnable(GL_TEXTURE)
glBindTexture(texid2)
...

glBegin(GL_QUADS)
glTexCoord2f(0, 0)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0, 0)
glVertex3f(-5, -5, 0)
...





Multitexturing Uses






Detail Texture

->





Multitexture Lightmapping

->





->