r.DistanceFields.MaxIndirectionAtlasSizeXYZ

r.DistanceFields.MaxIndirectionAtlasSizeXYZ

#Overview

name: r.DistanceFields.MaxIndirectionAtlasSizeXYZ

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.DistanceFields.MaxIndirectionAtlasSizeXYZ is to set the maximum size of the indirection atlas texture used in the distance field rendering system of Unreal Engine 5.

This setting variable is primarily used by the rendering subsystem, specifically in the distance field streaming module. It’s defined in the DistanceFieldStreaming.cpp file, which is part of the Renderer module.

The value of this variable is set as a console variable with a default value of 512. It can be modified at runtime through the console or configuration files, but it’s marked as read-only, meaning it should not be changed during gameplay.

The associated variable CVarMaxIndirectionAtlasSizeXYZ directly interacts with r.DistanceFields.MaxIndirectionAtlasSizeXYZ. They share the same value and purpose.

Developers must be aware that this variable affects the maximum size of the indirection atlas texture in all three dimensions (X, Y, and Z). It’s crucial for managing memory usage and performance in distance field rendering.

Best practices when using this variable include:

  1. Carefully considering the balance between texture quality and performance impact when adjusting this value.
  2. Testing thoroughly after changes, as it can affect rendering quality and performance.
  3. Being cautious about increasing the value, as larger textures consume more memory.

Regarding the associated variable CVarMaxIndirectionAtlasSizeXYZ:

It’s an internal representation of the r.DistanceFields.MaxIndirectionAtlasSizeXYZ console variable. It’s used within the C++ code to access the current value of the setting.

The variable is used in the DefragmentIndirectionAtlas function of the FDistanceFieldSceneData class. Here, it determines the maximum size of each dimension when creating the FTextureLayout3d object for the indirection atlas.

Developers should be aware that changes to r.DistanceFields.MaxIndirectionAtlasSizeXYZ will be reflected in CVarMaxIndirectionAtlasSizeXYZ.GetValueOnRenderThread(). This method should be used to access the current value in render thread operations for thread safety.

When working with this variable, it’s important to consider its impact on the entire distance field rendering pipeline and to ensure that any modifications are made with a clear understanding of the potential effects on performance and memory usage.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldStreaming.cpp:61

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarMaxIndirectionAtlasSizeXYZ(
	TEXT("r.DistanceFields.MaxIndirectionAtlasSizeXYZ"),
	512,
	TEXT("Maximum size of indirection atlas texture"),
	ECVF_RenderThreadSafe | ECVF_ReadOnly);

static TAutoConsoleVariable<int32> CVarDefragmentIndirectionAtlas(
	TEXT("r.DistanceFields.DefragmentIndirectionAtlas"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldStreaming.cpp:60

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_ReadOnly);

static TAutoConsoleVariable<int32> CVarMaxIndirectionAtlasSizeXYZ(
	TEXT("r.DistanceFields.MaxIndirectionAtlasSizeXYZ"),
	512,
	TEXT("Maximum size of indirection atlas texture"),
	ECVF_RenderThreadSafe | ECVF_ReadOnly);

static TAutoConsoleVariable<int32> CVarDefragmentIndirectionAtlas(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistanceFieldStreaming.cpp:1185

Scope (from outer to inner):

file
function     void FDistanceFieldSceneData::DefragmentIndirectionAtlas

Source code excerpt:

	Entries.Sort(FMeshDistanceFieldSorter());

	const int32 MaxIndirectionAtlasSizeXYZ = CVarMaxIndirectionAtlasSizeXYZ.GetValueOnRenderThread();
	IndirectionAtlasLayout = FTextureLayout3d(MinSize.X, MinSize.Y, MinSize.Z, MaxIndirectionAtlasSizeXYZ, MaxIndirectionAtlasSizeXYZ, MaxIndirectionAtlasSizeXYZ, false, false);

	for (int32 EntryIndex = 0; EntryIndex < Entries.Num(); EntryIndex++)
	{
		const FEntry& Entry = Entries[EntryIndex];
		const FDistanceFieldAssetState& AssetState = AssetStateArray[Entry.AssetSetId];