CMSC 435/634: Introduction to Computer Graphics

Assignment 6
Z-Buffer (opt/grad)
Due November 12, 2002

The Assignment

This assignment is required for 634 students. For 435 students, this project, including all of the extra credit portions, will be scaled to a maximum of 22 points of extra credit.

For this assignment, you will be modifying assignment 2 to use the z-buffer visibility algorithm for polygons specified with 4-element homogeneous vertices. You will need to change the input parser from assignment 2 to accept four coordinates values instead of just two for each vertex. You will also need to change your program from assignment 2 to emulate the glVertex4f function instead of glVertex2f, to interpolate z across the polygons in addition to r, g and b. You must emulate glVertex4f, but unless you are doing the perspective extra credit, you may always use w=1. You don't need to draw the polygon outlines for this assignment.

You must also create the input file to demonstrate your project. The input file should contain a list of polygons, each described by lines in the following format:

v1_x v1_y v1_z v1_w v1_r v1_g v1_b
v2_x v2_y v2_z v2_w v2_r v2_g v2_b
v3_x v3_y v3_z v3_w v3_r v3_g v3_b

Your input file should demonstrate the following features: Correct visibility for a cycle of overlapping polygons (a) and an intersection between polygons with changing z values (b). It is OK to only use vertices inside the viewing frustum (no clipping is necessary for this assignment), and to choose a simple orthographic projection (w=1 for all vertices).

cycle of triangles
intersecting polygons


Plan ahead first. The Z-buffer is most easily implemented as an array of floating point numbers the size of the screen. You can treat z and w just as extra parameters to interpolate until it is time for the visibility computations.

Rendering is often implemented as a pipeline of simpler stages. By the end of this assignment, you will have experience with all aspects of this pipeline: creation of polygonal models from more complex surface descriptions (splines, assignment 3) or procedurally (island, assignment 4), transformations and perspective (matrices in assignment 5), clipping (midterm problem 3), homogeneous division (extra credit, this assignment), scan conversion (assignment 2) and z-buffering (this assignment). You should start with your existing assignment 2 code rather than starting from scratch. A sample assignment 2 scan converter is available if yours didn't work right. It is available in ~olano/public/435/assn6.

Extra credit

For the base assignment it is enough to have a handful of isolated triangles in the input file to demonstrate the required features. For up to 10 points of extra credit, make it an interesting object instead. If you do this, you may want to provide a README file that says where to look for the cycle and intersection examples in your object. You may also want to increase GRIDSIZE if the 50x50 grid is too coarse to create your object.

Additional extra credit

For an additional 10 points, implement perspective z-buffering by allowing w values other than 1. You will need to perform the homogenous divisions, x/w, y/w and z/w in your myVertex4f function. You will also need to provide an input file with w values other than 1 to demonstrate your perspective z-buffering. Remember, the input file for this assignment mimics the results after transformation and clipping, so you will need to make sure that the homogenous points you provide make sense and all land inside the visible window. 

What to turn in

Turn in this assignment electronically as 'cs435 Proj6' (or after the due date as Proj6late) using the submit mechanism:

    submit cs435 Proj6 [files...]

The usual assignment boilerplate applies as always -- submit all files you've created or modified; we must be able to build and run on the GL systems to grade, if you develop elsewhere leave sufficient time to port back; comments are your friend and ours, they're a good idea and they can improve your grade. In either case, you should all files that you created or modified.