r.IESAtlas.MaxProfileCount

r.IESAtlas.MaxProfileCount

#Overview

name: r.IESAtlas.MaxProfileCount

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.IESAtlas.MaxProfileCount is to set the maximum number of IES (Illuminating Engineering Society) profiles that can be stored in the IES texture atlas. This setting is part of the rendering system in Unreal Engine 5, specifically related to lighting and texture management.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the IES texture management system. This can be seen from the file path where the variable is defined: “Engine/Source/Runtime/Renderer/Private/IESTextureManager.cpp”.

The value of this variable is set as a console variable using TAutoConsoleVariable. It is initialized with a default value of 32, but can be changed at runtime through console commands or project settings.

This variable interacts closely with CVarIESTextureMaxProfileCount, which is essentially the C++ representation of the same setting. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects the memory allocation for the IES texture atlas. Increasing this value allows for more IES profiles to be stored, but it will also increase memory usage. Conversely, decreasing it might lead to some IES profiles not being loaded if the limit is reached.

Best practices when using this variable include:

  1. Setting it to a value that balances between having enough slots for your IES profiles and managing memory usage.
  2. Monitoring performance and memory usage when adjusting this value.
  3. Considering the number of unique IES profiles used in your project when setting this value.

Regarding the associated variable CVarIESTextureMaxProfileCount:

The purpose of CVarIESTextureMaxProfileCount is the same as r.IESAtlas.MaxProfileCount - it controls the maximum number of IES profiles that can be stored in the atlas.

This variable is used directly in the C++ code to retrieve the current value of the setting. It’s used in the IESAtlas namespace, specifically in the UpdateAtlasTexture function.

The value of this variable is set through the r.IESAtlas.MaxProfileCount console variable.

It interacts with other variables like CVarIESTextureResolution to determine when the atlas texture needs to be recreated or updated.

Developers should be aware that changes to this variable at runtime will trigger a recreation of the IES texture atlas, which could have performance implications.

Best practices include:

  1. Using GetValueOnRenderThread() when accessing this variable to ensure thread-safe access.
  2. Caching the value when appropriate to avoid frequent calls to GetValueOnRenderThread().
  3. Considering the impact on performance when changing this value, especially in performance-critical sections of code.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IESTextureManager.cpp:32

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarIESTextureMaxProfileCount(
	TEXT("r.IESAtlas.MaxProfileCount"),
	32,
	TEXT("The maximum number of IES profiles which can be stored.\n"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarIESTextureDebug(
	TEXT("r.IESAtlas.Debug"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IESTextureManager.cpp:31

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarIESTextureMaxProfileCount(
	TEXT("r.IESAtlas.MaxProfileCount"),
	32,
	TEXT("The maximum number of IES profiles which can be stored.\n"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarIESTextureDebug(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IESTextureManager.cpp:492

Scope (from outer to inner):

file
namespace    IESAtlas
function     void UpdateAtlasTexture

Source code excerpt:

	// Force update by resetting the atlas layout
	static uint32 CachedAtlasResolution = CVarIESTextureResolution.GetValueOnRenderThread();
	static uint32 CachedAtlasMaxSlice = CVarIESTextureMaxProfileCount.GetValueOnRenderThread();
	const bool bHasSettingChanged = CachedAtlasResolution != CVarIESTextureResolution.GetValueOnRenderThread() || CachedAtlasMaxSlice != CVarIESTextureMaxProfileCount.GetValueOnRenderThread();

	// 1. Determine if a new atlas texture allocation is needed: If there are new entries, ensure it can fit into the atlas
	bool bForceRecreate = false;
	uint32 RequestedSliceCount = 0;
	if (GIESTextureManager.bHasPendingAdds)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IESTextureManager.cpp:512

Scope (from outer to inner):

file
namespace    IESAtlas
function     void UpdateAtlasTexture

Source code excerpt:

	{
		CachedAtlasResolution = CVarIESTextureResolution.GetValueOnRenderThread();
		CachedAtlasMaxSlice = CVarIESTextureMaxProfileCount.GetValueOnRenderThread();
		InvalidateSlots(GIESTextureManager, RequestedSliceCount);
	}
	else 
	{
		// Force update if among the existing valid slot a streamed a higher resolution than the existing one
		for (FAtlasSlot& Slot : GIESTextureManager.Slots)