Post on 20-Dec-2015
transcript
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Distance Fields
Avneesh Sud
COMP 290-058, Fall 2003
2The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Overview
WHAT are Distance Fields?HOW are they computed?WHY do we care?
3The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Overview
WHAT are Distance Fields?HOW are they computed?WHY do we care?
4The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Distance Functions
A scalar function f:Rn -> R representing the distance from an object O to any point P ε Rn
Object O is called a ‘site’
5The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Distance Functions: Example
Euclidean Distance Function:f(x,y)=√x2+y2
Point in 2D
6The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Distance Functions: Example
Euclidean Distance Function:f(x,y)=√x2+y2
Plot a graph:z=√x2+y2
Cone
Points in 2D
7The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Distance Metrics
Lp distance metric in k dim
p = 1, “Manhattan” or City Blockp = 2, Euclideanp =∞, Max-norm
pk
i
p
iip yxd
1
1
),(
yx
8The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Distance Fields
For a set of sites, the minima of all distance functions representing the distance from a point P ε Rn to closest site“Lower Envelope” of all distance functions
9The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Differential Geometry
S = surface moving in a normal direction with unit speedDistance of point X from surface = arrival time of the surface at X
S
X
d
10The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Differential Geometry
Shortest distance from X to point p ε S is orthogonal to SLine segment Xp is a characteristicS must be smooth
S
X
d
p
11The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
What is a Voronoi Diagram?Given a collection of geometric primitives, it is a subdivision of space into cells such that all points in a cell are closer to one primitive than to any other
Voronoi Site
Voronoi Region
12The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Ordinary Point sitesNearest Euclidean distance
GeneralizedHigher-order site geometryVarying distance metrics
Weighted Distances
Higher-orderSites
2.0
0.5
13The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Voronoi Diagram and Distance Fields“Projection of lower envelope” of
distance functions
“Lower Envelope” of distance functions
Voronoi Diagram
14The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Voronoi Diagram and Distance Fields
“Projection of lower envelope” of distance functionsGiven one, other can be easily computedPractical methods compute distance fields on a discrete grid
15The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Related Terminology
Distance Transform = Distance FieldClosest Point Transform = Feature Transform = Voronoi Diagram
16The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Why Should We Compute Them?
Useful in a wide variety of applications
Collision DetectionSurface ReconstructionRobot Motion Planning
Non-Photorealistic RenderingSurface Simplification
Mesh GenerationShape Analysis
17The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
GVD: “Clearance Information”
Points with the largest distance values to nearby obstacles
Maximally Clear Path
Density Estimation Nearest Neighbors
18The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Distance Field: “Proximity Information”
Potential Fields – need proximity information to obstaclesDistance field of obstacles (and its gradient) used to compute repulsive forces [Khatib86]
0
020
reprep
if0
if111
x
kF
19The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Overview
WHAT are Distance Fields?HOW are they computed?WHY do we care?
20The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Brute Force Algorithm (Grid)1. Initially : dp =∞, for all p ε
grid2. for each site m3. for each grid point p4. dnew = distance to m
5. if |dnew|<|dp|
6. dp = dnew
7. cpp = closest point on m8. end9. end
21The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Brute-force Algorithm
Record ID of the closest site to each sample
point
Coarsepoint-sampling
result
Finerpoint-sampling
result
22The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Brute Force Algorithm
Time Complexity?M sites, grid size N O(MN)
Space Complexity?O(N)
Immensely Parallelizable!
23The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
GPU Based Computation
Point Line Triangle
HAVOC2D, HAVOC3D [Hoff et al, 99]
Evaluate distance at each pixel for all sitesAccelerate using graphics hardwareModel is polygonal
24The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
HAVOC2D, HAVOC3DEvaluate distance at each pixel for all sitesAccelerate using graphics hardware
StepsMesh approximation of Distance FunctionsRender distance meshes using graphics hardwareReadback final buffers
GPU Based Computation
25The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Approximating the Distance Function
Depth buffer performs minimum comparisonGraphics Hardware performs fast linear interpolation Distance Functions are non-linearPerform linear approximation to Distance Function
26The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Approximating the Distance Function
Point Line Triangle
Avoid per-pixel distance evaluationPoint-sample the distance functionReconstruct by rendering polygonal mesh
27The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
The Error Bound
Error bound is determined by the pixel resolution farthest distance a point can be from a pixel sample point
Close-up of pixel grid
28The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Meshing the Distance Function
Shape of distance function for a 2D point is a cone
Need a bounded-error tessellation of the cone
29The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Rasterization to reconstruct distance valuesDepth test to perform minimum operator
Graphics Hardware Acceleration
Perspective, 3/4 view Parallel, top view
30The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Readback Results
Distance Field
Depth Buffer
Voronoi Regions
Color Buffer
31The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Shape of Distance Functions
Sweep apex of cone along higher-order site to obtain the shape of the distance function
32The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Example Distance Meshes
33The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Curves
Tessellate curve into a polylineTessellation error is added to meshing error
34The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
3D Voronoi Diagrams
Graphics hardware can generate one 2D slice at a timeSweep along 3rd dimension (Z-axis) computing 1 slice at a time
Polygonal model
35The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Shape of 3D Distance Functions
Slices of the distance function for a 3D point site
Distance meshes used to approximate slices
36The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Shape of 3D Distance FunctionsPoint Line segment Triangle
1 sheet of a hyperboloid
Elliptical cone Plane
37The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Advantages
Simple idea – efficiently implemented on graphics hardwareExtensible to any type of distance function and input set
38The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Disadvantages
Mesh Generation and TranformLarge number of triangles generated
Rasterization: Distance mesh can fill entire sliceComplexity for M sites and N slices = O(MN) Lot of Fill !
Readback:Stalls the graphics pipelineUnsuitable for interactive applications
39The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Using Voronoi Information
Assume point sites onlyCompute Voronoi diagram
O(M logM) in 2DO(M2) in 3D
Scan convert each Voronoi cell, computing closest distance
O(N)Edges of Voronoi polygons/polyhedra must be larger than grid spacing
40The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Characteristics/Scan Conversion Algorithm
Use characteristics [Mauch00]2D algorithm for a piecewise linear curve
41The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Characteristics/Scan Conversion Algorithm
Closest points to a line segment lie within an infinite stripEach strip exactly contains the characteristic curves from that edge
Characteristic Curve
42The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Characteristics/Scan Conversion Algorithm
Closest points to a point lie within an infinite wedgeCharacteristic line for non-smooth points on the manifold lies “between” the normals of surrounding smooth parts
43The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Edge Strips
Positive Distance Negative Distance
44The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Vertex Wedges
Positive Distance Negative Distance
45The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Bounds
Compute distance field in a band up to distance d from the curveCompute bounding polygons up to distance d
Vertex Edge
46The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
CSC algorithm – 2D
1. Initially: dij =∞, for all i,j2. for each edge e3. p = bounding polygon of e4. G = scan_convert(p)5. for each (i, j) ε G6. dnew = distance to e7. if |dnew|<|dij|8. dij = dnew
9. cpij = closest point on e10. end11. end12. for each vertex v13. …14. end
47The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
3D Triangle Mesh
Sites are triangular faces, edges or verticesCharacteristic lines have bounding polyhedra
Faces – Triangular Prims Edge - Wedge Vertices – “Cones”
48The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
3D Triangle Mesh
Sites are triangular faces, edges or verticesCharacteristic lines have bounding polyhedra
49The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
3D Computation
Slice polyhedra into polygonsScan convert each polygon
Slices of a “cone”
50The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
CSC algorithm – 3D
1. Initially: dij =∞, for all i,j2. for each face f3. p = bounding polyhedron of f4. …5. end6. for each edge e7. …8. end9. for each vertex v10. …11.end
51The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Complexity
M sites, N grid cells within distance d of the surfacer = ratio of sum of volumes of polyhedra by volume of region within distance d
Gives amount of overlap = number of times each cell is written
Complexity = O(M +rN)
Polyhedra Construction Scan Conversion
52The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Complexity
For small d, r ≈ 1For large d, clip bounding polyhedra to keep r small
Can increase setup cost of polyhedra construction to O(M2 )
53The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Advantages
Efficiently exploits surface connectivity, minimizing fillGives signed distance fields
54The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Disadvantages
Valid for manifold surfacesCannot evaluate non-linear distance functions on older generations of graphics hardwareA large number of polygons may be scan-converted for each sliceSaddle points – “Cones” invalidSetup cost
55The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
CSC on graphics hardware
Use programmable fragment programs on modern GPUs to compute distance functions at each pixel [Sigg03]
Can compute complicated functions at each pixel on current GPUs
56The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
HW-Based CSC
Compute entire slice at a timeCPU computes slicing polygonsGPU computes distance values at each pixel on slice in parallel
Model
Slice PolyhedraPolygons
57The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Reducing polygon count
Expand triangular prisms to encloses point closest to edges and faces
2D example
Bisector
58The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Reducing polygon count
Expand triangular prisms to encloses point closest to edges and faces
Fragment program computes closest siteComplete Voronoi information is lost
3D example
59The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Results
Stanford Bunny Model Knot Model
60The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Advantages
Efficient implementation on graphics hardware – exploits parallelismReduces number of polygons drawnHandles saddle points
61The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
DiFi
Fast Distance Field computation using graphics hardware [Sud03]Enhancement over HAVOCExploits Voronoi diagram properties for culling
62The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Voronoi Diagram Properties
Within a bounded region, all voronoi regions have a bounded volume
9 Sites, 2D
63The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Voronoi Diagram Properties
Within a bounded region, all voronoi regions have a bounded volume
As site density increases, average spatial bounds decrease
27 Sites, 2D
64The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Voronoi Diagram Properties
Voronoi regions are connected
Valid for all Lp norms
65The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Voronoi Diagram Properties
High distance field coherence between adjacent slicesChange in distance function between adjacent slices is bounded Distance functions for a
point site Pi to slice Zj
66The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Voronoi Diagram Properties
High distance field coherence between adjacent slicesChange in distance function between adjacent slices is bounded Distance functions for a
point site Pi to slice Zj+1
67The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Culling Techniques
Use Voronoi region bounds for culling
Site ClassificationEstimating Z-BoundsEstimating XY-Bounds
68The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Site Culling: Classification
For each slice partition the set of sites S1
S3
Slicej
S4
S2
Sweep Direction
X
Z
S5
69The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
S4
Site Culling: Classification
For each slice partition the set of sites, using voronoi region bounds:
Slicej
S1
S2
S3
X
ZSweep Direction
S5
70The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Site Culling: Classification
For each slice partition the set of sites, using voronoi region bounds:
Approaching (Aj)
Slicej
S1S3
S4
S2
X
ZSweep Direction
Aj
S5
71The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
S4
S2
Site Culling: Classification
For each slice partition the set of sites, using voronoi region bounds:
Approaching (Aj)
Intersecting (Ij)
Slicej
S1S3
X
ZSweep Direction
Aj
Ij
S5
72The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
S4
S2
Site Culling: Classification
For each slice partition the set of sites, using voronoi region bounds:
Approaching (Aj)
Intersecting (Ij)
Receding (Rj)
Slicej
S1S3
X
ZSweep Direction
Aj
Ij
Rj
S5
73The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
S4
S2
Site Culling: Classification
For each slice partition the set of sites, using voronoi region bounds:
Approaching (Aj)
Intersecting (Ij)
Receding (Rj)
Render distance functions for Intersecting sites only
Slicej
S1S3
X
ZSweep Direction
Aj
Ij
Rj
S5
74The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Coherence
Updating Ij
Ij+1 = Ij …
Slicej+1
S1S3
Previously Intersecting
S4
S2
X
ZSweep Direction
Ij
S5
75The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
S4
S2
Coherence
Updating Ij
Ij+1 = Ij
+ (Aj – Aj+1) …
Slicej+1
S1S3
X
ZSweep Direction
Approaching Intersecting
Aj-Aj+1
S5
76The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
S4
S2
Coherence
Updating Ij
Ij+1 = Ij
+ (Aj – Aj+1)
– (Rj+1 – Rj)
Slicej+1
S1S3
X
ZSweep Direction
Rj+1-Rj
Intersecting Receding
S5
77The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
S4
S2
Coherence
Updating Ij
Ij+1 = Ij
+ (Aj – Aj+1)
– (Rj+1 – Rj)
Slicej+1
S1S3
X
ZSweep Direction
S5
Aj+1Ij+1
Rj+1
78The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Estimating Set Partitions
Computing exact set partition = Exact voronoi computationUse hardware based occlusion queries
Determine number of visible fragments
Compute a set of potentially intersecting sites Îjjj II ˆ
79The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Estimating XY Bounds
Monotonic distance functions
80The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Estimating XY Bounds
Monotonic distance functionsVoronoi region’s XY extent bounded by depth of distance function
81The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Estimating XY Bounds
Monotonic distance functionsVoronoi region’s XY extent bounded by depth of distance functionEstimate max depth bounds for each site!
82The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Estimating Depth Bound
Render distance function in layers using occlusion query
83The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Estimating Depth Bound
Render distance field in layers using occlusion query
84The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Estimating Depth Bound
Render distance field in layers using occlusion query
85The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Estimating Depth Bound
Render distance field in layers using occlusion query
Last visible layer bounds the max depth
86The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Estimating Depth Bound
Render distance field in layers using occlusion query
Last visible layer bounds the max depth
Gives max depth at end of current slice
87The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Updating Depth Bound
Exploit depth field coherenceGiven a depth bound for current slice, estimate a bound for next slice
88The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Complexity
Performance depends on amount of occlusion in distance functions
Influences estimated boundsr = ratio of estimated Voronoi bounds by actual Voronoi size
Complexity O(M+rN )Worst case: r = MExpected: r = constant
Mesh Generation + Transform
Rasterization
89The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Results
Model Polys ResolutionHAVOC
(s)DiFi(s)
Shell Charge 4460 128x126x126 31.69 3.38
Head 21764 79x106x128 52.47 13.60
Bunny 69451 128x126x100 212.71 36.21
Cassini 90879 94x128x96 1102.01 47.90
4 -20 times speedup!
90The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Overview
WHAT are Distance Fields?HOW are they computed?WHY do we care?
91The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Planning Based on GVD & MAT
O’Dunlaing, Sharir and Yap [1983]
Canny and Donald [1987]
Latombe [1991]
Choset, Burdick, et al. [1994-1999]
Vleugels and Overmars [1996,1997]
Guibas, Holleman and Kavraki [1999]
Wilmarth, Amato and Stiller [1999]
…… and others ……
92The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Planning Using GVDs
Is a GVD sufficient for path planning?
GVD computed in 3D workspaceSufficient for a point robot
Use GVD along with other methods
93The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
3-DOF Potential Field Planner with GVD
Rigid robot moving on a plane in a dynamic environment [Hoff00]Combines a GVD roadmap with a local (potential field) planner
94The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Basic Approach
Depth Buffer – providing distance function and distance gradient (finite difference)
Color Buffer – building Voronoi graphs
Combination of BothCompute weighted Voronoi graphs Voronoi vertices used for milestonesWeighted edges used for selecting pathsDistance values for quick rejection
95The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Voronoi BoundaryFor each voxel in discrete GVD, associate a color corresponding to an object ID and a distance value to this obstacle.
To extract the boundary, use continuation method similar to iso-surface extraction -- starting from a seed point and step to next by bracketing boundary curves in a 2x2x2 region of sampled points.
Can be efficiently performed on modern GPUs using fragment programs
96The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Constructing Voronoi Roadmap
Identify Voronoi vertices
Extract Voronoi boundary
Build Voronoi graph
Select path based on edge weights
Incrementally construct Voronoi roadmap
local planner (PFF) between milestonesquick collision rejection test & exact CD
97The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Voronoi Roadmap/Graph for
Dynamic Environments
98The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Video (3D View)
99The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Other Approaches
Voronoi based sampling for PRM [Hoff, WAFR00], [Foskey01] Constraint based motion planning [Garber 02]
Planning problem formulated as a dynamic simulation problem with constraintsUses distance information for solving constraints
100The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
References (Distance Fields)
HAVOC: Hoff et al. Fast Computation of Generalized Voronoi Diagrams Using Graphics Hardware SIGGRAPH 1999 CSC: S. Mauch A fast algorithm for computing the closest point and distance transformHW-CSC: Sig et al. Signed Distance Transform Using Graphics Hardware IEEE Vis 2003DiFi: Sud and Manocha Fast Distance Field Computation Using Graphics Hardware UNC-TR03-026
101The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
References (Planning)
Hoff et al. Interactive Motion Planning Using Hardware-Accelerated Computation of Generalized Voronoi Diagrams ICRA 2000Pisula et al. Randomized Path Planning for a Rigid Body Based on Hardware Accelerated Voronoi Sampling WAFR 2000Garber and Lin Constraint-Based Motion Planning using Voronoi Diagrams WAFR 2002