CS 6620 Advanced Computer Graphics II - Assignment 9
Zach Gildersleeve
April 11, 2007
Required Image
There is no required image for this assignment.
Creative Image
Well, it's not the most creative image ever, but it illustrates arbitrary translation and rotation of instances. The bunny is a gridded group with a wood material as before. The grass is 10,000 instances of a single triangle, randomly translated across a plane to give the illusion of grass. Each blade has different random rotation around the y axis, and is slightly scaled along the y axis as well. Four instances of a box with a marble material are translated, rotated and sunk into the ground plane, and three instances of a reflective sphere give some funky reflections. The image took just under 5 hours to render, under significantly not optimal processing power.
Code Listing
The code for this image can be found here.
Design Choices
Two new classes were added to implement instances, and allow for arbitrary translation and rotation. The class Matrix was assembled from elements from my Point and Vector classes, as well as some adapted code form Pete Shirley's "Realistic Ray Tracing." Two important functions in Matrix are transformPoint() and transformVector(), which transform a Point or Vector by a passed in 4 x 4 matrix. As my Point and Vector classes are two separate 3 element classes, overloaded code was required to correctly deal with the missing fourth term of the Vector. The Matrix class is basically limited to the functionality required to build and use a transformation matrix.
The other class implemented is Instance. Instance is a sub-class of Primitive, and implements versions of preprocess(), intersect(), normal(), etc. A new Instance of an Object is created by passing in a reference to an object, and nine floats, which correspond to translation, rotation, and scale. These values are used to build a transformation matrix in the Instance preprocess() function, which is then used to transform incoming rays and outgoing normals.
Extra Credit
No extra credit.
Additional Comments
This assignment was actually easier than I anticipated, so it only took about 6 hours to do, not counting playing around with different images and rendering time. Most of the time was spent getting my Matrix class working. My Instance class, while not the most elegant, miraculous did something correct the first time, so only refinements were required. More time was spent troubleshooting errors that had been building up over the last several assignments.