Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Multitexturing

Concepts

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). 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, SoTextureCoordinate3, and SoTextureCoordinateFunction), texture transform (SoTextureMatrix, SoTexture2Transform, and SoTexture3Transform), texture enable state, and texture environment state. The texture coordinate generation is the same as with a single texture.

Multitexture and texture coordinates

An 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 fields:

mappingMethod (SoSFEnum) Specifies the mapping method used for texture mapping. IMAGE_MAPPING is the classic mapping method.
unit (SoSFUInt32) Specifies the texture unit identifier. Can range from 0 to the largest texture unit, which is getMaxTextureUnit() -1.

Example:

Two textures applied on the same shape

As in the usual texture case, there are three ways to map a texture in multitexture. You can:

  1. specify the texture coordinates yourself.
  2. allow Open Inventor to generate default texture coordinates.
  3. use a texture coordinate function (SoTextureCoordinateObject, 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::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 offers many more possibilities to make more complex combinations.

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.

Texture combiner pipeline

Example : Multitexture Source code for a complete program can be found in:

$OIVHOME/src/Inventor/examples/Features/MultiTexturing/MultiTexture.cxx.

Multitexturing