r.AOGlobalDistanceField.MinMeshSDFRadius
r.AOGlobalDistanceField.MinMeshSDFRadius
#Overview
name: r.AOGlobalDistanceField.MinMeshSDFRadius
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Meshes with a smaller world space radius than this are culled from the global SDF.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.AOGlobalDistanceField.MinMeshSDFRadius is to define the minimum world space radius for meshes to be included in the global Signed Distance Field (SDF) used for Ambient Occlusion (AO) calculations. This setting is part of the rendering system, specifically the global distance field feature used for ambient occlusion and other effects.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the global distance field calculations. It’s part of the advanced rendering features that contribute to realistic lighting and shadows in the game environment.
The value of this variable is set through the Unreal Engine console variable system. It’s initialized with a default value of 20 units and can be modified at runtime using console commands or through project settings.
This variable interacts closely with another variable named GAOGlobalDistanceFieldMinMeshSDFRadius. They share the same value, with r.AOGlobalDistanceField.MinMeshSDFRadius being the console-accessible name and GAOGlobalDistanceFieldMinMeshSDFRadius being the C++ variable used in the code.
Developers must be aware that this variable affects performance and visual quality. Setting it too low might include very small meshes in the global SDF, potentially impacting performance, while setting it too high might exclude important geometric details from the AO calculations.
Best practices when using this variable include:
- Adjusting it based on the scale of your game world and the size of important objects.
- Balancing between performance and visual quality.
- Testing different values to find the optimal setting for your specific project.
Regarding the associated variable GAOGlobalDistanceFieldMinMeshSDFRadius:
The purpose of GAOGlobalDistanceFieldMinMeshSDFRadius is to store the actual value used in the C++ code for the minimum mesh SDF radius. It’s directly linked to the console variable r.AOGlobalDistanceField.MinMeshSDFRadius.
This variable is used in the Renderer module, specifically in the global distance field calculations for ambient occlusion.
The value of this variable is set by the console variable system when r.AOGlobalDistanceField.MinMeshSDFRadius is modified.
It interacts with GAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels in the GetMinMeshSDFRadius function to determine the final minimum radius used for culling meshes from the global SDF.
Developers should be aware that modifying r.AOGlobalDistanceField.MinMeshSDFRadius will directly affect this variable.
Best practices include:
- Using the console variable r.AOGlobalDistanceField.MinMeshSDFRadius to modify this value rather than changing it directly in code.
- Considering the impact on both world space units and voxel space when adjusting this value.
- Monitoring performance and visual quality when making changes to this setting.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GlobalDistanceField.cpp:152
Scope: file
Source code excerpt:
float GAOGlobalDistanceFieldMinMeshSDFRadius = 20;
FAutoConsoleVariableRef CVarAOGlobalDistanceFieldMinMeshSDFRadius(
TEXT("r.AOGlobalDistanceField.MinMeshSDFRadius"),
GAOGlobalDistanceFieldMinMeshSDFRadius,
TEXT("Meshes with a smaller world space radius than this are culled from the global SDF."),
ECVF_RenderThreadSafe
);
float GAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels = .5f;
#Associated Variable and Callsites
This variable is associated with another variable named GAOGlobalDistanceFieldMinMeshSDFRadius
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GlobalDistanceField.cpp:150
Scope: file
Source code excerpt:
);
float GAOGlobalDistanceFieldMinMeshSDFRadius = 20;
FAutoConsoleVariableRef CVarAOGlobalDistanceFieldMinMeshSDFRadius(
TEXT("r.AOGlobalDistanceField.MinMeshSDFRadius"),
GAOGlobalDistanceFieldMinMeshSDFRadius,
TEXT("Meshes with a smaller world space radius than this are culled from the global SDF."),
ECVF_RenderThreadSafe
);
float GAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels = .5f;
FAutoConsoleVariableRef CVarAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GlobalDistanceField.cpp:364
Scope (from outer to inner):
file
function float GetMinMeshSDFRadius
Source code excerpt:
float GetMinMeshSDFRadius(float VoxelWorldSize)
{
float MinRadius = GAOGlobalDistanceFieldMinMeshSDFRadius * (GAOGlobalDistanceFieldFastCameraMode ? 10.0f : 1.0f);
float MinVoxelRadius = GAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels * VoxelWorldSize * (GAOGlobalDistanceFieldFastCameraMode ? 5.0f : 1.0f);
return FMath::Max(MinRadius, MinVoxelRadius);
}
int32 GetNumClipmapUpdatesPerFrame()