CS 551/645: Introduction to Computer Graphics

Assignment #7

Goal: Augment the rendering pipeline of assignment #6 to draw lit, Z-buffered polygons.

Assigned: Monday, November 8, 1999

Due: Wednesday, November 17, 1999

Relevant reading/files/software:

Update: Note that some of the models (namely, the bunny and the teapot) have their vertices defined clockwise rather than counterclockwise. Since the vertex normals are calculated by averaging the triangle normals, and the triangle normals are calculated with a cross-product, the net result is that the lighting on these models will appear "inside-out", with only ambient lighting on the outside but Phong lighting on the inside. To prevent this, you might want to add a button to your demo that flips the vertex normals, scaling them by -1. However, this is not required.

Synopsis: You will implement a library (librender.a) containing routines for rendering shaded, lit, Z-buffered 3-D triangles. These triangles will be given in world coordinates; no modeling transforms will be necessary. Your library must support everything that assignment #4 supported: the lookat() function, clipping to the view frustum, and perspective projection. In addition, Phong lighting computations should be performed at the triangle's corners and the final polygons should be rasterized as Z-buffered, Gouraud shaded triangles. You will also turn in a demo program for this assignment. At the least, your demo program should show a 3-D model from the course web page being lit by a single light source.

Specifics: You will want to reuse most of what you did for assignment 6. We are providing the header file render.h (last changed at 12:18PM Tuesday), which defines function prototypes for librender.a; you will have to fill in the source code for those functions. Your functions should rasterize the transformed clipped shaded triangles into the framebuffer implemented by the frame.c and frame.h. We provide the same files as assignment 6: gfx.c, matrix.h, matrix.c, and the usual Prof. McMillan's course page to see how to add in Z-buffering.

  • The window you are rendering into will again be square.
  • You will need to implement Phong lighting for point light sources. A number of functions are given in render.h to:
  • You will also need to implement Z-buffering, so we are providing a function to clear the framebuffer and Z-buffer before beginning to draw.
  • Note that the user may render triangles without adding ANY point light sources (i.e., using just the ambient light source). Your code should support this.
  • We promise to call functions in the sensible order.
  • draw_poly.h and draw_poly.c should help you develop a reasonable test program--it loads a ".poly" file, and renders it by making calls into your library. In fact, those, along with test_prog.h, test_prog.c, test_prog.fd, and test1.c should be a fairly functional test program.
  • Grading: A variation on the usual 10-point scale. You will be graded on correctness; a correct library will get 8 points. Assuming a satisfactory degree of correctness, you can gain up to one point of extra credit for speed. You can gain up to two points of extra credit for implementing "bells & whistles" on your demo. The two assignments that we judge best, taking into account correctness, speed, and creativity, will get an extra half point. We will compile all assignments on sgi-1.unixlab, so be sure your assignment compiles cleanly on that machine before turning it in.

    Turning in the assignment: Before class starts on the due date, you should do the usual: create a README (be sure to spell it that way: one word, all caps), edit the "SUBMIT =" line in the Makefile, and type "make submit". Make sure you include your demo files!

    Please write your full name and "Assignment #7" at the top of your README.

    Advice: The usual: start early. The library shouldn't be that hard, but creating a good demo may take a while. Leave yourself plenty of time to come to us with questions if you get stuck.