surface distance maps - gamma unc

8
Surface Distance Maps Avneesh Sud Naga Govindaraju Russell Gayle Erik Andersen Dinesh Manocha Dept of Computer Science, University of North Carolina at Chapel Hill http://gamma.cs.unc.edu/gvd/sdm Figure 1: Interactive motion planning of hundreds of agents for crowd simulation: We use our novel surface distance map computation algorithm for interactive path computation and collision detection in a dynamic environment: (left and center) Two views of the environment with dynamic 3D obstacles, including cars and flying drones. Each human agent is represented as a cylinder and colored based on its goal. (right) The nearest neighbor map of the obstacles and agents is computed using surface distance maps. Each colored region is closer to one of the 3D obstacles than to any other. The path for one of the agents is shown using solid black lines. Our algorithm can perform the simulation, including distance computations and path planning, for 100 agents at 10fps on a high-end PC. ABSTRACT We present a new parameterized representation called surface dis- tance maps for distance computations on piecewise 2-manifold primitives. Given a set of orientable 2-manifold primitives, the surface distance map represents the (non-zero) signed distance-to- closest-primitive mapping at each point on a 2-manifold. The dis- tance mapping is computed from each primitive to the set of re- maining primitives. We present an interactive algorithm for com- puting the surface distance map of triangulated meshes using graph- ics hardware. We precompute a surface parameterization and use the it to define an affine transformation for each mesh primitive. Our algorithm efficiently computes the distance field by applying this affine transformation to the distance functions of the primitives and evaluating these functions using texture mapping hardware. In practice, our algorithm can compute very high resolution surface distance maps at interactive rates and provides tight error bounds on their accuracy. We use surface distance maps for path planning and proximity query computation among complex models in dynamic environments. Our approach can perform planning and proximity queries in a dynamic environment with hundreds of objects at inter- active rates and offer significant speedups over prior algorithms. CR Categories: I.3.5 [Computing Methodologies]: Compu- tational Geometry and Object Modeling—Geometric algorithms; I.3.7 [Computing Methodologies]: Three-Dimensional Graphics and Realism—Animation, virtual reality Keywords: distance fields, parameterization, deformable models, collision detection, motion planning 1 I NTRODUCTION Distance fields are scalar fields that represent the closest distances. Given a set of primitives S in R 3 , the distance field at a point equals the distance to the closest point on S . Distance fields are widely studied in computer graphics, computational geometry, computer vision and robotics. They are used for several applications includ- ing shape representation and sculpting [15], skeleton computation [2], collision and proximity computations [32], remeshing [21], motion planning [18], implicit surface representation [16], non- photorealistic rendering [20], etc. Most of the prior techniques compute the distance field along a vol- umetric grid or a voxelized representation of space. At a broad level, these algorithms can be classified into object space methods that perform direct scan conversion into 3D voxels or image space methods that compute the closest primitive at each grid point. The latter methods can be accelerated by rasterizing the distance func- tions using the graphics hardware [19, 31, 30, 12]. These algo- rithms compute the distance field along each slice of a 3D grid and the computation can be accelerated by using spatial bounds on the Voronoi regions of the primitives [31, 27]. However, many appli- cations require distance information on the surface boundary of a mesh. The existing volumetric techniques are inefficient for such computations due to high storage overhead and computation cost. Moreover, their accuracy can be low as most of the grid vertices do not exactly lie on the mesh surface. In this paper, we consider the problem of computing the distance map on triangulated meshes in R 3 . Given a set of 2-manifold prim- itives S , the surface distance map at each point on a primitive o represents the (non-zero) distance-to-closest-primitive from the set

Upload: others

Post on 03-Feb-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Surface Distance Maps - GAMMA UNC

Surface Distance Maps

Avneesh Sud Naga Govindaraju Russell Gayle Erik Andersen Dinesh Manocha

Dept of Computer Science, University of North Carolina at Chapel Hillhttp://gamma.cs.unc.edu/gvd/sdm

Figure 1: Interactive motion planning of hundreds of agents for crowd simulation: Weuse our novel surface distance map computationalgorithm for interactive path computation and collision detection in a dynamic environment:(left and center) Two views of the environmentwith dynamic 3D obstacles, including cars and flying drones. Each humanagent is represented as a cylinder and colored based on its goal.(right) The nearest neighbor map of the obstacles and agents is computed using surface distance maps. Each colored region is closer to one ofthe 3D obstacles than to any other. The path for one of the agents is shown using solid black lines. Our algorithm can perform the simulation,including distance computations and path planning, for100 agents at10fps on a high-end PC.

ABSTRACT

We present a new parameterized representation called surface dis-tance maps for distance computations on piecewise 2-manifoldprimitives. Given a set of orientable 2-manifold primitives, thesurface distance maprepresents the (non-zero) signed distance-to-closest-primitive mapping at each point on a 2-manifold. The dis-tance mapping is computed from each primitive to the set of re-maining primitives. We present an interactive algorithm for com-puting the surface distance map of triangulated meshes using graph-ics hardware. We precompute a surface parameterization and usethe it to define an affine transformation for each mesh primitive.Our algorithm efficiently computes the distance field by applyingthis affine transformation to the distance functions of the primitivesand evaluating these functions using texture mapping hardware. Inpractice, our algorithm can compute very high resolution surfacedistance maps at interactive rates and provides tight error bounds ontheir accuracy. We use surface distance maps for path planning andproximity query computation among complex models in dynamicenvironments. Our approach can perform planning and proximityqueries in a dynamic environment with hundreds of objects at inter-active rates and offer significant speedups over prior algorithms.

CR Categories: I.3.5 [Computing Methodologies]: Compu-tational Geometry and Object Modeling—Geometric algorithms;I.3.7 [Computing Methodologies]: Three-Dimensional Graphicsand Realism—Animation, virtual reality

Keywords: distance fields, parameterization, deformable models,

collision detection, motion planning

1 INTRODUCTION

Distance fields are scalar fields that represent the closest distances.Given a set of primitivesS in R

3, the distance field at a point equalsthe distance to the closest point onS. Distance fields are widelystudied in computer graphics, computational geometry, computervision and robotics. They are used for several applications includ-ing shape representation and sculpting [15], skeleton computation[2], collision and proximity computations [32], remeshing [21],motion planning [18], implicit surface representation [16], non-photorealistic rendering [20], etc.

Most of the prior techniques compute the distance field along a vol-umetric grid or a voxelized representation of space. At a broadlevel, these algorithms can be classified into object space methodsthat perform direct scan conversion into 3D voxels or image spacemethods that compute the closest primitive at each grid point. Thelatter methods can be accelerated by rasterizing the distance func-tions using the graphics hardware [19, 31, 30, 12]. These algo-rithms compute the distance field along each slice of a 3D grid andthe computation can be accelerated by using spatial bounds on theVoronoi regions of the primitives [31, 27]. However, many appli-cations require distance information on the surface boundary of amesh. The existing volumetric techniques are inefficient for suchcomputations due to high storage overhead and computation cost.Moreover, their accuracy can be low as most of the grid vertices donot exactly lie on the mesh surface.

In this paper, we consider the problem of computing the distancemap on triangulated meshes inR

3. Given a set of 2-manifold prim-itives S, the surface distance mapat each point on a primitiveorepresents the (non-zero) distance-to-closest-primitive from the set

Page 2: Surface Distance Maps - GAMMA UNC

S \ {o}. The distance function varies continuously along the sur-face and the distance map yields the direction vector to the closestprimitive. As the surface distance map encodes closest primitivemapping, it also provides the Voronoi diagram at each point on the2-manifold primitives, or thenearest neighbor mapon the bound-ary. If the primitivesS are orientable, we can also associate a signwith the distance map.

Main Results: We present a new algorithm to compute sur-face distance maps of triangulated models. Our algorithm usesa simple texture representation and precomputes a piecewise pla-nar parametrization of each mesh. The parameterization definesan affine transformation for each primitive of a mesh to the plane.The 2D texture map is used as a discrete sampling of the meshfor distance map computation. As a result, the resolution of dis-tance map is limited by the size of the texture memory. We applythe affine transformations to compute the distance functions of 3Dprimitives using the texture mapping hardware. This formulationis also used to compute thenearest-neighbor mapin terms of firstorder and second order Voronoi diagrams of the primitives. Finally,we present tight error bounds on the discretization error in surfacedistance map and nearest neighbor map computation.

We highlight two interactive applications of surface distance mapsand nearest-neighbor maps computed on the surfaces.

1. Motion planning in dynamic environments: We use thenearest-neighbor maps to compute a collision free path forrobots or multiple agents moving in a dynamic environments.We update the position of all the robots and compute the sur-face distance map. We use our planner to compute collisionfree path for human agents in a crowd simulation.

2. Proximity queries between deformable models:The sur-face distance map is used for collision and proximity queriesbetween multiple deformable 3D models. We use the errorbounds to perform conservative computation and the result-ing algorithm has object-space precision.

We have implemented our algorithm to compute the surface dis-tance map on a3GHz Pentium D PC with an NVIDIA GeForce7900 GTX GPU. We highlight its performance on complex bench-marks composed of thousands of triangles. In practice, our algo-rithm is able to compute512 × 512 distance fields on triangulatedmeshes in a few hundred milli-seconds. The distance values arecomputed on a floating point buffer using32-bit floating point pre-cision. We apply our surface distance map computation algorithmto perform proximity queries among deformable models consistingof 6K primitives in200ms. We use the nearest-neighbor map com-putation for interactive motion planning of100 agents in a complexenvironment at10 fps.

As compared to prior distance field based approaches, our algo-rithm offers the following advantages:

• Generality: Our algorithm is applicable to all triangulatedmodels. The only requirement is the computation of the piece-wise affine parameterization of the mesh.

• Accuracy: We can compute very high resolution distancemaps, e.g.1K × 1K at 32-bit floating point precision. Onthe other hand, previous interactive techniques based on volu-metric approaches are typically restricted to lower resolution(643 or 1283) distance fields.

• Performance: Our algorithm can compute surface distancefields of deformable models with thousands of polygons atinteractive rates. We observe5−10 times speedup in the per-formance of resulting proximity queries and motion planningalgorithms over prior approaches.

Organization: The rest of the paper is organized as follows. Webriefly survey prior work on distance field computation and surfacemapping in Section 2. Section 3 describes our algorithm to computedistance maps for two-manifolds and we present a number of tech-niques to improve its performance in Section 4. We analyze ouralgorithm in Section 5 and highlight its performance on differentapplications in Section 6.

2 RELATED WORK

In this section, we give a brief overview of related work on distancefields and surface mappings.

2.1 Distance Fields

Algorithms to compute distance fields are widely studied. At abroad level, these algorithms can be broadly classified based on themodel representations such as images, volumes or polygonal repre-sentations. Good surveys of these algorithms are given in [8, 1].

The algorithms for image-based data sets perform exact or approx-imate computations in a local neighborhood of the voxels [9, 29, 4,25, 17]. Exact algorithms for handling 2-D and k-D images havebeen proposed to compute the distance transforms in voxel data inO(M) time, whereM is the number of voxels [4, 25].

Many object-space methods based on adaptive subdivision areknown for computing approximate Voronoi diagrams of polygonalmodels [35, 34, 11, 28]. These algorithms can be used to computedistance fields and are limited to static models. The computation ofa discrete Voronoi diagram on a uniform grid can be performed ef-ficiently using graphics rasterization hardware [36, 19, 10, 31, 12].These algorithms compute 3D distance fields along a uniform grid,and can compute them interactively for low resolution grids on cur-rent GPUs.

A class of exact distance computation and collision detection algo-rithms based on external Voronoi diagrams are described in [23].A scan-conversion method to compute the3-D Euclidean distancefield in a narrow band around manifold triangle meshes (CSC al-gorithm) is presented by Mauch [24]. The CSC algorithm uses theconnectivity of the mesh to compute polyhedral bounding volumesfor the Voronoi cells. The distance function for each site is evalu-ated only for the voxels lying inside this polyhedral bounding vol-ume. Sigg et al. [30] describe an efficient GPU based implementa-tion of the CSC algorithm. Peikert and Sigg [27] present algorithmsto compute optimized bounding polyhedra of the Voronoi cell forGPU-based distance computation algorithms. Lefohn et al. [22] de-scribe an algorithm for interactive deformation and visualization oflevel set surfaces using graphics hardware.

2.2 Surface Mapping

Surface distance maps can be regarded as amappingcomputed onthe surface. In some ways, this problem is related to other surfacemapping problems such as texture mapping [5], which is used todefine the color on the surface; displacement mapping [7], whichconsists of perturbations of the surface positions; bump mapping[3], which give perturbations to the surface normals; and normalmaps [14], which contains the actual normals instead of the per-turbations. All these mapping are supported by current graphicshardware.

3 SURFACE DISTANCE M APS

In this section, we present our notation and definitions used in thepaper. We introduce surface distance maps and list some of their

Page 3: Surface Distance Maps - GAMMA UNC

properties.

3.1 Notation and Definitions

Let S = {o1, . . . , on} denote the set ofn piecewise linear 2-manifold objects or meshes in 3D. Furthermore, each objectoi isdecomposed into vertices, open edges and open faces, also knownassites. A site is denoted aspi. Let Ti ⊂ R

2 represent the 2Dparametric domain for objectoi. The mapping of a primitive to the2D domainT is represented with an overline. Vectors and matricesare represented using boldface. For example, a pointq and trianglet in 3D map toq andt, respectively, onT.

O1

q

p

t

O2

q

M

q

t

q

Figure 2: Affine map and surface distance map computation:Theaffine mapM maps the trianglet on objecto1 to the trianglet indomainT. The distance vectors fromt to a point sitep on objecto2 are computed at the vertices oft. Then the distance vector ofa pointq on the trianglet is a convex combination of the distancevectors at the vertices.

The Euclidean distance function of a sitepi at a pointq ∈ R3 is

denotedd (q, pi). The closest vector fromq to pi is known as thedistance vector, denoted~d(q, pi). The distance of a pointq to anobjectoi is the minimum distanced (q, pj) for all sitespj in oi.

The surface distance map, D() : S → R, at a pointq on objectoi is defined as the distance to the closest object (excluding itself).The surface distance map is closely related to the nearest neighbormap on the surface, denotedN () : S → S, and is defined as theclosest object (excludingoi) at the pointq. Formally,

D(q|S) = minj 6=i

(d (q, oj)),q ∈ oi, oj ∈ S

N (q|S) = {oj | d (q, oj) = D(q)}

For ease of notation, when the surface distance map and the near-est neighbor maps are computed with respect to all the objects, wedo not explicitly denoteS, i.e. D(q) = D(q|S) andN (q) =N (q|S). For a set of points, the surface distance map provides thedistance field to closest objects (excluding itself).

The nearest neighbor map on the surface is closely related to theEuclidean Voronoi diagram in 3D. Assuming each objectoi to be aVoronoi site, letVDk(S) denote the k-th order Euclidean Voronoidiagram of the set of objects, andGovk(q,S) denote the k-th ordergovernor set of a pointq. The k-th order governor set of a pointq

is the set ofk closest sites atq. (see [26] for standard definitions).Then, the following result relates the nearest neighbor map on thesurface and the 3D Voronoi diagram.Lemma 1. Letq ∈ oi. Then (a)Gov1(q,S \ {oi}) = N (q), and(b) Gov2(q,S) = {oi,N (q)}.

Lemma 1 implies that the nearest neighbor map on the surface ofoi is given by the intersection ofoi with the 1st order Voronoi di-agramVD1(S \ {oi}), or equivalently with the 2nd order VoronoidiagramVD2(S). Later, we use these properties in order to usesurface distance fields for interactive motion planning and proxim-ity computations.

3.2 Surface Parameterization

We define an affine mappingMi,1 : ti → T1 to transform thesampled points on the trianglesti ono1 into the 2D domainT1. Forease of notation, when the object idj is implicit (j = 1 in this case),we shall drop the object id subscript fromMi,j and denote the affinemap asMi. Given a 3D mesho with trianglestk, k = 1, . . . , n, ouralgorithm transforms each triangletk into a triangletk by applyingan affine mappingMk (see Fig. 2). The matrixMk is constructedto satisfy the following constraints:

• There is a one-to-one mapping from a pointq ∈ tk to thepointMkq ∈ tk.

• No two transformed trianglestk = Mktk and tl = Mltl

share a common interior point in the 2D domainT.

These constraints are satisfied using piece-wise planar parameter-izations of the surface in 3D space and the mapped triangles canbe represented in a 2D texture atlas. SinceM is affine, it can bewritten as a composition of a scale, shear, translation and rotationmatrices.

3.3 Linear Interpolation

In this section, we show that the surface distance field at a pointin the triangle can be represented as linear interpolant of distancevectors of the vertices of that triangle. We shall present this propertyfor point, infinite lines and planes, and then extend it to finite edgesand triangles. Given a triangletk ∈ oi with verticesxa, a = 1, 2, 3,for a given point, infinite line or plane sitepl on objectoj (j 6= i),we use the linear interpolation property of distance vectors [31] toexpress the distance vector at any point on triangletk to sitepl as aconvex combination of the distance vectors at the verticesxa:

~d(q, pl) =3

Σa=1

βa~d(xa, pl),q ∈ tk,

3

Σa=1

βa = 1, βa ≥ 0 (1)

Given thattk = Mktk, it impliesD(tk) = D(Mktk). Since theconvex combination is invariant under affine transformMk, fromequation (1) we have,

⇒ ~d(q, pl) = ~d(q, pl) =3

Σa=1

βa~d(xa, pl),q = Mkq (2)

Thus the distance vector at a pointq ∈ tk (in objectoi) is computedby performing linear interpolation of distance vectors on the 2DdomainT, as shown in equation (2). Thus the surface distance mapat pointq is computed as the minimum of the length of distancevectors,

D(q) = D(Mkq) = min(d (q, pl)), ∀pl ∈ oj , j 6= i

We now extend the linear interpolation property to finite sites (edge,triangle). For a finite site, the linear interpolation is valid inside aconvex region defined by the boundary of the site [31].

4 INTERACTIVE DISTANCE M AP COMPUTATION

In this section, we present our algorithm to efficiently compute sur-face distance maps. We make use of the bilinear formulation ofdistance computation and evaluate it efficiently using GPUs. Wealso describe many techniques to accelerate the computation.

Page 4: Surface Distance Maps - GAMMA UNC

4.1 GPU Based Computation

We compute a discrete approximation of surface distance mapsat interactive rates using bilinear vertex attribute interpolators ingraphis hardware (for eg. texture coordinate interpolation). Dis-crete surface distance maps compute the distance-to-closest-objectmapping at a finite set of point samples on each 2-manifold mesh.

We first compute the affine mappings,Mk for each triangletk inthe 3D mesh. We sample the domainT uniformly using a 2D tex-ture. This defines a sampling on each triangletk in 3D space bysampling the projected triangletk in the 2D domainT. Instead ofcomputing distances along a volumetric grid, our algorithm com-putes the distance map on each triangletk by computing the dis-tance vectors at the vertices oftk and computing the distance vec-tors at the point samples ontk using equation (2).

In order to accelerate distance computations, prior algorithms con-struct a convex polytopeGi which bounds the Voronoi region of asite pi and reduces the fill requirements [31, 27]. We use similartechniques to accelerate the computation of surface distance maps.For each sitepi, we compute a convex bounding polytopeGi. Tocompute the surface distance maps on triangletk, we intersectGi

with the triangletk in the 3D mesh. The distance vector computa-tions are performed in the texture domainT only for the points thatlie inside the transformed domainMk(tk ∩Gi).

Surface distance maps can be computed on the rasterization hard-ware by using transformations, clipping and interpolation capabili-ties of the GPUs. The main stages of the pipeline are as follows:

• Bound Computation and Intersection: We compute thebounding polytopeGi of sitepi, and intersect it with the planeπk containing triangletk on the CPU. This gives a convexpolygongi = Gi ∩ πk.

• Distance Vector Computation and Transform: We com-pute the distance vectors at each vertex ofgi and project thevertices ofgi to the 2D domainT using the affine mapMk.This per vertex computation is efficiently performed in paral-lel using thevertex processoron the GPU.

• Clipping: We restrict the computation of distance vectors tothe domain given bytk ∩ gi. In the 2D domainT, this isequivalent to clipping the projectiongi againsttk. We use thestencil functionality of GPUs to perform this clipping.

• Bilinear Interpolation: The convex combination of distancevectors is equivalent to linear interpolation of texture co-ordinates assigned to the vertices of the polygongi, and isperformed by thetexture unitof the GPU.

• Distance Computation: The distance value at a texel in thetexture atlas is the norm of the distance vector and computedusing thefragment processorof the GPU.

• Distance Comparison: The distance value is returned asdepth and compared with the current minimum distance valueusing the depth test functionality in theraster processorofGPUs. The minimum distance value is stored in the depthbuffer.

The overall algorithm to compute the surface distance map of ob-ject o1 using sites in a set of objectsS is given in Algorithm 1.The algorithm requires computing of intersections between bound-ing polytopes of sites and the triangles in the 3D mesh, and clippingof polygons in 2D. We present details of stencil-based clipping andhierarchical culling techniques that are used to accelerate the per-formance of the algorithm.

Clipping: Surface distance maps require an efficient clipping al-gorithm for each triangle-site pair. Given a sitepi and a triangletk, we restrict the computation on the 2D domain to the interior oftk using stencil tests. As a result, each triangle-site pair requires avalid stencil to be set in the region corresponding totk. We firstset the stencil value of the triangle to1 by renderingtk on T. Wethen compute the distance vectors by renderinggi onto the portionsof the surface distance map where the stencil value is set to1. Wethen reset the stencil values by renderingtk and setting the sten-cil value to0 on the triangle. For a set of triangles, we reduce thestate change overhead by associating a unique stencil id with eachtriangle. Since the stencil buffer is limited to 8 bit precision, weuse a buffer that maintains a set of available stencil ids, which arereplaced using a least-recently-used replacement policy.

Input : Objecto1, Set of objectsS. Parameterization fromo1 to T1.

Output : The Surface Distance MapD(o1) of objecto1.

Initialize D(o1) to∞ for all pointsq in T11Update AABB hierarchy ofo12foreach triangle tk in o1 do Mk,1 ← UpdateAffine(tk)3foreachobjectoa in S contributing to SDM ofo1 do4

foreachsitepi in oa do5OBB(Gi)← ComputeOBB (pi)6Intersect OBB(Gi) against AABB hierarchy ofo17foreach triangle tk in o1 intersectingGi do8

gi ← IntersectPolytope(Gi, tk)9foreachvertexxj in gi do10

Compute distance vector~d(xj , pi)11Transformxj to xj usingMk,112Assign texture coordinates ofxj ,13

(r, s, t)← ~d(xj , pi)

end14Draw textured polygongi on domainT115

end16

end17

end18Read-backT119foreach triangle tk in T1 do20

Map distance values fromtk to tk21

end22

Algorithm 1 : Pseudo-code to compute the surface distancemap ofo1 using sites inS. Line 1 initializes the depth val-ues in the texture atlas for the triangles ino1. We computethe affine transform for each triangle ino1 (Line 3). Wefirst perform a broad-phase culling to compute objects thatcontribute to SDM ofo1. For each site in these objects,we compute the potentially overlapping triangles ino1 withthe distance function of sitepi (Lines 6-8). We then clip thebounding polytope enclosing the distance function ofpi tothe overlapping triangles ino1 (Line 9). Each clipped poly-gon corresponds to a triangle ino1 and we map the clippedpolygons onto the texture atlas using the affine transforma-tions of the corresponding triangles (Lines 10-15).

4.2 Hierarchical Culling

We use a hierarchical distance culling algorithm to reduce the num-ber of triangle-site pairs in the surface distance map computation.The distance functions are computed from a sitepi to a triangletk

in 3D mesh only when the intersection of the bounding polytopewith the triangle is non empty (i.e.Gi ∩ tk 6= ∅). We use an axis-aligned bounding box (AABB)-hierarchy of each object to quickly

Page 5: Surface Distance Maps - GAMMA UNC

Figure 3: Surface Distance map computation on deforming letters ”3d2007i”:Deforming dynamic simulation on7 letters falling on anuneven terrain, (6K triangles total). (a)-(b) Two frames from the simulation. (c) The surface distance maps between two letters show thedirection of the closest point on the other letter. Our algorithm can perform proximity queries using high resolution surface distance maps ofresolution512× 512 in 100− 200 ms per frame.

cull away sites whose bounding polytopes do not overlap with thetriangles in the 3D mesh.

Our algorithm initially constructs an AABB hierarchy for eachobject. Each leaf of the hierarchy stores a triangle of the ob-ject. At run-time, we update the AABB-hierarchy and use it forculling bounding polytopes that do not intersect with the AABB-hierarchy. The hierarchy nodes are updated in a bottom-up manner.The update cost of a hierarchy is linear in the number of leavesin the AABB-hierarchy. For each sitepi, we compute a bound-ing polytopeGi and compute a tight-fitting oriented bounding boxOBB(Gi) that enclosesGi. We perform overlap tests betweenOBB(Gi) and the nodes of the AABB hierarchy. For each leafwith triangletk that overlaps withOBB(Gi), we perform distancecomputations onGi ∩ tk as described in Section 4. The OBBs areconstructed only once per frame for each site, and therefore, thetime taken to update the OBBs is linear in the number of sites in thescene. The AABB hierarchy and OBBs are updated each frame fordeforming models.

We further improve the performance of our surface distance map al-gorithm by reducing the number of distance function rasterizationoperations using distance bounds computed using the AABB hier-archy. For each node in the AABB hierarchy, we maintain a lowerbound on the maximum distance from the AABB of a triangletk

to the AABB of the sites. Initially, the maximum distance bound ofeach node in the hierarchy is set to∞. We do not perform distanceevaluation of a sitepi for triangletk if the distance bound stored fora node in the hierarchy is less than the minimum distance from theAABB of the node to the AABB ofpi. This culling test based ondistance bounds is used to reject sites whose distance functions donot contribute to the distance map ontk, as there exists some othersites that are closer toTk.

If a site is not culled away, we intersect the bounding polytopeGi

of the site withtk and compute the distance vectors at the verticesof Gi ∩ tk. We then perform distance function computation onGi ∩ tk.

5 ANALYSIS

In this section, we analyze the time complexity of our algorithm.We also derive error bounds on the distance computation as a func-tion of 2D grid resolution in the parametric domain.

Time Complexity: Let there bem sites in each object. The costof performing hierarchical culling isO(m log m). The rasterizationcost of computing the surface distance map of resolutionM×M isO(rM2), where1 ≤ r ≤ m. The value ofr depends on the culling

efficiency achieved by our hierarchical culling algorithm and is typ-ically close to1, especially when we perform distance computationsin a localized region or narrow bands. Hence the total computa-tion cost of computing the surface distance map for each object isO(rM2 + m log m).

Error Bounds: Our algorithm, described in Section 4, computesa discrete surface distance map at the sample points on the mesh.The accuracy at these samples is governed by the precision of thetexture mapping hardware that performs bilinear interpolation. Cur-rent GPUs offer32-bit floating arithmetic to perform these compu-tations. We also present an error bound on the computed distancefor any point on the surface, as the object undergoes non-rigid affinetransformations, including scaling and shearing. Given a samplingon the parametric domain, we first derive a function that computesthe sampling density on the surface in 3D using the inverse of theaffine map. The 3D sampling density is used to compute discretiza-tion error bounds on the surface distance map.

The affine transform for each triangle can be decomposed into acombination of scale, shear, translation and rotation transforms.The distances are preserved under rigid transformations. In thiscase, scaling and shear transforms change the distance values be-tween adjacent samples. Next, we present a lemma that relates thesample density on the parametric domain with that on the 3D mesh.Lemma 2. Let the affine transformMk map triangletk on objecto to triangletk in texture domainT. Letsx, sy andsh, respectively,be the scale alongX-axis, scale alongY -axis and shear inducedby the inverseM−1

k . Further, let the base length of the triangletk

be b and spacing between adjacent samples inT be δ. Then themaximum distance between two adjacent samples ontk is given by

fk(δ) ≤ δ

q

(sx + dx)2 + s2y (3)

wheredx = max(|sh| − ( bsxδ

+ 1), 0).

It has been shown that the error introduced by a distance distancefield is bounded by the sample density [32]. Hence from Lemma 2,the maximum error in the continuous surface distance map com-puted on objecto is given bye(δ) = maxk(fk(δ)), for all trian-glestk ∈ o. Furthermore, it follows from equation (3) asδ → 0,dx → 0, and the maximum error,e(δ)→ 0 as expected.

Moreover, the error in the surface distance map is bounded as theobjecto undergoes bounded deformations. We assume the initialmappingMk has unit scale and zero shear. Then, we can derive theerror bound as the object undergoes deformations by the followinglemma:Lemma 3. Let the maximum motion of a vertex on triangletk,modulo any rigid body transformation, be bounded bydm, and the

Page 6: Surface Distance Maps - GAMMA UNC

base and height of triangletk on domainT beb andh, respectively.Then the discretization error in surface distance map is bounded by

g(δ) ≤ 2dmδ + max

»

dm −h

2

b

δ+ 1

«

, 0

Surface Distance Map Resolution: By definition, the transformMk is always invertible. Conversely, one can also use the inverse ofthe function to compute the sampling required in the texture domainto achieve a desired precision in the computed surface distance map.In particular, letem denote the maximum error in the surface dis-tance map. Then the sampling densityδ on the texture domainT isgiven bymink(f−1

k (em)), for all tk ∈ o, wheref−1

k x is given bythe scale and shear transforms ofMk. The resolution of the textureused to sampleT is M ×M , whereM = 1

δ. We use these error

bounds to perform proximity computations at object-space preci-sion in Section 6.2

6 IMPLEMENTATION AND PERFORMANCE

In this section we briefly describe our implementation of surfacedistance map computation and highlight its application to motionplanning and proximity computations between deformable models.We also compare our algorithm with prior distance field computa-tion algorithms.

6.1 Implementation

We have implemented our algorithm on a PC with a3.0GHz Pen-tium D CPU,2GB of memory and an NVIDIA7900 GTX GPUconnected via a PCI-Express bus, running Windows XP operatingsystem. We used OpenGL as the graphics API and the Cg program-ming language to implement the fragment programs. The initialmapping from the manifold objects to the texture atlas is computedusing NVIDIA’s Melody 1 software. The surface distance map ofeach object is computed on a floating point buffer using 32-bit float-ing point precision. The distance vectors are passed as texture pa-rameters to the fragment program.

Our algorithm can compute high-resolution (512×512 to1K×1K)surface distance map of objects with tens of thousands of polygonsin a fraction of a second. We also compute the gradient of the dis-tance field which gives the direction to the closest primitive for apoint on the surface of an object. As compared to prior approachesbased on volumetric techniques, our surface distance map compu-tation algorithm is about4− 10 times faster.

6.2 Comparison with Prior Distance Field Computation Algo-rithms

We compare the features and performance of our surface distancemap algorithm with prior approaches that compute the distance fieldon a uniform volumetric grid using GPUs. These include linearfactorization [31] and efficient GPU implementations of CSC algo-rithm [30, 27]. All the prior approaches compute the distance fieldalong a uniform 3D grid. Since the GPU computes the distance fieldalong one slice, these algorithm perform the computations alongdifferent slices and exploit spatial coherence between the slices tospeed up the computation.

The precision of the distance field computed using a volumetric ap-proach is governed by the cell size in the grid. Let the number ofcells in the grid beM ×M ×M , and storage overhead isO(M3).

1http://developer.nvidia.com/object/melodyhome.html

0

100

200

300

400

500

600

700

800

1 101 201 301 401 501

Frame Number

Tim

e (

ms)

DVD

SDM

Figure 4: Timing comparison for proximity computation betweenour algorithm (labeledSDM) and a GPU-based volumetric distancefield algorithm [Sud et al. 06b] (labeledDVD), respectively:Ouralgorithm is able to achieve 5–10 times speedup in proximity com-putation between two deforming alphabets. The scene is composedof 6K polygons. The surface distance field is computed at a reso-lution of 512 × 512 and the volumetric distance field is computedat 250 × 42 × 250. Our algorithm is able to obtain higher accu-racy in distance field computation on the surface and achieves aninteractive performance of 5–10 frames per second.

Then the discretization error in the distance field is√

3

2M. In compar-

ison, for a surface distance map of sizeM ×M , the storage costis O(M2), and the error in the distance field is

√2

2Min absence of

any scale and shear. As the model undergoes deformation, the er-ror bound for surface distance map is given by the functionf( 1

M),

presented in Section 5. Typically, the maximum amount of defor-mationdm in interactive applications is small, and the error in thedistance field is given asO( 1

M). As a result, surface distance maps

provide a more compact representation of the distance field withtighter error bounds. Conversely, our approach results in higherresolution distance fields. Current GPUs have512MB or 1GB ofvideo memory. It may not be possible to store or compute a volu-metric distance field at a high resolution (e.g.(1K)3) as it wouldrequire8GB of memory. Furthermore, the cost of reading back a3D distance field of(1K)3 and scanning could be rather high, i.e.about16 seconds using a readback bandwidth of500MB/sec. As aresult, prior applications of interactive distance field computationsare limited to low resolution distance fields. On the other hand, wecan compute surface distance maps at high resolution on currentGPUs.

Let there bem sites in each object. Then the computation costto compute the global distance field using a volumetric approachvaries betweenO(mM3) andO(M3). Fornarrow bands, the costis O(m + rM3) wherer depends on the relative configuration ofsites. On the other hand, the cost of computing the global sur-face distance map on the GPU isO(rM2 + m log m). Fornarrowbands, the cost is close toO(M2 + m log m). A quantitative com-parison of average time to compute the distance fields and performproximity queries on deformable models is shown in Figure 4.

6.3 Proximity Queries between Deformable Models

We use surface distance maps and nearest-neighbor maps to per-form different proximity queries among 3D deformable models.The set of queries include separation distance, collision detection,contact normal and local penetration depth computation. As shownin Lemma 1, the nearest neighbor map also provides the 2nd-ordergovernor set, and we use the algorithm presented in [32]. Wefirst use AABB hierarchies to localize the computation by com-puting the region of overlap or compute a potentially neighboring

Page 7: Surface Distance Maps - GAMMA UNC

set (PNS) for the primitives. Next, we compute the surface distancemap for all triangles of each object that lie inside the localized re-gion or the PNS. We use the error bounds on distance fields, pre-sented in Section 5, to perform conservative computations and re-duce the size of PNS based on properties of nearest-neighbor maps.Finally, we perform exact collision, distance or penetration queriesbetween the primitives lying in the PNS.

We used our algorithm for proximity queries on a scenarios con-sisting of deforming objects. The first is a sequence of7 deformingalphabets falling on a bumpy terrain as shown in figure 3. The let-ters are at different scales allowing us to vary resolution of surfacedistance map. The entire environment consists of6K polygons. Ateach frame, we compute a surface distance map on each letter at aresolution512 × 512. The average time to perform all proximityqueries varies between100 − 200ms. As compared to [32], oursurface distance algorithm results in a speedup of8 times. Sincewe are computing the distance map at a much higher resolution, theimage-space error using our algorithm is much lower as comparedto prior approaches, giving us significantly smaller error bounds.

The use of surface distance maps and nearest-neighbor maps con-siderably improve the performance of the proximity query algo-rithm. There are two main reasons.

• Faster computation: The underlying distance field compu-tation algorithm is much faster. This is due to the fact thatwe are only computing distance fields on the boundary of theobjects (i.e. a 2D manifold) as opposed to a 3D volumetricgrid.

• Higher accuracy : We compute the surface distance fieldsat a higher resolution (e.g.5122 or 1K × 1K) as opposedto volumetric approaches, which would typically compute at643 or 1283 grid resolutions. As a result, our distance errorbounds are much tighter and the Voronoi-based culling resultsin a smaller PNS and we perform significantly fewer exacttests in the primitives.

• Adaptive resolution : Using surface distance maps, we canselect a unique resolution for each object, providing us withadaptive resolution in large environments with variation inscale.

6.4 Motion Planning in Dynamic Environments

We use our distance field computation algorithm for interactive mo-tion planning of multiple 3D agents or robots moving along a 2Dmanifold, but the environment consists of 3D obstacles. Some ofthe driving applications include crowd simulation in urban environ-ments or architectural models, vehicles moving along a terrain, etc.We represent the environment as a set of objects,S, and partitionit into two disjoint sets: a set of obstaclesSo and a set of ’ground’surfacesSg. A ground surface is a 2-manifold along which robotsare constrained to move.

Our goal is to perform motion planning for multiple moving robotsor agents with no assumptions about their motion. In this case,each robot is treated as a dynamic obstacle for the other robots.As a result, prior motion planning algorithms based on sampling-based techniques and pre-computation of a roadmap are not directlyapplicable.

Voronoi diagrams have been widely used for motion planning, in-cluding roadmap computation [6], sample generation [13] or com-bined with potential field methods for 2D robots [18]. It is wellknown that the Voronoi diagram of the obstaclesVD(So) repre-sents the connectivity of the free space of the robot, and can pro-vide paths of maximal clearance between the obstacles. The 3D

Voronoi diagram consists of 2D Voronoi faces, 1D Voronoi edgesand Voronoi vertices. Since the motion of the robots is constrainedto Sg, we compute the intersection of the 3D Voronoi diagramVD(So) with the ground surfacesSg. In this case,VD(So) ∩ Sg

gives paths of maximal clearance alongSg.

For each ground surfaceog ∈ Sg, we compute the surface distancemapD(og|So) and the nearest neighbor mapN (og|So). SinceSo

andSg are disjoint, it follows from Lemma 1 that the nearest neigh-bor mapN (og|So) is equivalent toVD(So) ∩ og. We extract thediscrete Voronoi graph fromN (og|So) and assign the edge weightsbased on edge length and maximum clearance along the edge, asdescribed in [18]. The Voronoi vertices closest to the robot andthe goal position are classified as source and destination, respec-tively, and the minimum weight path is computed using Dijkstra’sshortest-path algorithm.

We combine the roadmap computed from the nearest-neighbor mapwith a potential field planner for local planning. For each robot,the potential field planner takes into account the proximity to thenearest obstacle. Hence, for each robot objector ∈ So, we computethe surface distance mapD(or|So) and use that map to compute theproximity information. The surface distance map is sampled at afinite set of points and we use that sampling to compute an averageforce and torque to simulate the robot dynamics.

We demonstrate the application of surface distance maps for in-teractive motion planning of a large number of human agents inan urban environment with dynamic 3D obstacles (see Figure 1).The set of obstacles consists of buildings, cars, flying drones andhumans. The set of ground surfaces consists of roads, sidewalksand lawns. The humans enter the scene from the buildings andexit through another building or the sidewalks. Each human isan individual robot and has an independent goal. The cars anddrones, along with other humans, are treated as dynamic obstacles,while the buildings, benches, fountains are treated as static obsta-cles. In our implementation, a higher weight is assigned to Voronoiedges corresponding to the cars and flying drones. As the flyingdrones approach the ground, the humans update the paths to evadethem. The nearest-neighbor map is computed on a grid of reso-lution 1K × 1K pixels. The environment has 15 static obstacles,and up to 8 dynamic obstacles, and100 dynamically moving hu-man agents. The complete motion planning takes120ms per frame,which includes cost of computing the nearest neighbor map, ex-tracting the discrete Voronoi graph and performing graph search.The time spent on nearest neighbor map computation is approxi-mately30ms per frame.

7 L IMITATIONS AND CONCLUSIONS

Our approach has certain limitations. We compute a 2D domaintriangle for each triangle in the 3D mesh. We pack all these 2D do-main triangles in the texture atlas and our current packing algorithmmay not be optimal. Our current approach is limited to deformingtriangles with fixed connectivity. If the underlying simulation con-sists of objects with changing topologies, we may need to updatethe planar parameterization and recompute the spatial hierarchies.The accuracy of our proximity computation algorithm is governedby the resolution of the distance map. It is possible to computehigher resolution distance fields using GPUs, but then the cost ofreadback to CPU goes up, especially for interactive applications.

7.1 Conclusions and Future Work

We present a new algorithm to compute surface distance maps fortriangulated models using the texture mapping hardware. We com-pute a planar parameterization of the mesh and use the affine map-

Page 8: Surface Distance Maps - GAMMA UNC

ping to efficient evaluate the distance maps. We also present cullingand clipping techniques to speed up the computations. We highlightthe performance of our algorithm on complex models and use it toperform interactive proximity queries between deformable models.

There are many avenues for future work. We could further improvethe performance of our algorithm by using spatial and temporal co-herence between successive frames. It may be possible to extendour algorithm to objects with changing topologies, where we in-crementally recompute the affine transformation to the parametricdomain. We would like to use proximity computation algorithmto perform self-proximity queries including self-collisions or self-penetrations in cloth simulation. Surface distance maps could alsobe useful to accelerate ray tracing dynamic scenes [33].

ACKNOWLEDGMENTS

This research is supported in part by ARO Contracts DAAD19-02-1-0390, and W911NF-04-1-0088, NSF Awards 0400134, 0118743,ONR Contract N00014-01-1-0496, DARPA RDECOM ContractN61339-04-C-0043 and Intel Corporation. We would like to ac-knowledge members of UNC GAMMA and the reviewers usefulcomments and feedback.

REFERENCES

[1] F. Aurenhammer. Voronoi diagrams: A survey of a fundamental geo-metric data structure.ACM Comput. Surv., 23(3):345–405, September1991.

[2] I. Bitter, A. Kaufmann, and M. Sato. Penalized-distance volumet-ric skeleton algorithm.IEEE Trans. on Visualization and ComputerGraphics, 7(3), 2001.

[3] J. F. Blinn. Simulation of wrinkled surfaces. InComputer Graphics(SIGGRAPH ’78 Proceedings), pages 286–292, 1978.

[4] H. Breu, J. Gil, D. Kirkpatrick, and M. Werman. Linear time Eu-clidean distance transform and Voronoi diagram algorithms.IEEETrans. Pattern Anal. Mach. Intell., 17:529–533, 1995.

[5] E. Catmull. A subdivision algorithm for computer display of curvedsurfaces. PhD thesis, University of Utah, 1974.

[6] H. Choset and J. Burdick. Sensor based motion planning: The hier-archical generalized Voronoi graph. InAlgorithms for Robot Motionand Manipulation, pages 47–61. A K Peters, 1996.

[7] Robert L. Cook. Shade trees. In Hank Christiansen, editor, ComputerGraphics (SIGGRAPH ’84 Proceedings), volume 18, pages 223–231,July 1984.

[8] O. Cuisenaire.Distance Transformations: Fast Algorithms and Ap-plications to Medical Image Processing. PhD thesis, UniversiteCatholique de Louvain, 1999.

[9] P. E. Danielsson. Euclidean distance mapping.Computer Graphicsand Image Processing, 14:227–248, 1980.

[10] M. Denny. Solving geometric optimization problems using graphicshardware.Computer Graphics Forum, 22(3), 2003.

[11] Michal Etzion and Ari Rappoport. Computing Voronoi skeletons ofa 3-d polyhedron by space subdivision.Computational Geometry:Theory and Applications, 21(3):87–120, March 2002.

[12] I. Fischer and C. Gotsman. Fast approximation of high order Voronoidiagrams and distance transforms on the GPU. Technical reportCSTR-07-05, Harvard University, 2005.

[13] M. Foskey, M. Garber, M. Lin, and D. Manocha. A voronoi-basedhybrid planner. Proc. of IEEE/RSJ Int. Conf. on Intelligent Robotsand Systems, 2001.

[14] Alain Fournier. Normal distribution functions and multiple surfaces.In Graphics Interface ’92 Workshop on Local Illumination, pages 45–52, May 1992.

[15] S. Frisken, R. Perry, A. Rockwood, and R. Jones. Adaptively sam-pled distance fields: A general representation of shapes forcomputergraphics. InProc. of ACM SIGGRAPH, pages 249–254, 2000.

[16] S. Gibson. Using distance maps for smooth representationin sampledvolumes. InProc. of IEEE Volume Visualization Symposium, pages23–30, 1998.

[17] J. Gomes and O. Faugeras. The vector distance functions.Int. Journalof Computer Vision, 52(2):161–187, 2003.

[18] K. Hoff, T. Culver, J. Keyser, M. Lin, and D. Manocha. Interactivemotion planning using hardware accelerated computation of general-ized voronoi diagrams.Proceedings of IEEE Conference of Roboticsand Automation, 2000.

[19] Kenneth E. Hoff, III, Tim Culver, John Keyser, Ming Lin,and DineshManocha. Fast computation of generalized Voronoi diagrams usinggraphics hardware. InComputer Graphics Annual Conference Series(SIGGRAPH ’99), pages 277–286, 1999.

[20] A. Klein, P. J. Sloan, A. Finkelstein, and M. Cohen. Stylized videocubes.Symposium on Computer Animation, 1992.

[21] L. Kobbelt, M. Botsch, U. Schwanecke, and H. P. Seidel. Feature-sensitive surface extraction from volume data. InProc. of ACM SIG-GRAPH, pages 57–66, 2001.

[22] A. Lefohn, J. Kniss, C.D. Hansen, and R. Whitaker. Interactive defor-mation and visualization of level set surfaces using graphics hardware.In Proceedings of IEEE Visualization, page To Appear, 2003.

[23] M.C. Lin. Efficient Collision Detection for Animation and Robotics.PhD thesis, Department of Electrical Engineering and Computer Sci-ence, University of California, Berkeley, December 1993.

[24] Sean Mauch.Efficient Algorithms for Solving Static Hamilton-JacobiEquations. PhD thesis, Californa Institute of Technology, 4 2003.

[25] C.R. Maurer, R. Qi, and V. Raghavan. A linear time algorithm forcomputing exact euclidean distance transforms of binary images inarbitary dimensions.IEEE Transactions on Pattern Analysis and Ma-chine Intelligence, 25(2):265–270, February 2003.

[26] Atsuyuki Okabe, Barry Boots, and Kokichi Sugihara.Spatial Tessel-lations: Concepts and Applications of Voronoi Diagrams. John Wiley& Sons, Chichester, UK, 1992.

[27] R. Peikert and C. Sigg. Optimized bounding polyhedra forgpu-baseddistance transform. InScientific Visualization: The visual extractionof knowledge from data, 2005.

[28] R. Perry and S. Frisken. Kizamu: A system for sculpting digital char-acters. InProc. of ACM SIGGRAPH, pages 47–56, 2001.

[29] J. A. Sethian.Level set methods and fast marching methods. Cam-bridge, 1999.

[30] C. Sigg, R. Peikert, and M. Gross. Signed distance transform usinggraphics hardware. InProceedings of IEEE Visualization, pages 83–90, 2003.

[31] A. Sud, N. Govindaraju, R. Gayle, and D. Manocha. Interactive 3ddistance field computation using linear factorization. InProc. ACMSymposium on Interactive 3D Graphics and Games, pages 117–124,2006.

[32] Avneesh Sud, Naga Govindaraju, Russell Gayle, Ilknur Kabul, and Di-nesh Manocha. Fast proximity computation among deformable mod-els using discrete voronoi diagrams.ACM Trans. Graph. (Proc ACMSIGGRAPH), 25(3):1144–1153, 2006.

[33] L. Szirmay-Kalos, B. Aszodi, I. Lazanyi, and M. Premecz. Approx-imate ray-tracing on the gpu with distance impostor.Proc. of Euro-graphics, 2005.

[34] M. Teichmann and S. Teller. Polygonal approximation of Voronoidiagrams of a set of triangles in three dimensions. Technical Report766, Laboratory of Computer Science, MIT, 1997.

[35] J. Vleugels and M. H. Overmars. Approximating Voronoi diagramsof convex sites in any dimension.International Journal of Computa-tional Geometry and Applications, 8:201–222, 1998.

[36] M. Woo, J. Neider, and T. Davis.OpenGL Programming Guide, Sec-ond Edition. Addison Wesley, 1997.