Program6
You must complete Program5 (LoadModel) before beginning Program6. Use your finished Program5 (LoadModel) as a base for Program6.
- Copy the
LoadModel
directory toProgram6
- Modify the CMakeList.txt file to build 'Program6' instead of 'LoadModel'
Add code to your new Program6 to shade the models with Phong reflectance and Gouraud and Phong shading.
Constants
- L (light intensity) should be (1, 1, 1)
- ka (ambient) RGB should be (0.1, 0.1, 0.1)
- kd (diffuse) should be the model color.
- ks (specular) RGB should be (1.0, 1.0, 1.0)
- The alpha term for specular reflectance should be 10.
The uploaded uniforms are these values:
uniform mat4 P; //projection matrix
uniform mat4 C; //camera matrix
uniform mat4 mT; //model transform
uniform mat4 mR; //model rotation
uniform mat4 M; //modelview matrix: M = C * mR * mT
uniform mat4 N; //inverse transpose of M
uniform mat4 L; //light rotation matrix
Todo:
- Shading mode 0: Normals scaled to [0,1] range
- Shading mode 1: Flat shading with model color as diffuse color
- Shading mode 2: Gouraud shading with model color as diffuse color
- Shading mode 3: Phong shading with model color as diffuse color
Hints
- GLSL has the
flat
andsmooth
qualifiers for inputs and outputs. You will need to use these. The default issmooth
. - You will need to apply all your lighting in a consistant vector space. For example, before any transfroms, after camera transform, after perspective, etc.
- You will need to set the output color from the vertex shader to the model color instead of the scaled normal.
- Use spacebar to change the shading mode, use 'r' to rotate the mode, and use 't' to rotate the light.
Program 6
Rubric | |||
---|---|---|---|
Vertex normals computed, uploaded, and used as colors | -1 : No normals | 0 : Face normals only | 1 : Correct vertex normals |
Ambient reflectance | 0 : No ambient | 1 : Ambient reflectance | |
Diffuse reflectance | 0 : No diffuse | 1 : Phong diffuse term correctly uses normal and light vector | |
Specular reflectance | 0 : No specular | 1 : Phong specular term correctly using view and light vector | |
Light rotation | 0 : Incorrect rotation | 1 : Correct reflectance for rotating light | |
Object position transformation | 0 : Incorrect reflectance after transform | 1 : Correct reflectance after transform | |
Object normal transformation | 0 : Incorrect reflectance after transform | 1 : Correct reflectance after transform | |
Flat shading | 0 : No shading | 1 : One reflectance per triangle, no interpolation | |
Gouraud shading | 0 : No shading | 1 : One reflectance per vertex, then color interpolated | |
Phong shading | 0 : No shading | 1 : Normals interpolated, then a reflectance per interpolated normal | |
Completion | 0 : On due date | 1 : Before due date |
Example cube images (normal, flat, gouraud, phong):
Example sphere images (normal, flat, gouraud, phong):
Example teapot images (normal, flat, gouraud, phong):