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( C++ | Java | .NET )). 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( C++ | Java | .NET ), SoTextureCoordinate3( C++ | Java | .NET ), and SoTextureCoordinateFunction( C++ | Java | .NET )), texture transform (SoTextureMatrix( C++ | Java | .NET ), SoTexture2Transform( C++ | Java | .NET ), and SoTexture3Transform( C++ | Java | .NET )), texture enable state, and texture environment state. The texture coordinate generation is the same as with a single texture.
An SoTextureUnit( C++ | Java | .NET )node specifies the current texture unit for subsequent 2D texture nodes and the way textures will be used.
The following table shows the SoTextureUnit( C++ | Java | .NET ) fields:
As in the usual texture case, there are three ways to map a texture in multitexture. You can:
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( C++ | Java | .NET ):: 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( C++ | Java | .NET ) offers many more possibilities to make more complex combinations.
SoTextureCombiner( C++ | Java | .NET )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
.