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.
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.
Press 's' to toggle showing suggestive contours.
Press 'esc' to exit the program.
The program reads an .obj file from stdin.
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.
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.
|Dragon with tonal shading and contours.
||Dragon with suggestive contours added.
|Teapot with tonal shading and contours.
||Teapot with suggestive contours added.
|Hand with tonal shading and contours.
||Hand with suggestive contours added.
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.
|Horse with tonal shading and contours.
||Horse with suggestive contours added.
|Cow with tonal shading and contours.
||Cow with suggestive contours added.
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.
- The source code and example files can be downloaded here.
You should be able to run the program by running:
> ./SuggestiveContours < input_file.obj
As usual, please be aware that this is by no means polished software; it was written for a weekly
Design and code ©2012 Julian Panetta