Specifying the Lighting Model
GLvoid glLightModelfv(GLenum pname, const GLfloat *params)
-
pname indicates which property to change
-
params is a Boolean value or array of RGBA
values
| pname |
Default Value |
Description |
| GL_LIGHT_MODEL_AMBIENT |
(0.2, 0.2, 0.2, 1.0) |
Specifies global ambient illumination; not
from any particular light source |
| GL_LIGHT_MODEL_LOCAL_VIEWER |
0.0 (infinite) |
Specifies whether viewer is local to the scene
or an infinite distance away |
| GL_LIGHT_MODEL_TWO_SIDE |
0.0 (one-sided) |
Specifies whether to perform lighting
calculations for both the front and back surfaces |
|
Notes:
GL_LIGHT_MODEL_AMBIENT specifies the ambient light
color when no lights are on. It represents light that is not from any
particular source. The default value {0.2, 0.2, 0.2, 1.0} yields a
small amount of white ambient light. So, even if you do not add a
specific light source to your scene, you can still see the objects in
the scene.
GL_LIGHT_MODEL_LOCAL_VIEWER changes the assumptions
made about the location of the viewpoint. (It does not actually move
the viewpoint).
-
With an infinite viewpoint (the default), the direction between it and
any vertex in the scene remains constant.
-
With a local viewpoint, the viewpoint is assumed to be at (0, 0, 0) in
eye coordinates. This affects the calculations of specular highlights.
The intensity of the highlight at a particular vertex depends on the
normal at that vertex, the direction from the vertex to the light
source, and the direction from the vertex to the viewpoint. A local
viewpoint tends to yield more realistic results, but since the
direction has to be calculated for each vertex, overall performance is
decreased.