Game Development Reference
In-Depth Information
material up. At the extreme you will simply have a white disc. Before we
look in detail at how this demonstration program works we will have a
short introduction to material properties.
Using materials in OpenGL
Each material has parameters for ambient, diffuse, specular, shininess
and emission. By carefully setting these levels the material can be made
to ignore any ambient light or have a specular colour that combines with
a light's specular colour in an interesting way. The emission parameter
sets whether the material is self-illuminating or luminous. Shininess has
just the effect you would expect; it can take a value between 0 and 128.
Table 4.2 lists the parameters together with their default values.
Table 4.2 OpenGL material parameters
Parameter name
Default value
Meaning
GL_AMBIENT
(0.2, 0.2, 0.2, 1.0)
Ambient colour of material
GL_DIFFUSE
(0.8, 0.8, 0.8, 1.0)
Diffuse colour of material
GL_SPECULAR
(0.0, 0.0, 0.0, 1.0)
Specular colour of material
GL_SHININESS
0.0
Specular exponent
GL_EMISSION
(0.0, 0.0, 0.0, 1.0)
Emissive colour of material
It is worth noting that, despite having an alpha setting for most values,
only the alpha value of diffuse is used in the calculations for the alpha
component.
How lights and materials are used in the rendering of a
frame update
Firstly, we use the following enables. In the sample program these are
never altered so are placed in the window creation function.
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
 
Search Nedrilad ::




Custom Search