r.AOHistoryDistanceThreshold
r.AOHistoryDistanceThreshold
#Overview
name: r.AOHistoryDistanceThreshold
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
World space distance threshold needed to discard last frame\'s DFAO results. Lower values reduce ghosting from characters when near a wall but increase flickering artifacts.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.AOHistoryDistanceThreshold is to control the world space distance threshold for discarding the previous frame’s Distance Field Ambient Occlusion (DFAO) results in Unreal Engine 5’s rendering system. This setting is primarily used in the post-processing stage of the DFAO rendering pipeline.
This setting variable is relied upon by the Renderer module of Unreal Engine, specifically in the Distance Field Lighting Post-processing subsystem. It’s used in the DFAO rendering process to manage temporal stability and reduce artifacts.
The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 30 and can be modified at runtime using console commands or through project settings.
The associated variable GAOHistoryDistanceThreshold directly interacts with r.AOHistoryDistanceThreshold. They share the same value, with GAOHistoryDistanceThreshold being the actual variable used in the rendering code.
Developers must be aware that adjusting this variable involves a trade-off. Lower values will reduce ghosting artifacts from moving objects (like characters) when they are near walls or other occluding geometry. However, lower values may also increase flickering artifacts in the ambient occlusion effect.
Best practices when using this variable include:
- Fine-tuning the value based on the specific needs of your scene and the movement speed of objects.
- Testing the setting with various types of geometry and movement to find the optimal balance between reducing ghosting and minimizing flickering.
- Considering the performance impact, as very low values might require more frequent updates of the DFAO results.
Regarding the associated variable GAOHistoryDistanceThreshold:
The purpose of GAOHistoryDistanceThreshold is to serve as the internal representation of the r.AOHistoryDistanceThreshold console variable within the rendering code.
This variable is used directly in the rendering pipeline, specifically in the UpdateHistory function of the Distance Field Lighting Post-processing system.
The value of GAOHistoryDistanceThreshold is set by the console variable system when r.AOHistoryDistanceThreshold is modified.
GAOHistoryDistanceThreshold interacts directly with the shader parameters in the DFAO post-processing pass.
Developers should be aware that modifying GAOHistoryDistanceThreshold directly in code is not recommended, as it may be overwritten by the console variable system. Instead, they should use the r.AOHistoryDistanceThreshold console variable to ensure consistency.
Best practices for GAOHistoryDistanceThreshold include accessing it through the appropriate rendering systems and avoiding direct modification unless absolutely necessary for specialized rendering techniques.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldLightingPost.cpp:48
Scope: file
Source code excerpt:
float GAOHistoryDistanceThreshold = 30;
FAutoConsoleVariableRef CVarAOHistoryDistanceThreshold(
TEXT("r.AOHistoryDistanceThreshold"),
GAOHistoryDistanceThreshold,
TEXT("World space distance threshold needed to discard last frame's DFAO results. Lower values reduce ghosting from characters when near a wall but increase flickering artifacts."),
ECVF_RenderThreadSafe
);
float GAOViewFadeDistanceScale = .7f;
#Associated Variable and Callsites
This variable is associated with another variable named GAOHistoryDistanceThreshold
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldLightingPost.cpp:46
Scope: file
Source code excerpt:
);
float GAOHistoryDistanceThreshold = 30;
FAutoConsoleVariableRef CVarAOHistoryDistanceThreshold(
TEXT("r.AOHistoryDistanceThreshold"),
GAOHistoryDistanceThreshold,
TEXT("World space distance threshold needed to discard last frame's DFAO results. Lower values reduce ghosting from characters when near a wall but increase flickering artifacts."),
ECVF_RenderThreadSafe
);
float GAOViewFadeDistanceScale = .7f;
FAutoConsoleVariableRef CVarAOViewFadeDistanceScale(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldLightingPost.cpp:354
Scope (from outer to inner):
file
function void UpdateHistory
Source code excerpt:
PassParameters->HistoryWeight = GAOHistoryWeight;
PassParameters->HistoryDistanceThreshold = GAOHistoryDistanceThreshold;
PassParameters->UseHistoryFilter = UseAOHistoryStabilityPass() ? 1.0f : 0.0f;
{
const float InvBufferSizeX = 1.0f / AOBufferSize.X;
const float InvBufferSizeY = 1.0f / AOBufferSize.Y;