University of British Columbia Old News New News Review: Volume Graphics CPSC 314 Computer Graphics • extra TA office hours in lab for hw/project • project 4 grading slots signup • for some data, difficult to create polygonal mesh Jan-Apr 2007 Q&A • voxels: discrete representation of 3D object • Wed Apr 18 10-12 Tamara Munzner • next week: Thu 4-6, Fri 10-2 • volume rendering: create 2D image from 3D object • Wed Apr 18 4-6 • translate raw densities into colors and • last week of classes: • Fri Apr 20 10-1 transparencies Blending, Modern Hardware • Mon 2-5, Tue 4-6, Wed 2-4, Thu 4-6, Fri 9-6 • different aspects of the dataset can be emphasized • final review Q&A session via changes in transfer functions Week 12, Mon Apr 2 • Mon Apr 16 10-12 • reminder: no lecture/labs Fri 4/6, Mon 4/9 http://www.ugrad.cs.ubc.ca/~cs314/Vjan2007 2 3 4 Review: Volume Graphics Review: Isosurfaces Review: Isosurface Extraction Review: Marching Cubes • create cube • pros • 2D scalar fields: isolines • array of discrete point 0 1 1 3 2 • classify each voxel 11110100 samples at grid points • formidable technique for data exploration • contour plots, level sets • binary labeling of each voxel to create • 3D array: voxels index • cons • topographic maps 1 3 6 6 3 • use in array storing edge list • find contours • rendering algorithm has high complexity! • 3D scalar fields: isosurfaces • all 256 cases can be derived from 15 base cases 3 7 9 7 3 • closed, continuous • special purpose hardware costly (~$3K-$10K) • interpolate triangle vertex • determined by iso-value • calculate the normal at each cube 2 7 8 6 2 vertex • several methods • render by standard methods • marching cubes is most 1 2 3 4 3 common Iso-value = 5 volumetric human head (CT scan) 5 6 7 8 Review: Transfer Functions To Classify Review: Volume Rendering Algorithms Review: Ray Casting Traversal Schemes Review: Direct Volume Rendering Pipeline • map data value to color and opacity • ray casting • do not compute surface • can be difficult, unintuitive, and slow Intensity • image order, forward viewing Max Classify α α • splatting Average • object order, backward viewing Shade f f • texture mapping Accumulate Interpolate α α First • object order • back-to-front compositing Composite f f Depth 9 10 11 12 Gordon Kindlmann Rendering Pipeline Blending/Compositing Premultiplying Colors • specify opacity with alpha channel: (r,g,b, α ) • how might you combine multiple elements? • α =1: opaque, α =.5: translucent, α =0: transparent • foreground color A , background color B Model/View Geometry Geometry Model/View Perspective Perspective • A over B Lighting Lighting Clipping Clipping Transform. • C = α A + (1- α ) B Database Database Transform. Transform. Transform. Blending • but what if B is also partially transparent ? • C = α A + (1- α ) β B = β B + α A + β B - α β B • γ = β + (1- β ) α = β + α – αβ • 3 multiplies, different equations for alpha vs. RGB Scan Frame- Frame- Scan Depth Depth Texturing Texturing Blending Blending Conversion buffer buffer Conversion Test Test • premultiplying by alpha • C’ = γ C, B’ = β B, A’ = α A • C’ = B’ + A’ - α B’ • γ = β + α – αβ • 1 multiply to find C, same equations for alpha and RGB 13 14 15 16
Reading Rendering Pipeline Modified Pipeline • so far • FCG Chap17 Using Graphics Hardware • vertex shader • replaces model/view, • rendering pipeline as a specific set of stages • especially 17.3 lighting, and perspective with fixed functionality • FCG Section 3.8 Image Capture and Storage • have to implement these • modern graphics hardware more flexible yourself Modern GPU Features • but can also implement • programmable “vertex shaders” replace much more several geometry processing stages • fragment/pixel shader • programmable “fragment/pixel shaders” • replaces texture mapping replace texture mapping stage • fragment shader must do • hardware with these features now called texturing Graphics Processing Unit (GPU) • but can do other things 17 18 19 20 Vertex Shader Motivation Vertex Shaders Vertex Program Properties Vertex Shaders/Programs • hardware transform and lighting: • programmability required for more complicated • run for every vertex, independently • concept effects • i.e. hardware geometry processing • access to all per-vertex properties • programmable pipeline stage • tasks that come before transformation vary widely • was mandated by need for higher • position, color, normal, texture coords, other custom • floating-point operations on 4 vectors properties performance in the late 90s • putting every possible lighting equation in hardware • points, vectors, and colors! is impractical • access to read/write registers for temporary results • previously, geometry processing was done on • replace all of • implementing programmable hardware has • value is reset for every vertex CPU, except for very high end machines • model/view transformation advantages over CPU implementations • cannot pass information from one vertex to the next • downside: now limited functionality due to • better performance due to massively parallel • access to read-only registers • lighting fixed function hardware implementations • global variables like light position, transformation • perspective projection • lower bandwidth requirements (geometry can be matrices cached on GPU) • write output to a specific register for resulting color 21 22 23 24 Vertex Shaders/Programs Vertex Programs Instruction Set Vertex Programs Applications Skinning • arithmetic operations on 4-vectors: • what can they be used for? • a little assembly-style program is executed on every individual vertex • ADD, MUL, MAD, MIN, MAX, DP3, DP4 • can implement all of the stages they replace • want to have natural looking joints on human • operations on scalars • but can allocate resources more dynamically • it sees: and animal limbs • RCP (1/x), RSQ (1/ √ x), EXP, LOG • e.g. transforming a vector by a matrix requires 4 dot • vertex attributes that change per vertex: products • requires deforming geometry, e.g. • specialty instructions • position, color, texture coordinates… • enough memory for 24 matrices • single triangle mesh modeling both upper and • DST (distance: computes length of vector) • registers that are constant for all vertices (changes • can arbitrarily deform objects lower arm • LIT (quadratic falloff term for lighting) are expensive): • procedural freeform deformations • if arm is bent, upper and lower arm remain • lots of other applications • matrices, light position and color, … more or less in the same shape, but transition • shading • very latest generation: • temporary registers • refraction zone at elbow joint needs to deform • loops and conditional jumps • output registers for position, color, tex coords… • … • still more expensive than straightline code 25 26 27 28 Skinning Skinning Skinning Skinning • approach: • arm example: • • in general: • multiple transformation matrices • M1: matrix for upper arm • many different matrices make sense! • more than one model/view matrix stack, e.g. • M2: matrix for lower arm • EA facial animations: up to 70 different matrices (“bones”) • one for model/view matrix for lower arm, and Upper arm: Upper arm: • one for model/view matrix for upper arm • hardware supported: weight for M1=1 weight for M1=1 • every vertex is transformed by both matrices weight for M2=0 weight for M2=0 • number of transformations limited by available Lower arm: Lower arm: registers and max. instruction count of vertex • yields 2 different transformed vertex positions! weight for M1=0 weight for M1=0 programs • use per-vertex blending weights to interpolate weight for M2=1 weight for M2=1 • but dozens are possible today between the two positions Transition zone: Transition zone: weight for M1 between 0..1 weight for M1 between 0..1 Example Example weight for M2 between 0..1 weight for M2 between 0..1 by NVIDIA by NVIDIA 29 30 31 32
Recommend
More recommend