VARKON Version 1.15 1997-10-24
material_view - Procedure
Sets material characteristics for shading
Description
Links a material to a pen number and sets its parameters. Initially no pens are linked to materials and the shader uses the standard color of the pen as set up in the Varkon resource- or ini-file or created with the cre_color() routine. If a material is defined the shader will use the characteristics of the material instead of the ordinary color when the specified pen is used. 8 different materials may be defined and accociated with pens one through eight.
A material is defined by 4 different light components each with a red, green and blue (RGB) value. A shininess factor may also be defined, a total of 13 float parameters which all must be set.
The ambient component sets how much ambient light the material reflects. The diffuse component sets the amount of diffuse light reflected and the specular component sets the amount of specular light reflected. The emitted component sets the amount of light emitted from the material itself (not reflected). The emitted component may be used to create a luminous material.
Syntax
material_view(pen, ar, ag, ab, dr, dg, db, sr, sg, sb, er, eg, eb, sh)
INT pen; FLOAT ar, ag, ab; FLOAT dr, dg, db; FLOAT sr, sg, sb; FLOAT er, eg, eb; FLOAT sh;
Principal parameters
pen - The pen number to link to the material. 1 - 8 ar - Ambient red ag - Ambient green ab - Ambient blue dr - Diffuse red dg - Diffuse green db - Diffuse blue sr - Specular red sg - Specular green sb - Specular blue er - Emitted red eg - Emitted green eb - Emitted blue sh - Shininess
Optional parameters
None..
Examples
material_veiw(1, 100, 0, 0, 100, 0, 0, 100, 0, 0, 0, 0, 0, 50);
A red material linked to pen 1 equally sensitive to ambient, diffuse and specular light but with no emitted light and medium shininess.
material_veiw(1, 50, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0);
A darker and less shiny red material.
Comments
A complete description of how to use light and material parameters to create different effects is not possible to give here. Please check with the litterature on OpenGL and similar graphics software.
A quick guide could be to start with ambient only. Ambient produces no shading but gives the right colors. You could think of it as a sort of background light which is always present everywhere. Add diffuse light to produce more realistic shades. The object now becomes brighter so the ambient level may have to be reduced. Diffuse light reminds of the light you would expect from the sun with some cloudiness. Finally add specular to give a more shiny surface. Use the shininess factor to concentrate or spread the reflected light. Specular light reminds of the very sharp light directly from the sun with no cloudiness.
Note that the Varkon resource- or ini-file sets the common ambient, diffuse and specular parameters for all lights but material_view() sets these for each material independantly.