Boolean Operations on Surfel-Bounded Solids Using Programmable Graphics Hardware Bart AdamsPhilip Dutré Katholieke Universiteit Leuven
Goal: CSG on the GPU not rendering, but construction GPGPU
Related Work Adams and Dutré [2003] points, 3-color octree Pauly et al. [2003] points and MLS, kd-tree Purcell et al. [2002] ray tracing on the GPU Zwicker et al. [2004] splatting clipped surfels
Adams and Dutré [2003] Space partitioned using 3-color octree Boundary cells partitioned using // planes
Adams and Dutré [2003] Classification of a surfel: test against 3-color octree test against boundary planes test against nearest surfel: NN query! α
CPU GPU: Problems Hierarchical algorithm –solution: use 3-color grid instead of octree only test surfels individually NN query for surfels close to the boundary –solution: avoid NN query use local distance fields
Part 1: Inside-Outside Partitioning
Partitioning: Idea Partition space around solids Construct 3-color grid –interior cells –exterior cells –boundary cells Partition boundary cells –signed distance field
Partitioning Boundary Cells Lay out cell corners in texture memory p6p6 p7p7 p4p4 p5p5 p2p2 p3p3 p0p0 p1p1 p0p0 p1p1 p2p2 p7p7 p3p3 p6p6 p5p5 p4p4
Partitioning Boundary Cells Lay out cell corners in texture memory p4p4 p5p5 p6p6 p 11 p7p7 p 10 p9p9 p8p8 p6p6 p7p7 p4p4 p5p5 p 11 p8p8 p9p9 p2p2 p3p3 p0p0 p1p1 p0p0 p1p1 p2p2 p7p7 p3p3 p6p6 p5p5 p4p4
Partitioning Boundary Cells Render each surfel as 3x3 glPoint with center corresponding to cell center p4p4 p5p5 p6p6 p 11 p7p7 p 10 p9p9 p8p8 p6p6 p7p7 p4p4 p5p5 p 11 p8p8 p9p9 p2p2 p3p3 p0p0 p1p1 p0p0 p1p1 p2p2 p7p7 p3p3 p6p6 p5p5 p4p4
Partitioning Boundary Cells Render each surfel as 3x3 glPoint with center corresponding to cell center p4p4 p5p5 p6p6 p 11 p7p7 p 10 p9p9 p8p8 p6p6 p7p7 p4p4 p5p5 p 11 p8p8 p9p9 p2p2 p3p3 p0p0 p1p1 p0p0 p1p1 p2p2 p7p7 p3p3 p6p6 p5p5 p4p4
Partitioning Boundary Cells Render each surfel as 3x3 glPoint with center corresponding to cell center p4p4 p5p5 p6p6 p 11 p7p7 p 10 p9p9 p8p8 p6p6 p7p7 p4p4 p5p5 p 11 p8p8 p9p9 p2p2 p3p3 p0p0 p1p1 p0p0 p1p1 p2p2 p7p7 p3p3 p6p6 p5p5 p4p4 known as scatter easy in VP
Partitioning Boundary Cells Fragment program computes signed distance between surfel and cell corner p4p4 p5p5 p6p6 p 11 p7p7 p 10 p9p9 p8p8 p6p6 p7p7 p4p4 p5p5 p 11 p8p8 p9p9 p2p2 p3p3 p0p0 p1p1 p0p0 p1p1 p2p2 p7p7 p3p3 p6p6 p5p5 p4p4 psps dist = || p 4 – p s || sign = (p 4 – p s )·n s >0?+1:-1 color = dist * sign depth = dist/diag Set glDepthFunc to GL_LEQUAL
Construct 3-color grid using distance values from boundary cell corners –render textured quad –each pixel corresponds to a cell Classifying Empty Cells
First pass: cells on the left from boundary cell are classified –inside if d i < 0 –outside if d i > 0 Easy in FP: –4 texture fetches Classifying Empty Cells
Next passes: cells on the left from a classified empty cell are classified Easy in FP: –1 texture fetch Classifying Empty Cells
Next passes: cells on the left from a classified empty cell are classified Easy in FP: –1 texture fetch Iterate further Classifying Empty Cells
Next passes: cells on the left from a classified empty cell are classified Easy in FP: –1 texture fetch Iterate further Classifying Empty Cells
Next passes: cells on the left from a classified empty cell are classified Easy in FP: –1 texture fetch Iterate further Classifying Empty Cells
Next passes: cells on the left from a classified empty cell are classified Easy in FP: –1 texture fetch Iterate further Classifying Empty Cells
All non-classified cells are outside (assumption: closed solid) Classifying Empty Cells
Part 2: Inside-Outside Classification
Classification: Idea Test surfels against partitioning of other solid: test against 3-color grid test against distance field (+ compute clipping plane)
Implementation: First Pass Enable depth write Render quad textured with surfel positions Test each surfel against 3-color grid –if surfel in empty cell: surfel takes classification of empty cell write depth value z 1 –if surfel in boundary cell: write depth value z 2 with z 1 < z 2
Implementation: Second Pass Disable depth write Set glDepthFunc to GL_LEQUAL Render quad textured with surfel positions –at depth z with z 1 < z < z 2 Classify surfel using distance field –8 texture fetches, tri-linear reconstruction Only unclassified surfels pass –fragments with z == z 2 Early z culling!
Clipping Plane Surfels close to other surface: –clipped –resampled Clipping plane defined by: –distance field value –distance field gradient
Timings: partitioning Distance field creation step (~ #surfels) # surfels60k170k250k370k time37ms98ms142ms220ms 3-color grid creation step (~ grid size) grid size time3ms22ms104ms214ms
Timings CPU GPU PartitioningClassification [AD03]GPU[AD03]GPU 30k60k720ms245ms330ms19ms 90k170k1980ms351ms490ms49ms 200k250k3500ms492ms720ms80ms ÷5 ÷10
Dragon - dragon Each dragon: #surfels: 650k grid size: 36 3 partitioning: 700ms classification: 122ms
Discussion Limitations –space wasted in distance field texture –not adaptive ( ADFs) –no hierarchy: each surfel classified individually –accuracy dependent on grid resolution Advantages –5 to 10 times faster