University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Blending, Modern Hardware.

Slides:



Advertisements
Similar presentations
COMPUTER GRAPHICS SOFTWARE.
Advertisements

CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
COMPUTER GRAPHICS CS 482 – FALL 2014 NOVEMBER 10, 2014 GRAPHICS HARDWARE GRAPHICS PROCESSING UNITS PARALLELISM.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Graphics Pipeline.
CS-378: Game Technology Lecture #9: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
9/25/2001CS 638, Fall 2001 Today Shadow Volume Algorithms Vertex and Pixel Shaders.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Visualization Week 11,
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Virtual Trackball, Scientific.
The Programmable Graphics Hardware Pipeline Doug James Asst. Professor CS & Robotics.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Curves Week 12, Wed Apr.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Information Visualization.
CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics April 19, 2007.
Control Flow Virtualization for General-Purpose Computation on Graphics Hardware Ghulam Lashari Ondrej Lhotak University of Waterloo.
Morphing and Animation GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from articles taken from ShaderX 3, 4 and 5 And GPU Gems 1.
A Crash Course on Programmable Graphics Hardware Li-Yi Wei 2005 at Tsinghua University, Beijing.
Skin Rendering GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from David Gosselin’s Power Point and article, Real-time skin rendering,
IN4151 Introduction 3D graphics 1 Introduction to 3D computer graphics part 2 Viewing pipeline Multi-processor implementation GPU architecture GPU algorithms.
Status – Week 277 Victor Moya.
The Graphics Pipeline CS2150 Anthony Jones. Introduction What is this lecture about? – The graphics pipeline as a whole – With examples from the video.
Compilation, Architectural Support, and Evaluation of SIMD Graphics Pipeline Programs on a General-Purpose CPU Mauricio Breternitz Jr, Herbert Hum, Sanjeev.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Using Vertex Shader in DirectX 8.1 강 신 진
Programmable Pipelines. 2 Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Lecture 3 : Direct Volume Rendering Bong-Soo Sohn School of Computer Science and Engineering Chung-Ang University Acknowledgement : Han-Wei Shen Lecture.
Chris Kerkhoff Matthew Sullivan 10/16/2009.  Shaders are simple programs that describe the traits of either a vertex or a pixel.  Shaders replace a.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
Cg Programming Mapping Computational Concepts to GPUs.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 Going-through.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Stream Processing Main References: “Comparing Reyes and OpenGL on a Stream Architecture”, 2002 “Polygon Rendering on a Stream Architecture”, 2000 Department.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
COMPUTER GRAPHICS CSCI 375. What do I need to know?  Familiarity with  Trigonometry  Analytic geometry  Linear algebra  Data structures  OOP.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Programmable Pipelines Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
A User-Programmable Vertex Engine Erik Lindholm Mark Kilgard Henry Moreton NVIDIA Corporation Presented by Han-Wei Shen.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Lab: Vertex Shading Chris Wynn Ken Hurley. Objective Hands-On vertex shader programming Start with simple programs … Part 1: Textured-Lit Teapot.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
09/25/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Shadows Stage 2 outline.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Mesh Skinning Sébastien Dominé. Agenda Introduction to Mesh Skinning 2 matrix skinning 4 matrix skinning with lighting Complex skinning for character.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
An Introduction to the Cg Shading Language Marco Leon Brandeis University Computer Science Department.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
GPU Architecture and Its Application
COMPUTER GRAPHICS CHAPTER 38 CS 482 – Fall 2017 GRAPHICS HARDWARE
- Introduction - Graphics Pipeline
Programmable Pipelines
A Crash Course on Programmable Graphics Hardware
Graphics Processing Unit
Deferred Lighting.
Chapter 6 GPU, Shaders, and Shading Languages
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Introduction to Programmable Hardware
Graphics Processing Unit
Where does the Vertex Engine fit?
Computer Graphics Introduction to Shaders
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
Presentation transcript:

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Blending, Modern Hardware Week 12, Mon Apr 2

2 Old News extra TA office hours in lab for hw/project Q&A next week: Thu 4-6, Fri 10-2 last week of classes: Mon 2-5, Tue 4-6, Wed 2-4, Thu 4-6, Fri 9-6 final review Q&A session Mon Apr reminder: no lecture/labs Fri 4/6, Mon 4/9

3 New News project 4 grading slots signup Wed Apr Wed Apr Fri Apr

4 Review: Volume Graphics for some data, difficult to create polygonal mesh voxels: discrete representation of 3D object volume rendering: create 2D image from 3D object translate raw densities into colors and transparencies different aspects of the dataset can be emphasized via changes in transfer functions

5 Review: Volume Graphics pros formidable technique for data exploration cons rendering algorithm has high complexity! special purpose hardware costly (~$3K-$10K) volumetric human head (CT scan)

6 Review: Isosurfaces 2D scalar fields: isolines contour plots, level sets topographic maps 3D scalar fields: isosurfaces

7 Review: Isosurface Extraction array of discrete point samples at grid points 3D array: voxels find contours closed, continuous determined by iso-value several methods marching cubes is most common Iso-value = 5

8 Review: Marching Cubes create cube classify each voxel binary labeling of each voxel to create index use in array storing edge list all 256 cases can be derived from 15 base cases interpolate triangle vertex calculate the normal at each cube vertex render by standard methods

9 Review: Direct Volume Rendering Pipeline Classify Shade Interpolate Composite do not compute surface

10 Review: Transfer Functions To Classify map data value to color and opacity can be difficult, unintuitive, and slow f  f  f  f  Gordon Kindlmann

11 Review: Volume Rendering Algorithms ray casting image order, forward viewing splatting object order, backward viewing texture mapping object order back-to-front compositing

12 Review: Ray Casting Traversal Schemes Depth Intensity Max Average Accumulate First

13 Blending

14 Rendering Pipeline Geometry Database Geometry Database Model/View Transform. Model/View Transform. Lighting Perspective Transform. Perspective Transform. Clipping Scan Conversion Scan Conversion Depth Test Depth Test Texturing Blending Frame- buffer Frame- buffer

15 Blending/Compositing how might you combine multiple elements? foreground color A, background color B

16 Premultiplying Colors specify opacity with alpha channel: (r,g,b,  )  =1: opaque,  =.5: translucent,  =0: transparent A over B C =  A + (1-  )B 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 premultiplying by alpha C’ =  C, B’ =  B, A’ =  A C’ = B’ + A’ -  B’  =  +  –  1 multiply to find C, same equations for alpha and RGB

17 Modern GPU Features

18 Reading FCG Chap17 Using Graphics Hardware especially 17.3 FCG Section 3.8 Image Capture and Storage

19 Rendering Pipeline so far rendering pipeline as a specific set of stages with fixed functionality modern graphics hardware more flexible programmable “vertex shaders” replace several geometry processing stages programmable “fragment/pixel shaders” replace texture mapping stage hardware with these features now called Graphics Processing Unit (GPU)

20 Modified Pipeline vertex shader replaces model/view, lighting, and perspective have to implement these yourself but can also implement much more fragment/pixel shader replaces texture mapping fragment shader must do texturing but can do other things

21 Vertex Shader Motivation hardware transform and lighting: i.e. hardware geometry processing was mandated by need for higher performance in the late 90s previously, geometry processing was done on CPU, except for very high end machines downside: now limited functionality due to fixed function hardware

22 Vertex Shaders programmability required for more complicated effects tasks that come before transformation vary widely putting every possible lighting equation in hardware is impractical implementing programmable hardware has advantages over CPU implementations better performance due to massively parallel implementations lower bandwidth requirements (geometry can be cached on GPU)

23 Vertex Program Properties run for every vertex, independently access to all per-vertex properties position, color, normal, texture coords, other custom properties access to read/write registers for temporary results value is reset for every vertex cannot pass information from one vertex to the next access to read-only registers global variables like light position, transformation matrices write output to a specific register for resulting color

24 Vertex Shaders/Programs concept programmable pipeline stage floating-point operations on 4 vectors points, vectors, and colors! replace all of model/view transformation lighting perspective projection

25 Vertex Shaders/Programs a little assembly-style program is executed on every individual vertex it sees: vertex attributes that change per vertex: position, color, texture coordinates… registers that are constant for all vertices (changes are expensive): matrices, light position and color, … temporary registers output registers for position, color, tex coords…

26 Vertex Programs Instruction Set arithmetic operations on 4-vectors: ADD, MUL, MAD, MIN, MAX, DP3, DP4 operations on scalars RCP (1/x), RSQ (1/  x), EXP, LOG specialty instructions DST (distance: computes length of vector) LIT (quadratic falloff term for lighting) very latest generation: loops and conditional jumps still more expensive than straightline code

27 Vertex Programs Applications what can they be used for? can implement all of the stages they replace but can allocate resources more dynamically e.g. transforming a vector by a matrix requires 4 dot products enough memory for 24 matrices can arbitrarily deform objects procedural freeform deformations lots of other applications shading refraction …

28 Skinning want to have natural looking joints on human and animal limbs requires deforming geometry, e.g. single triangle mesh modeling both upper and lower arm if arm is bent, upper and lower arm remain more or less in the same shape, but transition zone at elbow joint needs to deform

29 Skinning approach: multiple transformation matrices more than one model/view matrix stack, e.g. one for model/view matrix for lower arm, and one for model/view matrix for upper arm every vertex is transformed by both matrices yields 2 different transformed vertex positions! use per-vertex blending weights to interpolate between the two positions

30 Skinning arm example: M1: matrix for upper arm M2: matrix for lower arm Upper arm: weight for M1=1 weight for M2=0 Lower arm: weight for M1=0 weight for M2=1 Transition zone: weight for M1 between 0..1 weight for M2 between 0..1

31 Skinning Example by NVIDIA

32 Skinning in general: many different matrices make sense! EA facial animations: up to 70 different matrices (“bones”) hardware supported: number of transformations limited by available registers and max. instruction count of vertex programs but dozens are possible today

33 Fragment Shader Motivation idea of per-fragment shaders not new Renderman is the best example, but not at all real time traditional pipeline: only major per-pixel operation is texturing all lighting, etc. done in vertex processing, before primitive assembly and rasterization in fact, a fragment is only screen position, color, and tex-coords normal vector info is not part of a fragment, nor is world position what kind of shading interpolation does this restrict you to?

34 Fragment Shader Generic Structure

35 Fragment Shaders fragment shaders operate on fragments in place of texturing hardware after rasterization before any fragment tests or blending input: fragment, with screen position, depth, color, and set of texture coordinates access to textures, some constant data, registers compute RGBA values for fragment, and depth can also kill a fragment (throw it away) two types of fragment shaders register combiners (GeForce4) fully programmable (GeForceFX, Radeon 9700)

36 Fragment Shader Functionality consider requirements for Phong shading how do you get normal vector info? how do you get the light? how do you get the specular color? how do you get the world position?

37 Shading Languages programming shading hardware still difficult akin to writing assembly language programs

38 Vertex Program Example #blend normal and position # v=  v 1 +(1-  )v 2 =  (v 1 -v 2 )+ v 2 MOV R3, v[3] ; MOV R5, v[2] ; ADD R8, v[1], -R3 ; ADD R6, v[0], -R5 ; MAD R8, v[15].x, R8, R3 MAD R6, v[15].x, R6, R5 ; # transform normal to eye space DP3 R9.x, R8, c[12] ; DP3 R9.y, R8, c[13] ; DP3 R9.z, R8, c[14] ; # transform position and output DP4 o[HPOS].x, R6, c[4] ; DP4 o[HPOS].y, R6, c[5] ; DP4 o[HPOS].z, R6, c[6] ; DP4 o[HPOS].w, R6, c[7] ; # normalize normal DP3 R9.w, R9, R9 ; RSQ R9.w, R9.w ; MUL R9, R9.w, R9 ; # apply lighting and output color DP3 R0.x, R9, c[20] ; DP3 R0.y, R9, c[22] ; MOV R0.zw, c[21] ; LIT R1, R0 ; DP3 o[COL0], c[21], R1 ;

39 Vertex Programming Example example (from Stephen Cheney) morph between a cube and sphere while doing lighting with a directional light source (gray output) cube position and normal in attributes (input) 0,1 sphere position and normal in attributes 2,3 blend factor in attribute 15 inverse transpose model/view matrix in constants used to transform normal vectors into eye space composite matrix is in 4-7 used to convert from object to homogeneous screen space light dir in 20, half-angle vector in 22, specular power, ambient, diffuse and specular coefficients all in 21

40 Shading Languages programming shading hardware still difficult akin to writing assembly language programs shading languages and accompanying compilers allow users to write shaders in high level languages examples Microsoft’s HLSL (part of DirectX 9) Nvidia’s Cg (compatable with HLSL) OpenGL Shading Language (Renderman is ultimate example, but not real time)

41 Cg Cg is a high-level language developed by NVIDIA looks like C or C++ actually a language and a runtime environment can compile ahead of time, or compile on the fly what it can do is tightly tied to the hardware

42 Vertex Program Example

43 Pixel Program Example

44 Cg Runtime sequence of commands to get your Cg program onto the hardware

45 Bump Mapping normal mapping approach: directly encode the normal into the texture map (R,G,B)= (x,y,z), appropriately scaled then only need to perform illumination computation interpolate world-space light and viewing direction from the vertices of the primitive can be computed for every vertex in a vertex shader get interpolated automatically for each pixel in the fragment shader: transform normal into world coordinates evaluate the lighting model

46 Bump Mapping examples

47 GPGPU Programming General Purpose GPU use graphics card as SIMD parallel processor textures as arrays computation: render large quadrilateral multiple rendering passes

48 Image Formats major issue: lossless vs. lossy compression JPEG is lossy compression do not use for textures loss carefully designed to be hard to notice with standard image use texturing will expose these artifacts horribly! can convert to other lossless formats, but information was permanently lost

49 Acknowledgements Wolfgang Heidrich