CS248 Project 2

As Kurt described in the first lecture, the first rule of interactive graphics is to ensure that there are no misleading changes from frame-to-frame. In this project, you will explore some fundamental techniques for conforming to this rule. While completing this project you should be extremely picky! Look for anything on the screen that shouldn't be there and try to figure out how to get rid of it.

We are providing a simple OpenGL program (in C) that demonstrates some of these problems. Feel free to port the code to another language if you like. The code renders a rotating pinwheel with (initially) 32 arms.

Source code: project2.cpp (Updated on Wednesday, October 17th)

Key Dates


This project requires you to experiment with sampling and answer a series of questions. You should answer them in the form of a web page or pdf, which you will zip up and submit from this page.

As we have seen in demos, aliasing is a primary source of errors in animation. In the lectures we discussed two possible methods for anti-aliasing: pre-filtering and over-sampling. In this project, we'll only look at super-sampling using the OpenGL accumulation buffer.

Supersampling is done using a weighted set of samples. The set of samples implements a filter. There are many sets of samples that implement the same filter. For example, a 4x4 regular grid of equally weighted samples implements a box filter, as does a 4x4 jittered grid. One of them, however, is a superior implementation of a box filter.

For this assignment you should consider the following filters and sampling strategies:

Filters: box, tent, cone, Gaussian, or Mitchell filter

Sampling strategies: regular grid, n-rook, n-queen, random, jittered, or Poisson

You can also experiment with your own filters or sampling strategies if you wish, just be sure to explain what you did in your write up.

0) In the first lecture, we saw that our brain will perceive animation if still images are flashed quickly before our eyes. However, if the images are not flashed quickly enough, we will perceive a series of still images rather than smooth animation. At the top of project2.cpp, there is a variable update_ms, which controls how frequently the screen is redrawn. Experiment with changing this variable. At what frequency does your brain shift from seeing a series of still images to seeing an animation? At what frequency does the animation seem smooth?

1) In class Kurt discussed two kinds of aliasing--aliasing of the fundamentals and aliasing of the harmonics. Aliasing of the harmonics leads to jaggies. What false motion cues are introduced into the pinwheel animation by jaggies? To explore the aliasing of fundamentals problem, increase the number of arms on the pinwheel to 256. Why does the animation now look worse?

2) From Kurt's discussion in lecture, in one or two sentences explain why super-sampling should help improve the visual results.

3) Try enabling the super-sampled patterns given in the display function (a 2x2 and a 15x15 box filter). Briefly explain how super-sampling affects the aliasing of fundamentals and of harmonics.

4) Notice that when super-sampling is enabled the center of the pinwheel appears to darken. Explain why this happens (your answer should discuss gamma and gamma correction). Uncomment the call to gammaCorrect in display. Adjust the value of the gamma global parameter until the center of the pinwheel appears to have the correct brightness. Report this value.

(The following questions all assume a pinwheel with 256 arms.)

5) For one filter and one sample pattern, experiment with increasing the sample count (e.g. from 3x3 regular grid to 9x9 regular grid both using a box filter) while holding the filter extent constant. Try a few different sample counts. Sketch a graph of sample count vs. subjective quality and include it as an image in your report. How many samples are needed before you can't see any improvement?

6) What happens when the filter weights do not add up to one? Provide a screenshot and explanation for the case where they add up to 0.5 and the case where they add up to 2.0.

7) Using a large fixed number of samples (64 or more), increase the size of your filter so it covers more than one pixel. This should blur your image. What filter size optimizes the tradeoff between improved anti-aliasing and increased blurriness?

8) Select (at least) 3 filters and 3 patterns and implement them in the provided code. Subjectively rate the resulting quality of all 9 combinations using very few samples (8 or fewer) and using many samples (64 or more). Take screen shots and include images of each in your write up. Clearly label each image with which sample pattern was used, which filter was used, and your subjective rating of its quality (eg 'good', or 'too blurry'). Do some filters or patterns work better with few samples or with lots of samples? Why?

9) Combine your results from the previous questions and produce the best looking pinwheel animation you can. Provide a screen shot and describe what parameters you used.

10) A form of aliasing that we discussed briefly in class is motion aliasing. If you increase the speed of the pinwheel, its direction will appear to reverse (the wagon wheel in a movie problem). This aliasing is due to the fact that we are point sampling in time. We can improve the results by super-sampling the animation in time; the result is called motion blur. Read the Accumulation Buffer paper for details and implement motion blur. What sampling patterns work best for reducing motion aliasing? To guide you, what filter function in time does a standard camera use, and is this optimal from a sampling point of view?

Extra Credit

11) Implement a tent filter function with 16 equally weighted samples. No two samples should be in the same place. Provide a screenshot of the output and an explanation of the math you used to decide where to place your samples. Hint: Place more samples where the tent function is high valued and few where it is low valued. You can do this by carving up the tent function into 16 equal volume regions and assigning a single sample to each region. Be warned that long skinny regions will produce a worse result than regions that are closer to circular in footprint. You could also use a probabilistic approach.


This project is worth 15% of your final grade.

If you submit late, you will be penalized with a cap on your maximum possible score, at a rate of 10% per day until you submit your final version. Remember that the course outline affords you one day of grace for the course, which you may use for this assignment.


You should answer the questions in the form of a web page or a pdf. No .doc files please. Submit a zip file of your submission here. If it's very large, or if you have problems with the submission script, contact the TAs. You may submit as many times as you like, so submit early and often.

Email Address
Submission zip


For this project, we suggest reviewing past lectures, and your textbooks.

Your other main resource is the course TAs, Justin, Andrew, and David, who can be reached at cs248-aut0708-staff@lists.stanford.edu, by attending their office hours, or after a lecture for quick questions.

CS248 staff
Last modified: Mon Oct 15 12:48:13 PDT 2007