Upload
tiago-sousa
View
474
Download
2
Embed Size (px)
Citation preview
THE DEVIL IS IN THE DETAILS
Initial Requirements
Anatomy of a Frame
Frame Cost
Data Structure for Lighting & Shading
Preparing Clustered Structure
𝑍𝑆𝑙𝑖𝑐𝑒 = 𝑁𝑒𝑎𝑟𝑧 × ( 𝐹𝑎𝑟𝑧
𝑁𝑒𝑎𝑟𝑧)
𝑠𝑙𝑖𝑐𝑒
𝑛𝑢𝑚 𝑠𝑙𝑖𝑐𝑒𝑠
Preparing Clustered Structure
//Pseudo-code - 1 job per depth slice ( if any item )
for ( y = MinY; y < MaxY; ++y ) {
for ( x = MinX; x < MaxX; ++x ) {
intersects = N planes vs cell AABB
if ( intersects ) {
Register item
}
}
}
Preparing Clustered Structure
Preparing Clustered Structure
Preparing Clustered Structure
Detailing the World
Detailing the World
Detailing the World
𝑒0 𝑒1
const float4 albedo = tex2Dgrad( decalsAtlas, uv.xy * scaleBias.xy + scaleBias.zw, uvDDX, uvDDY );
𝑒
𝑒 𝑒𝑒0𝑥
𝑒1𝑥 2𝑥 𝑥
𝑒0𝑦𝑒1𝑦 2𝑦 𝑦
𝑒0𝑧𝑒1𝑧 2𝑧 𝑧
0 0 0 1
0.5
𝑠𝑖𝑧𝑒𝑋0 0 0.5
00.5
𝑠𝑖𝑧𝑒𝑌0 0.5
0 00.5
𝑠𝑖𝑧𝑒𝑍0.5
0 0 0 1
∙
Detailing the World
Detailing the World
Detailing the World
Detailing the World
Detailing the World
Detailing the World
Detailing the World
Lighting
Lighting
//Pseudocode
ComputeLighting( inputs, outputs ) {
Read & Pack base textures
for each decal in cell {
early out fragment check
Read textures
Blend results
}
for each light in cell {
early out fragment check
Compute BRDF / Apply Shadows
Accumulate lighting
}
}
Lighting
Lighting
Lighting
Lighting
Transparents
Particle Lighting
Decoupled Particle Lighting
Decoupled Particle Lighting
//Pseudocode – Particle shading becomes something like this
Particles( inputs, outputs ) {
…
const float3 lighting = tex2D( particleAtlas, inputs.texcoord );
result = lighting * inputs.albedo;
…
}
Decoupled Particle Lighting
Particle Light Atlas
Decoupled Particle Lighting
Post-Process
Optimizing Data Fetching ( GCN )
Clustered Lighting Access Patterns
Clustered Lighting Access Patterns
Clustered Lighting Access Patterns
Clustered Lighting Access Patterns
Analyzing the Data
Leveraging Access Patterns
Thread X A B D
Thread Y B C E
Thread Z A C D E
Scalar A B C D E
Special Paths
Dynamic Resolution Scaling
Async Post Processing
GCN Wave Limits Tuning
GCN Register Usage
What’s next ?
Special Thanks
We are Hiring !
Thank you
References
Bonus Slides
Lighting
Deferred Passes