r.StaticMesh.StripDistanceFieldDataDuringLoad

r.StaticMesh.StripDistanceFieldDataDuringLoad

#Overview

name: r.StaticMesh.StripDistanceFieldDataDuringLoad

This variable is created as a Console Variable (cvar).

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:

  1. This is a read-only variable, meaning it cannot be changed at runtime.
  2. It’s render thread safe, indicating it’s designed to be accessed safely from the render thread.
  3. 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:

  1. 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.
  2. Consider the performance implications: stripping this data can reduce memory usage but might affect certain rendering features that rely on distance fields.
  3. Be cautious when changing this setting, as it affects all static meshes loaded after the change.

Regarding the associated variable CVarStripDistanceFieldDataDuringLoad:

#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 )