SlideShare a Scribd company logo
Volume Rendering
In Unity3D
Matias Lavik
The presentation
- An introduction to volume rendering of medical 3D volume data.
- Based on my hobby-project:
https://github.com/mlavik1/UnityVolumeRendering
(still WIP)
- What we will cover:
- Raymarching volume data
- Techniques for volume rendering: Direct volume rendering with compositing, maximum
intensity projection, isosurface rendering
- Diffuse lighting
- Transfer functions
- Multidimensional transfer functions
The data
- We use 3D voxel data from a medical CT scan.
- The value of each data point represents the density.
- The data is read from a file and stored in a 3D texture
- The data fits nicely into a box, so we render a box (we only draw the back
faces) and use raymarching to fetch the densities of each visible voxel inside
the box.
(above illustration by: Klaus D Tönnies
https://www.researchgate.net/figure/3D-volume-d
ata-representation_fig1_238687132 )
Raymarching
Raytracing: Cast a ray from the eye through each pixel and find the first triangle(s)
hit by the ray. Then draw the colour of that triangle .
Usage: Rendering triangular 3D models (discrete)
Raymarching: Create a ray from/towards the camera. Divide the ray into N
steps/samples, and combine the value at each step.
Usage: Rendering continous data, such as mathematical equations.
Rendering volume data (such as CT scans)
For CT scans we want to see both the skin, blood veins and bones at the same
time - ideally with different colours
Raymarching the data
1. Draw the back-faces of a box
2. For each vertex:
2.1. Set startPos as the vertex local position
2.2. Set rayDir as the direction towards the eye (in model space)
2.3. Divide the ray into N steps/samples
2.4. For each step (starting at startPos moving along rayDir)
2.4.1. Get the density: use currentPos as a texture coordinate and fetch the value from the 3D
texture
2.4.2. ??? (use the density to decide the output colour of the fragment/pixel)
startPos: we start from here
rayDir: direction towards the eye
n steps: we get the density (data value)
at each step
we stop at the border of the box
We will look at 3 implementations:
1. Maximum intensity projection
2. Direct volume rendering with compositing
3. Isosurface rendering
1. Maximum Intensity Projection
- Draw the voxel (data value) with the highest density along the ray.
- Set the output colour to be white with alpha = maxDensity
- This is a simple but powerful visualisation, that highlights bones and big
variations in density.
Result
2. Direct Volume Rendering with compositing
- On each step, combine the current voxel colour with the accumulated colour
value from the previous steps.
- We linearly interpolate the RGB values
- newRGB = lerp(oldRGB, currRGB, currAlpha)
- And add the new alpha to the old alpha multiplied by (1 - new alpha)
col.rgb = src.a * src.rgb + (1.0f - src.a)*col.rgb;
col.a = src.a + (1.0f - src.a)*col.a;
Source colour: for now we use the density
to decide the RGB and alpha values. We
multiply alpha by 0.1 to make more
transparent.
As a result, bones (high density) are more
visible, and the skin (low density) is
almost invisible.
Later we will add colours!
3. Isosurface Rendering
- Draw the first voxel (data value) with a density higher than some threshold.
- Now we need to start raymarching at the eye (or ideally at the point where the
ray hits the front face of the box) and move away from the eye.
- When we hit a voxel with density > threshold we stop, and use that density
-
Lighting
- Since we are rendering the surfaces only, we need light reflection to make it
look good.
Diffuse reflection:
Light intensity is decided by the angle between the direction to the light source and the surface normal (θ), and a
diffuse constant (Kd - we can set it to 1).
Id = Kd · cos(θ)
When l and n are normalised, we have:
cos(θ) = dot(n, l)
Id = Kd · dot(n, l)
How do we get the normal?
- Since we are working with 3D voxels and not triangles, getting the normal
requires some extra work.
Solution: Use the gradient
Gradient = direction of change
Compare the neighbour data values in each axis
When the data values decrease towards the
right (positive X-axis), the normal will point to
the right
You might want to use another lighting
calculation, such as Phong (which includes
specular reflection as well).
NOTE: Here we use a transfer function to decide colour.
(see next slides)
(Note: we now add a random offset to the ray start position, to improve
the sample artifacts.)
Without lighting With lighting
With Transfer Function (see next slides)
Transfer Functions
- Basic idea: Use the density to decide colour and opacity/transparency.
- Example:
- Bones are white and opaque
- Blood vessels are red and semi-transparent
- The skin is brown and almost invisible
- Implementation
1. Allow the user to add colour knots and alpha knots to a box, where the x-axis
represents the density and the y-axis defines the opacity
2. Generate a 1D texture where x-axis = density and the textel (pixel)’s RGBA
defines the colour and opacity.
3. Shader: After getting the density of a voxel, use the density to look up the
RGBA value in the transfer function texture.
(based on the direct volume rendering shader
from previous slides)
Note: Unity doesn’t support 1D textures so we use
a 2D texture with height=1
X-axis: Density
Y-axis: Opacity (alpha) at density X
Gradient bar: Colour at density X
Alpha knots: move up and
down to change the alpha
value
Multidimensional Transfer Functions
- Sometimes opacity is not enough to identify the parts we want to highlight
- Different parts of the object might have similar densities
- We need another dimension in our transfer function!
Gradient magnitude
- Gradient = direction of change (already covered this in previous slides)
- Gradient magnitude = magnitude of the gradient vector
(= how much the density changes at the point - or the “derivative” if you want)
- Using both density and gradient magnitude when setting colours/alphas
allows us to highlight surfaces while ignoring what’s beneath it.
NOTE: I store the gradients in the data texture’s RGB (and the
data value is stored in the A)
We could calculate the gradients in the shader, but that is
expensive. This is a tradeoff, since it uses more memory.
See the earlier slide about “isosurface rendering” for how to
calculate gradients, or my GitHub:
https://github.com/mlavik1/UnityVolumeRendering
1D Transfer Function 2D Transfer Function
Slice rendering
- Create a movable plane
- In the shader, use the vertex coordinates (relative to the volume model) as 3D
texture coordinates.
- (optionally) use 1D transfer function to apply colour
References / credits
- ImageVis3D
- Some of the GUI are heavily inspired by ImageVis3D
- Get ImageVis3D here: http://www.sci.utah.edu/software/imagevis3d.html
- Marcelo Lima
- Marcelo presented his implementation of isosurface rendering during his assignment
presentation for the Visualisation course at the University of Bergen.
- See his amazing project here: https://github.com/m-lima/KATscans
- Thanks to Stefan Bruckner and Helwig Hauser who taught me CG and
visualisation at the University of Bergen.

More Related Content

What's hot

STEGANOGRAPHY PRESENTATION SLIDES
STEGANOGRAPHY PRESENTATION SLIDESSTEGANOGRAPHY PRESENTATION SLIDES
STEGANOGRAPHY PRESENTATION SLIDES
Lovely Mnadal
 
Image feature extraction
Image feature extractionImage feature extraction
Image feature extraction
Rishabh shah
 
Image Dithering.pptx
Image Dithering.pptxImage Dithering.pptx
Image Dithering.pptx
MuhanadBadee1
 
Semantic Segmentation on Satellite Imagery
Semantic Segmentation on Satellite ImagerySemantic Segmentation on Satellite Imagery
Semantic Segmentation on Satellite Imagery
RAHUL BHOJWANI
 
DirectX 11 Rendering in Battlefield 3
DirectX 11 Rendering in Battlefield 3DirectX 11 Rendering in Battlefield 3
DirectX 11 Rendering in Battlefield 3
Electronic Arts / DICE
 
Understanding neural radiance fields
Understanding neural radiance fieldsUnderstanding neural radiance fields
Understanding neural radiance fields
Varun Bhaseen
 
Image captioning
Image captioningImage captioning
Image captioning
Muhammad Zbeedat
 
Recent Progress on Object Detection_20170331
Recent Progress on Object Detection_20170331Recent Progress on Object Detection_20170331
Recent Progress on Object Detection_20170331
Jihong Kang
 
Single Image Super Resolution Overview
Single Image Super Resolution OverviewSingle Image Super Resolution Overview
Single Image Super Resolution Overview
LEE HOSEONG
 
[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기
[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기
[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기
동석 김
 
Visual Object Tracking: review
Visual Object Tracking: reviewVisual Object Tracking: review
Visual Object Tracking: review
Dmytro Mishkin
 
Object tracking a survey
Object tracking a surveyObject tracking a survey
Object tracking a survey
Haseeb Hassan
 
CIFAR-10
CIFAR-10CIFAR-10
CIFAR-10
satyam_madala
 
Handwritten bangla-digit-recognition-using-deep-learning
Handwritten bangla-digit-recognition-using-deep-learningHandwritten bangla-digit-recognition-using-deep-learning
Handwritten bangla-digit-recognition-using-deep-learning
Sharmin Rubi
 
Hog and sift
Hog and siftHog and sift
Hog and sift
AnandShinde47
 
3 d display-methods
3 d display-methods3 d display-methods
3 d display-methods
Mahmudul Hasan
 
Introduction to object detection
Introduction to object detectionIntroduction to object detection
Introduction to object detection
Brodmann17
 
IMAGE QUALITY ASSESSMENT- A SURVEY OF RECENT APPROACHES
IMAGE QUALITY ASSESSMENT- A SURVEY OF RECENT APPROACHES IMAGE QUALITY ASSESSMENT- A SURVEY OF RECENT APPROACHES
IMAGE QUALITY ASSESSMENT- A SURVEY OF RECENT APPROACHES
cscpconf
 
Scan line method
Scan line methodScan line method
Scan line method
Pooja Dixit
 
Convolutional Neural Network
Convolutional Neural NetworkConvolutional Neural Network
Convolutional Neural Network
Vignesh Suresh
 

What's hot (20)

STEGANOGRAPHY PRESENTATION SLIDES
STEGANOGRAPHY PRESENTATION SLIDESSTEGANOGRAPHY PRESENTATION SLIDES
STEGANOGRAPHY PRESENTATION SLIDES
 
Image feature extraction
Image feature extractionImage feature extraction
Image feature extraction
 
Image Dithering.pptx
Image Dithering.pptxImage Dithering.pptx
Image Dithering.pptx
 
Semantic Segmentation on Satellite Imagery
Semantic Segmentation on Satellite ImagerySemantic Segmentation on Satellite Imagery
Semantic Segmentation on Satellite Imagery
 
DirectX 11 Rendering in Battlefield 3
DirectX 11 Rendering in Battlefield 3DirectX 11 Rendering in Battlefield 3
DirectX 11 Rendering in Battlefield 3
 
Understanding neural radiance fields
Understanding neural radiance fieldsUnderstanding neural radiance fields
Understanding neural radiance fields
 
Image captioning
Image captioningImage captioning
Image captioning
 
Recent Progress on Object Detection_20170331
Recent Progress on Object Detection_20170331Recent Progress on Object Detection_20170331
Recent Progress on Object Detection_20170331
 
Single Image Super Resolution Overview
Single Image Super Resolution OverviewSingle Image Super Resolution Overview
Single Image Super Resolution Overview
 
[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기
[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기
[Ndc13]Ndc 2013 김동석:UDK로 물리기반 셰이더 만들기
 
Visual Object Tracking: review
Visual Object Tracking: reviewVisual Object Tracking: review
Visual Object Tracking: review
 
Object tracking a survey
Object tracking a surveyObject tracking a survey
Object tracking a survey
 
CIFAR-10
CIFAR-10CIFAR-10
CIFAR-10
 
Handwritten bangla-digit-recognition-using-deep-learning
Handwritten bangla-digit-recognition-using-deep-learningHandwritten bangla-digit-recognition-using-deep-learning
Handwritten bangla-digit-recognition-using-deep-learning
 
Hog and sift
Hog and siftHog and sift
Hog and sift
 
3 d display-methods
3 d display-methods3 d display-methods
3 d display-methods
 
Introduction to object detection
Introduction to object detectionIntroduction to object detection
Introduction to object detection
 
IMAGE QUALITY ASSESSMENT- A SURVEY OF RECENT APPROACHES
IMAGE QUALITY ASSESSMENT- A SURVEY OF RECENT APPROACHES IMAGE QUALITY ASSESSMENT- A SURVEY OF RECENT APPROACHES
IMAGE QUALITY ASSESSMENT- A SURVEY OF RECENT APPROACHES
 
Scan line method
Scan line methodScan line method
Scan line method
 
Convolutional Neural Network
Convolutional Neural NetworkConvolutional Neural Network
Convolutional Neural Network
 

Similar to Volume Rendering in Unity3D

Order Independent Transparency
Order Independent TransparencyOrder Independent Transparency
Order Independent Transparency
acbess
 
Direct Volume Rendering (DVR): Ray-casting
Direct Volume Rendering (DVR): Ray-castingDirect Volume Rendering (DVR): Ray-casting
Direct Volume Rendering (DVR): Ray-casting
CaferYaarKarabulut
 
Shader X³: Image Space - Color Grading
Shader X³: Image Space - Color GradingShader X³: Image Space - Color Grading
Shader X³: Image Space - Color Grading
Ronny Burkersroda
 
Estrazione automatica delle linee in un'immagine digitale
Estrazione automatica delle linee in un'immagine digitaleEstrazione automatica delle linee in un'immagine digitale
Estrazione automatica delle linee in un'immagine digitale
francescapadoin
 
Shaders project
Shaders projectShaders project
Shaders project
Timothy Kim
 
Rendering basics
Rendering basicsRendering basics
Rendering basics
icedmaster
 
Rendering: Vertices, Indices, UVs and Shaders
Rendering: Vertices, Indices, UVs and ShadersRendering: Vertices, Indices, UVs and Shaders
Rendering: Vertices, Indices, UVs and Shaders
David Goemans
 
Lec_2_Digital Image Fundamentals.pdf
Lec_2_Digital Image Fundamentals.pdfLec_2_Digital Image Fundamentals.pdf
Lec_2_Digital Image Fundamentals.pdf
nagwaAboElenein
 
Faire de la reconnaissance d'images avec le Deep Learning - Cristina & Pierre...
Faire de la reconnaissance d'images avec le Deep Learning - Cristina & Pierre...Faire de la reconnaissance d'images avec le Deep Learning - Cristina & Pierre...
Faire de la reconnaissance d'images avec le Deep Learning - Cristina & Pierre...
Jedha Bootcamp
 
Adaptive Median Filters
Adaptive Median FiltersAdaptive Median Filters
Adaptive Median Filters
Amnaakhaan
 
Data Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image ProcessingData Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image Processing
Derek Kane
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Modeling and texturing in 3 ds max
Modeling and texturing in 3 ds maxModeling and texturing in 3 ds max
Modeling and texturing in 3 ds max
sribalaji0007
 
Modelo y textrurizado 3 ds max
Modelo y textrurizado 3 ds maxModelo y textrurizado 3 ds max
Modelo y textrurizado 3 ds max
LuchIn Avalos
 
CNN_AH.pptx
CNN_AH.pptxCNN_AH.pptx
CNN_AH.pptx
ssuserc755f1
 
CNN_AH.pptx
CNN_AH.pptxCNN_AH.pptx
CNN_AH.pptx
ssuserc755f1
 
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
mmjalbiaty
 
Digital image processing Tool presentation
Digital image processing Tool presentationDigital image processing Tool presentation
Digital image processing Tool presentation
dikshabehl5392
 
study Diffusion Curves: A Vector Representation for Smooth-Shaded Images
study Diffusion Curves: A Vector Representation for Smooth-Shaded Imagesstudy Diffusion Curves: A Vector Representation for Smooth-Shaded Images
study Diffusion Curves: A Vector Representation for Smooth-Shaded Images
Chiamin Hsu
 
Image_processing_unit2_SPPU_Syllabus.pptx
Image_processing_unit2_SPPU_Syllabus.pptxImage_processing_unit2_SPPU_Syllabus.pptx
Image_processing_unit2_SPPU_Syllabus.pptx
Mayuri Narkhede
 

Similar to Volume Rendering in Unity3D (20)

Order Independent Transparency
Order Independent TransparencyOrder Independent Transparency
Order Independent Transparency
 
Direct Volume Rendering (DVR): Ray-casting
Direct Volume Rendering (DVR): Ray-castingDirect Volume Rendering (DVR): Ray-casting
Direct Volume Rendering (DVR): Ray-casting
 
Shader X³: Image Space - Color Grading
Shader X³: Image Space - Color GradingShader X³: Image Space - Color Grading
Shader X³: Image Space - Color Grading
 
Estrazione automatica delle linee in un'immagine digitale
Estrazione automatica delle linee in un'immagine digitaleEstrazione automatica delle linee in un'immagine digitale
Estrazione automatica delle linee in un'immagine digitale
 
Shaders project
Shaders projectShaders project
Shaders project
 
Rendering basics
Rendering basicsRendering basics
Rendering basics
 
Rendering: Vertices, Indices, UVs and Shaders
Rendering: Vertices, Indices, UVs and ShadersRendering: Vertices, Indices, UVs and Shaders
Rendering: Vertices, Indices, UVs and Shaders
 
Lec_2_Digital Image Fundamentals.pdf
Lec_2_Digital Image Fundamentals.pdfLec_2_Digital Image Fundamentals.pdf
Lec_2_Digital Image Fundamentals.pdf
 
Faire de la reconnaissance d'images avec le Deep Learning - Cristina & Pierre...
Faire de la reconnaissance d'images avec le Deep Learning - Cristina & Pierre...Faire de la reconnaissance d'images avec le Deep Learning - Cristina & Pierre...
Faire de la reconnaissance d'images avec le Deep Learning - Cristina & Pierre...
 
Adaptive Median Filters
Adaptive Median FiltersAdaptive Median Filters
Adaptive Median Filters
 
Data Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image ProcessingData Science - Part XVII - Deep Learning & Image Processing
Data Science - Part XVII - Deep Learning & Image Processing
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Modeling and texturing in 3 ds max
Modeling and texturing in 3 ds maxModeling and texturing in 3 ds max
Modeling and texturing in 3 ds max
 
Modelo y textrurizado 3 ds max
Modelo y textrurizado 3 ds maxModelo y textrurizado 3 ds max
Modelo y textrurizado 3 ds max
 
CNN_AH.pptx
CNN_AH.pptxCNN_AH.pptx
CNN_AH.pptx
 
CNN_AH.pptx
CNN_AH.pptxCNN_AH.pptx
CNN_AH.pptx
 
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
Image Interpolation Techniques with Optical and Digital Zoom Concepts -semina...
 
Digital image processing Tool presentation
Digital image processing Tool presentationDigital image processing Tool presentation
Digital image processing Tool presentation
 
study Diffusion Curves: A Vector Representation for Smooth-Shaded Images
study Diffusion Curves: A Vector Representation for Smooth-Shaded Imagesstudy Diffusion Curves: A Vector Representation for Smooth-Shaded Images
study Diffusion Curves: A Vector Representation for Smooth-Shaded Images
 
Image_processing_unit2_SPPU_Syllabus.pptx
Image_processing_unit2_SPPU_Syllabus.pptxImage_processing_unit2_SPPU_Syllabus.pptx
Image_processing_unit2_SPPU_Syllabus.pptx
 

Recently uploaded

SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 

Recently uploaded (20)

SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 

Volume Rendering in Unity3D

  • 2. The presentation - An introduction to volume rendering of medical 3D volume data. - Based on my hobby-project: https://github.com/mlavik1/UnityVolumeRendering (still WIP) - What we will cover: - Raymarching volume data - Techniques for volume rendering: Direct volume rendering with compositing, maximum intensity projection, isosurface rendering - Diffuse lighting - Transfer functions - Multidimensional transfer functions
  • 3. The data - We use 3D voxel data from a medical CT scan. - The value of each data point represents the density. - The data is read from a file and stored in a 3D texture - The data fits nicely into a box, so we render a box (we only draw the back faces) and use raymarching to fetch the densities of each visible voxel inside the box.
  • 4. (above illustration by: Klaus D Tönnies https://www.researchgate.net/figure/3D-volume-d ata-representation_fig1_238687132 )
  • 5. Raymarching Raytracing: Cast a ray from the eye through each pixel and find the first triangle(s) hit by the ray. Then draw the colour of that triangle . Usage: Rendering triangular 3D models (discrete) Raymarching: Create a ray from/towards the camera. Divide the ray into N steps/samples, and combine the value at each step. Usage: Rendering continous data, such as mathematical equations. Rendering volume data (such as CT scans) For CT scans we want to see both the skin, blood veins and bones at the same time - ideally with different colours
  • 6. Raymarching the data 1. Draw the back-faces of a box 2. For each vertex: 2.1. Set startPos as the vertex local position 2.2. Set rayDir as the direction towards the eye (in model space) 2.3. Divide the ray into N steps/samples 2.4. For each step (starting at startPos moving along rayDir) 2.4.1. Get the density: use currentPos as a texture coordinate and fetch the value from the 3D texture 2.4.2. ??? (use the density to decide the output colour of the fragment/pixel)
  • 7. startPos: we start from here rayDir: direction towards the eye n steps: we get the density (data value) at each step we stop at the border of the box
  • 8. We will look at 3 implementations: 1. Maximum intensity projection 2. Direct volume rendering with compositing 3. Isosurface rendering
  • 9. 1. Maximum Intensity Projection - Draw the voxel (data value) with the highest density along the ray. - Set the output colour to be white with alpha = maxDensity - This is a simple but powerful visualisation, that highlights bones and big variations in density.
  • 10.
  • 12. 2. Direct Volume Rendering with compositing - On each step, combine the current voxel colour with the accumulated colour value from the previous steps. - We linearly interpolate the RGB values - newRGB = lerp(oldRGB, currRGB, currAlpha) - And add the new alpha to the old alpha multiplied by (1 - new alpha) col.rgb = src.a * src.rgb + (1.0f - src.a)*col.rgb; col.a = src.a + (1.0f - src.a)*col.a;
  • 13. Source colour: for now we use the density to decide the RGB and alpha values. We multiply alpha by 0.1 to make more transparent. As a result, bones (high density) are more visible, and the skin (low density) is almost invisible. Later we will add colours!
  • 14.
  • 15. 3. Isosurface Rendering - Draw the first voxel (data value) with a density higher than some threshold. - Now we need to start raymarching at the eye (or ideally at the point where the ray hits the front face of the box) and move away from the eye. - When we hit a voxel with density > threshold we stop, and use that density -
  • 16. Lighting - Since we are rendering the surfaces only, we need light reflection to make it look good. Diffuse reflection: Light intensity is decided by the angle between the direction to the light source and the surface normal (θ), and a diffuse constant (Kd - we can set it to 1). Id = Kd · cos(θ) When l and n are normalised, we have: cos(θ) = dot(n, l) Id = Kd · dot(n, l)
  • 17. How do we get the normal? - Since we are working with 3D voxels and not triangles, getting the normal requires some extra work. Solution: Use the gradient Gradient = direction of change Compare the neighbour data values in each axis When the data values decrease towards the right (positive X-axis), the normal will point to the right
  • 18. You might want to use another lighting calculation, such as Phong (which includes specular reflection as well). NOTE: Here we use a transfer function to decide colour. (see next slides) (Note: we now add a random offset to the ray start position, to improve the sample artifacts.)
  • 20. With Transfer Function (see next slides)
  • 21. Transfer Functions - Basic idea: Use the density to decide colour and opacity/transparency. - Example: - Bones are white and opaque - Blood vessels are red and semi-transparent - The skin is brown and almost invisible - Implementation 1. Allow the user to add colour knots and alpha knots to a box, where the x-axis represents the density and the y-axis defines the opacity 2. Generate a 1D texture where x-axis = density and the textel (pixel)’s RGBA defines the colour and opacity. 3. Shader: After getting the density of a voxel, use the density to look up the RGBA value in the transfer function texture.
  • 22. (based on the direct volume rendering shader from previous slides) Note: Unity doesn’t support 1D textures so we use a 2D texture with height=1
  • 23. X-axis: Density Y-axis: Opacity (alpha) at density X Gradient bar: Colour at density X Alpha knots: move up and down to change the alpha value
  • 24.
  • 25. Multidimensional Transfer Functions - Sometimes opacity is not enough to identify the parts we want to highlight - Different parts of the object might have similar densities - We need another dimension in our transfer function! Gradient magnitude - Gradient = direction of change (already covered this in previous slides) - Gradient magnitude = magnitude of the gradient vector (= how much the density changes at the point - or the “derivative” if you want) - Using both density and gradient magnitude when setting colours/alphas allows us to highlight surfaces while ignoring what’s beneath it.
  • 26. NOTE: I store the gradients in the data texture’s RGB (and the data value is stored in the A) We could calculate the gradients in the shader, but that is expensive. This is a tradeoff, since it uses more memory. See the earlier slide about “isosurface rendering” for how to calculate gradients, or my GitHub: https://github.com/mlavik1/UnityVolumeRendering
  • 27. 1D Transfer Function 2D Transfer Function
  • 28.
  • 29. Slice rendering - Create a movable plane - In the shader, use the vertex coordinates (relative to the volume model) as 3D texture coordinates. - (optionally) use 1D transfer function to apply colour
  • 30.
  • 31.
  • 32. References / credits - ImageVis3D - Some of the GUI are heavily inspired by ImageVis3D - Get ImageVis3D here: http://www.sci.utah.edu/software/imagevis3d.html - Marcelo Lima - Marcelo presented his implementation of isosurface rendering during his assignment presentation for the Visualisation course at the University of Bergen. - See his amazing project here: https://github.com/m-lima/KATscans - Thanks to Stefan Bruckner and Helwig Hauser who taught me CG and visualisation at the University of Bergen.