r.StaticMesh.StripMinLodDataDuringCooking
r.StaticMesh.StripMinLodDataDuringCooking
#Overview
name: r.StaticMesh.StripMinLodDataDuringCooking
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If non-zero, data for Static Mesh LOD levels below MinLOD will be discarded at cook time
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.StaticMesh.StripMinLodDataDuringCooking is to control the stripping of data for Static Mesh LOD levels below MinLOD during the cooking process. This setting is primarily used in the rendering system, specifically for optimizing static mesh data.
This setting variable is mainly relied upon by the Unreal Engine’s rendering system, particularly in the Static Mesh processing and rendering modules. It’s used in the Engine/Source/Runtime/Engine/ directory, specifically in StaticMesh.cpp and StaticMeshRender.cpp files.
The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with a default value of 0, meaning by default, no data stripping occurs.
This variable interacts closely with another variable named CVarStripMinLodDataDuringCooking, which shares the same value and purpose. It also interacts with other variables like CVarStaticMeshKeepMobileMinLODSettingOnDesktop in certain conditions.
Developers must be aware that when this variable is set to a non-zero value, it will cause data for Static Mesh LOD levels below MinLOD to be discarded during the cooking process. This can significantly reduce the size of cooked content but may affect the appearance of meshes at certain distances or on certain platforms.
Best practices when using this variable include:
- Carefully consider the trade-off between file size and visual quality before enabling.
- Test thoroughly on all target platforms to ensure acceptable visual results.
- Be aware of how this interacts with platform-specific LOD settings, especially for mobile platforms.
Regarding the associated variable CVarStripMinLodDataDuringCooking:
The purpose of CVarStripMinLodDataDuringCooking is identical to r.StaticMesh.StripMinLodDataDuringCooking. It’s used to control the stripping of data for Static Mesh LOD levels below MinLOD during cooking.
This variable is used in the same subsystems as r.StaticMesh.StripMinLodDataDuringCooking, primarily in the Static Mesh processing and rendering modules.
The value is set through the console variable system, with a default value of 0.
It directly interacts with r.StaticMesh.StripMinLodDataDuringCooking, sharing the same value and purpose.
Developers should be aware that this variable has the same effects and considerations as r.StaticMesh.StripMinLodDataDuringCooking.
The best practices for using this variable are the same as those for r.StaticMesh.StripMinLodDataDuringCooking.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:121
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarStripMinLodDataDuringCooking(
TEXT("r.StaticMesh.StripMinLodDataDuringCooking"),
0,
TEXT("If non-zero, data for Static Mesh LOD levels below MinLOD will be discarded at cook time"));
static TAutoConsoleVariable<int32> CVarStaticMeshKeepMobileMinLODSettingOnDesktop(
TEXT("r.StaticMesh.KeepMobileMinLODSettingOnDesktop"),
0,
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshRender.cpp:257
Scope (from outer to inner):
file
function FStaticMeshSceneProxy::FStaticMeshSceneProxy
Source code excerpt:
#if WITH_EDITOR
// If we plan to strip the min LOD during cooking, emulate that behavior in the editor
static const auto* CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.StaticMesh.StripMinLodDataDuringCooking"));
check(CVar);
if (CVar->GetValueOnAnyThread())
{
EffectiveMinLOD = FMath::Max<int32>(EffectiveMinLOD, SMCurrentMinLOD);
}
#endif
#Associated Variable and Callsites
This variable is associated with another variable named CVarStripMinLodDataDuringCooking
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:120
Scope: file
Source code excerpt:
#endif
static TAutoConsoleVariable<int32> CVarStripMinLodDataDuringCooking(
TEXT("r.StaticMesh.StripMinLodDataDuringCooking"),
0,
TEXT("If non-zero, data for Static Mesh LOD levels below MinLOD will be discarded at cook time"));
static TAutoConsoleVariable<int32> CVarStaticMeshKeepMobileMinLODSettingOnDesktop(
TEXT("r.StaticMesh.KeepMobileMinLODSettingOnDesktop"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:343
Scope (from outer to inner):
file
function uint8 FStaticMeshLODResources::GenerateClassStripFlags
Source code excerpt:
const bool bWantToStripLOD = Ar.IsCooking()
&& (CVarStripMinLodDataDuringCooking.GetValueOnAnyThread() != 0)
&& OwnerStaticMesh
&& GetPlatformMinLODIdx(Ar.CookingTarget(), OwnerStaticMesh) > Index;
const bool bSupportRayTracing = OwnerStaticMesh ? OwnerStaticMesh->bSupportRayTracing : false;
const bool bWantToStripRayTracingResources = Ar.IsCooking() && (!Ar.CookingTarget()->UsesRayTracing() || !bSupportRayTracing);
return
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:1688
Scope (from outer to inner):
file
function void FStaticMeshRenderData::Serialize
Source code excerpt:
{
if (Ar.CookingTarget()->GetPlatformInfo().PlatformGroupName == TEXT("Desktop")
&& CVarStripMinLodDataDuringCooking.GetValueOnAnyThread() != 0
&& CVarStaticMeshKeepMobileMinLODSettingOnDesktop.GetValueOnAnyThread() != 0)
{
// Serialize 0 value when per quality level properties are used
if (!Owner->IsMinLodQualityLevelEnable())
{
MinMobileLODIdx = Owner->GetMinLOD().GetValueForPlatform(TEXT("Mobile")) - FStaticMeshLODResources::GetPlatformMinLODIdx(Ar.CookingTarget(), Owner);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:2877
Scope (from outer to inner):
file
function static FString BuildStaticMeshDerivedDataKeySuffix
Source code excerpt:
if (TargetPlatform->GetPlatformInfo().PlatformGroupName == TEXT("Desktop")
&& CVarStripMinLodDataDuringCooking.GetValueOnAnyThread() != 0
&& CVarStaticMeshKeepMobileMinLODSettingOnDesktop.GetValueOnAnyThread() != 0)
{
KeySuffix += TEXT("_MinMLOD");
}
// Append the section material slot mappings for LOD0, as they are baked into the Nanite build.