r.LumenScene.FastCameraMode

r.LumenScene.FastCameraMode

#Overview

name: r.LumenScene.FastCameraMode

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

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.LumenScene.FastCameraMode is to control the Lumen Scene update behavior for fast camera movement scenarios in Unreal Engine 5’s rendering system. This setting is designed to provide a balance between quality and performance when the camera is moving quickly.

This setting variable is primarily used in the Lumen subsystem of Unreal Engine’s rendering module. Lumen is UE5’s global illumination and reflections system.

The value of this variable is set through a console variable (CVar) named “r.LumenScene.FastCameraMode”. It’s associated with the C++ variable GLumenFastCameraMode, which shares the same value.

Several other parts of the Lumen system interact with this variable:

  1. It affects the card texel density calculation in LumenSceneGPUDrivenUpdate.cpp.
  2. It influences the maximum card resolution in LumenSceneRendering.cpp.
  3. It impacts the number of card captures per frame in LumenSceneRendering.cpp.
  4. It affects the clipmap grid resolution and probe resolution in LumenScreenProbeGather.cpp.

Developers should be aware that enabling this mode will result in lower quality but faster updates to the Lumen Scene, allowing lighting to keep up with rapid camera movements.

Best practices for using this variable include:

  1. Enable it during sequences with fast camera movement where lighting accuracy can be slightly compromised for performance.
  2. Disable it for static or slow-moving camera scenes to maintain high-quality lighting.
  3. Consider exposing this setting to end-users as a performance option, especially for VR or fast-paced games.

Regarding the associated variable GLumenFastCameraMode:

The purpose of GLumenFastCameraMode is to serve as the C++ representation of the r.LumenScene.FastCameraMode console variable. It’s an integer variable that stores the current state of the fast camera mode setting.

This variable is used directly in the Lumen rendering code to make decisions about quality vs. performance tradeoffs. It’s typically checked in conditional statements to adjust various parameters of the Lumen system.

The value of GLumenFastCameraMode is set by the console variable system when r.LumenScene.FastCameraMode is changed.

Developers should be aware that this variable is declared as extern in Lumen.h, making it accessible across multiple source files within the Lumen system.

Best practices for using GLumenFastCameraMode include:

  1. Use it for runtime checks in performance-critical code paths.
  2. Avoid modifying it directly; instead, use the console variable system to change its value.
  3. Consider caching its value locally if used frequently in tight loops to avoid potential thread synchronization issues.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneRendering.cpp:28

Scope: file

Source code excerpt:

int32 GLumenFastCameraMode = 0;
FAutoConsoleVariableRef CVarLumenFastCameraMode(
	TEXT("r.LumenScene.FastCameraMode"),
	GLumenFastCameraMode,
	TEXT("Whether to update the Lumen Scene for fast camera movement - lower quality, faster updates so lighting can keep up with the camera."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GLumenSceneParallelUpdate = 1;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/Lumen.h:148

Scope: file

Source code excerpt:

};

extern int32 GLumenFastCameraMode;

LLM_DECLARE_TAG(Lumen);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneGPUDrivenUpdate.cpp:81

Scope (from outer to inner):

file
function     float LumenScene::GetCardTexelDensity

Source code excerpt:

float LumenScene::GetCardTexelDensity()
{
	return CVarLumenSceneCardTexelDensityScale.GetValueOnRenderThread() * (GLumenFastCameraMode ? .2f : 1.0f);
}

float LumenScene::GetFarFieldCardTexelDensity()
{
	return CVarLumenSceneFarFieldTexelDensity.GetValueOnRenderThread();
}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneRendering.cpp:26

Scope: file

Source code excerpt:

#include "LumenRadiosity.h"

int32 GLumenFastCameraMode = 0;
FAutoConsoleVariableRef CVarLumenFastCameraMode(
	TEXT("r.LumenScene.FastCameraMode"),
	GLumenFastCameraMode,
	TEXT("Whether to update the Lumen Scene for fast camera movement - lower quality, faster updates so lighting can keep up with the camera."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GLumenSceneParallelUpdate = 1;
FAutoConsoleVariableRef CVarLumenSceneParallelUpdate(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneRendering.cpp:242

Scope (from outer to inner):

file
function     int32 GetCardMaxResolution

Source code excerpt:

int32 GetCardMaxResolution()
{
	if (GLumenFastCameraMode)
	{
		return GLumenSceneCardMaxResolution / 2;
	}

	return GLumenSceneCardMaxResolution;
}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneRendering.cpp:252

Scope (from outer to inner):

file
function     int32 GetMaxLumenSceneCardCapturesPerFrame

Source code excerpt:

int32 GetMaxLumenSceneCardCapturesPerFrame()
{
	return FMath::Max(GLumenSceneCardCapturesPerFrame * (GLumenFastCameraMode ? 2 : 1), 0);
}

namespace LumenScene
{
	int32 GetMaxMeshCardsToAddPerFrame()
	{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenScreenProbeGather.cpp:510

Scope (from outer to inner):

file
namespace    LumenScreenProbeGatherRadianceCache
function     int32 GetClipmapGridResolution

Source code excerpt:

	int32 GetClipmapGridResolution()
	{
		const int32 GridResolution = GRadianceCacheGridResolution / (GLumenFastCameraMode ? 2 : 1);
		return FMath::Clamp(GridResolution, 1, 256);
	}

	int32 GetProbeResolution()
	{
		return GRadianceCacheProbeResolution / (GLumenFastCameraMode ? 2 : 1);
	}

	int32 GetFinalProbeResolution()
	{
		return GetProbeResolution() + 2 * (1 << (GRadianceCacheNumMipmaps - 1));
	}