r.AOSampleSet
r.AOSampleSet
#Overview
name: r.AOSampleSet
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0 = Original set, 1 = Relaxed set
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.AOSampleSet is to control the sample set used for Ambient Occlusion (AO) calculations in Unreal Engine’s rendering system. It allows developers to choose between two different sets of sample vectors for AO computations.
This setting variable is primarily used in the rendering subsystem of Unreal Engine, specifically in the Distance Field Ambient Occlusion module. It’s referenced in the DistanceFieldAmbientOcclusion.cpp file, which is part of the Renderer module.
The value of this variable is set through the Unreal Engine console variable system. It’s initialized with a default value of 1, but can be changed at runtime using console commands or through project settings.
The r.AOSampleSet variable interacts directly with the GAOSampleSet variable. They share the same value, with GAOSampleSet being the actual integer used in the code logic, while r.AOSampleSet is the console-accessible name.
Developers should be aware that this variable affects the quality and performance of ambient occlusion calculations. The two options (0 and 1) represent different trade-offs between quality and performance:
- 0 represents the “Original set” of sample vectors
- 1 represents the “Relaxed set” of sample vectors
Best practices when using this variable include:
- Testing both settings to find the best balance between visual quality and performance for your specific project.
- Considering the target hardware when choosing a setting, as the more complex “Original set” might be more suitable for high-end systems.
- Documenting the chosen setting and its impact on the project’s visuals and performance.
Regarding the associated variable GAOSampleSet:
The purpose of GAOSampleSet is to serve as the actual integer value used in the code logic for selecting the AO sample set. It’s the internal representation of the r.AOSampleSet console variable.
GAOSampleSet is used directly in the GetSpacedVectors function to determine which set of sample vectors to use for AO calculations. When GAOSampleSet is 0, it uses the original set of vectors (SpacedVectors9), and when it’s not 0 (presumably 1), it uses a different set (not shown in the provided code snippets).
The value of GAOSampleSet is set by the console variable system when r.AOSampleSet is modified.
Developers should be aware that changes to r.AOSampleSet will directly affect GAOSampleSet, and vice versa. Any logic depending on GAOSampleSet will be affected by changes to the console variable.
Best practices for GAOSampleSet include:
- Avoiding direct modification of GAOSampleSet in code, instead using the r.AOSampleSet console variable for changes.
- When reading the value, always use GAOSampleSet rather than trying to access the console variable directly for better performance.
- Consider caching the value of GAOSampleSet if it’s used frequently in performance-critical sections of code, as reading console variables can have a small performance cost.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldAmbientOcclusion.cpp:91
Scope: file
Source code excerpt:
int32 GAOSampleSet = 1;
FAutoConsoleVariableRef CVarAOSampleSet(
TEXT("r.AOSampleSet"),
GAOSampleSet,
TEXT("0 = Original set, 1 = Relaxed set"),
ECVF_RenderThreadSafe
);
int32 GAOOverwriteSceneColor = 0;
#Associated Variable and Callsites
This variable is associated with another variable named GAOSampleSet
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldAmbientOcclusion.cpp:89
Scope: file
Source code excerpt:
);
int32 GAOSampleSet = 1;
FAutoConsoleVariableRef CVarAOSampleSet(
TEXT("r.AOSampleSet"),
GAOSampleSet,
TEXT("0 = Original set, 1 = Relaxed set"),
ECVF_RenderThreadSafe
);
int32 GAOOverwriteSceneColor = 0;
FAutoConsoleVariableRef CVarAOOverwriteSceneColor(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldAmbientOcclusion.cpp:222
Scope (from outer to inner):
file
function void GetSpacedVectors
Source code excerpt:
OutVectors.Empty(UE_ARRAY_COUNT(SpacedVectors9));
if (GAOSampleSet == 0)
{
for (int32 i = 0; i < UE_ARRAY_COUNT(SpacedVectors9); i++)
{
OutVectors.Add(SpacedVectors9[i]);
}
}