r.GTAO.FalloffStartRatio
r.GTAO.FalloffStartRatio
#Overview
name: r.GTAO.FalloffStartRatio
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Ratio of the r.GTAO.FalloffEnd value at which it starts to fall off. \n Must be Between 0 and 1. \n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.GTAO.FalloffStartRatio is to control the falloff behavior in the Ground Truth Ambient Occlusion (GTAO) rendering technique. It specifically determines the ratio of the falloff end value at which the falloff effect starts to occur.
This setting variable is primarily used in the rendering system, particularly in the ambient occlusion component of Unreal Engine 5. It is utilized by the renderer module, specifically in the post-processing pipeline for ambient occlusion calculations.
Based on the callsites, this variable is used in two main areas:
- The main renderer’s ambient occlusion processing (PostProcessAmbientOcclusion.cpp)
- The mobile renderer’s ambient occlusion processing (PostProcessAmbientOcclusionMobile.cpp)
The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 0.5f and can be changed at runtime.
This variable interacts closely with other GTAO-related variables, particularly r.GTAO.FalloffEnd. The FalloffStartRatio is used to calculate the actual start point of the falloff effect by multiplying it with the FalloffEnd value.
Developers should be aware that:
- The value must be between 0 and 1.
- It directly affects the visual quality and performance of the ambient occlusion effect.
- Changes to this value may require adjustments to other GTAO settings for optimal results.
Best practices when using this variable include:
- Experimenting with different values to find the right balance between visual quality and performance for your specific scene.
- Considering the interaction with other GTAO settings, especially r.GTAO.FalloffEnd.
- Testing on various hardware configurations, as the impact may vary depending on the graphics capabilities.
Regarding the associated variable CVarGTAOFalloffStartRatio:
This is the actual console variable that stores and manages the r.GTAO.FalloffStartRatio value. It’s defined using the TAutoConsoleVariable template, which allows for easy integration with Unreal Engine’s console variable system.
The CVarGTAOFalloffStartRatio is used to retrieve the current value of the falloff start ratio in the rendering code. It’s important to note that the value is retrieved using the GetValueOnRenderThread() method, ensuring thread-safe access in the render thread.
When working with this variable, developers should:
- Use the appropriate methods (like GetValueOnRenderThread()) when accessing the value to ensure thread safety.
- Be aware that changes to this variable will affect the rendering in real-time, which can be useful for tweaking and debugging but should be used cautiously in production environments.
- Consider exposing this setting in the user interface if it’s something that needs to be adjustable in the final product.
#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:127
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarGTAOFalloffStartRatio(
TEXT("r.GTAO.FalloffStartRatio"),
0.5f,
TEXT("Ratio of the r.GTAO.FalloffEnd value at which it starts to fall off. \n ")
TEXT("Must be Between 0 and 1. \n "),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarGTAONumAngles(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessAmbientOcclusionMobile.cpp:462
Scope (from outer to inner):
file
function static void RenderGTAO
Source code excerpt:
{
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);
const int32 MobileAmbientOcclusionQuality = FMath::Min(CVarMobileAmbientOcclusionQuality.GetValueOnRenderThread(), 3);
#Associated Variable and Callsites
This variable is associated with another variable named CVarGTAOFalloffStartRatio
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:126
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarGTAOFalloffStartRatio(
TEXT("r.GTAO.FalloffStartRatio"),
0.5f,
TEXT("Ratio of the r.GTAO.FalloffEnd value at which it starts to fall off. \n ")
TEXT("Must be Between 0 and 1. \n "),
ECVF_RenderThreadSafe | ECVF_Scalability);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:446
Scope: file
Source code excerpt:
// Fall Off Params
float FallOffEnd = CVarGTAOFalloffEnd.GetValueOnRenderThread();
float FallOffStartRatio = FMath::Clamp(CVarGTAOFalloffStartRatio.GetValueOnRenderThread(), 0.0f, 0.999f);
float FallOffStart = FallOffEnd * FallOffStartRatio;
float FallOffStartSq = FallOffStart * FallOffStart;
float FallOffEndSq = FallOffEnd * FallOffEnd;
float FallOffScale = 1.0f / (FallOffEndSq - FallOffStartSq);
float FallOffBias = -FallOffStartSq * FallOffScale;