Deferred shading explained

In the field of 3D computer graphics, deferred shading is a screen-space shading technique that is performed on a second rendering pass, after the vertex and pixel shaders are rendered.[1] It was first suggested by Michael Deering in 1988.

On the first pass of a deferred shader, only data that is required for shading computation is gathered. Positions, normals, and materials for each surface are rendered into the geometry buffer (G-buffer) using "render to texture". After this, a pixel shader computes the direct and indirect lighting at each pixel using the information of the texture buffers in screen space.

Screen space directional occlusion[2] can be made part of the deferred shading pipeline to give directionality to shadows and interreflections.

Advantages

The primary advantage of deferred shading is the decoupling of scene geometry from lighting. Only one geometry pass is required, and each light is only computed for those pixels that it actually affects. This gives the ability to render many lights in a scene without a significant performance hit.[3] There are some other advantages claimed for the approach. These advantages may include simpler management of complex lighting resources, ease of managing other complex shader resources, and the simplification of the software rendering pipeline.

Disadvantages

One key disadvantage of deferred rendering is the inability to handle transparency within the algorithm, although this problem is a generic one in Z-buffered scenes and it tends to be handled by delaying and sorting the rendering of transparent portions of the scene.[4] Depth peeling can be used to achieve order-independent transparency in deferred rendering, but at the cost of additional batches and g-buffer size. Modern hardware, supporting DirectX 10 and later, is often capable of performing batches fast enough to maintain interactive frame rates. When order-independent transparency is desired (commonly for consumer applications) deferred shading is no less effective than forward shading using the same technique.

Another serious disadvantage is the difficulty with using multiple materials. It's possible to use many different materials, but it requires more data to be stored in the G-buffer, which is already quite large and takes up a large amount of the memory bandwidth.[5]

One more disadvantage is that, due to separating the lighting stage from the geometric stage, hardware anti-aliasing does not produce correct results anymore since interpolated subsamples would result in nonsensical position, normal, and tangent attributes. One of the usual techniques to overcome this limitation is using edge detection on the final image and then applying blur over the edges,[6] however recently more advanced post-process edge-smoothing techniques have been developed, such as MLAA[7] [8] (used in Killzone 3 and Dragon Age II, among others), FXAA[9] (used in Crysis 2, FEAR 3, Duke Nukem Forever), SRAA,[10] DLAA[11] (used in ), and post MSAA (used in Crysis 2 as default anti-aliasing solution). Although it is not an edge-smoothing technique, temporal anti-aliasing (used in and Unreal Engine) can also help give edges a smoother appearance.[12] DirectX 10 introduced features allowing shaders to access individual samples in multisampled render targets (and depth buffers in version 10.1), giving users of this API access to hardware anti-aliasing in deferred shading. These features also allow them to correctly apply HDR luminance mapping to anti-aliased edges, where in earlier versions of the API any benefit of anti-aliasing may have been lost.

Deferred lighting

Deferred lighting (also known as Light Pre-Pass) is a modification of the Deferred Shading.[13] This technique uses three passes, instead of two in deferred shading. On first pass over the scene geometry, only normals and specular spread factor are written to the color buffer. The screen-space, “deferred” pass then accumulates diffuse and specular lighting data separately, so a last pass must be made over the scene geometry to output final image with per-pixel shading. The apparent advantage of deferred lighting is a dramatic reduction in the size of the G-Buffer. The obvious cost is the need to render the scene geometry twice instead of once. An additional cost is that the deferred pass in deferred lighting must output diffuse and specular irradiance separately, whereas the deferred pass in deferred shading need only output a single combined radiance value.

Due to reduction of the size of the G-buffer this technique can partially overcome one serious disadvantage of the deferred shading - multiple materials. Another problem that can be solved is MSAA. Deferred lighting can be used with MSAA on DirectX 9 hardware.

Deferred lighting in commercial games

Use of the technique has increased in video games because of the control it enables in terms of using a large amount of dynamic lights and reducing the complexity of required shader instructions. Some examples of games using deferred lighting are:

Deferred shading in commercial games

In comparison to deferred lighting, this technique is not very popular due to high memory size and bandwidth requirements, especially on seventh generation consoles where graphic memory size and bandwidth are limited and often bottlenecks.

Game engines featuring deferred shading or rendering techniques

History

The idea of deferred shading was originally introduced by Michael Deering and his colleagues in a paper[54] published in 1988 titled The triangle processor and normal vector shader: a VLSI system for high performance graphics. Although the paper never uses the word "deferred", a key concept is introduced; each pixel is shaded only once after depth resolution. Deferred shading as we know it today, using G-buffers, was introduced in a paper by Saito and Takahashi in 1990,[55] although they too do not use the word "deferred". The first deferred shaded video game was Shrek, an Xbox launch title shipped in 2001.[56] Around 2004, implementations on commodity graphics hardware started to appear.[57] The technique later gained popularity for applications such as video games, finally becoming mainstream around 2008 to 2010.[58]

Notes and References

  1. Web site: Forward Rendering vs. Deferred Rendering .
  2. Web site: O'Donnell. Yuriy. 2011-07-18. Deferred Screen Space Directional Occlusion. live. https://web.archive.org/web/20121022014044/http://kayru.org:80/articles/dssdo/ . October 22, 2012 . kayru.org.
  3. Web site: Kayi. Celal Cansin. Deferred Rendering in XNA 4. live. https://web.archive.org/web/20130813002000/http://homepage.lnu.se/staff/tblma/Deferred%20Rendering%20in%20XNA%204.pdf . August 13, 2013 . 2021-01-06. Linnaeus University.
  4. Web site: 2007-01-17. SDK 9.51 – Featured Code Samples. live. https://web.archive.org/web/20050308113755/http://download.nvidia.com:80/developer/SDK/Individual_Samples/featured_samples.html . March 8, 2005 . 2007-03-28. Nvidia.
  5. Web site: Engel. Wolfgang. Wolfgang Engel. 2008-03-16. Light Pre-Pass Renderer. live. https://web.archive.org/web/20080407065111/http://diaryofagraphicsprogrammer.blogspot.com:80/2008/03/light-pre-pass-renderer.html . April 7, 2008 . 2021-01-06. Diary of a Graphics Programmer.
  6. Web site: Deferred shading tutorial . Pontifical Catholic University of Rio de Janeiro . 2008-02-14 . dead . https://web.archive.org/web/20090306111435/http://www710.univ-lyon1.fr/~jciehl/Public/educ/GAMA/2007/Deferred_Shading_Tutorial_SBGAMES2005.pdf . March 6, 2009 .
  7. Web site: MLAA: Efficiently Moving Antialiasing from the GPU to the CPU. Intel. 2018-12-02.
  8. Web site: Morphological antialiasing and topological reconstruction. live. https://web.archive.org/web/20120403081105/http://igm.univ-mlv.fr/~biri/mlaa-gpu/TMLAA.pdf . April 3, 2012 . 2021-01-06. Gustave Eiffel University.
  9. Web site: Archived copy . November 7, 2011 . November 25, 2011 . https://web.archive.org/web/20111125073450/http://www.ngohq.com/images/articles/fxaa/FXAA_WhitePaper.pdf . dead .
  10. Web site: Chajdas. Matthäus G.. McGuire. Morgan. Luebke. David. 2011-02-01. Subpixel Reconstruction Antialiasing. live. https://web.archive.org/web/20110127214054/http://research.nvidia.com:80/publication/subpixel-reconstruction-antialiasing . January 27, 2011 . 2021-01-06. Nvidia.
  11. Web site: Andreev. Dmitry. 2011. Anti-Aliasing from a Different Perspective. live. https://web.archive.org/web/20110404143033/http://www.and.intercon.ru:80/releases/talks/dlaagdc2011/ . April 4, 2011 . 2021-01-06. and.intercon.ru.
  12. Web site: Andreev. Dmitry. 2011-03-04. Anti-Aliasing from a Different Perspective (GDC 2011 Extended Slides). live. https://web.archive.org/web/20110405211515/http://www.and.intercon.ru:80/releases/talks/dlaagdc2011/slides/ . April 5, 2011 . 2021-01-06. and.intercon.ru.
  13. Web site: Real-Time Rendering · Deferred lighting approaches. realtimerendering.com.
  14. Web site: Assassin's Creed III: The Redesigned Anvil Engine. https://web.archive.org/web/20120330004433/http://www.gameinformer.com/b/features/archive/2012/03/28/ac-iii-the-redesigned-anvil-engine.aspx. dead. March 30, 2012. www.GameInformer.com.
  15. Web site: BioShock Infinite development is PS3 focused and uses Uncharted 2 tech . blorge.com . dead . https://web.archive.org/web/20111003222842/http://gamer.blorge.com/2010/11/21/bioshock-infinite-development-is-ps3-focused-and-uses-uncharted-2-tech/ . 2011-10-03 .
  16. Web site: BlackMesa XenEngine: Part 4 – Lighting & Shadows. 18 July 2023. chetanjags.wordpress.com. Chetan Jags. 18 September 2023.
  17. Web site: Tech Interview: Crackdown 2. 26 June 2010. Eurogamer.net.
  18. Web site: A Bit More Deferred Cry Engine3. guest11b095. slideshare.net.
  19. Web site: Dead Space by Electronic Arts . NVIDIA . 2008-02-14 .
  20. Web site: Face-Off: Dead Space 2 . . 2010-02-01 .
  21. Web site: Face-Off: Dead Space 3 . . 2013-02-18 .
  22. Web site: Google Translate. google.com.
  23. Web site: GregaMan, Manage Blog. capcom-unity.com.
  24. Web site: Normals. Imgur.
  25. Web site: Tech Interview: Halo: Reach. 11 December 2010. Eurogamer.net.
  26. Web site: Tech Analysis: Metal Gear Solid 5's FOX Engine. 5 April 2013. Eurogamer.net.
  27. Web site: Archived copy . 2011-07-12 . dead . https://web.archive.org/web/20110915140642/http://cmpmedia.vo.llnwd.net/o1/vault/gdc09/slides/gdc09_insomniac_prelighting.pdf . 2011-09-15 .
  28. Web site: The Making of Shift 2 Unleashed Article • Page 2 • Eurogamer.net. 14 May 2011. Eurogamer.net.
  29. Web site: StarCraft II Effects & techniques . AMD . 2012-07-09.
  30. Web site: CGSociety Maintenance. cgsociety.org. 2011-07-12. https://web.archive.org/web/20150402095240/http://features.cgsociety.org/story_custom.php?story_id=5545. 2015-04-02. dead.
  31. Web site: Deferred Rendering « PlatinumGames Inc. . platinumgames.com . dead . https://web.archive.org/web/20101127091253/http://platinumgames.com/tag/deferred-rendering/ . 2010-11-27 .
  32. Web site: Ghost of Tsushima Analysis: A PS4 Graphics Powerhouse . gamingbolt.com.
  33. Web site: Frictional Games interview. Silard Šimon. playsomnia.com.
  34. Web site: SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3. DICE. slideshare.net.
  35. Web site: Valve Developer Wiki - Dota 2. 10 April 2012.
  36. Web site: Archived copy . 2011-07-12 . https://web.archive.org/web/20110711132810/http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf . 2011-07-11 . dead .
  37. [Miner Wars 2081]
  38. Web site: Tech Interview: Metro 2033 Interview • Page 2 • Eurogamer.net. 25 February 2010. Eurogamer.net.
  39. Web site: History - Electric Sheep Games. 14 April 2011.
  40. Web site: GPU Gems 2: Chapter 9. Deferred Shading in S.T.A.L.K.E.R . . 2005-03-07 . Oles . Shishkovtsov . 2011-02-02.
  41. Web site: Deferred shading in Tabula Rasa . NVIDIA . 2008-02-14 . https://web.archive.org/web/20090203081102/http://http.developer.nvidia.com/GPUGems3/gpugems3_ch19.html . 2009-02-03 . dead .
  42. Web site: Steam Users' Forums - View Single Post - Taking the Physx load off the CPU.... steampowered.com.
  43. Web site: Steam Users' Forums - View Single Post - Trine 2 rendering information - anti-aliasing, overheating, stereo, input lag, etc. steampowered.com.
  44. Web site: CryENGINE 3 Specifications . Crytek GmbH . 2009-03-27 . dead . https://web.archive.org/web/20090327231452/http://www.crytek.com/technology/cryengine-3/specifications/ . March 27, 2009 .
  45. Web site: Lighting you up in Battlefield 3 . . https://web.archive.org/web/20110825085117/http://publications.dice.se/attachments/GDC11_LightingYouUpInBattlefield3.pptx . dead . August 25, 2011 . March 3, 2011 . September 15, 2011 .
  46. Web site: GameStart – Feature List . dead . https://web.archive.org/web/20111202181806/http://gamestart3d.com/feature_list . 2011-12-02.
  47. Web site: Infinity Development Journal – Deferred Lighting . I-Novae Studios . https://archive.today/20130126165723/http://www.infinity-universe.com/Infinity/index.php?option=com_content&task=view&id=105&Itemid=26 . dead . 2013-01-26 . 2009-04-03 . 2011-01-26 .
  48. Web site: BUILD: Deferred rendering . 2009-02-26 . 2015-04-08.
  49. Web site: Torque 3D Development - Advanced Lighting (deferred lighting hybrid) . 2009-03-03 . 2015-07-02.
  50. Web site: Unity 3 Feature Preview – Deferred Rendering . Unity Technologies . Ethan . Vosburgh . 2010-09-09 . 2011-01-26.
  51. Web site: Unreal Engine 4 - Rendering Overview . Epic Games . June 6, 2015.
  52. Web site: Vision Engine 8.2 Brings 3D Technologies Cross-Platform . 2011-10-10 . 2015-04-08 . dead . https://web.archive.org/web/20121116234611/http://havok.com/news-and-press/releases/vision-engine-82-brings-3d-technologies-cross-platform . 2012-11-16.
  53. Web site: The Graphics Technology of Fallout 4 . . November 4, 2015 . 2020-04-24.
  54. Deering . Michael . Stephanie Winner . Bic Schediwy . Chris Duffy . Neil Hunt . The triangle processor and normal vector shader: A VLSI system for high performance graphics . ACM SIGGRAPH Computer Graphics . 22 . 4 . 21–30 . 10.1145/378456.378468 . 1988 .
  55. Saito . Takafumi . Tokiichiro Takahashi . Comprehensible rendering of 3-D shapes . ACM SIGGRAPH Computer Graphics . 24 . 4 . 197–206 . 1990 . 10.1145/97880.97901 .
  56. Web site: GDC 2004 Presentation on Deferred Lighting and Shading. Geldreich. Rich. August 24, 2013. March 11, 2014. https://web.archive.org/web/20140311040026/https://sites.google.com/site/richgel99/home. dead.
  57. Web site: Deferred Shading . NVIDIA . 2007-03-28 .
  58. Web site: Klint . Josh . Deferred Rendering in Leadwerks Engine . Leadwerks . dead . https://web.archive.org/web/20081209174351/http://www.leadwerks.com/files/Deferred_Rendering_in_Leadwerks_Engine.pdf . 2008-12-09.