Multitexture allows two or more textures to be applied to the same geometry. Similar effects could be obtained by drawing the geometry multiple times, each time with a different texture, but multitexture is much more efficient. Multitexture requires OpenGL 1.3 or the GL_ARB_multitexture extension. Without multitexture, there is only a single supported texture unit (SoTextureUnit SoTextureUnit SoTextureUnit ). Multitexture support allows every texture unit to maintain state that is independent of any other texture units. Each texture unit has its own texture image, texture coordinates (SoTextureCoordinate2 SoTextureCoordinate2 SoTextureCoordinate2 , SoTextureCoordinate3 SoTextureCoordinate3 SoTextureCoordinate3 , and SoTextureCoordinateFunction SoTextureCoordinateFunction SoTextureCoordinateFunction ), texture transform (SoTextureMatrix SoTextureMatrix SoTextureMatrix , SoTexture2Transform SoTexture2Transform SoTexture2Transform , and SoTexture3Transform SoTexture3Transform SoTexture3Transform ), texture enable state, and texture environment state. The texture coordinate generation is the same as with a single texture.
An SoTextureUnit SoTextureUnit SoTextureUnit node specifies the current texture unit for subsequent 2D texture nodes and the way textures will be used.
The following table shows the SoTextureUnit SoTextureUnit SoTextureUnit fields:
As in the usual texture case, there are three ways to map a texture in multitexture. You can:
specify the texture coordinates yourself.
allow Open Inventor to generate default texture coordinates.
use a texture coordinate function (SoTextureCoordinateObject SoTextureCoordinateObject SoTextureCoordinateObject , SoTextureCoordinatePlane SoTextureCoordinatePlane SoTextureCoordinatePlane , etc.) to compute the texture coordinates.
As you can see in the following figure, each texture unit is rendered the same way a single texture unit would be. You can also program a combiner. But if you don’t, the specified texture mapping (SoTexture SoTexture SoTexture :: model) will be used for each texture. In fact, MODULATE is actually a combiner which combines the incoming fragment with the texture’s fetched color, but SoTextureCombiner SoTextureCombiner SoTextureCombiner offers many more possibilities to make more complex combinations.
SoTextureCombiner SoTextureCombiner SoTextureCombiner provides a number of operations that can be performed by each texture unit. If you are not working in multitexture, it will only use the texture unit 0. So it is more appropriate for multitexturing.
Example 7.5. Multitexture
Source code for a complete program can be found in:
$OIVHOME/src/Inventor/examples/Features/MultiTexturing/MultiTexture.cxx
.