Game Development Reference
In-Depth Information
Figure 4.1 Cone angle for spotlights.
Ambient, diffuse and specular are parameters that all OpenGL lights
share. Each of these parameters has four components, one each for the
red, green, blue and alpha. The ambient parameter sets the level of
illumination that the light throws out that is not connected with position or
direction. This lights all surfaces in the scene regardless of their
orientation to the light. If you want full blacks in your scene then this must
be set to zero. If the scene wants to have a general blue tinge, or orange
tinge, then the ambient level is the best place to start for illumination. The
level that is set for each component is a value between 0 and 1 in the
same way that colours are indicated. The diffuse level is the colour of the
light; if you have a blue light then the diffuse level may well be set to (0.0,
0.0, 0.7, 0.0), which will be a very blue light. The specular component
defines the colour of the beam that lights the highlighted part of a surface
that is shiny. If the material for a polygon is matt, then this parameter will
have no effect. If, however, the material is shiny then it will define the
colour of the specular highlights.
Before we go any further you are highly recommended to play with the
demonstration software for this chapter. Take a look on the CD and find
the GLLighting example in the Chapter04 folder. The software lets you
experiment by adjusting the ambient, diffuse and specular levels of the
light. You are also encouraged to adjust the material properties for the
surface of the sphere that is presented in the OpenGL display. The only
material properties that you can adjust in this demonstration software are
the emission level and the diffuse colour. In order to limit the number of
sliders in the control box, one slider controls all four values for the
ambient, diffuse and specular levels of the light. This is simply a restriction
Search Nedrilad ::




Custom Search