next up previous contents
Next: 10.3 Gloss Maps Up: 10.2 Light Maps Previous: 10.2.1 2D Texture Light   Contents

10.2.2 3D Texture Light Maps

3D Textures can also be used as light maps. One or more light sources are represented in 3D data, then the 3D texture is applied to the entire scene. The main advantage of using 3D textures for light maps is that it's easy to calculate the proper texture coordinates. The textured light source can be positioned globally with the appropriate texture transformations then the scene is rendered, using glTexGen() to generate the proper $s$, $t$, and $r$ coordinates.

The light source can be moved by changing the texture matrix. The resolution of the light field is dependent on the texture resolution.

A useful approach is to define a canonical light field in 3D texture data, then use it to represent multiple lights at different positions and sizes by applying texture translations and scales to shift and resize the light. Multiple lights can be simulated by accumulating the results of each light source on the scene.

To ensure that the light source can be shifted easily, set GL_ TEXTURE_WRAP_S, GL_ TEXTURE_WRAP_T, and GL_ TEXTURE_WRAP_R_EXT to GL_ REPEAT. Then the light can be shifted to any location in the scene. Be sure that the texel values in the light map are the same at all boundaries of the texture; otherwise you'll be able to see the edges of the texture as vertical and horizontal ``shadows'' in the scene.

Although it is uncommon, some types of light fields would be very hard to do without 3D textures. A complex light source, whose brightness and range varies as a function of distance from the light source could be best done with a 3D texture. An example might be a ``disco ball'' effect where a light source has beams emanating out from the center, with some beams shining farther than others. A complex light source could be made more impressive by combining light maps with volume visualization techniques. For example the light beams could be made visible in fog.

The light source itself can be a simple piece of geometry textured with the rest of the scene. Since it is at the source of the textured light, it will be textured brightly.

For better realism, good lighting effects should be combined with the shadowing techniques described in Section 11.3.

Procedure:

  1. Create the 3D light data. A ``canonical light'' can be defined at the center of the texture volume, with the intensity dropping off in a realistic fashion towards the edges. In order to avoid artifacts, make sure the intensity of the light field is the same at all the edges of the texture volume.
  2. Define a 3D texture, using GL_ REPEAT for the wrap values in $S$, $t$, and $R$. Minification and magnification should be GL_ LINEAR to make the changes in intensity smoother.
  3. Render the scene without the lightmap, using surface textures as appropriate.
  4. Define planes in eye space so that glTexGen() will cause the texture to span the visible scene.
  5. If you have textured surfaces, adding a lightmap becomes a multipass technique. Use the appropriate blending function to modulate the surface color.
  6. Render the image with the light map, and texgen enabled. Use the appropriate texture transform to position and scale the light source correctly.
  7. Repeat steps 1-2 and 4-6 for each light source.

There are disadvantages to using 3D light maps:


next up previous contents
Next: 10.3 Gloss Maps Up: 10.2 Light Maps Previous: 10.2.1 2D Texture Light   Contents
2001-01-10