r.Streaming.UseMaterialData

r.Streaming.UseMaterialData

#Overview

name: r.Streaming.UseMaterialData

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Streaming.UseMaterialData is to control whether material texture scales and coordinates will be used in the texture streaming system of Unreal Engine 5.

This setting variable is primarily used in the texture streaming subsystem of Unreal Engine 5. It affects how the engine handles texture streaming, particularly in relation to material data.

The value of this variable is set through a console variable (CVar) system. It’s defined in the Engine/Source/Runtime/Engine/Private/Streaming/TextureStreamingHelpers.cpp file with a default value of 1 (enabled).

The associated variable CVarStreamingUseMaterialData interacts directly with r.Streaming.UseMaterialData. They share the same value and are used interchangeably in the code.

Developers should be aware that this variable significantly impacts how textures are streamed in the engine. When enabled (set to non-zero), the engine will use material texture scales and coordinates to determine streaming behavior. This can lead to more accurate texture streaming but may also have performance implications.

Best practices when using this variable include:

  1. Keeping it enabled (default value of 1) unless there’s a specific reason to disable it.
  2. If disabling it, thoroughly test the impact on texture streaming and overall performance.
  3. Consider the interaction with other streaming-related variables, particularly CVarStreamingUseNewMetrics.

Regarding the associated variable CVarStreamingUseMaterialData: Its purpose is identical to r.Streaming.UseMaterialData, serving as the internal representation of the console variable. It’s used in various parts of the engine, including the UMaterialInterface class and the FRenderAssetStreamingSettings struct. The value is typically accessed using the GetValueOnGameThread() or GetValueOnAnyThread() methods, depending on the context. Developers should treat it as equivalent to r.Streaming.UseMaterialData when working with the engine’s C++ code.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/TextureStreamingHelpers.cpp:218

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarStreamingUseMaterialData(
	TEXT("r.Streaming.UseMaterialData"),
	1,
	TEXT("If non-zero, material texture scales and coord will be used"),
	ECVF_Default);

TAutoConsoleVariable<int32> CVarStreamingNumStaticComponentsProcessedPerFrame(
	TEXT("r.Streaming.NumStaticComponentsProcessedPerFrame"),

#Associated Variable and Callsites

This variable is associated with another variable named CVarStreamingUseMaterialData. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Materials/MaterialInterface.cpp:1585

Scope: file

Source code excerpt:

}

extern 	TAutoConsoleVariable<int32> CVarStreamingUseMaterialData;

bool UMaterialInterface::FindTextureStreamingDataIndexRange(FName TextureName, int32& LowerIndex, int32& HigherIndex) const
{
#if WITH_EDITORONLY_DATA
	// Because of redirectors (when textures are renammed), the texture names might be invalid and we need to udpate the data at every load.
	// Normally we would do that in the post load, but since the process needs to resolve the SoftObjectPaths, this is forbidden at that place.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Materials/MaterialInterface.cpp:1596

Scope (from outer to inner):

file
function     bool UMaterialInterface::FindTextureStreamingDataIndexRange

Source code excerpt:

#endif

	if (CVarStreamingUseMaterialData.GetValueOnGameThread() == 0 || CVarStreamingUseNewMetrics.GetValueOnGameThread() == 0)
	{
		return false;
	}

	const int32 MatchingIndex = Algo::BinarySearchBy(TextureStreamingData, TextureName, &FMaterialTextureInfo::TextureName, FNameLexicalLess());
	if (MatchingIndex != INDEX_NONE)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/TextureStreamingHelpers.cpp:217

Scope: file

Source code excerpt:

	ECVF_Scalability);

TAutoConsoleVariable<int32> CVarStreamingUseMaterialData(
	TEXT("r.Streaming.UseMaterialData"),
	1,
	TEXT("If non-zero, material texture scales and coord will be used"),
	ECVF_Default);

TAutoConsoleVariable<int32> CVarStreamingNumStaticComponentsProcessedPerFrame(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/TextureStreamingHelpers.cpp:324

Scope (from outer to inner):

file
function     void FRenderAssetStreamingSettings::Update

Source code excerpt:

	MinLevelRenderAssetScreenSize = CVarStreamingMinLevelRenderAssetScreenSize.GetValueOnAnyThread();
	MaxTextureUVDensity = CVarStreamingMaxTextureUVDensity.GetValueOnAnyThread();
	bUseMaterialData = bUseNewMetrics && CVarStreamingUseMaterialData.GetValueOnAnyThread() != 0;
	HiddenPrimitiveScale = bUseNewMetrics ? CVarStreamingHiddenPrimitiveScale.GetValueOnAnyThread() : 1.f;
	LowResHandlingMode = (ELowResHandlingMode)CVarStreamingLowResHandlingMode.GetValueOnAnyThread();
	bMipCalculationEnablePerLevelList = CVarStreamingMipCalculationEnablePerLevelList.GetValueOnAnyThread() != 0;
	bPrioritizeMeshLODRetention = CVarPrioritizeMeshLODRetention.GetValueOnAnyThread() != 0;
	VRAMPercentageClamp = CVarStreamingVRAMPercentageClamp.GetValueOnAnyThread();

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/TextureStreamingHelpers.h:62

Scope: file

Source code excerpt:

extern TAutoConsoleVariable<int32> CVarStreamingPoolSize;
extern TAutoConsoleVariable<int32> CVarStreamingCheckBuildStatus;
extern TAutoConsoleVariable<int32> CVarStreamingUseMaterialData;
extern TAutoConsoleVariable<int32> CVarStreamingNumStaticComponentsProcessedPerFrame;
extern TAutoConsoleVariable<int32> CVarStreamingDefragDynamicBounds;
extern TAutoConsoleVariable<float> CVarStreamingMaxTextureUVDensity;
extern TAutoConsoleVariable<int32> CVarStreamingLowResHandlingMode;

struct FRenderAssetStreamingSettings