Deferred Shading Rasmus Vahtra, Andres Traks
Forward rendering (non-deferred shading)
Forward rendering (non-deferred shading)
Forward rendering (non-deferred shading)
Forward rendering (non-deferred shading) Depth culling
Forward rendering (non-deferred shading)
Forward shader: Vertex Shader (VS) VS PS
Forward shader: Pixel Shader (PS) VS PS
Complexity of forward rendering For each light: For each object: Render() Blend results together
Deferred shading Shading done in a separate rendering pass Pass 1: Render object data into buffers Pass 2: Do lighting/shading VS VS PS PS
Deferred shading: 1) collect data into intermediate textures
Deferred shading: 1) collect data into intermediate textures
Deferred shading: 1) collect data into intermediate textures Depth culling
Deferred shading: 1) collect data into intermediate textures, done Donβt care about geometry anymore
Deferred shader: Vertex Shader (pass 1) VS PS
Deferred shader: Pixel Shader (pass 1) VS PS
Deferred shading: 1) collect data into intermediate textures, done
Deferred shading: 2) Draw a full-screen quad UV = (0, 0) (1, 0) (0, 1) (1, 1)
Deferred shader: Pixel Shader (pass 2)
Review VS PS Forward rendering: Deferred shading: VS VS PS PS
Complexity of deferred rendering For each object: Render geometry data Then shade each pixel on screen exactly once
Deferred shading: VS Pass 2) Draw a full-screen quad VS PS ID TexCoord Position 0 (0, 0) (-1, 1, 0, 1) 1 (1, 0) (1, 1, 0, 1) 2 (0, 1) (-1, -1, 0, 1) 3 (1, 1) (1, -1, 0, 1)
Full screen triangle UV = (1, 0) (2, 0) (0, 0) (0, 1) (1, 1) A bit faster than a quad (0, 2)
G-buffer R G B A Diffuse RGB - Normal XYZ - Depth (32-bit) β’ 1920 x 1080 x 3 x 32 bits = 24 MB
G-buffer: extra attributes Battlefield 3 Killzone 2
Packing normals π. π¦ 2 + π. π§ 2 + π. π¨ 2 = 1 Works only with normalized view-space normals! http://aras-p.info/texts/CompactNormalStorage.html
Anti-aliasing Edge-detect Blur if edge detected http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter09.html
Transparent objects? Render them after the deferred pass using forward shading
Deferred lighting
Modifying the G-buffer for deferred lighting R G B A Diffuse RGB - Normal XYZ - Depth (32-bit) Light Accumulation RGB -
Deferred lighting: G-Buffer
Light Stencil Volumes Each point light area is bounded by a sphere (approximate)
Light Stencil Volumes Each point light area is bounded by a sphere (approximate)
Light Stencil Volumes Each point light area is bounded by a sphere (approximate)
Stencil shapes of lights Sphere Cone Fullscreen quad Fullscreen quad http://www.okino.com/new/toolkit/1-14.htm
Other effects: Screen Space Ambient Occlusion (SSAO) http://john-chapman-graphics.blogspot.co.uk/2013/01/ssao-tutorial.html
Recommend
More recommend