r.Lumen.Visualize.CardGenerationMaxSurfel

r.Lumen.Visualize.CardGenerationMaxSurfel

#Overview

name: r.Lumen.Visualize.CardGenerationMaxSurfel

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.Lumen.Visualize.CardGenerationMaxSurfel is to control the maximum number of surfels visualized during Lumen card generation debugging. This setting variable is part of the Lumen global illumination system in Unreal Engine 5’s rendering subsystem.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the Lumen visualization component. This can be seen from the file path “Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualize.cpp”.

The value of this variable is set through the FAutoConsoleVariableRef mechanism, which allows it to be modified at runtime via console commands. It’s initialized with a default value of -1.

This variable interacts directly with its associated variable GVisualizeLumenCardGenerationMaxSurfel. They share the same value, with the console variable acting as an interface to modify the global variable.

Developers must be aware that:

  1. This variable is intended for debugging and visualization purposes only.
  2. Setting a value >= 0 will limit the number of surfels drawn, which can be useful for performance or focusing on specific areas.
  3. The default value of -1 likely means “no limit” on the number of surfels visualized.

Best practices when using this variable include:

  1. Use it temporarily for debugging purposes and not in production builds.
  2. Start with smaller values to understand the surfel distribution before increasing.
  3. Be mindful of performance impact when visualizing a large number of surfels.

Regarding the associated variable GVisualizeLumenCardGenerationMaxSurfel:

The purpose of GVisualizeLumenCardGenerationMaxSurfel is to store the actual value used by the rendering code to limit surfel visualization. It’s the internal representation of the console variable.

This variable is used directly in the rendering code to control the number of surfels drawn. It’s checked in a loop that iterates over surfels, breaking the loop if the number of surfels drawn reaches the specified limit.

The value of this variable is set by the associated console variable r.Lumen.Visualize.CardGenerationMaxSurfel.

Developers should be aware that modifying this variable directly in code is not recommended, as it’s intended to be controlled via the console variable for easier debugging and tweaking.

Best practices include using the console variable for modifications rather than changing this global variable directly in code, and resetting it to -1 (unlimited) when detailed visualization is no longer needed.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualize.cpp:171

Scope: file

Source code excerpt:

int32 GVisualizeLumenCardGenerationMaxSurfel = -1;
FAutoConsoleVariableRef CVarVisualizeLumenSceneCardGenerationMaxSurfel(
	TEXT("r.Lumen.Visualize.CardGenerationMaxSurfel"),
	GVisualizeLumenCardGenerationMaxSurfel,
	TEXT(""),
	ECVF_RenderThreadSafe
);

int32 GVisualizeLumenCardPlacement = 0;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualize.cpp:169

Scope: file

Source code excerpt:

);

int32 GVisualizeLumenCardGenerationMaxSurfel = -1;
FAutoConsoleVariableRef CVarVisualizeLumenSceneCardGenerationMaxSurfel(
	TEXT("r.Lumen.Visualize.CardGenerationMaxSurfel"),
	GVisualizeLumenCardGenerationMaxSurfel,
	TEXT(""),
	ECVF_RenderThreadSafe
);

int32 GVisualizeLumenCardPlacement = 0;
FAutoConsoleVariableRef CVarVisualizeLumenSceneCardPlacement(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualize.cpp:1043

Scope (from outer to inner):

file
function     void DrawSurfels

Source code excerpt:

	for (int32 SurfelIndex = 0; SurfelIndex < Surfels.Num(); ++SurfelIndex)
	{
		if (GVisualizeLumenCardGenerationMaxSurfel >= 0 && NumSurfels >= GVisualizeLumenCardGenerationMaxSurfel)
		{
			break;
		}

		const FLumenCardBuildDebugData::FSurfel& Surfel = Surfels[SurfelIndex];
		if (Surfel.Type == SurfelType)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualize.cpp:1090

Scope (from outer to inner):

file
function     void DrawSurfels

Source code excerpt:


	if (SurfelType == FLumenCardBuildDebugData::ESurfelType::Cluster 
		&& GVisualizeLumenCardGenerationMaxSurfel >= 0)
	{
		LocalBounds = LocalBounds.ExpandBy(1.0f);

		DrawWireBox(&ViewPDI, PrimitiveToWorld, LocalBounds, SurfelColor, DepthPriority, GVisualizeLumenCardGenerationClusterScale);

		const FVector Start = PrimitiveToWorld.TransformPosition(LocalBounds.GetCenter());