Project 3

Shading

In this project, the goal was to implement Blinn-Phong shading. With the framework I build from the past two assignments, this wasn’t too hard to do.

From before

In the previous assignment, I was rendering a bunch of points on a mesh. To get to the picture I posted above, some changes need to be made.

Drawing a surface

First, I changed the primitive type from a point list:

...To a triangle list!

Drawing Normals

Next, I upload vertex normals in addition to vertex positions.

Uploading vertex normals is exactly like uploading vertex positions.

For materials using vertex normals, since my vertex normals aren't interlaced with my vertex positions, I create a new binding in vkVertexInputBindingDescription and vkVertexInputAttributeDescription

In the picture above, I just render the vertex normals as if they were vertex colors.

Uploading lights and Blinn Phong

Finally, I create a new uniform buffer object containing a list of light information. This uniform buffer is updated every frame, and is added as a parameter in the descriptor layout/set for this particular material.

I access that light buffer in GLSL, which has lights stored in world space. I then transform them to eye space, and compute lighting in eye space in a loop in my fragment shader.

TODO: move to differed rendering...

Program controls

  • esc closes the window
  • R resets the camera position
  • Click and drag to move the camera
  • Arrow keys move the camera
  • +/- zoom in and out

Build instructions

  1. If you don't have it already, download cmake
  2. Download and install the Vulkan SDK from here: https://www.lunarg.com/vulkan-sdk/
  3. Clone the project: https://github.com/n8vm/InteractiveComputerGraphics
  4. Generate the project with CMake
  5. Build and run any targets in the project

Resources Used

C++, Visual Studio 2017, CMake, Vulkan, GLFW, GLM

Hardware

Intel HD Graphics 620, Intel Core i7 - 8500U CPU @ 4.0GHz, 16GB of memory

Nvidia GTX 1070