r.GTAO.NumAngles
r.GTAO.NumAngles
#Overview
name: r.GTAO.NumAngles
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
How Many Angles we choose per pixel \n Must be Between 1 and 16. \n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.GTAO.NumAngles is to control the number of angles used per pixel in the Ground Truth Ambient Occlusion (GTAO) calculation within Unreal Engine’s rendering system. This setting is part of the ambient occlusion implementation, which is a technique used to add depth and realism to rendered scenes by simulating how light is occluded by nearby objects.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the ambient occlusion post-processing components. Based on the callsites, it’s clear that this variable is utilized in both the main rendering pipeline (PostProcessAmbientOcclusion.cpp) and the mobile rendering pipeline (PostProcessAmbientOcclusionMobile.cpp).
The value of this variable is set through a console variable (CVar) system, allowing it to be adjusted at runtime. It’s defined with a default value of 2 and can be set between 1 and 16.
The associated variable CVarGTAONumAngles interacts directly with r.GTAO.NumAngles, as they share the same value. This CVar is used to retrieve the current value of the setting in the rendering code.
Developers should be aware that:
- Increasing the number of angles will improve the quality of ambient occlusion at the cost of performance.
- The value is clamped between 1 and 16 in the code, so setting values outside this range will be automatically adjusted.
- This setting affects both the main and mobile rendering pipelines.
Best practices when using this variable include:
- Carefully balancing quality and performance based on the target hardware.
- Using it in conjunction with other GTAO settings for optimal results.
- Testing different values to find the sweet spot for your specific scene and performance requirements.
- Consider exposing this setting to end-users for performance scaling on different hardware configurations.
Regarding the associated variable CVarGTAONumAngles:
- Its purpose is to provide a programmatic interface to access and modify the r.GTAO.NumAngles setting.
- It’s defined as a TAutoConsoleVariable, which allows it to be changed at runtime through console commands.
- The value is retrieved in the rendering code using GetValueOnRenderThread(), ensuring thread-safe access.
- It’s used to calculate parameters for the GTAO shader, specifically influencing the angle calculations (SinDeltaAngle and CosDeltaAngle).
- Developers should be aware that changes to this variable will take effect immediately on the render thread, potentially causing visual changes in real-time.
#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:134
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarGTAONumAngles(
TEXT("r.GTAO.NumAngles"),
2,
TEXT("How Many Angles we choose per pixel \n ")
TEXT("Must be Between 1 and 16. \n "),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarGTAOPauseJitter(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessAmbientOcclusionMobile.cpp:464
Scope (from outer to inner):
file
function static void RenderGTAO
Source code excerpt:
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);
FRDGTextureUAVRef AmbientOcclusionTextureUAV = GraphBuilder.CreateUAV(AmbientOcclusionTexture);
#Associated Variable and Callsites
This variable is associated with another variable named CVarGTAONumAngles
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:133
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarGTAONumAngles(
TEXT("r.GTAO.NumAngles"),
2,
TEXT("How Many Angles we choose per pixel \n ")
TEXT("Must be Between 1 and 16. \n "),
ECVF_RenderThreadSafe | ECVF_Scalability);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CompositionLighting/PostProcessAmbientOcclusion.cpp:458
Scope: file
Source code excerpt:
float TemporalBlendWeight = FMath::Clamp(Settings.AmbientOcclusionTemporalBlendWeight, 0.01f, 1.0f);
float NumAngles = FMath::Clamp(CVarGTAONumAngles.GetValueOnRenderThread(), 1.0f, 16.0f);
float SinDeltaAngle, CosDeltaAngle;
FMath::SinCos(&SinDeltaAngle, &CosDeltaAngle, PI / NumAngles);
Result.GTAOParams[4] = FVector4f(Settings.AmbientOcclusionTemporalBlendWeight, NumAngles, SinDeltaAngle, CosDeltaAngle);
return Result;