The OpenGL lighting model makes the approximation that a material's color
depends on the percentages of the incoming red, green, and blue light it
reflects.
For example, a perfectly red ball reflects all the incoming red light
and absorbs all the green and blue light that strikes it. If you view such a
ball in white light (composed of equal amounts of red, green, and blue light),
all the red is reflected, and you see a red ball. If the ball is viewed in pure
red light, it also appears to be red. If, however, the red ball is viewed in
pure green light, it appears black (all the green is absorbed, and there's no
incoming red, so no light is reflected).
|
|
|
For materials, the numbers correspond to the reflected proportions of those colors. So if R=1, G=0.5, and B=0 for a material, that material reflects all the incoming red light, half the incoming green, and none of the incoming blue light. In other words, if an OpenGL light has components (LR, LG, LB), and a material has corresponding components (MR, MG, MB), then, ignoring all other reflectivity effects, the light that arrives at the eye is given by (LR*MR, LG*MG, LB*MB).
Similarly, if you have two lights, which send (R1, G1, B1) and (R2, G2, B2) to the eye, OpenGL adds the components, giving (R1+R2, G1+G2, B1+B2). If any of the sums are greater than 1 (corresponding to a color brighter than the equipment can display), the component is clamped to 1.
Like lights, materials have different ambient, diffuse, and specular colors,
which determine the ambient, diffuse, and specular reflectances of the
material. A material's ambient reflectance is combined with the ambient
component of each incoming light source, the diffuse reflectance with the
light's diffuse component, and similarly for the specular reflectance and
component. Ambient and diffuse reflectances define the color of the material
and are typically similar if not identical. Specular reflectance is usually
white or gray, so that specular highlights end up being the color of the light
source's specular intensity. If you think of a white light shining on a shiny
red plastic sphere, most of the sphere appears red, but the shiny highlight is
white.