The tree is built by combining all of the objects into one bounding box. The objects are then sorted by their center value (either by X,Y, or Z coordinate). Then half of the objects are placed into a new bounding box and the other half are put into a seperate bounding box. This division process continues until each object is in its own box. The critera to select whether to sort in X,Y, or Z is determined by minimizing surface area of the resulting bounding box.
The following scenes were used to test this structure:
N spheres were created, with the center of the sphere as
<drand48()*2-1,drand48()*2-1,drand48()*2-1> and
a radius of 0.1/(N^0.3333). The spheres were colored based on the absolute
value of their position.
The eye was located at <0,0,2> and was looking at <0,0,0> with a fov of 90 degrees. The scene was rendered at a resolution of 512x512 with one ray being fired per pixel. Notice that there were no shadow rays cast, although a simple phong shading model was applied to the spheres.
Click here to view the scene when N=1, N=10, N=100, N=1,000, N=10,000, N=100,000, and N=1,000,000.
Timings were performed on an SGI R10K ("Raptor") and on an UltraSparc 30.
Notice that as scene complexity increased there was a much more significant
overhead in creating the tree structure.
Compilition was performed with the native CC compiler on each platform
with the optimization flags -Ofast and -fast respectively.
(All times are in seconds)
|
|
|
|||
|
|
|
|
|
|
|
1
|
0.000026
|
0.546701
|
0.000029
|
0.825557
|
|
10
|
0.000299
|
0.77605
|
0.000299
|
1.0409
|
|
100
|
0.004933
|
1.79223
|
0.005265
|
2.03477
|
|
1,000
|
0.08027
|
3.53566
|
0.089457
|
3.6565
|
|
10,000
|
1.29316
|
7.3398
|
1.46029
|
7.2428
|
|
100,000
|
28.2581
|
14.2771
|
27.951
|
14.7375
|
|
1,000,000
|
417.149
|
31.8303
|
342.112
|
88.6204
|