foliage.MinLOD
foliage.MinLOD
#Overview
name: foliage.MinLOD
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Used to discard the top LODs for performance evaluation. -1: Disable all effects of this cvar.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of foliage.MinLOD is to control the minimum Level of Detail (LOD) for foliage rendering in Unreal Engine 5. It is primarily used for performance evaluation and optimization of foliage rendering.
This setting variable is primarily used in the rendering system, specifically for instanced static meshes and hierarchical instanced static meshes, which are commonly used for foliage in Unreal Engine.
The Unreal Engine subsystems that rely on this setting variable are:
- The rendering system, particularly the instanced static mesh rendering
- The foliage system
The value of this variable is set through a console variable (CVar) named CVarMinLOD. It is initialized with a default value of -1, which disables its effects. The value can be changed at runtime through console commands or programmatically.
This variable interacts with other LOD-related variables and systems:
- It is used in conjunction with the mesh’s LOD resources.
- It interacts with the MinLOD property of instancing user data.
- It is used alongside other LOD-related variables like CVarFoliageMinimumScreenSize and CVarRandomLODRange.
Developers must be aware of the following when using this variable:
- Setting a value of -1 disables the effects of this variable.
- The actual value used is clamped to the range of available LODs for the mesh.
- This variable is marked with ECVF_Scalability, indicating it’s intended for performance scaling.
Best practices when using this variable include:
- Use it primarily for performance evaluation and optimization, not for regular gameplay settings.
- Be cautious when setting high values, as it may significantly reduce visual quality.
- Consider the impact on different hardware configurations when adjusting this value.
Regarding the associated variable CVarMinLOD:
The purpose of CVarMinLOD is to provide a programmatic interface to control the foliage.MinLOD setting. It is an instance of TAutoConsoleVariable
CVarMinLOD is used in the same subsystems as foliage.MinLOD, primarily in the rendering and foliage systems.
The value of CVarMinLOD is set when the console variable is created, but can be modified at runtime using console commands or through C++ code using the SetValueOnGameThread or SetValueOnRenderThread methods.
CVarMinLOD directly interacts with the foliage.MinLOD setting, effectively controlling its value.
Developers should be aware that changes to CVarMinLOD will immediately affect the foliage rendering, potentially impacting performance and visual quality.
Best practices for using CVarMinLOD include:
- Use GetValueOnRenderThread() when accessing the value in render thread code.
- Consider performance implications when modifying the value at runtime.
- Use this variable for debugging and performance testing rather than as a primary game setting.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:95
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarMinLOD(
TEXT("foliage.MinLOD"),
-1,
TEXT("Used to discard the top LODs for performance evaluation. -1: Disable all effects of this cvar."),
ECVF_Scalability | ECVF_Default);
static TAutoConsoleVariable<int32> CVarCullAllInVertexShader(
TEXT("foliage.CullAllInVertexShader"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarMinLOD
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/InstancedStaticMesh.h:37
Scope: file
Source code excerpt:
extern TAutoConsoleVariable<float> CVarFoliageMinimumScreenSize;
extern TAutoConsoleVariable<float> CVarRandomLODRange;
extern TAutoConsoleVariable<int32> CVarMinLOD;
BEGIN_GLOBAL_SHADER_PARAMETER_STRUCT(FInstancedStaticMeshVertexFactoryUniformShaderParameters, ENGINE_API)
SHADER_PARAMETER_SRV(Buffer<float4>, VertexFetch_InstanceOriginBuffer)
SHADER_PARAMETER_SRV(Buffer<float4>, VertexFetch_InstanceTransformBuffer)
SHADER_PARAMETER_SRV(Buffer<float4>, VertexFetch_InstanceLightmapBuffer)
SHADER_PARAMETER_SRV(Buffer<float>, InstanceCustomDataBuffer)
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/HierarchicalInstancedStaticMesh.cpp:1741
Scope (from outer to inner):
file
function void FHierarchicalStaticMeshSceneProxy::GetDynamicMeshElements
Source code excerpt:
int32 UseMinLOD = ClampedMinLOD;
int32 DebugMin = FMath::Min(CVarMinLOD.GetValueOnRenderThread(), InstanceParams.LODs - 1);
if (DebugMin >= 0)
{
UseMinLOD = FMath::Max(UseMinLOD, DebugMin);
}
int32 UseMaxLOD = InstanceParams.LODs;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:94
Scope: file
Source code excerpt:
TEXT("Whether to allow creation of empty ISMS."));
TAutoConsoleVariable<int32> CVarMinLOD(
TEXT("foliage.MinLOD"),
-1,
TEXT("Used to discard the top LODs for performance evaluation. -1: Disable all effects of this cvar."),
ECVF_Scalability | ECVF_Default);
static TAutoConsoleVariable<int32> CVarCullAllInVertexShader(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:1152
Scope (from outer to inner):
file
function FInstancedStaticMeshVFLooseUniformShaderParametersRef FInstancedStaticMeshSceneProxy::CreateLooseUniformBuffer
Source code excerpt:
int32 FirstLOD = InstancingUserData->MinLOD;
int32 DebugMin = FMath::Min(CVarMinLOD.GetValueOnRenderThread(), InstancingUserData->MeshRenderData->LODResources.Num() - 1);
if (DebugMin >= 0)
{
FirstLOD = FMath::Max(FirstLOD, DebugMin);
}
FBoxSphereBounds ScaledBounds = InstancingUserData->MeshRenderData->Bounds.TransformBy(FTransform(FRotator::ZeroRotator, FVector::ZeroVector, InstancingUserData->AverageInstancesScale));