SlideShare a Scribd company logo
1 of 78
Download to read offline
Volumetric Lighting for Many Lights
in Lords of the Fallen
Benjamin Glatzel

Engine/Graphics Programmer

Deck13 Interactive GmbH
Who are we?
• One of Germany’s leading game studios
• Currently working on “Lords of the Fallen” in
cooperation with CI Games
• We’re using our own proprietary multi-platform
technology called “Fledge”
• We’ve shipped numerous titles primarily on PC but also
on Xbox 360, iOS and PS3 (maybe you know Jack
Keane, Ankh, Venetica, Blood Knights or Tiger and
Chicken)
Lords of the Fallen
• Lords of the Fallen is a challenging Action-RPG for PC,
Xbox One and PlayStation 4
• Will be released fall 2014
• For an in-depth view into the rendering guts of Fledge,
visit Philips talk tomorrow
Who am I?
• Engine/Graphics Programmer since 2 years
• Mainly responsible for the GNM/PS4 version of
“Fledge”
• Apart from that I'm behind everything related to
physics, our software rasterisation based culling
system, our IK system, …
Introduction
Light Scattering
Lightwaves
Participating media
Motivation
Motivation
• Simple light shafts as a screen space post-processing
effect [1] sure are shiny, but…
Light shafts as a post-processing effect
Light shafts as a post-processing effect
Motivation
• Billboards can be neat, but…
“Billboard volumetrics”
“Billboard volumetrics”
Motivation
• We wanted something more dynamic and flexible that
could be tightly integrated into our lighting system
• It should work with a lot of small to medium sized light
sources
• Our artists tend to place a whole lot of lights
• Thus a negligible performance penalty on all
supported platforms was critical
State of the Art
Deep Down
Killzone 4
Crysis 3
State of the Art
• Many recent implementations seem to be based on the
work of Toth et. al. [2]:
• Ray marching in light view space while evaluating the
shadow map
• Often combined with a special sampling approach to
reduce the workload per fragment
• Many other approaches/optimisations popped up
over the recent years: Epipolar sampling [3],
sampling planes shaded in light space [4], …
Our Approach
Our Approach
• Loosely based on “Real-time Volumetric Lighting in
Participating Media” (Toth et. al. [2])
• Straightforward ray marching
• Usage of “Interleaved Sampling” to reduce the overall
sample count needed per fragment
• Utilises low-resolution rendering to reduce the
fragment workload even further
Our Approach
• Works with multiple lights and light types
• Custom bilateral blurring and depth-aware up-
sampling to work around the obvious artefacts
• Various tweaks and optimisations per light type
• Completely implemented using good old pixel and
vertex shaders - no compute
Basic Algorithm
Radiative Transport Equation [2]
~x(s) = ~x0 + ~!s
L(~x(s), ~!)
⌧
a
P(~!0
, ~!)
Ray equation, where ω is the direction of the ray
Change of radiance along the ray
Probability of collision
Scattering probability after collision
Phase function
dL(~x(s), ~!)
ds
= ⌧L(~x(s), ~!) + ⌧a
Z
⌦0
L(~x(s), ~!)P(~!0
, ~!)d!0
L(~x(s), ~!) = e ⌧s
L(~x0, ~!) +
Z s
0
Li(~x(l), ~!)e ⌧(s l)
dl
L(~x(s), ~!) ⇡ L(~x0, ~!)e ⌧s
+
NX
n=0
Li(~x(ln), ~!)e ⌧(s ln)
l
Ignore multiple scattering
Li(~x, ~!) = ⌧a
4⇡d2
v(~x)e ⌧d
P(~!l, ~!) In-scattering term
s Total ray marching distance
d Distance to the light source
l Traveled distance on the ray
l Step size
v(~x) Visibility function
Source power of the light
Direction from the
ray position to
the light source
~!l
Basic Algorithm
• Let’s start with a simple
fullscreen pass for a
directional light
• Start the ray marching on the
position of the current
fragment in light space
• Evaluate and accumulate the
in-scattering term for each of
the n samples and march in
equidistant steps towards the
position of the viewer
#define NUM_SAMPLES 128!
#define NUM_SAMPLES_RCP 0.0078125!
!
FRAGMENT_OUT ps_main(VERTEX_OUTPUT f_in)!
{!
// Fallback if we can't find a tighter limit!
float raymarchDistanceLimit = 999999.0 ;!
!
[...]!
!
// Reduce noisyness by truncating the starting position!
float raymarchDistance = trunc ( clamp ( length ( cameraPositionLightVS . xyz - positionLightVS . xyz ) , !
0.0, raymarchDistanceLimit ) ) ;!
!
// Calculate the size of each step!
float stepSize = raymarchDistance * NUM_SAMPLES_RCP ;!
float3 rayPositionLightVS = positionLightVS . xyz ;!
!
// The total light contribution accumulated along the ray!
float3 VLI = 0.0 ;!
!
// ... start the actual ray marching!
[loop] for ( float l = raymarchDistance; l > stepSize ; l -= stepSize ) !
{!
executeRaymarching(...) ;!
}!
!
f_out . color . rgb = light_color_diffuse . rgb * VLI ;!
return f_out ;!
}
#define TAU 0.0001!
#define PHI 10000000.0!
!
#define PI_RCP 0.31830988618379067153776752674503!
!
void executeRaymarching(...)!
{!
rayPositionLightVS . xyz += stepSize * invViewDirLightVS . xyz ;!
!
[...]!
!
// Fetch whether the current position on the ray is visible form the light's perspective - or not!
float3 shadowTerm = getShadowTerm ( shadowMapSampler, shadowMapSamplerState, rayPositionLightSS . xyz ) . xxx ;!
!
// Distance to the current position on the ray in light view-space!
float d = length ( rayPositionLightVS . xyz ) ; ;!
float dRcp = rcp ( d ) ;!
!
// Calculate the final light contribution for the sample on the ray...!
float3 intens = TAU * ( shadowTerm * (phi * 0.25 * PI_RCP) * dRcp * dRcp ) * exp( -d * TAU ) * exp ( -l * TAU ) *
stepSize ;!
!
// ... and add it to the total contribution of the ray!
VLI += intens ;!
}
From One to Many
From One to Many
• Render the back faces of the
light volume for each
volumetric light (depth test/
write disabled)
• Start the ray marching on the
fragment of the light geometry
instead of the scene geometry
• If the light volume intersects
the scene geometry, the
starting position gets clamped
to the closest fragment
position relatively to the
viewer
From One to Many
• Calculate the in-scattering term as depicted before
• In addition to that evaluate the attenuation function for each
given light type and “modulate” it with the in-scattering
term
• March the ray in light view and in world space in parallel -
less costly than transforming between spaces for each step
• Accumulate the volumetric lighting contribution for each
visible light to an accumulation buffer using additive
blending
From One to Many
• Constrain the taken samples to the area inside the
light volume to increase the precision
• For box and point lights we simply clamp the total ray
marching distance to the attenuation ranges of the
lights
• In the case of spotlights we actually calculate the
intersection points between the current ray and the
light volume and calculate the range in-between
Much slow
Wow
So sample
How to Make it Fast
How to Make it Fast
• Everything I told you so far needs far too many
samples to achieve visually pleasing results
• 128+ samples per fragment for each light rendered to a
full resolution target does not sound like the ideal
solution
How to Make it Fast
• We ended up rendering all volumetrics to a half or
quarter resolution target
• We use an additional depth aware up-sampling pass
to hide this fact - often referred to as ”Nearest Depth
Up-Sampling“ [5]
Without depth-aware up-sampling
With depth-aware up-sampling
How to Make it Fast
• Only using half-resolution rendering will not suffice to
make it fast enough for multiple light sources on the
screen
• We can “abuse” the fact that the in-scattered light
value at a given fragment position is either equal or at
least close to one or more of the surrounding values
How to Make it Fast
• We spread the evaluation of
the in-scattering term from a
single pixel to multiple pixels
• We ended up using 8x8 pixel
tiles, where each pixel of a
tile evaluates 16 samples
• This makes a total of 8x8x16
= 1024 potential samples
• Each pixel of one tile
evaluates a different region of
the ray
vs.
How to Make it Fast
• Assign an unique index i ∊ [0..64) to each pixel of the tile
- the indices repeat for each tile
• Reduce the total ray marching distance by one step
• Offset the ray marching starting position for each pixel of
the tile according to i
•
• Randomising the indices trades the obvious repetitive
sampling pattern for some less noticeable noise
ray = i
stepSize
64
#define INTERLEAVED_GRID_SIZE 8!
#define INTERLEAVED_GRID_SIZE_SQR 64!
#define INTERLEAVED_GRID_SIZE_SQR_RCP 0.015625!
!
[...]!
!
// Calculate the offsets on the ray according to the interleaved sampling pattern!
float2 interleavedPos = fmod ( f_in . position . xy, INTERLEAVED_GRID_SIZE ) ; !
!
#if defined (USE_RANDOM_RAY_SAMPLES)!
float index = ( interleavedPos . y * INTERLEAVED_GRID_SIZE + interleavedPos . x ) ;!
// light_volumetric_random_ray_samples contains the values 0..63 in a randomized order!
// The indices are packed to float4s => { (0,1,2,3), (4,5,6,7), ... }!
float rayStartOffset = light_volumetric_random_ray_samples [ index * 0.25 ] [ fmod ( index, 4.0 ) ] * ( stepSize *
INTERLEAVED_GRID_SIZE_SQR_RCP ) ;!
#else!
float rayStartOffset = ( interleavedPos . y * INTERLEAVED_GRID_SIZE + interleavedPos . x ) * ( stepSize *
INTERLEAVED_GRID_SIZE_SQR_RCP ) ;!
#endif // USE_RANDOM_RAY_SAMPLES!
!
float3 rayPositionLightVS = rayStartOffset * invViewDirLightVS . xyz + positionLightVS . xyz ;!
!
[...]
Accumulation buffer before the gather pass
How to Make it Fast
• To achieve the final results we use an additional blur
pass before the up-sampling pass
• We use a simple bilateral blur filter to avoid bleeding
over the edges of any geometry inside or behind the
volumetrics
Accumulation buffer after the gather pass
Non-bilateral blur
Bilateral blur
Non-bilateral blur
Bilateral blur
Render light geometry
for each volumetric and
execute ray marching
R11G11B10
1/2 Resolution
Apply horizontal and
vertical bilateral
Gaussian Blur
Accumulation Pass
Gather Pass
Apply depth-aware up-
sampling
Upscale Pass
Composite Pass
Add final up-scaled
buffer to the scene
R11G11B10
Native Resolution
Final Scene
Extending the System
2D projector texture (gobo/cookie)
3D noise texture
IES profilesTop down perspective
Isostropic scattering
Anisotropic scattering
(Henyey-Greenstein phase function)
p(⇥) =
1 g2
(1 + g2 + 2g cos ⇥)1.5
Anisotropic scattering
(Schlick phase function)
p(⇥) =
1 k2
(1 + k cos ⇥)2
k ⇡ 1.55g 0.55g3
Without temporal re-projection
With temporal re-projection
Performance
Pass PC (GTX 700 Series GPU) PS4/GNM
Accumulation* 0.362 ms 0.161 ms
Gather 0.223 ms 0.375 ms
Upscale 0.127 ms 0.321 ms
= 0.712 ms = 0.857 ms
*measured using a half resolution render target
Results
No volumetrics
Volumetrics active
No volumetrics
Volumetrics active
“Faked” multiple scattering
Thanks for listening! :)
Questions?
Contact
• Benjamin Glatzel <bglatzel@deck13.com>
• @begla
• http://www.deck13.com
References
• [1] Volumetric Light Scattering as a Post-Process - http://
http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
• [2] Real-time Volumetric Lighting in Participating Media - http://
sirkan.iit.bme.hu/~szirmay/lightshaft.pdf
• [3] Epipolar Sampling for Shadows and Crepuscular Rays in Participating
Media with Single Scattering - http://www.sfb716.uni-stuttgart.de/uploads/
tx_vispublications/espmss10.pdf
• [4] Light Shafts - Rendering Shadows in Participating Media - http://
developer.amd.com/wordpress/media/2012/10/Mitchell_LightShafts.pdf
• [5] Fast Rendering of Opacity Mapped Particles using DirectX 11 Tessellation
and Mixed Resolutions - https://developer.nvidia.com/sites/default/files/akamai/
gamedev/files/sdk/11/OpacityMappingSDKWhitePaper.pdf
Bonus Slides
½-Resolution accumulation buffer
¼-Resolution accumulation buffer
static const float gauss_filter_weights[] = {!
0.14446445, 0.13543542, 0.11153505, 0.08055309, 0.05087564, 0.02798160, 0.01332457, 0.00545096!
} ;!
!
#define NUM_SAMPLES_HALF 7!
#define BLUR_DEPTH_FALLOFF 1000.0!
!
float4 gatherGauss ( in float2 blurDirection , in float2 uv )!
{!
[...]!
!
[unroll]!
for ( REAL r = -NUM_SAMPLES_HALF; r <= NUM_SAMPLES_HALF; ++r )!
{!
uvOffset = r * blurDirection * rendertarget_size . zw ;!
kernelSample = SAMPLE ( inputSampler, uv + uvOffset ) . rgba ;!
kernelDepth = getLinearDepth ( depthSampler, depthSamplerState, uv + uvOffset ) ;!
!
// Simple depth-aware filtering!
depthDiff = abs ( kernelDepth - centerDepth ) ;!
r2 = BLUR_DEPTH_FALLOFF * depthDiff ;!
g = exp ( -r2*r2 ) ;!
weight = g * gauss_filter_weights [ abs ( r ) ] ;!
!
accumResult += weight * kernelSample . rgb ;! !
accumWeights += weight ;!
}!
!
return float4 ( accumResult . rgb / accumWeights , 1.0 ) ;!
}!
!
float4 ps_gather_horz ( VERTEX_OUTPUT f_in ) : SV_Target!
{!
return gatherGauss ( float2 ( 1.0, 0.0 ), f_in . uv0 ) ;!
}!
!
[...]
float4 ps_upsample ( VERTEX_OUTPUT f_in ) : SV_Target!
{!
[...]!
!
// Better choose something relative to the far clip distance here!
const float upsampleDepthThreshold = 0.0001 ;!
!
float minDepthDiff = 1.0 ;!
uint nearestDepthIndex = 0 ;!
!
float currentDepthDiff = abs ( sampleDownsampledDepth[0] - fullResDepth ) ;!
bool rejectSample = currentDepthDiff < upsampleDepthThreshold ;!
!
[branch]!
if ( currentDepthDiff < minDepthDiff )!
{!
minDepthDiff = currentDepthDiff ;!
nearestDepthIndex = 0 ;!
}!
!
currentDepthDiff = abs ( sampleDownsampledDepth[1] - fullResDepth ) ;!
rejectSample = rejectSample && currentDepthDiff < upsampleDepthThreshold ; !
!
[branch]!
if ( currentDepthDiff < minDepthDiff )!
{!
minDepthDiff = currentDepthDiff ;!
nearestDepthIndex = 1 ;!
}!
!
// Repeat this for the remaining 2 samples!
[...]!
!
// Avoid blocky artefacts using edge detection!
if (rejectSample)!
return float4 ( SAMPLE ( inputSampler, f_in . uv0 ) . rgb, 1.0 ) ;!
!
return float4 ( sampleR[nearestDepthIndex], sampleG[nearestDepthIndex], sampleB[nearestDepthIndex], 1.0 ) ;!
}

More Related Content

What's hot

Rendering Tech of Space Marine
Rendering Tech of Space MarineRendering Tech of Space Marine
Rendering Tech of Space MarinePope Kim
 
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time RaytracingSIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time RaytracingElectronic Arts / DICE
 
Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3stevemcauley
 
The Rendering Technology of Killzone 2
The Rendering Technology of Killzone 2The Rendering Technology of Killzone 2
The Rendering Technology of Killzone 2Guerrilla
 
A Bizarre Way to do Real-Time Lighting
A Bizarre Way to do Real-Time LightingA Bizarre Way to do Real-Time Lighting
A Bizarre Way to do Real-Time LightingSteven Tovey
 
Lighting of Killzone: Shadow Fall
Lighting of Killzone: Shadow FallLighting of Killzone: Shadow Fall
Lighting of Killzone: Shadow FallGuerrilla
 
Decima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero DawnDecima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero DawnGuerrilla
 
Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)Tiago Sousa
 
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...Codemotion
 
A Bit More Deferred Cry Engine3
A Bit More Deferred   Cry Engine3A Bit More Deferred   Cry Engine3
A Bit More Deferred Cry Engine3guest11b095
 
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr LightingHable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lightingozlael ozlael
 
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)포프 김
 
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14AMD Developer Central
 
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3Electronic Arts / DICE
 
Taking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next GenerationTaking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next GenerationGuerrilla
 
Triangle Visibility buffer
Triangle Visibility bufferTriangle Visibility buffer
Triangle Visibility bufferWolfgang Engel
 
Advancements in-tiled-rendering
Advancements in-tiled-renderingAdvancements in-tiled-rendering
Advancements in-tiled-renderingmistercteam
 
Progressive Lightmapper: An Introduction to Lightmapping in Unity
Progressive Lightmapper: An Introduction to Lightmapping in UnityProgressive Lightmapper: An Introduction to Lightmapping in Unity
Progressive Lightmapper: An Introduction to Lightmapping in UnityUnity Technologies
 
DD18 - SEED - Raytracing in Hybrid Real-Time Rendering
DD18 - SEED - Raytracing in Hybrid Real-Time RenderingDD18 - SEED - Raytracing in Hybrid Real-Time Rendering
DD18 - SEED - Raytracing in Hybrid Real-Time RenderingElectronic Arts / DICE
 

What's hot (20)

Frostbite on Mobile
Frostbite on MobileFrostbite on Mobile
Frostbite on Mobile
 
Rendering Tech of Space Marine
Rendering Tech of Space MarineRendering Tech of Space Marine
Rendering Tech of Space Marine
 
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time RaytracingSIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
SIGGRAPH 2018 - Full Rays Ahead! From Raster to Real-Time Raytracing
 
Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3
 
The Rendering Technology of Killzone 2
The Rendering Technology of Killzone 2The Rendering Technology of Killzone 2
The Rendering Technology of Killzone 2
 
A Bizarre Way to do Real-Time Lighting
A Bizarre Way to do Real-Time LightingA Bizarre Way to do Real-Time Lighting
A Bizarre Way to do Real-Time Lighting
 
Lighting of Killzone: Shadow Fall
Lighting of Killzone: Shadow FallLighting of Killzone: Shadow Fall
Lighting of Killzone: Shadow Fall
 
Decima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero DawnDecima Engine: Visibility in Horizon Zero Dawn
Decima Engine: Visibility in Horizon Zero Dawn
 
Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)
 
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
 
A Bit More Deferred Cry Engine3
A Bit More Deferred   Cry Engine3A Bit More Deferred   Cry Engine3
A Bit More Deferred Cry Engine3
 
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr LightingHable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
 
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
 
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
 
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3
 
Taking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next GenerationTaking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next Generation
 
Triangle Visibility buffer
Triangle Visibility bufferTriangle Visibility buffer
Triangle Visibility buffer
 
Advancements in-tiled-rendering
Advancements in-tiled-renderingAdvancements in-tiled-rendering
Advancements in-tiled-rendering
 
Progressive Lightmapper: An Introduction to Lightmapping in Unity
Progressive Lightmapper: An Introduction to Lightmapping in UnityProgressive Lightmapper: An Introduction to Lightmapping in Unity
Progressive Lightmapper: An Introduction to Lightmapping in Unity
 
DD18 - SEED - Raytracing in Hybrid Real-Time Rendering
DD18 - SEED - Raytracing in Hybrid Real-Time RenderingDD18 - SEED - Raytracing in Hybrid Real-Time Rendering
DD18 - SEED - Raytracing in Hybrid Real-Time Rendering
 

Similar to Volumetric Lighting for Many Lights in Lords of the Fallen

Paris Master Class 2011 - 07 Dynamic Global Illumination
Paris Master Class 2011 - 07 Dynamic Global IlluminationParis Master Class 2011 - 07 Dynamic Global Illumination
Paris Master Class 2011 - 07 Dynamic Global IlluminationWolfgang Engel
 
Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1Ki Hyunwoo
 
ML Module 3 Non Linear Learning.pptx
ML Module 3 Non Linear Learning.pptxML Module 3 Non Linear Learning.pptx
ML Module 3 Non Linear Learning.pptxDebabrataPain1
 
Massive Point Light Soft Shadows
Massive Point Light Soft ShadowsMassive Point Light Soft Shadows
Massive Point Light Soft ShadowsWolfgang Engel
 
Temporal Superpixels Based on Proximity-Weighted Patch Matching
Temporal Superpixels Based on Proximity-Weighted Patch MatchingTemporal Superpixels Based on Proximity-Weighted Patch Matching
Temporal Superpixels Based on Proximity-Weighted Patch MatchingNAVER Engineering
 
SPATIAL POINT PATTERNS
SPATIAL POINT PATTERNSSPATIAL POINT PATTERNS
SPATIAL POINT PATTERNSLiemNguyenDuy
 
06 image features
06 image features06 image features
06 image featuresankit_ppt
 
Introduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous AgentsIntroduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous AgentsBryan Duggan
 
【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣
【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣
【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣Unity Technologies Japan K.K.
 
Simulating X-ray Observations with yt
Simulating X-ray Observations with ytSimulating X-ray Observations with yt
Simulating X-ray Observations with ytJohn ZuHone
 
NVIDIA 深度學習教育機構 (DLI): Image segmentation with tensorflow
NVIDIA 深度學習教育機構 (DLI): Image segmentation with tensorflowNVIDIA 深度學習教育機構 (DLI): Image segmentation with tensorflow
NVIDIA 深度學習教育機構 (DLI): Image segmentation with tensorflowNVIDIA Taiwan
 
A computer vision approach to speech enhancement
A computer vision approach to speech enhancementA computer vision approach to speech enhancement
A computer vision approach to speech enhancementRamin Anushiravani
 
From Experimentation to Production: The Future of WebGL
From Experimentation to Production: The Future of WebGLFrom Experimentation to Production: The Future of WebGL
From Experimentation to Production: The Future of WebGLFITC
 

Similar to Volumetric Lighting for Many Lights in Lords of the Fallen (20)

Paris Master Class 2011 - 07 Dynamic Global Illumination
Paris Master Class 2011 - 07 Dynamic Global IlluminationParis Master Class 2011 - 07 Dynamic Global Illumination
Paris Master Class 2011 - 07 Dynamic Global Illumination
 
Hw1 updated
Hw1 updatedHw1 updated
Hw1 updated
 
Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1
 
Light and Shadows
Light and ShadowsLight and Shadows
Light and Shadows
 
Compressed Sensing - Achuta Kadambi
Compressed Sensing - Achuta KadambiCompressed Sensing - Achuta Kadambi
Compressed Sensing - Achuta Kadambi
 
ML Module 3 Non Linear Learning.pptx
ML Module 3 Non Linear Learning.pptxML Module 3 Non Linear Learning.pptx
ML Module 3 Non Linear Learning.pptx
 
Massive Point Light Soft Shadows
Massive Point Light Soft ShadowsMassive Point Light Soft Shadows
Massive Point Light Soft Shadows
 
Temporal Superpixels Based on Proximity-Weighted Patch Matching
Temporal Superpixels Based on Proximity-Weighted Patch MatchingTemporal Superpixels Based on Proximity-Weighted Patch Matching
Temporal Superpixels Based on Proximity-Weighted Patch Matching
 
november29.ppt
november29.pptnovember29.ppt
november29.ppt
 
november6.ppt
november6.pptnovember6.ppt
november6.ppt
 
SPATIAL POINT PATTERNS
SPATIAL POINT PATTERNSSPATIAL POINT PATTERNS
SPATIAL POINT PATTERNS
 
06 image features
06 image features06 image features
06 image features
 
Introduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous AgentsIntroduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous Agents
 
【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣
【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣
【Unite 2018 Tokyo】プログレッシブライトマッパーの真価を発揮する秘訣
 
Simulating X-ray Observations with yt
Simulating X-ray Observations with ytSimulating X-ray Observations with yt
Simulating X-ray Observations with yt
 
NVIDIA 深度學習教育機構 (DLI): Image segmentation with tensorflow
NVIDIA 深度學習教育機構 (DLI): Image segmentation with tensorflowNVIDIA 深度學習教育機構 (DLI): Image segmentation with tensorflow
NVIDIA 深度學習教育機構 (DLI): Image segmentation with tensorflow
 
Far cry 3
Far cry 3Far cry 3
Far cry 3
 
A computer vision approach to speech enhancement
A computer vision approach to speech enhancementA computer vision approach to speech enhancement
A computer vision approach to speech enhancement
 
Real-time lightmap baking
Real-time lightmap bakingReal-time lightmap baking
Real-time lightmap baking
 
From Experimentation to Production: The Future of WebGL
From Experimentation to Production: The Future of WebGLFrom Experimentation to Production: The Future of WebGL
From Experimentation to Production: The Future of WebGL
 

Recently uploaded

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 

Recently uploaded (20)

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 

Volumetric Lighting for Many Lights in Lords of the Fallen

  • 1. Volumetric Lighting for Many Lights in Lords of the Fallen Benjamin Glatzel Engine/Graphics Programmer Deck13 Interactive GmbH
  • 2. Who are we? • One of Germany’s leading game studios • Currently working on “Lords of the Fallen” in cooperation with CI Games • We’re using our own proprietary multi-platform technology called “Fledge” • We’ve shipped numerous titles primarily on PC but also on Xbox 360, iOS and PS3 (maybe you know Jack Keane, Ankh, Venetica, Blood Knights or Tiger and Chicken)
  • 3. Lords of the Fallen • Lords of the Fallen is a challenging Action-RPG for PC, Xbox One and PlayStation 4 • Will be released fall 2014 • For an in-depth view into the rendering guts of Fledge, visit Philips talk tomorrow
  • 4. Who am I? • Engine/Graphics Programmer since 2 years • Mainly responsible for the GNM/PS4 version of “Fledge” • Apart from that I'm behind everything related to physics, our software rasterisation based culling system, our IK system, …
  • 6.
  • 7.
  • 10. Motivation • Simple light shafts as a screen space post-processing effect [1] sure are shiny, but…
  • 11. Light shafts as a post-processing effect
  • 12. Light shafts as a post-processing effect
  • 13. Motivation • Billboards can be neat, but…
  • 16. Motivation • We wanted something more dynamic and flexible that could be tightly integrated into our lighting system • It should work with a lot of small to medium sized light sources • Our artists tend to place a whole lot of lights • Thus a negligible performance penalty on all supported platforms was critical
  • 19. State of the Art • Many recent implementations seem to be based on the work of Toth et. al. [2]: • Ray marching in light view space while evaluating the shadow map • Often combined with a special sampling approach to reduce the workload per fragment • Many other approaches/optimisations popped up over the recent years: Epipolar sampling [3], sampling planes shaded in light space [4], …
  • 21. Our Approach • Loosely based on “Real-time Volumetric Lighting in Participating Media” (Toth et. al. [2]) • Straightforward ray marching • Usage of “Interleaved Sampling” to reduce the overall sample count needed per fragment • Utilises low-resolution rendering to reduce the fragment workload even further
  • 22. Our Approach • Works with multiple lights and light types • Custom bilateral blurring and depth-aware up- sampling to work around the obvious artefacts • Various tweaks and optimisations per light type • Completely implemented using good old pixel and vertex shaders - no compute
  • 24. Radiative Transport Equation [2] ~x(s) = ~x0 + ~!s L(~x(s), ~!) ⌧ a P(~!0 , ~!) Ray equation, where ω is the direction of the ray Change of radiance along the ray Probability of collision Scattering probability after collision Phase function dL(~x(s), ~!) ds = ⌧L(~x(s), ~!) + ⌧a Z ⌦0 L(~x(s), ~!)P(~!0 , ~!)d!0
  • 25. L(~x(s), ~!) = e ⌧s L(~x0, ~!) + Z s 0 Li(~x(l), ~!)e ⌧(s l) dl L(~x(s), ~!) ⇡ L(~x0, ~!)e ⌧s + NX n=0 Li(~x(ln), ~!)e ⌧(s ln) l Ignore multiple scattering Li(~x, ~!) = ⌧a 4⇡d2 v(~x)e ⌧d P(~!l, ~!) In-scattering term s Total ray marching distance d Distance to the light source l Traveled distance on the ray l Step size v(~x) Visibility function Source power of the light Direction from the ray position to the light source ~!l
  • 26. Basic Algorithm • Let’s start with a simple fullscreen pass for a directional light • Start the ray marching on the position of the current fragment in light space • Evaluate and accumulate the in-scattering term for each of the n samples and march in equidistant steps towards the position of the viewer
  • 27. #define NUM_SAMPLES 128! #define NUM_SAMPLES_RCP 0.0078125! ! FRAGMENT_OUT ps_main(VERTEX_OUTPUT f_in)! {! // Fallback if we can't find a tighter limit! float raymarchDistanceLimit = 999999.0 ;! ! [...]! ! // Reduce noisyness by truncating the starting position! float raymarchDistance = trunc ( clamp ( length ( cameraPositionLightVS . xyz - positionLightVS . xyz ) , ! 0.0, raymarchDistanceLimit ) ) ;! ! // Calculate the size of each step! float stepSize = raymarchDistance * NUM_SAMPLES_RCP ;! float3 rayPositionLightVS = positionLightVS . xyz ;! ! // The total light contribution accumulated along the ray! float3 VLI = 0.0 ;! ! // ... start the actual ray marching! [loop] for ( float l = raymarchDistance; l > stepSize ; l -= stepSize ) ! {! executeRaymarching(...) ;! }! ! f_out . color . rgb = light_color_diffuse . rgb * VLI ;! return f_out ;! }
  • 28. #define TAU 0.0001! #define PHI 10000000.0! ! #define PI_RCP 0.31830988618379067153776752674503! ! void executeRaymarching(...)! {! rayPositionLightVS . xyz += stepSize * invViewDirLightVS . xyz ;! ! [...]! ! // Fetch whether the current position on the ray is visible form the light's perspective - or not! float3 shadowTerm = getShadowTerm ( shadowMapSampler, shadowMapSamplerState, rayPositionLightSS . xyz ) . xxx ;! ! // Distance to the current position on the ray in light view-space! float d = length ( rayPositionLightVS . xyz ) ; ;! float dRcp = rcp ( d ) ;! ! // Calculate the final light contribution for the sample on the ray...! float3 intens = TAU * ( shadowTerm * (phi * 0.25 * PI_RCP) * dRcp * dRcp ) * exp( -d * TAU ) * exp ( -l * TAU ) * stepSize ;! ! // ... and add it to the total contribution of the ray! VLI += intens ;! }
  • 29.
  • 30. From One to Many
  • 31.
  • 32.
  • 33. From One to Many • Render the back faces of the light volume for each volumetric light (depth test/ write disabled) • Start the ray marching on the fragment of the light geometry instead of the scene geometry • If the light volume intersects the scene geometry, the starting position gets clamped to the closest fragment position relatively to the viewer
  • 34. From One to Many • Calculate the in-scattering term as depicted before • In addition to that evaluate the attenuation function for each given light type and “modulate” it with the in-scattering term • March the ray in light view and in world space in parallel - less costly than transforming between spaces for each step • Accumulate the volumetric lighting contribution for each visible light to an accumulation buffer using additive blending
  • 35. From One to Many • Constrain the taken samples to the area inside the light volume to increase the precision • For box and point lights we simply clamp the total ray marching distance to the attenuation ranges of the lights • In the case of spotlights we actually calculate the intersection points between the current ray and the light volume and calculate the range in-between
  • 36. Much slow Wow So sample How to Make it Fast
  • 37. How to Make it Fast • Everything I told you so far needs far too many samples to achieve visually pleasing results • 128+ samples per fragment for each light rendered to a full resolution target does not sound like the ideal solution
  • 38. How to Make it Fast • We ended up rendering all volumetrics to a half or quarter resolution target • We use an additional depth aware up-sampling pass to hide this fact - often referred to as ”Nearest Depth Up-Sampling“ [5]
  • 41. How to Make it Fast • Only using half-resolution rendering will not suffice to make it fast enough for multiple light sources on the screen • We can “abuse” the fact that the in-scattered light value at a given fragment position is either equal or at least close to one or more of the surrounding values
  • 42. How to Make it Fast • We spread the evaluation of the in-scattering term from a single pixel to multiple pixels • We ended up using 8x8 pixel tiles, where each pixel of a tile evaluates 16 samples • This makes a total of 8x8x16 = 1024 potential samples • Each pixel of one tile evaluates a different region of the ray vs.
  • 43. How to Make it Fast • Assign an unique index i ∊ [0..64) to each pixel of the tile - the indices repeat for each tile • Reduce the total ray marching distance by one step • Offset the ray marching starting position for each pixel of the tile according to i • • Randomising the indices trades the obvious repetitive sampling pattern for some less noticeable noise ray = i stepSize 64
  • 44. #define INTERLEAVED_GRID_SIZE 8! #define INTERLEAVED_GRID_SIZE_SQR 64! #define INTERLEAVED_GRID_SIZE_SQR_RCP 0.015625! ! [...]! ! // Calculate the offsets on the ray according to the interleaved sampling pattern! float2 interleavedPos = fmod ( f_in . position . xy, INTERLEAVED_GRID_SIZE ) ; ! ! #if defined (USE_RANDOM_RAY_SAMPLES)! float index = ( interleavedPos . y * INTERLEAVED_GRID_SIZE + interleavedPos . x ) ;! // light_volumetric_random_ray_samples contains the values 0..63 in a randomized order! // The indices are packed to float4s => { (0,1,2,3), (4,5,6,7), ... }! float rayStartOffset = light_volumetric_random_ray_samples [ index * 0.25 ] [ fmod ( index, 4.0 ) ] * ( stepSize * INTERLEAVED_GRID_SIZE_SQR_RCP ) ;! #else! float rayStartOffset = ( interleavedPos . y * INTERLEAVED_GRID_SIZE + interleavedPos . x ) * ( stepSize * INTERLEAVED_GRID_SIZE_SQR_RCP ) ;! #endif // USE_RANDOM_RAY_SAMPLES! ! float3 rayPositionLightVS = rayStartOffset * invViewDirLightVS . xyz + positionLightVS . xyz ;! ! [...]
  • 45. Accumulation buffer before the gather pass
  • 46. How to Make it Fast • To achieve the final results we use an additional blur pass before the up-sampling pass • We use a simple bilateral blur filter to avoid bleeding over the edges of any geometry inside or behind the volumetrics
  • 47. Accumulation buffer after the gather pass
  • 52. Render light geometry for each volumetric and execute ray marching R11G11B10 1/2 Resolution Apply horizontal and vertical bilateral Gaussian Blur Accumulation Pass Gather Pass Apply depth-aware up- sampling Upscale Pass Composite Pass Add final up-scaled buffer to the scene R11G11B10 Native Resolution Final Scene
  • 54. 2D projector texture (gobo/cookie)
  • 56. IES profilesTop down perspective
  • 58. Anisotropic scattering (Henyey-Greenstein phase function) p(⇥) = 1 g2 (1 + g2 + 2g cos ⇥)1.5
  • 59. Anisotropic scattering (Schlick phase function) p(⇥) = 1 k2 (1 + k cos ⇥)2 k ⇡ 1.55g 0.55g3
  • 63.
  • 64. Pass PC (GTX 700 Series GPU) PS4/GNM Accumulation* 0.362 ms 0.161 ms Gather 0.223 ms 0.375 ms Upscale 0.127 ms 0.321 ms = 0.712 ms = 0.857 ms *measured using a half resolution render target
  • 71. Thanks for listening! :) Questions?
  • 72. Contact • Benjamin Glatzel <bglatzel@deck13.com> • @begla • http://www.deck13.com
  • 73. References • [1] Volumetric Light Scattering as a Post-Process - http:// http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html • [2] Real-time Volumetric Lighting in Participating Media - http:// sirkan.iit.bme.hu/~szirmay/lightshaft.pdf • [3] Epipolar Sampling for Shadows and Crepuscular Rays in Participating Media with Single Scattering - http://www.sfb716.uni-stuttgart.de/uploads/ tx_vispublications/espmss10.pdf • [4] Light Shafts - Rendering Shadows in Participating Media - http:// developer.amd.com/wordpress/media/2012/10/Mitchell_LightShafts.pdf • [5] Fast Rendering of Opacity Mapped Particles using DirectX 11 Tessellation and Mixed Resolutions - https://developer.nvidia.com/sites/default/files/akamai/ gamedev/files/sdk/11/OpacityMappingSDKWhitePaper.pdf
  • 77. static const float gauss_filter_weights[] = {! 0.14446445, 0.13543542, 0.11153505, 0.08055309, 0.05087564, 0.02798160, 0.01332457, 0.00545096! } ;! ! #define NUM_SAMPLES_HALF 7! #define BLUR_DEPTH_FALLOFF 1000.0! ! float4 gatherGauss ( in float2 blurDirection , in float2 uv )! {! [...]! ! [unroll]! for ( REAL r = -NUM_SAMPLES_HALF; r <= NUM_SAMPLES_HALF; ++r )! {! uvOffset = r * blurDirection * rendertarget_size . zw ;! kernelSample = SAMPLE ( inputSampler, uv + uvOffset ) . rgba ;! kernelDepth = getLinearDepth ( depthSampler, depthSamplerState, uv + uvOffset ) ;! ! // Simple depth-aware filtering! depthDiff = abs ( kernelDepth - centerDepth ) ;! r2 = BLUR_DEPTH_FALLOFF * depthDiff ;! g = exp ( -r2*r2 ) ;! weight = g * gauss_filter_weights [ abs ( r ) ] ;! ! accumResult += weight * kernelSample . rgb ;! ! accumWeights += weight ;! }! ! return float4 ( accumResult . rgb / accumWeights , 1.0 ) ;! }! ! float4 ps_gather_horz ( VERTEX_OUTPUT f_in ) : SV_Target! {! return gatherGauss ( float2 ( 1.0, 0.0 ), f_in . uv0 ) ;! }! ! [...]
  • 78. float4 ps_upsample ( VERTEX_OUTPUT f_in ) : SV_Target! {! [...]! ! // Better choose something relative to the far clip distance here! const float upsampleDepthThreshold = 0.0001 ;! ! float minDepthDiff = 1.0 ;! uint nearestDepthIndex = 0 ;! ! float currentDepthDiff = abs ( sampleDownsampledDepth[0] - fullResDepth ) ;! bool rejectSample = currentDepthDiff < upsampleDepthThreshold ;! ! [branch]! if ( currentDepthDiff < minDepthDiff )! {! minDepthDiff = currentDepthDiff ;! nearestDepthIndex = 0 ;! }! ! currentDepthDiff = abs ( sampleDownsampledDepth[1] - fullResDepth ) ;! rejectSample = rejectSample && currentDepthDiff < upsampleDepthThreshold ; ! ! [branch]! if ( currentDepthDiff < minDepthDiff )! {! minDepthDiff = currentDepthDiff ;! nearestDepthIndex = 1 ;! }! ! // Repeat this for the remaining 2 samples! [...]! ! // Avoid blocky artefacts using edge detection! if (rejectSample)! return float4 ( SAMPLE ( inputSampler, f_in . uv0 ) . rgb, 1.0 ) ;! ! return float4 ( sampleR[nearestDepthIndex], sampleG[nearestDepthIndex], sampleB[nearestDepthIndex], 1.0 ) ;! }