Try #2. Differences noted a bit later
This assignment adds the Octree primitive for improved performance. The ability to load OBJ files has also been added.
Get the code here
How to get and build the code:
wget http://cs.unm.edu/~jbowles/cs413/a5/jbowles-assign5a.tar.bz2
tar jxf jbowles-assign5.tar.bz2
cd jbowles-assign5
make
./raytracer --width=512 --height=512 --reflections --shadows --maxdepth=20
For testing, I used a type of "Sphere Flake" built with approximately 2 million spheres. The octree dramatically sped up the rendering process.
Total number of spheres: 2,015,539
Without Octree | With Octree | Change | |
Time to build sphere flake (s) | 1.5 | 1.5 | 0 |
Time to build Octree (s) | N/A | 45.5 | N/A |
Time to render (s) | 76883 | 49 | 76834 |
Total time (s) | 76885 | 96 | 76789 or 99.87% increase |
Here are the images generated with the two different methods. The octree looks slightly different - notice the darker patches and the small chunks missing on the outside of the sphere flake. While this image looks very similar to my first post about assignment 5, smaller sphere flakes rendered properly, which was not happening before, and this larger octree took about 18 seconds longer to render and longer to build. Things are clearly getting better, but improvements still need to be made. My improvements consist of fixes to stupid coding errors.
Image of scene without octree:
Scene with octree:
What's different between #5 and #5a? Well, I made a couple of stupid mistakes.
1) Traversal: for(int i = 0; i < 7; i++) will not traverse all 8 child nodes. Duh. Incredibly stupid mistake.
2) ounding boxes needed to have the min and max corners forced. Like #1, stupid mistake
3) Rays that start inside of bounding boxes don't have their intersections calculated properly. Obvious once I thought about it, no fix implemented yet.
I've implemented fixes for 1 & 2, but not three. I tried backing off the camera to avoid #3 but still see some issues. Things are getting better.