the university of north carolina at chapel hill geometric computations on gpu: proximity queries...

109
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Geometric Computations on GPU: Proximity Queries Avneesh Sud & Dinesh Manocha

Post on 22-Dec-2015

220 views

Category:

Documents


3 download

TRANSCRIPT

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Geometric Computations on GPU: Proximity Queries

Avneesh Sud & Dinesh Manocha

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

This Lecture

Proximity Queries: OverviewVisibility computations using GPUsReliable GPU-based ComputationsCollision DetectionProximity Queries using Discrete Voronoi Diagram

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Proximity Queries

Collision Detection

Collision Detection

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Proximity Queries

Penetration Depth Contact forces

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Proximity Queries

Separation Distance Repulsive force, time of contact

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Motivation: Driving Applications

Computer animationSurgical simulationRoboticsHapticsBioinformatics

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Motivation

Interactive proximity computation among general deformable models

Inter-object queries among multiple models

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Motivation

Interactive proximity computation among general deformable models

Intra-object (self-proximity) queries in cloth simulation

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

This Lecture

Proximity Queries: OverviewVisibility computations using GPUsReliable GPU-based ComputationsCollision DetectionProximity Queries using Discrete Voronoi Diagram

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Graphics Processing Units (GPUs)

Well-designed for visibility computations

Rasterization – image-space visibility

Massively parallelRender millions of polygons per secondWell suited for image-based algorithms

High growth rate

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Recent growth rate of Graphics Processing Units

Card Million triangles/sec

Radeon 9700 Pro 325GeForce FX 5800 350Radeon 9800 XT 412GeForce FX 5950 356GeForce 6800 600GeForce 7950 1000GeForce 8800 ?

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

GPUs: Geometric Computations

Used for geometric applicationsMinkowski sums [Kim et al. 02]CSG rendering [Goldfeather et al. 89, Rossignac et al. 90]Voronoi computation [Hoff et al. 01, 02, Sud et al. 04]Isosurface computation [Pascucci 04]Map simplification [Mustafa et al. 01]Collision Detection [Govindaraju03, Govindaraju04]Proximity Computations [Sud06]

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Graphics Processing Units (GPUs)

Well-designed for visibility computations

Rasterization – image-space visibility

Massively parallelRender millions of polygons per secondWell suited for image-based algorithms

High growth rate

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Setup EngineStream of transformed vertices

Setup of setup commands and state

Vertex Processing Engines

Pixel Processing Engines

Stream of visible pixels

Alpha test

Stencil test

Depth test

Stream of vertices

IEEE Floating Point (32-bit)

IEEE Floating Point (32-bit) Limited Resolution!

Draw stream of triangles CPUGPU

Visibility of triangles

GPU

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Draw stream of triangles CPUGPU

Visibility of triangles

Vertex Processing Engines

Setup Engine

Stream of vertices

Stream of visible pixels

Alpha test

Pixel Processing Engines

Stencil test

Depth test

Stream of transformed vertices

Setup of setup commands and state

count of visible pixels

GPU

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

GPUs for Geometric Computations: Issues

PrecisionFrame-buffer readbacks

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Pixel Processing Engines

Stream of visible pixels

Limited Resolution!

Resolution along X, Y,Z

X – 13 bits fixed precision

Y – 13 bits fixed precision

Z – 24 bits fixed precision*

On CPU – 32-bit or 64-bit floating-point precision

Frame-Buffer Precision

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Frame-Buffer Readback

Involve stallsAffect throughput

Slow!

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Frame-Buffer Readback Performance

Data Courtesy: www.techreport.comJune 2004

Readback of 1Kx1K frame-buffer takes 18 ms over PCI-Express

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

GPU Growth Rate

CPU Growth Rate

AGP Bandwidth Growth Rate

Courtesy: Anselmo Lastra

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Solutions

Frame-Buffer Readbacks Minimize readback data (eg Visibility information)Precision Refine answer on CPU

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

NV Occlusion Query

Extension name: NV_occlusion_queryReturns pixel count – the no. of pixels that passProvides an interface to issue multiple queries at once before asking for the result of any oneApplications can now overlap the time it takes for the queries to return with other work increasing the parallelism between CPU and GPU

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

NV Occlusion Query – How to Use (1)(Optional) Disable Depth/Color Buffers(Optional) Disable any other irrelevant non-geometric stateGenerate occlusion queriesBegin ith occlusion queryRender ith (bounding) geometryEnd occlusion queryDo other CPU computation while queries are being made(Optional) Enable Depth/Color Buffers(Optional) Re-enable other stateGet pixel count of ith queryIf (count > MAX_COUNT) render ith geometry

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

NV Occlusion Query – How to Use (2)Generate occlusion queriesGluint queries[N];GLuint pixelCount;glGenOcclusionQueriesNV(N, queries);

Loop over queriesfor (i = 0; i < N; i++) {

glBeginOcclusionQueryNV(queries[i]); // render ith geometry glEndOcclusionQueryNV(); }

Get pixel countsfor (i = 0; i < N; i++) {

glGetOcclusionQueryuivNV(queries[i], GL_PIXEL_COUNT_NV, &pixelCount); if (pixelCount > MAX_COUNT) // do work for ith geometry }

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

This Lecture

Proximity Queries: OverviewVisibility computations using GPUsReliable GPU-based ComputationsCollision DetectionProximity Queries using Discrete Voronoi Diagram

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

GPU: Culling Coprocessor

AABB Culling

Exact Tests

2.5D Overlap Tests

Voronoi-Based Culling

Collision

DistancePotential Neighbor Set

N-ObjectsGPU-Based Culling

Potential Colliding Set

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Inaccuracies in GPU-Based Algorithms

Image samplingDepth buffer precision

[Govindaraju, Lin, Manocha,Special Issue on Best Papers of ACM

VRST’04in IEEE TVCG]

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Image Sampling

Occurs when a primitive does not cover any pixels

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Image Sampling

Primitives are rasterized but no intersecting points are sampled by hardware

Viewport

C = pixel center

Intersecting point

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Depth Buffer Precision

Intersecting points are sampled but precision is not sufficient

Viewport

C = pixel center

Intersecting point

T1

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Overcome Image Sampling

Sufficiently fatten the trianglesUse Minkowski sums

Minkowski Sum AB = A B = {a + b: a A, b

B}

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PL

Minkowski Sum: Example

P L

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

This Lecture

Proximity Queries: OverviewVisibility computations using GPUsReliable GPU-based ComputationsCollision DetectionProximity Queries using Discrete Voronoi Diagram

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Goal

Interactive collision detectionbetween complex objects

Large number of objectsHigh primitive countNon-convex objectsOpen and closed objects

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Non-rigid Motion

Deformable objectsChanging topologySelf-collisions

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

CULLIDE: Overview

Potentially Colliding Set (PCS) computationExact collision tests on the PCS

[Govindaraju, Redon, Lin, Manocha, ACM Graphics Hardware 2003]

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Algorithm

Object-LevelPruning

Subobject-Level

PruningExact Tests

GPU-based PCS computation Using CPU

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Potentially Colliding Set (PCS)

PCS

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Potentially Colliding Set (PCS)

PCS

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Algorithm

Object-LevelPruning

Subobject- Level

PruningExact Tests

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Visibility of Objects

An object is fully visible if it is completely in front of the remaining objects

O1

O

View

O2

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Visibility for Collisions: Geometric Interpretation

Sufficient but not a necessary condition for existence of separating surface with unit depth complexity

O1

O

View

O2

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Pruning

Prune objects that do not collide

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Pruning

O1 O2 … Oi-1 Oi Oi+1 … On-1 OnO1 O2 … Oi-1 Oi Oi+1 … On-1 OnO1 O2 … Oi-1 Oi Oi+1 … On-1 On

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation

Each object tested against all objects but itselfNaive algorithm is O(n2)Linear time algorithm

Uses two pass rendering approachConservative solution

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation: First Pass

O1 O2 … Oi-1 Oi Oi+1 … On-1 On

Render

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

O1 O2 … Oi-1 Oi

PCS Computation: First Pass

Fully Visible?

Render Yes. Does not collide withO1,O2,…,Oi-1

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation: First Pass

O1 O2 … Oi-1 Oi Oi+1 … On-1 On

Render

Fully Visible?

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation: Second Pass

O1 O2 … Oi-1 Oi Oi+1 … On-1 On

Render

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation: Second Pass

Render

Fully Visible?

Oi Oi+1 … On-1 On

Yes. Does not collide with Oi+1,…,On-1,On

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation: Second Pass

Render

Fully Visible?

O1 O2 … Oi-1 Oi Oi+1 … On-1 On

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation

O1 O2 … Oi-1 Oi Oi+1 … On-1 On

Fully VisibleFully Visible

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation

O1 O2 O3 … Oi-1 Oi Oi+1 … On-2 On-1 On

O1 O3 … Oi-1 Oi+1 … On-1

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Algorithm

Object-LevelPruning

Subobject- Level

PruningExact Tests

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

CULLIDE Algorithm

Object-LevelPruning

Subobject-Level

PruningExact Tests

Exact overlap tests using CPU

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Full Visibility Queries on GPUs

We require a queryTests if a primitive is fully visible or not

Current hardware supports occlusion queries

Test if only part of a primitive is visible or not

Our solutionChange the sign of the depth function

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Full Visibility Queries on GPUs

Depth function

GEQUAL LESSAll fragments Pass FailPass

Fail

Fail

PassFail PassFail

Query not supported

Occlusion query

Examples - HP_Occlusion_test, NV_occlusion_query

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Bandwidth Analysis

Read back only integer identifiers

Computation at high screen resolutions

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Demo: CULLIDE

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Quick-CULLIDE

Improved two-pass algorithmUtilize visibility relationships among objects across different viewsHandle intra-object collisions

[Govindaraju, Lin, Manocha,IEEE Virtual Reality 2005]

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Quick-CULLIDE: Visibility Sets

Decompose PCS into four disjoint sets

FFV (First pass Fully Visible)SFV (Second pass Fully Visible)NFV (Not Fully Visible in either passes)BFV (Both passes Fully Visible)

Visibility sets have five interesting properties!

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Visibility Sets: Properties

FFV and SFV are collision-free sets

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation: First Pass

O1 O2 … Oi-1 Oi … Oj … On-1 On

Render

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation: First Pass

O1 O2 … Oi-1 Oi … Oj … On-1 On

Render

Fully Visible

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Visibility Sets: PropertiesIt is sufficient to test visibility of

objects in FFV in second pass only

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation: First Pass

O1 O2 … Oi-1 Oi Oi+1 … On-1 On

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

O1 O2 … Oi-1 Oi

PCS Computation: First Pass

Render

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation: First Pass

O1 O2 … Oi-1 Oi Oi+1 … On-1 On

Not Colliding

Collision tested in Second pass

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Visibility Sets: PropertiesIt is sufficient to render objects in

FFV in first pass only!

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation: First Pass

O1 O2 … Oi-1 Oi Oi+1 … On-1 On

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

O1 O2 … Oi-1 Oi

PCS Computation: First Pass

Render

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

PCS Computation

O1 O2 … Oi-1 Oi Oi+1 … On-1 On

Not Colliding

Render

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Visibility Sets: PropertiesIt is sufficient to test the visibility

of objects in SFV in first pass only!

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Visibility Sets: Properties

It is sufficient to render objects in SFV in second pass only!

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Quick-CULLIDE: Advantages

Better culling efficiency Lower depth complexity than CULLIDEAlways better than CULLIDE

Faster computational performanceLower number of visibility queries and rendering operations

Can handle self-collisions

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Demo: Quick-CULLIDE

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Reliability

z

x

Given a primitive P

P

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Reliability

z

x

Px is the portion of P projecting inside pixel X

Pixel X

Px

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

S

Reliability

z

x

S is a sphere centered at origin bounding pixel X

Pixel X

Px

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Reliability

z

x

If we compute Minkowski sum PxS= Px S,

Pixel X

PxS

Px

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Reliability

z

x

Px

then the rasterization of the Minkowski sum PxS

generates two fragments

Pixel X

PxS

Sample Depths

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Reliability

z

x

Px

and the fragments bound depth values in Px

Pixel X

PxS

Sample Depths

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Reliability

z

x

P1

Given two primitives P1 and P2

Pixel X

P2

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Reliability

d

x

P1

If P1 and P2 intersect in 3-D,

Pixel X

P2

P1 and P2 intersect in 3-D

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Reliability

d

x

P1

and we compute their Minkowski sums with a pixel-

sized sphere centered at origin

Pixel X

P2

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Reliability

z

x

P1

rasterization of the Minkowski sums overlap in image-space

Pixel X

P2

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

z

x

Pixel X

P1

P2

P1S

P2S

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Bounding Offsets of a Triangle

Exact OffsetsThree edge-aligned cylinders, three spheres, two trianglesCan be rendered using fragment programsExpensive!

Oriented Bounding Box (OBB)

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Union of OBBs

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Demo: R-CULLIDE

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

This Lecture

Proximity Queries: OverviewVisibility computations using GPUsReliable GPU-based ComputationsCollision DetectionProximity Queries using Discrete Voronoi Diagram

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

N-Body Distance Query

Given a set of sites, find all closest pairsNearest-neighbor for each site1 5

2 1

3 1

4 1

5 1

6 5

1

2

3

4

5

6

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Goal

Compute N-Body distance efficiently

Culling

For each site, compute Potential Neighbor Set (PNS) of sites

1

2

3

4

5

6

1 5

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Goal

Compute N-Body distance efficientlyFor each site, compute Potential Neighbor Set (PNS) of sites

Contains nearest neighbor

1

2

3

4

5

6

PNS(1) = {5,3}

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Outline

Related workN-Body distance queriesCulling using second order discrete Voronoi diagramsResults

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Voronoi Culling for N-Body Query

AABB Culling

Voronoi-based Culling

N-ObjectsStage I Stage II

Exact Distance Tests

Potential Neighbor Set

Stage III

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Second-order Voronoi Diagram

1

2

3

4

5

6

Governors = 2 closest sites

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Benefit of Second-order Voronoi Diagram

Voronoi diagram: Spatial partition based on proximitySecond-order Voronoi diagram: Proximity to two sites

Nearest neighbor information

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Culling using Second-order Voronoi Diagram

12 3

9

9 Polygonal Objects

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Culling using Second-order Voronoi Diagram

PNS(1) = Sites whose second order Voronoi regions intersect 1

12 3

9

Second order Voronoi Diagram

8 7

45

6

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Culling using Second-order Voronoi Diagram

PNS(1) = Sites whose second order Voronoi regions intersect 1

PNS(1) = {2,3}

Second order Voronoi diagram provides PNS for all sites

12 3

PNS(1)

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Culling using Second-order Voronoi Diagram

PNS(1) = Sites whose second order Voronoi regions intersect 1Second order Voronoi diagram provides PNS for all sitesPNS(1) = {2,3}PNS(2) = {1,4,9}

12

PNS(2)

9

4

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Culling using Second-order Voronoi Diagram

PNS(1) = Sites whose second order Voronoi regions intersect 1Second order Voronoi diagram provides PNS for all sitesPNS(1) = {2,3}PNS(2) = {1,4,9}…PNS(9) = {2,8}

2

PNS(9)

98

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Proximity Culling using Discrete Voronoi Diagram

Computing exact Voronoi diagram difficult

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Proximity Culling using Discrete Voronoi Diagram

Computing exact Voronoi diagram difficultCompute Discrete Voronoi Diagram (DVD)

Interactive computation using GPU

Second order details in thesis

Discrete Voronoi Diagram

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Distance Bounds for Conservative Computation

Under-sampling errorsProvides approximate separation distance (SD)

SD’SD

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Distance Bounds for Conservative Computation

Theorem (Distance bounds):

SD’

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Distance Bounds for Conservative ComputationTheorem (Distance bounds):

SD’ - < SD < SD’ +

SD’ = Approximate Separation DistanceSD = Exact Separation Distance = Grid resolution

SD

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Distance Bounds for Conservative Computation

Compute PNS using distance boundsExact tests on CPU