Computers & Graphics 23 (1999) 681}692
Visibility * techniques and applications
Hierarchical back-face computationq Subodh Kumar!,*,1, Dinesh Manocha", William Garrett#, Ming Lin" !Department of Computer Science, Johns Hopkins University, Baltimore, 224 New Engineering Bldg, MD 21218, 2694, USA "Department of Computer Science, University of North Carolina at Chapel Hill, Chapel Hill, NC 27599, USA #Silicon Graphics, Incorporation, 2011 N. Shoreline Blvd. m/s 991, Mountain View, CA 94043, USA
Abstract We present a sub-linear algorithm to compute the set of back-facing polygons in a polyhedral model. The algorithm partitions the model into hierarchical clusters based on the orientations and positions of the polygons. As a preprocessing step, the algorithm constructs spatial decompositions with respect to each cluster. For a sequence of back-face computations, the algorithm exploits the coherence in view-point movement to e$ciently determine whether it is in front of or behind a cluster. Due to coherence, the algorithm's expected running time is linear in the number of clusters on average. We have applied this algorithm to speed up the rendering of polyhedral models. On average, we are able to cull about 40% of the polygons. The algorithm accounts for 5% of the total CPU time per frame on an SGI Onyx. The overall frame rate is improved by 40}75% as compared to the standard back-face culling implemented in hardware. We also present an extension of our back-face computation algorithm to determine silhouettes of polygonal models. Our technique "nds true perspective silhouettes by collecting edges at the common boundaries of back-facing and front-facing clusters. ( 1999 Published by Elsevier Science Ltd. All rights reserved.
1. Introduction Visibility computation is a signi"cant component of various graphics applications like hidden surface elimination, radiosity computation, shadow generation and simpli"cation. We present visibility algorithms based on polygonal orientation. A polygon may be oriented clockwise or counterclockwise by assigning a direction to each of its edges.
q Supported in part ARPA ISTO Order No. A410, ARPA Contract DABT63-93-C-0048, Alfred P. Sloan Foundation Fellowship, ARO Contract P-34982-MA, NSF Grant CCR9319957, NSF Grant CCR-9625217, NSF Grant No. MIP9306208, ONR Contract N00014-94-1-0738 and NSF/ARPA Center for Graphics and Sci. Visualization. * Corresponding author. Tel.: #1-410-516-0060; fax: #1410-516-6134. E-mail address:
[email protected] (S. Kumar) 1 Partially supported by NSF CAREER award.
Two adjacent polygons (in a polyhedron) are consistently oriented if the two respective directions of their common edge are opposite. The orientation of a polygon also imposes a direction on its normal, given by the righthand rule. Polygons whose normals point away from the view-point are called back-facing. Given a solid polyhedron comprising consistently oriented adjacent polygons, the back-facing polygons are not visible from the viewpoint. By eliminating these polygons, applications that need to perform computations only on the visible polygons can reduce the working set by approximately half on average. For example, a polygon renderer can skip drawing any polygon that is back-facing. This technique, known as back-face culling, is widely used to improve the frame rate. Many graphics systems implement it in hardware. If the polygons are not part of a polyhedron or if the polyhedra have missing or clipped faces, back-facing polygons can be treated specially. If culling is not desired, special shading may be performed for back-facing polygons to depict the inside of the model [1]. Similar techniques are also used by algorithms for shadow generation
0097-8493/99/$ - see front matter ( 1999 Published by Elsevier Science Ltd. All rights reserved. PII: S 0 0 9 7 - 8 4 9 3 ( 9 9 ) 0 0 0 9 1 - 6
682
S. Kumar et al. / Computers & Graphics 23 (1999) 681}692
[2] and collision detection [3]. In addition, a similar algorithm can also be used to compute the front-facing polygons. This results in an algorithm to e$ciently compute the silhouettes by eliminating both front- and back-facing polygons. Silhouettes are useful for clustering in radiosity computations, model simpli"cation, image registration, image based rendering and non-realistic shading, among other things. In the rest of this paper we assume all polygons are triangles. Results still hold for n-sided polygons as we could triangulate them. Main contribution: The simplest algorithms for back-face computation involve computing the dot product of the polygon normal with a vector from the view-point to any point on the polygon. The complexity of these standard algorithms is linear in the number of polygons. We present a simple, hierarchical, sub-linear algorithm for back-face computation. It is particularly e$cient for applications where the viewpoint moves slowly through space. It has three main components:
ive frames. The performance is nearly independent of the number of polygons in a cluster. We have implemented the algorithm and employed it to perform back-face culling for rendering. In practice, it improves the overall frame rate by 40}75% over hardware back-face culling. The rest of the paper is organized as follows. We survey the related work on visibility, polygon clustering, and use of coherence in Section 2. We introduce some terminology and give an overview of the algorithm in Section 3. In Section 4, we present the algorithm for computing the clusters and their hierarchical representation. Section 5 highlights our approach for partitioning the space with respect to each cluster. We describe the algorithms for tracking the view-point in Section 6. Section 7 discusses the computation of silhouettes and "nally we discuss an implementation and its performance in Section 8.
f Cluster formation: The input polygonal model is partitioned into a hierarchy of clusters based on both similarity of orientation and physical proximity of the polygons. f Spatial partition: The space is partitioned into BackRegion, FrontRegion and MixedRegion with respect to each cluster. All polygons in a cluster are back-facing if the view-point is in the BackRegion of that cluster. Similarly, all polygons in a cluster are front-facing if the view-point is in the FrontRegion of that cluster. If a point is neither in the FrontRegion nor the BackRegion of a cluster, it is in its MixedRegion. FrontRegion and BackRegion of a cluster are further decomposed into Query cells, each an open half-space bounded by three planes. f View-point tracking: At each frame the algorithm starts at the Query cell that contained the view point in the previous frame and incrementally locates the Query cell containing it in the current frame. This new Query cell is then used to determine the Regions the view point lies in. This operation takes expected constant time. If the view point lies in the MixedRegion of a cluster C, some polygons in the cluster are frontfacing while others are back-facing, so the algorithm is applied recursively to the children of C.
Since the early days of image synthesis, visible surface computation has been a central geometric problem. A number of algorithms have been proposed based on spatial partitioning, hierarchical representations, Z-buffer, list-priority, scan-line, area-subdivision and polygon clusters [4,1,5,6]. Many asymptotically e$cient algorithms have been proposed [4]. However, for models composed of tens of thousands of polygons, only Z-bu!er approaches are able to give interactive performance on current graphics systems. Many non-interactive applications use binary space-partitioning (BSP) trees [5] to improve the rendering speed of large static environments. There is also signi"cant literature on the use of polygon clusters in visibility computations. Schumaker [7] and Newell [8] were among the "rst researchers to employ polygon clustering. Coherence has been key to many visibility algorithms. In their classic paper [6], Sutherland et al. show how visibility algorithms can take advantage of coherence and identify eight di!erent kinds of coherence. Rendering complex geometric models composed of millions of polygons has always been a challenge, specially in terms of visibility computations. Consider for example walkthroughs of large CAD models like airplanes, submarines, buildings or entire cities. Such models are composed of millions of polygons. To handle such large data-sets, three kinds of visibility approaches have been used along with Z-bu!ering: View-frustum culling: The technique of view-frustum culling uses spatial data structures such as octrees and hierarchical traversals of such structures to cut out portions of the model not lying in the current view volume [9,1].
The space complexity of the cluster data structure containing n polygons is n log n, in general. However, we have found a small height for the cluster hierarchy to be the most e!ective in practice. Thus the space complexity is practically linear. Its overall performance is a function of the number of clusters, the height of the cluster hierarchy, and the motion of the view-point between success-
2. Previous work
S. Kumar et al. / Computers & Graphics 23 (1999) 681}692
Occlusion culling: These include techniques based on partitioning the model into cells and portals and computing the partial visibility set of polygons from each cell [10,11]. They have been successfully applied to architectural models and used to speed-up global visibility algorithms for illumination computation. However, in order to achieve maximum acceleration, the cells must be 3D regions of space which are almost entirely enclosed by occluding surfaces, so that most cells are hidden from most other cells. In principle, they can be used on general 3D polygons for occlusion, but the necessary algorithms have very high computational complexity [11]. A hierarchical Z-bu!er algorithm combining spatial and temporal coherence with hierarchical structures was presented by Greene et al. [12]. It cleverly exploits di!erent types of coherence and can achieve several orders of magnitudes of acceleration compared with traditional techniques. This algorithm is specially suited for hardware support. More recently, a variant proposed by Zhang et al. [13] proposed a technique called occlusion maps which can be implemented more e$ciently on current hardware. They use multi-pass rendering to rasterize occluders "rst. That images is then hierarchically decomposed into occlusion maps and subsequently used to cull away parts of the model completely hidden behind the map. Another method [14] for back-face culling with sublinear performance is based on collating global visibility information, which aH priori compute visibility from all view points. This is clearly more di$cult than determining merely what is visible from a single view point as is done in hidden surface removal. However, most computation is o!-line. The rendering time algorithm reduces to a simple point location. On the other hand, the required data structure tends to be prohibitively large. Variants [15,16,24] have been proposed to reduce the memory requirement at the cost of precise pre-computed occlusion information at rendering time. Back-face culling: Back-face culling is a particular form of occlusion culling used on solid models that can be easily combined with other visibility culling methods. It computes all the back-facing polygons from the given view-point and eliminates them from rendering. It has recently been extended to spline patches by computing a bound on the normals using the Gauss map of a patch [17,18]. The current back-face computation methods take time linear in the number of polygons. Most back-face computation algorithms can be extended to compute silhouettes in linear time. Some techniques have been proposed to speed that up. Tanimoto [19] proposed a graph-theoretic approach that incrementally computes the silhouettes of a convex polytope using frame-to-frame coherence. It is di$cult to extend it to general non-convex polytope models, however. The silhouettes of such models can have multiple components and the number of components vary from di!erent view point.
683
3. De5nitions and background For a polygon, P , in R3, let the equation of the plane i containing P be a x#b y#c z"d . It partitions R3 i i i i i into two half-spaces: Hb : a x#b y#c z(d , i i i i i Hf : a x#b y#c z*d . i i i i i Given the view-point, V" (X,>,Z), polygon P is backi facing i! V 3Hb or front-facing i! V 3Hf. i i For a cluster C of polygons, P , P , 2, P , we de"ne: 1 2 m BackRegion: the set of points, Hb"Hb WHb W2 i 1 2 WHb . m FrontRegion: the set of points, Hf"HfWHfW2 i 1 2 WHf . m MixedRegion: R3CBackRegionCFrontRegion, the set of points which do not belong to either BackRegion or FrontRegion. (C denotes set di!erence). Note that there is a separate spatial partition for each polygon cluster. We illustrate these Regions for a collection of lines in 2-D in Fig. 1. Based on these de"nitions, it is clear that if the view point V lies in the BackRegion, then all the polygons in the cluster C are back-facing. Similarly, if V lies in the FrontRegion, all the polygons are front-facing. Finally, if the view point lies in the MixedRegion, some of the polygons are back-facing and the others are front-facing. Our overall algorithm uses many concepts and algorithms from computational geometry, e.g. convex hulls, linear programming and duality. Details of these can be found in [20]. We only mention some relevant pointers here.
Fig. 1. Di!erent regions of a cluster.
684
S. Kumar et al. / Computers & Graphics 23 (1999) 681}692
Convex hull: The convex hull of a set of points is the smallest convex set containing those points. A number of algorithms are known in the literature to compute the algorithms in 2-D and 3-D [20]. In our application, we use the Quickhull algorithm for computing convex hulls [21]. Its robust implementation is available as part of the Qhull public domain package. Linear programming: Geometrically, linear programming amounts to the following: given a set H of halfspaces and a vector W, compute a vertex v, in the common intersection of half-spaces, that minimizes v ) W. If this common intersection is null or unbounded, no such vertex exists. To solve a linear programming problem, we use the randomized algorithm presented in [22]. A public domain implementation of this algorithm is available. Duality: Duality is powerful concept and used in a number of geometric algorithms [20]. In R3, the dual of a plane P : ax#by#cz"1 is the point PM : (a, b, c) and vice versa. (The dual of a line is a line.) Note that this normalized form of plane equation assumes that the plane does not pass through the origin. To handle this problem, the coordinate system is transformed, so that the new origin does not lie on the plane, i.e. we move the origin O@ to a new point O. The dual is said to be taken about the point O. In our application, we are interested in the following property of duality: the dual of the intersection of half-spaces MH N, is the convex hull of Mdual(H )N. i i Faces, edges and points on the dual hull correspond to points, edges and faces, respectively, on the boundary of the intersection of half-spaces MH N. i 4. Clusters Given a model with N polygons, decomposing the model into clusters is an essential component of our algorithm. When we cluster polygons, we must consider two issues: f How many clusters do we partition the model into? f Given the number of clusters, how do we distribute the polygons among di!erent clusters?
Given cluster and the associated Regions, the tracking algorithm determines if the polygons in the cluster are all back-facing or all front-facing. The quality of clustering is crucial to the e!ectiveness of our culling algorithm. Done naively, the BackRegion of a cluster can become very small thus reducing the probability of the view point being in the back region. For instance, a closed set of polygons has null BackRegion, since there always exists a view point in space such that some polygon of the given set is front facing. Therefore, the variation of orientation of the polygons in a group must be reduced to maximize the BackRegion to optimize our culling algorithm. However, two similarly oriented polygons that are far apart should not be grouped into a cluster, since the view point is likely to locate between the polygons. Hence it is important to consider proximity not only in the normal space, but also in physical space. We use duality to minimize the proximity of the polygons in the normal space. We compute a point in the dual space for each polygon in the primal space. A polygon contained in the plane a x#b y#c z"d maps to the i i i i point (a /d , b /d , c /d ) in the dual space. The proximity of i i i i i i the polygons in the normal space implies that their corresponding dual points are very close to each other in the dual space (based on the Euclidean distance between two points in the dual space). Thus, one simple algorithm for computing the clusters is to compute the duals of all polygons and partition them into Q groups in the dual space such that all the points belonging to a group are `closea to each other. Such groups can be computed by decomposing the dual space into a three-dimensional grid, classifying the dual points with respect to the grid boxes, and merging or splitting the boxes as necessary (so as to obtain Q groups). The dual of the points in each group is a cluster in the primal space. Note that polygons at distance l from the origin in the primal space get mapped to points at distance 1/l in the dual space. Correspondingly we use inverted distances. Given two points (not at the origin), A"(x , y , z ) 1 1 1 and B" (x , y , z ), the distance between them is 1 1 1 de"ned as
K
D(A, B)" 4.1. Cluster formation We address the "rst question in Section 8.2 and present an algorithm to compute the number of clusters to maximize the overall performance. Given the number (Q), we decompose the polygonal model into various clusters based on two constraints: f Physical proximity: Minimize the distance between polygons. f Proximity in the normal space: Minimize the variation of orientations of the polygons. This corresponds to minimizing their distance in the normal space.
1
K
1 ! . Jx2#y2#z2 Jx2#y2#z2 1 1 1 2 2 2
(1)
The resulting algorithm partitions the points in the dual space in di!erent grids based on this metric. All the points in the same grid are merged into a cluster. Di!erent grids are merged, so that we obtain Q clusters eventually. For the polygons whose plane equations pass through the origin, we associate them with the cluster which has the average normal closest to it. Fig. 2(a) demonstrates the performance of our implementation on polygonal models of the teapot and Fig. 3 on a bunny and the PLB model (recommended
S. Kumar et al. / Computers & Graphics 23 (1999) 681}692
685
Fig. 2. Cluster Formation: One color for each cluster.
benchmark by the Graphics Performance Committee). Each cluster corresponds to a di!erent color on the model. For example, Q equals 148 for Fig. 2(a), 128 for 2(b), 372 for 3(a), and 226 for 3(b).
4.2. Hierarchical representation If the average number of polygons per cluster is high (as with large models decomposed into relatively few clusters), the algorithm is unable to classify many of the back-facing polygons as they lie in a cluster with other front-facing polygons. Increasing the number of clusters alleviates that problem, but the performance of the tracking algorithm is a linear function of the number of clusters. To avoid these problems, we represent large clusters hierarchically. Each cluster is decomposed into sub-clusters. Each sub-cluster is decomposed recursively until the number of polygon is less than a user-speci"ed threshold. In our implementations, we set the threshold to 20. An example of hierarchical representation for a cluster is shown in Fig. 4. Fig. 4(b) shows a cluster, A, with two sub-clusters, B and C. The BackRegion of A, RA, is RBWRC. The BackRegion of each sub-cluster is a proper superset of the BackRegion of the original cluster. The sub-clusters corresponding to the "rst and second levels of the PLB model are shown in Fig. 3(c) with 904 clusters and in Fig. 3(d) with 2536 clusters. A model is partitioned into several clusters at the top level. Each cluster is further sub-partitioned. We do not use a deep hierarchy in general, as the space requirement and traversal overhead starts to grow without equivalent improvement in overall performance.
5. Spatial partition Given a cluster, C, of polygons, P , P , 2, P , we 1 2 m present algorithms for computing the Regions of this cluster and decomposing them into Query cells. 5.1. Regions computation The BackRegion of a cluster is an open convex set consisting of boundary planes, and de"ned as the intersection of Hbs. We need to compute: i f the boundary set hb of planes that lie on BackRegion. f lb, the lines of intersection between adjacent boundary planes. f pb, the points of intersection between adjacent boundary planes. These are computed from the dual convex hull of Hb.
Algorithm I (1) Compute a point O 3 BackRegion (see Algorithm II). (2) Compute the dual point of each plane about O. Find convex hull of these points. (3) The points on the hull correspond to hb. Since BackRegion is an open set, not all faces of the hull correspond to a point in pb } only those whose normals point away from origin. lb corresponds to the edges of the hull between valid faces.
686
S. Kumar et al. / Computers & Graphics 23 (1999) 681}692
Fig. 3. Clusters for the bunny and PLB models.
The algorithm for computing FrontRegion is essentially the same as that for BackRegion. The FrontRegion corresponds to the intersection of Hfs as i opposed to Hbs. We do not compute the MixedRegion i explicitly. It is implicit in R3CBackRegionCFrontRegion. In both FrontRegion and BackRegion, we compute contained feasible points using variants of the same algorithm. It is described in terms of the BackRegion next. 5.2. Feasible point computation We use linear programming to compute the point O. We can choose any minimization vector W, and use the
resulting vertex v. However, for any random choice of W, linear programming may return an unbounded solution. We present a simple algorithm, which computes a bounded point O inside (BackRegion): Algorithm II (1) Choose a small d'0 and modify each half-space Hb to: Hb : a x#b y#c z((d !d). It follows that i i i i i i HbLHb. i i (2) Choose any polygon P of the cluster with j the plane equation: a x#b y#c z"d , and set j j j j W"(!a , !b , !c ). j j j
S. Kumar et al. / Computers & Graphics 23 (1999) 681}692
687
Fig. 4. Hierarchical representation of clusters.
(3) Set O"v, the vertex returned by the linear programming routine. Based on our construction, it is clear that O is a vertex in BackRegion, at least a distance of d away from its boundary. 5.3. Decomposing into Query cells Given an arbitrary location of the view-point V, a naive algorithm for point location initially tests each bounding plane for containment in the BackRegion. If the result is negative, it checks if the point is in FrontRegion. Both BackRegion and FrontRegion for a cluster are represented by the planes on their respective boundaries. Thus, any point location query can take time proportional to the number of bounding planes, which is O(m), m being the number of polygons in the cluster. In computational geometry literature, algorithms with logarithmic asymptotic complexity are known for point location in convex sets [23]. However, their space requirements and constant factors are rather high. In this section, we present a simple algorithm to decompose BackRegion and FrontRegion into Query cells. Each Query cell is a convex open region bounded by three planes. A point-location query in such cells can be answered in constant time. Furthermore, a decision plane, P , is associate with each query cell i. If the view i point lies in BackRegion cell i and in Hb, the cluster is i back-facing. The tracking algorithm presented in Section 6 uses these cells along with temporal coherence to check which of the three Regions contain the view point. We
Fig. 5. Tracking inside the query cells.
present the decomposition algorithm for BackRegion; the same formulation applies to FrontRegion. Our algorithm computes a center point in BackRegion. Planes passing through this center point and the boundary lines of BackRegion partition it into disjoint cells. It is easier to understand this partitioning in 2-D. Fig. 5 shows one such partitioning. The lightly shaded region shows the BackRegion of a cluster. CB is the center point. For each edge B "b b on the boundary of BackRegion, the query j i j cell BQ is the open cone with CB as its apex. These cells j have the following property: if the view point lies in BQ , j it is su$cient to test against the line B to determine if the j view-point is in fact in BackRegion. Now we present the algorithm in 3-D:
688
S. Kumar et al. / Computers & Graphics 23 (1999) 681}692
Algorithm III (1) Compute the boundary of BackRegion, as outlined in Algorithm I. (2) Compute a center point CB 3 BackRegion. The arithmetic mean of boundary points is a good center point. (3) Each face on the boundary of BackRegion is de"ned by a sequence of edges. (This sequence is closed for polygons that have adjacent boundary planes on all their edges.) We triangulate the polygonal region, so that each face is bounded by three edges. Call the set of these triangular regions, BT. (4) For each BT we construct three side-planes, each i including an edge of BT , and the point CB. Correi sponding to each face BT is an open tetrahedral i Query cell, BQ with CB as its apex. If the view point i lies in a cell BQ , the plane of face BT determines i i containment in BackRegion. (5) Each edge on the boundary of BackRegion is shared by two facets. Hence each side-plane of a facet is shared by two Query cells. We use this adjacency information to maintain a neighbor list for each Query cell. This is used to &walk' to the appropriate cell when the view point moves out of a given Query cell (as explained in Section 6). (6) In addition to these cells, we add a truncated cone that encloses the center point. It is used to reduce the number of traversal steps (as discussed in Section 6). The algorithm similarly computes a decomposition of space into Query cells FQ s based on the boundary of j FrontRegion. It follows from construction that the two decompositions can overlap in MixedRegion. The algorithm keeps track of the overlaps amongst these query cells by storing the following information: f We are given the boundary triangles of BackRegion, BT s, and those of FrontRegion FT s. For each BT i i i maintain pointers to all the FrontRegion Query Cells FQ s, it overlaps. If there are more than three such j values of j, subdivide BT into smaller triangles such i that the set associated with each sub-triangle has at most three cells. f Repeat the process for FT on the boundary of Froni tRegion, storing their overlaps with BQ s. j
6. View-point tracking At run-time, the algorithm uses the pre-computed cluster descriptions to locate the view point in the corresponding Region for each cluster. If the view point is contained in BackRegion or FrontRegion, it is in a unique Query cell. If the view point lies in MixedRegion,
it is contained in two Query cells, respectively, (BQ and i FQ ). The "rst corresponding to BackRegion and the j second corresponding to FrontRegion. For each frame, the algorithm tests whether the view point lies in the same cell(s) it did in the previous frame. Each test involves computing the position of the view point with respect to each bounding plane. If the view-point fails a bounding plane test, the algorithm walks to the neighboring cell adjoining that plane, as shown in Fig. 6 (red cell is the tracked cell in b and c). This walk is repeated until the algorithm "nds the cell containing the viewpoint. If the resulting cell lies in the MixedRegion, the algorithm is applied recursively to each child of that cluster. Some extra processing is involved whenever the algorithm moves from BackRegion or FrontRegion to MixedRegion (or vice-versa). The running time of the algorithm is a function of the number of cells traversed per frame. Due to coherence, this number is typically small. Thus, if a cluster consists of k sub-clusters, the expected time to traverse all subclusters is O(k). On the other hand, if we do not assume coherence, the expected number of cells traversed in a cluster with m equi-sized cells, is O(Jm), if the cells uniformly partition the space. This is because the average length of the shortest path from one cell to the other is O(Jm). For a model with n polygons, the total traversal time for a k-way hierarchy is O(Jnk) in that case.
6.1. Reducing traversals Given that the performance for each cluster at every frame is determined by number of cells traversed, the algorithm minimizes the number of traversals. When the view point fails the containment test for the current Query cell, it walks to a neighboring cell. If the view point motion is small, for most cases the algorithm traverses only a few cells. But consider the case, when the view point is very close to the center point CB for the BackRegion (as computed by Algorithm III), shown in Fig. 5. The initial position of the view point is shown as V in the i cell BQ (corresponding to the previous frame) and the 1 "nal position is V (corresponding to the current frame) f in the cell BQ . The traversal algorithm can visit O(m) 4 cells for a cluster with m Query cells for a small motion. To circumvent such problems, the algorithm constructs a maximal inscribed cone inside the BackRegion, around the center point CB (as shown in Fig. 5). (A similar inscribed cone is constructed for the FrontRegion.) If the view point was in BackRegion in the previous frame, the algorithm "rst tests whether the new location of the view point is inside the inscribed cone of BackRegion. Only if this test fails, does the algorithm start traversing the Query cells. As a result, whenever the view point is close to CB, the algorithm can trivially decide it
S. Kumar et al. / Computers & Graphics 23 (1999) 681}692
689
Fig. 6. View-point tracking (BackRegion Query cell boundaries are shown in light blue. Red colored polygon is on the decision plane for the cell containing the viewpoint in each case.)
is contained inside the BackRegion. A similar procedure is used if the view point was in FrontRegion at the previous frame. 6.2. Traversing in and out of MixedRegion When the view point moves into MixedRegion (from BackRegion or FrontRegion), the algorithm keeps track of two Query cells containing the view point (of the BQ i and FQ ). Assume that the view point was in BackRegion j at the previous frame and moves to the MixedRegion in the current frame. The traversal algorithm walks to a cell BQ . Let the bounding polygon of BQ correspond to BT . i i i BT has associated with it, the FQs it overlaps. The i algorithm starts with one of those cells, and tracks the view point down to the appropriate FQ . The algorithm j similar when the view point moves from FrontRegion to MixedRegion. When the view point moves into BackRegion (resp. FrontRegion) from MixedRegion, the algorithm stops tracking the query cell from FrontRegion (resp. BackRegion). 6.3. Space requirements In addition to the planes of the polygons, we must also store the three bounding planes for each query cell. Except the outside plane on the Query cells lying on the boundary of a cluster, each bounding plane is shared by two adjacent Query cells. Since there are only about Jm boundary cells in a cluster of size m, we store only
3 m#Jm equations for a cluster of size m. Further, not 2 all polygons of a cluster lie on the convex set that de"nes it. Thence m is much smaller than the number of polygons in the cluster. In practice, the extra information that we need to store less than doubles the database size.
7. Silhouette computation The silhouette of a polyhedral model consists of edges between two polygons that are front-facing and backfacing, respectively. Polygons with their normals at right angles to the direction of view are also on the silhouette. Thus, these are neither back-facing nor front-facing. Additionally, an edge between a front-facing and a backfacing polygon lies on the silhouette. Due to our method of computing the back-facing and front-facing polygons at the same time we are also able to compute the silhouette of the polyhedral models easily. In addition to maintaining the cluster data structure, we maintain the list of edges in a cluster that do not have all adjacent polygons in the same cluster. We call these boundary edges. Each boundary edge has a polygon adjacent to it that does not lie in the same cluster. We call that the matching polygon. (We assume consistent manifold topology.) If the matching polygon of a boundary edge lies in a cluster that is classi"ed di!erently from the cluster containing the edge, it is a silhouette edge. Unfortunately, a polygon lies in all clusters along a path in the cluster hierarchy. Hence to facilitate e$cient silhouette computation, we modify the earlier traversal as follows:
690
S. Kumar et al. / Computers & Graphics 23 (1999) 681}692
(1) With every polygon, store a pointer to its leaf cluster. (2) When a cluster is classi"ed as back-facing or frontfacing, mark all its children also with the same classi"cation. (3) For a leaf cluster that is marked to be in MixedRegion, perform the brute-force computation of polygon orientations and mark them accordingly. The silhouette "nder works as follows: f For each back-facing cluster, mark a boundary edge as silhouette if its matching polygon's leaf cluster is front facing. f If the corresponding leaf cluster is marked to be in MixedRegion, check if the polygon itself is front-facing, and if so mark the edge as silhouette. f For a leaf cluster in MixedRegion, test all edges and mark them as silhouettes, if two adjacent polygons are oriented di!erently.
8. Implementation and performance We employed a prototype implementation of the algorithms presented in this paper to speed up rendering of polyhedra models. We found that the extra space needed to store the Query cells approximately doubles the size of the polygonal database. The preprocessing time needed for their construction is small, for example less than 2 minutes for the bunny model. 8.1. Performance of the tracking algorithm The running time of the tracking algorithm is primarily a function of the motion of the view point between successive frames. It also depends inversely on the volume of the Query cells and sub-linearly on the size of the clusters. The graphs in Fig. 7, which correspond to an SGI Indigo2 Extreme, demonstrate this. Fig. 7(a) shows the average number of Query cells traversed at each
frame as a function of the cluster size. Fig. 7(b) plots the average tracking time (in microseconds) as a function of the view-point motion. As the angle increases, the tracking time increases only sub-linearly. When the rotation is large ('1203), the view-point oscillates between Back Region and FrontRegion in successive frames, producing the worst case behavior for the tracking algorithm. The typical tracking time for each cluster is 4}10 ls. 8.2. Number of clusters The overhead of the back-face computation is primarily determined by the number of clusters and is nearly independent of cluster size. Given an input model with N polygons, our goal is to divide it into Q clusters such that the overall performance is maximized. The choice of Q is governed by the following con#icting constraints: f The running time of the visibility algorithm increases linearly as a function of Q. f The average number of polygons per cluster is N/Q. A small value of Q would imply that fewer polygons are marked as back-facing or that the view-point is in the MixedRegion of more clusters. In the latter case, the tracking algorithm is applied recursively to each sub-cluster, which increases the overall running time. The optimum choice of Q is a function of the graphics system. This includes the polygon rendering performance as well as the CPU performance. If polygon rendering is the bottleneck, the clustering algorithm can use a large value of Q. On the other hand, if the CPU performance is the bottleneck, the algorithm should use a low value of Q. In general, computing an optimum value of Q is nontrivial. In our implementation, we have used the following heuristic to estimate a good value of Q. Given a graphics system and a model, we perform simple experiments to estimate the average tracking time per cluster, t, (e.g. 4}10 ls on a 250 MHz R4400 for the bunny) and the average CPU time available, ¹, for visibility
Fig. 7. (a) Number of Query cells vs. cluster size; (b) tracking time as a function of `motiona.
S. Kumar et al. / Computers & Graphics 23 (1999) 681}692
691
Table 1 Performance comparison Model
Sphere Bunny PLB
Platform
Indigo2, extreme graphics
d Polygons
Polygons culled
Frame-rate improved
Tracking overhead
Polygons culled
Frame-rate improved
Tracking overhead
2048 69 451 59 079
55.69% 47.23% 37.54%
41.91% 71.05% 48.59%
2.26% 5.77% 6.29%
55.69% 47.23% 37.50%
8.60% 59.68% 35.15%
6.63% 11.97% 13.27%
computation. For a degree Q hierarchy the algorithm typically tracks 2Q}4Q clusters and sub-clusters per frame. Thus a value of Q"¹/4t works well in practice. 8.3. Applications and speed-up Table 1 demonstrates the performance of our implementation for back-face culling in a rendering application. We used both an SGI Indigo2 Extreme (250 MHz R4400 with 128 MB memory) and an SGI Reality EngineII (200 MHz R4400 with 512 MB memory). The polygon rendering performance of the latter is about "ve times better than the former. We computed the average percentage of polygons culled in each frame, the additional overhead imposed on the CPU (by the hierarchical back-face culling algorithm), and the improvement in frame rate compared to using hardware back-face culling. The performance varies with the graphics systems and the models. Typically, the algorithm is able to classify 40}50% of the polygons as back-facing. Overall, we achieve a 30}70% rendering performance improvement compared to hardware backface culling, which compares well with the theoretical upper bound of 100% on the speedup. Furthermore, back-face and silhouette computation using our scheme achieves a four to "ve times speedup over a brute-force linear time computation.
9. Conclusion and future work In this paper, we have presented a simple algorithm for hierarchical back-face computation. It can be easily integrated with all applications that bene"t from back-face computation. We have applied the algorithm to render a number of models and are able to improve the frame rate by 30}70% in practice, with an additional overhead of approximately 10% on the CPU. This software backface computation method is 5}8 times faster than the standard method implemented in hardware. This enables the interactive rendering of larger models than otherwise possible on a given machine. Future work includes e$-
Onyx, reality engine
cient implementation of the algorithm on parallel systems as well as extension to dynamic environments. In addition, a general drawback of several geometric algorithms, robustness remains an issue with our system. Robust implementations of convex hull and halfspace intersections are necessary for utilization of our algorithm.
Acknowledgements We thank Anselmo Lastra and Steve Molnar for their helpful comments, and Greg Turk and Marc Levoy for the bunny model.
References [1] Foley J, VanDam A, Feiner S, Hughes J. Computer graphics principles and practice. Menlo Park, California: Addison-Wesley, 1993. [2] Crow FC. Shadow algorithms for computer graphics. ACM Computer Graphics 1977;11(3):242}8 (SIGGRAPH Proceedings). [3] Bouma W, Vanecek G. Velocity-based collision detection. In: Paeth A, editor. Graphics gems V. New York: Academic Press, 1995. p. 380}5. [4] Bern M, Dobkin D, Eppstein D, Grossman R. Visibility with a moving point of view. Algorithmica 1994;11:360}78. [5] Fuchs H, Kedem Z, Naylor B. On Visible Surface Generation by a Priority Tree Structure. In Proceedings of ACM SIGGRAPH, 1980. p. 124}33. [6] Sutherland I, Sproull R, Schumaker R. A Characterization of Ten Hidden-surface Algorithms. ACM Computing Surveys 1974;6(1):1}55. [7] Schumacker R, Brand B, Gilliland M, Sharp W. Study for applying computer-generated images to visual generation. Technical Report, AFHRL-TR-69-74, US Air Force Human Resources Lab, 1969. [8] Newell M, Newell R, Sancha T. A new solution to the hidden surface problem. Proceedings of ACM Annual Conference, 1972. p. 443}8. [9] Clark JH. Hierarchical geometric models for visible surface algorithms. Communications of the ACM 1976;19(10):547}54.
692
S. Kumar et al. / Computers & Graphics 23 (1999) 681}692
[10] Airey J, Rohlf J, Brooks F. Towards image realism with interactive update rates in complex virtual building environments. ACM Computer Graphics 1990;24(2):41}50 (In Symposium on Interactive 3D Graphics). [11] Teller SJ. Visibility computations in densely occluded polyhedral environments. PhD thesis, CS Division, UC Berkeley, 1992. [12] Greene N, Kass M, Miller G. Hierarchical Z-bu!er visibility. In Proceedings of ACM SIGGRAPH, 1993. p. 231}8. [13] Zhang H, Manocha D, Hudson T, Ho! K. Visibility culling using hierarchical occlusion maps. In Proceedings of ACM SIGGRAPH, 1997. p. 77}88. [14] Gigus Z, Canny J, Seidel R. E$ciently computing and representing aspect graphs of polyhedral objects. IEEE Transactions on Pattern Analysis and Machine Intelligence 1991;13(6):542}51. [15] Coorg S, Teller S. Temporally coherent conservative visibility. In Proceedings of 12th Annual ACM Symposium on Computational Geometry, 1996. p. 78}87. [16] Durand F, Drettakis G, Puech C. The visibility skeleton: a powerful and e$cient multi-purpose global visibility tool. In Proceedings of ACM SIGGRAPH, 1997. p. 89}100.
[17] Kumar S, Manocha D. Hierarchical visibility culling for spline models. In Proceedings of Graphics Interface, Toronto, Canada, 1996. p. 142}50. [18] Shirman LA, Abi-Ezzi SS. The cone of normals technique for fast processing of curved patches. In EUROGRAPHICS, 1993. p. 261}72. [19] Tanimoto SL. A graph-theoretic real-time visible surface editing technique. In Proceedings of ACM SIGGRAPH, 1977. p. 223-8. [20] Preparata FP, Shamos MI. Computational geometry. New York: Springer, 1985. [21] Barber B, Dobkin D, Huhdanpaa H. The quickhull algorithm for convex hull. Technical Report GCG53, The Geometry Center, MN, 1993. [22] Seidel R. Linear programming and convex hulls made easy. In Proceedings of 6th Annual ACM Conference on Computational Geometry, Berkeley, California, 1990. p. 211}5. [23] Dobkin DP, Kirkpatrick DG. Fast detection of polyhedral intersection. In: . Proceedings of 9th International Colloquim Automata Lang. Program., Lecture Notes in Computer Science, vol. 140. Berlin: Springer, 1982. p. 154}65. [24] Durand F, Puech C. The visibility complex made visibly simple. In Proceedings of 11th Annual ACM Symposium Computational Geometry, 1995. p. V2.