Hybrid Computational Voxelization using the Graphics Pipeline Randall Rauwendaal Michael J. Bailey Sunday, April 6, 14
Voxelization • Conversion of input geometry (triangles) into a regular 3D discretized representation (voxels) • Analogous to rasterization in 3D Original Image 2 Mar 14, 2014 Sunday, April 6, 14
Motivation • Voxels are useful in many applications (global illumination, collision detection, fluid sim, etc...) • Voxelization can enable these e fg ects for traditional triangle based scenes • Fast voxelization can enable these e fg ects for dynamic scenes 3 Mar 14, 2014 Sunday, April 6, 14
Triangle vs Fragment Parallel Triangle Parallel • Threads per triangle • Can su fg er from uneven triangle size distributions Fragment Parallel • Threads per triangle fragment • Can su fg er from oversubscription and poor thread utilization 4 Mar 14, 2014 Sunday, April 6, 14
Triangle-Parallel Performance 5 Mar 14, 2014 Sunday, April 6, 14
Triangle-Parallel Analysis • Performs well on scenes with many small evenly sized triangles • Performs poorly on any scene with large triangles • Performance degrades as voxel resolution increases 6 Mar 14, 2014 Sunday, April 6, 14
Fragment-Parallel Performance 7 Mar 14, 2014 Sunday, April 6, 14
Fragment-Parallel Analysis • Performs well on scenes with large triangles • Performs poorly on scenes with many small triangles • Performance degrades as voxel resolution decreases • Poor “quad-utilization” on small triangles 8 Mar 14, 2014 Sunday, April 6, 14
Fragment vs Triangle parallel @256 3 9 Mar 14, 2014 Sunday, April 6, 14
Hybrid Voxelization • Introduce a hybrid pipeline that splits the workload between “small” and “large” triangles ����������������������� ������������������� ���������� ����������������� ��������������� ������������ ���������� ����������������� ������������ 10 Mar 14, 2014 Sunday, April 6, 14
Details • Creates a “two-pass” approach • Avoids poor thread utilization and oversubscription caused by rasterizing small triangles • Avoids idle threads waiting on large triangles • E fg ectively classified scenes take longer 11 Mar 14, 2014 Sunday, April 6, 14
Optimized Hybrid Voxelization • Immediately voxelize small triangles, defer only large triangles ����������������������� ������������������� ��������������� ���������� ����������������� ������������ ���������� ������������ ����������������� ������������ 12 Mar 14, 2014 Sunday, April 6, 14
Benefits • Less overhead for small triangle voxelization • Reduce under-utilized threads • Reduces output of classification stage • More of a “just over one-pass” approach, as typically only a small subset of triangles are processed twice 13 Mar 14, 2014 Sunday, April 6, 14
“Small” vs “Large” Triangles • Classify triangles based on the maximal 2D projected area of triangle in voxel units • Triangles are classified as large or small according to a cuto fg value 14 Mar 14, 2014 Sunday, April 6, 14
Hybrid Performance (Sponza) �� ������������������������������ ������������������������������ �� �� �� �� � �������������������������� � �� � ������������ � � �� � �� �� �� �� �� �� �� � ����������������� 15 Mar 14, 2014 Sunday, April 6, 14
Hybrid Performance (zoomed) ���� ��� �������������� �� ������������� ��������������� ��������������� ������������� �������������� � ������������ �������� ��� ���� � � �� �� �� �� ������������������ 16 Mar 14, 2014 Sunday, April 6, 14
Implementation Details • Surface Voxelization • OpenGL 4.2 • Computational Intersection 17 Mar 14, 2014 Sunday, April 6, 14
Surface Voxelization • Conservative voxelization (26-separable) • Thin voxelization (6-separable) Conservative Thin 18 Mar 14, 2014 Sunday, April 6, 14
Triangle/Voxel Overlap • Reduce the set of potential voxel intersections to only those that overlap the axis-aligned bounding volume of the triangle • Iterate over this reduced set of voxels and discard any that do not intersect the triangle's plane • If the triangle plane divides the voxels test all three of its 2D planar projections to confirm overlap 19 Mar 14, 2014 Sunday, April 6, 14
3D Voxel Overlap � ��� � � � � � � � � ��� � � ��� � � � � � � � ��� � � � � Conservative Thin 20 Mar 14, 2014 Sunday, April 6, 14
2D Box Overlap � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � Conservative Thin 21 Mar 14, 2014 Sunday, April 6, 14
Optimization • Pre-compute all per-triangle variables • Determine the dominant normal direction • select the orthogonal plane of maximal projection (XY, YZ, or ZX) • iterate over the component axes • Test the 2D projected overlap with the orthogonal plane of maximal projection first • Depth intersection test to determine the minimal necessary range to iterate over • Test the remaining two planar projections for overlap 22 Mar 14, 2014 Sunday, April 6, 14
Pseudocode ( v 0 , v 1 , v 2 , b min , b max , unswizzle ) e i v ( i +1)mod3 � v i n cross ( e 0 , e 1 ) sign ( n z ) · ( � e i, y , e i, x ) T n XY e i e i sign ( n x ) · ( � e i, z , e i, y ) T n YZ e i sign ( n y ) · ( � e i, x , e i, z ) T n ZX � ⌦ ↵ + max � � + max � � d XY n XY 0 , n XY 0 , n XY e i , v i, xy e i , x e i , y e i e i � ⌦ ↵ + max � � + max � � d YZ n YZ 0 , n YZ 0 , n YZ e i , v i, yz e i , x e i , y e i � ⌦ ↵ + max � � + max � � d ZX n ZX 0 , n ZX 0 , n ZX e i , v i, zx e i , x e i , y n sign ( n z ) · n z min < z max d min h n , v 0 i � max(0 , n x ) � max(0 , n y ) d max h n , v 0 i � min(0 , n x ) � min(0 , n y ) p x b min , x , . . . , b max , x p y b min , y , . . . , b max , y �⌦ ↵ � 0 � 8 2 n XY + d XY e i , p xy i =0 e i z min max � b min , z , ⌅ 1 ⇧� ( � h n xy , p xy i + d min ) n z z max min � b max , z , ⌃ 1 ⌥� ( � h n xy , p xy i + d max ) n z p z z min , . . . , z max �⌦ ↵ e i � 0 ^ ⌦ ↵ e i � 0 � 8 2 n YZ + d YZ n ZX + d ZX e i , p xy e i , p xy i =0 V [ unswizzle · p ] true 23 Mar 14, 2014 Sunday, April 6, 14
Pseudocode ( v 0 , v 1 , v 2 , b min , b max , unswizzle ) e i v ( i +1)mod3 � v i n cross ( e 0 , e 1 ) sign ( n z ) · ( � e i, y , e i, x ) T n XY e i e i sign ( n x ) · ( � e i, z , e i, y ) T n YZ e i sign ( n y ) · ( � e i, x , e i, z ) T n ZX Precompute � ⌦ ↵ + max � � + max � � d XY n XY 0 , n XY 0 , n XY e i , v i, xy e i , x e i , y Variables e i e i � ⌦ ↵ + max � � + max � � d YZ n YZ 0 , n YZ 0 , n YZ e i , v i, yz e i , x e i , y e i � ⌦ ↵ + max � � + max � � d ZX n ZX 0 , n ZX 0 , n ZX e i , v i, zx e i , x e i , y n sign ( n z ) · n z min < z max d min h n , v 0 i � max(0 , n x ) � max(0 , n y ) d max h n , v 0 i � min(0 , n x ) � min(0 , n y ) p x b min , x , . . . , b max , x p y b min , y , . . . , b max , y �⌦ ↵ � 0 � 8 2 n XY + d XY e i , p xy i =0 e i z min max � b min , z , ⌅ 1 ⇧� ( � h n xy , p xy i + d min ) n z z max min � b max , z , ⌃ 1 ⌥� ( � h n xy , p xy i + d max ) n z p z z min , . . . , z max �⌦ ↵ e i � 0 ^ ⌦ ↵ e i � 0 � 8 2 n YZ + d YZ n ZX + d ZX e i , p xy e i , p xy i =0 V [ unswizzle · p ] true 23 Mar 14, 2014 Sunday, April 6, 14
Recommend
More recommend