Advanced Programmable Shading: Beyond Per-vertex and Per-pixel Shading.

Slides:



Advertisements
Similar presentations
Real-Time Rendering 靜宜大學資工研究所 蔡奇偉副教授 2010©.
Advertisements

Exploration of advanced lighting and shading techniques
An Optimized Soft Shadow Volume Algorithm with Real-Time Performance Ulf Assarsson 1, Michael Dougherty 2, Michael Mounier 2, and Tomas Akenine-Möller.
Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Optimized Stencil Shadow Volumes
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Optimized Stencil Shadow Volumes
Computer Graphics methods
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
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.
1 Dr. Scott Schaefer Shadows. 2/40 Shadows Shadows provide clues about depth Make scenes appear more realistic.
Real-Time Rendering SPEACIAL EFFECTS Lecture 03 Marina Gavrilova.
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.
Practical and Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering Cass Everitt and Mark J. Kilgard Speaker: Alvin Date: 5/28/2003 NVIDIA.
A Real-Time Soft Shadow Volume Algorithm DTU Vision days Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Sweden
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,
Approximate Soft Shadows on Arbitrary Surfaces using Penumbra Wedges Tomas Akenine-Möller Ulf Assarsson Department of Computer Engineering, Chalmers University.
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
Computer Graphics Shadows
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
9/20/2001CS 638, Fall 2001 Today Finishing Up Reflections More Multi-Pass Algorithms Shadows.
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel  dramatic effects  spooky effects Without shadows the.
Computer Graphics Mirror and Shadows
Shadow Algorithms Ikrima Elhassan.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
CS 638, Fall 2001 Today Light Mapping (Continued) Bump Mapping with Multi-Texturing Multi-Pass Rendering.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
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.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
Week 2 - Friday.  What did we talk about last time?  Graphics rendering pipeline  Geometry Stage.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
Shadow Mapping Chun-Fa Chang National Taiwan Normal University.
CS-378: Game Technology Lecture #8: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Realtime NPR Toon and Pencil Shading Joel Jorgensen May 4, 2010.
Computer graphics & visualization Shadows / Transparency.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Havok FX Physics on NVIDIA GPUs. Copyright © NVIDIA Corporation 2004 What is Effects Physics? Physics-based effects on a massive scale 10,000s of objects.
Computer Graphics 3 Lecture 6: Other Hardware-Based Extensions Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
11/24/ :45 Graphics II Shadow Maps Reflections Session 5.
From Turing Machine to Global Illumination Chun-Fa Chang National Taiwan Normal University.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
Emerging Technologies for Games Capability Testing and DirectX10 Features CO3301 Week 6.
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.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
1 Shadow Rendering Techniques: Hard and Soft Author: Jamiur Rahman Supervisor: Mushfiqur Rouf Department of CSE BRAC University.
Non-Photorealistic Rendering FORMS. Model dependent Threshold dependent View dependent Outline form of the object Interior form of the object Boundary.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
Graphics Processing Unit
Deferred Lighting.
3D Graphics Rendering PPT By Ricardo Veguilla.
Chapter 6 GPU, Shaders, and Shading Languages
From Turing Machine to Global Illumination
The Graphics Rendering Pipeline
Introduction to Computer Graphics with WebGL
Graphics Processing Unit
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
Frame Buffer Applications
CIS 6930: Chip Multiprocessor: GPU Architecture and Programming
Presentation transcript:

Advanced Programmable Shading: Beyond Per-vertex and Per-pixel Shading

T & L setup rasterizer texture blending fb anti-alias vertex transform and lighting per-pixel texture The DirectX7™ Graphics Pipeline (GeForce/GeForce2)

curved surfaces vertex shaders setup rasterizer tex-addr ops texture blending fb antialias shadows 3d tex per-vertex shading per-pixel shading The DirectX8™ Graphics Pipeline (GeForce3) programmable

Programmable Vertex Processing GeForce family introduced hardware T&L to the PC Transform and Lighting GeForce3 (next generation) makes T&L user programmable Vertex programs Developers can now write custom Vertex Transformation Vertex Lighting Special effects (layered fog, volumetric lighting, morphing…)

Custom Substitute for Standard T&L Constant Memory 96 entries 128 bits 4 floats 16 entries 13 entries 12 entries Vertex Input Vertex Output Registers Programmable Vertex Processor A0 128 instructions addr data 128 bits 4 floats 128 bits 4 floats 128 bits 4 floats addr data

curved surfaces vertex shaders setup rasterizer tex-addr ops texture blending fb antialias shadows 3d tex per-vertex shading per-pixel shading What do Developers do with all of this Programmability? programmable ? ?

curved surfaces vertex shaders setup rasterizer tex-addr ops texture blending fb antialias shadows 3d tex per-vertex shading per-pixel shading So far, mostly… programmable ? ? T & L texture blending (better)

Wassup wit dat? The advent of programmable vertex shaders and pixel shaders in hardware is the most fundamental change in graphics for a long time! But, many developers do not use them in their games, or only use them to map simple multipass shaders into a single pass

There are Bigger Opportunities A complex rendering technique can be "factored" into components executed on CPU, vertex shader, and pixel shader The true power of programmable vertex and pixel processing lies in the programmers‘ ability to map more complex and varied algorithms onto the hardware

Instead of... CPU does Game code AI Physics Scene management GPU does T&L Rasterization Texturing / Shading Drawing Triangles & Textures CPU GPU Triangles & Textures

Think in terms of... Higher level algorithms are mapped across both CPU & GPU CPU still does Game code, AI, Physics, Scene management GPU still does T&L, Rasterization, Texturing / Shading, Drawing And, MORE Partial Results CPU GPU Data Partial Results

New Things to do with Vertex/Pixel Shaders (Automatic!!!) Shadow Volume Generation for Stencil Shadows Order-independent Transparency (Depth Peeling) Requires DX8.1 PS1.3 texm3x2depth Motion Blur / Depth of Field

Stenciled Shadow Volumes Powerful technique, excellent results possible

Review: Stenciled Shadow Volumes A single point light source splits the world into Shadowed regions Unshadowed regions The surface of a shadow volume is the boundary between these shadowed and unshadowed regions The idea: determine if an object is inside the boundary of the shadowed region and thereby know if the object is shadowed First described by [Crow 77]

Visualizing Shadow Volumes Occluders and light source cast out a shadow volume Objects within the volume should be shadowed Light source Scene with shadows from an NVIDIA logo casting a shadow volume Visualization of the shadow volume

Shadow Volume Algorithm High-level view of the algorithm: Given the scene and a light source position, determine the shadow volume (harder to do than it sounds, but we’re going to make it easy!) Render the scene in two passes Draw scene with the light enabled, updating only fragments in unshadowed region Draw scene with the light disabled, updated only fragments in shadowed region We’re going to focus on the Shadow Volume Generation part of the problem

Computing Shadow Volumes Harder than you might think Easy for a single triangle, just project out three infinite polygons from the triangle, opposite the light position For complex objects, projecting object’s 2D silhouette is a good approximation, but calculating this is hard Two other new GPU Vertex Shader techniques Quick and dirty (fast, cheap, doesn’t always work) Robust (always works, but costs more computes)

The Hard Way: Computing Shadow Volumes for Polygonal Models High-level: determine “possible silhouette” edges of the model Transform light into object space Compute the plane equation for every polygon in the model (can be pre-computed for static models) For every polygon in the model, determine if the object-space light position is behind or in front of the polygon’s plane I.e., Is the planar distance from the polygon’s plane to the light positive or negative? Search for edges where polygons have opposite facingness toward the light These edges are possible silhouette edges

Quick and Dirty Way: Stencil Shadow Volume Generation with Vertex Shaders Use your polygon model (un-adulterated) Vertex shader tests vertex normal N \dot L Front-facing vertices are unchanged Back-facing vertices are pushed to FAR Has the effect of extruding approximate silhouette edges away from light to produce shadow volumes APPROXIMATE – only works for closed, highly & smoothly tesselated objects (imagine a single triangle, or a cube)

Robust Way: Stencil Shadow Volume Generation with Vertex Shaders Adulterate your polygon model Add degenerate quads at every edge Normals for new degenerate quad vertices come from real geometry Vertex shader tests vertex normal N \dot L Front-facing vertices are unchanged Back-facing vertices are pushed to FAR Has the effect of extruding silhouette edges away from light to produce shadow volumes Always works, for all objects (imagine a single triangle)

Order-Independent Transparency: Good…Bad.

Order-Independent Transparency (Depth Peeling) The algorithm uses an “implicit sort” to extract multiple depth layers First pass render finds front-most fragment color/depth Each successive pass render finds (extracts) the fragment color/depth for the next-nearest fragment on a per pixel basis Use dual depth buffers to compare previous nearest fragment with current Second “depth buffer” used for comparison (read only) from texture

Layer 0Layer 1 Layer 2Layer 3

0 depth 1 Layer 0 Layer 1Layer 2 Depth peeling strips away depth layers with each successive pass. The frames above show the frontmost (leftmost) surfaces as bold black lines, hidden surfaces as thin black lines, and “peeled away” surfaces as light grey lines. 0 depth 1

Pseudo-code for (i=0; i<num_passes; i++) { clear color buffer A = i % 2 B = (i+1) % 2 depth unit 0: if(i == 0) disable depth test else enable depth test bind buffer A disable depth writes; set depth func to GREATER depth unit 1: bind buffer B clear depth buffer enable depth writes; enable depth test; set depth func to LESS render scene save color buffer RGBA as layer I }

1 layer2 layers 3 layers4 layers

Using Vertex/Pixel Shaders to do Motion Blur / Depth of Field Advertisement: Matthias Wloka from Nvidia will talk about this tomorrow (it’s cool stuff!) Motion blur screenshot:

Depth of Field: Screenshots

Aggressive use of Vertex Shaders is SAFE and IMPORTANT It’s “safe” to use vertex shaders pervasively Many hardware platforms have them Mainstream GPUs will have them this fall CPUs can emulate vertex shaders adequately, so CPU fallback is OK It’s “important” to design content for vertex and pixel shaders Adopt vertex and pixel programming, and author content from the top-down It’s much much easier to scale down and fallback than to scale up

Acknowledgements Thanks to John Carmack, Rui Bastos, Mark Kilgard, Sim Dietrich, Matthew Papakipos, Cem Cebonoyan, Greg James, Matthias Wloka, Erik Lindholm, Doug Rogers, Cass Everitt, (and others I forgot!) for contributing ideas, slides, demos, and images. Demo/Example source code and more whitepapers can be found at