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 Light Arguments and Default Values. The table shows default values for each argument.
(x, y, z, w) position
(x, y, z) direction of spotlight
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.
where c = CONSTANT_ATTENUATION, l = LINEAR_ATTENUATION, and q = QUADRATIC_ATTENUATION.
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.
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.
Light Arguments and Default Values shows the three valid arguments for the Light Model command.
Normal vectors are set at the same time the surface is constructed, and are specified with the Normal command. Use the Enable(NORMALIZE) command to have the normals re-normalized to 1 each time the scene is drawn.
where mode can be SMOOTH (the default) or FLAT. SMOOTH shading interpolates the colors of the primitive from one vertex to the next. FLAT mode duplicates the color of one vertex across the entire primitive.
The following script changes the color at each of a triangle’s vertices. The FILL shade model interpolates the color of the interior automatically.
Shading
Material( face, argument, value,...value )
face can be Front, Back, or Front_and_back. (Note that the material properties can be set separately for the front and back faces of a polygon.)
Material Arguments and Default Values shows the arguments and default values for Material arguments.
Both AMBIENT and DIFFUSE
The BlendFunc command allows for alpha blending. To use it, send a BlendFunc message to a scene, for example:
SRC_ALPHA and ONE_MINUS_SRC_ALPHA are OpenGL constants that tell BlendFunc to use alpha to blend against the existing display buffer. Disabling z-buffer testing or rendering primitives from back to front might be needed for some applications. By default, the z-buffer tests prevent anything from drawing behind a transparent polygon after it is drawn.
Complete details of all the constants available to BlendFunc (many of which are not useful to the JSL programmer) are available in the OpenGL documentation at opengl.org.
Fog