Posted: Tue Nov 25
Due: Wednesday 12/3 10:00am
- 4th Period: https://classroom.github.com/a/y72xZWkp
- 5th Period: https://classroom.github.com/a/bVuQJDxr
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
Ionce per polygon. - Remember to limit
Ito 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
colorstruct usesunsigned charvalues 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
doublevalues (double *). I’ve included a function that you should use at the end to take adouble *and return acolor.
- Types are important. The
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