next up previous contents
Next: 6.19.3 3D Textures as Up: 6.19 3D Textures Previous: 6.19.1.1 3D Textures vs.   Contents

6.19.2 3D Textures to Render Solid Materials

A direct 3D texture application is rendering solid objects composed of heterogeneous material. An example is rendering a statue made of marble or wood. The object itself is composed of polygons or NURBS surfaces bounding the solid. Combined with proper texgen values, rendering the surface using a 3D texture of the material makes the object appear cut out of the material. With 2D textures objects often appear to have the material laminated on the surface. The difference can be striking when there are obvious 3D coherencies in the material, combined with sharp angles in the object's surface.

Rendering a solid with 3D texture is straightforward:

Create the 3D texture
The texture data for the material is organized as a three dimensional array. Often the material is generated procedurally. As with 2D textures, proper filtering and sampling of the data must be done to avoid aliasing. A mipmapped 3D texture will increase realism of the object. OpenGL does not support a gluBuild3DMipmaps() command, so the mipmaps need to created by the application. Be sure to check to see if the size of the texture you want to create is supported by the system, and there is sufficient texture memory available by calling glTexImage3DEXT() with GL_ PROXY_TEXTURE_3D_EXT to find a supported size. You can also call glGet() with GL_ MAX_3D_TEXTURE_SIZE_EXT to find the maximum allowed size of any dimension in a 3D texture for your implementation of OpenGL, though the result may be more conservative than the result of a proxy query.
Create Texture Coordinates
For a solid surface, using glTexGen() to create the texture coordinates is the easiest approach. Define planes for $s$, $t$, and $r$ in eye space. Adjusting the scale has more effect on texture quality than the position and orientation of the planes, since scaling affects how the texture is sampled.
Enable Texturing
Use glEnableGL_ TEXTURE_3D_EXT(GL_ TEXTURE_3D_EXT) to enable 3D texture mapping. Be sure to set the texture parameters and texture environment appropriately. Check to see what restrictions your implementation puts on these values.
Render the Object
Once configured, rendering with 3D texture is no different than other texturing.


next up previous contents
Next: 6.19.3 3D Textures as Up: 6.19 3D Textures Previous: 6.19.1.1 3D Textures vs.   Contents
2001-01-10