Intro Graphics Assignment 5
Lighting, Non-Photorealistic Rendering, and GPU Programming
Due: April 14, 2005
Overview
This assignment has three parts. First, you will implement Phong lighting (rather, the OpenGL variant of Phong lighting) of model vertices on the CPU. Then, you will implement a simple Non-Photorealistic (NPR) rendering technique, namely a "toon shader" or "cell shader" that simplifies and thresholds the lighting model, and adds a silhouette edge (see images below). Finally, you will implement both Phong lighting and toon shading on the GPU.
Your NPR renders might look something like this (from www.paulsprojects.net):
![]()
or this (from The Legend of Zelda: The Windwaker):
![]()
Required Features
Getting Started
Some skeleton code is here. This code was written to be a skeleton for an NPR-only assignment last semester (I added the glut_printf() function and a couple examples of how to use it). Most of the functions you should have to manipulate for the basic lighting and NPR aspects of the assignment should be contained within the student.h and student.cpp files. You will need to modify other files, but these are a good place to start. Feel free to modify this skeleton any way you see fit.
Your code should let the user switch between various modes (CPU lighting, built-in OpenGL lighting, CPU NPR, etc) and control the various parameters (e.g. the coefficients in the Phong/OpenGL lighting model) with keyboard and mouse.
To find the silhouette edges, you will need to create a data structure to represent the polygonal mesh and its connectivity. One simple example would be an array of "edges", each of which contains the two vertices which comprise the edge, and the two triangles which lay on either side. You would then selectively render the edges which you determine to be silhouettes (as defined above) as thick lines over top of the previously rendered model. If you want to explore more sophisticated data structures, look up the winged-edge and quad-edge representations.
Using the Interface
The interface for the skeleton program would not win any awards, but will get you started:
- Right-click and drag: rotates the camera (badly)
- Left-click and drag: rotates the light source (not implemented)
- Middle-click and drag up/down: changes the current parameter
(only one parameter implemented in skeleton, a uniform scaling of the wireframe color)- Up/Down arrows: zoom in and out (badly)
- 1-5: Load different models to view (note: some models may take some time to load)
Sample Assignment
A sample assignment from last year (NPR only) can be found here.
Extra Credit
Modify your cel-shading code so that triangles are rendered with an appropriate cross-hatched texture instead of simply being vertex shaded. You may use the textures provided (xhatch1.bmp-xhatch4.bmp) or some method of your own. Up to 20 pts
Find a way to make the silhouette edges look more hand-drawn, for example by making random or wavy lines. Up to 20 pts
There are many other possible cool extra credit projects with NPR and GPU programming, but check with me before embarking on any of them for extra credit.
Submission
The usual: write a web page describing what you did, including your entry for the art contest.
Your web page should contain a link to a .zip file that contains ALL of the source code that your TAs will need to build your assignment. It is your responsibility to make sure that the zip file is complete. We are not going to fix compile errors or fill in missing pieces of assignments.
Please e-mail a link to your submission to the TAs. Never, NEVER e-mail the TAs anything except a URL when submitting. In particular, do NOT e-mail your .zip file or any images as attachments.