Silicon Graphics

[Prev] [TOC] [Next]



(-) OpenGL Programming Guide

Chapter 6
Lighting

Chapter Objectives

After reading this chapter, you'll be able to do the following:

As you saw in Chapter 5 , OpenGL computes the color of each pixel in a final, displayed scene that's held in the framebuffer. Part of this computation depends on what lighting is used in the scene and on how objects in the scene reflect or absorb that light. As an example of this, recall that the ocean has a different color on a bright, sunny day than it does on a gray, cloudy day. The presence of sunlight or clouds determines whether you see the ocean as bright turquoise or murky gray-green. In fact, most objects don't even look three-dimensional until they're lit. Figure 6-1 shows two versions of the exact same scene (a single sphere), one with lighting and one without.

[IMAGE]

Figure 6-1 : A Lit and an Unlit Sphere


As you can see, an unlit sphere looks no different from a two-dimensional disk. This demonstrates how critical the interaction between objects and light is in creating a three-dimensional scene.

With OpenGL, you can manipulate the lighting and objects in a scene to create many different kinds of effects. This chapter explains how to control the lighting in a scene. It discusses OpenGL's conceptual model of lighting, and it describes in detail how to set the numerous illumination parameters to achieve certain effects. Toward the end of the chapter, the mathematical computations that determine how lighting affects color are presented.

This chapter contains the following major sections:


(+) Real-World and OpenGL Lighting
(+) A Simple Example: Rendering a Lit Sphere
(+) Creating Light Sources
(+) Selecting a Lighting Model
(+) Defining Material Properties
(+) The Mathematics of Lighting
(+) Lighting in Color-Index Mode

[Prev] [TOC] [Next]

OpenGL Programming Guide


Maintained by Maintainer: Send e-mail to .htm">name@address.