|
|
|
|
| |
3D Texture Mapping
|
Sections
|
Memory Impact 3D Light Mapping Volume Visualization 3D Detail Texturing References and Links
| |
|
Introduction
Support for 3D texture mapping refers to a graphics accelerator's
ability to address and appropriately filter a 3D texture
map when rasterizing a graphics primitive. This is not
a radical rendering paradigm shift, it is simply an additional
dimension in texture data. Triangles are still triangles
and the frame buffer is still pixels. That said, for certain
applications, 3D textures have advantages over the 1D
and 2D textures that are in common use today.
- After addressing memory usage issues, we will cover three applications of 3D textures in this tutorial:
-
- 3D Light Mapping
- Volume Rendering
- 3D Detail Texturing
We also provide a number of Sample Applications for OpenGL® which use the EXT texture3D extension as well as Direct3D® versions using DirectX® 8.
| |
|
Memory Impact
- Making effective use of texture memory is already a major task for real-time 3D content. Adding an additional dimension to a texture map increases its memory footprint significantly. There are four major techniques you can use to improve 3D texture mapping performance on the Radeon®:
-
- Keep textures small. Small volumetric light
maps can do the job just fine. Lots of magnification
will increase texel locality of reference and
thus improve on-chip texel cache performance.
- Repeat and mirror where appropriate. Volume
detail textures can be repeated to great effect.
Use mirroring address modes for symmetrical textures
like volumetric light maps. The "mirror once"
addressing mode is especially useful with 3D light
maps. This is exposed in OpenGL® via the ATI_texture_mirror_once
extension and in DirectX® 8 via the D3DTADDRESS_MIRRORONCE
texture addressing mode.
- Keep texture bit-depth as low as possible. Volumetric
detail textures and light maps are often grayscale.
For these, use a single-channel texture.
- Use Compression. The Radeon® supports the DXV1
through DXV5 volumetric compression formats. Developers
should make the appropriate size/quality tradeoff
for their application.
These techniques will be used in the following examples.
| |
|
3D Light Mapping
In order to decouple geometry tesselation-level from detailed lighting of the geometry, light mapping was developed. At the cost of additional memory for storing and accessing light maps, sophisticated lighting can be done while minimizing geometry cost. This can produce amazing results for static scenes illuminated with static light sources.
Complex Geometry
Handling the case of light mapping for dynamic lights or dynamic scenes can be problematic, however. Calculating appropriate texture coordinates for complex geometry can be both awkward and costly. Using a 3D texture to compute the distance attenuation term of the lighting equation can provide an elegant solution to the problem. This can be done very concisely by using the texture matrix to transform the geometry into the space of the light source.
Extended Light Sources
Light sources for real-time computer graphics are generally modeled as simple points or direction vectors. Light sources with "extent" such as a long fluorescent tube or more complex shapes are not generally modeled. Using 3D texture mapping, the distance attenuation term of extended light sources can be encoded in a 3D light map, giving the developer the ability to model the effect of an extended light source very easily.
The Lighting Equation
In our examples, we will use an 8-bit grayscale 3D texture to represent the distance attenuation term in the diffuse term of our lighting equation:
| |
|
Dm ×
|

|

|
Ai +
|

|
(N·L × DistAtten)i
|

|
+ Sm ×
|

|
(N·H)ki + Em
|
| |
|
- where
-
- Dm and Sm are the Diffuse
and Specular material properties
- Ai is the Ambient illumination from
light i
- N·L is the Lambertian term for light i
- DistAtten is the Distance Attenuation term for
light i
- (N·H) k i is the Specular
term for light i
- Em is the Emissive material property
There is nothing absolute about this lighting equation. While there are a variety of other terms that one can use in a lighting equation, some sort of distance attenuation term is very common.
Minimizing Memory Usage
We use two tricks to minimize the memory footprint of our 3D light maps. As mentioned above, we use an 8-bit texture map to encode the distance attenuation term of the light source modeled by the 3D light map. Additionally, we use the "mirror once" addressing mode to exploit the axial symmetry which naturally occurs in 3D light maps. If we want the light source to have a color other than white, we can use a constant color or texture factor to color the lightsource in the pixel pipe.
| |
|
Volume Visualization
3D Volume Visualization is motivated by the relatively
recent development of the digital medical imaging modalities
which include Magnetic Resonance Imaging (MRI), Computed
Tomography (CT) and Positron Emission Tomography (PET)
and the desire to interactively view the acquired 3D data
from arbitrary viewpoints.
Viewing a volume from an arbitrary position requires reconstructing and resampling the volume along rays from the viewpoint through each pixel in the image plane. If the resampled points are constrained to spherical slices through the dataset, we can use a series of spherical shells consisting of texture mapped polygons in the reconstruction process, as shown in the figure below:
| |
|

Volume Reconstruction Geometry
|
|
|
The spherical shells shown above are composited back-to-front into the framebuffer. Depending on the desired application and the source of the imaging data, different compositing math (frame buffer blending) can be used. The texture coordinates for the spherical shells are assigned dynamically, using their camera space position and a texture matrix to allow transformation of the image data. In this way, the image data can be scaled, translated and rotated interactively by the user.
We will cover the specifics of Radiography, Opacity-based Compositing, Gradient-Based Compositing, some novel improvements on the current state of the art and possible applications in the entertainment space.
Radiography
Digitally reconstructing a radiograph is done by combining the resampled values behind each pixel to approximate the attenuation integral:
| |
|
Pixel Intensity = 1 - exp
|

|

|
ui d
|

|
| |
|
where
ui are the resample values behind a pixel d is the distance between sample values This technique is implemented in the RadeonVolVis Sample.
Opacity-Based Compositing
A similar technique to the radiographic technique above can be used to visualize opaque structures in volumetric data. Simple alpha-testing can be used to reject 3D texel values which lie outside of the opaque region in the volume data as shown in the Figure n below.
[Here, we could visualize two structures at once. Set the alpha channel for one of the structures to be in a high range of alpha space and one in the low range. Then switch the sense of our alpha-compare and draw the "other" structure.]
In Figure n and Figure n+1 above, the structures appear to be illuminated from a fixed point relative to the volumetric data set. This is because we have pre-computed the illumination and stored it in the LUMINANCE channel of a LUMINANCE_ALPHA 3D texture (with the opacity used in the alpha-test stored in the ALPHA channel of the texture).
This raises the issue of how to compute illumination of the dataset at runtime. [Westermann] stores a surface normal at each 3D texel, precomputed from the desired isosurface and, using the color matrix, is able to perform N·L per-pixel for diffuse illumination of the dataset from a single lightsource.
As a variation on this theme, we propose using a per-pixel dotproduct operator exposed. Results are shown in Figure m below as well as in forthcoming samples.
Future Experiments
- In the future, we will cover other 3D texture applications
here. Such experiments are likely to include:
-
- Clipping/Sculpting/CSG
- Gradient-Based Compositing
- Extensions to Entertainment
- Better explosions
- Volume displays a la The World is Not Enough.
Show how to correctly overlay with normal polygonal
objects in the scene
- X-Ray screen a la Total Recall
| |
|
Detail Texture Mapping
|
|
|
For complex or procedurally generated geometry it is often easier to assign 3D texture coordinates than to come up with some 2D mapping which makes sense and avoids visual artifacts. In fact, for online-generated procedural geometry, there is no opportunity for an artist to go in and assign 2D texture coordinates. In this case it is natural to use the fractional part of the 3-dimensional object or world space coordinates as 3D texture coordinates. This causes a volume of texels to tile throughout space as polygons "carve" through the volume.
The hollow torus in the figures below has no texture coordinates but, rather, uses texture coordinate generation based on object-space position. The images are from the RadeonVolumeTexture sample and use the stencil capping technique from the Rage128StencilCap sample. All of the geometry, including the "capping plane" is textured with the same volumetric (blue marble) texture and the user can slide the clipping plane in space to reveal the consistent solid "inside" of the torus. This consistency of the marble pattern from the outer surface of the torus to the capped surface of the torus would not be possible with 2D texture mapping.
| |
| |
|
|
|
- References
-
- Timothy J. Cullip and Ulrich Neumann, "Accelerating
Volume Reconstruction with 3D Texturing Hardware,"
Technical Report TR93-027, University of North
Carolina, Chapel Hill, N.C., 1993.
- Bradley M. Hemminger, Timothy J. Cullip and
Michael J. North, "Interactive Visualization of
3D Medical Image Data,"
- Rüdiger Westermann and Thomas Ertl, "Efficiently
Using Graphics Hardware in Volume Rendering Applications,"
ACM Computer Graphics, SIGGRAPH '98, pp. 169-177.
| |
|
- Volumetric Datasets
-
-
|
| |
| |
 |
|
|
|