Homework 6 - Instancing
I implemented Instancing into my program. An instance is a sub-class
of Shape, just like all my other primitives. Each instance stores a
inverse transformation matrix which is initialized to the identity matrix.
An instance can then have several methods called on it which transform the
instance. Supported Transformations include 3-D Translations, 3-D scaling,
Arbitrary rotations (given a matrix), and Rotations about X Y or Z by specific
angles. As these transformations are applied to a base object the Bounding
Box for the object is transformed by the given transformation, and then the
inverse transformation matrix is stored. When a ray hits the bounding
box the ray is transformed using the stored inverse transformation, then
we see if that transformed ray hits the base object.
The following picture shows how my Instance transformations work.
The Buddah at the left is the original base object. The one at the right
has been Translated to the origin, Scaled abnormally, Rotated about
the Y and Z axes, and finally Translated to it's final postion.
Figure 1 - Example of instance transformations
Next, I created a scene with around 10,000 ants. Here is the
result. The ants are not shaded.
Figure 2 - 10,000 Ants
The following is an image including 10,000 instances of the Happy Buddah
model, using lambertian shading (see next assignment). The statues are
in a 100X100 grid, and the image is ray-traced at 400 samples per pixel.
That is why it looks a little grainy.
Figure 3 - 10,000 Buddahs