Introduction
This lab implements non-photorealistic rendering with tone shading, contours, and suggestive contours. All of the rendering is done in glsl with vertex and fragment shaders. This takes all of the rendering load off the cpu and results in much higher perfomance. I implemented the suggestive contours by using the Gaussian curvature at each vertex to find, by interpolation, a line of zero Gaussian curvature. I have not gotten the real directional curvature working yet.
User Interface
Mouse interaction:
Mouse input exactly the same as the supplied viewer code. The only difference is I've added a "Non-Photorealistic" option to the draw menu that appears when right clicking.

Click and drag to rotate the model using an arcball interface. Shift- or Ctrl-clicking restricts rotation to a plane. Dragging with the middle mouse button zooms in and out on the object.

Key interaction:
Press 's' to toggle showing suggestive contours.
Press 'esc' to exit the program.
Input File Format
The program reads an .obj file from stdin.
GPU Approach
I managed to do all of the contour drawing on the GPU. I did this by transferring all the contour candidates (all the mesh edges) to the GPU with the normals of their two adjacent triangles as attributes. Then the GPU does the transformation of the normals, the computation of the eye vector, and the dotting of these vectors that is required to determine if the edge is a contour.

I do a similar thing with the suggestive contours, passing all the potential suggestive contours to the GPU along with the corresponding curvature gradient as an attribute, and the vertex shader decides whether or not the contour should be drawn based on the eye vector.
Good Results
The suggestive contours for these objects add a lot to the illustrated effect. They are not too noisy and are, for the most part, intuitive.

Not So Good Results
While the contours and tonal shading still worked will for these models, the suggestive contours were very noisy. I tried filtering them by using a threshold as described in the suggestive contours paper, but that tended to remove the contours I wanted in addition to the spurious ones.
Obtaining
This program is written in C++ using GLUT. It should compile on most Linux, Windows, and Mac OS X machines if the proper libraries are installed. You should be able to run the program by running:
> make > ./SuggestiveContours < input_file.obj
As usual, please be aware that this is by no means polished software; it was written for a weekly assignment.
Design and code ©2012 Julian Panetta
Valid HTML 4.01 Strict