Posted: Tue Nov 25

Due: Wednesday 12/3 10:00am

Implement the Phong Reflection model with flat shading. (reminder: if you look up information online, do not confuse this with Phong Shading).

  • You should be calculating I once per polygon.
  • Remember to limit I to be in the range [0, 255]. You may not want to do this all at once at the end.
  • There are a lot of user-defined values in lighting calculation, eventually, we will to be able to set them in our scripts. For now, pass them around to the necessary functions, and set them in either your main or parser functions. This is modeled in the provided source code.
  • For those working in c:
    • Types are important. The color struct uses unsigned char values to represent each color value. This can be a problem if in the process of one of the lighting calculations, you end up with a value outside of [0, 255].
    • The straightforward solution is to have each lighting function return an array of 3 double values (double *). I’ve included a function that you should use at the end to take a double * and return a color.

Here are the lighting values used in the source code:

  • View vector: <0, 0, 1>
  • Ambient light: 50, 50, 50
  • Point light location: <0.75, 0.75, 1>
  • Point light color: 255, 255, 255
  • Constant of ambient reflection: 0.1, 0.1, 0.1
  • Constant of diffuse reflection: 0.75, 0.25, 0.25
  • Constant of specular reflection: 0.25, 0.25, 0.75