310 likes | 319 Views
Boolean Operations on Surfel-Bounded Solids Using Programmable Graphics Hardware. Bart Adams Philip 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]
E N D
Boolean Operations onSurfel-Bounded Solids Using Programmable Graphics Hardware Bart Adams Philip 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
Partitioning: Idea • Partition space around solids • Construct 3-color grid • interior cells • exterior cells • boundary cells • Partition boundary cells • signed distance field
p6 p0 p7 p5 p1 p4 p3 p2 p2 p6 p1 p5 p3 p7 p0 p4 Partitioning Boundary Cells • Lay out cell corners in texture memory
p6 p4 p7 p0 p5 p1 p5 p4 p6 p3 p2 p2 p10 p6 p11 p7 p1 p9 p5 p10 p9 p8 p11 p3 p7 p0 p8 p4 Partitioning Boundary Cells • Lay out cell corners in texture memory
p6 p4 p7 p0 p1 p5 p5 p2 p3 p4 p6 p2 p6 p11 p7 p1 p5 p10 p9 p8 p3 p7 p0 p4 Partitioning Boundary Cells • Render each surfel as 3x3 glPoint with center corresponding to cell center p10 p9 p11 p8
p6 p4 p7 p0 p1 p5 p5 p2 p3 p4 p6 p2 p6 p11 p7 p1 p5 p10 p9 p8 p3 p7 p0 p4 Partitioning Boundary Cells • Render each surfel as 3x3 glPoint with center corresponding to cell center p10 p9 p11 p8
p6 p7 p4 p0 p5 p1 p5 p6 p2 p3 p4 p2 p6 p11 p7 p1 p5 p10 p9 p8 p3 p7 p0 p4 Partitioning Boundary Cells • Render each surfel as 3x3 glPoint with center corresponding to cell center p10 p9 p11 p8 known as scatter easy in VP
p6 p4 p0 p7 p5 p5 p1 p4 p6 p3 p2 p2 p11 p7 p1 p10 p9 p8 p3 p0 Partitioning Boundary Cells • Fragment program computes signed distance between surfel and cell corner p10 p6 p9 p5 ps p11 p7 dist = || p4 – ps || sign = (p4 – ps)·ns>0?+1:-1 color = dist * sign depth = dist/diag p8 p4 Set glDepthFunc to GL_LEQUAL
Classifying Empty Cells • 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 di < 0 • outside if di > 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)
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 z1 • if surfel in boundary cell: • write depth value z2 with z1 <z2
Implementation: Second Pass • Disable depth write • Set glDepthFunc to GL_LEQUAL • Render quad textured with surfel positions • at depth z with z1 < z < z2 • Classify surfel using distance field • 8 texture fetches, tri-linear reconstruction • Only unclassified surfels pass • fragments with z == z2 • 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) • 3-color grid creation step (~ grid size)
Timings CPU GPU ÷10 ÷5
Dragon - dragon Each dragon: #surfels: 650k grid size: 363 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