Memory Efficient and Robust Software Implementation of the Raycast Algorithm Aline Pina Cristiana Bentes Ricardo Farias COPPE/UFRJ DESC/UERJ COPPE/UFRJ Rio de Janeiro - Brazil Rio de Janeiro - Brazil Rio de Janeiro - Brazil aline@lcg.ufrj.br cristianabentes@gmail.com rfarias@cos.ufrj.br WSCG 2007 Outline • • • • • Volume Visualization Ray-casting Proposed Ray-casting Algorithms Experimental Results Conclusions Volume Visualization • Volumetric data images • 3D data 2D plane • Gains: – Understanding – Visual analysis and interpretation Volumetric Data • Generated: – Simulation (Fluid Dynamic) – Sensors (CT scanner) – Measured Data (Ocean Buoys) • Represented: – 3D grid of voxels (Regular or Irregular) Volume Visualization Methods Surface Rendering x Volume Rendering • Discard data between surfaces • Object is semi-transparent • Loses information • Hides internal structures • Faster to compute • More information • Shows internal structures • Computational intensive Volume Rendering Algorithms • Cell projection: cells are projected on the screen • Ray-casting: rays are casted through every pixel Ray-casting Ray-casting - History • First software implementation: – Garrity(1990) - cell connectivity • Improvement: – Bunyk(1998) - entry points + new auxiliary structures Ray-casting - History • Problems: • Auxiliary data structures - high memory consumption • Degenerate cases Our Goal • Improvements in Bunyk approach: – Completely handle degenerate cases – Smaller data structures – Deal with tetrahedral and/or hexahedral grids Ray-casting Algorithms • ME-Raycast Memory Efficient Ray-casting • EME-Raycast Enhanced Memory Efficient Ray-casting ME-Raycast ME-Raycast • Data Structures – Points array – Cells array – Use_set for each vertex – Neighbor_set for each cell – Faces array – on-the-fly ME-Raycast • Use_set(v) – List of all cells incident on v A E B v C D 2D example Use_set(v) = {A, B, C, D, E} ME-Raycast • Neighbor_set(c) – List of all cells that share a face with c A 2D example ME-Raycast • Neighbor_set(c) – List of all cells that share a face with c Neighbor_set(A) = {B, C, D} B C A D 2D example ME-Raycast • Faces array – List of all faces intersected by the rays 3D example ME-Raycast • Faces array – List of all faces intersected by the rays 3D example ME-Raycast • Faces array – List of all faces intersected by the rays Faces array A 3D example ME-Raycast • Faces array – List of all faces intersected by the rays Faces array A B B 3D example ME-Raycast • Faces array – List of all faces intersected by the rays Faces array A B B 3D example ME-Raycast • Algorithm – Preprocessing: • Read data – create arrays Points and Cells • Create Use_set • Create Neighbor_set ME-Raycast • Algorithm – Raycasting: • Project visible faces – entry point • For each pixel: – Find next intersection – check other cell's faces – If (no intersection) – check degenerate cases – Accumulate color and opacity EME-Raycast EME-Raycast • Data Structures – Points array – Cells array – Use_set for each vertice – Neighbor_set for each cell – Faces array EME-Raycast • Algorithm – Verification of intersection: • Checking the face - recalculate parameters Handling Degeneracies Handling Degeneracies • Ray hits a vertex a 2D example Handling Degeneracies • Ray hits a vertex Bunyk check a A b E 2D example Handling Degeneracies • Ray hits a vertex Our check a B A b E C D 2D example Handling Degeneracies • Ray hits a vertex a B A b E C D 2D example c Handling Degeneracies • Ray hits an edge 3D example Handling Degeneracies • Ray hits an edge a 3D example Handling Degeneracies • Ray hits an edge a b 3D example Handling Degeneracies • Ray hits an edge a b 3D example Handling Degeneracies • Ray hits an edge Bunyk check a b 3D example Handling Degeneracies • Ray hits an edge Our check a b c 3D example Experimental Results Experimental Results Workload Datasets # Cells Blunt Fin 187 395 Combustion Chamber 215 040 Oxygen Post 513 375 SPX 827 904 Delta Wing Hexa 1 005 675 1 920 Experimental Results • Baselines: – Bunyk (ray-casting) – ZSweep (cell projection) Bunyk Algorithm Step 1 Viewing Direction Screen Bunyk Algorithm Step 2 Viewing Direction Screen ZSweep Algorithm Z Target Z t Sweep Direction v P X Pixel P List ZSweep Algorithm Z Target Z t v P X Pixel P List Experimental Results Degenerate cases: 5122 10242 Blunt 10 31 Comb - 2 Oxygen 11 38 Delta 7 17 SPX 5 18 Pixels not rendered Experimental Results Memory Consumption ME-Raycast – 1024 x 1024 image Bunyk ZSweep Blunt 75% 40% Combustion 76% 76% Oxygen 66% 70% Delta 61% 152% SPX 74% 222% Experimental Results Memory Consumption EME-Raycast – 1024 x 1024 image Bunyk ZSweep Blunt 39% 20% Combustion 37% 37% Oxygen 30% 30% Delta 27% 68% SPX 27% 83% Experimental Results Execution Time ME-Raycast – 1024 x 1024 image Bunyk ZSweep Blunt 126% 29% Combustion 106% 38% Oxygen 136% 38% Delta 148% 33% SPX 116% 41% Experimental Results Execution Time EME-Raycast – 1024 x 1024 image Bunyk ZSweep Blunt 304% 70% Combustion 224% 80% Oxygen 289% 82% Delta 271% 61% SPX 222% 79% Conclusions • Two memory-aware ray-casting algorithms • Improved Bunyk work: memory, degenerate cases, handling hexahedral • Significant gains in memory usage • Correct images Future Work • Software out-of-core version • GPU implementation • Parallelization Thank you! cristianabentes@gmail.com