r.LightFunctionAtlas.SlotResolution

r.LightFunctionAtlas.SlotResolution

#Overview

name: r.LightFunctionAtlas.SlotResolution

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.LightFunctionAtlas.SlotResolution is to control the resolution of each slot in the Light Function Atlas. This setting is part of the rendering system in Unreal Engine 5, specifically related to light functions and their rendering optimization.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, as evidenced by its location in the LightFunctionAtlas.cpp file within the Renderer’s private directory.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 128, but can be changed at runtime through console commands or configuration files.

This variable interacts with another variable named CVarLightFunctionAtlasSlotResolution, which is essentially the C++ representation of the console variable. They share the same value and purpose.

Developers must be aware that this variable is marked as experimental, which means it might change or be removed in future versions of the engine. Also, the value is clamped between 32 and MAX_LIGHT_FUNCTION_ATLAS_SLOT_RESOLUTION when used, so setting values outside this range will be automatically adjusted.

Best practices when using this variable include:

  1. Only modify it if you understand the implications on rendering performance and quality.
  2. Test thoroughly after changing the value, as it can affect the visual quality of light functions.
  3. Be prepared to adjust related settings, such as the atlas size, to accommodate changes in slot resolution.

Regarding the associated variable CVarLightFunctionAtlasSlotResolution:

This is the actual C++ variable that stores the value of r.LightFunctionAtlas.SlotResolution. It’s defined as a TAutoConsoleVariable, which is Unreal Engine’s way of exposing variables to the console and config files.

The purpose of CVarLightFunctionAtlasSlotResolution is the same as r.LightFunctionAtlas.SlotResolution - to control the resolution of each slot in the Light Function Atlas.

It’s used in the GetAtlasSlotResolution() function, which retrieves the current value and applies the clamping mentioned earlier. This function is likely called whenever the engine needs to know the current slot resolution for the Light Function Atlas.

Developers should be aware that this variable is accessed on the render thread (GetValueOnRenderThread()), which means changes to it will be applied on the next frame render.

Best practices for using CVarLightFunctionAtlasSlotResolution include:

  1. Access it through the provided getter function (GetAtlasSlotResolution()) rather than directly, to ensure proper clamping is applied.
  2. Be mindful of potential performance impacts when changing this value, especially on lower-end hardware.
  3. Consider the relationship between this value and the overall atlas size when making adjustments.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightFunctionAtlas.cpp:57

Scope: file

Source code excerpt:

// We do not dynamically scale allocated slot resolution for now.
static TAutoConsoleVariable<int32> CVarLightFunctionAtlasSlotResolution(
	TEXT("r.LightFunctionAtlas.SlotResolution"),
	128,
	TEXT("Experimental: The resolution of each atlas slot."),
	ECVF_RenderThreadSafe);

// We do not dynamically scale allocated slot resolution for now.
static TAutoConsoleVariable<int32> CVarLightFunctionAtlasSize(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightFunctionAtlas.cpp:56

Scope: file

Source code excerpt:


// We do not dynamically scale allocated slot resolution for now.
static TAutoConsoleVariable<int32> CVarLightFunctionAtlasSlotResolution(
	TEXT("r.LightFunctionAtlas.SlotResolution"),
	128,
	TEXT("Experimental: The resolution of each atlas slot."),
	ECVF_RenderThreadSafe);

// We do not dynamically scale allocated slot resolution for now.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightFunctionAtlas.cpp:122

Scope (from outer to inner):

file
function     static uint32 GetAtlasSlotResolution

Source code excerpt:

static uint32 GetAtlasSlotResolution()
{
	const uint32 AtlasSlotResolution = FMath::Clamp(CVarLightFunctionAtlasSlotResolution.GetValueOnRenderThread(), 32, MAX_LIGHT_FUNCTION_ATLAS_SLOT_RESOLUTION);
	return AtlasSlotResolution;
}

static uint32 GetAtlasEdgeSize()
{
	const uint32 AtlasEdgeSize = FMath::Clamp(CVarLightFunctionAtlasSize.GetValueOnRenderThread(), 4, MAX_LIGHT_FUNCTION_ATLAS_EDGE_SIZE);// 16x16 is the maximum slot count of LIGHT_FUNCTION_ATLAS_MAX_LIGHT_FUNCTION_COUNT=256 we currently allow