Next | Prev | Up | Top | Contents | Index

Optimizing Lighting Performance

OpenGL offers a large selection of lighting features: Some are virtually "free" in terms of computational time, others offer sophisticated effects with some performance penalty. The penalties some features carry may vary depending on the hardware you're running on. Be prepared to experiment with the lighting configuration.

As a general rule, use the simplest possible lighting model, a single infinite light with an infinite viewer. For some local effects, try replacing local lights with infinite lights and a local viewer.

You normally won't notice a performance degradation when using one infinite light, unless you use lit textures or color index lighting.

Use the following settings for peak performance lighting:


Lighting Operations With Noticeable Performance Costs

Follow these guidelines to achieve peak lighting performance:


Lighting Operations With Significant Performance Costs

The features described in this section are classified as having significant costs because any one of them, when added to high-performance lighting, causes a substantial drop in performance. However, while adding more features has still higher cost, the additional penalty is small compared to the initial drop from high-performance lighting. Follow these guidelines to limit use of lighting features that significantly reduce performance:


Practices to Avoid

Avoid using lighting calls inside a glBegin()/glEnd() sequence.

If possible, avoid calls to glMaterial() during a glBegin()/glEnd() drawing sequence, as this has a serious performance impact. While making such calls to change colors by changing material properties is possible, the performance penalty makes it unadvisable. Use glColorMaterial() instead.


Next | Prev | Up | Top | Contents | Index