CS6620 Advanced Graphics 2 University of Utah
Prof: Peter Shirley Ray Tracing Sem: Spring 2002



Assignment 04 - RGS vs. BVH Bake-Off

On top of the framework I built for Assignment 03a - Sorting vs. Splitting, I've added a regular grid subdivision (RGS) option, as another acceleration technique to compare with the bounding volume hierarchy (BVH).

In most cases, RGS is a faster algorithm, in both speed of generation and rendering speed. However, there are cases where it is slower. These cases usually involve scenes with a mix of very large primitives and very small primitives. I believe what happens is that the number of grid spaces created isn't sufficient to put few enough objects into. So, there are a few primitives that span many grid cells, but most grid cells have many primitives in them, which leads to the poor performance.

I found an interesting thing when rendering the random sphere scenes. The resulting images were different between the RGS and BVH algorigthms. I originally thought this was a bug in my RGS create routine, but I later discovered that it was simply caused by concentric spheres that were being re-ordered by the BVS routine, but not by the RGS routine. This caused a different sphere to be hit for each set of concentric spheres between the two algorithms. I did nothing to fix this, as which sphere to pick is arbitrary. However, it should be noted that the random sphere pictures are not identical, but under careful inspection, it can be seen that the positions of the spheres are identical, their color is not.

I've made some charts comparing the performance characteristics of the two algorithms:

spheres colorcube models sphereflake
(click on each image for a larger view).

I noticed something interesting after making these charts. The performance of the RGS seems to degrade much better than that of the BVH. Notice the geometric look of the BVH curves, compared to the almost linear (especially in the sphereflake case) look of the RGS curves.




Timings (MM:SS.S) are for 500x500 pixel images on a PentiumIII 733Mhz with 384MB SDRAM
(unless otherwise noted).



Random Spheres

bvh rgs
spheres create render total create render total times faster
1,000 0.0 2.6 2.6 0.0 1.2 1.2 2.2x
10,000 0.1 5.9 5.9 0.0 2.1 2.1 2.8x
100,000 1.3 14.4 15.7 0.4 3.9 4.3 3.7x
1,000,00018.2 33.7 51.9 5.3 7.7 13.0 4.0x

1000-bvh 10000-bvh 100000-bvh 1000000-bvh
1000-rgs 10000-rgs 100000-rgs 1000000-rgs
(click on each image for a larger view).

BVH images are on top, RGS images on bottom (they are not identical - see the discussion above).



Color Cubes

bvh rgs
spheres create render total create render total times faster
5x5x5 = 125 0.0 4.1 4.1 0.0 2.0 2.0 2.1x
25x25x25 = 15,625 0.2 27.6 27.8 0.1 5.5 5.6 5.0x
50x50x50 = 125,000 1.6 55.6 57.2 0.6 7.3 7.9 7.2x
100x100x100 = 1,000,00016.9 2:41.2 2:56.1 6.6 13.8 20.4 8.6x

These tests show best case performance, since the data is actually in a grid structure to begin with, so there is exactly a single primitive in each grid cell. Hence, an increase in speed by an average of almost 6 times!

5x5x5-bvh 25x25x25-bvh 50x50x50-bvh 100x100x100-bvh
5x5x5-rgs 25x25x25-rgs 50x50x50-rgs 100x100x100-rgs
(click on each image for a larger view).

BVH images are on top, RGS images on bottom (they are identical - which is a good thing).



Models

bvh rgs
scene triangles create render total create render total times faster
al 7124 0.1 11.8 11.9 0.0 4.1 4.1 2.9x
soccerball3516 0.0 15.4 15.4 0.0 8.2 8.2 1.9x
flowers7627 0.1 26.8 26.9 0.0 29.4 29.4 0.9x
teapot 3360 0.1 4.2 4.3 0.0 2.4 2.4 1.8x

The row in red shows a case in which the RGS is not as fast as the BVH. Notice the mixture of large polygons and small polygons in the model for this scene. This causes the grid size to be too large, hence too many primitives are in each grid cell, causing the poor performance.

al-bvh soccerball-bvh flowers-bvh teapot-bvh
al-rgs soccerball-rgs flowers-rgs teapot-rgs
(click on each image for a larger view).

BVH images are on top, RGS images on bottom (they are identical - which is a good thing).



Sphereflakes

bvh rgs
spheres create render total create render total times faster
10 0.0 1.5 1.5 0.0 1.3 1.3 1.2x
91 0.0 4.4 4.4 0.0 2.2 2.2 2.0x
820 0.0 8.8 8.8 0.0 2.9 2.9 3.0x
7381 0.1 15.6 15.7 0.0 3.7 3.7 4.2x

sphereflake-1-bvh sphereflake-2-bvh sphereflake-3-bvh sphereflake-4-bvh
sphereflake-1-rgs sphereflake-2-rgs sphereflake-3-rgs sphereflake-4-rgs
(click on each image for a larger view).

BVH images are on top, RGS images on bottom (they are identical - which is a good thing).



All of the images above can be regenerated by specifying the appropriate scene file on the command line of the rayn program rayn-04.zip (1.20 Mb). The source code is included in the zip file. Here is a description of the command line parameters for rayn.
usage: rayn [options] <scene_file>

 required:

             <scene_file>    file containing scene description

 options:

  -o         <output_file>   output image filename (output.tga)
  -w         <width>         width of output image (256)
  -h         <height>        height of output image (256)
  -shadows   <true/false>    generate shadow rays (true)
  -rgs       <true/false>    generate regular grid subdivision (true)
  -bvh       <true/false>    generate bounding volume hierarchy (false)
  -sort      <true/false>    sort (not split) the surface list (false)
  -cull      <true/false>    cull backfacing triangles (false)

Questions/comments to nate@pobox.com.



March 2002
© Nate Robins