## Homework 8, due Monday, Nov 24.

Because it turned out to be giving many of you so much trouble, I'm going to extend the deadline again for z-buffer based scan conversion.

What follows below is a preview of what's coming next, which those of you who are working faster can do for extra credit.

If you only use Gouraud shading your surfaces will look dull, lifeless, boring, blah. That's because they don't have highlights. One cool thing about highlights is that, in addition to being all bright an shiny, they change as the object moves. In this way, highlights provide useful visual information about shape and motion.

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:

• Ambient
• Diffuse
• Specular
The ambient component is the same as that value of 0.2 that we use in Gouraud shading. It approximates light coming from a surface due to all the non-directional ambient light that is in the environment. In general, you'll want this to be some color [ra,ga,ba]. For example, a slightly greenish object might have an ambient color of [0.1,0.3,0.1].

The diffuse component is that dot product nL used in Gouraud shading. 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 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, which can be defined by: 2 (ne) n - e, where e is the unit-length direction vector from the surface to the camera eyepoint.

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](nL) + [rs,gs,bs](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](nLi) + [rs,gs,bs](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.