r.GTAO.FilterWidth
r.GTAO.FilterWidth
#Overview
name: r.GTAO.FilterWidth
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Size of the noise pattern and filter width\n 5: 5x5 Pattern (default) \n 4: 4x4 Pattern \n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.GTAO.FilterWidth is to control the size of the noise pattern and filter width for Ground Truth Ambient Occlusion (GTAO) in Unreal Engine’s rendering system.
This setting variable is primarily used in the rendering subsystem of Unreal Engine, specifically in the post-processing and ambient occlusion components. It’s part of the CompositionLighting module, as evidenced by its location in the PostProcessAmbientOcclusion.cpp file.
The value of this variable is set through a console variable (CVarGTAOFilterWidth) with a default value of 5. It can be changed at runtime using console commands or through project settings.
The associated variable CVarGTAOFilterWidth directly interacts with r.GTAO.FilterWidth, as they share the same value. This console variable is used to retrieve the current filter width value in the rendering code.
Developers should be aware that:
- The filter width affects the quality and performance of the GTAO effect.
- Only two options are explicitly mentioned in the comments: 5x5 (default) and 4x4 patterns.
- The variable is marked as render thread safe and scalable, meaning it can be adjusted for different performance levels.
Best practices when using this variable include:
- Consider the performance implications when adjusting the filter width. A larger filter may provide better quality but at a higher performance cost.
- Use the provided options (5 or 4) unless there’s a specific need for other values.
- Test the visual impact and performance when changing this value, as it directly affects the GTAO calculation.
Regarding the associated variable CVarGTAOFilterWidth:
- It’s a TAutoConsoleVariable of type int32, which allows for easy runtime modification and retrieval of the GTAO filter width.
- It’s used directly in the rendering code to determine the filter width for GTAO calculations.
- The value is retrieved using GetValueOnRenderThread(), ensuring thread-safe access in the render thread.
- While the comments mention 5x5 and 4x4 patterns, the code also checks for a value of 3.0, suggesting there might be an undocumented 3x3 pattern option.
- Developers should use this variable when they need to programmatically access or modify the GTAO filter width in C++ code, rather than directly accessing the r.GTAO.FilterWidth console variable.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:104
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarGTAOFilterWidth(
TEXT("r.GTAO.FilterWidth"),
5,
TEXT("Size of the noise pattern and filter width\n ")
TEXT("5: 5x5 Pattern (default) \n ")
TEXT("4: 4x4 Pattern \n "),
ECVF_RenderThreadSafe | ECVF_Scalability);
#Associated Variable and Callsites
This variable is associated with another variable named CVarGTAOFilterWidth
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:103
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<int32> CVarGTAOFilterWidth(
TEXT("r.GTAO.FilterWidth"),
5,
TEXT("Size of the noise pattern and filter width\n ")
TEXT("5: 5x5 Pattern (default) \n ")
TEXT("4: 4x4 Pattern \n "),
ECVF_RenderThreadSafe | ECVF_Scalability);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:1555
Scope (from outer to inner):
file
function FScreenPassTexture AddGTAOSpatialFilter
Source code excerpt:
FVector4f FilterWidthParamsValue(0.0f, 0.0f, 0.0f, 0.0f);
float FilterWidth = CVarGTAOFilterWidth.GetValueOnRenderThread();
if (FilterWidth == 3.0f)
{
FilterWidthParamsValue.X = -1.0f;
FilterWidthParamsValue.Y = 1.0f;
}