r.RayTracing.DebugTriangleHitCountPerInstance.MaxThreshold

r.RayTracing.DebugTriangleHitCountPerInstance.MaxThreshold

#Overview

name: r.RayTracing.DebugTriangleHitCountPerInstance.MaxThreshold

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.RayTracing.DebugTriangleHitCountPerInstance.MaxThreshold is to set the maximum hit count threshold for debug ray tracing hit count per instance heat map visualization in Unreal Engine 5’s ray tracing system.

This setting variable is primarily used in the rendering system, specifically within the ray tracing debug functionality. It is part of Unreal Engine’s Renderer module, which is responsible for handling various rendering tasks, including ray tracing debug visualizations.

The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with a default value of 100,000. This means that developers can change this value at runtime through console commands or configuration files.

The associated variable CVarRayTracingDebugHitCountPerInstanceMaxThreshold directly interacts with r.RayTracing.DebugTriangleHitCountPerInstance.MaxThreshold. They share the same value and purpose.

Developers should be aware that this variable affects the visualization of ray tracing hit counts per instance. It sets an upper limit for the heat map visualization, which can be crucial for performance and visual clarity when debugging ray tracing behavior.

Best practices when using this variable include:

  1. Adjusting the value based on the complexity of the scene and the expected hit counts.
  2. Using it in conjunction with other ray tracing debug variables for comprehensive analysis.
  3. Be mindful of potential performance impacts when setting very high values, especially in complex scenes.

Regarding the associated variable CVarRayTracingDebugHitCountPerInstanceMaxThreshold:

This is the C++ implementation of the console variable. It’s used internally by the engine to access and modify the value set by r.RayTracing.DebugTriangleHitCountPerInstance.MaxThreshold.

The value is accessed in the RenderRayTracingDebug function of the FDeferredShadingSceneRenderer class. Here, it’s used to set the TriangleHitCountPerInstanceMaxThreshold parameter for ray tracing debug visualization. The value is clamped to a minimum of 1 to ensure valid operation.

Developers working directly with the C++ code should use this variable when they need to programmatically access or modify the threshold value within the rendering pipeline. It’s important to note that any changes made to this variable will directly affect the debug visualization of ray tracing hit counts per instance.

#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:96

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRayTracingDebugHitCountPerInstanceMaxThreshold(
	TEXT("r.RayTracing.DebugTriangleHitCountPerInstance.MaxThreshold"),
	100000,
	TEXT("Maximum hit count threshold for debug ray tracing hit count per instance heat map visualization. (default = 100000)\n")
);

static TAutoConsoleVariable<int32> CVarRayTracingDebugHitCountTopKHits(
	TEXT("r.RayTracing.DebugTriangleHitCount.TopKMostHits"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarRayTracingDebugHitCountPerInstanceMaxThreshold(
	TEXT("r.RayTracing.DebugTriangleHitCountPerInstance.MaxThreshold"),
	100000,
	TEXT("Maximum hit count threshold for debug ray tracing hit count per instance heat map visualization. (default = 100000)\n")
);

static TAutoConsoleVariable<int32> CVarRayTracingDebugHitCountTopKHits(

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

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderRayTracingDebug

Source code excerpt:

	RayGenParameters->OpaqueOnly = CVarRayTracingDebugModeOpaqueOnly.GetValueOnRenderThread();
	RayGenParameters->TriangleHitCountMaxThreshold = FMath::Clamp((float)CVarRayTracingDebugHitCountMaxThreshold.GetValueOnRenderThread(), 1, 100000);
	RayGenParameters->TriangleHitCountPerInstanceMaxThreshold = FMath::Max(1, CVarRayTracingDebugHitCountPerInstanceMaxThreshold.GetValueOnRenderThread());
	RayGenParameters->RayTracingDebugHitStatsUniformBuffer = DebugHitStatsUniformBuffer;
	RayGenParameters->LightGridPacked = View.RayTracingLightGridUniformBuffer;
	RayGenParameters->TopKMostHitInstances = CVarRayTracingDebugHitCountTopKHits.GetValueOnRenderThread();
	RayGenParameters->NumTotalInstances = NumInstances;