Parallel BVH Construction using k -means Clustering Daniel Meister and Jiˇ r´ ı Bittner Department of Computer Graphics and Interaction Faculty of Electrical Engineering Czech Technical University in Prague
Motivation: Interactive Ray Tracing t = t build + t trace + t shading Trade-off between BVH quality ( t trace ) and BVH build ( t build ) Goal minimize t build + t trace camera image plane Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 2/19
Bounding Volume Hierarchy Ray tracing, collision detection, and visibility culling Rooted tree of arbitrary branching factor Geometric primitives in leaves Bounding volumes in interior nodes Branching factor 2, axis aligned bounding boxes A A B B [Clark 1976] Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 3/19
Surface Area Heuristic ( 2 n − 3 ) !! 1 valid binary bounding volume hierarchies ⎧ ⎪ k T + P ( N L ∣ N ) c ( N L ) + P ( N R ∣ N ) c ( N R ) ⎪ c ( N ) = ⎨ if N is interior node ⎪ k I ∣ N ∣ ⎪ ⎩ otherwise P ( N L ∣ N ) = SA ( N L ) P ( N R ∣ N ) = SA ( N R ) SA ( N ) SA ( N ) N R N L N [MacDonald and Booth 1990] 1 double factorial defined as k !! = k ( k − 2 )( k − 4 ) . . . 1 for odd k Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 4/19
BVH Construction Methods Top-down Surface Area Heuristic [Hunt et al. 2007, ...] Binning [Wald 2007, ...] Bottom-up Agglomerative clustering [Walter et al. 2008, Gu et al. 2013] Insertion Heuristic greedy search [Goldsmith and Salmon 1987] Online construction [Bittner et al. 2015] Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 5/19
BVH Construction Methods Top-down Surface Area Heuristic [Hunt et al. 2007, ...] Binning [Wald 2007, ...] k -means clustering Bottom-up Agglomerative clustering [Walter et al. 2008, Gu et al. 2013] Insertion Heuristic greedy search [Goldsmith and Salmon 1987] Online construction [Bittner et al. 2015] Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 5/19
k -means Clustering pass 1 ... pass 2 .... ... ... ... pass n Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 6/19
k -means Clustering Lloyd’s algorithm [Lloyd 1982] Initialize k representatives k -means loop Assignment step Update step Initialization of k representatives r 1 ,..., r k Randomly draw r 1 To select r i Randomly draw p candidates Select one maximizing distance to the nearest already selected representative Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 7/19
BVH Construction via k -means Clustering b max 1 Distance d between bounding boxes b 1 and b 2 ∣∣ 2 + ∣∣ b max d ( b 1 , b 2 ) = ∣∣ b min − b min − b max ∣∣ 2 b max 1 2 1 2 2 Positions of representatives b min 2 = 1 i ∣( ∑ , ∑ ) r t + 1 b min b max ∣C t i j j b j ∈C t b j ∈C t i i b min 1 Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 8/19
Agglomerative Clustering All treelets processed in parallel ıve algorithm without additional data structures O( n 3 ) Na¨ Surface area of merged cluster as a distance between clusters [Walter et al. 2008] pass n+1 ... ... ... ... Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 9/19
k -means Visualization Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 10/19
Results 9 scenes, 66k - 12M tris, 3 representatives views, resolution 1024 × 768 Path tracing with Russian roulette (GPU ray tracing kernel [Aila and Laine 2009]) Low quality rendering (total time LQ): 8 samples per pixel, 2 shadow samples High quality rendering (total time HQ): 128 samples per pixel, 2 shadow samples Intel Core I7-3770 3.4 GHz CPU (4 cores), 16 GB RAM CUDA: NVIDIA GeForce GTX TITAN Black, 6 GB RAM Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 11/19
Tested Methods parameters k ... the number of clusters p ... the number of candidates in initialization procedure i ... the number of iterations reference methods Full sweep SAH (idealized with zero build time) LBVH [Karras 2012]: 60-bit Morton codes HLBVH [Garanzha et al. 2011]: 60-bit Morton codes, 15 bits for SAH splits ATRBVH [Domingues and Pedrini 2015]: 2 iterations, treelet size 9 Max. 8 triangles per leaf for all methods, SAH cost constants k T = 3 , k I = 2 Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 12/19
Sponza 66k tris, k = 32 , p = 20 , i = 10 1.25 k -means 1.2 LBVH HLBVH 1.15 ATRBVH 1.1 1.05 1 0.95 0.9 0.85 0.8 trace speed SAH cost total time LQ total time HQ Normalized with the respect to idelized full sweep SAH builder Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 13/19
Conference 331k tris, k = 8 , p = 5 , i = 2 1.4 k -means 1.3 LBVH HLBVH ATRBVH 1.2 1.1 1 0.9 0.8 0.7 trace speed SAH cost total time LQ total time HQ Normalized with the respect to idelized full sweep SAH builder Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 14/19
Power Plant 12759k tris, k = 16 , p = 5 , i = 5 3.5 k -means LBVH 3 HLBVH ATRBVH 2.5 2 1.5 1 0.5 trace speed SAH cost total time LQ total time HQ Normalized with the respect to idelized full sweep SAH builder Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 15/19
Power Plant Kernel times of BVH construction 4000 other computation Q 1 : k = 8 , p = 5 , i = 0 3500 agglomerative clustering bounding boxes computation 3000 Q 2 : k = 8 , p = 5 , i = 2 triangle indices reordering cluster size computation 2500 k -means loop Q 3 : k = 16 , p = 5 , i = 5 time [ms] k -means initialization 2000 Q 4 : k = 32 , p = 20 , i = 10 1500 Q 5 : k = 64 , p = 30 , i = 15 1000 500 0 Q 1 Q 2 Q 3 Q 4 Q 5 Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 16/19
Power Plant SAH cost stabilization rate ( k T = 3 , k I = 2 ) 115 110 k = 8 , p = 5 SAH cost [-] 105 k = 16 , p = 5 100 k = 32 , p = 20 95 k = 64 , p = 30 90 85 0 2 4 6 8 10 iteration [-] Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 17/19
Conclusion and Future Work BVH construction k -means and agglomerative clustering Viable alternative to Morton ordering Implementation in CUDA Future work k -ary BVH Evaluation for larger k Other distance functions (e.g. k -medians) Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 18/19
Thank you for your attention! Daniel Meister and Jiˇ r´ ı Bittner Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 19/19
Euclidean Distance n ∑ ∣∣ x i − r ∣∣ 2 min 2 r i = 1 dr ( n ∣∣ x i − r ∣∣ 2 2 ) = − 2 n ( x i − r ) ∑ ∑ d i = 1 i = 1 n n n 0 = − 2 ( x i − r ) = ( x i − r ) = x i − n r ∑ ∑ ∑ i = 1 i = 1 i = 1 r = 1 n ∑ x i (mean) n i = 1 Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 20/19
Manhattan Distance n ∣∣ x i − r ∣∣ 1 ∑ min r i = 1 n n n d dr ( ∑ ∣∣ x i − r ∣∣ 1 ) = ∑ dr ∣∣ x i − r ∣∣ 1 = ∑ ∑ dr j ∣ x j i − r j ∣ = 0 d d d i = 1 i = 1 i = 1 j = 1 ⎧ ⎪ − 1 i > r j ⎪ x j dr j ∣ x j i − r j ∣ = ⎨ d ⎪ i < r j ⎪ ⎩ x j 1 ⎧ ⎪ ⎪ ⎪ x j r j = n odd ⎨ ( n + 1 2 ) ⎪ n even (component-wise median) ⎪ 2 ( x j 2 ) + x j 2 + 1 ) ) ⎪ 1 ⎩ ( n ( n Daniel Meister and Jiˇ r´ ı Bittner Parallel BVH Construction using k -means Clustering 21/19
Recommend
More recommend