The assignment this time is to finish up the acceleration data structure by making it handle our arbitrary geometric objects instead of just a set of boxes. So I added code to take a list of geometric objects and put them into a BVH. Then I tested it out on my sphere flake. The results are quite noticeable.
Here's just 1 level of recursion, resulting in 7 spheres:
Without BVH:
Raytraced image in 250885 microseconds
With BVH:
Raytraced image in 172963 microseconds
So the BVH approach is a little faster, but not very impressive. Below are the image and results with 3 levels of recursion, which result in 37 spheres:
Without BVH:
Raytraced image in 1032742 microseconds
With BVH:
Raytraced image in 388892 microseconds
That's a tiny bit better, now the BVH approach looks a little more than twice as fast. Here's the next step: 4 levels of recursion resulting in 187 spheres.
Without BVH:
Raytraced image in 5098718 microseconds
With BVH:
Raytraced image in 805257 microseconds
So now it's better. We're tracing 187 spheres in 800 microseconds with the BVH, and it's taking over 5 seconds to the same number without it.
Let's keep going. Next is 5 levels of recursion for 937 spheres:
Without BVH:
Raytraced image in 26434916 microseconds
With BVH:
Raytraced image in 1416842 microseconds
The BVH is really starting to pay off now. I can do 937 spheres in under 1.5 seconds with the BVH, where it took 26 seconds to do that many without it. At 937 objects, the BVH is 17 times faster.
How about 4687 spheres?
Without BVH:
Raytraced image in 135769963 microseconds
With BVH:
Raytraced image in 2239579 microseconds
Over 2 minutes without the BVH, just over 2 seconds with it. It just gets better as we add more and more spheres. I don't have time to wait around for the old one to do this many spheres:
With BVH:
Raytraced image in 5171065 microseconds
That's 117,187 spheres in about 5 seconds, that's about how long it took to do 187 spheres without the BVH, so that's about 600 times faster with the BVH than without it.
When you check out this project by doing an "svn update", you can try different levels of recursion on the sphere flake, as well as choose whether or not to use the BVH, both from the command line. See the README.txt for details. The project is in the "cs513/assignment03_spike03/" folder.






No comments:
Post a Comment