What is Specular Reflection and How is it Computed?

Two other tutorials in this chapter deal with ambient and diffuse reflection. The focus of this tutorial is specular reflection and specular highlights.

The perceived color of a surface due to specular reflection without the inclusion of shininess is computed in a similar way as diffuse reflection, namely,

I = M*L*cosine(A)

where M is the material's specular color and L is the color of the light source's specular component. The angle A for specular reflection is the angle between the viewpoint direction and the direction relative to the light source versus between the vertex normal and the light direction. The light direction in the case of an omni light is the vector from the vertex to the position of the light. For a spotlight, the direction is from the vertex to the position of the light provided that this direction is within the cone of the spotlight. If the light is directional, then its direction is used in the calculation of the angle. There are two choices for the viewpoint direction, local and infinite. For the infinite option, the vector (0.0, 0.0, 1.0) is used independent of the vertex location; this is the default option. On the other hand, the direction from the vertex to the actual eyepoint in world coordinates is used with the local option. Since the vector varies with each vertex, the local option makes the computations more intense but the specular highlight is more realistic as seen when the eyepoint moves.

Shininess is a material property. Its range of values is [0.0, 128.0]. For a material that is more shiny, the specular highlight is more concentrated at the vertex producing the specular highlight. By decreasing the shininess, we make the material more glossy than shiny. The shininess factor is included in the computaton as an exponent on the cosine(A), as seen in the following:

I = M*L*cosine(A)^shininess
Last, recall that when the vectors are normalized the dot product of the two vectors gives the cosine of the angle.