*This page was last updated: January 31, 2018*

Project #1 asked you to create your own object in a Vulkan program. Project #2 is asking you to add lighting to it.

In the sample.cpp code, you already have a start on this with the
**lightBuf** struct having the **uLightPos** vec4 in it.
You need to add:

- Ka
- Kd
- Ks
- Light Position
- Light Specular Color
- Shininess
- Eye Position

Keep the 'm' and 'i' keys doing what they used to do. But, add a 'l' (ell) key to turn lighting off and on.

Feel free to add more keyboard inputs to control more aspects of the lighting if you want.

In your video, somehow demonstrate that this all works. This could be by:

- Demonstrating the features by toggling them off and on with keyboard keys.
- Animating the features by using the uTime uniform variable.

I recommend you copy the Sample2017 folder and edit the sample.cpp file.

You can define your object with either direct drawing with a vertex data buffer, or with an indexed draw with a vertex data buffer and index buffer.

The file LightingForClass.zip cointains lighting shaders for use with OpenGL. Remember that you need to Vulkan-ize them.

Use the Teach system to turn in your:

- A one-page PDF with a title, your name, your email address, nice screen shots from your program, and the link to the Kaltura video demonstrating that your project does what the requirements ask for. I'd like you to narrate your video so that you can tell me what you did.

http://cs.oregonstate.edu/~mjb/cs557/Handouts/lighting.1pp.pdf

// uniform variable block: struct matBuf { glm::mat4 uModelMatrix; glm::mat4 uViewMatrix; glm::mat4 uProjectionMatrix; glm::mat4 uNormalMatrix; }; // uniform variable block: struct lightBuf { float uKa; float uKd; float uKs; glm::vec4 uLightPos; glm::vec3 uLightSpecularColor; float uShininess; glm::vec4 uEyePos; };

glm::vec3 eye(0., 0., EYEDIST); glm::vec3 look(0., 0., 0.); glm::vec3 up(0., 1., 0.); Matrices.uViewMatrix = glm::lookAt( eye, look, up ); Matrices.uProjectionMatrix = glm::perspective( FOV, (double)Width/(double)Height, 0.1, 1000. ); Matrices.uProjectionMatrix[1][1] *= -1.; Matrices.uNormalMatrix = glm::mat4( glm::inverseTranspose( glm::mat3( Matrices.uModelMatrix ) ) ); // initialize the light position: Light.uKa = 0.1f; Light.uKd = 0.6f; Light.uKs = 0.3f; Light.uEyePos = glm::vec4( eye, 1. ); Light.uLightPos = glm::vec4( 0., 0., 10., 1. ); Light.uLightSpecularColor = glm::vec3( 1., 1., 1. ); Light.uShininess = 20.f;

// change the viewing matrix: glm::vec3 eye(0., 0., EYEDIST); //glm::vec3 look(0., 0., 0.); //glm::vec3 up(0., 1., 0.); //Matrices.uViewMatrix = glm::lookAt(eye, look, up); // change the normal matrix: Matrices.uNormalMatrix = glm::mat4(glm::inverseTranspose(glm::mat3(Matrices.uModelMatrix)));

// non-opaque must be in a uniform block: layout( std140, set = 0, binding = 0 ) uniform matBuf { mat4 uModelMatrix; mat4 uViewMatrix; mat4 uProjectionMatrix; mat4 uNormalMatrix; } Matrices; layout( std140, set = 1, binding = 0 ) uniform lightBuf { float uKa; float uKd; float uKs; vec4 uLightPos; vec3 uLightSpecularColor; float uShininess; vec4 uEyePos; } Light;

Feature | Points |
---|---|

Ka, Kd, Ks | 25 |

Light Position | 25 |

Light Specular Color | 25 |

Shininess | 25 |

Potential Total | 100 |