r.StaticMesh.KeepMobileMinLODSettingOnDesktop
r.StaticMesh.KeepMobileMinLODSettingOnDesktop
#Overview
name: r.StaticMesh.KeepMobileMinLODSettingOnDesktop
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If non-zero, mobile setting for MinLOD will be stored in the cooked data for desktop platforms
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.StaticMesh.KeepMobileMinLODSettingOnDesktop is to control whether the mobile setting for MinLOD should be stored in the cooked data for desktop platforms in Unreal Engine 5.
This setting variable is primarily used in the Static Mesh rendering system within the Engine module. It affects how static mesh data is processed and stored during the cooking process, particularly for desktop platforms.
The value of this variable is set through a console variable (CVar) named CVarStaticMeshKeepMobileMinLODSettingOnDesktop. It is initialized with a default value of 0, meaning that by default, the mobile MinLOD setting is not stored for desktop platforms.
This variable interacts with other variables, particularly CVarStripMinLodDataDuringCooking, to determine how MinLOD data is handled during the cooking process for desktop platforms.
Developers must be aware that:
- This setting affects the size of cooked data for desktop platforms.
- It may impact performance and memory usage on desktop platforms if enabled.
- It’s particularly relevant when developing games that target both mobile and desktop platforms.
Best practices when using this variable include:
- Only enable it if you need consistent MinLOD behavior between mobile and desktop platforms.
- Consider the impact on data size and loading times when enabling this feature.
- Test thoroughly on both mobile and desktop platforms to ensure desired behavior.
Regarding the associated variable CVarStaticMeshKeepMobileMinLODSettingOnDesktop:
This is the actual console variable that controls the r.StaticMesh.KeepMobileMinLODSettingOnDesktop setting. It’s defined as a TAutoConsoleVariable
The purpose of this variable is the same as r.StaticMesh.KeepMobileMinLODSettingOnDesktop - to control whether the mobile MinLOD setting is stored for desktop platforms.
It’s used in the Engine module, specifically in the StaticMesh.cpp file, affecting how static mesh data is serialized and how derived data keys are built.
The value of this variable can be set through the console or configuration files. It’s checked during the static mesh serialization process and when building derived data keys.
Developers should be aware that changing this variable at runtime may not have an immediate effect on already loaded static meshes. It primarily affects the cooking and loading processes.
Best practices for using this variable include:
- Set it before cooking content if you want it to affect the cooked data.
- Consider performance implications when enabling it, especially for projects with many static meshes.
- Use it in conjunction with other related CVars like CVarStripMinLodDataDuringCooking for consistent behavior.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:126
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarStaticMeshKeepMobileMinLODSettingOnDesktop(
TEXT("r.StaticMesh.KeepMobileMinLODSettingOnDesktop"),
0,
TEXT("If non-zero, mobile setting for MinLOD will be stored in the cooked data for desktop platforms"));
static TAutoConsoleVariable<int32> CVarSupportDepthOnlyIndexBuffers(
TEXT("r.SupportDepthOnlyIndexBuffers"),
1,
#Associated Variable and Callsites
This variable is associated with another variable named CVarStaticMeshKeepMobileMinLODSettingOnDesktop
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:125
Scope: file
Source code excerpt:
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,
TEXT("If non-zero, mobile setting for MinLOD will be stored in the cooked data for desktop platforms"));
static TAutoConsoleVariable<int32> CVarSupportDepthOnlyIndexBuffers(
TEXT("r.SupportDepthOnlyIndexBuffers"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:1683
Scope (from outer to inner):
file
function void FStaticMeshRenderData::Serialize
Source code excerpt:
{
int32 MinMobileLODIdx = 0;
bool bShouldSerialize = CVarStaticMeshKeepMobileMinLODSettingOnDesktop.GetValueOnAnyThread() != 0;
#if WITH_EDITOR
if (Ar.IsSaving())
{
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);
// Will be cast to uint8 when applying LOD bias. Also, make sure it's not < 0,
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:2878
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.
const FMeshSectionInfoMap& SectionInfoMap = Mesh->GetSectionInfoMap();