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.4.
There are disadvantages to using 3D light maps: