CS 248 - Introduction to Computer Graphics
Spring Quarter, 1995
Demos on Wednesday, May 31
Writeups due on Thursday, June 1 by 5:00pm
Your assignment is to layer on top of your polygon scan converter a module that implements 3D viewing transformations and a module that implements Z-buffer hidden-surface removal. You will also modify your supersampling postprocess to work together with these two modules. With the addition of shading in assignment #4, you will have a complete rendering pipeline capable of generating realistic (well, sort of) antialiased pictures of 3D scenes.
subpixwindowfunction from appendix A of Haeberli and Akeley to implement your shifts. Set
ypixelsto the width and height of your canvas in pixels, respectively. For
pixdy, use the subpixel offsets in your sample distribution pattern (e.g. fractions between -0.5 and +0.5 for pixels spaced one unit apart and a box resampling filter of width equal to the pixel spacing). We do not require progressive refinement for this assignment (or assignment #4). To speed up debugging, we suggest either eliminating it or providing a option to disable it, i.e. to display only your final image.
To help you create interesting scenes to render, we are providing two programs: i3dm, an SGI demonstration application, and Composer, written by Brian Curless and Apostolos Lerios using tools from Inventor - SGI's 3D graphics toolkit. i3dm allows you to interactively define several types of curved surfaces, which it outputs as triangle meshes. Composer allows you to interactively assemble scenes composed of 3D boxes and triangle meshes from i3dm. Composer also allows you to specify viewing parameters, define directional or point light sources, and specify reflectance properties for each object in the scene. For scenes of modest complexity, Composer provides real-time shaded renderings as feedback.
To transfer a scene from Composer to your renderer, Composer provides an "Export scene" button, an "Export camera" button, and an "Export both" button. When pressed, the scene description and object properties (for Export scene) or viewing parameters (for Export camera) are written to binary files with extensions ".sc" and ".cam", respectively. A filter program is available to convert these binary files into text files in case you want to edit them. You should provide a "Load scene" button, a "load camera" button, and a "Load both" button in your program. Documentation of routines for loading the binary or text formats of .sc or .cam files, and a description of the text file formats, are given in /usr/class/cs248/support/composer/README. Also contained in that file are some hints on using i3dm and Composer. Please read this file. before asking us questions; it answers many FAQs.
Using the "Export" buttons in Composer and the "Load" buttons in your program, you can model a scene in Composer, specify a viewpoint using Composer's real-time shaded renderings, then transfer the scene and camera specification to your program for rerendering. Although the way you specify a view (using sliders) and the way Composer does it (using a combination of sliders, thumbwheels, and direction manipulation) are different, the .cam file Composer constructs for you will allow you to match the view you see in Composer, assuming that you compose your transformations in the order that we suggest. The views will not match perfectly because of differences in clipping, antialiasing, shading, and scan conversion algorithms between your renderer and Composer. Nevertheless, the ability to compare your view with Composer's view is a powerful debugging tool - use it!
A hint regarding the interface between your program and Composer. When you load viewing parameters, you should reset your sliders to match the loaded values. This may give rise to the following difficulty. The viewing parameters Composer passes you, in particular those that specify parameters of the viewing frustum, are floating point numbers and are not constrained to lie within any particular interval. If you map a large interval of these parameters linearly to your sliders, the views that will typically interest you will occupy only a tiny portion of the slider range, making it difficult to specify a view using your sliders. We suggest one of two strategies to avoid this difficulty: (a) Employ a linear mapping that covers only a small interval surrounding the values given to you by Composer, changing the interval whenever you load a new set from Composer, or (b) Make your sliders cover a large interval that can accommodate any reasonable values given to you by Composer, but employ a nonlinear mapping from each slider to the associated viewing parameter. Experiment a bit to find a strategy that you like. If you choose (a), xsupport doesn't allow you to modify the displayed endpoints dynamically, so just display something generic like -10 to 10, indicating (linear) placement relative to a dynamic middle value (the Composer input).
For off-campus students, the executable of Composer (but not i3dm) is available for copying. The source is not available, so recompilation for other platforms is not an option. If you wish to develop your renderer entirely on another platform, you can create scene descriptions that match Composer's format by hand-generating text files in the documented format. Several example files are available for debugging your scene description reader. These files are in /usr/class/cs284/data/models.
We will follow the same demo and submission procedure as in the last assignment. The assignment will be graded on correctness (60 points), efficiency (20 points), programming style (10 points), and the elegance of your user interface (10 points).
Your program should be capable of reading the files output by Composer (although you don't need Composer in order to generate them, as discussed above). Be prepared to demonstrate your program on grader data files that we will provide on the spot during the demo. Please provide file loading buttons as already explained. Be prepared to handle up to 10000 triangles. Try to anticipate every nasty scene we will want to test. In particular, test for degenerate triangles twice - once on your 3D scene as you load it (both i3dm and Composer sometimes create degenerate triangles), and again on your 2D coordinates before rasterization (to discard triangles that, after transformation, are being viewed on edge).
You may work alone or in teams of two or three. For a team of two, you must implement two of the following bells and whistles. For a team of three, you must implement five. Alternatives are acceptable if approved in advance. If you have completed the assignment and wish to earn extra credit, you may add more bells and whistles.
translatein GL (SGI's graphics library) causes the translation to be applied before the perspective mapping. Be prepared to show example images. For motion blur, be prepared with an image that shows motion not aligned with the screen X,Y axes.