r.AOGlobalDistanceField.MinMeshSDFRadiusInVoxels
r.AOGlobalDistanceField.MinMeshSDFRadiusInVoxels
#Overview
name: r.AOGlobalDistanceField.MinMeshSDFRadiusInVoxels
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Meshes with a smaller radius than this number of voxels 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.MinMeshSDFRadiusInVoxels is to set a threshold for culling meshes from the global Signed Distance Field (SDF) used in Ambient Occlusion (AO) calculations. It defines the minimum radius, in voxels, that a mesh must have to be included in the global SDF.
This setting variable is primarily used in the rendering system, specifically in the global distance field calculations for ambient occlusion. It is part of Unreal Engine’s advanced rendering features.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, as evidenced by its location in the GlobalDistanceField.cpp file within the Renderer’s private directory.
The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands. It’s initialized with a default value of 0.5 voxels.
This variable interacts with GAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels, which is the associated C++ variable that stores the actual value. They share the same value, with the console variable providing an interface for adjusting it.
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 and detail level of your scene.
- Balancing it with other AO and global distance field settings for optimal performance and visual quality.
- Testing different values to find the best trade-off between performance and visual fidelity for your specific use case.
Regarding the associated variable GAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels:
This is the actual float variable that stores the minimum mesh SDF radius in voxels. It’s used directly in the GetMinMeshSDFRadius function to calculate the minimum radius for meshes to be included in the global SDF.
The purpose of this variable is to provide a runtime-accessible storage for the minimum mesh SDF radius value, which can be modified through the console variable.
It’s used in the Renderer module, specifically in global distance field calculations.
The value is set initially to 0.5f and can be modified through the console variable r.AOGlobalDistanceField.MinMeshSDFRadiusInVoxels.
It interacts with other variables like GAOGlobalDistanceFieldFastCameraMode in the GetMinMeshSDFRadius function to determine the final minimum radius.
Developers should be aware that this variable directly affects the culling of meshes from the global SDF, impacting both performance and visual quality of ambient occlusion.
Best practices include monitoring this variable’s value when debugging AO issues and considering its impact when optimizing rendering performance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GlobalDistanceField.cpp:160
Scope: file
Source code excerpt:
float GAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels = .5f;
FAutoConsoleVariableRef CVarAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels(
TEXT("r.AOGlobalDistanceField.MinMeshSDFRadiusInVoxels"),
GAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels,
TEXT("Meshes with a smaller radius than this number of voxels are culled from the global SDF."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
float GAOGlobalDistanceFieldCameraPositionVelocityOffsetDecay = .7f;
#Associated Variable and Callsites
This variable is associated with another variable named GAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GlobalDistanceField.cpp:158
Scope: file
Source code excerpt:
);
float GAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels = .5f;
FAutoConsoleVariableRef CVarAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels(
TEXT("r.AOGlobalDistanceField.MinMeshSDFRadiusInVoxels"),
GAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels,
TEXT("Meshes with a smaller radius than this number of voxels are culled from the global SDF."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
float GAOGlobalDistanceFieldCameraPositionVelocityOffsetDecay = .7f;
FAutoConsoleVariableRef CVarAOGlobalDistanceFieldCameraPositionVelocityOffsetDecay(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GlobalDistanceField.cpp:365
Scope (from outer to inner):
file
function float GetMinMeshSDFRadius
Source code excerpt:
{
float MinRadius = GAOGlobalDistanceFieldMinMeshSDFRadius * (GAOGlobalDistanceFieldFastCameraMode ? 10.0f : 1.0f);
float MinVoxelRadius = GAOGlobalDistanceFieldMinMeshSDFRadiusInVoxels * VoxelWorldSize * (GAOGlobalDistanceFieldFastCameraMode ? 5.0f : 1.0f);
return FMath::Max(MinRadius, MinVoxelRadius);
}
int32 GetNumClipmapUpdatesPerFrame()
{