Ray Casting on Programmable Graphics Hardware
Martin KrausPURPL group, Purdue University
Martin KrausPURPL group, Purdue University
2
Overview• Parallel volume rendering with a single GPU
• Implementing ray casting for a GPU
– Basics
– Optimizations
• Published systems
• Open questions
• Parallel volume rendering with a single GPU
• Implementing ray casting for a GPU
– Basics
– Optimizations
• Published systems
• Open questions
3
Parallel Volume Rendering with a single Graphics Processing Unit (GPU) (1)
Even a single GPU is a parallel computer:• Multiple vertex and pixel pipelines
(e.g. “8 pixel pipelines” of QuadroFX and FireGL)
• APIs support this parallelism (independent processing of vertices and fragments)
• When implementing algorithms for a GPU, it’s crucial to exploit this parallelism
Even a single GPU is a parallel computer:• Multiple vertex and pixel pipelines
(e.g. “8 pixel pipelines” of QuadroFX and FireGL)
• APIs support this parallelism (independent processing of vertices and fragments)
• When implementing algorithms for a GPU, it’s crucial to exploit this parallelism
4
Parallel Volume Rendering with a single Graphics Processing Unit (GPU) (2)
Many volume rendering algorithms cannot fully exploit these parallel pixel pipelines:• Cell projection: requires visibility sorting of cells
• Textured slices: rasterize all fragments of all slices
Many volume rendering algorithms cannot fully exploit these parallel pixel pipelines:• Cell projection: requires visibility sorting of cells
• Textured slices: rasterize all fragments of all slices
5
Parallel Volume Rendering with a single Graphics Processing Unit (GPU) (3)
Ray casting can exploit parallel pixel pipes:• Like ray tracing, ray casting is embarrassingly parallel
Ray casting can exploit parallel pixel pipes:• Like ray tracing, ray casting is embarrassingly parallel
Volume DataEye Point
View RayPixel Sampling
Points
View Plane
6
Parallel Volume Rendering with a single Graphics Processing Unit (GPU) (4)
More benefits of ray casting on a GPU:• Applicable to uniform and tetrahedral meshes
• Important optimizations can be implemented:
– early ray termination
– empty space leaping
– adaptive sampling distance
More benefits of ray casting on a GPU:• Applicable to uniform and tetrahedral meshes
• Important optimizations can be implemented:
– early ray termination
– empty space leaping
– adaptive sampling distance
7
Implementing Ray Casting for a GPU: Basics (1)
Multi-pass approach: Render screen-filling rectangles to call a program for each pixelMulti-pass approach: Render screen-filling rectangles to call a program for each pixel
View Plane
Volume DataEye Point
Pixels
8
Implementing Ray Casting for a GPU: Basics (2)
Initialize pixels with first intersection of the rays with the volume dataInitialize pixels with first intersection of the rays with the volume data
View Plane
Volume DataEye Point
9
Implementing Ray Casting for a GPU: Basics (3a)
In each pass, propagate view rays and store accumulated color and sampling positionIn each pass, propagate view rays and store accumulated color and sampling position
View Plane
Volume DataEye Point
10
Implementing Ray Casting for a GPU: Basics (3b)
In each pass, propagate view rays and store accumulated color and sampling positionIn each pass, propagate view rays and store accumulated color and sampling position
View Plane
Volume DataEye Point
11
Implementing Ray Casting for a GPU: Basics (3c)
In each pass, propagate view rays and store accumulated color and sampling positionIn each pass, propagate view rays and store accumulated color and sampling position
View Plane
Volume DataEye Point
12
Implementing Ray Casting for a GPU: Basics (4)
Stop when all rays have left the volumeStop when all rays have left the volume
View Plane
Volume DataEye Point
13
Implementing Ray Casting for a GPU: Basics (5a)
Sampling of volume data:• Just a 3D-texture lookup for uniform data
• For tetrahedral cells: sample at cell boundaries
Sampling of volume data:• Just a 3D-texture lookup for uniform data
• For tetrahedral cells: sample at cell boundaries
View PlaneTetrahedral
Mesh
Eye Point
14
Implementing Ray Casting for a GPU: Basics (5b)
Sampling of volume data:• Just a 3D-texture lookup for uniform data
• For tetrahedral cells: sample at cell boundaries
Sampling of volume data:• Just a 3D-texture lookup for uniform data
• For tetrahedral cells: sample at cell boundaries
View PlaneTetrahedral
Mesh
Eye Point
15
Implementing Ray Casting for a GPU: Basics (5c)
Sampling of volume data:• Just a 3D-texture lookup for uniform data
• For tetrahedral cells: sample at cell boundaries
Sampling of volume data:• Just a 3D-texture lookup for uniform data
• For tetrahedral cells: sample at cell boundaries
View PlaneTetrahedral
Mesh
Eye Point
16
Implementing Ray Casting for a GPU: Basics (5d)
Sampling of volume data:• Just a 3D-texture lookup for uniform data
• For tetrahedral cells: sample at cell boundaries
Sampling of volume data:• Just a 3D-texture lookup for uniform data
• For tetrahedral cells: sample at cell boundaries
View PlaneTetrahedral
Mesh
Eye Point
17
Implementing Ray Casting for a GPU: Basics (5e)
Sampling of volume data:• Just a 3D-texture lookup for uniform data
• For tetrahedral cells: sample at cell boundaries
Sampling of volume data:• Just a 3D-texture lookup for uniform data
• For tetrahedral cells: sample at cell boundaries
View PlaneTetrahedral
Mesh
Eye Point
18
Implementing Ray Casting for a GPU: Basics (5f)
Sampling of volume data:• Just a 3D-texture lookup for uniform meshes
• For tetrahedral cells: sample at cell boundaries
Sampling of volume data:• Just a 3D-texture lookup for uniform meshes
• For tetrahedral cells: sample at cell boundaries
View PlaneTetrahedral
Mesh
Eye Point
19
Implementing Ray Casting for a GPU: Optimizations (1)
Overview:• Avoid work for rays that don’t intersect the volume
• Avoid work for rays that have accumulated full opacity
• Quickly test whether all rays have left the volume
• Quickly go through empty regions
• Adapt sampling distance to data
Overview:• Avoid work for rays that don’t intersect the volume
• Avoid work for rays that have accumulated full opacity
• Quickly test whether all rays have left the volume
• Quickly go through empty regions
• Adapt sampling distance to data
20
Implementing Ray Casting for a GPU: Optimizations (2)
Avoid work for rays that don’t intersect or have left the volume:• Idea: avoid rasterization of corresponding pixels by
depth tests
• Advantage: exploits early-depth tests to avoid execution of fragment program
• Requires updates of the depth-buffer (not after each pass but from time to time)
Avoid work for rays that don’t intersect or have left the volume:• Idea: avoid rasterization of corresponding pixels by
depth tests
• Advantage: exploits early-depth tests to avoid execution of fragment program
• Requires updates of the depth-buffer (not after each pass but from time to time)
21
Implementing Ray Casting for a GPU: Optimizations (3)
Avoid work for rays that have accumulated full opacity (early ray termination):• Idea: treat them as if they have left the volume
• Advantage: also exploits early-depth tests for these pixels
Avoid work for rays that have accumulated full opacity (early ray termination):• Idea: treat them as if they have left the volume
• Advantage: also exploits early-depth tests for these pixels
22
Implementing Ray Casting for a GPU: Optimizations (4)
Quickly test whether all rays have left the volume:• Observation: once all rays have left the volume, all
fragments fail the depth test
• Just use an “occlusion query” to determine whether all fragments have failed the depth test!
Quickly test whether all rays have left the volume:• Observation: once all rays have left the volume, all
fragments fail the depth test
• Just use an “occlusion query” to determine whether all fragments have failed the depth test!
23
Implementing Ray Casting for a GPU: Optimizations (5)
Quickly go through empty regions (empty space leaping):• Increase sampling distance in empty regions by
lookup in a 3D-texture that encodes empty regions
• Works only for uniform meshes
• Generalization: Adapt sampling distance to data
Quickly go through empty regions (empty space leaping):• Increase sampling distance in empty regions by
lookup in a 3D-texture that encodes empty regions
• Works only for uniform meshes
• Generalization: Adapt sampling distance to data
24
Published Systems (1)Purcell, Buck, Mark, and Hanrahan. Ray Tracing on Programmable Graphics Hardware. SIGGRAPH 2002.• “Ray tracing” (not ray casting)• Discusses concepts, not an actual implementation• Features several similar techniques, e.g., for
– invoking fragment programs– ray termination
Purcell, Buck, Mark, and Hanrahan. Ray Tracing on Programmable Graphics Hardware. SIGGRAPH 2002.• “Ray tracing” (not ray casting)• Discusses concepts, not an actual implementation• Features several similar techniques, e.g., for
– invoking fragment programs– ray termination
25
Published Systems (2)Röttger, Guthe, Weiskopf, and Ertl. Smart Hardware-Accelerated Volume Rendering. VisSym 2003.• Ray casting on a GPU for uniform meshes• Features:
– early ray termination– pre-integrated classification– adaptive sampling distance
Röttger, Guthe, Weiskopf, and Ertl. Smart Hardware-Accelerated Volume Rendering. VisSym 2003.• Ray casting on a GPU for uniform meshes• Features:
– early ray termination– pre-integrated classification– adaptive sampling distance
26
Published Systems (3)Krüger and Westermann. Acceleration Techniques for GPU-based Volume Rendering. Visualization 2003 (Session P10).• Ray casting on a GPU for uniform meshes
• Features:– early ray termination– empty-space leaping– multiple sampling points per pass
Krüger and Westermann. Acceleration Techniques for GPU-based Volume Rendering. Visualization 2003 (Session P10).• Ray casting on a GPU for uniform meshes
• Features:– early ray termination– empty-space leaping– multiple sampling points per pass
27
Published Systems (4)Weiler, Kraus, Merz, and Ertl. Hardware-Based Ray Casting for Tetrahedral Meshes. Visualization 2003 (Session P11).• Ray casting on a GPU for tetrahedral meshes
• Features:– early ray termination– pre-integrated classification– imaginary tetrahedra for non-convex meshes
Weiler, Kraus, Merz, and Ertl. Hardware-Based Ray Casting for Tetrahedral Meshes. Visualization 2003 (Session P11).• Ray casting on a GPU for tetrahedral meshes
• Features:– early ray termination– pre-integrated classification– imaginary tetrahedra for non-convex meshes
28
Open QuestionsRay casting on GPUs is a rapidly developing method, thus there are many open question:• What about worst-case performances?
• What about limited texture memory?
• What about hierarchical methods?
• What about multiple GPUs?
Ray casting on GPUs is a rapidly developing method, thus there are many open question:• What about worst-case performances?
• What about limited texture memory?
• What about hierarchical methods?
• What about multiple GPUs?
29
More Open Question?
Thanks!Thanks!
Ray Casting on Programmable Graphics HardwareOverviewParallel Volume Rendering with a single Graphics Processing Unit (GPU) (1)Parallel Volume Rendering with a single Graphics Processing Unit (GPU) (2)Parallel Volume Rendering with a single Graphics Processing Unit (GPU) (3)Parallel Volume Rendering with a single Graphics Processing Unit (GPU) (4)Implementing Ray Casting for a GPU: Basics (1)Implementing Ray Casting for a GPU: Basics (2)Implementing Ray Casting for a GPU: Basics (3a)Implementing Ray Casting for a GPU: Basics (3b)Implementing Ray Casting for a GPU: Basics (3c)Implementing Ray Casting for a GPU: Basics (4)Implementing Ray Casting for a GPU: Basics (5a)Implementing Ray Casting for a GPU: Basics (5b)Implementing Ray Casting for a GPU: Basics (5c)Implementing Ray Casting for a GPU: Basics (5d)Implementing Ray Casting for a GPU: Basics (5e)Implementing Ray Casting for a GPU: Basics (5f)Implementing Ray Casting for a GPU: Optimizations (1)Implementing Ray Casting for a GPU: Optimizations (2)Implementing Ray Casting for a GPU: Optimizations (3)Implementing Ray Casting for a GPU: Optimizations (4)Implementing Ray Casting for a GPU: Optimizations (5)Published Systems (1)Published Systems (2)Published Systems (3)Published Systems (4)Open QuestionsMore Open Question?