computer graphics (cs 563) advanced graphicsemmanuel/courses/cs563/s12/slides/cs563...shaders:...
TRANSCRIPT
Computer Graphics (CS 563) Lecture 1: Advanced Computer Graphics
Prof Emmanuel Agu
Computer Science Dept.Worcester Polytechnic Institute (WPI)
Photorealistic Rendering Photorealistic? Indistinguishable from picture Main concern: Realism. Slow: Does NOT care how long it takes (hours, days) Example photorealistic algorithm: Ray tracing images
Real Time Rendering Some applications re‐render moving objects many times per second = Real‐time rendering
Examples: Games Flight simulators Virtual reality Augmented reality, etc
• Real Time graphics: Milliseconds to render (30 FPS)But lower image quality
What is Real‐Time Rendering? How fast should real‐time rendering happen? Rendering speed measured in Frames Per Second (fps) About 72 fps guarantees that user:
becomes immersed in graphics experience No distraction of waiting for rendering to complete Smooth interaction
So, we can say 30 fps upwards is real‐time Frank Cho, electronics arts, algorithms must run in at least
30 fps (minimum) Images produced must have feel of 3D graphics
Photorealistic Vs Real‐Time GraphicsEach frame takes Less than 0.033 seconds
Hours to render
Ray tracing rendering time is over 10,000x that of real‐time render!!
But is the image quality 10,000x better?
Applications of Real‐Time Rendering
Computer Games
Courtesy: Super Mario Galaxy 2
Courtesy: Final Fantasy XIV
Applications of Real‐Time Rendering
Flight simulators, virtual worlds
Courtesy: Evans and Sutherland Courtesy: PC Mag
About This Course Focus this semester on Real time rendering Emphasis on real‐time global illumination techniques
Previous editions: focussed on Photo‐realisticRendering Advances in ray tracing Photon mapping
Appearance Modeling BRDFs /materials (representations, viewers, acquisition) Rendering humans (face, skin) Rendering nature (water, trees, seashells) Rendering animals (feathers, butterflies)
Basically, entire semester of ray tracing
Professor Background
Dr. Emmanuel Agu (professor, “Emmanuel”) Research areas Computer Graphics (real time/photorealistic rendering, etc) Mobile computing (Healthcare apps on smartphone, etc) Mobile graphics (games on mobile devices, mobile 3D, etc)
Research opportunities Independent Study Project MQP MS theses PhD theses
Student Background
Name Class (undergrad (seniors), masters, PhD …) Full and Part‐time student Programming experience (C, C++, java) Graphics background
At least one graphics class taken Solid math skills…. Other (Physics, computer vision, image science, ???)
Students intro themselves Fill in above info, say what you want from this class
Course Prerequisites No official prerequisite However, will assume you Have probably taken at least 1 graphics course (OpenGL?) Can quickly learn graphics representations and techniques,
(will briefly cover them in class as needed) have background in calculus, linear algebra Can read book(s), research articles, fill in gaps Can learn rendering package, shading language, use it
Still have questions? See me
Syllabus
http://web.cs.wpi.edu/~emmanuel/courses/cs563/S12/ Office hours: Tuesdays: 4:00‐5:00pm Other times by appointment
Email me if you have specific questions Text Book: Real‐Time Rendering by Akenine‐Moller, Haines
and Hoffman plus selected papers See online course paper schedule Text takes survey‐style approach:
Give overview, When to use specific techniques Where to find more information
Grading No exams Presentations each (30%) Class participation (10%) Projects defined by me (30%) Final project, chosen by you (30%) Projects for this course Small stand‐alone shader (OpenGL) programs Real time rendering platform (e.g. Ogre)
Why this course? Understand state‐of‐the‐art real‐time graphics techniques Become conversant with cutting edge graphics literature Hands‐on exploration of a selection of the techniques
encountered Use cutting edge shading language(s), rendering package(s),
graphics card(s) Possibly extend one of the algorithms/techniques
Class Time
Two halves with 15 minutes break Each half 45 minute presentation followed by 30 minute discussion of topic(s) and questions
Presentations My goal is to guide you how to present effectively I will be strict with time (no breaks when presenting at
conferences!!) Get right to the point (core), offer motivation & insights Communicate basic ideas to fellow students Offer a ‘roadmap’ for studying the paper/readings Look over reading list & let me know which paper/readings you
want to present Note: can use any resources (videos, Internet images) to build
your talk. Must give credit. If not.. Cheating!!! Don’t just summarize! Find authors websites, videos, images,
supplimentary cool stuff
Presentations Common mistakes: Avoid: putting too much on a slide (talk!!) Too many slides for alloted time (approx 2 mins/slide) 45 mins time? Estimate: 25 slides max!
Student presentations start in week 4
Final Project Implement one of the RT rendering techniques discussed in
class, use shading language? Game engine? May also use high end package to create models Maya Renderman Blender PovRay, etc
Must submit your final project proposal by March 20, 2012 Can get ambitious: convert photorealistic technique to real time Ideas?? See Stanford rendering competition http://graphics.stanford.edu/courses/cs348b‐competition/
Where to do Projects? Most self‐respecting home PC’s have a graphics card Some PCs even have sweet Nvidia or ATI cards You can use your home computer or on‐campus labs Remember you will demo project at the end Six labs on campus support OpenGL 3.3 or 4.0 Gordon's Library Salisbury Labs 123 Stratton Hall 003 (Math Lab) Washburn 226 Higgins Lab 230 Kaven Hall 203
Supplementary Books
Will place the supplementary books on reserve: On reserve in the library under CS 563 folder Randy Rost et al "OpenGL Shading Language", Addison
Wesley publishers, 2009 More to come..
About This Course Previous versions of class
Students chose any topics they liked Students tend to pick what’s easy Many random papers. Sometimes big picture lost
This version.. Suggested structure/papers based on hot trends in RT rendering In fact, using an advanced text for most of the literature Creates better flow, students understand better Should still do additional literature survey, etc Will get nice points for finding sweet links, videos, supplementary
material
Drivers of Real‐Time Graphics? A major driver of advances in real‐time graphics: Graphics Hardware acceleration Previously, SGI was king Today: 3D graphics cards from ATI, Nvidia on PCs 3Dfx Voodoo 1 was first card in 1996 beginning of real‐time graphics era?
Most advances in real time graphics are due to innovation in graphics cards Chip on card also called Graphics Processing Unit (GPU)
Graphics Processing Unit (GPU) Entire graphics library (OpenGL, DirectX) in hardware => FAST!!
Speed: GPUs renders graphics faster CPUs Programmable: in last 8 years (Shaders)
Located either on PC motherboard (Intel) or Separate graphics card (Nvidia or ATI)
On PC motherboard On separate PCI express card
GPU Evolution
High throughput computation GeForce GTX 280: 933 GFLOP/s
High bandwidth memory GeForce GTX 280: 140 GB/s
High availability to all 180+ million CUDA‐capable GPUs in the wild
Numbers doubling every 6 months (Moore’s law cubed)
1995 2000 2005 2010
RIVA 1283M xtors
GeForce® 25623M xtors
GeForce FX125M xtors
GeForce 8800681M xtors
GeForce 3 60M xtors
“Fermi”3B xtors
Slide from Stanford course 193G 2010
GPU Server?
Using Nvidia SLI, may install multiple cards
Why is GPU so Fast?
GPUs grew out of need for graphics to render quicker Observation: Graphics rendering involves:
Many: sequential calculations (linear algebra, matrix calculations) sequential memory access (Orderly rendering of pixels/images)
Few: conditional (if/else,loops), branching statements Random memory access operations
Geometrytransforms Projection Lighting
and shading Rasterization
Graphics Rendering Pipeline
GPU Design
Arithmetic Logic Unit (ALU) is part of chip for calculations ALU chip area: CPU (7%) vs GPU ( > 50%) Transistors devoted to ALU, processing NOT
Data caching Flow control (if, else)
Result: GPU runs graphics (or math‐intensive apps) much faster than CPU
Geometrytransforms Projection Lighting
and shading Rasterization
Graphics Rendering Pipeline
Why is GPU so Fast?
More transistors for ALU, faster rendering calculations GPUs will run applications with lots of branches, loops badly?
GFLOP/sec growth
GPU!!
CPU!!
GPU Memory Bandwidth
Graph from: http://developer.download.nvidia.com/compute/cuda/3_2_prod/toolkit/docs/CUDA_C_Programming_Guide.pdf
How did GPU growth this happen?
Games demand advanced shading Fast GPUs = better shading Need for speed = continued innovation The gaming industry has overtaken the defense, finance, oil and healthcare industries as the main driving factor for high performance processors.
146X
Medical Imaging
U of Utah
36X
Molecular Dynamics
U of Illinois, Urbana
18X
Video Transcoding
Elemental Tech
50X
Matlab Computing
AccelerEyes
100X
AstrophysicsRIKEN
149X
Financial simulation
Oxford
47X
Linear AlgebraUniversidad
Jaime
20X
3D UltrasoundTechniscan
130X
Quantum Chemistry
U of Illinois, Urbana
30X
Gene Sequencing
U of Maryland
Aside: GPGPU: GPUs to speedup Non‐Graphics Applications
Graphics Pipeline Revisited
Conceptual graphics pipeline fits into 3 parts Application stage Geometry stage Rasterizer stage
OpenGL pipeline fits into geometry and rasterizer stages Application stage is “stuff” that main program may do before
sending vertices down the pipeline
Application Geometry Rasterizer
CPU GPU
Graphics pipeline What about modelview, clipping, projection, etc? Functional stages fit into conceptual stages Application stage:
Stuff that you thought about as your OpenGL program Camera movement: slide, pitch, yaw, roll Collecting user interaction with models Animation calculations
Geometry stage (also called vertex pipeline): Model and view transforms Lighting Projection Clipping Screen mapping
Graphics Pipeline
Rasterizer stage (also called pixel pipeline): Fill algorithm (line drawing, polygon fill, etc) Z‐buffer Texturing: Look up/fill textures
Application stage => usually in software Geometry stage => may be in hardware of software For high performance graphics rasterizer stage has to be in
hardware!!!
Programmable Pipeline
With OpenGL, programs focussed on generating and pumping primitives (actually vertices) down pipeline
Little control of vertices once in pipeline, fixed functions Recent hardware offers option of replacing portions of
pipeline with user‐programmed stages Vertex shader: replaces fixed‐function transform and lighting Geometry shader: May add or remove vertices from geometric model Pixel shader: replaces texture stages
GPU typically programmed using shading languages Examples: Cg, HLSL, OpenGL shading language, RTSL, etc
Performance Bottlenecks
A pipeline’s fastest speed is defined by it’s slowest stage Depending on specific configuration, application, geometric
or rasterizer stages could be the bottleneck We say:
Application stage bottleneck => application/CPU/bus‐bound Geometry stage bottleneck => vertex/geometry‐bound Rasterizer stage bottleneck => pixel‐bound
Question: Give an example scene that would cause each type of bottleneck above
Possible Bottlenecks
Framebuffer
Fragment Processor
Texture Storage + Filtering
RasterizerGeometry Processor
Geometry StorageCPU
CPU transfer transform raster texture fragment framebuffer
Vertex Bound Pixel Bound
CPU/BusBound
GPU Programming Evolution
1st gen GPU: fixed graphics pipeline on chip 2nd gen GPU:
Shaders: Limited re‐programming of graphics functions using assembler, graphics shader languages
Can update/re‐program graphics algorithms (new techniques for shading, materials, etc) as new ones are developed
3rd gen: All graphics programs must write shaders (E.g. OpenGL 4.0) Most fixed function pipeline deprecated.
Geometrytransforms Projection Lighting
and shading Rasterization
Graphics Rendering Pipeline
NVIDIA G80 Architecture
Slide from David Luebke: http://s08.idav.ucdavis.edu/luebke-nvidia-gpu-architecture.pdf
Some New GPU Hardware features Geometry shader Texture access from Fragment Shader Unified shader model Unlimited program lines in shaders
Today: Real‐Time LoD Management Geometry shader unit: can generate new vertices, primitives Tesselation and simplification algorithms on GPU Real‐time change LoD in game
Why Unify Shader Processors?
Slide from David Luebke: http://s08.idav.ucdavis.edu/luebke-nvidia-gpu-architecture.pdf
Why Unify Shader Processors?
Slide from David Luebke: http://s08.idav.ucdavis.edu/luebke-nvidia-gpu-architecture.pdf
Unified Shader Processors
Slide from David Luebke: http://s08.idav.ucdavis.edu/luebke-nvidia-gpu-architecture.pdf
Terminology
ShaderModel
Direct3D OpenGL Video cardExample
2 9 2.x NVIDIA GeForce 6800ATI Radeon X800
3 10.x 3.x NVIDIA GeForce 8800ATI Radeon HD 2900
4 11.x 4.x NVIDIA GeForce GTX 480ATI Radeon HD 5870
Shader Capabilities
Table courtesy of A K Peters, Ltd. http://www.realtimerendering.com/
Real‐Time Rendering Techniques Polygonal techniques: OpenGL, DirectX Shading: Pixel/vertex/geometry shading Level of detail management (simplification, tesselation) Texturing to improve RT performance Point‐based rendering BRDF factorization, SH lighting Image‐based rendering: Spectrum of IBR techniques Real time global illumination
Billboard Example in Games
Billboard forbackground
Billboards IBR: pre‐render geometry onto images/textures Rendering at runtime involves simple lookups, fast Similar technique used for crowds in NFL madden football
Real time cloud rendering, Mark J. Harris
Billboard Clouds Billboard Clouds, Decoret, Durand et al [SIGGRAPH‘03] Render complex mesh onto cloud of billboards Billboard inclined at different viewpoints
Imposters
Similar to billboards
Impostors Made Easy – William Damon, Intel
No Impostors
With Impostors
Depth Sprite aka Nailboard
Give depth to image ! RGBΔ ‐ Δ (transparency) is depth parameter Set Δ based on depth of actual geometry Accuracy varies with no. of bits to represent Δ
2 bits 4 bits 8 bits
http://zeus.gup.uni-linz.ac.at/~gs/research/nailbord/
IBR: Pros and Cons
Billboards, imposters, sprites: Image‐based Rendering (IBR)
Pros Speesd up rendering complex scenes Rendering cost independent of scene complexity
Cons Static scene geometry Fixed look‐from or look‐at point Fixed lighting
Advanced Shading: Shadow mapping
Courtesy Hellgate:London, flagship studios incVariance shadow mapping
Courtesy Nvidia SDK 10
Global Illumination Global illumination: model interaction of light from all surfaces in scene (track multiple bounces)
translucent surface
shadow
multiple reflection
Real Time Global Illumination
Ray tracing is classic global illumination algorithm Instead of billboards, imposters, images use physically‐based
appearance models Very cool effects possible:
Shadows Ambient Occlusion Reflections Transmittance Refractions Caustics Global subsurface scattering What does it look like?
Game Engine without Real Time GI
Example: Torque 3D Images look somewhat fake
Game Engine with GI: Crytek Crisis
Better Sky and Atmosphere
[BrunetonNeyret2008] Single and multiple scattering Pre‐computation on the GPU Viewable from space Light shafts
Different Atmospheres
Time Of Day
Caustics and Refraction
Courtesy Chris Wyman, Univ Iowa
Sub‐Surface Scattering
Marble
Human Skin
Crysis skin demo
Sub‐Surface Scattering
Participating Media
Consider other volumes that light must pass through. E.g. smoke, clouds
CloudsSmoke
Real‐Time Global Illumination
For real‐time GI on the fly, need real time GI algorithm One option: Make classic GI techniques real time Real‐time ray tracing Real‐time photon mapping
Ray tracing algorithm
Ray Casting (Appel, 1968)
direct illuminationOpenGL does this too
Real Time Ray Tracing
Multi‐pass rendering: Ray tracer using 4 shaders
Courtesy Purcell et alSIGGRAPH, 2002
Photon mapping: Caustics examples
Images: courtesy of Stanford rendering contest
Caustics
Photon Mapping Pass 1: Photon Tracing Photon mapping: Simulates the transport of individual photons
(Jensen ’95‐’96): Two pass algorithm Pass 1: Emitted photons are probabilistically scattered through
the scene, bounce around and eventually absorbed. Photon hits surface: can be reflected, refracted, or absorbed Photon hits volume: can be scattered or absorbed.
Illustration is based on figures from Jensen[1].
Store final positionOf photon in data structureCalled photon map (kd-tree)
Photon mapping: Pass 2 ‐ Rendering
Indirect diffuse lighting: Use ray tracing Indirect light, volumes, caustics: estimate illumination using photon map (kd‐tree)
Photon Tracing Pass 2: Rendering
Pass 2 ‐ Rendering Imagine ray tracing a hitpoint x Information from photon maps used to estimate radiance from x Radius of circle required to encountering N photons gives radiance
estimate at x
x
Real Time Photon mapping
Similar idea to real‐time ray tracing. Photon mapping as multi‐pass shading
Real‐Time GI
Real‐time RT/photon mapping still not 30 FPS One solution: pre‐compute parts of rendering Faster run‐time Hence, pre‐computed global illumination
Pre‐computed Global Illumination
Pre‐compute Global Illumination rationale Lights objects mostly static Use GPU to pre‐compute approximate lighting solutions Speeds up run‐time
Pre‐computed Occlusion Pre‐computed Radiance Transfer (reflections) Use spherical harmonics
object 1
object 2object 3
object 4
Pre‐Compute Occlusion
Ambient occlusion Estimate fraction of hemisphere above point that is blocked Render ambient term proportional to fraction of hemisphere
occluded
Courtesy NvidiaSDK 10
Precomputed Radiance Transfer Factorize and precompute light & material as Spherical
Harmonics Run‐time: Light reflection is dot product at run time (Fast)
Sponza Atrium: Courtesy Marko Dabrovic
New Real‐Time GI Algorithms
Third option: Create brand new real time GI approaches Designed to run fast on graphics hardware/shaders Two examples: Light Propagation Volumes (LPV) Screen Space Directional Occlusion (SSDO)
CryEngine 3:GI with Light Propagation Volumes State‐of‐the‐art game engine Real‐time simulation of massive,indirect physically‐based lighting
Demo
Light Propagation Volumes Demo
LPV Idea
Main idea: represent light propagation as Virtual Point Lights (VPL)Re‐project VPL into adjacent cells
Game Engine For some projects/final projects, we may use Ogre, 3D open source game engine
Free! Easy to learn and work with Will also look at Ogre source code and learn from it Ogre website: http://www.ogre3d.com
Assignment
Go home, review schedule, decide on which topics you can/want to present
Sign up for topics next week
References Kutulakos K, CSC 2530H: Visual Modeling, course slides UIUC CS 319, Advanced Computer Graphics Course David Luebke, CS 446, U. of Virginia, slides Chapter 1‐4 of RT Rendering CS 543/4731 course slides