r.RayTracing.DebugVisualizationMode

r.RayTracing.DebugVisualizationMode

#Overview

name: r.RayTracing.DebugVisualizationMode

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.RayTracing.DebugVisualizationMode is to set the ray tracing debug visualization mode in Unreal Engine 5. This setting variable is primarily used for debugging and visualizing various aspects of the ray tracing system.

This setting variable is utilized by the ray tracing subsystem within the Renderer module of Unreal Engine 5. Specifically, it is used in the RayTracingDebug.cpp file, which is part of the ray tracing debugging functionality.

The value of this variable is set through the console command system. It can be set either programmatically or through the game console. The default value is an empty string, which means the debug visualization mode is driven by the viewport menu.

The r.RayTracing.DebugVisualizationMode variable interacts closely with its associated variable CVarRayTracingDebugMode. They share the same value and are used interchangeably in the code.

Developers should be aware that this variable affects the visualization of ray tracing debug information. When set, it overrides the debug visualization mode that would normally be selected through the viewport menu.

Best practices when using this variable include:

  1. Use it primarily for debugging purposes during development.
  2. Be cautious when enabling debug visualizations in production builds, as they may impact performance.
  3. Clear the value (set it to an empty string) when debug visualizations are no longer needed to ensure the system reverts to the default behavior.

Regarding the associated variable CVarRayTracingDebugMode:

The purpose of CVarRayTracingDebugMode is identical to r.RayTracing.DebugVisualizationMode. It’s an internal representation of the console variable used within the C++ code.

This variable is used directly in the ray tracing debug system to determine which debug visualization mode to use. It’s accessed using GetValueOnRenderThread() to ensure thread-safe access to its value.

The value of CVarRayTracingDebugMode is set automatically when r.RayTracing.DebugVisualizationMode is set through the console command system.

CVarRayTracingDebugMode interacts with other parts of the ray tracing debug system, such as the RayTracingDebugVisualizationModes map, which translates string mode names to their corresponding enumeration values.

Developers should be aware that changes to CVarRayTracingDebugMode will directly affect the behavior of the ray tracing debug visualization system.

Best practices for CVarRayTracingDebugMode include:

  1. Avoid modifying it directly in code; instead, use the r.RayTracing.DebugVisualizationMode console command.
  2. When reading its value, always use GetValueOnRenderThread() to ensure thread safety.
  3. Be aware of the performance implications of enabling different debug visualization modes, especially in non-development builds.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:26

Scope: file

Source code excerpt:


static TAutoConsoleVariable<FString> CVarRayTracingDebugMode(
	TEXT("r.RayTracing.DebugVisualizationMode"),
	TEXT(""),
	TEXT("Sets the ray tracing debug visualization mode (default = None - Driven by viewport menu) .\n")
	);

TAutoConsoleVariable<int32> CVarRayTracingDebugPickerDomain(
	TEXT("r.RayTracing.Debug.PickerDomain"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:25

Scope: file

Source code excerpt:

DECLARE_GPU_STAT(RayTracingDebug);

static TAutoConsoleVariable<FString> CVarRayTracingDebugMode(
	TEXT("r.RayTracing.DebugVisualizationMode"),
	TEXT(""),
	TEXT("Sets the ray tracing debug visualization mode (default = None - Driven by viewport menu) .\n")
	);

TAutoConsoleVariable<int32> CVarRayTracingDebugPickerDomain(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:1337

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderRayTracingDebug

Source code excerpt:

	uint32 DebugVisualizationMode;
	
	FString ConsoleViewMode = CVarRayTracingDebugMode.GetValueOnRenderThread();

	if (!ConsoleViewMode.IsEmpty())
	{
		DebugVisualizationMode = RayTracingDebugVisualizationModes.FindRef(FName(*ConsoleViewMode));
	}
	else if(View.CurrentRayTracingDebugVisualizationMode != NAME_None)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:1709

Scope (from outer to inner):

file
function     bool IsRayTracingInstanceDebugDataEnabled

Source code excerpt:

	}

	FString ConsoleViewMode = CVarRayTracingDebugMode.GetValueOnRenderThread();
	if (!ConsoleViewMode.IsEmpty())
	{
		return RayTracingDebugVisualizationModes.Contains(FName(*ConsoleViewMode));
	}
	else if (View.CurrentRayTracingDebugVisualizationMode != NAME_None)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:1733

Scope (from outer to inner):

file
function     bool IsRayTracingInstanceOverlapEnabled

Source code excerpt:

	}

	FString ConsoleViewMode = CVarRayTracingDebugMode.GetValueOnRenderThread();
	if (!ConsoleViewMode.IsEmpty())
	{
		return RayTracingDebugVisualizationModes.Contains(FName(*ConsoleViewMode));
	}
	else if (View.CurrentRayTracingDebugVisualizationMode != NAME_None)
	{