Emerging Technologies for Games Deferred Rendering CO3303 Week 22.

Slides:



Advertisements
Similar presentations
15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
Advertisements

8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
Exploration of advanced lighting and shading techniques
Deferred Shading Optimizations
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
Solving Some Common Problems in a Modern Deferred Rendering Engine
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Optimized Stencil Shadow Volumes
Optimized Stencil Shadow Volumes
GAM532 DPS932 – Week 7 Introduction to shadows. Shadow Effects Light Surface No Shadows Shadows.
Direct Volume Rendering. What is volume rendering? Accumulate information along 1 dimension line through volume.
The Art and Technology Behind Bioshock’s Special Effects
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
Real-Time Rendering TEXTURING Lecture 02 Marina Gavrilova.
Pre-lighting in Resistance 2
Deferred Shading Patrick Cozzi University of Pennsylvania CIS Fall 2014.
Week 9 - Wednesday.  What did we talk about last time?  Fresnel reflection  Snell's Law  Microgeometry effects  Implementing BRDFs  Image based.
Rasterization and Ray Tracing in Real-Time Applications (Games) Andrew Graff.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
18.1 Si31_2001 SI31 Advanced Computer Graphics AGR Lecture 18 Image-based Rendering Light Maps What We Did Not Cover Learning More...
Advanced lighting and rendering Multipass rendering.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Beyond Meshes Spring 2012.
4.2. D EFERRED S HADING Exploration of deferred shading (rendering)
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
Hidden Surface Removal
SET09115 Intro Graphics Programming
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Visual quality techniques.
4.7. I NSTANCING Introduction to geometry instancing.
Computer Graphics Texture Mapping
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
CS 376 Introduction to Computer Graphics 04 / 16 / 2007 Instructor: Michael Eckmann.
09/11/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15.
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.
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
More on Advanced Interfaces, Image Basics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, November 21, 2003.
2 COEN Computer Graphics I Evening’s Goals n Discuss application bottleneck determination n Discuss various optimizations for making programs execute.
Games Development 1 Camera Projection / Picking CO3301 Week 8.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
Advanced Computer Graphics Shadow Techniques CO2409 Computer Graphics Week 20.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
- Laboratoire d'InfoRmatique en Image et Systèmes d'information
CSCE 552 Spring D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and.
Computer Graphics Blending CO2409 Computer Graphics Week 14.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 7. Speed-up Techniques Presented by SooKyun Kim.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
Maths & Technologies for Games Advanced Graphics: Scene Post-Processing CO3303 Week
Single Pass Point Rendering and Transparent Shading Paper by Yanci Zhang and Renato Pajarola Presentation by Harmen de Weerd and Hedde Bosman.
Maths & Technologies for Games Graphics Optimisation - Batching CO3303 Week 5.
Maths & Technologies for Games Spatial Partitioning 1 CO3303 Week 8-9.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
Graphics for Games Particle Systems CO2301 Games Development 1 Week 23.
Parallel Lighting Directional Lighting Distant Lighting (take your pick) Paul Taylor 2010.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
Chapter 5. Lighting Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
Patrick Cozzi University of Pennsylvania CIS Fall 2013
Deferred Lighting.
Jim X. Chen George Mason University
Craig Schroeder October 26, 2004
Introduction to geometry instancing
GR2 Advanced Computer Graphics AGR
Computer Graphics Material Colours and Lighting
Frame Buffer Applications
Emerging Technologies for Games Review & Revision Strategy
Presentation transcript:

Emerging Technologies for Games Deferred Rendering CO3303 Week 22

Today’s Lecture 1.Forward Rendering – Issues 2.Deferred Rendering – Concept 3.The G-Buffer 4.Light Volumes 5.Light Quads 6.Ambient & Directional Lights 7.Pros / Cons 8.Advanced Approaches

Forward Rendering Forward Rendering is the name for the method of rendering we have used in all material so far: –Render geometry and light effects on the geometry in a single pass –From mesh to back buffer in one step To do this we need to know all the lights that affect each particular polygon –Not convenient because lights and geometry are independent –Geometry moves around, the lights might move around differently –The lights affecting geometry are constantly changing We’ve generally used a brute force solution –Store a global list of lights –Use a shader that renders all lights on all objects –Cost of this naïve approach = Num Objects x Num Lights

Forward Rendering Try to render this: Brute force not effective –100’s of lights –Lots of geometry –Pixel shader far too slow How to resolve this? Well, notice the light radiuses are small –Any light only affects local geometry, not whole scene

Forward Rendering Small light radius and fixed light positions –Majority of lights in a typical scene Use a spatial partition: –Each partition stores lights that affect it –Geometry only uses lights affecting its own partition –Much smaller number of lights to render in shader Basis of most forward renderers

Forward Rendering Here’s a problem: Small radiuses maybe… –But a huge number in the same place –Dynamic models, makes the partition solution harder Huge number of lights to render in one place And yet the background is barely affected Big variation in shaders needed

Forward Rendering So another key problem is the pixel shader –Do we write one shader that can handle any number of lights? Conditional branching will be inefficient –Or one shader for every combination A shader for 1 point light, another shader for 2, and 3. Then a shader for 1 point and 1 spot light, etc. Shader explosion, batching problems In summary Forward Rendering can be effective but: –Need a slow uber-shader, or lots of shaders and batch problems –Doesn’t work well with lots of lights in one place –Or a huge object affected by different lights in different parts –Probably need partitioning scheme for efficiency - more work –Difficult to work with many dynamic lights

Deferred Rendering Deferred Rendering decouples geometry from lighting Splits the rendering process into two stages: –First render geometric information without lighting, store this data –Then render the effect of each light in turn, accumulating the result –Idea is to reduce the cost to: Num Objects + Num Lights

G-Buffer First step is to render the geometry to the g-buffer –G-buffer is several textures holding geometry & surface data Example g-buffer: Texture 1: Diffuse colour –The basic colour at that pixel Texture 2: World position –Where the pixel is in the world Texture 3: World normal –What direction the surface is pointing at that pixel

G-Buffer A pixel shader can render to several render targets at the same time –So we can build these three textures all in one pass with a special pixel shader So we start by rendering the scene with fairly standard vertex shaders With a special MRT pixel shader to fill the g-buffer –Although unusual this pixel shader is quite simple MRT = Multiple Render Target

G-Buffer Data in the g-buffer is anything we need to calculate a lit version of the scene –Exact contents are up to us. The typical g-buffer is much more complex than the example given on the previous slide. –In particular, rarely store position as it can be derived from depth A large g-buffer is a major performance drain –Memory access is slow, cache misses make it worse So data compression in the g-buffer is common –E.g. Store X & Y of normal, together with a single bit for direction. Calculate Z from this. Faster compared to texture look-up.

Lighting Volumes The g-buffer is not displayed, it’s data for the next step Render the actual scene by going through each light and rendering it’s effect on the geometry Consider a point light, it will light up a sphere around itself –At a certain distance attenuation will reduce the light to almost zero So to render the effect of a point light, we render a sphere For each pixel in the sphere, find if it is actually lit up Use the data in the g-buffer to calculate the amount of light –Use the usual lighting equations Do this for every light and accumulate = rendered scene

Lighting Volumes / Quads Same concept works for spotlights –Except they would be bounded by a cone Don’t need high-poly spheres or cones –These volumes are used only to limit the number of pixels we attempt to light In fact can just use a bounding quad for each light –A rectangle that covering the area potentially affected by the light –A quad is less polygons to render than a sphere –But a less tight fit, will consider pixels that couldn’t be lit Calculating the bounding quad has some details –A sphere seen in perspective becomes an ellipse –There’s a method shown in the lab

Bounding Quads Example A visualisation of the lighting stage –Red: the bounding quads rendered around each light –Bright green: pixels within the quad that actually received any light

Depth When rendering a light volume or quad, some pixels within the area may too far away or too near - not affected by light Can use depth to reject pixels that are within the 2D area of the light volume / quad, but are actually far away With light volumes, use stencil buffer methods to identify the pixels inside With quads it is easy to reject pixels that are in front, less easy for distant pixels In practice the work involved can outweigh the advantages Can use stencil buffer to detect pixels inside volumes

Ambient / Directional / Transparency Ambient light & directional light both affect all pixels –So render these with a full screen quad and g-buffer data –Ambient is very simple, directional not much harder Can do these two together –Since in most scenes there is only one directional light Convenient as the first lighting pass –Lay down an initial lighting level for every pixel before accumulating all the point and spot lights on top On a separate point, note that transparent geometry does not work with standard deferred techniques. –Because the g-buffer only stores the nearest pixel, see through pixels are not accounted for

Pros/Cons of Deferred Pros: –Lights become very cheap to render –No need for complex partitioning to manage lights –Shaders become simpler, less of them –Better batching performance –G-buffer data can be reused for post-processing Cons: –Huge g-buffer can be a slow down –G-buffer compression to counter this reduces material flexibility –Transparent objects don’t work, must be rendered separately –MSAA becomes very difficult due to g-buffer –Not actually particularly useful in some scenes (daylight) –More advanced techniques are getting very complex

Advanced Approaches This has been a very brief overview of the topic –There are many complexities to consider, and variations on the approach Most notable variants: –Light Pre-pass: Only store normals, use to calculate lighting only. Render a second geometry pass to combine lighting with materials. Reduces g-buffer size –Light Indexed: Lighting pass stores a light ID only per-pixel, second geometry pass can look up exactly what lights affect a pixel. A mix of forward and deferred. –Tiled (popular now): Split screen into tiles, for each tile find the intersecting light volumes. Calculate the lighting for all these lights on one tile simultaneously.