0% found this document useful (0 votes)
265 views

An Efficient Parametric Algorithm For Octree Traversal

An octree is a well known hierarchical spatial structure which is widely used in Computer Graphics algorithms. In this paper we introduce a new top-down parametric method. The main difference with previously proposed methods is related to descent movements, that is, the selection of a child sub-voxel from the current one.

Uploaded by

triton
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
265 views

An Efficient Parametric Algorithm For Octree Traversal

An octree is a well known hierarchical spatial structure which is widely used in Computer Graphics algorithms. In this paper we introduce a new top-down parametric method. The main difference with previously proposed methods is related to descent movements, that is, the selection of a child sub-voxel from the current one.

Uploaded by

triton
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

An Efcient Parametric Algorithm for Octree Traversal

J. Revelles , C. Urena , M. Lastra


Dpt. Lenguajes y Sistemas Inform ticos, E.T.S. Ingeniera Inform tica, a a University of Granada, Spain, e-mail: [jrevelle,almagro]@ugr.es, URL: http://giig.ugr.es

Dpt. de Inform tica, E.U.P. Linares, a University of Ja n, Spain, e e-mail: [email protected]

ABSTRACT An octree is a well known hierarchical spatial structure which is widely used in Computer Graphics algorithms. One of the most frequent operations is the computation of the octree voxels intersected by a straight line. This has a number of applications, such as ray-object intersection tests speed-up and visualisation of hierarchical density models by ray-casting. Several methods have been proposed to achieve this goal, which differ in the order in which intersected voxels are visited. In this paper we introduce a new top-down parametric method. The main difference with previously proposed methods is related to descent movements, that is, the selection of a child sub-voxel from the current one. This selection, as the algorithm, is based on the parameter of the ray and comprises simple comparisons. The resulting algorithm is easy to implement, and efcient when compared to other related top-down and bottom-up algorithms for octrees. Finally, a comparison with Kelvins method for binary trees is presented. Keywords: Octree, Binary tree, Ray Tracing, Acceleration Techniques

1 Introduction By Octree Traversing we mean the process of nding the subset of voxels in an octree pierced by a directed line. As stated in the abstract, this has several applications in Computer Graphics. Maybe the best known one is the speeding-up of intersection tests of a line with a set of objects. In this case, the octree is used as a spatial index. Each voxel holds a pointer to the subset of objects that it intersects or contains. Then, the set of objects hit by the ray is necessarily included in the set of objects intersecting voxels pierced by the ray. By traversing the octree it is possible to restrict the ray-object intersection test to this set of objects. This is only an improvement when the traversal process is much faster than the test on all objects. Octrees are also used in solid modelling. In this case, the density of one or several materials is considered constant for each voxel of the octree. Generally, the internal structure of this density distribution can be visualised by using a rendering algorithm which displays it as a transparent material. For these kind of algorithms, the accumulated opac-

ity along a ray is computed by obtaining the traversed voxels. Several algorithms for octree traversing have been proposed [Agate91, Cohen93, Endl94, Fujim86, Garga93, Glass84, Jevan89, Samet89, Sung91]. They can be classied into two groups, according to the order in which pierced voxels are obtained: Bottom-Up Methods: Traversing starts at the rst terminal node intersected by the ray. A process called neighbour nding is used to obtain the next terminal node from the current one [Glass84, Samet89, Samet90]. Top-Down Methods: These methods start from the root voxel (that is, from the one covering all others). Then a recursive procedure is used. From the current node, its direct descendants hit by the ray are obtained, and the process is (recursively) repeated for each of them, until terminal voxels are reached [Agate91, Cohen93, Endl94, Janse85, Garga93]. In this paper we introduce a new top-down algorithm. This new algorithm is based on the parametric representation of the ray. This representation allows us to

A node in a quadtree is the set of points inside an axis-aligned rectangle (whose four edges have equal length). Formally, is the set of points such that and , and are four scalar valued funcwhere tions which dene the position of each node (we also dene as the length of each edge of ) From the above denitions, we deduce that an intersection between a ray and a node occurs if at least one real value exists such that:
 E R 2 "YUVba54 3 Q  ' E 2 `#"G2 H  E F '  E R 7 "UGPTPI""7 Q 7 H  E F E  7 2 %5 E  E R 2 "8SPPI"G2 Q 2 H  E F R 7 E F 7 R 2 F 85WV52  E "YX E

By using the inverse functions of , and the above parameter values can be dened explicitly
w u "%0 3 87 i i i  3 2   " e y  E 2   x"dG f '  E e

B'  "5dUB'  e E 

  E X &"d""5GYB'   E 

B'

e UE

 B'

 E  "UdGB'

Results show that the new algorithm is more efcient than these other methods except on the algorithm presented by Spackman and Willis. Furthermore, its simplicity makes it straightforward to implement, as can be observed in the source code listings in section 4.

Substituting (4) into (5), we get , for each node . In the case that is non-terminal, for all children of we have . Similar relations hold for . Thus, the values and can be incrementally computed for a child node just by halving the value for

 E "5GY8F  UdG"R  "5GY ' y  E '   E

 E UdGF

' "5G"R y  E

' "5G   E

 '

'

This paper is organised as follows: section 2 describes a simplied version of the algorithm for quadtrees. The extension for octrees is detailed in section 3. A comparison in terms of efciency with other methods, such as the bottom-up method introduced by Samet [Samet89], two extensions of it proposed by Endl [Endl94], and a recursive top-down method [Garga93], is also included. We use the same software system for all the algorithms.

(4) being , and the origin of the half line, and and the unit length direction vector. These four values are computed for each node when traversing the quadtree. Initially they are obtained for the root node, and then an incremental computation is performed for each child node. In order to detail this incremental computation, we rst dene the following quantities (5)
    

t Isi r p

w u 8v%0

t Isqi r p



 E e "2

 E e "Y587

" e 4 y  E 7

 g5"5GYdfB4&2   E e  ' 3

 h5"5GY56B887   E e ' 3

 UdG 6 '  E e

Moreover, we must refer a signicant work presented by J. Spackman and P.J. Willis [Spack91]. The authors presented a very efcient algorithm to traverse an octree that only employed operations with integer arithmetic throughout the traversal. That algorithm is outlined into the paper and it is very robust. In essence, both algorithms must be equivalent because they use the same principles for each movement. We think the proposed method in this paper is easy to understand and very didactic for teaching.

(3)

'

 E UdG

'  E F B56"5G

 F B'

  ' 3 7  ' 3 2 d54&856548!4

 E "dG&R

'  E 56"5G"R  '

Sung [Sung91] presented an octree traversal algorithm which has the same theoretical basis as the 3DDDA traversal algorithm [Amana87] for uniform spatial subdivision, however, for unbalanced octrees, efciency decreases. This is due to the fact that Sungs algorithm uses the smallest octree leaf as traversal base unit.

The algorithm we propose is called a parametric algorithm because all computations use values of such that is a point on a node boundary. For a node and ray , , and are dened as the ray parameter values for which the ray intersects with the boundary of the node. Formally, these values obey the following equalities:

 "!  

3 87

0 1)' (

 E R 7 "YUba5 3 ba"Y&"7 Q  ' 7 H  E F

3 !2

&B)D! ' @

 ' &B)A @ 

 

 "&%$#  

 954&2  ' 3

 C54"87  ' 3

  ' 3 7  ' 3 2 554&85654

map real values (parameter values) to ray points. The algorithm computes the parameter values at which the ray intersects the three planes that divide each voxel. These values are computed incrementally, by using additions and divisions by two. In essence, this algorithm is related to other parametric top-down algorithms, such as the one introduced by Jansen [Janse85], Arvo [Arvo88], and Agate [Agate91]. Afterward, Sung and Shirley [Sung92] proposed a version on a BSP tree of Jansens work. Authors of these papers pointed out that the cost of traversing an octree and a BSP tree are similar, (these results have been formally presented by Reinhard [Reinh96]). Both parametric methods (for octrees and BSPs) are based on the same principles as our work. However, here we propose a new method for selecting the rst sub-voxel of a voxel, by using comparisons on previously obtained parameter values. This allows us to avoid the neighbour nding process, thus saving memory and computing time. With respect to the movements between neighbour voxels with the same parent voxel, we use an algorithm which is also based on the ray parameter, as the algorithm described by Amanatides [Amana87].

The Algorithm for 2D case

We dene a ray as a pair , where is the origin, and is the unit length direction vector. For each real value exists a point on the ray, where and are two scalar functions dened as follows: (1)

(2)

Y
2 2 0

3 6 4

7 6 4 7 5

If a exists obeying (9), then . The inverse implication also holds, thus equation (9) is equivalent to
 k h ' mlBgjgB' Q ' H i e h  E "5GY  k mlh `a"5GY ' Q  E i e sDh ' '

(10)
'

Figure 1: Labeled octree (the hidden node has label 1). the parent node. If we substitute the following recurrence relations
e e 7 2  e Y&"Y2 E X @  E F  e "&87 E X @  E F  9 e G2 E F

(6)

into (4) we obtain


   y e 2  e "G E X @  E F 2  xUd e 8F  '  E

The last result also holds for . Thus, we have shown how these values can be incrementally computed for all child nodes of the current node. The computation of these values for the root node is carried out by using (4). Knowing the denitions of a node and a ray, we easily deduce that an intersection between a ray and a node occurs if at least one real value exists such that:
 E " R  E " R 2 `#58`#"Y Q  ' 3 2 H  E 7 b#54&8$)" Q  ' 3 7 H  E ' F 7 F 2 c E e F B'

(8)
'

Where a intersection occurs, an interval o values of satises the above inequalities. This interval is closed at the left and open on the right for half lines with a positive or zero valued direction vector. By taking all these results into account, we can now rewrite the condition 8 by using the parameters of the ray. For instance, taking condition from (8), we can substitute by , then, as is an increasing function, we obtain . By using the other inequalities in (8) the same way, we can state that an intersection between and occurs if and only if exists such that
 E "Y R

q2

q3

q2

q3

tym txm
q0 q1 q0 q1

t y0 t x0 tx0

t y0 txm

(9)

This equation can be further simplied by dening and for a node and a ray as
  E 5"dGGF '  E 56UdGF  V"fn ' p o E  x"dG  E  k h mlB' i e jgh ' i e h jDB'

Note that, for any non-terminal node , , and . Other child nodes behave in a similar way. Thus, computation of the entry and exit parameters for each child node of is redundant, because some of them can be taken directly from the parent node, and the others are shared by several child nodes. In fact, there are just six different
 w"5  E  F  F B' E  R  E  '  E  F Byx F  R B'  E "5G  F B'

F  '

'

Figure 3: Sub-nodes crossed when (2D case).

F B'

 v IF B'

  E d"5G R B&!2  ' 3

Q f'

2 1)582 Q  ' 3

  E dUdG8R

 E UdG"R  b#$"5G&F  ' ' Q ' H  E

 E "5GYUR

'  E 56"5G"R  jdn ' r q

0 g' (

' b#$"5GF Q ' H  E

w u u 0 "8vd0

w u 0 u 8v%8%0

 E " R

e 87

In this case, and llowing two vectors:


 2 e !2

are components of the fo-

(7)
q2 q3

txm tx0 tym ty0


q2 q3

txm t x0 ty0 t ym
q0 q1

q0

Figure 2: Sub-nodes crossed when (2D case).

 6R

' 5WR  4 '

  k h ' i e h 8mlB5usDB' t  WF ' 5&F   '

When above condition is true, all values of in the interval are mapped to points which belong to the node. If the condition is false, no intersection occurs. It is now possible to outline the proposed parametric algorithm used to traverse a quadtree. First, we check condition (10) for the root node. If this condition is not satised then the ray does not intersect with the octree. But where it is, the four parameters and need to be computed for the root node by using (4). The main recursive procedure is subsequently executed accepting a node as input parameter, and its corresponding four parameter values. In cases where the node is terminal, this node is added to the resulting pierced nodes list. If it is non-terminal, those child nodes which are pierced by the ray are checked using (10) for each of them. A recursive call to the procedure is carried out for each of them.
  ' 3 7  ' 3 2 d54&856544 e

e 2  Ud e   ' E  "d e Y@   E X

"G y  E F 2

@ "dG&F  '  E

 d7

 h e Y&"7 E F  x"dG  E '   3 2 c  k mlh '  E "dG R B' 

q1

t ym

parameters for a child node. These are the four parameters of the parent plus the following two values:
  E "dd"5G R B)"dG F B4"5GYzfB'  ' @  E  '   E h 

3.1

Obtaining the First Crossed Node

(11)

1. Select the rst sub-node hit by the ray 2. For each pierced node, select the next one, until the current parent node is exited. Assuming a node is crossed by a ray , and the ray direction components are non negative, then the next implications hold:
6 } | WAm{WA| } e

Entry Plane
d

Conditions to examine
| Wd~Ifm| } | W 5 {f } |

Bit affected

These assumptions may be easily proved (see gures 2 and and are computed, only three compar3). When isons are necessary to determine the sub-nodes which are crossed.
} | } m |

Table 1: Comparisons to obtain the rst node intersected.

Maximum
~|

Entry plane

Table 2: First plane intersected.


are shown below to explain in greater detail the rst step for and results a quad-tree case. If the comparison of then the rst edge crossed is edge 1. For this case, the rst sub-node crossed can be or (Figure 2). However, when the above comparison results , then the rst edge crossed is edge 2. In this case, the subnode that can be crossed is either or (Figure 3).

3.2

Obtaining the Next Node

A recursive top-down parametric algorithm called HERO is described in the paper by Agate et al.[Agate91]. The main difference with the proposed algorithm is in the computation of the sequence of visited sub-voxels from the current voxel (see section 3.2).

Once the rst sub-node of a node has been found, the sequence of the rest of the traversed sub-nodes must be obtained[Amana87]. Since the location of the sub-nodes is xed, we can design an automaton whose states correspond to the voxels and whose transitions are associated to the movements between neighbouring sub-nodes visited sequentially by the ray. In gure 5 all possible transitions are shown. For a given ray, the sequence of traversed nodes or

m~|

~|

m|

"

d~|

m |

To extend the above algorithm to traverse an octree, we have into account the two steps previously detailed, including the third dimension when necessary. With respect to the rst step, we introduce a new method which allows the use of a nine parameter set to compute which voxel is pierced rst. This computation avoids neighbour nding to obtain the rst voxel, as it is the case for the algorithm introduced by Glassner[Glass84] and improved in other papers[Arvo88, Samet89, Endl94]. This yields a simpler method. The following sections describe these two steps in detail. The second step is carried out by using a parametric DDA algorithm, as described by Amanatides[Amana87], but restricted to eight voxels (which can be viewed as a uniform grid space). The parameter values are computed by successive additions[Amana87]. In our case, the values are incrementally computed from those of the parent by using three additions and three shifts.
zx

m~|

3 Extending the algorithm to octrees

| Wmf5| }

| W {f

| W m {W

| Wf{WAd~| }

} m |

} |

} | W~Ifm| }

W f f |

| W{Wm| }

} | WAm{Wf|

} | {f m |

} |

if if else if if if

if

} | W~8{{W~8s~|  }

if

then the ray crosses , and the ray crosses . the ray crosses . the ray crosses , and the ray crosses . the ray crosses .

} |

} m |

} WAd~|

Here is the value of the ray parameter for which the ray crosses the horizontal line which divides the node in two equal halves. A similar equation . This kind of coherence can be used to holds for improve the algorithm further by using a sequential algorithm. The selection of pierced sub-nodes of a node is carried out in two steps:
 E "5GY h v ' h f '

To nd the rst sub-voxel at which the ray enters the current voxel, rst we obtain the entry face of the current voxel. This step is made by computing . In table 2 we show the entry plane selected for each case. Once the entry plane has been determined, four sub-nodes are candidates. To determine , , and the rst sub-node crossed, we examine . In table 1 the necessary comparisons are shown. The results of evaluating this condition (a bit) is copied to one of the bits which form the index of the rst sub-node crossed. When a condition is true, the bit associated is set to , otherwise it is set to . For each entry plane there are two conditions, so we have four possibilities, one for each sub-node touched by that plane. In this way, any node could be selected with the exception of node , because the ray direction vector components are assumed to be positive. The whole process can be implemented using the operator to combine the necessary bits. Several illustrations
| | | ff5~dff~~dffm 6w

  E 8d5"dG R Ba{UdG ' @  E

'   E h F B4"5GYz6B'

o 2

o 3

o 2

o3

In the HERO algorithm it is necessary to sort a list of potentially visited sub-voxels and then explicitly check each of them for intersection. However our algorithm is simpler because this is not necessary, as visited sub-voxels are obtained sequentially. Some computations are unnecessary because non-visited sub-voxels are not considered at all. Thus this yields a faster and simpler algorithm.

tx1 ty1
o0 o1 o0

ty1 tx1
o1

r 2 6 4

Figure 4: Exit Edge.

Table 3 shows the next visited node given the current node and the exit plane. The entries labelled with End mean that the ray leaves node . For example, if the rst node is

Figure 6: Reection transformation for the generalisation.

Table 3: State transitions.

3 6 110

010 2

1 4 100

000

otherwise (12)

, the nodes that can be visited are 4, 2 and 1, depending on

when

fm!ff

W"m~| }

Figure 5: Sub-nodes that can be reached from an initial node.

} m~|

| f~Im|

lf"mf|

d"

001

101

} ~~|

s$df8 m |

sA

lys

lAv%

011

111

f5m"vaA

"!m)f

"

 ~|

"

Current sub-node (state) 0 1 2 3 4 5 6 7

Exit plane YZ 4 5 6 7 End End End End

Exit plane XZ 2 3 End End 6 7 End End

Exit plane XY 1 End 3 End 5 End 7 End

3.3

Generalising for Rays Parallel to One Main Axis

In the case that is zero for any , the direction vector of the ray is parallel to an octree face or even to one of the main axes. In this case, some of the entry and exit parameters are not dened, because their denition involves a division by . In our algorithm, we have tried to keep the program simple, avoiding any special case handling. So we have chosen to allow the parameters to take innite values. This way the intersections between a ray and a plane may occur at an innite distance from the origin of the ray. Note that in this case the interval of parameter values at which the ray is in a voxel may be equal to the whole real line. with and Any parameter can take real values and also the values and . All operations involving parameter values should take this into for all and account. We set for all . We also have for all real values . With these denitions it is possible to obtain the initial entry and exit parameters for the root voxel, and also to compare parameter values. The computation of is also affected by innite values. Assuming that , ray enters any voxel if and only if and . In this case, the value cannot be computed because is undened. However, in these conditions it can be shown that:

58584

states visited will be established so that the followed path is one of the possible ones in the before mentioned gure. In order to obtain the exact path followed by the ray it will be necessary to compute the face where the ray leaves each of the visited nodes, which will make it possible to obtain be the current visited the next node to be visited. Let node. The ray can leave this node through the following , or and this is calculated by getting the faces: minimum of . In gure 4 a 2D example of computation of the exit edge for node is shown. You can see how the ordering of and determine the exit edge.
f v | | | v6~~dfm~dfmf~| f | d

the exit plane. From node number , node number is the only one that can be reached because movements along the or axes would mean that the ray leaves the parent node. The longest path includes four nodes and an example is the which involve three one including the sub-nodes transitions. In each one we choose the minimum of those three values. Therefore two comparisons are made in each transition which, when added to the four operations needed to obtain the rst sub-node, results in ten comparisons in the most unfavourable case.

U6

Wf"

U8

"

U8

v8v"

8 E 'I 8 E 'H 8 E '0 8 E  8 E 'F 8 E ' 8 E  8 !

Vsj S Sj 4jsss ) ( &  % $ # j! 'sss V Vsj  s v" Ys v  V   ! Sjjszs ffss %Gjj sWs&js&j    YssWYss&jYss&jSjjsjjs      sssssU s WYss j ss Sjsjjs     s s  SGsj ss Ys Vs V

  V ~j Gss S"  V ~j G 4ss Sj   V ~j Gss S"  V ~j G 4ss Sj   V ~j Gss S"  V ~j G 4ss Sj   Ss ~G ~  u ~ssssssG ~ j Ysss V S Ss ~G ~ u ~sssssssG ~ j Ysss V V Ss ~G ~ u ~sssssssG ~ j Ysss V S GsfsssjUSsjjjssjs SGsss jj

Similar relations can be derived for the other axes, thus we in these cases. This ensures have a method to obtain that the comparisons yield the correct parameter intervals where the ray intersects the voxels (including the case when those intervals are equal to the whole real line), and the visited voxels are also correct. Some hardware architectures include innite values in the set of allowed real values, and are produced after a division by zero has taken place.

oat value is the minimum of the three oat values. Funcis used to perform any computation tion required when a terminal node is reached by the ray. Its parameter is a pointer to that node.

W8m6fU

U"U

As has been pointed out at the beginning, this method only works properly if the direction vector of the ray has no negative components. To solve this problem, eight different versions of the method, one for each sub-voxel, could be written and implemented. However, this solution has been avoided because of the redundant code that would be necessary to produce. An example where the ray direction is only negative for the axis is now considered. In this case the ray can be reected with respect to the middle plane of the octree to turn the negative direction component positive. Starting from the reected ray, the visited nodes must be relabelled and this way the previous scheme is valid. One ray with origin and direction is transformed to other ray and by using the following relations:

3.4 Generalising for Rays with Negative Directions

(13)

Sss 4j0 G  1 Sss 4j0 G  1  1 Sss 4j0 G

The only difference will be in the labelling of the sub-nodes of a node. In gure 6 it can be observed when the origiof the octree and that nal ray traverses sub-nodes the transformed ray traverses sub-nodes which would produce wrong movements in the octree. To avoid this, a function is needed to transform labels, so that when node is computed as the next node, in fact is accessed. In , the image by of the subthe example, where nodes would be: . Function changes the value of the most signicant bit of the binary representation of a node label. In general (any component of the direction can be negative) it is necessary to change label bits when the direction component corresponding to that bit is negative. This is done by using a operation with the original label and an integer value lower than 8 (3 bits). , where , and Formally, where is if , and in other case (for each axis ).

G ! SjssCs S32 B uCss G ! SQsj 6     4 7jsfffW~s~s~sVsssssss5I B uCss I G  G  2 ! @f@WY@sf!jjsssj 6    4 7jsf~ffWYss~s~sVsssssss5H B uCss G  I G  2 ! @f@~WY@sf!jjsssj 6    4 7jsff~fW~sYss~sVsssssss50 B uCss 0 H G  2 ! @f@~WY@sf!jjsssj 67jsf~f~fWYssYss~sVsssssssP   4 B uCss G  G  I 2 ! @f@WY@sf!jjsssj 6    4 7jsfff~W~s~sYssVsssssss5F B uCss F G  H 2 ! @f@WY@sf!jjsssj 6   4 7jsf~ff~WYss~sYssVsssssss5 B uCss G  F 0 2 ! @f@~WY@sf!jjsssj 6   4 7jsff~f~W~sYssYssVsssssssD B uCss  2 ! &Af@~W9sf!jjsssj 67jsf~f~f~WYssYssYssVsssssss5  4 ! 2 sjjs Vj 3 s ! !f~f~WYssYssYssVjjsjGjjs

A pseudocode of the algorithm will now be shown, where recursion is used for ease of understanding, although this may be avoided by implementing an iterative algorithm with a stack. We consider an octree as a data structure that contains a pointer to the root node whose type is node. It also contains its dimensions called (xmin, xmax, ymin, ymax, zmin, zmax), and its size called sizei, where . Each non-terminal node has eight pointers pointing to its eight children. Function implements tables 1 and 2, such as described in section 3.1. Function implements table 3. This function accepts three values, and three values as parameters. The function returns the -th integer where the -th
a G

4 Parametric Algorithm Pseudocode

The proposed method was implemented in a rendering system written in C++, which already included several acceleration techniques based on octrees, and a wide range of algorithms for octree traversal. Time comparisons were made for these algorithms.

The comparisons were carried out on a Silicon Graphics Indigo 2 with a MIPS R4000 processor and 64MB of RAM. Three different scenes were used: the rst is a sphere ake with 1890 objects (see gure 10), the second is a structure, composed of spheres and cylinders, with 4320 objects (see gure 11), and the third a patio with 4350 objects (see gure 12). Space subdivision has been applied to these scenes using octrees with maximum depth levels 5, 6, 7 and 8. The traversal algorithms

Results

DY!

WB

f"5"5"5"58

Y!

"5&

G!fU "

} ~~|

Sphere-Flake 4500 4000 3500 3000 2500 2000 1500 1000 5 CPU Time (sec.) Sam SamC SamN Gar Par

Figure 7: Timing graph for Sphere-Flake.

CPU Time (sec.)

Figure 8: Timing graph for Architecture. Figure 11: Architecture.


used to compare the performances with our method were: Samet[Samet89] (Sam), SametCorner[Endl94] (SamC) and SametNet[Endl94] (SamN) as bottom-up algorithms, and Gargantini[Garga93] (Gar) as top-down algorithm. The time comparisons are plotted in gures 7, 8, and 9. SametNet method requires much memory because pointers to neighbour voxels must be kept within each voxel (they are required for the neighbour nding process). So, a higher rendering time is obtained after increasing the octree depth level due to swap time. In summary, we can see that the Gargantini method presents better results than the other bottomup methods shown. In Gargantinis paper, we may see a comparison with Samets method. The improvement of the rst one is shown in terms of execution time and a run-time analysis.
Patio 10000 9000 8000 7000 6000 5000 4000 3000 2000 1000 5 CPU Time (sec.) Sam SamC SamN Gar Par

These results shows that octrees are more efcient than bi-

6 7 Octree depth level

Figure 9: Timing graph for Patio.

Figure 12: Patio.

W U

W X 8

V 9

T fUW

W @V "

R R R

6 7 Octree depth level

Figure 10: Sphere-Flake.

Architecture 8000 7000 6000 5000 4000 3000 2000 5 6 7 Octree depth level 8 Sam SamC SamN Gar Par

5.1

Comparison with the Binary Tree Structure

To study the efciency of our method [Sung92], a comparison with the Kelvin Sung method has been done. We have obtained two images from the same scene. The rendering system was the same in both cases. One of these images was rendered using an octree structure, and the other using a binary tree. The scene is shown in Figure 14. This scene . has one object per leaf node. The number of spheres is We ran three tests setting to , , and . The total num, , and . The cpu time ber of spheres was employed when using the octrees was , and lower than the time for the binary trees.

nary trees when the tree is full or nearly full, due to the number of necessary descents to reach one terminal node. In an octree, the number of recursive calls to the main function is lower, meanwhile the rest of computations are basically equivalent (as it was established by Reinhard et al. [Reinh96]).

vances in Computer Graphics Hardware IV R.L. Grimsdale, W. Strasser (eds) Springer-Verlag, New York, 1991. [Amana87] J. Amanatides, A. Woo. A Fast Voxel Traversal Algorithm for Ray Tracing. Eurographics87. Proceedings of the European Computer Graphics Conference and Exhibition, August 1987, pp 3-10. [Arvo88] J. Arvo. Linear-time voxel walking for octrees. Ray Tracing News 1(12), March 1988. Available under anonymous ftp from drizzle.cs.uoregon.edu [Cohen93] D. Cohen, A. Shaked. Photo-Realistic Imaging of Digital Terrains. Computer Graphics Forum Vol. 12(3), pp 363-376, 1993. [Coqui85] S. Coquillart. An improvement of the raytracing algorithm. Eurographics85: Proceedings of the European Computer Graphics Conference and Exhibition, Ed C. E. Vandoni, pp. 77-88, 1985. [Endl94] R. Endl, M. Sommer. Classication of RayGenerators in Uniform Subdivisions an Octrees for Ray Tracing. Computer Graphics Forum Vol. 13(1), 1994. [Fujim86] A. Fujimoto, K. Iwata. ARTS: Accelerated Ray Tracing System. IEEE Computer Graphics & Applications Vol. 6(4), pp. 16-26. 1986. [Garga93] I. Gargantini, H.H. Atkinson. Ray Tracing an Octree: Numerical Evaluation of the First Intersection. Computer Graphics Forum Vol. 12(4), 1993. [Glass84] A. S. Glassner. Space Subdivision for Fast Ray Tracing. IEEE Computer Graphics & Applications Vol. 4(10), pp. 15-22 October 1984. [Janse85] F.W. Jansen. Data Structures for Ray-tracing. Data Structures for Raster Graphics L. Kessner, F. Peters, M. van Lierop (eds). Springer-Verlag, 1985, pp. 57-73. [Jevan89] D. Jevans, B. Wyvill. Adaptive Voxel Subdivision for Ray Tracing. Graphics Interface89, pp. 164172. June 1989. [Reinh96] E. Reinhard, Arjan J.F. Kok, F.W. Jansen. Cost Prediction in Ray Tracing. Rendering Techniques 96, Springer-Verlag, 1996, pp. 42-51. [Samet89] H. Samet. Implementing Ray Tracing with Octrees and Neighbor Finding. Computer & Graphics Vol. 13(4), pp. 445-460, 1989. [Samet90] H. Samet. Applications of Spatial Data Structures: Computer Graphics, Image Processing, and GIS. Addison-Wesley 1990. [Spack91] J. Spackman, P.J. Willis. The Smart Navigation of a Ray Through an Oct-Tree: Computer & Graphics Vol. 15(2), pp.185-194, 1991. [Sung91] K. Sung. A DDA Octree Traversal Algorithm for Ray Tracing. Eurographics91. Proceedings of the European Computer Graphics Conference and Exhibition, F.H Post and W. Barth (eds), pp. 73-85, North Holland, 1991. [Sung92] K. Sung, P. Shirley. Ray Tracing with the BSP tree. Graphics Gems III. pp. 271-274, 1992.

Octree

Binary Tree

Figure 13: Bintree and Octree equivalent structures (depth level for octree is 1, and 3 for bintree).

Figure 14: 3D array of spheres.

6 Conclusions
The recursive top-down algorithm which has been presented improves the performance of existing ones, as the time graphs show. It minimizes the number of operations because they are carried out in a top-down recursive style, and using at each stage the results of the previous stage. Besides efciency, it is also desirable for any method to be easy to read, comprehend and implement into a rendering system. This method is very easy to understand and to incorporate into such systems because of its simplicity, when compared to other referenced algorithms.

7 Acknowledgements
This work has been supported by a grant coded as TIC950614-C03-02, and TIC98-0973-C03-01 from the Committee for Science and Technology of the Spanish Government (CICYT).

REFERENCES
[Agate91] M. Agate, R.L. Grimsdale, P.F. Lister. The HERO Algorithm for Ray Tracing Octrees. Ad-

You might also like