Light sources are specifications of a color, position, and direction. JSL allows for up to eight lights (numbered 0 to 7) defined by the Light command, where n is the number of the light.
Light( n, argument, value, ... value )
Note: To turn each light on, issue an Enable (Lighting) and an Enable (lightn) command, where n is the light number. Then, move the light to a position in the scene with a Light(n, POSITION, x, y, z) command.
The value of argument can be any one of those shown in Table 12.3. The table shows default values for each argument.
AMBIENT |
||
DIFFUSE |
||
SPECULAR |
||
POSITION |
||
SPOT_DIRECTION |
||
SPOT_EXPONENT |
||
SPOT_CUTOFF |
||
CONSTANT_ATTENUATION |
||
LINEAR_ATTENUATION |
||
QUADRATIC_ATTENUATION |
Note: The default values for DIFFUSE and SPECULAR in this table only apply to Light 0. For other lights, the default value is (0, 0, 0, 1) for both arguments.
The first three arguments (AMBIENT, DIFFUSE, and SPECULAR) are used to color the light. DIFFUSE is the argument that is most closely associated with the physical color of the light. AMBIENT refers to the property of the light when it functions as a background light. SPECULAR alters the way a light is reflected off a surface.
Specify the position of the light using the POSITION argument. Nonzero values of the fourth (w) coordinate position the light in homogenous object coordinates.
To create a spotlight, limit the shape of the light to a cone. Use the SPOT_CUTOFF argument to define the side of the cone, as shown in the following illustration.
Figure 12.16 Spotlight
In addition to the cutoff angle, you can control the intensity and direction of the light distribution in the cone. SPOT_DIRECTION specifies the direction for the spotlight to point; SPOT_EXPONENT influences how concentrated the light is.