r.LightFunctionAtlas.Size
r.LightFunctionAtlas.Size
#Overview
name: r.LightFunctionAtlas.Size
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Experimental: The default size in atlas slot count of the edge of the 2D texture atlas.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.LightFunctionAtlas.Size is to control the size of the light function atlas in Unreal Engine’s rendering system. Specifically, it determines the number of slots along the edge of the 2D texture atlas used for light functions.
This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the light function atlas implementation. The light function atlas is a texture that stores multiple light functions, which are used to modify the appearance of lights in the scene.
The value of this variable is set through a console variable (CVar) named CVarLightFunctionAtlasSize. It is defined with a default value of 4, meaning the atlas will have a 4x4 grid of slots by default. The value can be changed at runtime through console commands or programmatically.
The associated variable CVarLightFunctionAtlasSize directly interacts with r.LightFunctionAtlas.Size. They share the same value and purpose.
Developers should be aware of the following when using this variable:
- The value is clamped between 4 and MAX_LIGHT_FUNCTION_ATLAS_EDGE_SIZE (which appears to be 16 based on the comment in the code).
- Changing this value affects the memory usage and performance of light function rendering.
- It’s marked as “Experimental,” indicating that its behavior or implementation might change in future engine versions.
Best practices when using this variable include:
- Only modify it if you have a specific need for more or fewer light function slots.
- Monitor performance and memory usage when adjusting this value, especially on lower-end hardware.
- Consider the trade-off between the number of available slots and the resolution of each slot in the atlas.
Regarding the associated variable CVarLightFunctionAtlasSize:
Its purpose is identical to r.LightFunctionAtlas.Size, serving as the actual CVar implementation in the engine’s code.
It’s used in the GetAtlasEdgeSize() function to retrieve the current value of the atlas size, which is then used in various parts of the light function atlas implementation.
The value is accessed using GetValueOnRenderThread(), ensuring thread-safe access in the rendering pipeline.
Developers should treat CVarLightFunctionAtlasSize as the internal representation of r.LightFunctionAtlas.Size and generally interact with it through the console variable system rather than directly in code, unless they’re extending the light function atlas functionality.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightFunctionAtlas.cpp:64
Scope: file
Source code excerpt:
// We do not dynamically scale allocated slot resolution for now.
static TAutoConsoleVariable<int32> CVarLightFunctionAtlasSize(
TEXT("r.LightFunctionAtlas.Size"),
4,
TEXT("Experimental: The default size in atlas slot count of the edge of the 2D texture atlas."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarLightFunctionAtlasMaxLightCount(
TEXT("r.LightFunctionAtlas.MaxLightCount"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarLightFunctionAtlasSize
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightFunctionAtlas.cpp:63
Scope: file
Source code excerpt:
// We do not dynamically scale allocated slot resolution for now.
static TAutoConsoleVariable<int32> CVarLightFunctionAtlasSize(
TEXT("r.LightFunctionAtlas.Size"),
4,
TEXT("Experimental: The default size in atlas slot count of the edge of the 2D texture atlas."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarLightFunctionAtlasMaxLightCount(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightFunctionAtlas.cpp:128
Scope (from outer to inner):
file
function static uint32 GetAtlasEdgeSize
Source code excerpt:
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
return AtlasEdgeSize;
}
namespace LightFunctionAtlas