Defines a new material, light, or lighting model.
FORTRAN (libfgl.a)
void lmdef (Int16 deftype, Int32 index, Int16 numpoints, Float32 properties[ ])
SUBROUTINE LMDEF(deftype, index, numpoints, properties) INTEGER*4 deftype, numpoints, index REAL properties(numpoints)
Note: For FORTRAN users, this subroutine accepts long integer parameters (INTEGER*4) when started from a FORTRAN program, although it accepts short integers when started from a C program. The C and FORTRAN syntax shown here reflect this difference.
The lmdef subroutine defines a new material, light, or lighting model.
The type of definition (material, light, or lighting model) is specified by the deftype parameter. The definition is read from the properties array and stored in the appropriate definition table at the index specified by the index parameter.
You can make incremental changes to a material, light, or lighting model definition. Each call to the lmdef subroutine changes only the properties specified in the properties array.
Any property of any definition can be changed regardless of whether that definition is currently bound. Changes made to a definition that is currently bound by the lmbind subroutine are effective immediately.
Index 0 (zero) of the material, light, and lighting model definition tables contains predefined definitions. These predefined definitions have set all properties to their default values and cannot be changed. Their values are as follows:
Value | Function |
DEFMATERIAL | Turns off lighting. Most efficient way to disable calculations. Equivalent to lighting model 0. |
DEFLIGHT | Turns off lighting. Binding light 0 to a light turns off that light. |
DEFLMODEL | Turns off lighting. |
To turn off lighting, bind material 0 as the current material. You can also turn off lighting by binding lighting model 0 as the current lighting model, but this method is less efficient than binding material 0. To turn off a light, but not all lighting calculations, bind light definition 0 to the light you want to turn off.
There is a unique properties table for each category of definition created by this routine (materials, light sources, or lighting models). Indexes within each of these categories are independent. Valid entries for this parameter range from 1 to 65535. In each category, index 0 is reserved.
For maximum efficiency, use the default values for all properties. Lighting model performance is best if relatively few properties are changed from the default. A definition can be reset to all default values by calling the lmdef subroutine with the symbolic constant LMNULL as the first command token in the properties array.
The default lighting model values are as follows:
AMBIENT | 0.2, 0.2, 0.2 |
LOCALVIEWER | 0.0 |
ATTENUATION | 1.0, 0.0 |
Notes:
- The operation of this subroutine for the Supergraphics Processor Subsystem is modified. (See "Hardware Considerations".)
- This subroutine cannot be used to add to a display list.
deftype | Category in which you want to create a new definition. There are three categories:
| ||||||||||||||||||||||||||||||||||||||||||
index | Specifies the index into the table of stored definitions. | ||||||||||||||||||||||||||||||||||||||||||
numpoints | Specifies the number of floating-point values contained within the properties array. | ||||||||||||||||||||||||||||||||||||||||||
properties | Specifies an array that contains the definition to store at the index parameter. A definition is a grouping of properties and values ended by the symbolic constant LMNULL. There is a total of 13 defined symbolic constants (command tokens) that identify the properties of a definition. The valid symbolic constants for the properties parameter are shown in the following table.
|
The example C language program cylinder2.c uses the lmdef subroutine to define the properties of two materials and two lights, and to define a lighting model.
This subroutine is part of GL in the AIXwindows Environment/6000 Version 1, Release 2 with AIXwindows/3D Feature.
On the POWERstation 730 and POWERgraphics GTO, the specular reflection exponent (as set with the SHININESS symbolic constant of the lmdef subroutine properties parameter) is truncated to the nearest power of 2 before computing lighting. The only valid values for the specular exponent are 1, 2, 4, 8, 16, 32, 64, and 128.
The POWERstation 730 and POWERgraphics GTO do not support lighting in color index mode.
Materials with different material properties on each side are supported on the POWER Gt4 class of graphics adapters. Support for two-sided lighting is accomplished with the following token:
Type | DEFLMODEL |
Property | TWOSIDE |
Function | The TWOSIDE token followed by 0.0 disables two-sided lighting; followed by 1.0 enables two-sided lighting. |
When two-sided lighting is disabled, the direction of the normal vector solely affects how a material is lit. When the normal vector points towards the viewer, there will typically be a positive contribution to the ambient, diffuse and specular terms of the lighting equation (based, of course, on the material properties, the light positions and colors) When the normal points away from the viewer, there will only be a contribution from the ambient term, and the surface will not appear shiny and reflective (This is because all terms in the lighting equation involving a dot product with the normal vector are clamped to zero, and are not allowed to go negative. If the normal points away from the user, such dot product terms will be clamped to zero, no mater what the light positions might be.)
When two-sided lighting is enabled, the manner in which lighting is performed depends on whether the polygon being lit is front-facing or back-facing. If the polygon is front-facing (the polygon vertices were specified in counter-clockwise order in screen coordinates), then lighting is performed as usual. If the polygon is backfacing, then the direction of the normal vector is reversed before it is used in the lighting equation (that is, it is multiplied by -1 before being used.). Thus, if two-sided lighting is enabled, and if the normal vectors were specified consistently with the handedness of the polygon, then both sides of the polygon will have diffuse and specular contributions,
If a material has been bound to the BACKMATERIAL token, then this material will be used when the back-side lighting is being computed. Otherwise, both front and back-facing polygons will be lit with the MATERIAL properties.
Two-sided lighting can only be enabled for, and affects only polygons and triangle strips. Points, lines and characters are always lit as if two-sided lighting were disabled.
The default lighting model is: | |
AMBIENT 0.2, 0.2, 0.2 | |
ATTENUATION 1.0, 0.0 | |
LOCALVIEWER 0.0 | |
TWOSIDE 0.0 |
Note: To obtain the desired lighting effect with two-sided lighting, one must be careful that the direction of the normal vector is consistent with the handedness of the polygon. If the direction of the normal vector is accidentally reversed, then both sides of the polygon will appear dark.
/usr/include/gl/gl.h | Contains C language constant and variable type definitions for GL. |
/usr/include/gl/fgl.h | Contains FORTRAN constant and variable type definitions for GL. |
Setting the current color in RGB mode with the c subroutine.
Setting the current color as a single packed 32-bit integer with the cpack subroutine.
Making a new material, light, or lighting model definition active with the lmbind subroutine.
Changing the target of the color commands with the lmcolor subroutine.
Specifying a normal vector with the n3f subroutine.
Updating the current normal vector with the normal subroutine.
Setting the current color in RGB mode with the RGBcolor subroutine.
AIX Graphics Library Overview, Creating Lighting Effects, Setting Pipeline Options, and Working in Color Map and RGB Modes.