Deferred Rendering
in Dying Light
Agenda
Deferred shading - why?
G-Buffer
Questions?
Deferred shading - why?
Deferred shading - why?
>250K objects
Deferred shading - why?
>250K objects
Multiple materials
Deferred shading - why?
>250K objects
Multiple materials
Thousands of lights
Deferred shading - why?
>250K objects
Multiple materials
Thousands of lights
Day-night cycle
Deferred shading - why?
>250K objects
Multiple materials
Thousands of lights
Day-night cycle
Changing weather
Deferred shading - why?
Deferred Shading vs Forward Rendering
● Separated scene and lighting rendering
SCENE
Deferred shading - why?
Deferred Shading vs Forward Rendering
● Separated scene and lighting rendering
○ G-Buffer
SCENE
Deferred Shading vs Forward Rendering
● Separated scene and lighting rendering
○ G-Buffer
● Improved lighting rendering performance
○ Scene complexity independency
Deferred shading - why?
Deferred Shading vs Forward Rendering
● Separated scene and lighting rendering
○ G-Buffer
● Improved lighting rendering performance
○ Scene complexity independency
○ Object material & geometry complexity independency
Deferred shading - why?
Deferred shading - why?
Deferred Shading vs Forward Rendering
● Separated scene and lighting rendering
○ G-Buffer
● Improved lighting rendering performance
○ Scene complexity independency
○ Object material & geometry complexity independency
● Simpler rendering pipeline
○ Easy light handling
Deferred shading - why?
Deferred Shading vs Forward Rendering
● Separated scene and lighting rendering
○ G-Buffer
● Improved lighting rendering performance
○ Scene complexity independency
○ Object material & geometry complexity independency
● Simpler rendering pipeline
○ Easy light handling
○ No material-light litght shader combinations
Deferred shading - why?
Not only lights
● Complex materials
● Scene overdraw
● Consistency
● Lighting model independency
● Deferred Linear Space
Deferred shading - why?
Not only lights
● Complex materials
● Scene overdraw
● Consistency
● Lighting model independency
● Deferred Linear Space
Deferred shading - why?
Not only lights
● Complex materials
● Scene overdraw
● Consistency
● Lighting model independency
● Deferred Linear Space
Deferred shading - why?
Not only lights
● Complex materials
● Scene overdraw
● Consistency
● Lighting model independency
● Deferred Linear Space
Deferred shading - why?
Not only lights
● Complex materials
● Scene overdraw
● Consistency
● Lighting model independency
● Deferred Linear Space
G-Buffer
G-Buffer
Limitations
X Y Z W
R G B A
Z-Buffer
G-Buffer
Limitations
X Y Z W
R G B A
G-Buffer
Limitations
Needs (PBR)
X Y Z W
R G B A
Normal (XYZ)
Specular (RGB)
Diffuse (RGB)
Roughness
Human Skin Translucency Leaves
G-Buffer
How?
X Y Z W
R G B A
Normal (XYZ)
Specular (RGB)
Diffuse (RGB)
Roughness
Human Skin Translucency Leaves
?
G-Buffer
How?
Solutions
● Lower resolution
X Y Z W
R G B A
Normal (XYZ)
Specular (RGB)
Diffuse (RGB)
Roughness
Human Skin Translucency Leaves
?
G-Buffer
How?
Solutions
● Lower resolution
● Spherical Normals
X Y Z W
R G B A
Normal (XYZ)
Specular (RGB)
Diffuse (RGB)
Roughness
Human Skin Translucency Leaves
?
G-Buffer
How?
Solutions
● Lower resolution
● Spherical Normals
● YUV
X Y Z W
R G B A
Normal (XYZ)
Specular (RGB)
Diffuse (RGB)
Roughness
Human Skin Translucency Leaves
?
G-Buffer
How?
Solutions
● Lower resolution
● Spherical Normals
● YUV
● ?
X Y Z W
R G B A
Normal (XYZ)
Specular (RGB)
Diffuse (RGB)
Roughness
Human Skin Translucency Leaves
?
G-Buffer
● Specular & Diffuse
G-Buffer
● Specular & Diffuse
● PBR Materials
○ Metals
○ Dielectrics
Specular Diffuse
Metals
bright
colorful
black
Dielectrics
dark
monochromatic
full range
colorful
G-Buffer
● Specular & Diffuse
● PBR Materials
○ Metals
○ Dielectrics
● Conclusions
○ Metals needs only RGB
○ Dielectrics needs only RGB + Gray
○ Non-overlaping ranges
Specular Diffuse
Metals
bright
colorful
black
Dielectrics
dark
monochromatic
full range
colorful
G-Buffer
● Specular & Diffuse
● PBR Materials
○ Metals
○ Dielectrics
● Conclusions
○ Metals needs only RGB
○ Dielectrics needs only RGB + Gray
○ Non-overlaping ranges
● PBR needs (real)
Specular Diffuse
Metals
bright
colorful
black
Dielectrics
dark
monochromatic
full range
colorful
RGB Alpha
Metal specular color 0 (black)
Dielectric diffuse color Dielectric specular
G-Buffer
● Specular & Diffuse
● PBR Materials
○ Metals
○ Dielectrics
● Conclusions
○ Metals needs only RGB
○ Dielectrics needs only RGB + Gray
○ Non-overlaping ranges
● PBR needs (real)
○ Lossless
Specular Diffuse
Metals
bright
colorful
black
Dielectrics
dark
monochromatic
full range
colorful
RGB Alpha
Metal specular color 0 (black)
Dielectric diffuse color Dielectric specular
G-Buffer
● Encoding
rgb = dielectric ? diffuse.rgb : specular.rgb
alpha = dielectric ? specular.g : 0.0
G-Buffer
● Encoding
rgb = dielectric ? diffuse.rgb : specular.rgb
alpha = dielectric ? specular.g : 0.0
● Decoding
Specular = (alpha > 0.0) ? alpha : rgb;
Diffuse = (alpha > 0.0) ? rgb : 0.0;
G-Buffer
Specular & Diffuse
Normal (XYZ)
Specular (RGB)
Diffuse (RGB)
Roughness
Human Skin Translucency Leaves
G-Buffer
Specular & Diffuse
Normal (XYZ)
Specular/Diffuse (RGB) Specular (SD)
Roughness
Human Skin Translucency Leaves
G-Buffer
Specular & Diffuse
Roughness
Normal (XYZ)
Specular/Diffuse (RGB) Specular (SD)
Roughness
Human Skin Translucency Leaves
G-Buffer
Specular & Diffuse
Roughness
Masks
● subsurface scattering
● dielectrics only
● binary values
● exclusive
Normal (XYZ) Roughness
Specular/Diffuse (RGB) Specular (SD)
Human Skin Translucency Leaves
G-Buffer
Diffuse/Specular alpha channel - human skin
Normal (XYZ) Roughness
Specular/Diffuse (RGB) Specular (SD)
Human Skin Translucency Leaves
G-Buffer
Diffuse/Specular alpha channel - human skin
M Dielectric Specular
0 1 255
G-Buffer
Diffuse/Specular alpha channel - human skin
M Dielectric Specular H
0 1 254 255
G-Buffer
Diffuse/Specular alpha channel - translucency
● simple subsurface scattering
M Dielectric Specular H
0 1 254 255
G-Buffer
Diffuse/Specular alpha channel - translucency
● simple subsurface scattering
● varying specular
M Dielectric Specular H
0 1 254 255
G-Buffer
Diffuse/Specular alpha channel - translucency
● simple subsurface scattering
● varying specular
● signed format?
M Dielectric Specular H
0 1 254 255
G-Buffer
Diffuse/Specular alpha channel - translucency
● simple subsurface scattering
● varying specular
● signed format?
● encoding/decoding - single mad instruction (alpha * 2.0 - 1.0)
H Translucent Dielectric Specular M M Dielectric Specular H
0 1 126 127 128 129 254 255
-1.0 0.0 1.0
G-Buffer
Diffuse/Specular alpha channel - translucency
● simple subsurface scattering
● varying specular
● signed format?
● encoding/decoding - single mad instruction (alpha * 2.0 - 1.0)
● encoded specular inversion - abs()
H Translucent Dielectric Specular M M Dielectric Specular H
0 1 max min 126 127 128 129 min max 254 255
-1.0 0.0 1.0
G-Buffer
Diffuse/Specular alpha channel - leaves
● simplified lighting for tree crowns
H Translucent Dielectric Specular M M Dielectric Specular H
0 1 max min 126 127 128 129 min max 254 255
-1.0 0.0 1.0
G-Buffer
Diffuse/Specular alpha channel - leaves
● simplified lighting for tree crowns
● no specular
H Translucent Dielectric Specular M M Dielectric Specular H
0 1 max min 126 127 128 129 min max 254 255
-1.0 0.0 1.0
G-Buffer
Diffuse/Specular alpha channel - leaves
L Translucent Dielectric Specular M M Dielectric Specular H
0 1 max min 126 127 128 129 min max 254 255
-1.0 0.0 1.0
Final layout (almost)
Normal (XYZ) Roughness
Specular/Diffuse (RGB) M/SD/H/T/L
G-Buffer
G-Buffer
Final layout
Normal (XYZ) M/SD/H/T/L
Specular/Diffuse (RGB) Roughness
G-Buffer
Final layout - summary
● simple (en)coding
Normal (XYZ) M/SD/H/T/L
Specular/Diffuse (RGB) Roughness
G-Buffer
Final layout - summary
● simple (en)coding
● slim
Normal (XYZ) M/SD/H/T/L
Specular/Diffuse (RGB) Roughness
G-Buffer
Final layout - summary
● simple (en)coding
● slim
● lossless
Normal (XYZ) M/SD/H/T/L
Specular/Diffuse (RGB) Roughness
G-Buffer
Final layout - summary
● simple (en)coding
● slim
● lossless
● PBR correct
Normal (XYZ) M/SD/H/T/L
Specular/Diffuse (RGB) Roughness
Questions?

Deferred rendering in Dying Light

  • 1.
  • 2.
    Agenda Deferred shading -why? G-Buffer Questions?
  • 3.
  • 4.
    Deferred shading -why? >250K objects
  • 5.
    Deferred shading -why? >250K objects Multiple materials
  • 6.
    Deferred shading -why? >250K objects Multiple materials Thousands of lights
  • 7.
    Deferred shading -why? >250K objects Multiple materials Thousands of lights Day-night cycle
  • 8.
    Deferred shading -why? >250K objects Multiple materials Thousands of lights Day-night cycle Changing weather
  • 9.
    Deferred shading -why? Deferred Shading vs Forward Rendering ● Separated scene and lighting rendering SCENE
  • 10.
    Deferred shading -why? Deferred Shading vs Forward Rendering ● Separated scene and lighting rendering ○ G-Buffer SCENE
  • 11.
    Deferred Shading vsForward Rendering ● Separated scene and lighting rendering ○ G-Buffer ● Improved lighting rendering performance ○ Scene complexity independency Deferred shading - why?
  • 12.
    Deferred Shading vsForward Rendering ● Separated scene and lighting rendering ○ G-Buffer ● Improved lighting rendering performance ○ Scene complexity independency ○ Object material & geometry complexity independency Deferred shading - why?
  • 13.
    Deferred shading -why? Deferred Shading vs Forward Rendering ● Separated scene and lighting rendering ○ G-Buffer ● Improved lighting rendering performance ○ Scene complexity independency ○ Object material & geometry complexity independency ● Simpler rendering pipeline ○ Easy light handling
  • 14.
    Deferred shading -why? Deferred Shading vs Forward Rendering ● Separated scene and lighting rendering ○ G-Buffer ● Improved lighting rendering performance ○ Scene complexity independency ○ Object material & geometry complexity independency ● Simpler rendering pipeline ○ Easy light handling ○ No material-light litght shader combinations
  • 15.
    Deferred shading -why? Not only lights ● Complex materials ● Scene overdraw ● Consistency ● Lighting model independency ● Deferred Linear Space
  • 16.
    Deferred shading -why? Not only lights ● Complex materials ● Scene overdraw ● Consistency ● Lighting model independency ● Deferred Linear Space
  • 17.
    Deferred shading -why? Not only lights ● Complex materials ● Scene overdraw ● Consistency ● Lighting model independency ● Deferred Linear Space
  • 18.
    Deferred shading -why? Not only lights ● Complex materials ● Scene overdraw ● Consistency ● Lighting model independency ● Deferred Linear Space
  • 19.
    Deferred shading -why? Not only lights ● Complex materials ● Scene overdraw ● Consistency ● Lighting model independency ● Deferred Linear Space
  • 20.
  • 21.
    G-Buffer Limitations X Y ZW R G B A Z-Buffer
  • 22.
  • 23.
    G-Buffer Limitations Needs (PBR) X YZ W R G B A Normal (XYZ) Specular (RGB) Diffuse (RGB) Roughness Human Skin Translucency Leaves
  • 24.
    G-Buffer How? X Y ZW R G B A Normal (XYZ) Specular (RGB) Diffuse (RGB) Roughness Human Skin Translucency Leaves ?
  • 25.
    G-Buffer How? Solutions ● Lower resolution XY Z W R G B A Normal (XYZ) Specular (RGB) Diffuse (RGB) Roughness Human Skin Translucency Leaves ?
  • 26.
    G-Buffer How? Solutions ● Lower resolution ●Spherical Normals X Y Z W R G B A Normal (XYZ) Specular (RGB) Diffuse (RGB) Roughness Human Skin Translucency Leaves ?
  • 27.
    G-Buffer How? Solutions ● Lower resolution ●Spherical Normals ● YUV X Y Z W R G B A Normal (XYZ) Specular (RGB) Diffuse (RGB) Roughness Human Skin Translucency Leaves ?
  • 28.
    G-Buffer How? Solutions ● Lower resolution ●Spherical Normals ● YUV ● ? X Y Z W R G B A Normal (XYZ) Specular (RGB) Diffuse (RGB) Roughness Human Skin Translucency Leaves ?
  • 29.
  • 30.
    G-Buffer ● Specular &Diffuse ● PBR Materials ○ Metals ○ Dielectrics Specular Diffuse Metals bright colorful black Dielectrics dark monochromatic full range colorful
  • 31.
    G-Buffer ● Specular &Diffuse ● PBR Materials ○ Metals ○ Dielectrics ● Conclusions ○ Metals needs only RGB ○ Dielectrics needs only RGB + Gray ○ Non-overlaping ranges Specular Diffuse Metals bright colorful black Dielectrics dark monochromatic full range colorful
  • 32.
    G-Buffer ● Specular &Diffuse ● PBR Materials ○ Metals ○ Dielectrics ● Conclusions ○ Metals needs only RGB ○ Dielectrics needs only RGB + Gray ○ Non-overlaping ranges ● PBR needs (real) Specular Diffuse Metals bright colorful black Dielectrics dark monochromatic full range colorful RGB Alpha Metal specular color 0 (black) Dielectric diffuse color Dielectric specular
  • 33.
    G-Buffer ● Specular &Diffuse ● PBR Materials ○ Metals ○ Dielectrics ● Conclusions ○ Metals needs only RGB ○ Dielectrics needs only RGB + Gray ○ Non-overlaping ranges ● PBR needs (real) ○ Lossless Specular Diffuse Metals bright colorful black Dielectrics dark monochromatic full range colorful RGB Alpha Metal specular color 0 (black) Dielectric diffuse color Dielectric specular
  • 34.
    G-Buffer ● Encoding rgb =dielectric ? diffuse.rgb : specular.rgb alpha = dielectric ? specular.g : 0.0
  • 35.
    G-Buffer ● Encoding rgb =dielectric ? diffuse.rgb : specular.rgb alpha = dielectric ? specular.g : 0.0 ● Decoding Specular = (alpha > 0.0) ? alpha : rgb; Diffuse = (alpha > 0.0) ? rgb : 0.0;
  • 36.
    G-Buffer Specular & Diffuse Normal(XYZ) Specular (RGB) Diffuse (RGB) Roughness Human Skin Translucency Leaves
  • 37.
    G-Buffer Specular & Diffuse Normal(XYZ) Specular/Diffuse (RGB) Specular (SD) Roughness Human Skin Translucency Leaves
  • 38.
    G-Buffer Specular & Diffuse Roughness Normal(XYZ) Specular/Diffuse (RGB) Specular (SD) Roughness Human Skin Translucency Leaves
  • 39.
    G-Buffer Specular & Diffuse Roughness Masks ●subsurface scattering ● dielectrics only ● binary values ● exclusive Normal (XYZ) Roughness Specular/Diffuse (RGB) Specular (SD) Human Skin Translucency Leaves
  • 40.
    G-Buffer Diffuse/Specular alpha channel- human skin Normal (XYZ) Roughness Specular/Diffuse (RGB) Specular (SD) Human Skin Translucency Leaves
  • 41.
    G-Buffer Diffuse/Specular alpha channel- human skin M Dielectric Specular 0 1 255
  • 42.
    G-Buffer Diffuse/Specular alpha channel- human skin M Dielectric Specular H 0 1 254 255
  • 43.
    G-Buffer Diffuse/Specular alpha channel- translucency ● simple subsurface scattering M Dielectric Specular H 0 1 254 255
  • 44.
    G-Buffer Diffuse/Specular alpha channel- translucency ● simple subsurface scattering ● varying specular M Dielectric Specular H 0 1 254 255
  • 45.
    G-Buffer Diffuse/Specular alpha channel- translucency ● simple subsurface scattering ● varying specular ● signed format? M Dielectric Specular H 0 1 254 255
  • 46.
    G-Buffer Diffuse/Specular alpha channel- translucency ● simple subsurface scattering ● varying specular ● signed format? ● encoding/decoding - single mad instruction (alpha * 2.0 - 1.0) H Translucent Dielectric Specular M M Dielectric Specular H 0 1 126 127 128 129 254 255 -1.0 0.0 1.0
  • 47.
    G-Buffer Diffuse/Specular alpha channel- translucency ● simple subsurface scattering ● varying specular ● signed format? ● encoding/decoding - single mad instruction (alpha * 2.0 - 1.0) ● encoded specular inversion - abs() H Translucent Dielectric Specular M M Dielectric Specular H 0 1 max min 126 127 128 129 min max 254 255 -1.0 0.0 1.0
  • 48.
    G-Buffer Diffuse/Specular alpha channel- leaves ● simplified lighting for tree crowns H Translucent Dielectric Specular M M Dielectric Specular H 0 1 max min 126 127 128 129 min max 254 255 -1.0 0.0 1.0
  • 49.
    G-Buffer Diffuse/Specular alpha channel- leaves ● simplified lighting for tree crowns ● no specular H Translucent Dielectric Specular M M Dielectric Specular H 0 1 max min 126 127 128 129 min max 254 255 -1.0 0.0 1.0
  • 50.
    G-Buffer Diffuse/Specular alpha channel- leaves L Translucent Dielectric Specular M M Dielectric Specular H 0 1 max min 126 127 128 129 min max 254 255 -1.0 0.0 1.0
  • 51.
    Final layout (almost) Normal(XYZ) Roughness Specular/Diffuse (RGB) M/SD/H/T/L G-Buffer
  • 52.
    G-Buffer Final layout Normal (XYZ)M/SD/H/T/L Specular/Diffuse (RGB) Roughness
  • 53.
    G-Buffer Final layout -summary ● simple (en)coding Normal (XYZ) M/SD/H/T/L Specular/Diffuse (RGB) Roughness
  • 54.
    G-Buffer Final layout -summary ● simple (en)coding ● slim Normal (XYZ) M/SD/H/T/L Specular/Diffuse (RGB) Roughness
  • 55.
    G-Buffer Final layout -summary ● simple (en)coding ● slim ● lossless Normal (XYZ) M/SD/H/T/L Specular/Diffuse (RGB) Roughness
  • 56.
    G-Buffer Final layout -summary ● simple (en)coding ● slim ● lossless ● PBR correct Normal (XYZ) M/SD/H/T/L Specular/Diffuse (RGB) Roughness
  • 57.