Jump to content

Deferred shading

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Richgel999 (talk | contribs) at 11:47, 24 August 2013 (Changing "Xbox" so it links to the "Xbox (console) wiki page.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Diffuse Color G-Buffer
Z-Buffer
Normal G-Buffer
Final Compositing

Deferred shading is a screen-space shading technique. It is called deferred because no shading is actually performed in the first pass of the vertex and pixel shaders: instead shading is "deferred" until a second pass.

On the first pass of a deferred shader, data that is required for shading computation is only gathered. Positions, normals, and materials for each surface are rendered into the geometry buffer (G-buffer) as a series of textures. 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[1] 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 scene without significant performance-hit.[2] There are some other advantages claimed for the approach. These advantages may include the 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.[3] 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 eats up a large amount of the memory bandwidth.[4]

One more rather important disadvantage is that, due to separating the lighting stage from the geometric stage, hardware anti-aliasing does not produce correct results any more: although the first pass used when rendering the basic properties (diffuse, normal etc.) can use anti-aliasing, it's not until full lighting has been applied that anti-alias is needed. One of the usual techniques to overcome this limitation is using edge detection on the final image and then applying blur over the edges,[5] however recently more advanced post-process edge-smoothing techniques have been developed, such as MLAA[6] (used in Killzone 3 and Dragon Age 2, among others), FXAA[7] (used in Crysis 2, FEAR 3, Duke Nukem Forever), SRAA,[8] DLAA[9] (used in Star Wars: The Force Unleashed II), post MSAA (used in Crysis 2 as default anti-aliasing solution). Although it is not an edge-smoothing technique, Temporal anti-aliasing (used in Halo Reach) can also help give edges a smoother appearance. [10] DirectX 10 introduced features allowing shaders to access individual samples in multisampled render targets (and depth buffers in version 10.1), making hardware anti-aliasing possible in deferred shading. These features also make it possible to correctly apply HDR luminance mapping to anti-aliased edges, where in earlier hardware any benefit of anti-aliasing may be lost, making this form of anti-aliasing desirable in any case.

Deferred lighting

Deferred lighting (also known as Light Pre-Pass) is a modification of the Deferred Shading.[11] This technique uses three passes, instead of two in deferred shading. On first pass over the scene geometry, only the attributes necessary to compute per-pixel lighting (irradiance) are written to the G-Buffer. The screen-space, “deferred” pass then outputs only diffuse and specular lighting data, so a second pass must be made over the scene to read back the lighting data and output the final 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 consoles, where memory size and bandwidth are very limited and often a bottleneck.

Deferred techniques in game engines

History

The idea of deferred shading was originally introduced by Michael Deering and his colleagues in a paper[46] published in 1988 entitled 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,[47] although they too do not use the word "deferred". The first deferred shaded video game was Shrek, a Xbox launch title shipped in 2001[48]. Around 2004 implementations on commodity graphics hardware started to appear.[49] The technique later gained popularity for applications such as video games, finally becoming mainstream around 2008 to 2010.[50]

See also

References

  1. ^ http://kayru.org/articles/dssdo/
  2. ^ http://thecansin.com/Files/Deferred%20Rendering%20in%20XNA%204.pdf
  3. ^ "NVIDIA SDK 9.51 - Featured Code Samples". NVIDIA. 2007-01-17. Retrieved 2007-03-28.
  4. ^ http://diaryofagraphicsprogrammer.blogspot.com/2008/03/light-pre-pass-renderer.html
  5. ^ "Deferred shading tutorial" (PDF). Pontifical Catholic University of Rio de Janeiro. Retrieved 2008-02-14.
  6. ^ http://igm.univ-mlv.fr/~biri/mlaa-gpu/TMLAA.pdf
  7. ^ http://www.ngohq.com/images/articles/fxaa/FXAA_WhitePaper.pdf
  8. ^ http://research.nvidia.com/publication/subpixel-reconstruction-antialiasing
  9. ^ http://and.intercon.ru/releases/talks/dlaagdc2011/
  10. ^ http://and.intercon.ru/releases/talks/dlaagdc2011/slides/
  11. ^ http://www.realtimerendering.com/blog/deferred-lighting-approaches/
  12. ^ http://www.gameinformer.com/b/features/archive/2012/03/28/ac-iii-the-redesigned-anvil-engine.aspx
  13. ^ http://gamer.blorge.com/2010/11/21/bioshock-infinite-development-is-ps3-focused-and-uses-uncharted-2-tech/
  14. ^ http://www.eurogamer.net/articles/digitalfoundry-crackdown2-tech-interview
  15. ^ http://www.slideshare.net/guest11b095/a-bit-more-deferred-cry-engine3
  16. ^ "Dead Space by Electronic Arts". NVIDIA. Retrieved 2008-02-14.
  17. ^ "Face-Off: Dead Space 2". Retrieved 2010-02-01.
  18. ^ "Face-Off: Dead Space 3". Retrieved 2013-02-18.
  19. ^ http://translate.google.com/translate?hl=en&sl=ja&tl=en&u=http%3A%2F%2Fgame.watch.impress.co.jp%2Fdocs%2Fseries%2F3dcg%2F20100922_395310.html
  20. ^ http://www.capcom-unity.com/gregaman/blog/2012/04/05/how_dragons_dogma_changed_the_mt_framework
  21. ^ http://www.eurogamer.net/articles/digitalfoundry-halo-reach-tech-interview
  22. ^ http://www.digitalscrutiny.com/content/2011/01/littlebigplanet-2-tech-analysis/
  23. ^ http://www.eurogamer.net/articles/digitalfoundry-the-making-of-shift-2?page=2
  24. ^ Shishkovtsov, Oles (2005-03-07). "GPU Gems 2: Chapter 9. Deferred Shading in S.T.A.L.K.E.R". Nvidia. Retrieved 2011-02-02.
  25. ^ http://cmpmedia.vo.llnwd.net/o1/vault/gdc09/slides/gdc09_insomniac_prelighting.pdf
  26. ^ "StarCraft II Effects & techniques" (PDF). AMD. Retrieved 2012-07-09.
  27. ^ http://features.cgsociety.org/story_custom.php?story_id=5545
  28. ^ http://platinumgames.com/tag/deferred-rendering/
  29. ^ http://www.playsomnia.com/index.php?option=com_content&view=article&id=863:frictional-games-interview&catid=56:intervjui
  30. ^ http://www.slideshare.net/DICEStudio/spubased-deferred-shading-in-battlefield-3-for-playstation-3
  31. ^ http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf
  32. ^ http://en.wikipedia.org/wiki/Miner_Wars_2081
  33. ^ http://www.eurogamer.net/articles/digitalfoundry-tech-interview-metro-2033?page=2
  34. ^ "History - Electric Sheep Games". Retrieved 14 April 2011.
  35. ^ "Deferred shading in Tabula Rasa". NVIDIA. Retrieved 2008-02-14.
  36. ^ http://forums.steampowered.com/forums/showpost.php?p=16668774&postcount=5
  37. ^ http://forums.steampowered.com/forums/showpost.php?p=27599827&postcount=18
  38. ^ "Valve Developer Wiki - Dota 2". Retrieved 10 April 2012.
  39. ^ "CryENGINE 3 Specifications". Crytek GmbH. Retrieved 2009-03-27.
  40. ^ "Infinity Development Journal – Deferred Lighting". I-Novae Studios. 2009-04-03. Retrieved 2011-01-26.
  41. ^ Vosburgh, Ethan (2010-09-09). "Unity 3 Feature Preview – Deferred Rendering". Unity Technologies. Retrieved 2011-01-26.
  42. ^ "Lighting you up in Battlefield 3". DICE. March 3, 2011. Retrieved September 15, 2011.
  43. ^ "Unreal Engine 3 Showcase - Samaritan". Epic Games. 2011-03-10. Retrieved 2011-07-07.
  44. ^ "GameStart – Feature List".
  45. ^ "Deferred lighting - Alien Swarm SDK". 2012-05-29. Retrieved 2012-05-29.
  46. ^ Deering, Michael. "The triangle processor and normal vector shader: a VLSI system for high performance graphics". ACM SIGGRAPH Computer Graphics. 22 (4). ACM Press: 21–30. doi:10.1145/378456.378468. {{cite journal}}: Unknown parameter |coauthors= ignored (|author= suggested) (help)
  47. ^ Saito, Takafumi (1990). "Comprehensible rendering of 3-D shapes". ACM SIGGRAPH Computer Graphics. 24 (4). ACM Press: 197–206. doi:10.1145/97880.97901. {{cite journal}}: Unknown parameter |coauthors= ignored (|author= suggested) (help)
  48. ^ Geldreich, Rich. "GDC 2004 Presentation on Deferred Lighting and Shading".
  49. ^ "Deferred Shading" (PDF). NVIDIA. Retrieved 2007-03-28.
  50. ^ Klint, Josh. "Deferred Rendering in Leadwerks Engine" (PDF). Leadwerks. {{cite journal}}: Cite journal requires |journal= (help)