b.DistanceForFixedLOD2
b.DistanceForFixedLOD2
#Overview
name: b.DistanceForFixedLOD2
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of b.DistanceForFixedLOD2 is to control the Level of Detail (LOD) management for customizable objects in Unreal Engine 5, specifically within the Mutable plugin. It sets a distance threshold at which the system will fix the LOD of an instance to the lowest resolution (LOD2) to prevent unnecessary LOD changes and reduce memory consumption.
This setting variable is primarily used by the Mutable plugin, which is an experimental feature in Unreal Engine 5 for creating customizable objects. The subsystem that relies on this variable is the CustomizableInstanceLODManagement system within the Mutable plugin.
The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 50000 units, but can be changed at runtime or through configuration files.
The associated variable CVarDistanceForFixedLOD2 interacts directly with b.DistanceForFixedLOD2. It’s a TAutoConsoleVariable that holds the actual value and provides methods to access it, such as GetValueOnGameThread().
Developers must be aware that this variable only takes effect when NumGeneratedInstancesLimit is set to a non-zero value. It’s used in conjunction with other LOD management settings to optimize performance and memory usage for customizable objects.
Best practices when using this variable include:
- Carefully tuning the value based on the scale and requirements of your game world.
- Testing thoroughly to ensure that the LOD transitions are not noticeable to players.
- Considering the trade-off between performance/memory usage and visual quality when adjusting this value.
- Using it in conjunction with other LOD management settings for optimal results.
Regarding the associated variable CVarDistanceForFixedLOD2:
The purpose of CVarDistanceForFixedLOD2 is to provide a programmatic interface for the b.DistanceForFixedLOD2 console variable. It allows the engine to access and modify the value of b.DistanceForFixedLOD2 at runtime.
This variable is used directly in the CustomizableInstanceLODManagement system of the Mutable plugin. It’s accessed using the GetValueOnGameThread() method to retrieve the current distance threshold for fixed LOD2.
The value of CVarDistanceForFixedLOD2 is set when the console variable b.DistanceForFixedLOD2 is modified, either through console commands or configuration files.
CVarDistanceForFixedLOD2 interacts closely with b.DistanceForFixedLOD2, essentially serving as its in-code representation.
Developers should be aware that changes to CVarDistanceForFixedLOD2 will directly affect the behavior of the LOD management system for customizable objects.
Best practices for using CVarDistanceForFixedLOD2 include:
- Accessing its value using GetValueOnGameThread() when needed in performance-critical code.
- Avoiding frequent changes to this value during gameplay, as it could lead to sudden LOD changes.
- Considering caching the value if it’s accessed frequently in a single frame or update cycle.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Plugins/Experimental/Mutable/Config/DefaultMutable.ini:45, section: [ViewDistanceQuality@0]
- INI Section:
ViewDistanceQuality@0
- Raw value:
0
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Experimental/Mutable/Source/CustomizableObject/Private/MuCO/CustomizableInstanceLODManagement.cpp:46
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDistanceForFixedLOD2(
TEXT("b.DistanceForFixedLOD2"),
50000,
TEXT("If NumGeneratedInstancesLimit is different than 0, sets the distance at which the system will fix the LOD of an instance to the lowest res one (LOD2) to prevent unnecessary LOD changes and memory consumption"),
ECVF_Scalability);
static TAutoConsoleVariable<bool> CVarOnlyUpdateCloseCustomizableObjects(
TEXT("b.OnlyUpdateCloseCustomizableObjects"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarDistanceForFixedLOD2
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/Mutable/Source/CustomizableObject/Private/MuCO/CustomizableInstanceLODManagement.cpp:45
Scope: file
Source code excerpt:
ECVF_Scalability);
static TAutoConsoleVariable<int32> CVarDistanceForFixedLOD2(
TEXT("b.DistanceForFixedLOD2"),
50000,
TEXT("If NumGeneratedInstancesLimit is different than 0, sets the distance at which the system will fix the LOD of an instance to the lowest res one (LOD2) to prevent unnecessary LOD changes and memory consumption"),
ECVF_Scalability);
static TAutoConsoleVariable<bool> CVarOnlyUpdateCloseCustomizableObjects(
#Loc: <Workspace>/Engine/Plugins/Experimental/Mutable/Source/CustomizableObject/Private/MuCO/CustomizableInstanceLODManagement.cpp:232
Scope (from outer to inner):
file
function void UCustomizableInstanceLODManagement::UpdateInstanceDistsAndLODs
Source code excerpt:
bool bAlreadyReachedFixedLOD = false;
const float DistanceForFixedLOD = float(CVarDistanceForFixedLOD2.GetValueOnGameThread());
const float DistanceForFixedLODSquared = FMath::Square(DistanceForFixedLOD);
for (int32 i = 0; i < NumGeneratedInstancesLimitLODs && i < SortedInstances.Num(); ++i)
{
if (!bAlreadyReachedFixedLOD && SortedInstances[i]->GetMinSquareDistToPlayer() < DistanceForFixedLODSquared)