Graphics Without Polygons Volume Rendering May 11, 2010
So Far Volumetric Rendering Techniques Misc.
So Far Extended the Fixed Function Pipeline with a Programmable Pipeline Programming the pipeline is done using vertex and fragment programs written in Cg Shaders loaded and compiled in one go, or commmand-line Loaded onto graphics card Pipeline values usable through binding sematics enable and disable shaders similar to enabling and disabling textures Examples given which shows how to do per-pixel calculations using vectors from different spaces (phong lighting, projective textures, fake bump, tangent bump, toon shading, shadow maps) Introduced OpenGL extensions and GLEW Examples of point size calculations, point sprites and off screen rendering given. Reading Material CgUsersManual, CgReferenceManual, the GPU Gems Series (html), OpenGL Extension Registry
Volumetric Rendering Volumetric Rendering
Volumetric Rendering Why Volumetric Rendering Data not always polygons Data can be fields, intensities etc... Scalar values in (multi dimensional) arrays Point-clouds Converting to polygons looses information... or creates lots of surfaces! Polygonizing a scalar field can be done by marching cubes algorithm Still need rendering
Volumetric Rendering Example Sets
Techniques Pointbased Surfaces represented as many points. Renders point-wise: billboarded splat - always orthogonal to camera 3D primitive not widely used Volume Textures Raytracing/raymarching photorealism slower Slices-based fast! approximates photorealism.
Techniques Pointbased Splatting Point based splatting: Surface represented by a large set of points Render a splat instead of a point square, opaque/fuzzy circle. Use subsequent filter to smooth out gaps between points
Techniques QSplat - Example Interactive: High Quality: 8 Frames Per Second 8 Seconds Per Frame Closeup Closeup
Techniques Pointbased Splatting - cont. Point based hierarchy: Surface represented by a large set of points Points ordered in a (spherical) hierarcy Size of splat determined from size of sphere Filter paramater varies with density of points on the surface and the density of points on screen.
Techniques Hierarchy example
Volume Textures: Uses a 3D image as data Intensities - Medical Data Distances - Iso-Surfaces Proxy Geometry: Image is encapsulated in 3D Geometry Represent the volume containing the data. Analoguous to 2D texture mapping. The Box: 3D scans are cubic (cubic datasets) convex easier maths In OpenGL GL TEXTURE 3D
Raymarching March through proxy geometry along ray One ray for each pixel on screen Collect information at all points Pros: Cons: Calculate color based on this information. Fairly easy math. Can capture internal light very good Expensive Lots of sample points - multiplies pre lightsource. Doesn t fit directly onto graphics hardware
Raymarching Example Virtual Ear Simulator:
Raymarching Example Virtual Ear Simulator:
Slice Based Volume Rendering Use primitives instead of rays Cheaper, and much faster Fits better to rendering pipeline Samples a lot of points at once, a ray only samples one. Easy math: Clipping of proxy-geometry and primitive Photorealism harder. Example: Planes as primitive and proxy geometry is a box: Sampling, number of planes increases through a, b and c.
Clipping the Geometry A plane is described by equation ax + by + cz + d = 0, d is shortest distance from center to surface. A line between points p 1,p 2 is described by: l = p 1 + (p 2 p 1 )t, 0 t 1 Coordinates: l x = p 1x + (p 2x p 1x )t = p 1x + it l y = p 1y + (p 2y p 1y )t = p 1y + jt l z = p 1z + (p 2z p 1z )t = p 1z + kt Insert lx,ly and lz for x,y,z in plane eq. Solve for t: t = (ap 1x + bp 1y + cp 1z + d) (ai + bj + ck) Special cases: denominator = 0: line is parallel to plane denominator and nominator = 0: line is contained in plane. NB: t is the same for calculating texture coordinates.
Drawing the geometry Need the rotated coords of proxy geometry: get transformation from top of OpenGL matrix stack implement rotations Cut from back to front eliminates the need for sorting explicitly Cleaning up the cut geometry Remove duplicates Sort according to rotational order calculate angles using inverse tan. We now have a polygon contained in the cut-plane. Both 3d-coordinates and texture-coordinates have been calculated. The coords are sorted, so we just use glbegin(gl POLYGON).
Blending Use an additive blend. uniform opacity, A, for the slices Opacity correction: A = 1 (1 A0) (s0/s), A0 and s0 are determined from dataset s is the sampling rate, ie. number of primitives. usually (s0/s) and number of slices can be determined via user interface.
Example Example
Transfer Function Transfer function: Purpose: Emphasize features in the dataset by mapping values to optical properties. Often implemented by using a Look-Up Table (LUT). Can be multidimensional, using gradients etc. Can be implemented on GPU.
Transfer Function Pick Iso-value:
Transfer Function Gradient of low intensities
Transfer Function Transfer functions per color component:
Advanced Features Advanced Features:... possible extensions in a project. 2D - LUT Lighting Procedural Renderings adding noise to low-res datasets calculating the dataset Calculating intersection on GPU Etc...
Misc. Exercises Monday and Friday this week But, no code handed out! Monday in week 21 is a holiday. Exercises: Continue working on previous exercises Make sure you get an understanding of working with vector in different spaces Animating Point Sprites 3D texture? Look into ClipPlanes Decide on project
Misc. References Realtime Rendering Qsplat http://graphics.stanford.edu/software/qsplat/ GPU Gems I, Chapter 39 http://http.developer.nvidia.com/gpugems/gpugems_ch39.html Virtual Ear Simulator http://www.jespermosegaard.dk/projects