r.HLOD.DistanceOverride
r.HLOD.DistanceOverride
#Overview
name: r.HLOD.DistanceOverride
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If non-zero, overrides the distance that HLOD transitions will take place for all objects at the HLOD level index, formatting is as follows:\n\'r.HLOD.DistanceOverride 5000, 10000, 20000\' would result in HLOD levels 0, 1 and 2 transitioning at 5000, 1000 and 20000 respectively.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.HLOD.DistanceOverride is to control the transition distances for Hierarchical Level of Detail (HLOD) levels in Unreal Engine 5. It allows developers to override the default distances at which HLOD transitions occur for different LOD levels.
This setting variable is primarily used by the HLOD system, which is part of the Engine module in Unreal Engine 5. It specifically interacts with the LODActor class, which is responsible for managing HLOD instances.
The value of this variable is set through the console variable system, as evidenced by the TAutoConsoleVariable declaration. It can be set in-game or through configuration files using the syntax “r.HLOD.DistanceOverride 5000, 10000, 20000”, where each number represents the transition distance for a corresponding HLOD level.
The associated variable CVarHLODDistanceOverride interacts directly with r.HLOD.DistanceOverride, as they are essentially the same console variable. This variable is used to store and retrieve the override values throughout the engine code.
Developers must be aware that:
- The values are comma-separated and correspond to HLOD levels 0, 1, 2, and so on.
- Setting this variable will override the default HLOD transition distances for all objects at the specified HLOD level indexes.
- The values are in Unreal Units (typically centimeters).
Best practices when using this variable include:
- Use it sparingly and only when the default HLOD transition distances are not suitable for your specific use case.
- Ensure that the values make sense in the context of your game’s scale and camera settings.
- Test thoroughly to ensure that the new transition distances do not negatively impact performance or visual quality.
- Consider using it in conjunction with r.HLOD.DistanceOverrideScale for more fine-grained control.
Regarding the associated variable CVarHLODDistanceOverride: The purpose of CVarHLODDistanceOverride is to provide a programmatic interface to the r.HLOD.DistanceOverride console variable within the engine’s C++ code. It allows engine systems to read and potentially modify the HLOD distance override values at runtime.
This variable is used in the Engine module, specifically within the LODActor class implementation. It’s primarily used to parse the override values and apply them to the HLOD system.
The value of CVarHLODDistanceOverride is set automatically by the engine when the r.HLOD.DistanceOverride console variable is modified. It directly reflects the value of r.HLOD.DistanceOverride.
CVarHLODDistanceOverride interacts closely with the ALODActor::ParseOverrideDistancesCVar() function, which parses the string value into usable float values for the HLOD system.
Developers should be aware that:
- This variable provides a string representation of the override values.
- Any changes to r.HLOD.DistanceOverride will be reflected in this variable.
Best practices for using CVarHLODDistanceOverride include:
- Use it for reading the current override values in C++ code rather than directly accessing the console variable.
- Be cautious when parsing its value, as it may contain invalid data if the user has input incorrect values.
- Consider caching the parsed values to avoid frequent string parsing operations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LODActor.cpp:53
Scope: file
Source code excerpt:
ENGINE_API TAutoConsoleVariable<FString> CVarHLODDistanceOverride(
TEXT("r.HLOD.DistanceOverride"),
"0.0",
TEXT("If non-zero, overrides the distance that HLOD transitions will take place for all objects at the HLOD level index, formatting is as follows:\n")
TEXT("'r.HLOD.DistanceOverride 5000, 10000, 20000' would result in HLOD levels 0, 1 and 2 transitioning at 5000, 1000 and 20000 respectively."),
ECVF_Scalability);
static TAutoConsoleVariable<FString> CVarHLODDistanceOverrideScale(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/LODActor.h:325
Scope (from outer to inner):
file
class class ALODActor : public AActor
Source code excerpt:
static ENGINE_API TArray<float> HLODDistances;
// Updates the transition distance according to values (if) set in r.HLOD.DistanceOverride
ENGINE_API void UpdateOverrideTransitionDistance();
// Called to make sure autoregistration/manual registration state matches based on the LOD override cvar and this actor's lod level
ENGINE_API void UpdateRegistrationToMatchMaximumLODLevel();
// Setup a LOD static mesh component.
#Associated Variable and Callsites
This variable is associated with another variable named CVarHLODDistanceOverride
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/LODActor.h:15
Scope: file
Source code excerpt:
class UHLODProxyDesc;
extern ENGINE_API TAutoConsoleVariable<FString> CVarHLODDistanceOverride;
/**
* Mesh/Material pair used as a key to insert/retrieve instances in the LODActor.
*/
USTRUCT()
struct FHLODInstancingKey
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LODActor.cpp:52
Scope: file
Source code excerpt:
ECVF_Scalability | ECVF_RenderThreadSafe);
ENGINE_API TAutoConsoleVariable<FString> CVarHLODDistanceOverride(
TEXT("r.HLOD.DistanceOverride"),
"0.0",
TEXT("If non-zero, overrides the distance that HLOD transitions will take place for all objects at the HLOD level index, formatting is as follows:\n")
TEXT("'r.HLOD.DistanceOverride 5000, 10000, 20000' would result in HLOD levels 0, 1 and 2 transitioning at 5000, 1000 and 20000 respectively."),
ECVF_Scalability);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LODActor.cpp:381
Scope (from outer to inner):
file
function void ALODActor::ParseOverrideDistancesCVar
Source code excerpt:
{
// Parse HLOD override distance cvar into array
const FString DistanceOverrideValues = CVarHLODDistanceOverride.GetValueOnAnyThread();
const FString DistanceOverrideScaleValues = CVarHLODDistanceOverrideScale.GetValueOnAnyThread();
const TCHAR* Delimiters[] = { TEXT(","), TEXT(" ") };
TArray<FString> Distances;
DistanceOverrideValues.ParseIntoArray(/*out*/ Distances, Delimiters, UE_ARRAY_COUNT(Delimiters), true);