r.LightFunctionAtlas

r.LightFunctionAtlas

#Overview

name: r.LightFunctionAtlas

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 is to enable or disable the light function atlas generation at runtime in Unreal Engine’s rendering system. This feature is experimental and allows for dynamic creation of light function atlases, which are used to optimize the rendering of light functions in the engine.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the light function atlas subsystem. Based on the callsites, it’s clear that this variable is utilized in the LightFunctionAtlas.cpp file, which is part of the rendering pipeline.

The value of this variable is set through a console variable (CVarLightFunctionAtlas) with a default value of 1, meaning it’s enabled by default. Developers can change this value at runtime using console commands or through code.

The associated variable CVarLightFunctionAtlas interacts directly with r.LightFunctionAtlas, as they share the same value. This console variable is used to control the behavior of the light function atlas system.

Developers must be aware of several important aspects when using this variable:

  1. It’s an experimental feature, so its behavior might change in future engine versions.
  2. The atlas will only be generated if other systems are using it at runtime, even if the variable is set to 1.
  3. It’s render thread safe, meaning it can be safely modified from different threads.

Best practices when using this variable include:

  1. Testing thoroughly when enabling or disabling this feature, as it may impact rendering performance and visual quality.
  2. Monitoring performance metrics to ensure the light function atlas is providing the expected benefits.
  3. Using it in conjunction with the engine show flag for light functions (ViewFamily.EngineShowFlags.LightFunctions).

Regarding the associated variable CVarLightFunctionAtlas:

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarLightFunctionAtlas(
	TEXT("r.LightFunctionAtlas"),
	1,
	TEXT("Experimental: enable the light function atlas generation at runtime. The atlas will only be generated if other systems are using it at runtime."),
	ECVF_RenderThreadSafe);

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

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

*/

static TAutoConsoleVariable<int32> CVarLightFunctionAtlas(
	TEXT("r.LightFunctionAtlas"),
	1,
	TEXT("Experimental: enable the light function atlas generation at runtime. The atlas will only be generated if other systems are using it at runtime."),
	ECVF_RenderThreadSafe);

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

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

Scope (from outer to inner):

file
namespace    LightFunctionAtlas
function     void FLightFunctionAtlas::BeginSceneFrame

Source code excerpt:


	// Now lets check if we need to generate the atlas for this frame
	bLightFunctionAtlasEnabled = CVarLightFunctionAtlas.GetValueOnRenderThread() > 0 && ViewFamily.EngineShowFlags.LightFunctions > 0;

	// But only really enable the atlas generation if a system asks for it
	bool bVolumetricFogRequestsLF = false;
	bool bDeferredlightingRequestsLF = false;
	bool bManyLightsRequestsLF = false;
	bool bLumenRequestsLF = false;