Andy Zeng
Uniform/Adaptive Tessallation

Bézier Surfaces

Bézier surfaces are a species of mathematical spline used in computer graphics, computer-aided design, and finite element modeling. As with the Bézier curve, a Bézier surface is defined by a set of control points. Similar to interpolation in many respects, a key difference is that the surface does not, in general, pass through the central control points; rather, it is "stretched" toward them as though each were an attractive force. They are visually intuitive, and particularly for computing tessallation, mathematically convenient. This project (triangles and shading) was rendered in OpenGL, however the math and code behind tessallation was all written from scratch. Credits to UC Berkeley professor O'Brien's helpful powerpoint slides! The magic and beauty of this form of tessallation lies in its simplicity. With only a few points, one could easily generate an unbelievably smooth-surfaced teapot. Since threholds for how far each polygon is tessallated can be set rather easily, many games use this technique to optimize the rendering of 3D objects in space: the further away the object is from the camera, the fewer number of tessallations performed, and vice versa (giving the illusion of a very detailed 3D world while maximizing performance).

Program Features and Notes

- Reads in a list of patch data from a file.
- Subdivides the patch using either a uniform or adaptive subdivision technique. Both techniques are implemented, the program uses a command-line flag to determine which is used.
- When "s" is pressed the program will toggle between flat and smooth shading.
- When "w" is pressed the program will toggle between filled and wireframe mode.
- When "h" is pressed the program will toggle between filled and hidden-line mode.
- When the arrow keys are pressed the object will be rotated.
- When the shift+arrow keys are pressed the object will be translated.
- When launched the initial zoom will show the entire object. Pressing the +/- keys will zoom in/out.
- The program takes two command line arguments with a third option parameter. These are: the input file name, the subdivision parameter, and a flag which determines if subdivision should be adaptive or uniform.
- An example command looks like (produces the image on the right):

            bezier_surf.exe teapot.bez 0.1 -a

- The input file contains a list of patches. The subdivision parameter is interpreted as the step size in U and V for uniform subdivision, or as an error measure for adaptive subdivision. If the -a is present, then adaptive subdivision is used, otherwise uniform.
- The input file contains the control points for the patches and an output file name. Keep in mind that the control points are vectors, not scalars!
- Again, all tessallation code was written from scratch!
- You can find the final version of the executable here. You can also find a sample input file here.
- Video gallery here.

Gallery - Uniform

The following images were produced using uniform tessallation. Quadrilateral polygons are formed by taking parameter sized steps in the U and V direction. Additional features include smooth shading vs. flat shading, wireframe mode, and hidden line mode.

Gallery - Adaptive

The following images were produced using adaptive tessallation. The error between the actual surface and the quadrilateral polygon are less than the specified parameter. The error is the distance evaluated at the midpoints of the polygon edges and the center of each quadrilateral. Techniques to avoid cracking are used in the adaptive subdivision code. Additional features include smooth shading vs. flat shading, wireframe mode, and hidden line mode.

Gallery - Extra .OBJ File Parser

.OBJ is a simple 3D surface file format, described here and elsewhere on the web. In it's simplest form, it is just a list of vertices followed by a list of faces (potentially just triangles). My program additionally recognizes if the input file has a .obj extension instead of .bez and directly displays the polygons in the OBJ file if so. The following images were produced from a few different .obj files. Additional features such as wireframe mode and smooth shading were applied to a few of these images.