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