r.UITextureLODBias

r.UITextureLODBias

#Overview

name: r.UITextureLODBias

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.UITextureLODBias is to apply an extra LOD (Level of Detail) bias specifically to UI textures in Unreal Engine 5. This setting allows developers to adjust the quality of UI textures independently from other texture types in the game.

This setting variable is primarily used in the rendering system, specifically for texture streaming and LOD management. Based on the callsites, it’s utilized in the Engine module, particularly in the texture streaming and LOD settings subsystems.

The value of this variable is set through the console variable system, as indicated by the FAutoConsoleVariableRef declaration. This means it can be modified at runtime through console commands or configuration files.

The r.UITextureLODBias interacts directly with its associated variable GUITextureLODBias. They share the same value, with r.UITextureLODBias being the console-accessible name and GUITextureLODBias being the actual integer variable used in the code.

Developers should be aware that this variable specifically affects textures in the TEXTUREGROUP_UI group. It’s applied in addition to other LOD biases, such as those set for specific LOD groups or textures.

Best practices when using this variable include:

  1. Use it sparingly and only when necessary to adjust UI texture quality.
  2. Be aware that it affects all UI textures globally, so consider the impact on performance and memory usage.
  3. Test thoroughly with different values to find the right balance between quality and performance.

Regarding the associated variable GUITextureLODBias:

The purpose of GUITextureLODBias is to store the actual integer value of the UI texture LOD bias. It’s used internally by the engine to apply the bias to UI textures.

This variable is used in the Engine module, specifically in the texture streaming manager and LOD settings systems.

The value of GUITextureLODBias is set through the console variable system, mirroring the value of r.UITextureLODBias.

GUITextureLODBias interacts directly with the texture streaming and LOD calculation systems. It’s used in calculations for determining the appropriate LOD level for UI textures.

Developers should be aware that modifying GUITextureLODBias directly in code is not recommended. Instead, they should use the r.UITextureLODBias console variable to ensure proper synchronization.

Best practices for GUITextureLODBias include:

  1. Avoid modifying it directly in code; use the console variable system instead.
  2. When debugging texture streaming issues related to UI, check the value of this variable.
  3. Be aware of its impact on UI texture quality and memory usage when optimizing performance.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/TextureLODSettings.cpp:9

Scope: file

Source code excerpt:

int32 GUITextureLODBias = 0;
FAutoConsoleVariableRef CVarUITextureLODBias(
	TEXT("r.UITextureLODBias"),
	GUITextureLODBias,
	TEXT("Extra LOD bias to apply to UI textures. (default=0)"),
	ECVF_Scalability
);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/StreamingManagerTexture.cpp:2779

Scope (from outer to inner):

file
function     bool FRenderAssetStreamingManager::HandleInvestigateRenderAssetCommand

Source code excerpt:

					{
						// UI specific Bias : see UTextureLODSettings::CalculateLODBias(), included in CachedCombinedLODBias.
						extern int32 GUITextureLODBias;
						if (StreamingRenderAsset.LODGroup == TEXTUREGROUP_UI && GUITextureLODBias)
						{
							BiasDesc += FString::Printf(TEXT(" [UI:%d]"), GUITextureLODBias);
							CumuBias += GUITextureLODBias;
						}

						// LOD group Bias : see UTextureLODSettings::CalculateLODBias(), included in CachedCombinedLODBias
						const FTextureLODGroup& LODGroupInfo = UDeviceProfileManager::Get().GetActiveProfile()->GetTextureLODSettings()->TextureLODGroups[StreamingRenderAsset.LODGroup];
						if (LODGroupInfo.LODBias)
						{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/StreamingManagerTexture.cpp:2803

Scope (from outer to inner):

file
function     bool FRenderAssetStreamingManager::HandleInvestigateRenderAssetCommand

Source code excerpt:

						// LOD group MaxResolution clamp : see UTextureLODSettings::CalculateLODBias(), included in CachedCombinedLODBias
						const int32 MipCountBeforeMaxRes = ResourceState.MaxNumLODs - RenderAsset->NumCinematicMipLevels -
							(StreamingRenderAsset.LODGroup == TEXTUREGROUP_UI ? GUITextureLODBias : 0) - 
							(FPlatformProperties::RequiresCookedData() ? 0 : (LODGroupInfo.LODBias + (Texture ? Texture->LODBias : 0)));
						const int32 MaxResBias = MipCountBeforeMaxRes - (LODGroupInfo.MaxLODMipCount + 1);
						if (MaxResBias > 0)
						{
							BiasDesc += FString::Printf(TEXT(" [LODGroup.MaxRes:%d]"), MaxResBias);
							CumuBias += MaxResBias;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/TextureLODSettings.cpp:7

Scope: file

Source code excerpt:

#include UE_INLINE_GENERATED_CPP_BY_NAME(TextureLODSettings)

int32 GUITextureLODBias = 0;
FAutoConsoleVariableRef CVarUITextureLODBias(
	TEXT("r.UITextureLODBias"),
	GUITextureLODBias,
	TEXT("Extra LOD bias to apply to UI textures. (default=0)"),
	ECVF_Scalability
);


void FTextureLODGroup::SetupGroup()

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/TextureLODSettings.cpp:199

Scope (from outer to inner):

file
function     int32 UTextureLODSettings::CalculateLODBias

Source code excerpt:

	if (LODGroup == TEXTUREGROUP_UI)
	{
		UsedLODBias += GUITextureLODBias;  
		// @todo Oodle : GUITextureLODBias is applied at both cook time & run time , which is screwy
		//	this is not inside the if (!FPlatformProperties::RequiresCookedData()) ?
		//	it should either act like cinematic bias (runtime streaming)
		//	or like the "drop mip" lod bias (cook time)
		//	but it's not quite like either
		// -> this looks broken, probably never used
	}