Friday, March 27, 2009

Assignment #5a

Assignment #5: Acceleration Data Structures

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.

Tuesday, March 24, 2009

Assignment #5

Assignment #5: Acceleration Data Structures

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-assign5.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 34.5 N/A
Time to render (s) 76883 42 76841
Total time (s) 76885 78 76807 or 97.3%
Intersection Tests 629019024 588972081 4004693
Failed Intersection Tests 608663340 527464523 81198817
Percent successful intersection tests 3.2% 10.4% 7.2%


Using the octree results a 97.3% speed increase. Very nice. However, I'm surprised by the number of intersection tests that still have to be performed. This makes me wonder if I'm counting those correctly.

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. This seems to indicate that some of the spheres didn't make it into the octree voxels.

Image of scene without octree:
Scene with octree: