CS 6620 Advanced Computer Graphics II - Assignment 6

Zach Gildersleeve
March 7, 2007

Required Image

Here is the required image, as produced by the program.

required6.ppm

The bunny is made from 69451 triangles. With the current implementation of my raytracer, it would take approximately 37800 seconds (about 10.5 hours) to render these triangles and the resulting reflections. With a basic grid acceleration structure, the above image was rendered in close to 33 seconds.

Code Listing

The code for this image can be found here.

Debugging

Below are a few images generated during the debugging of the grid acceleration structure. The grid itself seemed to work as intended, but several key bugs produced incorrect results initially. The first image below was the result of adding every triangle to every cell in the grid, for somewhere near 50 billion triangles. Needless to say, this took a while to render, and so I stopped this render early. The second image saw the full speedup expected for the acceleration structure, but the parameter checking for parallel rays in the Triangle intersection function missed many triangles. Making the epsilon smaller produced the correct image.

Design Choices

For an acceleration structure, I implemented a basic grid. This required several new classes. BoundingBox implements a simple bounding volume structure, and allows new points to build onto the box by checking if they represent new minimum or maximum values. Each primitive that was used in the required image and the creative image implements a function to calculate and return the bounding box for each individual primitive. The GriddedGroup is an extension of the Group class, and is built using some of the code from the HeightField class. The most intensive aspect of this new class is the preprocess method, which calculates the bounding box of the entire GriddedGroup based on the combined bounding boxes of its associated objects. Using the number of cells passed in as a parameter, the size and grid coordinates for each cell is calculated. Each cell is implemented as class Cell, which holds a local bounding box, as well as a pointer to a Group that will represent a list of all objects thought to be contained in each Cell.

Once the Cell locations are known, GriddedGroup counts the occurrences of each object (added initially to a queue) in each cell, based on the cells bounding box. Memory for all cells is allocated all at once. Finally, the objects that occur in each cell are added to the Cell's Group to be accessed later. The GriddedGroup intersection is a 3D extension of the intersection routine in HeightField. If the appropriate Cell is found to contain any objects, each object is intersected individually.

Creative Image

My creative image is the now classic Andy Warhol duplication of the Stanford bunny. There are about 625073 primitives in this image, and it took 95 seconds to render. The material for each bunny is typically a Phong material with different parameters, but there is two different Metal materials (lower left and upper center) as well as a purple Dielectric material in the upper right. Each of the bunnies is placed in front of a box (typically) although two bunnies are placed in front of spheres for some different shading. The bunny in the left center cell has every 15th triangle replaced with a red sphere. With the above image, only one grid is used, and all bunny triangles are placed in this single grid. I found that for this particular image, this rendered quicker than adding multiple grids.

Extra Credit

No extra credit.

Additional Comments

The required image took me about 12 hours, and was fairly straightforward given the methods presented in class. The creative image took about 3 hours to do.