Programming Assignment 4: Shaded Rendering and Depth-Buffering
Due Tuesday, December 8 at 11:59pm

In this assignment will write your own implementation of the depth-buffering algorithm, along with computation of the illumination and shading of triangles.

Program Template:

There is no program template for this assignment. 

You can develop your own program from scratch, or you can use parts of past programming assignments and labs if you find it helpful to do so. 

In Programming Assignment 1, you developed code that rasterizes and fills triangles, allowing smooth interpolation of vertex colors.  You could use this as a starting point for your implementation in this programming assignment.  A working example for Programming Assignment 1 is also provided with materials for the lab on November 18. You are welcome to reuse parts of these programs if you wish.  However, you may find it easier to play out your object classes and write a clean implementation from scratch, using hints described in class.

You may also find it helpful to use the scene file format and scene viewer that will be provided in the lab on November 18.  A description of the format for the model files is provided here.  However, this is not required. And while you are welcome to use the scene reader code, beware: you are not permitted to use OpenGL to render the images presented in the demo – instead you write your own rendering methods, producing an image in the frame buffer (very similar to what you did for the triangle drawing in Programming Assignment 1).


There are a number of options for extra credit for this assignment. 

·       CS680 students are required to complete at least one extra credit, which will be counted as part of the assignment grade.

·       CS680 students may complete up to 2 additional extra credits

·       CS480 students may complete up to 2 extra credits


Part of your grade for this programming assignment will be based on your giving a short demo (10 minutes) in the CS instructional laboratory. You will be expected to talk about how your program works.

Source Code Submission

Your program's source files are to be submitted electronically. Use the gsubmit program on the CS cluster.

The code you submit should conform to the program assignment guidelines.


Your own, correct implementation of the depth-buffer algorithm for triangles

You can assume an orthographic camera model

15 points

Rotation and translation of the camera, rotation, scaling, and translation of objects

15 points

Generate triangle meshes solid objects with vertex normals:


·       Ellipsoid, sphere

·       Cylinder with end caps

·       Box

·       Torus


You will likely need to create a class for triangle meshes, a class for surfaces, and a class for solids.



20 points total

(5 points each)

Your own implementation of polygon rendering methods:


·       Flat surface rendering – compute the triangle plane normal for this

·       Gouraud rendering – interpolate vertex colors determined by lighting equation

·       Phong rendering – interpolate normal and apply lighting equation at each pixel


Provide a keyboard interface that allows the user to change rendering method: F, G, P

25 points


Correct implementation of illumination equation (combined diffuse, specular, and ambient) and demonstration of the lighting model and colored lights in the three different scenes you define, with at least 3 differently shaped solid objects and at least 2 lights in each scene.


Your implementation must support:


·       Point light source

·       Infinite light source

·       Ambient light source

·       Attenuation: radial and angular


Provide a keyboard interface that allows the user to toggle on/off specular term, diffuse term, ambient term: S, D, A.


Provide a keyboard interface that allows the user to toggle on/off each of the lights in your scene model: Hit L key, then 1, 2, 3, 4, etc., to identify which light to toggle on/off.

15 points

Define materials and their properties:


·       Coefficients of reflection for each color channel (R,G,B): ka, kd, ks

·       Specular exponent: ns


Provide a keyboard interface to change the materials for solid objects in the scene model and redisplay.

10 points

(10 points) bump mapping
(10 points) environment mapping

(10 points) shadow mapping

(10 points) superellipsoids and supertoroids


Late Assignment Policy

Late programming projects and problem sets will be levied a late penalty of 12% per day (up to three days). In other words, lateness will be penalized at 0.5% per hour late. After three days (72 hours) no credit will be given.

Collaboration/Academic Honesty

The code you submit must be your own. If you find/use information about specific algorithms from the Web, etc., then be sure to cite the source(s) clearly in your source code.

Please be aware that the code submitted for this course is automatically analyzed using a code plagiarism detection program. Code flagged as suspicious by the detection program will be examined by the teaching staff and action will be taken in cases of plagiarism. BU Academic Conduct Code.

All instances of academic dishonesty will be reported to the Academic Conduct Committee.

Stan Sclaroff

Last edited:  November 12, 2015