Ray Tracing Projects

Assignment 8: Instancing

Return to Ray Tracing Assignment Overview
 

Finally.  I got it right.

My class notes for this project have a picture of a ray hitting an "instanced" object.  The ray is labeled "free lunch".  Now realize, I did find when doing this implementation that these inverse transformed rays flying around and hitting virtual objects was sorta magical; there wasn't much that I had to do to get that particular part to work.  However, the time I spent on everything that had to happen around the basic instancing code nullified any free lunch that might've been available.  Free lunches don't exist.

Special thanks goes to Brian Budge who straightened me out and helped me fix what I was doing wrong.  Also, thanks to Nate Robins who let me modify his OBJ reader for my ray tracer.

Looking back, the concepts are easy enough to understand.  I just had a total breakdown when it came to what I was actually supposed to instance.  I didn't even think to instance the efficiency structure.  Maybe I missed that part of the lecture.  I was instancing triangles and throwing all of them (possibly all 1 billion of them) into my bounding volume hierarchy (BVH) and my computer just decided that that wasn't such a good idea.  I ran out of physical RAM when trying to instance over about 2-3 million triangles.

The key (as Brian pointed out) is to pack all of the to-be-instanced triangles into one BVH and then instance the BVH.  Just throw the BVH pointer into your main object list, fumble around with the bounding box of the instance, bake it, and presto-magico, you're done!  Doing this meant that I didn't have to do a lot of the lower level things that I had been trying to get right the last few days.

The great news is that instead of 3 million triangles wanting to live in 1.5 GB, now I can get a billion of them in just over 100 MB.
 


1932 Dodge Reunion in 2002
60,000 Instances of a '32 Dodge from an OBJ file
Approximately 1 billion instanced triangles
3000x450 JPEG converted from PPM output (shown cropped above)
144 samples per pixel
6 hours, 56 minutes
 

There are 60,000 cars in the above image, you just can't see all of them well.  The image has all the basic instancing concepts...scaling, rotation, and transformation.  Note that the shading, shadows, and reflections are all correct.

I've set the windows on the model to be "mirrors".  I couldn't set them to glass, because the windows are made up of only one layer of triangles.  The glass doesn't look like it was modeled too well anyway.

This project was implemented after assignments 9-12 which is the reason I have multiple samples per pixel and soft shadows in the image above.

Executable compiled with Microsoft Visual Studio .NET Professional and run on a Dell desktop with an Intel Pentium 4 1.8 GHz processor with 1.0GB of RDRAM running Microsoft Windows XP.
 

email at jasonwaltman dot com

(c) 2000-2007 jason waltman