Deferred Shading Rasmus Vahtra, Andres Traks Forward rendering - - PowerPoint PPT Presentation

β–Ά
deferred shading
SMART_READER_LITE
LIVE PREVIEW

Deferred Shading Rasmus Vahtra, Andres Traks Forward rendering - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

Deferred Shading

Rasmus Vahtra, Andres Traks

slide-2
SLIDE 2
slide-3
SLIDE 3
slide-4
SLIDE 4

Forward rendering (non-deferred shading)

slide-5
SLIDE 5

Forward rendering (non-deferred shading)

slide-6
SLIDE 6

Forward rendering (non-deferred shading)

slide-7
SLIDE 7

Forward rendering (non-deferred shading)

Depth culling

slide-8
SLIDE 8

Forward rendering (non-deferred shading)

slide-9
SLIDE 9

Forward shader: Vertex Shader (VS)

VS PS

slide-10
SLIDE 10

Forward shader: Pixel Shader (PS)

VS PS

slide-11
SLIDE 11

Complexity of forward rendering

For each light: For each object: Render() Blend results together

slide-12
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
SLIDE 13

Deferred shading: 1) collect data into intermediate textures

slide-14
SLIDE 14

Deferred shading: 1) collect data into intermediate textures

slide-15
SLIDE 15

Deferred shading: 1) collect data into intermediate textures

Depth culling

slide-16
SLIDE 16

Deferred shading: 1) collect data into intermediate textures, done

Don’t care about geometry anymore

slide-17
SLIDE 17

Deferred shader: Vertex Shader (pass 1)

VS PS

slide-18
SLIDE 18

Deferred shader: Pixel Shader (pass 1)

VS PS

slide-19
SLIDE 19

Deferred shading: 1) collect data into intermediate textures, done

slide-20
SLIDE 20

Deferred shading: 2) Draw a full-screen quad

UV = (0, 0) (0, 1) (1, 1) (1, 0)

slide-21
SLIDE 21

Deferred shader: Pixel Shader (pass 2)

slide-22
SLIDE 22

Review

VS PS VS PS VS PS

Forward rendering: Deferred shading:

slide-23
SLIDE 23

Complexity of deferred rendering

For each object: Render geometry data Then shade each pixel on screen exactly once

slide-24
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
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
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
SLIDE 27

G-buffer: extra attributes

Battlefield 3 Killzone 2

slide-28
SLIDE 28

Packing normals

http://aras-p.info/texts/CompactNormalStorage.html π‘œ. 𝑦2 + π‘œ. 𝑧2 + π‘œ. 𝑨2 = 1 Works only with normalized view-space normals!

slide-29
SLIDE 29

Anti-aliasing

Edge-detect Blur if edge detected

http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter09.html

slide-30
SLIDE 30

Transparent objects?

Render them after the deferred pass using forward shading

slide-31
SLIDE 31

Deferred lighting

slide-32
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
SLIDE 33

Deferred lighting: G-Buffer

slide-34
SLIDE 34

Light Stencil Volumes

Each point light area is bounded by a sphere (approximate)

slide-35
SLIDE 35

Light Stencil Volumes

Each point light area is bounded by a sphere (approximate)

slide-36
SLIDE 36

Light Stencil Volumes

Each point light area is bounded by a sphere (approximate)

slide-37
SLIDE 37

Stencil shapes of lights

Fullscreen quad Fullscreen quad Sphere Cone

http://www.okino.com/new/toolkit/1-14.htm

slide-38
SLIDE 38

Other effects: Screen Space Ambient Occlusion (SSAO)

http://john-chapman-graphics.blogspot.co.uk/2013/01/ssao-tutorial.html