

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Due date: October 17th, 11.59.59 pm
Delivery: Source code and screenshots to [email protected]
Problem: Write a program to render images using per-pixel and per-vertex lighting for point lights for both diffuse and specular reflections.
First, download the template solution for this assignment. The solution already contains the teapot model, sets up the modeling/view and projection matrices and should display models on the screen immediately after building and executing it. In order to complete this assignment with 100%, only write shader code in appropriate files. No need to touch/modify cpp/h files. Also, uniform variables are already set and assigned.
Per-vertex lighting:
Start off with implementing the shaders as described in lectures 8 and 9. You shouldn’t be having any problems with this at all.
Add your code to perVertexDiff.frag / perVertexDiff.vert for diffuse lighting only. Add your code to perVertexDiffSpec.frag / perVertexDiffSpec.vert for diffuse and specular lighting.
Per-pixel lighting:
In order to implement per-pixel lighting, the lighting computations must be performed in fragment shaders, not vertex shaders. Your vertex shaders will have to pass at least the following information down the pipeline to fragment shaders using “varying” variables:
Add your code to perPixelDiff.frag / perPixelDiff.vert for diffuse lighting only. Add your code to perPixelDiffSpec.frag / perPixelDiffSpec.vert for diffuse and specular lighting.
The code is set up to use the aforementioned shader files and display models as shown in the picture on the first page.
TOPLEFT – Per-vertex diffuse + specular TOPRIGHT – Per-pixel diffuse + specular BOTTOMLEFT – Per-vertex diffuse only BOTTOMRIGHT – Per-pixel diffuse only
Diffuse-only renderings will give you very similar results. However, you must be able to see difference between per-vertex and per-pixel specular lighting in terms of banding artifacts. Final images should look similar to what’s on the first page. However, you have the freedom to tweak lights/colors/highlights as you wish.
BONUS (Point lights):
The shader code from lectures 8 and 9 was written for point lights. Bonus points will be awarded if you implement spot lights (25% extra for this assignment). No code for spot lights was given in class, you need to figure this out. If you decide to do this, only show images with spot lights (no need to show images with point lights, because the code for point lights is a subset of what you’ll have to do for spot lights). You might have to modify cpp/h files for this part too.