32
CSE 167: Introduction to Computer Graphics Introduction to Computer Graphics Lecture #17: Volume Rendering Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

CSE 167:

Introduction to Computer GraphicsIntroduction to Computer Graphics

Lecture #17: Volume Rendering

Jürgen P. Schulze, Ph.D.

University of California, San Diego

Fall Quarter 2012

Page 2: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Announcements

� Thursday, Dec 13: Final project presentations in EBU-3B room 1202, 3-6pm

� Midterms

� Verify total score on front sheet is sum of individual scores

� Cross-check total score with Ted

� If exam kept past end of today’s office hour, cannot dispute grade later

2

Page 3: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Midterm Statistics

Midterm 1 Midterm 2

# Submissions 53 49

Average score 70.5 69.9

3

Median score 72.5 69.5

Highest score 95 98

Lowest score 39.5 26

Standard Deviation 14.2 13.3

Page 4: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Lecture Overview

� Volume Rendering

� SSAO

4

Page 5: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Applications: Medicine

CT Angiography:Dept. of NeuroradiologyUniversity of Erlangen,Germany

CT Human Head:Visible Human Project,US National Library of Medicine, Maryland, USA

5 This and some of the following slides are from a Eurographics 2006 course by Dr. Christof Rezk Salama, Computer Graphics and Multimedia Group, University of Siegen, Germany

Page 6: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Translucent Objects

6

Source: GPU Gems

Page 7: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Methods of Representation

� Polygonal - Triangle Mesh

� Freeforms - parametric curves, patches...

� Solid Modelling - CSG (Constructive Solid Geometry)

� Direct Volume Rendering� Direct Volume Rendering

7

Page 8: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Why Direct Volume Rendering?

Pros Cons

� Natural representation of CT/MRI images

� Transparency effects (Fire,

� Huge data sets

� Computationally expensiveTransparency effects (Fire,

Smoke…)

� High quality

expensive

� Cannot be embedded easily into polygonal scene

8

Page 9: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Volume Rendering Outline

Data Set 3D Rendering Classification

in real-time on

commodity graphics hardware

9

Page 10: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Rendering Methods

There are two categories of volume rendering algorithms:

1. Ray casting algorithms (Object Order)� Basic ray-casting� Using octrees

2. Plane Composing (Image Order)� Basic slicing with 2D textures� Basic slicing with 2D textures� Shear-Warp factorization� Translucent textures with image-aligned 3D textures

10

Page 11: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Ray Casting

� Software Solution

Image Plane

Eye

Data Set

Numerical Integration

Resampling

High Computational Load

Eye

11

Page 12: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Rendering Methods

There are two categories of volume rendering algorithms:

1. Ray casting algorithms (Object Order)� Basic ray-casting� Using octrees

2. Plane Composing (Image Order)� Basic slicing with 2D textures� Basic slicing with 2D textures� Shear-Warp factorization� Translucent textures with image-aligned 3D textures

12

Page 13: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Ray Casting

� Software Solution

Image Plane

Eye

Data Set

Numerical Integration

Resampling

High Computational Load

Eye

13

Page 14: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Plane Compositing

Proxy geometry (Polygonal Slices)

14

Page 15: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Compositing

� Maximum Intensity ProjectionNo emission/absorptionSimply compute maximum value along a ray

Emission/Absorption Maximum Intensity Projection

15

Page 16: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

2D Textures

Decompostition into axis-aligned slices

Draw the volume as a stack of 2D textures

Bilinear Interpolation in Hardware

3 copies of the data set in memory

16

Page 17: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

2D Textures: Drawbacks

Sampling rate is inconsistent

dd´ ≠ d

Emission/absorption slightly incorrect

Super-sampling on-the-fly impossible

17

Page 18: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

3D Textures

R

R G B A

GB

For each fragment:

interpolate the

texture coordinates

(barycentric)

Texture-Lookup:interpolate the

texture color

(trilinear)

18

Page 19: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

3D Textures

Slices parallel to the image plane

3D Texture: Volumetric Texture Object

Trilinear Interpolation in Hardware

One large texture block in memory

19

Page 20: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Comparison of 2D with 3D Texturing

20

Left: 2D textures, right: 3D textures

[Lewiner2006]

Page 21: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Resampling via 3D Textures

Sampling rate is constant

d d

Supersampling by increasing the

number of slices

21

Page 22: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Transfer Functions

� 1D transfer function: maps RGBA to each data value (see a and c below).

� 2D transfer function: maps RGBA to each combination of data value and gradient magnitude (see b and d below).

22

From GPU Gems

Page 23: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Shadows

23

Volume rendering with shadows

(from GPU Gems)

Page 24: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Implementation: Loading a 3D Texture� // init the 3D texture

� glEnable(GL_TEXTURE_3D_EXT);

� glGenTextures(1, &tex_glid);

� glBindTexture(GL_TEXTURE_3D_EXT, tex_glid);

� // texture environment setup

� glTexParameteri( GL_TEXTURE_3D_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR );

� glTexParameteri( GL_TEXTURE_3D_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

� glTexParameteri( GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE );

� glTexParameteri( GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );

� glTexParameteri( GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );

� // load the texture image

� glTexImage3DEXT(GL_TEXTURE_3D_EXT, // target

� 0, // level

� GL_RGBA, // color storage

� (int) tex_ni(), // width

� (int) tex_nj(), // height

� (int) tex_nk(), // depth

� 0, // border

� GL_COLOR_INDEX, // format

� GL_FLOAT, // type

� _texture ); // allocated texture buffer

� glPixelTransferi(GL_MAP_COLOR, GL_FALSE);

24

Page 25: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Videos

� Human head, rendered with 3D texture:

� http://www.youtube.com/watch?v=94_Zs_6AmQw

� GigaVoxels:

� http://www.youtube.com/watch?v=HScYuRhgEJw

25

Page 26: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Demo: DeskVox

� Created at IVL/Calit2

� http://ivl.calit2.net/wiki/index.php/VOX_and_Virvo

26

Page 27: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Lecture Overview

� Volume Rendering

� SSAO

27

Page 28: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Screen Space Ambient Occlusion

� Screen Space Ambient Occlusion = SSAO

� Rendering technique for approximating ambient occlusion in real time

� Developed by Vladimir Kajalin while working at Crytek

� First use in 2007 PC game Crysis

28 SSAO component

Page 29: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

SSAO Demo

� Screen Space Ambient Occlusion (SSAO) in Crysis

� http://www.youtube.com/watch?v=ifdAILHTcZk

29

Page 30: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

Basic SSAO Algorithm

� Copy frame buffer to texture

� Pixel shader samples depth values around current pixel and tries to compute amount of occlusion

� Occlusion depends on depth difference between sampled point and current point

Nvidia’s documentation:� Nvidia’s documentation:

� http://developer.download.nvidia.com/SDK/10.5/direct3d/Source/ScreenSpaceAO/doc/ScreenSpaceAO.pdf

� SSAO shader code from Crysis:

� http://69.163.227.177/forum.php?mod=viewthread&tid=772

� Another implementation:

� http://www.gamerendering.com/2009/01/14/ssao/30

Page 31: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

SSAO With Normals

� First pass: render depth information in a texture’s alpha channel and scene normals in the RGB channels

� Use this information to render SSAO in a render target

� It uses the normals and pixel depth to compute the occlusion between current pixel and several samples around that pixel, chosen by sampling texels from depth around that pixel, chosen by sampling texels from depth map around it.

31 With SSAONo SSAO

Page 32: CSE 167: Introduction to Computer Graphics Lecture #17 ...ivl.calit2.net/wiki/images/d/d2/17_VolumeRenderingF12.pdfThere are two categories of volume rendering algorithms: 1. Ray casting

SSAO Discussion

� Advantages:

� Independent from scene complexity.

� No pre-processing, no memory allocation in RAM

� Works with dynamic scenes

� Works in the same way for every pixel

No CPU usage: executed completely on GPU� No CPU usage: executed completely on GPU

� Disadvantages:

� Local and view-dependent (dependent on adjacent texeldepths)

� Hard to correctly smooth/blur out noise without interfering with depth discontinuities, such as object edges

32