r.Streaming.MaxTextureUVDensity

r.Streaming.MaxTextureUVDensity

#Overview

name: r.Streaming.MaxTextureUVDensity

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Streaming.MaxTextureUVDensity is to set a maximum limit on the UV density for static texture entries in Unreal Engine’s texture streaming system. This setting is primarily used for the rendering and texture streaming subsystems.

The Unreal Engine subsystems that rely on this setting variable are primarily the texture streaming and level rendering modules. This can be seen from the file names where the variable is referenced, such as ‘TextureStreamingHelpers.cpp’ and ‘LevelTextureManager.cpp’.

The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a TAutoConsoleVariable, which means it can be changed at runtime through console commands or configuration files.

This variable interacts closely with CVarStreamingMaxTextureUVDensity, which is its associated console variable. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects how static and dynamic components are handled in texture streaming. If a component has a UV density higher than this value, it will be treated as a dynamic component instead of a static one. This can have implications for performance and memory usage.

Best practices when using this variable include:

  1. Setting it to a non-zero value to enable the feature.
  2. Carefully tuning the value based on the specific needs of the project, considering the trade-offs between static and dynamic component handling.
  3. Monitoring performance impacts when adjusting this value, especially in scenes with many textured objects.

Regarding the associated variable CVarStreamingMaxTextureUVDensity:

The purpose of CVarStreamingMaxTextureUVDensity is to provide a programmatic way to access and modify the r.Streaming.MaxTextureUVDensity setting within the C++ code of Unreal Engine.

This console variable is used in various parts of the engine, particularly in the texture streaming and level rendering systems. It’s accessed in functions like FLevelRenderAssetManager::IncrementalBuild and FRenderAssetStreamingSettings::Update, indicating its importance in these systems.

The value of this variable is set when the engine initializes the console variables, but it can be changed at runtime through console commands.

CVarStreamingMaxTextureUVDensity directly interacts with r.Streaming.MaxTextureUVDensity, as they represent the same setting.

Developers should be aware that changes to this variable will immediately affect the engine’s texture streaming behavior. It’s used to determine how UV density affects the classification of components as static or dynamic.

Best practices for using CVarStreamingMaxTextureUVDensity include:

  1. Using GetValueOnAnyThread() when accessing its value, as seen in the provided code snippets.
  2. Considering the performance implications when modifying this value, especially in performance-critical sections of code.
  3. Documenting any code that relies on or modifies this variable, as it can have wide-reaching effects on texture streaming behavior.

#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:249

Scope: file

Source code excerpt:


TAutoConsoleVariable<float> CVarStreamingMaxTextureUVDensity(
	TEXT("r.Streaming.MaxTextureUVDensity"),
	0,
	TEXT("If non-zero, the max UV density a static entry can have.\n")
	TEXT("Used to improve level culling from MinLevelTextureScreenSize.\n")
	TEXT("Component with bigger entries become handled as dynamic component.\n"),
	ECVF_Default);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/LevelTextureManager.cpp:112

Scope (from outer to inner):

file
function     void FLevelRenderAssetManager::IncrementalBuild

Source code excerpt:

	check(Level);

	const float MaxTextureUVDensity = CVarStreamingMaxTextureUVDensity.GetValueOnAnyThread();

	switch (BuildStep)
	{
	case EStaticBuildStep::BuildTextureLookUpMap:
	{
		// Build the map to convert from a guid to the level index. 

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

Scope: file

Source code excerpt:

	ECVF_Default);

TAutoConsoleVariable<float> CVarStreamingMaxTextureUVDensity(
	TEXT("r.Streaming.MaxTextureUVDensity"),
	0,
	TEXT("If non-zero, the max UV density a static entry can have.\n")
	TEXT("Used to improve level culling from MinLevelTextureScreenSize.\n")
	TEXT("Component with bigger entries become handled as dynamic component.\n"),
	ECVF_Default);

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

Scope (from outer to inner):

file
function     void FRenderAssetStreamingSettings::Update

Source code excerpt:

	MaxHiddenPrimitiveViewBoost = FMath::Max<float>(1.f, CVarStreamingMaxHiddenPrimitiveViewBoost.GetValueOnAnyThread());
	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:65

Scope: file

Source code excerpt:

extern TAutoConsoleVariable<int32> CVarStreamingNumStaticComponentsProcessedPerFrame;
extern TAutoConsoleVariable<int32> CVarStreamingDefragDynamicBounds;
extern TAutoConsoleVariable<float> CVarStreamingMaxTextureUVDensity;
extern TAutoConsoleVariable<int32> CVarStreamingLowResHandlingMode;

struct FRenderAssetStreamingSettings
{
	// How to handle assets with too many missing MIPs or LODs
	enum ELowResHandlingMode