SlideShare a Scribd company logo
Bindless Deferred Decals in
Philip Hammer
(DECK13 Interactive GmbH)
Digital Dragons 2019, Krakow
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
This talk is ..
● .. about
○ our own implementation of bindless deferred decals in D3D12 and Vulkan
○ overcoming problems of past approaches
○ practical bread & butter techniques
○ how to efficiently render many decals on the GPU
○ tackling common issues and glitches
● .. but unfortunately not
○ super-fancy new research
○ a comprehensive view on our new renderer
● .. and has
○ probably more too much source code
2
2
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Introduction
● Brief overview of the latest iteration of our inhouse FLEDGE engine
● 4th generation: re-designed renderer module from ground up:
○ Vulkan + D3D12 support only
○ Dropped legacy code (D3D11)
○ No more OOP code - all in for DOD / SoA
○ New possibilities for high-level renderer design (e.g. bindless texturing)
● Improved some existing features e.g.
○ Clustered Deferred + Clustered Forward Rendering
○ Physical-based Rendering
● Some fancy new rendering features, e.g.
○ Unified Volumetric Lighting, Irradiance Probe Grid, Simulated interactive grass, Temporal Antialiasing, etc.
○ Unfortunately not part of this talk :-)
3
3
Bindless Deferred Decals in The Surge 2
Bindless Deferred Decals in The Surge 2
Bindless Deferred Decals in The Surge 2
Bindless Deferred Decals in The Surge 2
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Motivation
● Decals = one key benefit of deferred rendering
● Used in environment art + VFX
○ Static decals to detail the world
○ Dynamic decals spawned by the effect system
○ Gameplay-driven decals like footsteps
● High demands on decal count, usability and performance
8
8
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Decal usage & examples
99
9
Decal usage & examples
10
Decal usage & examples
11
Decal usage & examples
12
Decal usage & examples
13
Decal usage & examples
14
Decal usage & examples
15
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Rasterization-based deferred decals
● Had deferred decals for quite a while [LotF14]
○ Be aware of decal count, overdraw, etc.
○ Limitations led to sparse usage
● “Classic” deferred decal rendering
○ analogous to deferred light volume rendering
● Improved that a lot over the years, but basic principle stayed the same
16
16
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Rasterization-based deferred decals
● Advantages
○ Easy to implement and possible with most
(even older) graphics APIs
○ Near pixel-perfect culling and shader segmentation
● Disadvantages
○ CPU-Performance
■ one drawcall per decal
■ Lots of state setup per decal
○ GPU-Performance
■ Double work: fetching gbuffers,
rasterizing fragments, etc.
■ Need to update the G-Buffer as
intermediate blend buffer
17
17
Transformed box geometry rasterizing a decal
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Bindless Deferred Decals
● How about rendering all decals at once?
18
18
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Bindless Deferred Decals
● How about rendering all decals at once?
● Problem: Too many resource bindings
○ Each decal references a potentially unique set of textures
○ Not possible to bind arbitrary amount of texture resources
19
19
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Bindless Deferred Decals
● How about rendering all decals at once?
● Problem: Too many resource bindings
○ Each decal references a potentially unique set of textures
○ Not possible to bind arbitrary amount of texture resources
● Solution(s):
○ Texture atlases or arrays
-> limited and inflexible
○ is around since 2013 [Everitt14]
-> vendor specific and what about consoles?
20
20
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Bindless Texturing
● D3D12 + Vulkan to the rescue!
○ Built-in support for bindless texturing
○ API specific descriptor arrays
○ Create a descriptor table for all textures in the game
○ Descriptors are globally available and bound to any draw/dispatch in need
21
21
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Bindless Texturing
● D3D12 + Vulkan to the rescue!
○ Built-in support for bindless texturing
○ Create an (API specific) descriptor array for all textures in the game
○ Descriptors are globally available and bound to any draw/dispatch in need
● Idea of bindless texturing is around for a while!
○ e.g. [Reed14], [Pettineo16], [Sousa16], [Drobot17]
22
22
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Bindless Texturing
D3D12 / HLSL Vulkan / GLSL
23
23
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Non-uniform resource indices
● Texture index must be uniform
○ In GCN terms: loaded into an SGPR
○ It’s not by default if fetched from a GPU buffer
○ Non-uniform indices lead to unexpected results
and graphical corruptions
● Need to explicitly make the index uniform!
24
24
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Non-uniform resource indices
● D3D12 / HLSL:
● Vulkan / GLSL:
○ Check [GpuInfo] for availability
● Alternative: use wave intrinsics
○ D3D12: Shader Model 6 wave intrinsics
○ Vulkan: ballot extensions
● Heavily driver- and vendor-dependent
○ Availability of extensions and performance
25
25
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Clustered Deferred Decals
● We already have a clustered deferred renderer for lighting
○ Similar approach to [Persson], [Sousa16], etc.
○ Cull lights, specular cubemaps, etc. into subdivided view frustum bins
○ Render everything in one go (single compute dispatch / fullscreen quad)
○ Easy to query clustered data also for forward-rendered objects
○ Already a good coverage on the topic, so we won’t go much deeper here
26
26
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Clustered Deferred Decals
● We already have a clustered deferred renderer for lighting
○ Similar approach to [Persson], [Sousa16], etc.
○ Cull lights, specular cubemaps, etc. into subdivided view frustum bins
○ Render everything in one go (single compute dispatch / fullscreen quad)
○ Easy to query clustered data also for forward-rendered objects
○ Already a good coverage on the topic, so we won’t go much deeper here
● Good fit also for decals!
27
27
Output
scene color
Fetch
G-Buffer
Compute
decals
Compute
direct
lighting
Lighting shader
Compute
indirect
specular
Compute
indirect
diffuse
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Clustered Deferred Decals
● Decal blending only in registers, no double fetching or updating of G-Buffer
● Very efficient, but be aware of register pressure / low CU occupancy
28
28
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Bindless Decals Optimization
● High-level art optimizations
○ Cull by distance with soft fade-out
○ Switch to simpler feature set over distance
29
29
Decal overlay icons for all decals
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Bindless Decals Optimization
● High-level art optimizations
○ Cull by distance with soft fade-out
○ Switch to simpler feature set over distance
30
30
Decal overlay icons for all decals surviving distance culling
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Bindless Decals Optimization
● Low-level optimizations
● Biggest bottleneck in shader: VGPRs / CU Occupation
● GCN Loop Scalarization works great with decals
○ Load decal and material data in SGPRs and loop over necessary lanes
○ Note: not necessary anymore!
● Splitting decal and material features into isolated blocks
○ Free up registers by grouping features
○ Register lifetime is not always obvious - measure and profile
○ Reorganization of large shaders with a lot of resource access is always worth a try!
31
31
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
GCN loop scalarization
● Great in-depth coverage available [Drobot17]
● Make cluster index uniform / scalar
○ Load all related data (DecalData, MaterialData, etc.) into SGPRs
○ Index is actually not uniform, but most pixel in a wave likely hit
the same index
○ Double work can happen but higher occupancy will cancel it out
○ Only doable with wave intrinsics
32
32
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Bindless Decals Limitations
● Downsides of blending decals in registers
● Decals not visible for other (deferred) renderpasses
○ normals + albedo won’t see decal modifications (e.g. SSAO, SSR, separate ambient pass)
○ Material-ID not updated (TAA Ghosting! [Xu16])
● Could render decals before lighting and update G-Buffer
○ Additional costs for e.g. copying G-Buffer Normals
33
33
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Common decal issues
34
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Common decal issues #1: Normal blending
● Linear blending is trivial and useful for e.g.
snow accumulation
○ Perfect for thick covers like layers of sand or snow
○ Tends to “flatten” normals in gradual blending:
normal directions cancel out each other
35
35
Decal with linear normal blending
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Common decal issues #1: Normal blending
● Re-orientated normal mapping [Hill12]
○ Our default mode for blending, works best for most decals
○ Decal normal will always follow surface normal
○ Fits mostly better into the scene
36
36
Decal with re-oriented normal blending
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Common decal issues #2: screenspace UV gradients
● UV- and Z-gradients cannot be derived correctly in screenspace
○ No hardware gradient data (ddx/ddy) available in shader loops
○ No mip-mapping and wrong UV-gradients around object boundaries
● Solution:
○ Sample a fixed Mip Level :-(
○ Compute gradients in shader
■ Slightly higher runtime cost
■ Need to compute 2 addition decal-space positions with 1-pixel-offset in X and Y direction
■ Be aware of decal & uv scaling!
37
37
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Common decal issues #2: screenspace UV gradients
● Computation of UV gradients in the shader
● Be aware that hardware gradients of position is not correct
38
38
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Common decal issues #3: screenspace Z gradients
● UV gradients = almost good
● But can get huge at depth discontinuities
if gradient is computed in the shader
● Two possibilities
○ Store z-gradients in G-Buffer and compute
with these
○ Or check for depth discontinuities
in shader + fix-up [Hammer18]
39
39
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Common decal issues #3: screenspace Z gradients
● Checkerboard is a prime example because of
maximum contrast
○ lower mips converge to middle gray due to downscale
● Large UV gradients will fetch a very low mip
ending up in a color discontinuity
40
40
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Common decal issues #3: screenspace Z gradients
● Find the edges causing the trouble
● Sample Lod0 if fragment is on edge
● Can be done directly in the decal fullscreen
shader based on two depth quads
41
41
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Common decal issues #3: screenspace Z gradients
● Find the edges causing the trouble
● Sample Lod0 if fragment is on edge
● Can be done directly in the decal fullscreen
shader based on two depth quads
42
42
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Common decal issues #3: screenspace Z gradients
● Color discontinuities are now gone
● Fixed edges can now suffer from Mip-Flickering
● In practice a rather minor issue
○ Barely noticeable during gameplay
○ Antialiasing - especially Temporal AA - migitates as well
43
43
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Common decal issues #4: Leaking and object separation
● Decals may leak into areas where they don’t belong
44
44
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Common decal issues #4: Leaking and object separation
● Decals may leak into areas where they don’t belong
● Solution:
○ Decals and materials both store a “DecalGroup” bitmask
○ Bitwise AND the masks and check if at least one bit matches
○ Up to artists how to assign bits (e.g. character, vegetation,
environment, transparent, etc.)
45
45
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Dirty decal tricks
4646
46
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Dirty decal tricks #1 - Smoothing Edges
● Modify decal normal to “smooth” corners and edges
● Interpolate surface normal towards (uniform) decal direction
● Simple but effective and artists love the hack
● Useful for covering uneven geometry e.g. with mud
47
47
Smoothed Edges off (smoothFactor = 0.0)
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Dirty decal tricks #1 - Smoothing Edges
● Modify decal normal to “smooth” corners and edges
● Interpolate surface normal towards (uniform) decal direction
● Simple but effective and artists love the hack
● Useful for covering uneven geometry e.g. with mud
● Geometry normal is otherwise hard to override
● Be careful, it’s a hack
48
48
Smoothed Edges on (smoothFactor = 1.0)
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Dirty decal tricks #2 - Water puddles
● Decalling shallow water puddles
○ Faking surface porosity by blending
black decal albedo (only 10-20% opacity)
○ low roughness (100%)
○ water ripple normal (100%)
● No special code path, just special
parametrization
49
49
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Dirty decal tricks #3 - Texturing the world
● Base model (no decals)
50
50
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Dirty decal tricks #3 - Texturing the world
● Base model + decal with UV-free texturing
aka Triplanar mapping
○ Sample texture(s) 3x from different directions
and blend based on decal normal
○ Triplanar contrast defines the “steepness”
of the blending according to the normal
51
51
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Dirty decal tricks #3 - Texturing the world
● Base model + decal with triplanar +
slope dependent blending
○ Generate a blend mask based on the slope of the
underlying surface and the decal direction
52
52
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Future improvements
53
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Future improvements
54
54
● Better tooling for bulk decalling
○ Brush decals with randomized parameters
We already have that for small geometry instances like plants, debris, etc.!
○ Procedural placement based on world parameters
(e.g. biomes, material types, indoor/outdoor)
○ Physically simulated placement
(e.g. rigid body / particle simulation)
● Extend system to go full bindless
○ Bindless texturing also for scene rendering
○ Prototype exists but not yet ready for production
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Thank you for listening!
@philiphammer0
phammer@deck13.com
55
Also a big thanks to the amazing DECK13 team which helped
with contributions, reviews and suggestions!
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
We’re hiring! :)
@deck13_de
https://www.deck13.com/jobs/
56
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
Q & A
57
Philip Hammer (Deck13 Interactive)
Digital Dragons 2019, Krakow
References
[Persson] “Practical Clustered Shading”, Emil Persson,
http://www.humus.name/Articles/PracticalClusteredShading.pdf
[Drobot17] “Improved Culling for Tiled and Clustered Rendering”, Michal Drobot, Siggraph 2017
http://advances.realtimerendering.com/s2017/
[Hammer18] “Dissecting the Rendering of The Surge”, Philip Hammer, Quo Vadis Berlin 2018
https://de.slideshare.net/philiphammer/dissecting-the-rendering-of-the-surge
[Xu16] "Temporal Antialiasing in Uncharted 4", Ke Xu, Siggraph 2016
http://advances.realtimerendering.com/s2016/
[Lagarde14] “Moving Frostbite to physical based rendering”, Sébastien Lagarde, Siggraph 2014
https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
[Wronski15] “Fixing screen-space deferred decals”, Bart Wronski, 2015
https://bartwronski.com/2015/03/12/fixing-screen-space-deferred-decals/
[Sawicki15] "Watch out for non-uniform resource index!", Adam Sawicki,
http://www.asawicki.info/news_1608_direct3d_12_-_watch_out_for_non-uniform_resource_index.html
[Sousa16] "The Devil is in the Details: idTech 666", Tiago Sousa, Siggraph 2016
https://de.slideshare.net/TiagoAlexSousa/siggraph2016-the-devil-is-in-the-details-idtech-666
[Pettineo16] “Bindless Texturing for Deferred Rendering and Decals”, Matt Pettineo
https://mynameismjp.wordpress.com/2016/03/25/bindless-texturing-for-deferred-rendering-and-decals/
[Reed14] “Deferred Texturing”
http://www.reedbeta.com/blog/deferred-texturing/
[LotF14] “Building your own engine, part 3 – Visual effects for the next generation”, Benjamin Glatzel, David Reinig
https://www.makinggames.biz/news/building-your-own-engine-part-3-visual-effects-for-the-next-generation,6330.html
[Hill12] “Blending in Detail”, Stephen Hill, 2012
https://blog.selfshadow.com/publications/blending-in-detail/
[Everitt14] “Approaching zero driver overhead”, Cass Everitt et. al.,, Siggraph 2014
https://de.slideshare.net/CassEveritt/approaching-zero-driver-overhead
[GpuInfo] “Vulkan Hardware Database”, Sascha Willems
https://vulkan.gpuinfo.org/listextensions.php
58
58

More Related Content

PDF
Screen Space Reflections in The Surge
PPTX
Rendering Technologies from Crysis 3 (GDC 2013)
PPTX
Physically Based and Unified Volumetric Rendering in Frostbite
PPT
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
PDF
Rendering AAA-Quality Characters of Project A1
PPT
Secrets of CryENGINE 3 Graphics Technology
PDF
Taking Killzone Shadow Fall Image Quality Into The Next Generation
PPTX
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
Screen Space Reflections in The Surge
Rendering Technologies from Crysis 3 (GDC 2013)
Physically Based and Unified Volumetric Rendering in Frostbite
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Rendering AAA-Quality Characters of Project A1
Secrets of CryENGINE 3 Graphics Technology
Taking Killzone Shadow Fall Image Quality Into The Next Generation
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...

What's hot (20)

PPT
A Bit More Deferred Cry Engine3
PPTX
Optimizing the Graphics Pipeline with Compute, GDC 2016
PDF
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
PPTX
Frostbite on Mobile
PPTX
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
PPTX
Stochastic Screen-Space Reflections
PPTX
Moving Frostbite to Physically Based Rendering
PDF
Deferred Rendering in Killzone 2
PDF
Graphics Gems from CryENGINE 3 (Siggraph 2013)
PPTX
Decima Engine: Visibility in Horizon Zero Dawn
PDF
Siggraph2016 - The Devil is in the Details: idTech 666
PPTX
Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite
PDF
Advanced Scenegraph Rendering Pipeline
PDF
Rendering Tech of Space Marine
PPTX
FrameGraph: Extensible Rendering Architecture in Frostbite
PDF
Killzone Shadow Fall Demo Postmortem
PDF
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
PPT
The Unique Lighting of Mirror's Edge
PPT
Crysis Next-Gen Effects (GDC 2008)
PPTX
The Rendering Technology of Killzone 2
A Bit More Deferred Cry Engine3
Optimizing the Graphics Pipeline with Compute, GDC 2016
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
Frostbite on Mobile
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Stochastic Screen-Space Reflections
Moving Frostbite to Physically Based Rendering
Deferred Rendering in Killzone 2
Graphics Gems from CryENGINE 3 (Siggraph 2013)
Decima Engine: Visibility in Horizon Zero Dawn
Siggraph2016 - The Devil is in the Details: idTech 666
Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite
Advanced Scenegraph Rendering Pipeline
Rendering Tech of Space Marine
FrameGraph: Extensible Rendering Architecture in Frostbite
Killzone Shadow Fall Demo Postmortem
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
The Unique Lighting of Mirror's Edge
Crysis Next-Gen Effects (GDC 2008)
The Rendering Technology of Killzone 2
Ad

Similar to Bindless Deferred Decals in The Surge 2 (20)

PPT
OpenGL for 2015
PPTX
Develop2012 deferred sanchez_stachowiak
PPTX
Sig13 ce future_gfx
PPTX
Approaching zero driver overhead
PPT
Destruction Masking in Frostbite 2 using Volume Distance Fields
PDF
Rendering basics
PDF
Deferred rendering in_leadwerks_engine[1]
PPTX
The Technology behind Shadow Warrior, ZTG 2014
PDF
Deferred rendering in Dying Light
PDF
Commandlistsiggraphasia2014 141204005310-conversion-gate02
PDF
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
PDF
Forward+ (EUROGRAPHICS 2012)
PPT
Advanced Lighting Techniques Dan Baker (Meltdown 2005)
PDF
Mobile crossplatformchallenges siggraph
PDF
Mobile crossplatformchallenges siggraph
PPT
Order Independent Transparency
PDF
OpenGL ES and Mobile GPU
PDF
Clustered defered and forward shading
PPT
CS 354 Texture Mapping
OpenGL for 2015
Develop2012 deferred sanchez_stachowiak
Sig13 ce future_gfx
Approaching zero driver overhead
Destruction Masking in Frostbite 2 using Volume Distance Fields
Rendering basics
Deferred rendering in_leadwerks_engine[1]
The Technology behind Shadow Warrior, ZTG 2014
Deferred rendering in Dying Light
Commandlistsiggraphasia2014 141204005310-conversion-gate02
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
Forward+ (EUROGRAPHICS 2012)
Advanced Lighting Techniques Dan Baker (Meltdown 2005)
Mobile crossplatformchallenges siggraph
Mobile crossplatformchallenges siggraph
Order Independent Transparency
OpenGL ES and Mobile GPU
Clustered defered and forward shading
CS 354 Texture Mapping
Ad

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Cloud computing and distributed systems.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Modernizing your data center with Dell and AMD
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Electronic commerce courselecture one. Pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
Empathic Computing: Creating Shared Understanding
NewMind AI Weekly Chronicles - August'25 Week I
Chapter 3 Spatial Domain Image Processing.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Cloud computing and distributed systems.
20250228 LYD VKU AI Blended-Learning.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
The AUB Centre for AI in Media Proposal.docx
Building Integrated photovoltaic BIPV_UPV.pdf
Modernizing your data center with Dell and AMD
Dropbox Q2 2025 Financial Results & Investor Presentation
The Rise and Fall of 3GPP – Time for a Sabbatical?
Spectral efficient network and resource selection model in 5G networks
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Electronic commerce courselecture one. Pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Review of recent advances in non-invasive hemoglobin estimation

Bindless Deferred Decals in The Surge 2

  • 1. Bindless Deferred Decals in Philip Hammer (DECK13 Interactive GmbH) Digital Dragons 2019, Krakow
  • 2. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow This talk is .. ● .. about ○ our own implementation of bindless deferred decals in D3D12 and Vulkan ○ overcoming problems of past approaches ○ practical bread & butter techniques ○ how to efficiently render many decals on the GPU ○ tackling common issues and glitches ● .. but unfortunately not ○ super-fancy new research ○ a comprehensive view on our new renderer ● .. and has ○ probably more too much source code 2 2
  • 3. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Introduction ● Brief overview of the latest iteration of our inhouse FLEDGE engine ● 4th generation: re-designed renderer module from ground up: ○ Vulkan + D3D12 support only ○ Dropped legacy code (D3D11) ○ No more OOP code - all in for DOD / SoA ○ New possibilities for high-level renderer design (e.g. bindless texturing) ● Improved some existing features e.g. ○ Clustered Deferred + Clustered Forward Rendering ○ Physical-based Rendering ● Some fancy new rendering features, e.g. ○ Unified Volumetric Lighting, Irradiance Probe Grid, Simulated interactive grass, Temporal Antialiasing, etc. ○ Unfortunately not part of this talk :-) 3 3
  • 8. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Motivation ● Decals = one key benefit of deferred rendering ● Used in environment art + VFX ○ Static decals to detail the world ○ Dynamic decals spawned by the effect system ○ Gameplay-driven decals like footsteps ● High demands on decal count, usability and performance 8 8
  • 9. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Decal usage & examples 99 9
  • 10. Decal usage & examples 10
  • 11. Decal usage & examples 11
  • 12. Decal usage & examples 12
  • 13. Decal usage & examples 13
  • 14. Decal usage & examples 14
  • 15. Decal usage & examples 15
  • 16. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Rasterization-based deferred decals ● Had deferred decals for quite a while [LotF14] ○ Be aware of decal count, overdraw, etc. ○ Limitations led to sparse usage ● “Classic” deferred decal rendering ○ analogous to deferred light volume rendering ● Improved that a lot over the years, but basic principle stayed the same 16 16
  • 17. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Rasterization-based deferred decals ● Advantages ○ Easy to implement and possible with most (even older) graphics APIs ○ Near pixel-perfect culling and shader segmentation ● Disadvantages ○ CPU-Performance ■ one drawcall per decal ■ Lots of state setup per decal ○ GPU-Performance ■ Double work: fetching gbuffers, rasterizing fragments, etc. ■ Need to update the G-Buffer as intermediate blend buffer 17 17 Transformed box geometry rasterizing a decal
  • 18. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Bindless Deferred Decals ● How about rendering all decals at once? 18 18
  • 19. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Bindless Deferred Decals ● How about rendering all decals at once? ● Problem: Too many resource bindings ○ Each decal references a potentially unique set of textures ○ Not possible to bind arbitrary amount of texture resources 19 19
  • 20. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Bindless Deferred Decals ● How about rendering all decals at once? ● Problem: Too many resource bindings ○ Each decal references a potentially unique set of textures ○ Not possible to bind arbitrary amount of texture resources ● Solution(s): ○ Texture atlases or arrays -> limited and inflexible ○ is around since 2013 [Everitt14] -> vendor specific and what about consoles? 20 20
  • 21. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Bindless Texturing ● D3D12 + Vulkan to the rescue! ○ Built-in support for bindless texturing ○ API specific descriptor arrays ○ Create a descriptor table for all textures in the game ○ Descriptors are globally available and bound to any draw/dispatch in need 21 21
  • 22. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Bindless Texturing ● D3D12 + Vulkan to the rescue! ○ Built-in support for bindless texturing ○ Create an (API specific) descriptor array for all textures in the game ○ Descriptors are globally available and bound to any draw/dispatch in need ● Idea of bindless texturing is around for a while! ○ e.g. [Reed14], [Pettineo16], [Sousa16], [Drobot17] 22 22
  • 23. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Bindless Texturing D3D12 / HLSL Vulkan / GLSL 23 23
  • 24. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Non-uniform resource indices ● Texture index must be uniform ○ In GCN terms: loaded into an SGPR ○ It’s not by default if fetched from a GPU buffer ○ Non-uniform indices lead to unexpected results and graphical corruptions ● Need to explicitly make the index uniform! 24 24
  • 25. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Non-uniform resource indices ● D3D12 / HLSL: ● Vulkan / GLSL: ○ Check [GpuInfo] for availability ● Alternative: use wave intrinsics ○ D3D12: Shader Model 6 wave intrinsics ○ Vulkan: ballot extensions ● Heavily driver- and vendor-dependent ○ Availability of extensions and performance 25 25
  • 26. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Clustered Deferred Decals ● We already have a clustered deferred renderer for lighting ○ Similar approach to [Persson], [Sousa16], etc. ○ Cull lights, specular cubemaps, etc. into subdivided view frustum bins ○ Render everything in one go (single compute dispatch / fullscreen quad) ○ Easy to query clustered data also for forward-rendered objects ○ Already a good coverage on the topic, so we won’t go much deeper here 26 26
  • 27. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Clustered Deferred Decals ● We already have a clustered deferred renderer for lighting ○ Similar approach to [Persson], [Sousa16], etc. ○ Cull lights, specular cubemaps, etc. into subdivided view frustum bins ○ Render everything in one go (single compute dispatch / fullscreen quad) ○ Easy to query clustered data also for forward-rendered objects ○ Already a good coverage on the topic, so we won’t go much deeper here ● Good fit also for decals! 27 27 Output scene color Fetch G-Buffer Compute decals Compute direct lighting Lighting shader Compute indirect specular Compute indirect diffuse
  • 28. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Clustered Deferred Decals ● Decal blending only in registers, no double fetching or updating of G-Buffer ● Very efficient, but be aware of register pressure / low CU occupancy 28 28
  • 29. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Bindless Decals Optimization ● High-level art optimizations ○ Cull by distance with soft fade-out ○ Switch to simpler feature set over distance 29 29 Decal overlay icons for all decals
  • 30. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Bindless Decals Optimization ● High-level art optimizations ○ Cull by distance with soft fade-out ○ Switch to simpler feature set over distance 30 30 Decal overlay icons for all decals surviving distance culling
  • 31. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Bindless Decals Optimization ● Low-level optimizations ● Biggest bottleneck in shader: VGPRs / CU Occupation ● GCN Loop Scalarization works great with decals ○ Load decal and material data in SGPRs and loop over necessary lanes ○ Note: not necessary anymore! ● Splitting decal and material features into isolated blocks ○ Free up registers by grouping features ○ Register lifetime is not always obvious - measure and profile ○ Reorganization of large shaders with a lot of resource access is always worth a try! 31 31
  • 32. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow GCN loop scalarization ● Great in-depth coverage available [Drobot17] ● Make cluster index uniform / scalar ○ Load all related data (DecalData, MaterialData, etc.) into SGPRs ○ Index is actually not uniform, but most pixel in a wave likely hit the same index ○ Double work can happen but higher occupancy will cancel it out ○ Only doable with wave intrinsics 32 32
  • 33. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Bindless Decals Limitations ● Downsides of blending decals in registers ● Decals not visible for other (deferred) renderpasses ○ normals + albedo won’t see decal modifications (e.g. SSAO, SSR, separate ambient pass) ○ Material-ID not updated (TAA Ghosting! [Xu16]) ● Could render decals before lighting and update G-Buffer ○ Additional costs for e.g. copying G-Buffer Normals 33 33
  • 34. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Common decal issues 34
  • 35. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Common decal issues #1: Normal blending ● Linear blending is trivial and useful for e.g. snow accumulation ○ Perfect for thick covers like layers of sand or snow ○ Tends to “flatten” normals in gradual blending: normal directions cancel out each other 35 35 Decal with linear normal blending
  • 36. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Common decal issues #1: Normal blending ● Re-orientated normal mapping [Hill12] ○ Our default mode for blending, works best for most decals ○ Decal normal will always follow surface normal ○ Fits mostly better into the scene 36 36 Decal with re-oriented normal blending
  • 37. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Common decal issues #2: screenspace UV gradients ● UV- and Z-gradients cannot be derived correctly in screenspace ○ No hardware gradient data (ddx/ddy) available in shader loops ○ No mip-mapping and wrong UV-gradients around object boundaries ● Solution: ○ Sample a fixed Mip Level :-( ○ Compute gradients in shader ■ Slightly higher runtime cost ■ Need to compute 2 addition decal-space positions with 1-pixel-offset in X and Y direction ■ Be aware of decal & uv scaling! 37 37
  • 38. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Common decal issues #2: screenspace UV gradients ● Computation of UV gradients in the shader ● Be aware that hardware gradients of position is not correct 38 38
  • 39. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Common decal issues #3: screenspace Z gradients ● UV gradients = almost good ● But can get huge at depth discontinuities if gradient is computed in the shader ● Two possibilities ○ Store z-gradients in G-Buffer and compute with these ○ Or check for depth discontinuities in shader + fix-up [Hammer18] 39 39
  • 40. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Common decal issues #3: screenspace Z gradients ● Checkerboard is a prime example because of maximum contrast ○ lower mips converge to middle gray due to downscale ● Large UV gradients will fetch a very low mip ending up in a color discontinuity 40 40
  • 41. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Common decal issues #3: screenspace Z gradients ● Find the edges causing the trouble ● Sample Lod0 if fragment is on edge ● Can be done directly in the decal fullscreen shader based on two depth quads 41 41
  • 42. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Common decal issues #3: screenspace Z gradients ● Find the edges causing the trouble ● Sample Lod0 if fragment is on edge ● Can be done directly in the decal fullscreen shader based on two depth quads 42 42
  • 43. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Common decal issues #3: screenspace Z gradients ● Color discontinuities are now gone ● Fixed edges can now suffer from Mip-Flickering ● In practice a rather minor issue ○ Barely noticeable during gameplay ○ Antialiasing - especially Temporal AA - migitates as well 43 43
  • 44. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Common decal issues #4: Leaking and object separation ● Decals may leak into areas where they don’t belong 44 44
  • 45. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Common decal issues #4: Leaking and object separation ● Decals may leak into areas where they don’t belong ● Solution: ○ Decals and materials both store a “DecalGroup” bitmask ○ Bitwise AND the masks and check if at least one bit matches ○ Up to artists how to assign bits (e.g. character, vegetation, environment, transparent, etc.) 45 45
  • 46. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Dirty decal tricks 4646 46
  • 47. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Dirty decal tricks #1 - Smoothing Edges ● Modify decal normal to “smooth” corners and edges ● Interpolate surface normal towards (uniform) decal direction ● Simple but effective and artists love the hack ● Useful for covering uneven geometry e.g. with mud 47 47 Smoothed Edges off (smoothFactor = 0.0)
  • 48. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Dirty decal tricks #1 - Smoothing Edges ● Modify decal normal to “smooth” corners and edges ● Interpolate surface normal towards (uniform) decal direction ● Simple but effective and artists love the hack ● Useful for covering uneven geometry e.g. with mud ● Geometry normal is otherwise hard to override ● Be careful, it’s a hack 48 48 Smoothed Edges on (smoothFactor = 1.0)
  • 49. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Dirty decal tricks #2 - Water puddles ● Decalling shallow water puddles ○ Faking surface porosity by blending black decal albedo (only 10-20% opacity) ○ low roughness (100%) ○ water ripple normal (100%) ● No special code path, just special parametrization 49 49
  • 50. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Dirty decal tricks #3 - Texturing the world ● Base model (no decals) 50 50
  • 51. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Dirty decal tricks #3 - Texturing the world ● Base model + decal with UV-free texturing aka Triplanar mapping ○ Sample texture(s) 3x from different directions and blend based on decal normal ○ Triplanar contrast defines the “steepness” of the blending according to the normal 51 51
  • 52. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Dirty decal tricks #3 - Texturing the world ● Base model + decal with triplanar + slope dependent blending ○ Generate a blend mask based on the slope of the underlying surface and the decal direction 52 52
  • 53. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Future improvements 53
  • 54. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Future improvements 54 54 ● Better tooling for bulk decalling ○ Brush decals with randomized parameters We already have that for small geometry instances like plants, debris, etc.! ○ Procedural placement based on world parameters (e.g. biomes, material types, indoor/outdoor) ○ Physically simulated placement (e.g. rigid body / particle simulation) ● Extend system to go full bindless ○ Bindless texturing also for scene rendering ○ Prototype exists but not yet ready for production
  • 55. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Thank you for listening! @philiphammer0 phammer@deck13.com 55 Also a big thanks to the amazing DECK13 team which helped with contributions, reviews and suggestions!
  • 56. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow We’re hiring! :) @deck13_de https://www.deck13.com/jobs/ 56
  • 57. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow Q & A 57
  • 58. Philip Hammer (Deck13 Interactive) Digital Dragons 2019, Krakow References [Persson] “Practical Clustered Shading”, Emil Persson, http://www.humus.name/Articles/PracticalClusteredShading.pdf [Drobot17] “Improved Culling for Tiled and Clustered Rendering”, Michal Drobot, Siggraph 2017 http://advances.realtimerendering.com/s2017/ [Hammer18] “Dissecting the Rendering of The Surge”, Philip Hammer, Quo Vadis Berlin 2018 https://de.slideshare.net/philiphammer/dissecting-the-rendering-of-the-surge [Xu16] "Temporal Antialiasing in Uncharted 4", Ke Xu, Siggraph 2016 http://advances.realtimerendering.com/s2016/ [Lagarde14] “Moving Frostbite to physical based rendering”, Sébastien Lagarde, Siggraph 2014 https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf [Wronski15] “Fixing screen-space deferred decals”, Bart Wronski, 2015 https://bartwronski.com/2015/03/12/fixing-screen-space-deferred-decals/ [Sawicki15] "Watch out for non-uniform resource index!", Adam Sawicki, http://www.asawicki.info/news_1608_direct3d_12_-_watch_out_for_non-uniform_resource_index.html [Sousa16] "The Devil is in the Details: idTech 666", Tiago Sousa, Siggraph 2016 https://de.slideshare.net/TiagoAlexSousa/siggraph2016-the-devil-is-in-the-details-idtech-666 [Pettineo16] “Bindless Texturing for Deferred Rendering and Decals”, Matt Pettineo https://mynameismjp.wordpress.com/2016/03/25/bindless-texturing-for-deferred-rendering-and-decals/ [Reed14] “Deferred Texturing” http://www.reedbeta.com/blog/deferred-texturing/ [LotF14] “Building your own engine, part 3 – Visual effects for the next generation”, Benjamin Glatzel, David Reinig https://www.makinggames.biz/news/building-your-own-engine-part-3-visual-effects-for-the-next-generation,6330.html [Hill12] “Blending in Detail”, Stephen Hill, 2012 https://blog.selfshadow.com/publications/blending-in-detail/ [Everitt14] “Approaching zero driver overhead”, Cass Everitt et. al.,, Siggraph 2014 https://de.slideshare.net/CassEveritt/approaching-zero-driver-overhead [GpuInfo] “Vulkan Hardware Database”, Sascha Willems https://vulkan.gpuinfo.org/listextensions.php 58 58