r.SkeletalMesh.LODMaterialReference
r.SkeletalMesh.LODMaterialReference
#Overview
name: r.SkeletalMesh.LODMaterialReference
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether a material needs to be referenced by at least one unstripped mesh LOD to be considered as used.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.SkeletalMesh.LODMaterialReference is to control whether a material needs to be referenced by at least one unstripped mesh LOD to be considered as used in skeletal meshes.
This setting variable is primarily used in the Unreal Engine’s rendering system, specifically for skeletal mesh rendering and material management. It is part of the Engine module, as evident from its location in the Engine/Source/Runtime/Engine/Private/SkeletalMesh.cpp file.
The value of this variable is set using a TAutoConsoleVariable, which means it can be changed at runtime through console commands. The default value is 1, indicating that by default, a material needs to be referenced by at least one unstripped mesh LOD to be considered as used.
This variable interacts directly with its associated variable CVarSkeletalMeshLODMaterialReference. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable affects material usage determination in skeletal meshes. When set to 1 (default), it enforces a stricter material usage policy, potentially optimizing memory usage by considering only materials referenced by unstripped LODs. When set to 0, all materials might be considered as used, regardless of LOD references.
Best practices when using this variable include:
- In editor mode, consider leaving it at the default value (1) to ensure accurate material usage.
- For runtime optimization, you might adjust this value based on your specific use case and performance requirements.
- Be cautious when changing this value, as it may affect material loading and rendering behavior.
Regarding the associated variable CVarSkeletalMeshLODMaterialReference:
The purpose of CVarSkeletalMeshLODMaterialReference is identical to r.SkeletalMesh.LODMaterialReference, as they share the same value and functionality.
This variable is used in the USkeletalMesh::IsMaterialUsed function to determine whether a material is considered used. It’s checked in conjunction with the GIsEditor flag, indicating that its behavior might differ between editor and runtime environments.
The value of this variable is set using the same TAutoConsoleVariable as r.SkeletalMesh.LODMaterialReference.
Developers should be aware that this variable directly affects the material usage determination logic in skeletal meshes. It’s particularly important in non-editor scenarios, where it can influence which materials are loaded and processed.
Best practices for using CVarSkeletalMeshLODMaterialReference include:
- Consider the implications on performance and memory usage when modifying this value.
- Test thoroughly in both editor and runtime environments when changing this setting.
- Use in conjunction with other skeletal mesh and material-related settings for optimal performance tuning.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMesh.cpp:113
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarSkeletalMeshLODMaterialReference(
TEXT("r.SkeletalMesh.LODMaterialReference"),
1,
TEXT("Whether a material needs to be referenced by at least one unstripped mesh LOD to be considered as used."));
static TAutoConsoleVariable<int32> CVarRayTracingSupportSkeletalMeshes(
TEXT("r.RayTracing.Geometry.SupportSkeletalMeshes"),
1,
#Associated Variable and Callsites
This variable is associated with another variable named CVarSkeletalMeshLODMaterialReference
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMesh.cpp:112
Scope: file
Source code excerpt:
TEXT("Include skeletal meshes in ray tracing effects (default = 1 (skeletal meshes enabled in ray tracing))"));
static TAutoConsoleVariable<int32> CVarSkeletalMeshLODMaterialReference(
TEXT("r.SkeletalMesh.LODMaterialReference"),
1,
TEXT("Whether a material needs to be referenced by at least one unstripped mesh LOD to be considered as used."));
static TAutoConsoleVariable<int32> CVarRayTracingSupportSkeletalMeshes(
TEXT("r.RayTracing.Geometry.SupportSkeletalMeshes"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMesh.cpp:5435
Scope (from outer to inner):
file
function bool USkeletalMesh::IsMaterialUsed
Source code excerpt:
bool USkeletalMesh::IsMaterialUsed(int32 MaterialIndex) const
{
if (GIsEditor || !CVarSkeletalMeshLODMaterialReference.GetValueOnAnyThread())
{
return true;
}
const FSkeletalMeshRenderData* RenderData = GetSkeletalMeshRenderData();