Texture-based Volume Rendering Texture...

6
5/12/2003 R. Crawfis, Ohio State Univ. 72 Texture-based Volume Rendering aVolume rendering by ray casting is time- consuming `one ray per pixel `each ray involves tracking through volume calculating samples, and then compositing `different for each viewpoint aAlternative approach - using texture maps - can exploit graphics hardware 5/12/2003 R. Crawfis, Ohio State Univ. 73 Texture Mapping aModern graphics hardware includes facility to draw a textured polygon aThe texture is an image with red, green, blue and alpha components… a… so several overlapping polygons can be composited 5/12/2003 R. Crawfis, Ohio State Univ. 74 Texture-based Volume Rendering aDraw from back-to-front a set of rectangles `first rectangle drawn as an area of coloured pixels, with associated opacity, as determined by transfer function and interpolation - and merged with background in a compositing operation (supported by hardware) `successive rectangles drawn on top 5/12/2003 R. Crawfis, Ohio State Univ. 75 Texture-based Volume Rendering aFor a given viewing direction, we would need to select slices perpendicular to this direction aThis requires interpolation to get the values on the slices aOnly expensive 3D texture hardware can do this fast enough… image plane volume 3D texture mapping 5/12/2003 R. Crawfis, Ohio State Univ. 76 Texture-based Volume Rendering aSimpler solution - 2D texture mapping: `view volume as set of slices parallel to co- ordinate planes choose the orientation best suited to viewing direction 5/12/2003 R. Crawfis, Ohio State Univ. 77 Texture Mapping 2D image 2D polygon + Textured-mapped polygon

Transcript of Texture-based Volume Rendering Texture...

Page 1: Texture-based Volume Rendering Texture Mappingweb.cse.ohio-state.edu/~crawfis.3/cis694L/Slides/TextureSlicing.pdf · the slicing planes are always parallel to the view plane 5/12/2003

1

5/12/2003 R. Crawfis, Ohio State Univ. 72

Texture-based Volume Rendering

Volume rendering by ray casting is time-consuming

one ray per pixeleach ray involves tracking through volume

calculating samples, and then compositingdifferent for each viewpoint

Alternative approach - using texture maps - can exploit graphics hardware

5/12/2003 R. Crawfis, Ohio State Univ. 73

Texture Mapping

Modern graphics hardware includes facility to draw a textured polygonThe texture is an image with red, green, blue and alpha components…… so several overlapping polygons can be composited

5/12/2003 R. Crawfis, Ohio State Univ. 74

Texture-based Volume Rendering

Draw from back-to-front a set of rectangles

first rectangle drawn as an area of coloured pixels, with associated opacity, as determined by transfer function and interpolation - and merged with background in a compositing operation (supported by hardware)successive rectangles drawn on top

5/12/2003 R. Crawfis, Ohio State Univ. 75

Texture-based Volume Rendering

For a given viewing direction, we would need to select slices perpendicular to this directionThis requires interpolation to get the values on the slicesOnly expensive 3D texture hardware can do this fast enough…

imageplane

volume

3D texture mapping

5/12/2003 R. Crawfis, Ohio State Univ. 76

Texture-based Volume Rendering

Simpler solution - 2D texture mapping:view volume as set of slices parallel to co-

ordinate planes

choose the orientation best suited to viewing direction

5/12/2003 R. Crawfis, Ohio State Univ. 77

Texture Mapping

2D image 2D polygon

+

Textured-mappedpolygon

Page 2: Texture-based Volume Rendering Texture Mappingweb.cse.ohio-state.edu/~crawfis.3/cis694L/Slides/TextureSlicing.pdf · the slicing planes are always parallel to the view plane 5/12/2003

2

5/12/2003 R. Crawfis, Ohio State Univ. 78

Texture Mapping (2)

(0,0) (1,0)

(0,1) (1,1)

Each texel has 2D coordinates assignedto it.

assign the texture coordinatesto each polygon to establish the mapping

(0,0.5) (0.5,0.5)

(0,0) (0.5,0)

5/12/2003 R. Crawfis, Ohio State Univ. 79

Tex. Mapping for Volume Rendering

Remember ray casting …

y

z

5/12/2003 R. Crawfis, Ohio State Univ. 80

Texture based volume rendering

x

zy

• Render each xz slice in the volume as a texture-mapped polygon• The texture contains RGBA (color and opacity) • The polygons are drawn from back to front

5/12/2003 R. Crawfis, Ohio State Univ. 81

Texture based volume rendering

5/12/2003 R. Crawfis, Ohio State Univ. 82

Changing Viewing Direction

What if we change the viewing position?

That is okay, we justchange the eye position(or rotate the polygonsand re-render),

Until …

x

y

5/12/2003 R. Crawfis, Ohio State Univ. 83

Changing View Direction (2)

Until … You are not going to see anything this way …

This is because the view direction now is Parallel to the slice planes

What do we do?

x

y

Page 3: Texture-based Volume Rendering Texture Mappingweb.cse.ohio-state.edu/~crawfis.3/cis694L/Slides/TextureSlicing.pdf · the slicing planes are always parallel to the view plane 5/12/2003

3

5/12/2003 R. Crawfis, Ohio State Univ. 84

Switch Slicing Planes

What do we do?

• Change the orientation of slicing planes

• Now the slice polygons are parallel to YZ plane in the object space

x

y

5/12/2003 R. Crawfis, Ohio State Univ. 85

Some Considerations… (5)

When do we need to change the slicing orientation?

When the major component of view vector changes from y to -x

x

y

5/12/2003 R. Crawfis, Ohio State Univ. 86

Major component of view vector?

Given the view vector (x,y,z) -> get the maximal component

If x: then the slicing planes are parallel to yz planeIf y: then the slicing planes are parallel to xz planeIf z: then the slicing planes are parallel to xy plane

-> This is called (object-space) axis-aligned method.

Some Considerations… (6)

5/12/2003 R. Crawfis, Ohio State Univ. 87

Three copies of data needed

x

zy

xz slices yz slices xy slices

•We need to reorganize the input textures for diff. View directions.

• Reorganize the textures on the fly is too time consuming. We want to prepare the texture sets beforehand

5/12/2003 R. Crawfis, Ohio State Univ. 88

Texture based volume rendering

Algorithm: (using 2D texture mapping hardware)

Turn off the depth test; Enable blendingFor (each slice from back to front) {

- Load the 2D slice of data into texture memory- Create a polygon corresponding to the slice- Assign texture coordinates to four corners of the polygon

- Render and blend the polygon (use OpenGLalpha blending) to the frame buffer

}

5/12/2003 R. Crawfis, Ohio State Univ. 89

Problem (1)

Non-even sampling rate

d d’ d’’

d’’ > d’ > d Sampling artifact will become visible

Page 4: Texture-based Volume Rendering Texture Mappingweb.cse.ohio-state.edu/~crawfis.3/cis694L/Slides/TextureSlicing.pdf · the slicing planes are always parallel to the view plane 5/12/2003

4

5/12/2003 R. Crawfis, Ohio State Univ. 90

Problem (2)

Object-space axis-aligned method can create artifacts:Popping Effect

There is a sudden change of slicing direction when the view vector transitions from one major direction to another.The change in the image intensity can be quite visible

x

y

5/12/2003 R. Crawfis, Ohio State Univ. 91

Solution (1)

Insert intermediate slides to maintain the sampling rate

d d’ d’’

5/12/2003 R. Crawfis, Ohio State Univ. 92

Solution (2)

Use Image-space axis-aligned slicing plane:

the slicing planes are always parallel to the view plane

5/12/2003 R. Crawfis, Ohio State Univ. 93

3D Texture Based Volume Rendering

5/12/2003 R. Crawfis, Ohio State Univ. 94

3D Texture Mapping

Arbitrary slicing through the volume and texturemapping capabilities are needed

- Arbitrary slicing polygon: this can be computed using software in real time

This is basically polygon-volumeclipping

5/12/2003 R. Crawfis, Ohio State Univ. 95

Slice-Interpolated Volume Rendering

color

opacity

object (color, opacity)Similar to raycasting with simultaneous rays1.0

Page 5: Texture-based Volume Rendering Texture Mappingweb.cse.ohio-state.edu/~crawfis.3/cis694L/Slides/TextureSlicing.pdf · the slicing planes are always parallel to the view plane 5/12/2003

5

5/12/2003 R. Crawfis, Ohio State Univ. 96

3D Texture Mapping

Texture mapping to the arbitrary slices

This requires 3D texture mapping harware

Input texture: volume (pre-classified and shaded)essentially an (R,G,B,α) volume

Depending on the position of the polygon, appropriate textures are resampled, constructed andmapped to the polygon.

5/12/2003 R. Crawfis, Ohio State Univ. 97

Solid (3D) Texture Mapping

Now the input texture space is 3D

Texture coordinates: (r,s,t)

(0,0,0) (1,0,0)

(0,1,0)(1,1,0)

(0,1,1) (1,1,1)

(r0,s0,t0) (r1,s1,t1)

(r2,s2,t2) (r3,s3,t3)

5/12/2003 R. Crawfis, Ohio State Univ. 98

Slice Based Rendering

Volume Data

Eye

Image plane

Graphics Hardware•Polygons – Proxy geometry

•Textures – Data & interpolation

•Blending operations – Numerical integration

Slices

5/12/2003 R. Crawfis, Ohio State Univ. 99

Slice Based Rendering

View direction

1 slice

5 slices

20 slices 45 slices 85 slices 170 slices

Slices

5/12/2003 R. Crawfis, Ohio State Univ. 100

Slice Based Problems?

Does not perform correct IlluminationAccumulation - but can get close

Can not easily add correct illumination and shadowing

See the Van Gelder paper for their addition for illumination⌧Stored in LUT quantized normal vector directions

See Kniss papers (Utah) for use of vertex shadersand new hardware to solve many of these problems.

5/12/2003 R. Crawfis, Ohio State Univ. 101

Lighting and Shading

3D texture mapping with hardware tricks to achieve lighting is becoming feasible.

C. Lao, OSU

Page 6: Texture-based Volume Rendering Texture Mappingweb.cse.ohio-state.edu/~crawfis.3/cis694L/Slides/TextureSlicing.pdf · the slicing planes are always parallel to the view plane 5/12/2003

6

5/12/2003 R. Crawfis, Ohio State Univ. 102

Pros and ConsAdvantages: - Fast with volume sizes that the hardware can take

e.g. 2 fps for 256 cube volumes- No popping effect

Disadvantages: - Need to compute the slicing planes for every view angle

- only supported on high end hardware- low quality without per-pixel classification shading

and classification (i.e. post-classification and shading)

Both 2D or 3D hardware texture mapping methods can not computeshading on the fly. The input textures have to be pre-shaded.

With multi-texturing functions, per-pixel shading and classification arebecoming possible.