FidelityFX Brixelizer GI 1.0
FidelityFX Brixelizer GI is a compute-based, highly-optimized global illumination technique implemented in HLSL.
Table of Contents
Requirements
-
HLSL
CS_6_6
Integration Guidelines
FidelityFX Brixelizer GI
API
// =============================================================================
// Initialize/destroy the FFX Brixelizer GI backend
// =============================================================================
FfxBrixelizerGIContextDescription desc = {};
desc.flags = ...;
desc.internalResolution = ...;
desc.displaySize = ...;
desc.backendInterface = ffxGetInterface (...);
FfxBrixelizerGIContext context = {};
FfxErrorCode error = ffxBrixelizerGIContextCreate (&context, &desc);
assert(error == FFX_OK );
// ...
FfxErrorCode error = ffxBrixelizerGIContextDestroy (&context);
assert(error == FFX_OK );
// =============================================================================
// Brixelizer GI frame update
// =============================================================================
FfxBrixelizerGIDispatchDescription desc = {};
desc.view = ...;
desc.projection = ...;
desc.prevView = ...;
desc.prevProjection = ...;
desc.cameraPosition = ...;
desc.startCascade = ...;
desc.endCascade = ...;
desc.rayPushoff = ...;
desc.sdfSolveEps = ...;
desc.specularRayPushoff = ...;
desc.specularSDFSolveEps = ...;
desc.tMin = ...;
desc.tMax = ...;
desc.environmentMap = ...;
desc.prevLitOutput = ...;
desc.depth = ...;
desc.historyDepth = ...;
desc.normal = ...;
desc.historyNormal = ...;
desc.roughness = ...;
desc.motionVectors = ...;
desc.noiseTexture = ...;
desc.normalsUnpackMul = ...;
desc.normalsUnpackAdd = ...;
desc.isRoughnessPerceptual = ...;
desc.roughnessChannel = ...;
desc.roughnessThreshold = ...;
desc.environmentMapIntensity = ...;
desc.motionVectorScale = ...;
desc.sdfAtlas = ...;
desc.bricksAABBs = ...;
for (uint32_t i = 0; i < 24; ++i) {
desc.cascadeAABBTrees[i] = ...;
desc.cascadeBrickMaps[i] = ...;
}
desc.outputDiffuseGI = ...;
desc.outputSpecularGI = ...;
desc.brixelizerContext = ...;
FfxCommandList commandList = ffxGetCommandList (...);
FfxErrorCode error = ffxBrixelizerGIContextDispatch (&context, &desc, commandList);
assert(error == FFX_OK );
// =============================================================================
// Brixelizer GI debug visualization
// =============================================================================
FfxBrixelizerGIDebugDescription desc = {};
desc.view = ...; // The view matrix for the scene in row major order.
desc.projection = ...; // The projection matrix for the scene in row major order.
desc.startCascade = ...; // The index of the start cascade for use with ray marching with Brixelizer.
desc.endCascade = ...; // The index of the end cascade for use with ray marching with Brixelizer.
desc.outputSize = ...; // The dimensions of the output texture.
desc.debugMode = ...; // The mode for the debug visualization. See <c><i>FfxBrixelizerGIDebugMode</i></c>.
desc.depth = ...; // The input depth buffer.
desc.normal = ...; // The input normal buffer.
desc.sdfAtlas = ...; // The SDF Atlas resource used by Brixelizer.
desc.bricksAABBs = ...; // The brick AABBs resource used by Brixelizer.
for (uint32_t i = 0; i < 24; ++i) {
desc.cascadeAABBTrees [24]; // The cascade AABB tree resources used by Brixelizer.
desc.cascadeBrickMaps [24]; // The cascade brick map resources used by Brixelizer.
}
desc.outputDebug = ...; // The output texture for the debug visualization.
desc.brixelizerContext = ...; // A pointer to the Brixelizer context for use with Brixelizer GI.
FfxCommandList = ffxGetCommandList (...);
FfxErrorCode error = ffxBrixelizerGIContextDebugVisualization (&context, &desc, commandList);
assert(error == FFX_OK );
Algorithm Overview
FidelityFX Brixelizer GI is a simplified implementation of AMD GI-1.0.
It takes in the G-Buffer resources of your application alongside the output resources from Brixelizer to generate Diffuse and Specular GI outputs.
Due to the lack of material information in the distance field from Brixelizer, we maintain an internal radiance cache which is populated by the previous frames’ lighting output.
Including just direct lighting will result in 1-bounce diffuse GI, whereas including the composited output from the previous frame gives you multiple bounces effectively for free.
Next we spawn screen probes on the visible surfaces in the depth buffer and shoot rays using Brixelizer and sample the radiance cache for shading.
Screen probes are internally stored in an 8×8 octahedral mapping:
These screen probes are then used to feed a world space irradiance cache by performing a parallel reduction in shared memory to project the 8×8 incoming radiance values on to 2nd order spherical harmonics that are stored at each valid brick.
The final Diffuse GI output is resolved by projecting the nearest SH probe on to G-Buffer normal.
For Specular GI we perform a pre-trace at quarter resolution to figure out the brick IDs at hit points and afterwards use a full-resolution dispatch to skip directly to ray-marching the bricks, finding the hit point and sample the radiance cache.
After the update you composite the diffuse and specular GI outputs into your direct lighting output the same way you would do with Image based lighting. Usually by plugging it into Epic’s split-sum approximation.
Implementation
Resources
User Created Resources
Name |
Type |
Format/Stride |
Dimensions/Size in bytes |
---|---|---|---|
Output Diffuse GI |
|
|
|
Output Specular GI |
|
|
|
Debug Output |
|
A user defined |
|
Internal Frame Persistent Resources
The following is a table of all structured buffers managed internally by the Brixelizer context.
Name |
Format/Stride |
Length/Dimensions |
Description |
---|---|---|---|
|
|
|
A 3D texture containing the incoming direct lighting at each brick volume represented using 4x4x4 texels. |
|
|
|
One of two ping-pong textures for storing internal Diffuse GI output. |
|
|
|
One of two ping-pong textures for storing internal Diffuse GI output. |
|
|
|
One of two ping-pong textures for storing screen probes output. |
|
|
|
One of two ping-pong textures for storing screen probes output. |
|
|
|
One of two ping-pong textures for storing internal Specular GI output. |
|
|
|
One of two ping-pong textures for storing internal Specular GI output. |
|
|
|
A texture that stores the generated disocclusion mask for rejecting history. |
|
|
|
A texture that stores the average color of a screen probe. |
|
|
|
A texture that stores the spawn information for screen probes. |
|
|
|
A texture that stores brick IDs at specular trace hits. |
|
|
|
A texture that stores the random seeds for screen probes. |
|
|
|
A buffer that stores indirect dispatch arguments. |
|
|
|
A texture that stores the downsampled depth. |
|
|
|
A texture that stores the downsampled history depth. |
|
|
|
A texture that stores the downsampled normals. |
|
|
|
A texture that stores the downsampled history normals. |
|
|
|
A texture that stores the downsampled roughness. |
|
|
|
A texture that stores the downsampled motion vectors. |
|
|
|
A texture that stores the downsampled previous frames’ shading output. |
|
|
|
A texture that stores the output Diffuse GI prior to upsampling. |
|
|
|
A texture that stores the output Specular GI prior to upsampling. |
|
|
|
A buffer that stores the spherical harmonics probes at bricks. |
|
|
|
A buffer that stores the incoming direct lighting at bricks as second order spherical harmonics. |
|
|
|
A buffer that stores the direction of the screen probe sample as second order spherical harmonics. |
|
|
|
A buffer that stores the spherical harmonics representation ofthe screen probes. |
|
|
|
A buffer that stores the spherical harmonics representation ofthe screen probes. |
|
|
|
A buffer that stores packed information of screen probe. |
|
|
|
A buffer that stores packed information of screen probe. |
The following is a list of the different constant buffers managed by the Brixelizer GI context.
Name |
Format |
Description |
---|---|---|
|
|
Parameters describing the Brixelizer GI context. |
|
|
Parameters describing the emit irradiance pass. |
|
|
Parameters for downsampling and upsampling constants. |
|
|
Parameters describing the Brixelizer context. |
|
|
Parameters describing a single cascade. |
Shader Passes
Here is a list of all the shader passes used by Brixelizer GI.
Function |
File |
Group Dimensions |
Description |
---|---|---|---|
|
|
|
Downsample input resources if using a non-native internal resolution scale. |
|
|
|
Generate a disocclusion mask into |
|
|
|
Write indirect dispatch arguments into |
|
|
|
Clear radiance cache entries for invalidated bricks. |
|
|
|
Inject reprojected radiance from the last frame into the radiance cache. |
|
|
|
Propagate the SH probes at each brick into the neighboring bricks. |
|
|
|
Spawn new screen probes on the depth buffer and output probe information. |
|
|
|
Reproject screen probes from the previous frame into the current frame. |
|
|
|
Trace diffuse rays using Brixelizer to inject new radiance information into screen probes. |
|
|
|
Trace specular rays using Brixelizer and output brick IDs at hit points. |
|
|
|
Reproject the diffuse and specular GI outputs from the previous frame into the current frame. |
|
|
|
Resolve specular output by ray marching the bricks from the Specular Pre Trace pass and sampling the radiance cache. |
|
|
|
Project the octahedral screen probes into spherical harmonics. |
|
|
|
Update the irradiance cache using spherical harmonics screen probes. |
|
|
|
Resolve final diffuse and specular GI output and perform temporal accumulation. |
|
|
|
Spatially denoise the diffuse and specular GI outputs. |
|
|
|
Upscale diffuse and specular GI outputs if using a non-native internal resolution scale. |