Transcript Slide 1

Distance Fields

Avneesh Sud COMP 290-058, Fall 2003 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Overview

WHAT are Distance Fields?

HOW are they computed?

WHY do we care?

2 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Overview

WHAT are Distance Fields?

HOW are they computed?

WHY do we care?

3 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

4

Distance Functions

A scalar function f:R n -> R representing the distance from an object

O

to any point

P

ε R n Object O is called a ‘site’ The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Distance Functions: Example

Euclidean Distance Function: f(x,y)=√x 2 +y 2 5

Point in 2D

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

6

Distance Functions: Example

Euclidean Distance Function: f(x,y)=√x 2 +y 2 Plot a graph: z=√x 2 +y 2 Cone

Points in 2D

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

7

Distance Metrics L

p distance metric in

k

dim

d p

(

x

,

y

)   

i k

  1

x i

y i p

  1

p

p p

= 1, “Manhattan” or City Block = 2, Euclidean

p

=∞, Max-norm The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

8

Distance Fields

For a set of sites, the minima of all distance functions representing the distance from a point

P

ε R n to closest site “Lower Envelope” of all distance functions The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

9

Differential Geometry

S = surface moving in a normal direction with unit speed Distance of point X from surface = arrival time of the surface at X

S

X d

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

10

Differential Geometry

Shortest distance from X to point p orthogonal to S Line segment Xp is a characteristic S must be smooth ε S is

X d

S

p

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

11

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 to any other closer to one primitive than

Voronoi Site Voronoi Region

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

12

Ordinary Generalized

Point sites Nearest Euclidean distance

Higher-order

Higher-order site geometry Varying distance metrics

Sites 2.0

0.5

Weighted Distances

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Voronoi Diagram and Distance Fields

“Projection of lower envelope” of distance functions 13

“Lower Envelope” of distance functions Voronoi Diagram

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

14

Voronoi Diagram and Distance Fields

“Projection of lower envelope” of distance functions Given one, other can be easily computed Practical methods compute distance fields on a discrete grid The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

15

Related Terminology

Distance Transform = Distance Field Closest Point Transform = Feature Transform = Voronoi Diagram The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

16

Why Should We Compute Them?

Useful in a wide variety of applications Collision Detection Surface Reconstruction Robot Motion Planning Non-Photorealistic Rendering Surface Simplification Mesh Generation Shape Analysis The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

GVD: “Clearance Information”

17

Maximally Clear Path

Points with the largest distance values to nearby obstacles

Density Estimation Nearest Neighbors

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

18

Distance Field: “Proximity Information”

Potential Fields – need proximity information to obstacles Distance field of obstacles (and its gradient) used to compute repulsive forces [Khatib86]

F

rep   

k

rep   1   1  0 0    1 2   

x

if    0 if    0

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Overview

WHAT are Distance Fields?

HOW are they computed?

WHY do we care?

19 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

20

Brute Force Algorithm (Grid)

1. Initially :

d

p =∞, for all 2. for each site

m p

ε grid 3.

for each grid point

p

4.

5.

6.

7.

8.

d

new if |

d

= distance to

d

new |<|

d

p | p

cp

p end

m

=

d

new = closest point on

m

9. end The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Brute-force Algorithm

Record ID of the closest site to each sample point

21

Coarse point-sampling result Finer point-sampling result

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

22

Brute Force Algorithm

Time Complexity?

M sites, grid size N O( MN ) Space Complexity?

O( N ) Immensely Parallelizable!

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

GPU Based Computation

HAVOC2D, HAVOC3D [Hoff et al, 99]

Evaluate distance at each pixel for all sites Accelerate using graphics hardware Model is polygonal

23

Point Line Triangle

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

24

GPU Based Computation

HAVOC2D, HAVOC3D

Evaluate distance at each pixel for all sites Accelerate using graphics hardware

Steps Mesh approximation of Distance Functions Render distance meshes using graphics hardware Readback final buffers The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

25

Approximating the Distance Function

Depth buffer performs minimum comparison Graphics Hardware performs fast linear interpolation Distance Functions are non linear Perform linear approximation to Distance Function The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Approximating the Distance Function

Avoid per-pixel distance evaluation Point-sample the distance function Reconstruct by rendering polygonal mesh 26

Point Line Triangle

The 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 27

Close-up of pixel grid

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Meshing the Distance Function

28

Shape of distance function for a 2D point is a cone Need a bounded-error tessellation of the cone

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Graphics Hardware Acceleration

Rasterization to reconstruct distance values Depth test to perform minimum operator 29

Perspective, 3/4 view Parallel, top view

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Readback Results

Color Buffer Depth Buffer 30 Voronoi Regions Distance Field The 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

31 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Example Distance Meshes

32 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Curves

Tessellate curve into a polyline Tessellation error is

added

to meshing error

33 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

34

3D Voronoi Diagrams

Graphics hardware can generate one 2D slice at a time Sweep along 3 rd dimension (Z axis) computing 1 slice at a time

Polygonal model

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Shape of 3D Distance Functions

35

Slices of the distance function for a 3D point site Distance meshes used to approximate slices

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Shape of 3D Distance Functions

Point Line segment Triangle

36

1 sheet of a hyperboloid Elliptical cone Plane

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

37

Advantages

Simple idea – efficiently implemented on graphics hardware Extensible to any type of distance function and input set The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

38

Disadvantages

Mesh Generation and Tranform Large number of triangles generated Rasterization: Distance mesh can fill entire slice Complexity for O( MN ) M sites and N slices = Lot of Fill !

Readback: Stalls the graphics pipeline Unsuitable for interactive applications The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

39

Using Voronoi Information

Assume point sites only Compute Voronoi diagram O( M log M ) in 2D O( M 2 ) in 3D Scan convert each Voronoi cell, computing closest distance O( N ) Edges of Voronoi polygons/polyhedra must be larger than grid spacing The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Characteristics/Scan Conversion Algorithm

Use characteristics [Mauch00] 2D algorithm for a piecewise linear curve 40 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

41

Characteristics/Scan Conversion Algorithm

Closest points to a line segment lie within an infinite strip Each strip exactly contains the characteristic curves from that edge

Characteristic Curve

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Characteristics/Scan Conversion Algorithm

Closest points to a point lie within an infinite wedge Characteristic line for non-smooth points on the manifold lies “between” the normals of surrounding smooth parts 42 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Edge Strips

43

Positive Distance Negative Distance

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Vertex Wedges

44

Positive Distance Negative Distance

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

45

Bounds

Compute distance field in a band up to distance d from the curve Compute bounding polygons up to distance d

Vertex Edge

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

46

CSC algorithm – 2D

1. Initially: d ij =∞, for all 2. for each edge 3.

4.

5.

6.

7.

8.

9.

p G = bounding polygon of = scan_convert( for each ( d new if | d new |<| d ij | d ij = distance to cp ij = d new e i , j ) ε 10.

end 11. end 12. for each vertex 13.

… 14. end v G p ) e i,j e = closest point on e The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

3D Triangle Mesh

Sites are triangular faces, edges or vertices Characteristic lines have bounding polyhedra 47

Faces – Triangular Prims Edge - Wedge Vertices – “Cones”

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

3D Triangle Mesh

Sites are triangular faces, edges or vertices Characteristic lines have bounding polyhedra 48 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

49

3D Computation

Slice polyhedra into polygons Scan convert each polygon

Slices of a “cone”

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

50

CSC algorithm – 3D

1. Initially: d ij =∞, for all 2. for each face f i,j 3.

p = bounding polyhedron of f 4.

… 5. end 6. for each edge e 7. … 8. end 9. for each vertex v 10.

… 11. end The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

51

Complexity M

sites,

N

grid cells within distance

d

of the surface

r

= 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

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

52

Complexity

For small

d

,

r

≈ 1 For large

d

, clip bounding polyhedra to keep

r

small Can increase setup cost of polyhedra construction to O( M 2 ) The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Advantages

Efficiently exploits surface connectivity, minimizing fill Gives signed distance fields 53 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

54

Disadvantages

Valid for manifold surfaces Cannot evaluate non-linear distance functions on older generations of graphics hardware A large number of polygons may be scan-converted for each slice Saddle points – “Cones” invalid Setup cost The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

55

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 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

56

Model Slice

HW-Based CSC

Polyhedra

Compute entire slice at a time CPU computes slicing polygons GPU computes distance values at each pixel on slice in parallel

Polygons

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

57

Reducing polygon count

Expand triangular prisms to encloses point closest to edges and faces

Bisector 2D example

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

58

Reducing polygon count

Expand triangular prisms to encloses point closest to edges and faces Fragment program computes closest site Complete Voronoi information is lost

3D example

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Results

59

Stanford Bunny Model Knot Model

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

60

Advantages

Efficient implementation on graphics hardware – exploits parallelism Reduces number of polygons drawn Handles saddle points The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

61

DiFi

Fast Distance Field computation using graphics hardware [Sud03] Enhancement over HAVOC Exploits Voronoi diagram properties for culling The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

62

Voronoi Diagram Properties

Within a bounded region, all voronoi regions have a bounded volume

9 Sites, 2D

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

63

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

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Voronoi Diagram Properties

Voronoi regions are connected Valid for all L p norms 64 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

65

Voronoi Diagram Properties

High distance field coherence between adjacent slices Change in distance function between adjacent slices is bounded

Distance functions for a point site P i to slice Z j

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

66

Voronoi Diagram Properties

High distance field coherence between adjacent slices Change in distance function between adjacent slices is bounded

Distance functions for a point site P i to slice Z j+1

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

67

Culling Techniques

Use Voronoi region bounds for culling Site Classification Estimating Z-Bounds Estimating XY-Bounds The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

68

Site Culling: Classification

For each slice partition the set of sites

Slice j S 1 S 3 S 2 S 5 X Z S 4 Sweep Direction

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

69

Site Culling: Classification

For each slice partition the set of sites, using voronoi region bounds:

S 1 Slice j S 3 S 2 S 5 X Z S 4 Sweep Direction

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

70

Site Culling: Classification

For each slice partition the set of sites, using voronoi region bounds: Approaching (A j )

S 1 Slice j S 2 S 3

A j

S 5 X Z S 4 Sweep Direction

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

71

Site Culling: Classification

For each slice partition the set of sites, using voronoi region bounds: Approaching (A j ) Intersecting (I j )

X S 1 Slice j S 2

I j

Z S 4 Sweep Direction S 3

A j

S 5

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

72

Site Culling: Classification

For each slice partition the set of sites, using voronoi region bounds: Approaching (A j ) Intersecting (I j ) Receding (R j )

X Slice j S 1

R j

S 2

I j

Z S 4 Sweep Direction S 3

A j

S 5

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

73

Site Culling: Classification

For each slice partition the set of sites, using voronoi region bounds: Approaching (A j ) Intersecting (I j ) Receding (R j ) Render distance functions for Intersecting sites only

X

R j

S 1 Slice j S 2

I j

Z S 4 Sweep Direction S 3

A j

S 5

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

74

Coherence

Updating I j I j+1 = I j …

Previously Intersecting Slice j+1 S 1 S 3 S 2 X Z S 4 Sweep Direction

I j

S 5

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

75

Coherence

Updating I j I j+1 = I j + (A j – A j+1 ) …

Approaching  Intersecting Slice j+1 S 1 S 3

A j -A j+1

S 2 S 5 X Z S 4 Sweep Direction

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

76

Coherence

Updating I j I j+1 = I j + (A j – A j+1 ) – (R j+1 – R j )

Intersecting  Receding S 1 Slice j+1 S 3 X

R j+1 -R j

S 2 Z S 4 Sweep Direction S 5

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

77

Coherence

Updating I j I j+1 = I j + (A j – A j+1 ) – (R j+1 – R j )

Slice j+1

R j+1

S 1 S 2

I j+1

S 3

A j+1

S 5 X Z S 4 Sweep Direction

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

78

Estimating Set Partitions

Computing exact set partition = Exact voronoi computation Use hardware based occlusion queries Determine number of visible fragments Compute a set of

potentially intersecting

sites Î j I

ˆ

j

I j The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Estimating XY Bounds

Monotonic distance functions 79 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

80

Estimating XY Bounds

Monotonic distance functions Voronoi region’s XY extent bounded by depth of distance function The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

81

Estimating XY Bounds

Monotonic distance functions Voronoi region’s XY extent bounded by depth of distance function Estimate max depth bounds for each site!

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Estimating Depth Bound

Render distance function in layers using occlusion query 82 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Estimating Depth Bound

Render distance field in layers using occlusion query 83 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Estimating Depth Bound

Render distance field in layers using occlusion query 84 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

85

Estimating Depth Bound

Render distance field in layers using occlusion query Last visible layer bounds the max depth The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

86

Estimating Depth Bound

Render distance field in layers using occlusion query Last visible layer bounds the max depth Gives max depth at end slice of current The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

87

Updating Depth Bound

Exploit depth field coherence Given a depth bound for current slice, estimate a bound for next slice The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

88

Complexity

Performance depends on amount of occlusion in distance functions Influences estimated bounds r = ratio of estimated Voronoi bounds by actual Voronoi size Complexity O(

M

+

rN

) Worst case: r Expected:

+ Transform

r = M = constant

Rasterization

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Results

4 -20 times speedup!

89 Model Shell Charge Polys Resolution 4460 128x126x126 HAVOC (s) 31.69

DiFi (s) 3.38

Head 21764 79x106x128 52.47

13.60

Bunny Cassini 69451 128x126x100 212.71

36.21

90879 94x128x96 1102.01

47.90

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Overview

WHAT are Distance Fields?

HOW are they computed?

WHY do we care?

90 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Planning Based on GVD & MAT

91 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 …… The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

92

Planning Using GVDs

Is a GVD sufficient for path planning?

GVD computed in 3D workspace Sufficient for a point robot Use GVD along with other methods The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

93

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 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

94

Basic Approach

Depth Buffer – providing distance function and distance gradient (finite difference) Color Buffer graphs – building Voronoi Combination of Both Compute weighted Voronoi graphs Voronoi vertices used for milestones Weighted edges used for selecting paths Distance values for quick rejection The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

95

Voronoi Boundary

For 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 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

96

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 milestones quick collision rejection test & exact CD The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Voronoi Roadmap/Graph for Dynamic Environments

97 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Video (3D View)

98 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

99

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 constraints Uses distance information for solving constraints The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

100

References (Distance Fields)

HAVOC: Hoff et al. Generalized Voronoi Diagrams Using Graphics Hardware Fast Computation of SIGGRAPH 1999 CSC: S. Mauch computing the closest point and distance transform A fast algorithm for HW-CSC: Sig et al. Signed Distance Transform Using Graphics Hardware IEEE Vis 2003 DiFi: Sud and Manocha Computation Using Graphics Hardware UNC-TR03-026 Fast Distance Field

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

101

References (Planning)

Hoff et al. Diagrams Interactive Motion Planning Using Hardware-Accelerated Computation of Generalized Voronoi ICRA 2000 Pisula et al. Randomized Path Planning for a Rigid Body Based on Hardware Accelerated Voronoi Sampling Diagrams WAFR 2000 Garber and Lin Constraint-Based Motion Planning using Voronoi WAFR 2002

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL