r.StaticMesh.StripDistanceFieldDataDuringLoad
r.StaticMesh.StripDistanceFieldDataDuringLoad
#Overview
name: r.StaticMesh.StripDistanceFieldDataDuringLoad
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If non-zero, data for distance fields will be discarded on load. TODO: change to discard during cook!.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.StaticMesh.StripDistanceFieldDataDuringLoad is to control whether distance field data for static meshes should be discarded during the loading process. This setting is primarily related to the rendering system, specifically the management of static mesh data.
This setting variable is used within the Engine module, particularly in the static mesh loading and serialization process. Based on the callsites, it’s primarily utilized in the StaticMesh.cpp file, which is part of the core engine’s rendering system.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0, meaning that by default, distance field data is not stripped during load.
The associated variable CVarStripDistanceFieldDataDuringLoad directly interacts with r.StaticMesh.StripDistanceFieldDataDuringLoad. They share the same value and purpose.
Developers must be aware that:
- This is a read-only variable, meaning it cannot be changed at runtime.
- It’s render thread safe, indicating it’s designed to be accessed safely from the render thread.
- The variable’s description mentions that this functionality should ideally be changed to discard during cook, suggesting potential future changes to this system.
Best practices when using this variable include:
- Only enable it (set to non-zero) if you’re certain you don’t need distance field data for your static meshes, as it can’t be easily recovered once stripped.
- Consider the performance implications: stripping this data can reduce memory usage but might affect certain rendering features that rely on distance fields.
- Be cautious when changing this setting, as it affects all static meshes loaded after the change.
Regarding the associated variable CVarStripDistanceFieldDataDuringLoad:
- Its purpose is identical to r.StaticMesh.StripDistanceFieldDataDuringLoad.
- It’s used in the FStaticMeshRenderData::Serialize function to determine whether to strip distance field data during the serialization process.
- The value is accessed using GetValueOnAnyThread(), suggesting it’s designed for multi-threaded access.
- Developers should be aware that this variable directly controls the behavior of distance field data stripping during static mesh loading.
- Best practices include ensuring consistency between this variable and r.StaticMesh.StripDistanceFieldDataDuringLoad, and considering the implications on rendering features that rely on distance fields before modifying its value.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:143
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarStripDistanceFieldDataDuringLoad(
TEXT("r.StaticMesh.StripDistanceFieldDataDuringLoad"),
0,
TEXT("If non-zero, data for distance fields will be discarded on load. TODO: change to discard during cook!."),
ECVF_ReadOnly | ECVF_RenderThreadSafe);
const TCHAR* GMinLodQualityLevelCVarName = TEXT("r.StaticMesh.MinLodQualityLevel");
const TCHAR* GMinLodQualityLevelScalabilitySection = TEXT("ViewDistanceQuality");
#Associated Variable and Callsites
This variable is associated with another variable named CVarStripDistanceFieldDataDuringLoad
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:142
Scope: file
Source code excerpt:
ECVF_ReadOnly | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarStripDistanceFieldDataDuringLoad(
TEXT("r.StaticMesh.StripDistanceFieldDataDuringLoad"),
0,
TEXT("If non-zero, data for distance fields will be discarded on load. TODO: change to discard during cook!."),
ECVF_ReadOnly | ECVF_RenderThreadSafe);
const TCHAR* GMinLodQualityLevelCVarName = TEXT("r.StaticMesh.MinLodQualityLevel");
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMesh.cpp:1844
Scope (from outer to inner):
file
function void FStaticMeshRenderData::Serialize
Source code excerpt:
if (Ar.IsLoading() )
{
bool bStripDistanceFieldDataDuringLoad = (CVarStripDistanceFieldDataDuringLoad.GetValueOnAnyThread() == 1);
if( bStripDistanceFieldDataDuringLoad )
{
for (int32 ResourceIndex = 0; ResourceIndex < LODResources.Num(); ResourceIndex++)
{
FStaticMeshLODResources& LOD = LODResources[ResourceIndex];
if( LOD.DistanceFieldData != nullptr )