Next: 2.3.1 Types of Lighting Up: 2 Example Walk Through Previous: 2.2.3 Back-face Culling

2.3 Lighting

The realism of a computer generated 3D scene is greatly enhanced by adding lighting. In the first article's sample program, glColor3f was used to add color to the faces of the 3D cube. This adds color to rendered objects but does not use lighting. In the example, the cube moves but the colors do not vary the way a real cube might as it is affected by real world lighting. In this article's example, lighting will be used to add an extra degree of realism to the scene.

OpenGL supports a sophisticated 3D lighting model to achieve higher realism. When you look at a real object, its color is affected by lights, the material properties of the object, and the angle at which the light shines on the object. OpenGL's lighting model approximates the real world.

Complicated effects such as the reflection of light and shadows are not supported by OpenGL's lighting model though techniques and algorithms are available to simulate such effects. Environment mapping to simulate reflection is possible using OpenGL's texturing capability. OpenGL's stencil buffers and blending support can be used to create shadows, but an explanation of these techniques is beyond the scope of this article. (See the topics in the final chapter of the OpenGL Programming Guide).



mjk@asd.sgi.com
Wed Oct 19 18:11:46 PDT 1994