Deferred shading

Deferred Shading




             Chun-Fu “Frank” Chao
                       Image from source 1
Outline
 Why(Why not) deferred shading
 History of deferred shading
 Basic of deferred shading
 Shadow in deferred shading
 Extension of deferred shading
    ◦   Light Pre-Pass deferred shading
    ◦   Anti-aliasing in deferred shading
    ◦   Inferred shading
    ◦   Tile-based deferred shading
What is deferred shading?
   Instead of intermediately calculate the
    color and write to frame buffer, we divide
    the information into smaller parts and
    write them into intermediate buffer (i.e.
    G(eometric)-buffer). Then combine and
    calculate color later.




                                    Video from source 15
Killzone 2 Behind the Bullet for
PlayStation 3




                            Video from source 2
Why deferred shading?




                        Image from source 26
Why deferred shading?
   Decouple the scene geometry complexity
    and light complexity
    ◦ Going from O( #Light * #Triangle ) to
      O( #Light ) + O( #Triangle )
 Only do the BRDF calculation on the
  visible surfaces
 Simplify the rendering process
    ◦ Few passes on G-buffer V.S. Switching shaders
   G-buffer is useful for post-processing
Comparison with Forward
Rendering
 Single pass lighting:
  For each object
     Render object
     Apply all the lights in shader
 Why this is not good?
    ◦ Boated shader if we do code generation for all
      the light sources
    ◦ Wasteful ( We are throwing away fully shaded
      fragment in depth test !)

                                       From source 4, slide 3
Comparison with Forward
Rendering
   Multi-pass lighting:
    For each light
        For each object affected by light
               Framebuffer += BRDF( object, light )
   Why this is not good?
    ◦ Repetitive vertex transformation for the same
      object
    ◦ Wasteful ( We are “still” throwing away fully
      shaded fragment in depth test !)

                                        From source 4, slide 4
Deferred Shading
  For each object
     Render the lighting(material) property
     into G-buffer
  For each light
     Framebuffer += BRDF( G-buffer, light )
 Simplify the lighting process
 O(1) depth complexity for lighting



                                From source 4, slide 5
Why “not” deferred shading?
   Memory intensive
    ◦ Multiple buffer ( Multiple render target )
    ◦ Buffer read-back
    ◦ Limited material type
   Cannot apply hardware assisted anti-aliasing
    ◦ MSAA(Multi-sample anti-aliasing) is for pixel
      already shaded
   Cannot handle translucent object
    ◦ We only have the information of the object with
      smallest depth value
History
   Deering, M., et al. “The Triangle
    Processor and Normal Vector Shader:
    A VLSI System for High Performance
    Graphics”, Proceedings of SIGGRAPH
    ‘88
    ◦ Only shading once after depth resolution

   T. Saito and T. Takahashi.
    “Comprehensible rendering of 3d
    shapes”, Proceedings of SIGGRAPH ’90
    ◦ It is designed for contour rendering
    ◦ The first time the term of G-Buffer
      appears




                                                 Image from source 6, 7
Multiple Render target
 A feature that allows programmable
  rendering pipeline to render images to
  multiple render target texture at the
  same time.
 Introduced by OpenGL 2.0 and DirectX
  9.0
 Supported by Xbox360 and Playstation 3
Multiple Render target
   We can do deferred shading without
    Multiple render target.
    ◦ But the performance is going to be a problem




                                     Image from source 6, 8
DEFERRED SHADING BASIC
What kind of G-buffer do we need?
   Going from the SSAO assignment we did
Say we want something like this




                        From source 9, slide 9
What kind of G-buffer do we need?




                        From source 9, slide 10
What kind of G-buffer do we need?




                        From source 9, slide 11
What kind of G-buffer do we need?




                        From source 9, slide 12
What kind of G-buffer do we need?




                        From source 9, slide 13
What kind of G-buffer do we need?




                        From source 9, slide 14
What kind of G-buffer do we need?




                        From source 9, slide 15
What kind of G-buffer do we need?




                        From source 9, slide 16
What kind of G-buffer do we need?




                        From source 9, slide 17
The G-Buffer of Killzone 2




   4 X R8G8B8 + 24Depth + 8Stencil ~= 36 MB
    ◦ We only got 256 MB RAM and 256 MB VRAM on
      PS3 
   No Normal.z term
    ◦ Normal.z = sqrt( 1.0 – Normal.x^2 – Normal.y^2 )
    ◦ Trade memory space with computation time
                                          From source 9, slide 19
The G-buffer of Battlefield 3
         Material ID is a common way to manage
          material
             R8                 G8                        B8                  A8
GB0                            Normal .xyz                            Spec. Smoothness
GB1                         Diffuse albedo .rgb                       Specular albedo
GB2   Sky visibility   Custom envmap ID           Material Param.     Material ID
GB3                               Irradiance (dynamic radiosity)




                                             Image from source 9, slide 12 and source 10
Lighting Result




                  Image from source 10, slide 31
SHADOW
That’s cool. But where is my shadow?
 1000 lights without shadow is easy, but
  100 lights with shadow is impossible now
  
 Shadow map
    ◦ A good fit with deferred shading
    ◦ Need more memory 
   Shadow volume
    ◦ Render light as geometry volume
    ◦ Depth test to determine whether the object is
      inside the volume or not
Shadow map
 Create a depth map in the perspective of light
  source.
 Compare the position of the geometry
  surface with the depth map of light source.
 Position = Screen space position + depth




                                    Image from source 14
Ouch!




        Image from source 16, Page 16
Shadow Volume
 Only apply the light to the pixel enclose by
  the shadow volume
 Depth test needs to be handle carefully




       Image from source 4, slide 12   Image from source 17
Xbox Gladiator 2k4 demo




                      Video from source 5
Wait! We still have plenty of
problems
   Memory usage
    ◦ Light Pre-Pass deferred shading
   Anti-aliasing
    ◦ MLAA ( Morphological Anti-aliasing )
    ◦ SRAA ( Sub-pixel Reconstruction Anti-Aliasing )
   Alpha blending
    ◦ Inferred shading
LIGHT PRE-PASS DEFERRED
SHADING
Light Pre-pass / Deferred Lighting
 Two pass deferred
  shading
 1st pass
    ◦ Only render depth
      and normal
    ◦ Do not need MRT!




                           Image from source 17
Light Pre-pass / Deferred Lighting

   Write LightColor * N dot L * Attenuation
    in RGB, specular in A channel




                                     Image from source 17
Light Pre-pass / Deferred Lighting
 2nd geometry pass
  ◦ Fetch the material property
  ◦ Combine with light buffer




                                  Image from source 17
Light Pre-pass / Deferred Lighting
   Pro
    ◦ Less memory required
    ◦ Doesn’t not require MRT feature
         = Enable programmer to turn on MSAA in
         DirectX9
    ◦ Only one material fetch regardless number of
      light
   Con
    ◦ “Two” geometry passes
ANTI-ALIASING
Anti-aliasing
 Super-sampling one framebuffer is painful,
  super-sampling 5 MRT is 5X painful 
 Hardware supported MSAA is incompatible
  with deferred shading
    ◦ MSAA cannot apply to MRT in DirectX 9
    ◦ Super-sampling and averaging normal or depth
      might cause wired result
 Imaged based approach of anti-aliasing
 We have depth and normal information 
Basic Edge-detection Anti-aliasing
 Do the 2D edge detection algorithm on
  frame buffer
 Apply low-pass filter across the edge
 The discontinuities of normal and depth
  are better features to locate edges
Basic Edge-detection Anti-aliasing
   Detect depth or normal discontinuity is
    better than the color discontinuity




                                    Image from source 17
Morphological Anti-aliasing
 Detect the pattern of color discontinuity
 Draw triangular area based on the
  pattern




                                 Image from source 18
Morphological Anti-aliasing
 Connect the mid-points of the L, Z, and U
  shape segments.
 The blending weight is based on the triangle
  area enclosed by mid points




                                  Image from source 18
Sub-pixel Reconstruction Anti-
Aliasing
   MLAA will alter the shape of the original
    image




                                    Image from source 20
Sub-pixel Reconstruction Anti-
Aliasing
   Determine the blending pattern based on
    the super-sampled depth and normal
    information




                                Image from source 20
Anti-aliasing comparison




                    Image from source 21, slide 44
Anti-aliasing comparison




                    Image from source 21, slide 45
Anti-aliasing comparison




                    Image from source 21, slide 46
Anti-aliasing comparison




                    Image from source 21, slide 47
Anti-aliasing comparison




                    Image from source 21, slide 48
Anti-aliasing comparison




                    Image from source 21, slide 49
INFERRED SHADING
Alpha blending
   How do we get transparent/transculant
    effect in deferred shading
    ◦ One more forward rendering pass 
    ◦ Depth peeling
      So expensive 
      Limited layer of transculant material
Depth Peeling
 Multiple pass of depth buffer generation
  from front to back
 Peel the fragments away after depth
  buffer generated
 Render image form back to front




                                Image from source 22
Depth Peeling




                Image from source 22
Inferred Shading
 3-pass algorithm based on the 2-pass
  Light Pre-pass deferred shading
 Can create
  transparent effect
  in deferred shading
  scheme
    ◦ Even multiple
      layer of
      transparency!

                               Image from source 23
Inferred Shading
   Geometry Pass
    ◦ RT1 : Normal.X / Normal.Y
    ◦ RT2 : Depth / Object ID
    ◦ The resolution is lower than target
   Light Pass
    ◦ Apply lighting to the G-buffer to create L-buffer
    ◦ The resolution is also lower that target
   Material Pass
    ◦ Material fetch
    ◦ Combine material with L-buffer information
Inferred Shading
   Discontinuity Sensitive Filtering
    ◦ Sample lighting information based on the
      object ID information stored in G-buffer
    ◦ If the sample is not from the same object,
      then ignore the sample




                                       Image from source 23
Lighting Alpha Polygons
 Render the transparent objects last in the
  geometry pass and render them into
  stipple pattern
 Special sampling rule parse over the
  stipple pattern in the material pass




                                 Image from source 23
Stipple Pattern




                  Image from source 23
Material Pass : Render Opaque
Objects




                         Image from source 23
Material Pass : Render Transparent
Objects




                          Image from source 23
Multiple Layer of Transparency
Transparent
                 Opaque
     1


 Opaque          Opaque




   Transparent    Transparent
        1              3


   Transparent
                   Opaque
        2



                                Image from source 23
Resolution Decrease




                      Image from source 23
TILE-BASED DEFERRED
SHADING
Tile-based Deferred Shading
 Introduced into Frostbite 2 engine
 Divide the screen in screen-space tiles
 Cull analytical lights (point, cone, line), per
  tile
 Compute lighting for all contributing lights,
  per tile




                                       Slide from source 25
Tile-based Deferred Shading




                    Image from source 10, slide 42
Tile-based Deferred Shading




                    Image from source 10, slide 43
Tile-based Deferred Shading




                    Image from source 10, slide 43
Tile-based Deferred Shading
• The screen is divided in 920 tiles of
  32x32 pixels
• Downsample and classify the
  scene from 720p to 40x23
   (1 pixel == 1 tile)
  • Find each tile’s Min/Max depth
  • Find each tile’s material permutations
  • Downsampling is done in multi-pass
    and via MRTs

                                Slide from source 25
Tile-based Deferred Shading




                    Image from source 25, slide 72
Tile-based Deferred Shading




                    Image from source 25, slide 73
Tile-based Deferred Shading




                    Image from source 25, slide 74
Tile-based Deferred Shading
 Build mini-frustas for each tile
 Cull lights against sky-free tiles in a shader
 Store the culling results in a texture:
    ◦ Column == Light ID
    ◦ Row == Tile ID
 Actually, 4 lights can be processed at once
  (A-R-G-B)
 Read back the contribution results on the
  CPU and prepare for lighting!

                                       Slide from source 25
Tile-based Deferred Shading
 Parse the culling results texture on CPU
 For each light type
  For each tile
  For each material permutation,
      Regroup & set the light parameters for
      the pixel shader constants
 Setup the shader loop counter
  (Limited number of light passed)
 Additively render lights with a single draw
  call (to the final HDR lighting buffer)

                                    Slide from source 25
Tile-based Deferred Shading




                    Image from source 25, slide 66
Tile-based Deferred Shading




                    Image from source 25, slide 67
Tile-based Deferred Shading




                    Image from source 25, slide 68
Tile-based Deferred Shading




                    Image from source 25, slide 69
Thank you
   Questions?




                 Image from source 25
BONUS
GDC 2011

APPROXIMATING
TRANSLUCENCY
Demonstration




                Image from source 1
Approximating Translucency




                     Image from source 1
Approximating Translucency




                     Image from source 1
SOURCE
Source
1.   John Chapman, “Deferred Rendering, Transparency & Alpha Blending Tutorial”,
     Available at:
     http://john-chapman.net/content.php?id=13
2.   Guerrilla Games, “Killzone 2 Behind the Bullet for PlayStation 3”, Available at:
     http://www.youtube.com/watch?v=tzx_JfujYT4
3.   Shawn Hargreaves, “Deferred Shading”, Available at:
     http://www.shawnhargreaves.com/DeferredShading.pdf
4.   Shawn Hargreaves, “Deferred Shading : 6800 Leagues Under The Sea”,
     Available at:
     http://http.download.nvidia.com/developer/presentations/2004/6800_Leagues/
     6800_Leagues_Deferred_Shading.pdf
5.   Rich Geldreich, “Deferred Lighting and Shading”, Available at:
     https://sites.google.com/site/richgel99/
6.   Deering, M., et al. “The Triangle Processor and Normal Vector Shader: A VLSI
     System for High Performance Graphics”, Proceedings of SIGGRAPH ‘88 ,
     Available at:
     http://dl.acm.org/citation.cfm?id=378468
Source
7.    T. Saito and T. Takahashi. “Comprehensible rendering of 3d shapes”, Proceedings
      of SIGGRAPH ’90, Available at:
      http://dl.acm.org/citation.cfm?id=97901
8.    Filion, D. and McNaughton, R. (Blizzard Entertainment), “ StarCraft II: Effects &
      Techniques”, slide available at:
      http://developer.amd.com/gpu_assets/S2008-Filion-McNaughton-StarCraftII.pdf
      Course note available at:
      http://developer.amd.com/documentation/presentations/legacy/Chapter05-
      Filion-StarCraftII.pdf
9.    Michal Valient (Guerrilla), “Deferred Rendering in Killzone 2 “, Available at:
      http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf
10.   Christina Coffin (DICE), “SPU-based Deferred Shading for Battlefield 3 on
      Playstation 3”, Available at:
      http://publications.dice.se/publications.asp?show_category=yes&which_categor
      y=Rendering
11.   Colin Barré-Brisebois (DICE), “Approximating Translucency for a Fast, Cheap and
      Convincing Subsurface Scattering Look”, Available at:
      http://zigguratvertigo.com/tag/deferred-shading/
Source
12.   Michal Valient (Guerrilla), “The Rendering Technology of Killzone 2”, Available at:
      http://www.slideshare.net/guerrillagames/the-rendering-technology-of-killzone-
      2
13.   Michiel van der Leeuw (Guerrilla), “The PlayStation®3’s SPUs in the Real World: A
      KILLZONE 2 Case Study “, Available at:
      http://www.slideshare.net/guerrillagames/the-playstation3s-spus-in-the-real-
      world-a-killzone-2-case-study-9886224
14.   Wikipedia : Shadow Mapping
      http://en.wikipedia.org/wiki/Shadow_mapping
15.   Wikipedia : Deferred Shading
      http://en.wikipedia.org/wiki/Deferred_shading
16.   Johan Andersson (DICE), “5 Major Challenges in Interactive Rendering”,
      Available at:
      http://publications.dice.se/publications.asp?show_category=yes&which_categor
      y=Rendering
17.   Nicolas Thibieroz, “Deferred Shading Optimizations” ,
      Available at:
      http://developer.amd.com/gpu_assets/Deferred%20Shading%20Optimizations.p
      ps
Source
18.   Alexander Reshetov (Intel Labs ), “Morphological Antialiasing” , Available at:
      http://visual-computing.intel-
      research.net/publications/papers/2009/mlaa/mlaa.pdf
19.   Alexandre De Pereyra (Intel), “MLAA: Efficiently Moving Antialiasing from the
      GPU to the CPU”, Available at:
      http://software.intel.com/en-us/articles/mlaa-efficiently-moving-antialiasing-
      from-the-gpu-to-the-cpu/
20.   Chajdas, McGuire, and Luebke, Subpixel Reconstruction Antialiasing, ACM
      Symposium on Interactive 3D Graphics and Games (I3D 2011 proceedings),
      February 2011, Available at:
      http://graphics.cs.williams.edu/papers/SRAAI3D11/
21.   Johan Andersson (DICE), “DirectX 11 Rendering in Battlefield 3”, Available at:
      http://publications.dice.se/publications.asp?show_category=yes&which_categor
      y=Rendering
22.   Cass Everitt (Nvidia), “Interactive Order-Independent Transparency”, Available at:
      http://developer.nvidia.com/content/interactive-order-independent-
      transparency
Source
23.   Scott Kircher and Alan Lawrance. 2009. Inferred lighting: fast dynamic lighting
      and shadows for opaque and translucent objects. In Proceedings of the 2009
      ACM SIGGRAPH Symposium on Video Games (Sandbox '09), Stephen N. Spencer
      (Ed.). ACM, New York, NY, USA, 39-45. Available at:
      http://dl.acm.org/citation.cfm?id=1581080
24.   ENGEL, W., 2008. Diary of a graphics programmer: Light pre-pass renderer.
      Online, accessed Jan. 27th, 2009. Available at:
      http://diaryofagraphicsprogrammer.blogspot.com/2008/03/light-pre-pass-
      renderer.html.
25.   John White (Black Box), Colin Barré-Brisebois (DICE)“More Performance! Five
      Rendering Ideas from Battlefield 3 and Need For Speed The Run”, Available at:
      http://publications.dice.se/
26.   Kenny Magnusson (DICE),“Lighting you up in Battlefield 3”
      http://publications.dice.se/
Indirect Reference Source
1.   Oles Shishkovtsov (GSC Game World), "GPU Gems 2 Chapter 9. Deferred Shading
     in S.T.A.L.K.E.R.", Available at:
     http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter09.html
2.   Rusty Koonce (NCsoft Corporation), "GPU Gems 3 chapter 19. Deferred Shading
     in Tabula Rasa", Available at:
     http://http.developer.nvidia.com/GPUGems3/gpugems3_ch19.html
3.   Tiago Sousa(Crytek), "GPU Gems 3 chapter 16. Vegetation Procedural Animation
     and Shading in Crysis", Available at:
     http://http.developer.nvidia.com/GPUGems3/gpugems3_ch16.html
4.   Wolfgang Engel, “ShaderX2 : introductions and tutorials with DirectX 9”,
     Available at:
     http://tog.acm.org/resources/shaderx/Introductions_and_Tutorials_with_Direct
     X_9.pdf
5.   Wolfgang Engel, “Light Pre-Pass -Deferred Lighting: Latest Development”,
     Available at:
     http://www.bungie.net/images/Inside/publications/siggraph/Engel/LightPrePass.
     ppt
Indirect Reference Source
6.    Mark Lee(Insomniac games), “Pre-lighting, Available at:
      http://www.insomniacgames.com/tech/articles/0209/files/prelighting.pdf
7.    Mark Lee(Insomniac games), “Pre-lighting in Resistance 2”, Available at:
      http://www.insomniacgames.com/gdc09-resistance-2-prelighting/
8.    Rouslan Dimitrov(Nvidia), “Cascaded Shadow Maps”, Available at:
      http://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_
      maps/doc/cascaded_shadow_maps.pdf
9.    Damian Trebilco, “Light Indexed Deferred Lighting”, Available at:
      http://code.google.com/p/lightindexed-deferredrender/
10.   Andrew Lauritzen(Intel), "Deferred Rendering for Current and Future Rendering
      Pipelines", Available at:
      http://visual-computing.intel-research.net/art/publications/deferred_rendering/
11.   B. Segovia, J. C. Iehl, R. Mitanchey, and B. Péroche. 2006. Non-interleaved
      deferred shading of interleaved sample patterns. In Proceedings of the 21st ACM
      SIGGRAPH/EUROGRAPHICS symposium on Graphics hardware (GH '06). ACM,
      New York, NY, USA, 53-60.
      http://dl.acm.org/citation.cfm?id=1283909
Indirect Reference Source
12.   John Tsiombikas, “Volume Shadows Tutorial”, Available at:
      http://nuclear.mutantstargoat.com/
13.   Stefan Brabec , Thomas Annen , Hans-peter Seidel, ” Shadow Mapping for
      Hemispherical and Omnidirectional Light Sources”, Available at:
      http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.11.3540
14.   Emil Persson (AMD), “Depth In-depth “, Available at:
      http://developer.amd.com/media/gpu_assets/Depth_in-depth.pdf
15.   Sam Martin, Per Einarsson(Geomerics), “A Real Time Radiosity Architecture”
      http://www.geomerics.com/downloads/radiosity_architecture.pdf
16.   Martin Mittring(Crytek), “A bit more deferred – CryEngine3”, Available at:
       http://www.crytek.com/cryengine/presentations&page=2
17.   Anton Kaplanyan(Crytek), “CryENGINE 3: reaching the speed of light”
      http://www.crytek.com/cryengine/presentations/CryENGINE3-reaching-the-
      speed-of-light
18.   Nickolay Kasyan, Nicolas Schulz, Tiago Sousa(Crytek), ”Secrets of CryENGINE 3
      Graphics Technology”, Available at:
       http://www.crytek.com/cryengine/presentations/secrets-of-cryengine-3-
      graphics-technology
Indirect Reference Source
19.   Martin Mittring(Epic games), Bryan Dudash(Nvidia), “The Technology Behind the
      DirectX 11 Unreal Engine "Samaritan" Demo”, Available at:
       http://www.nvidia.com/content/PDF/GDC2011/Epic.pdf
20.   Dean Calver , “Photo-realistic Deferred Lighting”
      http://www.beyond3d.com/content/articles/19/1
21.   Anton Kaplanyan (Crytek) ,”Light Propagation Volumes in CryEngine 3” ,
      Available at:
      http://www.crytek.com/cryengine/cryengine3/presentations/light-propagation-
      volumes-in-cryengine-3
22.   Aths, “Multisampling Anti-Aliasing: A Closeup View “, Available at:
      http://alt.3dcenter.org/artikel/multisampling_anti-aliasing/index3_e.php
23.   Fabio Policarpo, Francisco Fonseca(CheckMate Games), “ Deferred Shading Tutorial”,
      Available at:
      http://www710.univ-
      lyon1.fr/~jciehl/Public/educ/GAMA/2007/Deferred_Shading_Tutorial_SBGAMES2005.
      pdf
24.   Josh Klint (CEO, Leadwerks Corporation ), “Deferred Rendering in Leadwerks Engine “,
      Available at:
      http://leadwerks.com/files/Deferred_Rendering_in_Leadwerks_Engine.pdf
Previous Presentation
   [Spring 2011] Sean Thomas
    http://smt565.blogspot.com/

   [Spring 2010] Ian Perera
    http://www.seas.upenn.edu/~cis565/LEC
    TURE2010/Deferred%20RenderingMacro.
    pptm
1 of 98

Recommended

Lighting the City of Glass by
Lighting the City of GlassLighting the City of Glass
Lighting the City of GlassElectronic Arts / DICE
106.7K views167 slides
Star Ocean 4 - Flexible Shader Managment and Post-processing by
Star Ocean 4 - Flexible Shader Managment and Post-processingStar Ocean 4 - Flexible Shader Managment and Post-processing
Star Ocean 4 - Flexible Shader Managment and Post-processingumsl snfrzb
7.2K views114 slides
A Bit More Deferred Cry Engine3 by
A Bit More Deferred   Cry Engine3A Bit More Deferred   Cry Engine3
A Bit More Deferred Cry Engine3guest11b095
12K views27 slides
Rendering Technologies from Crysis 3 (GDC 2013) by
Rendering Technologies from Crysis 3 (GDC 2013)Rendering Technologies from Crysis 3 (GDC 2013)
Rendering Technologies from Crysis 3 (GDC 2013)Tiago Sousa
24.6K views64 slides
Z Buffer Optimizations by
Z Buffer OptimizationsZ Buffer Optimizations
Z Buffer Optimizationspjcozzi
18.2K views41 slides
Lighting of Killzone: Shadow Fall by
Lighting of Killzone: Shadow FallLighting of Killzone: Shadow Fall
Lighting of Killzone: Shadow FallGuerrilla
26.6K views118 slides

More Related Content

What's hot

Taking Killzone Shadow Fall Image Quality Into The Next Generation by
Taking Killzone Shadow Fall Image Quality Into The Next GenerationTaking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next GenerationGuerrilla
14.9K views112 slides
Rendering AAA-Quality Characters of Project A1 by
Rendering AAA-Quality Characters of Project A1Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1Ki Hyunwoo
19.7K views94 slides
Lighting Shading by John Hable by
Lighting Shading by John HableLighting Shading by John Hable
Lighting Shading by John HableNaughty Dog
16.9K views313 slides
Physically Based and Unified Volumetric Rendering in Frostbite by
Physically Based and Unified Volumetric Rendering in FrostbitePhysically Based and Unified Volumetric Rendering in Frostbite
Physically Based and Unified Volumetric Rendering in FrostbiteElectronic Arts / DICE
160.6K views56 slides
Moving Frostbite to Physically Based Rendering by
Moving Frostbite to Physically Based RenderingMoving Frostbite to Physically Based Rendering
Moving Frostbite to Physically Based RenderingElectronic Arts / DICE
345.7K views91 slides
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu... by
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...Electronic Arts / DICE
5.7K views58 slides

What's hot(20)

Taking Killzone Shadow Fall Image Quality Into The Next Generation by Guerrilla
Taking Killzone Shadow Fall Image Quality Into The Next GenerationTaking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next Generation
Guerrilla14.9K views
Rendering AAA-Quality Characters of Project A1 by Ki Hyunwoo
Rendering AAA-Quality Characters of Project A1Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1
Ki Hyunwoo19.7K views
Lighting Shading by John Hable by Naughty Dog
Lighting Shading by John HableLighting Shading by John Hable
Lighting Shading by John Hable
Naughty Dog16.9K views
Physically Based and Unified Volumetric Rendering in Frostbite by Electronic Arts / DICE
Physically Based and Unified Volumetric Rendering in FrostbitePhysically Based and Unified Volumetric Rendering in Frostbite
Physically Based and Unified Volumetric Rendering in Frostbite
Electronic Arts / DICE160.6K views
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu... by Electronic Arts / DICE
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
Physically Based Lighting in Unreal Engine 4 by Lukas Lang
Physically Based Lighting in Unreal Engine 4Physically Based Lighting in Unreal Engine 4
Physically Based Lighting in Unreal Engine 4
Lukas Lang10.8K views
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014) by Philip Hammer
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
Philip Hammer7.3K views
Calibrating Lighting and Materials in Far Cry 3 by stevemcauley
Calibrating Lighting and Materials in Far Cry 3Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3
stevemcauley12.7K views
Graphics Gems from CryENGINE 3 (Siggraph 2013) by Tiago Sousa
Graphics Gems from CryENGINE 3 (Siggraph 2013)Graphics Gems from CryENGINE 3 (Siggraph 2013)
Graphics Gems from CryENGINE 3 (Siggraph 2013)
Tiago Sousa11K views
Secrets of CryENGINE 3 Graphics Technology by Tiago Sousa
Secrets of CryENGINE 3 Graphics TechnologySecrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics Technology
Tiago Sousa32.3K views
Screen Space Reflections in The Surge by Michele Giacalone
Screen Space Reflections in The SurgeScreen Space Reflections in The Surge
Screen Space Reflections in The Surge
Michele Giacalone8.8K views
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing... by Johan Andersson
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Johan Andersson19.1K views
A Scalable Real-Time Many-Shadowed-Light Rendering System by Bo Li
A Scalable Real-Time Many-Shadowed-Light Rendering SystemA Scalable Real-Time Many-Shadowed-Light Rendering System
A Scalable Real-Time Many-Shadowed-Light Rendering System
Bo Li358 views
The Rendering Technology of Killzone 2 by Guerrilla
The Rendering Technology of Killzone 2The Rendering Technology of Killzone 2
The Rendering Technology of Killzone 2
Guerrilla11.1K views
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run by Electronic Arts / DICE
Five Rendering Ideas from Battlefield 3 & Need For Speed: The RunFive Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Rendering Tech of Space Marine by Pope Kim
Rendering Tech of Space MarineRendering Tech of Space Marine
Rendering Tech of Space Marine
Pope Kim20.5K views
Dissecting the Rendering of The Surge by Philip Hammer
Dissecting the Rendering of The SurgeDissecting the Rendering of The Surge
Dissecting the Rendering of The Surge
Philip Hammer3.4K views
DD18 - SEED - Raytracing in Hybrid Real-Time Rendering by Electronic Arts / DICE
DD18 - SEED - Raytracing in Hybrid Real-Time RenderingDD18 - SEED - Raytracing in Hybrid Real-Time Rendering
DD18 - SEED - Raytracing in Hybrid Real-Time Rendering
Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite by Electronic Arts / DICE
Physically Based Sky, Atmosphere and Cloud Rendering in FrostbitePhysically Based Sky, Atmosphere and Cloud Rendering in Frostbite
Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite

Similar to Deferred shading

4K Checkerboard in Battlefield 1 and Mass Effect Andromeda by
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect AndromedaElectronic Arts / DICE
58K views154 slides
The rendering technology of 'lords of the fallen' philip hammer by
The rendering technology of 'lords of the fallen'   philip hammerThe rendering technology of 'lords of the fallen'   philip hammer
The rendering technology of 'lords of the fallen' philip hammerMary Chan
1.1K views53 slides
Killzone Shadow Fall Demo Postmortem by
Killzone Shadow Fall Demo PostmortemKillzone Shadow Fall Demo Postmortem
Killzone Shadow Fall Demo PostmortemGuerrilla
42.8K views103 slides
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems by
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open ProblemsHPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open ProblemsElectronic Arts / DICE
3.6K views79 slides
DirectX 11 Rendering in Battlefield 3 by
DirectX 11 Rendering in Battlefield 3DirectX 11 Rendering in Battlefield 3
DirectX 11 Rendering in Battlefield 3Electronic Arts / DICE
56.5K views56 slides
Deferred rendering in_leadwerks_engine[1] by
Deferred rendering in_leadwerks_engine[1]Deferred rendering in_leadwerks_engine[1]
Deferred rendering in_leadwerks_engine[1]ozlael ozlael
1.1K views10 slides

Similar to Deferred shading(20)

The rendering technology of 'lords of the fallen' philip hammer by Mary Chan
The rendering technology of 'lords of the fallen'   philip hammerThe rendering technology of 'lords of the fallen'   philip hammer
The rendering technology of 'lords of the fallen' philip hammer
Mary Chan1.1K views
Killzone Shadow Fall Demo Postmortem by Guerrilla
Killzone Shadow Fall Demo PostmortemKillzone Shadow Fall Demo Postmortem
Killzone Shadow Fall Demo Postmortem
Guerrilla42.8K views
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems by Electronic Arts / DICE
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open ProblemsHPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
HPG 2018 - Game Ray Tracing: State-of-the-Art and Open Problems
Deferred rendering in_leadwerks_engine[1] by ozlael ozlael
Deferred rendering in_leadwerks_engine[1]Deferred rendering in_leadwerks_engine[1]
Deferred rendering in_leadwerks_engine[1]
ozlael ozlael1.1K views
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) Unite Seoul Ver. by ozlael ozlael
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) Unite Seoul Ver.유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) Unite Seoul Ver.
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) Unite Seoul Ver.
ozlael ozlael8.6K views
Substanceshanghaippt repacked by Lee Jungpyo
Substanceshanghaippt repackedSubstanceshanghaippt repacked
Substanceshanghaippt repacked
Lee Jungpyo694 views
CS 354 Project 2 and Compression by Mark Kilgard
CS 354 Project 2 and CompressionCS 354 Project 2 and Compression
CS 354 Project 2 and Compression
Mark Kilgard1.3K views
NVIDIA effects GDC09 by IGDA_London
NVIDIA effects GDC09NVIDIA effects GDC09
NVIDIA effects GDC09
IGDA_London3.1K views
Improving Shadows and Reflections via the Stencil Buffer by Mark Kilgard
Improving Shadows and Reflections via the Stencil BufferImproving Shadows and Reflections via the Stencil Buffer
Improving Shadows and Reflections via the Stencil Buffer
Mark Kilgard3.3K views
04. The Rendering Pipeline by Amin Babadi
04. The Rendering Pipeline04. The Rendering Pipeline
04. The Rendering Pipeline
Amin Babadi966 views
Technologies Used In Graphics Rendering by Bhupinder Singh
Technologies Used In Graphics RenderingTechnologies Used In Graphics Rendering
Technologies Used In Graphics Rendering
Bhupinder Singh767 views
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) NDC15 Ver. by ozlael ozlael
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) NDC15 Ver.유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) NDC15 Ver.
유니티 그래픽 최적화, 어디까지 해봤니 (Optimizing Unity Graphics) NDC15 Ver.
ozlael ozlael19.1K views
GRPHICS05 - Rendering (2) by Michael Heron
GRPHICS05 - Rendering (2)GRPHICS05 - Rendering (2)
GRPHICS05 - Rendering (2)
Michael Heron626 views
Crysis 2-key-rendering-features by Raimundo Renato
Crysis 2-key-rendering-featuresCrysis 2-key-rendering-features
Crysis 2-key-rendering-features
Raimundo Renato1.3K views

Recently uploaded

Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx by
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptxPharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptxMs. Pooja Bhandare
93 views51 slides
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant... by
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...Ms. Pooja Bhandare
109 views45 slides
Psychology KS4 by
Psychology KS4Psychology KS4
Psychology KS4WestHatch
90 views4 slides
Create a Structure in VBNet.pptx by
Create a Structure in VBNet.pptxCreate a Structure in VBNet.pptx
Create a Structure in VBNet.pptxBreach_P
75 views8 slides
Psychology KS5 by
Psychology KS5Psychology KS5
Psychology KS5WestHatch
103 views5 slides
Classification of crude drugs.pptx by
Classification of crude drugs.pptxClassification of crude drugs.pptx
Classification of crude drugs.pptxGayatriPatra14
92 views13 slides

Recently uploaded(20)

Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx by Ms. Pooja Bhandare
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptxPharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant... by Ms. Pooja Bhandare
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
Ms. Pooja Bhandare109 views
Psychology KS4 by WestHatch
Psychology KS4Psychology KS4
Psychology KS4
WestHatch90 views
Create a Structure in VBNet.pptx by Breach_P
Create a Structure in VBNet.pptxCreate a Structure in VBNet.pptx
Create a Structure in VBNet.pptx
Breach_P75 views
Psychology KS5 by WestHatch
Psychology KS5Psychology KS5
Psychology KS5
WestHatch103 views
Classification of crude drugs.pptx by GayatriPatra14
Classification of crude drugs.pptxClassification of crude drugs.pptx
Classification of crude drugs.pptx
GayatriPatra1492 views
Narration lesson plan by TARIQ KHAN
Narration lesson planNarration lesson plan
Narration lesson plan
TARIQ KHAN59 views
7 NOVEL DRUG DELIVERY SYSTEM.pptx by Sachin Nitave
7 NOVEL DRUG DELIVERY SYSTEM.pptx7 NOVEL DRUG DELIVERY SYSTEM.pptx
7 NOVEL DRUG DELIVERY SYSTEM.pptx
Sachin Nitave61 views
CUNY IT Picciano.pptx by apicciano
CUNY IT Picciano.pptxCUNY IT Picciano.pptx
CUNY IT Picciano.pptx
apicciano54 views
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB... by Nguyen Thanh Tu Collection
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
Education and Diversity.pptx by DrHafizKosar
Education and Diversity.pptxEducation and Diversity.pptx
Education and Diversity.pptx
DrHafizKosar177 views
AUDIENCE - BANDURA.pptx by iammrhaywood
AUDIENCE - BANDURA.pptxAUDIENCE - BANDURA.pptx
AUDIENCE - BANDURA.pptx
iammrhaywood89 views
Ch. 8 Political Party and Party System.pptx by Rommel Regala
Ch. 8 Political Party and Party System.pptxCh. 8 Political Party and Party System.pptx
Ch. 8 Political Party and Party System.pptx
Rommel Regala53 views
The basics - information, data, technology and systems.pdf by JonathanCovena1
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdf
JonathanCovena1126 views
REPRESENTATION - GAUNTLET.pptx by iammrhaywood
REPRESENTATION - GAUNTLET.pptxREPRESENTATION - GAUNTLET.pptx
REPRESENTATION - GAUNTLET.pptx
iammrhaywood107 views
Use of Probiotics in Aquaculture.pptx by AKSHAY MANDAL
Use of Probiotics in Aquaculture.pptxUse of Probiotics in Aquaculture.pptx
Use of Probiotics in Aquaculture.pptx
AKSHAY MANDAL104 views

Deferred shading

  • 1. Deferred Shading Chun-Fu “Frank” Chao Image from source 1
  • 2. Outline  Why(Why not) deferred shading  History of deferred shading  Basic of deferred shading  Shadow in deferred shading  Extension of deferred shading ◦ Light Pre-Pass deferred shading ◦ Anti-aliasing in deferred shading ◦ Inferred shading ◦ Tile-based deferred shading
  • 3. What is deferred shading?  Instead of intermediately calculate the color and write to frame buffer, we divide the information into smaller parts and write them into intermediate buffer (i.e. G(eometric)-buffer). Then combine and calculate color later. Video from source 15
  • 4. Killzone 2 Behind the Bullet for PlayStation 3 Video from source 2
  • 5. Why deferred shading? Image from source 26
  • 6. Why deferred shading?  Decouple the scene geometry complexity and light complexity ◦ Going from O( #Light * #Triangle ) to O( #Light ) + O( #Triangle )  Only do the BRDF calculation on the visible surfaces  Simplify the rendering process ◦ Few passes on G-buffer V.S. Switching shaders  G-buffer is useful for post-processing
  • 7. Comparison with Forward Rendering  Single pass lighting: For each object Render object Apply all the lights in shader  Why this is not good? ◦ Boated shader if we do code generation for all the light sources ◦ Wasteful ( We are throwing away fully shaded fragment in depth test !) From source 4, slide 3
  • 8. Comparison with Forward Rendering  Multi-pass lighting: For each light For each object affected by light Framebuffer += BRDF( object, light )  Why this is not good? ◦ Repetitive vertex transformation for the same object ◦ Wasteful ( We are “still” throwing away fully shaded fragment in depth test !) From source 4, slide 4
  • 9. Deferred Shading For each object Render the lighting(material) property into G-buffer For each light Framebuffer += BRDF( G-buffer, light )  Simplify the lighting process  O(1) depth complexity for lighting From source 4, slide 5
  • 10. Why “not” deferred shading?  Memory intensive ◦ Multiple buffer ( Multiple render target ) ◦ Buffer read-back ◦ Limited material type  Cannot apply hardware assisted anti-aliasing ◦ MSAA(Multi-sample anti-aliasing) is for pixel already shaded  Cannot handle translucent object ◦ We only have the information of the object with smallest depth value
  • 11. History  Deering, M., et al. “The Triangle Processor and Normal Vector Shader: A VLSI System for High Performance Graphics”, Proceedings of SIGGRAPH ‘88 ◦ Only shading once after depth resolution  T. Saito and T. Takahashi. “Comprehensible rendering of 3d shapes”, Proceedings of SIGGRAPH ’90 ◦ It is designed for contour rendering ◦ The first time the term of G-Buffer appears Image from source 6, 7
  • 12. Multiple Render target  A feature that allows programmable rendering pipeline to render images to multiple render target texture at the same time.  Introduced by OpenGL 2.0 and DirectX 9.0  Supported by Xbox360 and Playstation 3
  • 13. Multiple Render target  We can do deferred shading without Multiple render target. ◦ But the performance is going to be a problem Image from source 6, 8
  • 15. What kind of G-buffer do we need?  Going from the SSAO assignment we did
  • 16. Say we want something like this From source 9, slide 9
  • 17. What kind of G-buffer do we need? From source 9, slide 10
  • 18. What kind of G-buffer do we need? From source 9, slide 11
  • 19. What kind of G-buffer do we need? From source 9, slide 12
  • 20. What kind of G-buffer do we need? From source 9, slide 13
  • 21. What kind of G-buffer do we need? From source 9, slide 14
  • 22. What kind of G-buffer do we need? From source 9, slide 15
  • 23. What kind of G-buffer do we need? From source 9, slide 16
  • 24. What kind of G-buffer do we need? From source 9, slide 17
  • 25. The G-Buffer of Killzone 2  4 X R8G8B8 + 24Depth + 8Stencil ~= 36 MB ◦ We only got 256 MB RAM and 256 MB VRAM on PS3   No Normal.z term ◦ Normal.z = sqrt( 1.0 – Normal.x^2 – Normal.y^2 ) ◦ Trade memory space with computation time From source 9, slide 19
  • 26. The G-buffer of Battlefield 3  Material ID is a common way to manage material R8 G8 B8 A8 GB0 Normal .xyz Spec. Smoothness GB1 Diffuse albedo .rgb Specular albedo GB2 Sky visibility Custom envmap ID Material Param. Material ID GB3 Irradiance (dynamic radiosity) Image from source 9, slide 12 and source 10
  • 27. Lighting Result Image from source 10, slide 31
  • 29. That’s cool. But where is my shadow?  1000 lights without shadow is easy, but 100 lights with shadow is impossible now   Shadow map ◦ A good fit with deferred shading ◦ Need more memory   Shadow volume ◦ Render light as geometry volume ◦ Depth test to determine whether the object is inside the volume or not
  • 30. Shadow map  Create a depth map in the perspective of light source.  Compare the position of the geometry surface with the depth map of light source.  Position = Screen space position + depth Image from source 14
  • 31. Ouch! Image from source 16, Page 16
  • 32. Shadow Volume  Only apply the light to the pixel enclose by the shadow volume  Depth test needs to be handle carefully Image from source 4, slide 12 Image from source 17
  • 33. Xbox Gladiator 2k4 demo Video from source 5
  • 34. Wait! We still have plenty of problems  Memory usage ◦ Light Pre-Pass deferred shading  Anti-aliasing ◦ MLAA ( Morphological Anti-aliasing ) ◦ SRAA ( Sub-pixel Reconstruction Anti-Aliasing )  Alpha blending ◦ Inferred shading
  • 36. Light Pre-pass / Deferred Lighting  Two pass deferred shading  1st pass ◦ Only render depth and normal ◦ Do not need MRT! Image from source 17
  • 37. Light Pre-pass / Deferred Lighting  Write LightColor * N dot L * Attenuation in RGB, specular in A channel Image from source 17
  • 38. Light Pre-pass / Deferred Lighting  2nd geometry pass ◦ Fetch the material property ◦ Combine with light buffer Image from source 17
  • 39. Light Pre-pass / Deferred Lighting  Pro ◦ Less memory required ◦ Doesn’t not require MRT feature = Enable programmer to turn on MSAA in DirectX9 ◦ Only one material fetch regardless number of light  Con ◦ “Two” geometry passes
  • 41. Anti-aliasing  Super-sampling one framebuffer is painful, super-sampling 5 MRT is 5X painful   Hardware supported MSAA is incompatible with deferred shading ◦ MSAA cannot apply to MRT in DirectX 9 ◦ Super-sampling and averaging normal or depth might cause wired result  Imaged based approach of anti-aliasing  We have depth and normal information 
  • 42. Basic Edge-detection Anti-aliasing  Do the 2D edge detection algorithm on frame buffer  Apply low-pass filter across the edge  The discontinuities of normal and depth are better features to locate edges
  • 43. Basic Edge-detection Anti-aliasing  Detect depth or normal discontinuity is better than the color discontinuity Image from source 17
  • 44. Morphological Anti-aliasing  Detect the pattern of color discontinuity  Draw triangular area based on the pattern Image from source 18
  • 45. Morphological Anti-aliasing  Connect the mid-points of the L, Z, and U shape segments.  The blending weight is based on the triangle area enclosed by mid points Image from source 18
  • 46. Sub-pixel Reconstruction Anti- Aliasing  MLAA will alter the shape of the original image Image from source 20
  • 47. Sub-pixel Reconstruction Anti- Aliasing  Determine the blending pattern based on the super-sampled depth and normal information Image from source 20
  • 48. Anti-aliasing comparison Image from source 21, slide 44
  • 49. Anti-aliasing comparison Image from source 21, slide 45
  • 50. Anti-aliasing comparison Image from source 21, slide 46
  • 51. Anti-aliasing comparison Image from source 21, slide 47
  • 52. Anti-aliasing comparison Image from source 21, slide 48
  • 53. Anti-aliasing comparison Image from source 21, slide 49
  • 55. Alpha blending  How do we get transparent/transculant effect in deferred shading ◦ One more forward rendering pass  ◦ Depth peeling  So expensive   Limited layer of transculant material
  • 56. Depth Peeling  Multiple pass of depth buffer generation from front to back  Peel the fragments away after depth buffer generated  Render image form back to front Image from source 22
  • 57. Depth Peeling Image from source 22
  • 58. Inferred Shading  3-pass algorithm based on the 2-pass Light Pre-pass deferred shading  Can create transparent effect in deferred shading scheme ◦ Even multiple layer of transparency! Image from source 23
  • 59. Inferred Shading  Geometry Pass ◦ RT1 : Normal.X / Normal.Y ◦ RT2 : Depth / Object ID ◦ The resolution is lower than target  Light Pass ◦ Apply lighting to the G-buffer to create L-buffer ◦ The resolution is also lower that target  Material Pass ◦ Material fetch ◦ Combine material with L-buffer information
  • 60. Inferred Shading  Discontinuity Sensitive Filtering ◦ Sample lighting information based on the object ID information stored in G-buffer ◦ If the sample is not from the same object, then ignore the sample Image from source 23
  • 61. Lighting Alpha Polygons  Render the transparent objects last in the geometry pass and render them into stipple pattern  Special sampling rule parse over the stipple pattern in the material pass Image from source 23
  • 62. Stipple Pattern Image from source 23
  • 63. Material Pass : Render Opaque Objects Image from source 23
  • 64. Material Pass : Render Transparent Objects Image from source 23
  • 65. Multiple Layer of Transparency Transparent Opaque 1 Opaque Opaque Transparent Transparent 1 3 Transparent Opaque 2 Image from source 23
  • 66. Resolution Decrease Image from source 23
  • 68. Tile-based Deferred Shading  Introduced into Frostbite 2 engine  Divide the screen in screen-space tiles  Cull analytical lights (point, cone, line), per tile  Compute lighting for all contributing lights, per tile Slide from source 25
  • 69. Tile-based Deferred Shading Image from source 10, slide 42
  • 70. Tile-based Deferred Shading Image from source 10, slide 43
  • 71. Tile-based Deferred Shading Image from source 10, slide 43
  • 72. Tile-based Deferred Shading • The screen is divided in 920 tiles of 32x32 pixels • Downsample and classify the scene from 720p to 40x23 (1 pixel == 1 tile) • Find each tile’s Min/Max depth • Find each tile’s material permutations • Downsampling is done in multi-pass and via MRTs Slide from source 25
  • 73. Tile-based Deferred Shading Image from source 25, slide 72
  • 74. Tile-based Deferred Shading Image from source 25, slide 73
  • 75. Tile-based Deferred Shading Image from source 25, slide 74
  • 76. Tile-based Deferred Shading  Build mini-frustas for each tile  Cull lights against sky-free tiles in a shader  Store the culling results in a texture: ◦ Column == Light ID ◦ Row == Tile ID  Actually, 4 lights can be processed at once (A-R-G-B)  Read back the contribution results on the CPU and prepare for lighting! Slide from source 25
  • 77. Tile-based Deferred Shading  Parse the culling results texture on CPU  For each light type For each tile For each material permutation, Regroup & set the light parameters for the pixel shader constants  Setup the shader loop counter (Limited number of light passed)  Additively render lights with a single draw call (to the final HDR lighting buffer) Slide from source 25
  • 78. Tile-based Deferred Shading Image from source 25, slide 66
  • 79. Tile-based Deferred Shading Image from source 25, slide 67
  • 80. Tile-based Deferred Shading Image from source 25, slide 68
  • 81. Tile-based Deferred Shading Image from source 25, slide 69
  • 82. Thank you  Questions? Image from source 25
  • 83. BONUS
  • 85. Demonstration Image from source 1
  • 86. Approximating Translucency Image from source 1
  • 87. Approximating Translucency Image from source 1
  • 89. Source 1. John Chapman, “Deferred Rendering, Transparency & Alpha Blending Tutorial”, Available at: http://john-chapman.net/content.php?id=13 2. Guerrilla Games, “Killzone 2 Behind the Bullet for PlayStation 3”, Available at: http://www.youtube.com/watch?v=tzx_JfujYT4 3. Shawn Hargreaves, “Deferred Shading”, Available at: http://www.shawnhargreaves.com/DeferredShading.pdf 4. Shawn Hargreaves, “Deferred Shading : 6800 Leagues Under The Sea”, Available at: http://http.download.nvidia.com/developer/presentations/2004/6800_Leagues/ 6800_Leagues_Deferred_Shading.pdf 5. Rich Geldreich, “Deferred Lighting and Shading”, Available at: https://sites.google.com/site/richgel99/ 6. Deering, M., et al. “The Triangle Processor and Normal Vector Shader: A VLSI System for High Performance Graphics”, Proceedings of SIGGRAPH ‘88 , Available at: http://dl.acm.org/citation.cfm?id=378468
  • 90. Source 7. T. Saito and T. Takahashi. “Comprehensible rendering of 3d shapes”, Proceedings of SIGGRAPH ’90, Available at: http://dl.acm.org/citation.cfm?id=97901 8. Filion, D. and McNaughton, R. (Blizzard Entertainment), “ StarCraft II: Effects & Techniques”, slide available at: http://developer.amd.com/gpu_assets/S2008-Filion-McNaughton-StarCraftII.pdf Course note available at: http://developer.amd.com/documentation/presentations/legacy/Chapter05- Filion-StarCraftII.pdf 9. Michal Valient (Guerrilla), “Deferred Rendering in Killzone 2 “, Available at: http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf 10. Christina Coffin (DICE), “SPU-based Deferred Shading for Battlefield 3 on Playstation 3”, Available at: http://publications.dice.se/publications.asp?show_category=yes&which_categor y=Rendering 11. Colin Barré-Brisebois (DICE), “Approximating Translucency for a Fast, Cheap and Convincing Subsurface Scattering Look”, Available at: http://zigguratvertigo.com/tag/deferred-shading/
  • 91. Source 12. Michal Valient (Guerrilla), “The Rendering Technology of Killzone 2”, Available at: http://www.slideshare.net/guerrillagames/the-rendering-technology-of-killzone- 2 13. Michiel van der Leeuw (Guerrilla), “The PlayStation®3’s SPUs in the Real World: A KILLZONE 2 Case Study “, Available at: http://www.slideshare.net/guerrillagames/the-playstation3s-spus-in-the-real- world-a-killzone-2-case-study-9886224 14. Wikipedia : Shadow Mapping http://en.wikipedia.org/wiki/Shadow_mapping 15. Wikipedia : Deferred Shading http://en.wikipedia.org/wiki/Deferred_shading 16. Johan Andersson (DICE), “5 Major Challenges in Interactive Rendering”, Available at: http://publications.dice.se/publications.asp?show_category=yes&which_categor y=Rendering 17. Nicolas Thibieroz, “Deferred Shading Optimizations” , Available at: http://developer.amd.com/gpu_assets/Deferred%20Shading%20Optimizations.p ps
  • 92. Source 18. Alexander Reshetov (Intel Labs ), “Morphological Antialiasing” , Available at: http://visual-computing.intel- research.net/publications/papers/2009/mlaa/mlaa.pdf 19. Alexandre De Pereyra (Intel), “MLAA: Efficiently Moving Antialiasing from the GPU to the CPU”, Available at: http://software.intel.com/en-us/articles/mlaa-efficiently-moving-antialiasing- from-the-gpu-to-the-cpu/ 20. Chajdas, McGuire, and Luebke, Subpixel Reconstruction Antialiasing, ACM Symposium on Interactive 3D Graphics and Games (I3D 2011 proceedings), February 2011, Available at: http://graphics.cs.williams.edu/papers/SRAAI3D11/ 21. Johan Andersson (DICE), “DirectX 11 Rendering in Battlefield 3”, Available at: http://publications.dice.se/publications.asp?show_category=yes&which_categor y=Rendering 22. Cass Everitt (Nvidia), “Interactive Order-Independent Transparency”, Available at: http://developer.nvidia.com/content/interactive-order-independent- transparency
  • 93. Source 23. Scott Kircher and Alan Lawrance. 2009. Inferred lighting: fast dynamic lighting and shadows for opaque and translucent objects. In Proceedings of the 2009 ACM SIGGRAPH Symposium on Video Games (Sandbox '09), Stephen N. Spencer (Ed.). ACM, New York, NY, USA, 39-45. Available at: http://dl.acm.org/citation.cfm?id=1581080 24. ENGEL, W., 2008. Diary of a graphics programmer: Light pre-pass renderer. Online, accessed Jan. 27th, 2009. Available at: http://diaryofagraphicsprogrammer.blogspot.com/2008/03/light-pre-pass- renderer.html. 25. John White (Black Box), Colin Barré-Brisebois (DICE)“More Performance! Five Rendering Ideas from Battlefield 3 and Need For Speed The Run”, Available at: http://publications.dice.se/ 26. Kenny Magnusson (DICE),“Lighting you up in Battlefield 3” http://publications.dice.se/
  • 94. Indirect Reference Source 1. Oles Shishkovtsov (GSC Game World), "GPU Gems 2 Chapter 9. Deferred Shading in S.T.A.L.K.E.R.", Available at: http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter09.html 2. Rusty Koonce (NCsoft Corporation), "GPU Gems 3 chapter 19. Deferred Shading in Tabula Rasa", Available at: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch19.html 3. Tiago Sousa(Crytek), "GPU Gems 3 chapter 16. Vegetation Procedural Animation and Shading in Crysis", Available at: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch16.html 4. Wolfgang Engel, “ShaderX2 : introductions and tutorials with DirectX 9”, Available at: http://tog.acm.org/resources/shaderx/Introductions_and_Tutorials_with_Direct X_9.pdf 5. Wolfgang Engel, “Light Pre-Pass -Deferred Lighting: Latest Development”, Available at: http://www.bungie.net/images/Inside/publications/siggraph/Engel/LightPrePass. ppt
  • 95. Indirect Reference Source 6. Mark Lee(Insomniac games), “Pre-lighting, Available at: http://www.insomniacgames.com/tech/articles/0209/files/prelighting.pdf 7. Mark Lee(Insomniac games), “Pre-lighting in Resistance 2”, Available at: http://www.insomniacgames.com/gdc09-resistance-2-prelighting/ 8. Rouslan Dimitrov(Nvidia), “Cascaded Shadow Maps”, Available at: http://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_ maps/doc/cascaded_shadow_maps.pdf 9. Damian Trebilco, “Light Indexed Deferred Lighting”, Available at: http://code.google.com/p/lightindexed-deferredrender/ 10. Andrew Lauritzen(Intel), "Deferred Rendering for Current and Future Rendering Pipelines", Available at: http://visual-computing.intel-research.net/art/publications/deferred_rendering/ 11. B. Segovia, J. C. Iehl, R. Mitanchey, and B. Péroche. 2006. Non-interleaved deferred shading of interleaved sample patterns. In Proceedings of the 21st ACM SIGGRAPH/EUROGRAPHICS symposium on Graphics hardware (GH '06). ACM, New York, NY, USA, 53-60. http://dl.acm.org/citation.cfm?id=1283909
  • 96. Indirect Reference Source 12. John Tsiombikas, “Volume Shadows Tutorial”, Available at: http://nuclear.mutantstargoat.com/ 13. Stefan Brabec , Thomas Annen , Hans-peter Seidel, ” Shadow Mapping for Hemispherical and Omnidirectional Light Sources”, Available at: http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.11.3540 14. Emil Persson (AMD), “Depth In-depth “, Available at: http://developer.amd.com/media/gpu_assets/Depth_in-depth.pdf 15. Sam Martin, Per Einarsson(Geomerics), “A Real Time Radiosity Architecture” http://www.geomerics.com/downloads/radiosity_architecture.pdf 16. Martin Mittring(Crytek), “A bit more deferred – CryEngine3”, Available at: http://www.crytek.com/cryengine/presentations&page=2 17. Anton Kaplanyan(Crytek), “CryENGINE 3: reaching the speed of light” http://www.crytek.com/cryengine/presentations/CryENGINE3-reaching-the- speed-of-light 18. Nickolay Kasyan, Nicolas Schulz, Tiago Sousa(Crytek), ”Secrets of CryENGINE 3 Graphics Technology”, Available at: http://www.crytek.com/cryengine/presentations/secrets-of-cryengine-3- graphics-technology
  • 97. Indirect Reference Source 19. Martin Mittring(Epic games), Bryan Dudash(Nvidia), “The Technology Behind the DirectX 11 Unreal Engine "Samaritan" Demo”, Available at: http://www.nvidia.com/content/PDF/GDC2011/Epic.pdf 20. Dean Calver , “Photo-realistic Deferred Lighting” http://www.beyond3d.com/content/articles/19/1 21. Anton Kaplanyan (Crytek) ,”Light Propagation Volumes in CryEngine 3” , Available at: http://www.crytek.com/cryengine/cryengine3/presentations/light-propagation- volumes-in-cryengine-3 22. Aths, “Multisampling Anti-Aliasing: A Closeup View “, Available at: http://alt.3dcenter.org/artikel/multisampling_anti-aliasing/index3_e.php 23. Fabio Policarpo, Francisco Fonseca(CheckMate Games), “ Deferred Shading Tutorial”, Available at: http://www710.univ- lyon1.fr/~jciehl/Public/educ/GAMA/2007/Deferred_Shading_Tutorial_SBGAMES2005. pdf 24. Josh Klint (CEO, Leadwerks Corporation ), “Deferred Rendering in Leadwerks Engine “, Available at: http://leadwerks.com/files/Deferred_Rendering_in_Leadwerks_Engine.pdf
  • 98. Previous Presentation  [Spring 2011] Sean Thomas http://smt565.blogspot.com/  [Spring 2010] Ian Perera http://www.seas.upenn.edu/~cis565/LEC TURE2010/Deferred%20RenderingMacro. pptm