r.ManyLights.Debug

r.ManyLights.Debug

#Overview

name: r.ManyLights.Debug

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.ManyLights.Debug is to enable debug mode for the many lights system in Unreal Engine’s rendering pipeline. This setting variable is used to control the level of debug information printed from shaders related to the many lights system.

This setting variable is primarily used within the Renderer module of Unreal Engine, specifically in the ManyLights subsystem. Based on the callsites, it’s clear that this variable is part of the rendering system and is used to debug the many lights feature.

The value of this variable is set through a console variable (CVarManyLightsDebug) with three possible values: 0 - Disable debug mode 1 - Visualize sampling 2 - Visualize tracing

The associated variable CVarManyLightsDebug is directly linked to r.ManyLights.Debug. It’s an instance of TAutoConsoleVariable that allows for runtime modification of the debug mode.

Developers must be aware that this variable is render thread safe (ECVF_RenderThreadSafe), meaning it can be safely accessed and modified from the render thread. When using this variable, developers should consider the performance impact of enabling debug visualizations, especially in production builds.

Best practices when using this variable include:

  1. Using it primarily during development and debugging phases.
  2. Ensuring it’s disabled in release builds to avoid performance overhead.
  3. Understanding the different visualization modes (sampling and tracing) to effectively debug lighting issues.
  4. Using it in conjunction with other rendering debug tools for comprehensive analysis.

Regarding the associated variable CVarManyLightsDebug:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:82

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarManyLightsDebug(
	TEXT("r.ManyLights.Debug"),
	0,
	TEXT("Whether to enabled debug mode, which prints various extra debug information from shaders.")
	TEXT("0 - Disable\n")
	TEXT("1 - Visualize sampling\n")
	TEXT("2 - Visualize tracing\n"),
	ECVF_RenderThreadSafe

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarManyLightsDebug(
	TEXT("r.ManyLights.Debug"),
	0,
	TEXT("Whether to enabled debug mode, which prints various extra debug information from shaders.")
	TEXT("0 - Disable\n")
	TEXT("1 - Visualize sampling\n")
	TEXT("2 - Visualize tracing\n"),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ManyLights/ManyLights.cpp:202

Scope (from outer to inner):

file
namespace    ManyLights
function     int32 GetDebugMode

Source code excerpt:

	int32 GetDebugMode()
	{
		return CVarManyLightsDebug.GetValueOnRenderThread();
	}

	bool UseWaveOps(EShaderPlatform ShaderPlatform)
	{
		return CVarManyLightsWaveOps.GetValueOnRenderThread() != 0
			&& GRHISupportsWaveOperations