Posted: Mon Apr 27
Due: Monday 5/4 10:00am
- 4th Period: https://classroom.github.com/a/fRkkquY-
- 5th Period: https://classroom.github.com/a/tWMiZc3S
5th period!
The GH classroom assignment did not include the source code, you can find it here:
- https://github.com/stuycs-gh-classrooms/gfx-10-lighting
Important note:
If your test image uses a mesh file, make sure the path to that mesh file is ../mesh_files/ and include the download command for your mesh as a dependency for your custom makefile target.
Lighting!
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