[ Previous | Next | Contents | Glossary | Home | Search ]
GL3.2 Version 4.1 for AIX: Programming Concepts

## Lighting Execution Time and Performance

The lighting equation is evaluated whenever the normal or the graphics position changes, depending on whether the viewer and light sources are local. If the viewer is local, or any of the light sources are local, then the lighting calculation is performed when the graphics position changes (for example, when a v3f command is issued).

When the viewer is local, the vector from the vertex to the eye is different for each vertex and has to be calculated for each point. If the viewer is at infinity, then view vector is constant for all vertices and the calculation time is less. When a light source is local, the vector from the vertex to the light source is different for each vertex and has to be calculated for each vertex. If a light is at infinity, then light direction vector is constant for all vertices and the calculation time is less.

Performance is highest when an infinite viewer and a single infinite light source are used in the lighting calculation. Execution time increases slightly for each infinite light source added to the computation. However, the addition of local light sources increases the execution time noticeably.

After a normal is transformed by the inverse transpose of the modeling/viewing matrix, it must be renormalized if the transforming matrix is not orthonormal. This renormalization takes additional time and results in lower performance.

A matrix is orthonormal if each of its row vectors is of unit length and orthogonal to the others. Rotations and translations are always orthonormal. Shear transformations are never orthonormal. Because GL does not have any built-in shear transformations, the only transformations that might generate a nonorthonormal modeling/viewing matrix are the multmatrix and loadmatrix subroutines, and the scale subroutine when the x, y, and z scale factors are not equal.

Note: If the transformation has been made nonorthonormal by introducing a shear or other nonorthonormal transformation, the system is automatically renormalizing normal vectors. In such a case, you do not need to feed normalized normal vectors to the system because they are renormalized anyway. Note, however, this should not be used as a trick to avoid explicit normalization by the user application.

[ Previous | Next | Contents | Glossary | Home | Search ]