r.DistanceFields.MaxObjectBoundingRadius
r.DistanceFields.MaxObjectBoundingRadius
#Overview
name: r.DistanceFields.MaxObjectBoundingRadius
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Objects larger than this will not be included in the Mesh Distance Field scene, to improve performance.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DistanceFields.MaxObjectBoundingRadius is to set a maximum size limit for objects to be included in the Mesh Distance Field scene. This setting is used in the rendering system, specifically for distance field calculations.
This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the distance field object management system. It’s referenced in the DistanceFieldObjectManagement.cpp file, which is part of the rendering subsystem.
The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 100000 units and can be changed at runtime using console commands.
The associated variable GMeshDistanceFieldsMaxObjectBoundingRadius directly interacts with r.DistanceFields.MaxObjectBoundingRadius. They share the same value, with GMeshDistanceFieldsMaxObjectBoundingRadius being the actual float variable used in the C++ code.
Developers must be aware that this variable affects performance and memory usage. Objects larger than the specified radius will be excluded from the Mesh Distance Field scene. This can improve performance by reducing the number of objects processed for distance field calculations, but it may also affect the visual quality or functionality of distance field-based features for very large objects.
Best practices when using this variable include:
- Setting it to a value that balances performance and visual quality for your specific game or application.
- Monitoring performance impact when adjusting this value.
- Considering the scale of objects in your scene when setting this value.
- Testing thoroughly after making changes to ensure distance field-based features still work as expected for all relevant objects.
Regarding the associated variable GMeshDistanceFieldsMaxObjectBoundingRadius:
The purpose of GMeshDistanceFieldsMaxObjectBoundingRadius is to store the actual float value used in the C++ code for the maximum object bounding radius in distance field calculations.
This variable is used directly in the Renderer module, specifically in the DistanceFieldObjectManagement.cpp file. It’s used to determine whether an object should be included in the Mesh Distance Field scene based on its size.
The value of GMeshDistanceFieldsMaxObjectBoundingRadius is set through the console variable system, linked to r.DistanceFields.MaxObjectBoundingRadius.
It interacts directly with r.DistanceFields.MaxObjectBoundingRadius, sharing the same value. It’s also used in comparisons with object bounding radii to determine inclusion in the distance field scene.
Developers should be aware that this variable is used directly in the C++ code for size comparisons. Any changes to r.DistanceFields.MaxObjectBoundingRadius will affect this variable and, consequently, the distance field calculations.
Best practices for GMeshDistanceFieldsMaxObjectBoundingRadius are essentially the same as for r.DistanceFields.MaxObjectBoundingRadius, as they are directly linked. Developers should treat them as a single entity when considering adjustments or optimizations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldObjectManagement.cpp:29
Scope: file
Source code excerpt:
float GMeshDistanceFieldsMaxObjectBoundingRadius = 100000;
FAutoConsoleVariableRef CVarMeshDistanceFieldsMaxObjectBoundingRadius(
TEXT("r.DistanceFields.MaxObjectBoundingRadius"),
GMeshDistanceFieldsMaxObjectBoundingRadius,
TEXT("Objects larger than this will not be included in the Mesh Distance Field scene, to improve performance."),
ECVF_RenderThreadSafe
);
int32 GDFParallelUpdate = 0;
#Associated Variable and Callsites
This variable is associated with another variable named GMeshDistanceFieldsMaxObjectBoundingRadius
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldObjectManagement.cpp:27
Scope: file
Source code excerpt:
extern int32 GDistanceFieldOffsetDataStructure;
float GMeshDistanceFieldsMaxObjectBoundingRadius = 100000;
FAutoConsoleVariableRef CVarMeshDistanceFieldsMaxObjectBoundingRadius(
TEXT("r.DistanceFields.MaxObjectBoundingRadius"),
GMeshDistanceFieldsMaxObjectBoundingRadius,
TEXT("Objects larger than this will not be included in the Mesh Distance Field scene, to improve performance."),
ECVF_RenderThreadSafe
);
int32 GDFParallelUpdate = 0;
FAutoConsoleVariableRef CVarDFParallelUpdate(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldObjectManagement.cpp:351
Scope (from outer to inner):
file
function void ProcessPrimitiveUpdate
Source code excerpt:
// Proxy bounds are only useful if single instance
if (InstanceLocalToWorldTransforms.Num() > 1 || BoundingRadius < GMeshDistanceFieldsMaxObjectBoundingRadius)
{
if (bIsAddOperation)
{
PrimitiveSceneInfo->DistanceFieldInstanceIndices.Empty(InstanceLocalToWorldTransforms.Num());
PrimitiveSceneInfo->DistanceFieldInstanceIndices.AddZeroed(InstanceLocalToWorldTransforms.Num());