*This page was last updated: January 27, 2019*

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
- Shininess
- Light Position
- Light Specular Color
- Eye Position

'l' (ell) | Toggle lighting on and off |

'm' | Toggle display mode (textures vs. colors) |

'r' | Toggle rotation-animation and using the mouse |

Esc, 'q' | Exit the program |

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 Sample2019 folder and edit the sample.cpp file.

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; float uShininess; glm::vec4 uLightPos; glm::vec4 uLightSpecularColor; 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.uShininess = 20.f; Light.uEyePos = glm::vec4( eye, 1. ); Light.uLightPos = glm::vec4( 0., 0., 10., 1. ); Light.uLightSpecularColor = glm::vec4( 1., 1., 1., 1. );

// 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; float uShininess; vec4 uLightPos; vec4 uLightSpecularColor; vec4 uEyePos; } Light;

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

Ka, Kd, Ks | 25 |

Light Position | 25 |

Light Specular Color | 25 |

Shininess | 25 |

Potential Total | 100 |