The simplest model for approximating surface highlights is the Phong model, originally developed by Bui-Tong Phong. In this model, we think of the interaction between light and a surface as having three distinct components:
The diffuse component is that dot product nL that we discussed in class. It approximates light, originally from light source L, reflecting from a surface which is diffuse, or non-glossy. One example of a non-glossy surface is paper. In general, you'll also want this to have a non-gray color value, so this term would in general be a color defined as: [rd,gd,bd](nL).
Finally, the Phong model has a provision for a highlight, or specular, component, which reflects light in a shiny way. This is defined by [rs,gs,bs](RL)p, where R is the mirror reflection direction vector we discussed in class (and also used for ray tracing), and where p is a specular power. The higher the value of p, the shinier the surface.
The complete Phong shading model for a single light source is:
[ra,ga,ba] + [rd,gd,bd]max0(nL) + [rs,gs,bs]max0(RL)p
If you have multiple light sources, the effect of each light source Li will geometrically depend on the normal, and therefore on the diffuse and specular components, but not on the ambient component. Also, each light might have its own [r,g,b] color. So the complete Phong model for multiple light sources is:
[ra,ga,ba] + Σi( [Lr,Lg,Lb] ( [rd,gd,bd]max0(nLi) + [rs,gs,bs]max0(RLi)p ) )
Below you can see three different shaders for a sphere. In all cases, the sphere is lit by two light sources: a dim source from the rear left (-1,0,-.5) and a bright source from the front upper right (1,1,.5). The spheres have, respectively, no highlight, a highlight with an exponent of p = 4, and a highlight with an exponent of p = 16.