r.GTAO.ThicknessBlend
r.GTAO.ThicknessBlend
#Overview
name: r.GTAO.ThicknessBlend
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
A heuristic to bias occlusion for thin or thick objects. \n 0 : Off \n >0 : On - Bigger values lead to reduced occlusion \n 0.5: On (default)\n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.GTAO.ThicknessBlend is to adjust the ground truth ambient occlusion (GTAO) algorithm’s behavior for thin or thick objects in the rendering system. It provides a heuristic to bias occlusion based on object thickness.
This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically in the ambient occlusion post-processing subsystem. It is referenced in both the standard and mobile versions of the ambient occlusion implementation.
The value of this variable is set through a console variable (CVar) system. It is defined with a default value of 0.5f and can be adjusted at runtime.
The r.GTAO.ThicknessBlend variable interacts with other GTAO-related variables such as r.GTAO.FalloffStartRatio, r.GTAO.FalloffEnd, and r.GTAO.NumAngles. These variables collectively control various aspects of the GTAO algorithm.
Developers must be aware that this variable affects the visual quality of ambient occlusion in the scene. Higher values lead to reduced occlusion, which can be useful for fine-tuning the appearance of thin or thick objects.
Best practices when using this variable include:
- Experiment with different values to find the optimal balance for your specific scene.
- Consider the performance impact of adjusting this value, as it may affect rendering time.
- Use in conjunction with other GTAO settings for a comprehensive control over ambient occlusion.
Regarding the associated variable CVarGTAOThicknessBlend:
The purpose of CVarGTAOThicknessBlend is to provide a programmatic interface for the r.GTAO.ThicknessBlend setting. It allows the engine to access and modify the thickness blend value from C++ code.
This variable is used within the Renderer module, specifically in the ambient occlusion post-processing implementation.
The value of CVarGTAOThicknessBlend is set when the console variable r.GTAO.ThicknessBlend is initialized or changed.
CVarGTAOThicknessBlend interacts directly with the rendering code, providing the actual value used in GTAO calculations.
Developers should be aware that changing CVarGTAOThicknessBlend programmatically will affect the GTAO rendering in the same way as adjusting r.GTAO.ThicknessBlend through the console.
Best practices for using CVarGTAOThicknessBlend include:
- Use GetValueOnRenderThread() when accessing the value to ensure thread-safety.
- Consider caching the CVar pointer for performance in frequently called rendering code.
- Be cautious when modifying this value dynamically, as it can have a significant impact on visual quality.
#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:112
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarGTAOThicknessBlend(
TEXT("r.GTAO.ThicknessBlend"),
0.5f,
TEXT("A heuristic to bias occlusion for thin or thick objects. \n ")
TEXT("0 : Off \n ")
TEXT(">0 : On - Bigger values lead to reduced occlusion \n ")
TEXT("0.5: On (default)\n "),
ECVF_RenderThreadSafe | ECVF_Scalability);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessAmbientOcclusionMobile.cpp:461
Scope (from outer to inner):
file
function static void RenderGTAO
Source code excerpt:
static void RenderGTAO(FRDGBuilder& GraphBuilder, FRDGTextureRef SceneDepthTexture, FRDGTextureRef AmbientOcclusionTexture, const TArray<FViewInfo>& Views)
{
static const auto GTAOThicknessBlendCVar = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.GTAO.ThicknessBlend"));
static const auto GTAOFalloffStartRatioCVar = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.GTAO.FalloffStartRatio"));
static const auto GTAOFalloffEndCVar = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.GTAO.FalloffEnd"));
static const auto GTAONumAnglesCVar = IConsoleManager::Get().FindTConsoleVariableDataFloat(TEXT("r.GTAO.NumAngles"));
const uint32 DownsampleFactor = 2;
const int32 MobileGTAOPreIntegratedTextureType = FMath::Min(CVarMobileGTAOPreIntegratedTextureType.GetValueOnRenderThread(), 2);
#Associated Variable and Callsites
This variable is associated with another variable named CVarGTAOThicknessBlend
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:111
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarGTAOThicknessBlend(
TEXT("r.GTAO.ThicknessBlend"),
0.5f,
TEXT("A heuristic to bias occlusion for thin or thick objects. \n ")
TEXT("0 : Off \n ")
TEXT(">0 : On - Bigger values lead to reduced occlusion \n ")
TEXT("0.5: On (default)\n "),
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:435
Scope: file
Source code excerpt:
// Frame X = number , Y = Thickness param,
float ThicknessBlend = CVarGTAOThicknessBlend.GetValueOnRenderThread();
ThicknessBlend = FMath::Clamp(1.0f - (ThicknessBlend * ThicknessBlend), 0.0f, 0.99f);
Result.GTAOParams[1] = FVector4f(Frame, ThicknessBlend, 0.0f, 0.0f);
// Destination buffer Size and InvSize
float Fx = float(DestSize.X);
float Fy = float(DestSize.Y);