Ray Tracing Algorithms - Theory and Practice: 1 Photographic Realism in Computer Graphics
Ray Tracing Algorithms - Theory and Practice: 1 Photographic Realism in Computer Graphics
Abstract. This paper gives a survey on recent advances in making ray tracing a practical
technique for realistic image synthesis from spatial scenes. First, the structure of the
Karlsruhe ray tracing software VERA is described as an example of practical ray tracing.
Then a comprehensive analysis of worst case time bounds of the ray tracing procedure
and of some related algorithms, e.g. the visible surface reporting algorithm, is carried
out.
Keywords. Computer graphics, computational geometry, realistic image synthesis, ray
tracing, visible surface reporting, ray query problem.
1
Figure 1a. This picture was generated without any lighting effects based on viewing
angles and without a depression of pixel stair cases. The objects look flat and some of
the geometric details are not at all visible, e.g. the correct shape of the chess board.
Figure 1b. If anti-aliasing is switched on, the stair cases (jaggies) disappear. The anti-
aliasing procedure is based on a controlled oversampling.
Figure 1c. Here the diffuse angle-dependent part of the light as well as anti-aliasing
was switched on. The rendering of the left silver beaker as well as the up till now black
glass sphere is far from being realistic since shadows, mirror and glass effects are still
switched off.
Figure 1d. Three light sources as well as hightlight effects are added. Almost all of
todays computer animation sequences are generated using exactly this lighting model.
The ubiquitous and simple depth buffer strategy is sufficient to generate this kind of
pictures.
Figure 1e. One of the strong points of the general ray tracing procedure is its ability
to visualize mirror and glass objects in a natural way. But there are some more effects
that improve realism, e.g. surface texture, secondary light effects, lens distortion, and
motion blur.
this ray, the intersection point lies in the shadow of this light source, and its intensity is
not taken into account for intensity calculations. The calculation of intensity is carried
out according to a lighting formula incorporating parameters of material attached to the
geometric objects of the scene.
VERA accepts a set of primitive objects, which are used to build up a scene. These
primitives are triangles (P3), spheres (SP), and rotational shapes (RS). The attribute
“IP” (inner point) lies on the inner side of a boundary face of a solid. This makes it
unnecessary to specify solids explicitly. The design of more complex scenes is greatly
simplified by the concept of hierarchy. It is possible to specify subscenes (SCENE) that
can be used several times (SSC) under different transformations (rotational, transla-
tional, scaling). This technique is very similar to the procedure- or macro-concept of
programming languages. The description of the scene belonging to figure 2a is
PROJECTION 54.0 75.0 200.0 (* view point *)
27.0 0.0 0.0 (* lower left *)
148.0 0.0 0.0 (* lower right *)
27.0 121.0 0.0 (* upper left of the image *)
LI 110.0 100.0 -25.0 13000.0 1.0 1.0 1.0 (* light source 8000 *)
(* geometry *)
CM darkwhite
IP 0 -10 0 (* floor *)
P4 -200 0 100 800 0 100 800 0 -200 -200 0 -200
CM brightgrey
IP 80 20 -28
P4 90 0 -15 155 0 -15 155 40 -15 90 40 -15
P4 155 0 -15 155 0 -55 155 40 -55 155 40 -15
P4 90 0 -55 155 0 -55 155 40 -55 90 40 -55 (* parallelepiped *)
P4 90 0 -15 90 0 -55 90 40 -55 90 40 -15
P4 90 40 -15 155 40 -15 155 40 -55 90 40 -55
(* is open at the bottom *)
CM refwhite
SP 55 25 0 25 (* sphere *)
CM mirror
IP 0 40 -100
P4 0 4 -85 160 4 -85 160 120 -85 0 120 -85 (* mirror *)
CM grey
P4 -4 0 -85 164 0 -85 164 4 -85 -4 4 -85
P4 160 4 -85 164 4 -85 164 120 -85 160 120 -85 (* frame *)
P4 -4 120 -85 164 120 -85 164 124 -85 -4 124 -85
P4 -4 4 -85 0 4 -85 0 120 -85 -4 120 -85
CM whiteluminant
SP 110 120 -25 4 (* lamp *)
CM darkgrey
RK 110 120 -25 P 110 160 -25 (* wire of lamp *)
AN 0 0 GE 1 0 GE 1 50 GE 0 50
(* materials *)
MA grey DRF 0.7 0.7 0.7
MA whiteluminant DRF 0.9 0.9 0.9 SDI 1.0 1.0 1.0
MA darkgrey DRF 0.4 0.4 0.4
MA mirror SPC 1.0 RAB 0.7 0.7 0.7 REF 1.0
MA refwhite DRF 0.2 0.2 0.2 ARF 0.5 0.5 0.5 SAN 0.5 0.5 0.5
MA brightgrey ARF 0.8 0.8 0.8 DRF 0.2 0.2 0.2
MA darkwhite DRF 0.8 0.8 0.8
A file like this is either specified by a text editor, or results by conversion of the output of
an interactive graphics editor or CAD system. The textual format allows easily to trans-
fer files to other computers. This is important in an environment where computational
power must be gained from several machines.
2.2 Preprocessing
The specific power of VERA is to process large scenes in relatively moderate time. This
is made possible by decreasing the number of intersection tests to be performed between
rays and primitives by preprocessing the scene into a suitable data structure. The quality
of this data structure is crucial for the practicability of ray tracing. Straightforward ray
tracing would require to test every ray against every object. For a number of rays up
to several millions and a number of objects up to several 10000 or 100000, the time
Figure 2a. A black and white still-life.
Illumination
If an intersection point is found, its contribution to the total ntensity of the pixel un-
der consideration must be calculated. This is done according to the following lightness
formula. For each of the basic colors red, green and blue we calculate the color-intensity
where Ambc is the ambient light, Difc the diffuse light, Spkc the specular light, Slmc
the self-luminosity, Rf lc the reflecting light from mirrors, and Rf rc the refracted light
from glass. Let N ~ be the normal vector to the object, R ~ the ray that intersects the
object, S~ the vector of reflection, F~ the vector of refraction and L
~ i the vector from the
intersection point to the light source i. Then
~ ·N
Ambc := (R ~ · DRFc + ARFc ) · AmbLightc
~i · N
~ · DRFc + L
~i · R
~ · ARFc ) · Intensi,c .
X
Difc := (L
i
The intensities of the light sources depend on the color, basic intensity and distance.
~i · L
If S ~ i < SP C Then Spkc := 0
Else
!2
X ~i · S
(L ~ − SP C) · (L~i · S
~ + SP C − 2.0)
Spkc := · Intensi,c
i
distance · (1.0 − SP C)2
~ ·N
Slmc := R ~ · SANc + SDIc
Advanced Features
With the set of primitives used by VERA, large scenes of many distinct subjects can
be built up. On the other hand, it is possible to approximate more complex shapes, like
smooth or fractal surfaces, by these primitives. For smooth surfaces it is of advantage to
use RT-patches instead of triangles. Then VERA interpolates the surface normal similar
to the shading method of Phong.
A very important feature to obtain realistic looking images is the firmament-function,
where a heaven-earth model is built in. This allows to design the shape of the horizon
at the bottom of the scene and over there a sky with a continuous change in colours.
Another command allows some automatic exposure measurement. Before the ray tracing
of the whole image, the colors of some representative rays are calculated. This allows
one to detect whether the image will be too dark or too bright. In such cases we can
switch on an option to embrighten or darken the light sources automatically. Further,
if desired, VERA chooses the parameters of the image plane so that the whole scene
is mapped into the image. Finally, the shape of pixels can be chosen according to the
aspect ratio of the monitor. These informations are collected in a control file which is
read by VERA in addition to the scene file. A typical control file is shown below.
Figure 2e. The lighting model of the VERA raytracer is well suited to render even
difficult materials. Perfect rendering of such parts is only possible if the scene defines
not only a body but a complete environment. Design: A. Stößer, Karlsruhe.
Figure 2f. This tree was generated by a recursive procedure that uses only some basic
laws describing the relations between branches and leaves. Such methods are used to
design complex graphical objects. Quite similar approaches help to generate so-called
fractals. Design: T. Maus, Karlsruhe.
Figure 2g. This cooling rotor is an optimized design. It was developed by a mechanical
engineering institute of the University of Karlsruhe. The realistic raytraced picture was
used to check the design. An automatically milled model was available only several
months later. Design: Doneit, Bieberich, Karlsruhe.
Figure 2h. Still-life demonstrating photographic realism. Design: A. Stößer, Karlsruhe.
Figure 2i. This snake shell is simply a raytraced (u, v)-parametric surface. The formula
is
v
X(u, v) := 1.66 2π · (0.1 · cos v + 0.125 · cos v · sin u),
v
Y (u, v) := 1.66 2π · (0.1 · sin v + 0.125 · sin v · sin u),
v
Z(u, v) := 1.66 2π · (0.6 + 0.25 · cos u).
The surface is approximated by a sufficiently large number of raytracing patches. This
approximation is carried out in a preprocessing step. Design: V. Vlassopoulos, Athens,
Greece.
usefulness of spatial subdivision [TK84,Gl84,FT85,M86a] as it was applied in the VERA
system.
The other approach favored by some implementors is hierarchy of hulls
[RH82,KK86,Gv86]. Two or more spatially related primitives are clustered into a sub-
scene, subscenes are again clustered together, until a final composite scene is reached.
To every node of this tree of scenes, a bounding box of the subscene’s primitives is as-
signed. On this preprocessed tree, ray tracing is performed starting up at the root, and
traversing the tree according to the intersected nodes. A survey on clustering methods
is given in [DE83]. For tree-like specified scenes, i.e. hierarchies and constructive solid
geometry [M86a,RH82], clustering is straightforward by taking subtrees as clusters.
Space decomposition and hierarchy of hulls work well in practice, but theoretically they
may behave badly in worst case. The remainder of sect. 3 is devoted to worst case ef-
ficient solutions of the ray-primitive intersection test. We present worst case efficient
solutions involving classical data structures of computational geometry covered by text-
books like e.g. those of Preparata and Shamos [PS85] and Mehlhorn [Mh84]. The reader
is supposed to be familiar with the basics of these data structures. Our more theoretical
investigations help to grade ray tracing as relatively complex among other problems of
computational geometry. However, they show new directions that may be of practical
interest too.
3.2 Ray Tracing without Mirrors and Glass: Simple Ray Tracing
If the 3d scene does not contain light reflecting or refracting materials, the ray tracing
procedure has to answer only so-called centrally distributed ray queries. A ray starts at
the view point (primary rays) or it starts at one of the L light sources. In this case and
if the 3d scene consists of plane polygons that do not penetrate each other, there is a
nice solution to show, that a single ray query can be answerd in time of O(log n), where
n is the total number of polygon vertices of the scene.
The basic idea is to transform a central ray query problem to an equivalent plane point
location problem. The details of this construction are as follows:
1. Choose for example the view point A as the central point of our ray query problem.
Thus we have to solve the ray query problem only for those rays having A as
starting point.
2. Wrap up the view point by a box consisting of six regularly oriented square faces,
see figure 3a for details.
3. For each of these square faces solve the visible reporting problem with the view
point as the central point of the projection and the square face as its screen plane.
Details of an applicable algorithm are given in the appendix. There it is shown,
that it is possible to perform visible surface reporting in time of O((n + k) log n),
where k depends on the special nature of the 3D scene.
4. For each of these six sets of visible parts of polygons generate a data structure in
order to solve the following point location problem at the surfaces of the square
Figure 3a. The centrally distributed ray query problem can be solved by six indepen-
dent 2d point location problems where the point regions correspond exactly to those
parts of the surfaces of the 3d scene which are visible from the view point.
faces: The regions of the point location problem correspont exactly to the visible
parts of polygons when projected to the square faces. It was shown by Kirkpatrick
[Ki83] that the point location problem based on m triangular regions in the plane
needs preprocessing time of O(m log m) and answers a single point query in time
of O(log m). In our case, m is of the order of O(n + k) in the worst case. Since k
is at most of O(n2 ), we have a total preprocessing time of O((n + k) log(n + k)) =
O((n + k) log n) and a single query time of O(log n).
5. A centrally distributed ray query is now reduced to a single point location query:
Determine the square face penetrated by the ray (starting at the view point A)
and calculate the penetration point. Use this point in order to solve the point
location problem attached to the penetrated square face.
As a result of this construction we can state: Single (central) ray query problems of the
specified structure can be answerd in time of O(log n) and the preprocessing can be done
in time of O((n + k) log n).
In order to derive specific results on the time complexity of simple ray tracing, we first
note, that the calculation of a single pixel generates exactly L + 1 centrally distributed
ray query problems, where L is the number of light sources given for the scene. This
amounts to a time bound of O((L + 1) log n). The preprocessing needs total time of
and the total time to generate a complete picture with mx horizontal and my vertical
pixels is bounded by
It should be noted that simple ray tracing is more of academic than practical relevance.
The method was included here in order to show, that the centrally distributed ray query
problem has an efficient solution, at least in theory. Consequent application of visible
surface reporting allows an even more direct procedure to generate shaded pictures of
the same quality. For details see section 3.4.
xo ≥ a ∗ zo + b, xo ≤ a ∗ zo + b, projection on x − z − plane
y o ≥ c ∗ zo + d, yo ≤ c ∗ zo + d, projection on y − z − plane.
(xo , yo , zo ) and (xo , y o , zo ) are the lower left resp. upper right vertices of some rectangle.
These nested queries can be solved by four nested conjugation trees, according to a more
general technique developed by Dobkin and Edelsbrunner [DE84]. The computational
complexity is summarized by
Proposition 1. It is possible to preprocess n iso-oriented rectangles within P (n) =
O(n polylog n) time (assuming ham-sandwich cutting done according to Meggido
[Me85]) into a data structure of size O(n polylog n) s.t. an arbitrary ray query √ for a
α 1+ 5
closest rectangle can be answered within Q(n) = O(n polylog n) time, α = log 2 ≤
0.695 (polylog stands for logc for some c ≥ 0).
A slightly better α can be obtained by applying the -nets due to Haussler and Welzl
[HW86]. However, the question of efficent calculation of -nets seems unanswered.
A totally different approach is based on point location. The idea is to restrict the query
space consisting of all lines to a restricted set of lines with the same answer, as follows.
The edges of the rectangles are segments of lines. The query line is moved in parallel
to the x-axis to the first line perpendicular to the x-z-plane, and then in parallel to the
y-axis to a first intersecting line perpendicular to the y-z-plane, cf. figure 3b. This means
that only those query lines must be considered further that connect two such orthogonal
lines. This problem is equivalent to the inverse range query problem for rectangles in
the plane, i.e. to find the rectangles containing the query point. The perpendicular lines
onto which a query line is to be moved is found by point location, as shown in figure 3c
and in detail described by Chazelle [Ch83]. The complexitiy of the resulting solution is
as follows.
Proposition 2. It is possible to preprocess n iso-oriented rectangles within P (n) =
O(n3 polylog n) time into a data structure of size O(n3 polylog n), s.t. an arbitrary ray
query for a closest rectangle can be answered within Q(n) = O(log3 n) time.
The strips are initialized by the query rectangle, while the points stem from the lines.
These simultanous strip queries can be solved by preprocessing the lines into a two-
fold nested conjugation tree, again following Dobkin and Edelsbrunner [DE84]. The
computational complexity is stated here:
Proposition 3. It is possible to preprocess m rays within P (m) = O(m polylog m) time
into a data structure of size S(m) = O(m polylog m) s.t. the set of all rays intersected
by an arbitrary query rectangle
√
(fixed orientation) can be found within Q(m) = O(I +
α 1+ 5
m polylog m), α = log 2 , I the number of intersections reported.
The next data structure answers a primitive query in polylog m time, at the expense of
O(m2 polylog m) storage. The lines of a generation are projected onto the x-z- and y-z-
planes. Their intersection points divide the lines into line segments. These line segments
are organized into a segment tree, cf. figure 3d. For the line segments stored with a
node of the segment tree, a 2-d range tree is built up. These line segments intersect a
plane perpendicular to the z-axis with intersection points in the same relative x- and
Figure 3d. Answering a query of a primitive. The primary tree is a segment tree, the
secondary trees at its nodes are 2d range trees for the respective line segments.
y-order within the range of the segment tree node. The range tree is built up on these
intersection points. It allows efficiently to answer rectangular range queries. For a query
rectangle, the nodes of the segment tree relevant for the query rectangle are determined,
and a range query with this rectangle is carried out in the range trees of these nodes.
Proposition 4. It is possible to preprocess m rays within P (m) = O(m2 polylog m) time
into a data structure of size S(m) = O(m2 polylog m) s.t. the set of all rays intersected
by an arbitrary query rectangle (fixed orientation) can be found within Q(m) = O(I +
log4 m) time, I the number of intersections reported.
These arbitrary range queries solve a task analogous to determining the pixels covered
by a polygon for the depth buffer visible surface algorithm. Comparison of depth in
the depth buffer algorithm can be saved, if the priority of the primitives w.r.t. the
viewpoint is unique. Then the primitives can be sorted according to depth. For our iso-
oriented rectangles, sorting according to increasing z-coordinates has shown to be quite
useful. The way we treat these rectangles is space-sweep. A plane perpendicular to the
z-axis is moved through the scene, starting at the smallest z-coordinate of the scene. The
intersection points of the rays with the sweeping plane are arranged into a semidynamical
range tree R. If a rectangle occurs during the sweep, R allows quickly to find those
intersection points in its interior, and hence its intersecting rays. The continuous sweep
is directly simulated by processing a sequence of discrete z-events of interest. Clearly, one
z-event of interest is the occurence of a rectangle. In this case, the intersection points are
reported, and all z-events initiated by the intersected lines are deleted from the list of z-
events. Other events of interest are those where the intersection points with the sweeping
plane change their x- or y-order. These events require an update of R. Note that these
events happen just at the intersection points of the lines projected onto the x-z- and y-
z-plane. They can be found by carrying out simultanously the plane sweep algorithm of
Bentley and Ottmann [PS86,Mh85] in these two planes. The time necessary to calculate
the proposed intersection points is O((m + k) log m), k the number of intersection points
of the projected lines. The amortized time for updating R at these intersection points
resp. deleting rays intersected by a rectangle is bounded by O((m + k) log2 m). Finally,
the time for calculating the intersection points with rectangles by range search is of
order O(n log2 m + I), I the total number of intersections that are found. The space is
bounded by O(m log m + n). For more details, the reader may consult [M86a].
The crucial point of this algorithm is k, which can be of order O(m2 ). A way out is to
decompose the given set of lines in, say, p disjoint sets of rays, each of about m p rays,
and apply the algorithm on each of these sets in separate. Particularily suited are the
subproblems obtained by cutting a twofold nested conjugation tree from above at some
level i. At the leaves of the primary tree, the spacesweep algorithm on the corresponding
sets of nodes is carried out. At the leaves of the secondary tree, analogous planesweep
algorithm is applied which finds for the iso-oriented line segments induced by the y-
2 −log n
z-projection of the rectangles, the intersected projected lines. For i = log m1+α , we
obtain
Proposition 5. Given m rays and n iso-oriented rectangles in space, m1−α < n <
m2 , the closest intersection point of every ray with the rectangles can √ be found
2α 1
in time O(m 1+α n 1+α polylog m) = O(m0.820 n0.590 polylog m), α = log 1+2 5 , using
O(m polylog m + n) space.
In interesting scenes, the number of geometric primitives can be of the same order like
the number of rays. Under this assumption, the proposition implies an average query
time of O(n0.41 ) per ray. There remains the question whether the first intersection point
of a ray can be reported within a time per ray polylogarithmic in m und n, using
O((m + n)polylog(m + n)) space at most. For special distributions of rays, like that
discussed in sect. 3.2, time bounds of this quality are available.
by polygon pi and L the number of light sources. If the triangles are replaced by more
complex primitives, time analysis becomes more complicated.
A second approach to generate shaded pictures is based on a direct application of a
visible surface algorithm. If P is the set of n given triangular polygons and A is the view
point, e.g. the central point of a perspective projection, let Vissurf(P, A) denote the set
of all parts of P visible from point A (details on the visible surface problem can be found
in the appendix). Assume now a light source at point Q. The exact parts of polygons
illuminated by the light source at point Q can be determined by first constructing a
larger set of polygons P 0 by P 0 := P ∪ Vissurf(P ,A). Then the visible surface reporting
problem Vissurf(P 0 ,Q) is solved, reporting only those visible parts of polygons contained
in Vissurf(P ,A). The set of visible and illuminated parts may be P 00 . The polygons in P 00
are projected onto the image plane and scan-converted into the raster image, evaluating
the formula of illumination for the light source in question. If there are several light
sources, this procedure is repeated as often as necessary and the respective intensities
summed into the final shaded picture.
The total time bound in the case of L light sources is of O((n + k) log n + L ∗ (n0 +
k 0 ) log n + L ∗ mx ∗ my ). The parameters n0 and k 0 are dependent on the scene. n0 is the
maximum number of polygons in any of the sets P 0 , and k 0 is the maximum number of
line intersections for the respective visible surface problem.
The table (see next page) compares the worst case time bounds of these algrithms with
those of raytracing.
4 Final Remarks
Raytracing is a technique of image generation of increasing importance. This is de-
monstrated by the length of the list of references at the end of this paper. A large
portion of these references is devoted to efficient solutions of the ray-primitive intersec-
tion test which was excluded here [Br86,Bv85,JB86,Kj83,Kj84,SA84,SB86,To85,Wk84].
Besides well-known approaches to speed up raytracing by restricting the search space,
we have presented the new strategy of primitive object query. This approach to consi-
der coherence seems to be of advantage compared with methods usually refered to as
“beam-tracing” [Am84], [DK85],[HH84], which certainly may be useful for special types
of scenes, but lacks the generality and flexibility of ray-tracing. Finally, new models of
illumination were developed, further improving the optical quality of images. Closely
related to ray tracing is distributed ray tracing [CP84],[LR86]. Distributed raytracing
allows to generate depth of field and motion blur almost at the same cost of computation
as usual anti-aliasing. A very different technique is the radiosity approach. The radiosity
approach allows diffuse interreflection and refraction of light from primary light sources.
Further aspects being excluded here are parallel algorithms and hardware to speed
up raytracing. To our experience, raytracing is well suited for pipelined processing,
concerning vectorial supercomputers [MC86] as well as systolic processing [M86d]. Other
contributions to the discussion on parallel raytracing are [Br84,CW86,DS84].
depth buffer visible surface ray tracing
strategy strategy algorithm
P
shading i P olypixel(pi ) n + k)logn (n + k)logn
(incl. highlights) +n + L · mx · my +L · mx · my +(L + logn) · mx · my
Pass 1: This part of the algorithm concentrates on the mapped 2d scene and generates
the so-called connection graph. The set of vertices of the connection graph is composed
of all points in the plane that are start or end points of line segments, all intersection
points of line segments, and all drain points. Two vertices are connected by an edge (of
the connection graph), if the two vertices are neighbours on a specific line segment or
if a vertex needs a drain connection with another line segment (drain edge). Figure A1
shows a simple 3d scene and its corresponding connection graph. The connection graph
is connected, planar and geometric since vertices are discrete points of the plane.
The data structure to store the connection graph is relatively complex. Each vertex
which is left endpoint of a line segment has a natural drain line or an artificial one.
There is no need for an artificial drain line if the vertex has a line segment edge with
an end point left of it. In general we choose that line segment with maximal slope as
the natural drain line of a vertex. Note that vertical line segments can be avoided by a
small rotation of the whole scene.
A suitable extension of the algorithm of Bentley and Ottmann [Mh84,PS85] for line
segment intersection reporting can generate connection graphs in time of O((n+k) log n).
Artificial drain lines and drain vertices are introduced by a simple inspection of the actual
line segment ordering generated by this algorithm during the sweep. If m line sements
intersect at a point V , the generation of the corresponding vertex data structure for the
connection graph is possible in time of O(m log m) by straightforward methods even if
the line segment ordering information of the plane sweep is not used. But this term is
absorbed since m intersecting line segments produce m(m−1) 2 pairwise intersections and
the plane sweep needs time of O(k log n) to process k intersections.
The space to store the connection graph is of O(n + k), where k is the total number of
Figure A2. If vertex V is reached by e2 or e3 the traversal returns immediately, no
updating of the actual inclusion status is necessary. If V is reached by its drain edge e1 ,
all edges to the right of V are traversed consecutively and recursively.
pairwise intersections of line segments. The additional artificial drain lines are without
charge since their number is always less than n and since they are free of intersections.
Pass 2: Now the connection graph is traversed in order to assign to all edges the
corresponding visibility status. Consider an edge e of the connection graph. The inclusion
status of e is defined as
I− (e):= ordered set of polygons (visibility order) covering the region below of e,
I+ (e):= ordered set of polygons covering the region above of e.
Note that this definition is unequivocal and sound only if the 3d scene is free of pe-
netrations of polygons. We use balanced trees to store the polygons of an inclusion
state in visibility order. Since there are at most n polygons, the space is of O(n) and
inclusion/deletion operations can be performed in O(log n).
There are several different strategies to travers the connection graph in such a way, that
each single edge is processed exactly twice. One possible strategy starts at the root vertex
and ends there. Each edge is traversed once from left to right and once backwards. If a
vertex is reached (from left to right) by an edge, which is not the (natural or artificial)
drain edge of that vertex, movement goes back to the left. If a vertex is reached from
left by the drain edge, all edges to the right of that vertex are traversed one after the
other in natural order, and then a return to the drain edge takes place. See figure A2
for an illustration of this strategy. In order to combine this traversal with a continuous
update of the inclusion status for the actually reached edge, we need only to know, what
edge belongs to what polygon.
In the case of a transfer to a new edge which is incident to the actual one, updating of
the inclusion status is done as follows.
Consider a transfer from an edge e to an edge e’ above e.
During the traversal the edges are labeled as early as possible with their visibility infor-
mation. If the top polygons of I− (e) and I+ (e) are identical, then e is covered by this
polygon. If these top polygons are different, the edge is visible and is part of one of these
polygons. These two polygons are also recorded. Thus the ’most visible’ polygons in the
neighbourhood of a visible edge are always known and their determination is possible
in time O(log n).
Since the number of edges is at most of O(n + k), the total time for the traversal (pass
2) is of O((n + k) log n) and does not increase the overall time complexity.
Pass 3: Now the visible parts of polygons are collected and reported. Due to pass 2, the
question for visible edges can be answered immediately. Invisible edges are treated as if
not being present. But the subgraph consisting of visible edges and their corresponding
vertices may not be connected any more. Therefore we treat some of these invisible drain
edges as pseudo-visible in order to connect everything again.
This graph - which is still geometric - partitions the relevant parts of the plane into
simply connected regions. These regions represent all visible parts of the given plane
surfaces. There is no problem to report all these parts and to specify the polygon of
which the visible surface is a part. All this clearly can be done is time of O(n + k).
As a result of this algorithm and of its time analysis we can state:
Theorem. The algorithm described above reports all visible parts of a given set of
plane, simple and nonpenetrating polygons of a given 3D scene in time O((n + k) log n)
and space O(n + k), where n = total number of edges of polygons, and k = number of
intersections of edges (=line segments) after transformation of the scene into 2d screen
space.
It should be mentioned that an implementation of this algorithm is not at all a trivi-
al task since various complicated data structures must be used in order to reach the
asymptotic time bounds. For practical implementations an approach based on Franklins
cell raster technique [Fr80, MSA85] should be used. It was shown that this technique
allows solutions of the visible surface reporting problem for almost all practical scenes
in expected linear time. For more details see [MSA 85].
It should be noted that hidden line elimination is always simpler than visible surface
reporting. But up to now it is not possible to verify this by presenting different time
bounds for both problems. Only recently, Devai [D86] showed that any visible line repor-
ting problem can be solved in time O(n2 ), which is an improvement to the O((n+k) log n)
bound in cases where k = Ω(n2 ). In the meantime, McKenna [M86] proved this same
time bound for the visible surface problem too. The drawback of these algorithms is
that they require O(n2 ) space.
References
[Am84] Amanatides, J.: Ray-Tracing with Cones, Computer Graphics 18 (1984) 129-
139
[Bv85] Bouville, C.: Bounding ellipsoids for ray-fractal intersection, CG 19 (1985) 45-52
[Bv85] Bouville, C., Brusq, R., Dubois, J.L., Marchal, I.: Generating high quality pic-
tures by ray tracing. Computer Graphics Forum 4 (1985) 87-99
[Br84] Brusq, R.: Synthese d’image par lancer de rayon (ray tracing): la machine Cristal
- resultats et perspectives, Deuxieme colloque image, Nice, 1984, 404-410
[Ch83] Chazelle, B.: Filtering Search: A new approach to query answering, 24 IEEE
FOCS, 1983, 122-132
[CG83] Chazelle, B., Guibas, L.J., Lee, D.T.: The power of geometric duality, IEEE
FOCS, 1983, 217
[CP84] Cook, R. L., Porter, T., Carpenter, L.: Distributed Ray Tracing, Computer
Graphics 18 (1984) 137-144
[CW86] Cleary, J.G., Wyvill; B.M., Birtwistle, G.M., Vatti, R.: Multiprocessor ray
tracing, Computer Graphics Forum 5 (1986) 3-12
[DK85] Dadoun, N., Kirkpatrick, D.G., Walsh, J.P.: The geometry of beam tracing. 1.
Symposium on Computational Geometry, Baltimore, 1985, 55-61
[DE83] Day, W.H.E., Edelsbrunner, H.: Efficient algorithms for agglomerative hierar-
chical clustering methods, IFIP Graz, Report F121, July, 1983
[D86] Devai. F.: Quadratic bounds for hidden line elimination. Proc. 2nd Annual ACM
Symposium on Computational Geometry, Yorktown Heights, New York, June 86,
pp. 269-275.
[DS84] Dippé, M., Swensen, J.: An adaptive subdivision algorithm and parallel archi-
tectures for realistic image synthesis, Computer Graphics 18 (1984) 149
[DE84] Dobkin, P.D., Edelsbrunner, H. Space searching for intersecting objects, IEEE
FOCS, 1984, 387-391
[EW86] Edelsbrunner, H., Welzl, E.: Halfplanar range search in linear space and
O(n0.695 ) query time, Information Processing Letters 23, 1986, 289-293
[FS75] Floyd, R.W., Steinberg, L.: An Adaptive Algorithm for Spatial Grey Scale,
SID’75, Int. Symp. Dig. tech. Papers, 1975,36
[Fr80] Franklin, W.R.: A linear time exact hidden surface algorithm, Computer Gra-
phics 14 (1980) 117-123
[FI85] Fujimoto, A., Iwata, K.: Accelerated ray tracing. Proceedings of Computer Gra-
phics Tokyo’85, T.L. Kunii, ed., Springer-Verlag, Tokyo, 1985
[Gv86] Gervautz, M.: Kugel- und Quaderumgebungen zur Optimierung des Ray-
Tracing-Verfahrens für CSG-Bäume, Proc. AUSTROGRAPHICS’86, Oldenbourg-
Verlag, München, Wien, 1986
[Gl84] Glassner, A.S.: Space subdivision for fast ray tracing, IEEE CG & Appl. 4,
October 1984, 15-22
[HW86] Haussler, D., Welzl, E. Epsilon-nets and simplex range queries, 2. ACM Symp.
on Comput. Geometry, 1986
[HH84] Heckbert, P.S., Hanrahan, P.: Beam Tracing Polygonal Objects. Computer
Graphics 18 (1984) 119-127
[JB86] Joy, K.I., Bhetanabhotla, M.,N.: Ray tracing parametric surface patches utilizing
numerical techniques and ray coherence, CG 20 (1986) 279-285
[KG79] Kay, D.S., Greenberg, D.: Transparency for computer synthesized images. CG
13 (1979) 158-164
[KK86] Kay, T.L., Kajiya, J.T.: Ray tracing complex scenes, CG 20 (1986) 269-278
[Kj84] Kajiya, J.T., von Herzen, B.P.: Ray tracing Volume Densities. Computer Gra-
phics 18 (1984) 165-174
[Kj83] Kajiya, J.T.: New Techniques for Ray Tracing Procedurally Defined Objects.
ACM Trans. on Graphics 2 (1983) 161-181
[LR86] Lee, M.E., Redner, R.A., Uselton, S.P.: Statistically optimized sampling for
distributed ray tracing, CG 19 (1986) 61-68
[Me85] Meggido, N.: Partitioning with two lines in the plane, J. of Algorithms 6 (1985)
430-433
[Mh84] Mehlhorn, K.: Data structures and algorithms, III, Springer-Verlag, Berlin,
1984
[MHS85] Müller, H., Schmitt, A., Abramowski, S.: Visible Surface Calculation for Com-
plex Unstructured Scenes, Computing 35 (1985) 231-246
[M86a] Müller, H: Realistic image synthesis from complex scenes by raytracing (in
German), Angewandte Informatik 4/86, 151-155
[M86b] Müller, H., Image generation by space sweep, Computer Graphics Forum 5
(1986) 189-195
[MC86] Müller, H., Christmann, A.: Realistic image synthesis on vector supercomputers
(in German), it-Informationstechnik 5, 1986, 275-280
[M87] Müller, H.: Parallel computers for realistic image synthesis, IEEE Proceedings
CompEuro’87, 1987
[Rh82] Roth, S.D.: Ray casting for modeling solids, Computer Graphics and Image
Processing 18 (1982) 109-144
[SA84] Sederberg, T.W., Anderson, D.C: Ray tracing of Steiner patches, CG 18 (1984)
159-164
[SD85] Speer, L.R., DeRose, T.D., Barsky, B.A.: A theoretical and empirical analysis
of coherent ray tracing, Springer-Verlag, Tokyo, 1985
[Sa84] Samet, H.: The quadtree and related hierarchical data structures, ACM Com-
puting Surveys 16 (1984) 187
[Sch81a] Schmitt, A.: Time and space bounds for hidden line and visible surface algo-
rithms, Proceedings Eurographics’81, North-Holland Publ. Comp., 1981, 43-56
[Sch81b] Schmitt, A.: Reporting geometric inclusions with an application to the hid-
den line problem, in: Proceedings 7th Conference on Graphtheoretic concepts in
Computer Science (WG81), Hanser-Verlag, 1981, 135-143
[SB86] Sweeney, M.A.J., Bartels, R.H.: Ray tracing free-form B-Spline surfaces, IEEE
CG&Appl., Feb. 1986, 41-49
[TK84] Tamminen, M., Karonen, O., Mäntylä, M.: Ray-casting and block model con-
version using a spatial index, CAD 16(4) (1984) 203-208
[WH84] Weghorst, H., Hooper, G., Greenberg, D.P.: Improved computational methods
for raytracing, ACM Trans. on Graphics 3 (1984) 52-69
[Wh80] Whitted, T.: An Improved Illumination Model for Shaded Display. CACM 23
(1980) 343 - 349
[Wk84] Wijk, J.J.: Ray Tracing Objects Defined by Sweeping Planar Cubic Splines.
ACM Transactions on Graphics 3 (1984) 223-237
Alfred Schmitt is a full professor at the Karlsruhe (technical) University since 1972
and is the leader of an academic teaching and research group working in the field of man-
machine dialogue and computer graphics. His present research areas are fast hidden line
and visible surface algorithms, ray tracing and its implementation and designing the man
machine interface. He received a degree in mathematics and physics from the University
of Saarbrücken and a doctoral degree from the Technical University of Hannover. He is
a member of the ACM since 1965 and of Eurographics, GI, German Chapter ACM and
EATCS.
Heinrich Müller is a lecturer at the Institut für Informatik I, Universität Karlsruhe,
West Germany. He received diplomas in mathematics and computer science in 1978, and
a Ph.D. in computer science in 1981 from the Universität Stuttgart. Research interests
are the development of algorithms, data structures, and systems for geometric problems
(in particular in computer graphics, CAD, and robotics) and parallelism. He is a member
of the Gesellschaft für Informatik (GI).
Wolfgang Leister is a research associate at the Institut für Informatik I, Universität
Karlsruhe, West Germany. interests include computer animation. He received a diploma
in computer science from the Universität Karlsruhe in 1986. In his diploma thesis he
worked on generating highly realistic images by ray tracing especially for application in
computer animation. He is a member of the Gesellschaft für Informatik (GI).