r.RayTracing.DebugTriangleHitCount.MaxThreshold
r.RayTracing.DebugTriangleHitCount.MaxThreshold
#Overview
name: r.RayTracing.DebugTriangleHitCount.MaxThreshold
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Maximum hit count threshold for debug ray tracing triangle hit count heat map visualization. (default = 6)\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.DebugTriangleHitCount.MaxThreshold is to set the maximum hit count threshold for debug ray tracing triangle hit count heat map visualization in Unreal Engine 5’s ray tracing system.
This setting variable is primarily used in the rendering system, specifically in the ray tracing debug visualization subsystem. It’s part of Unreal Engine’s Renderer module, as evident from its location in the RayTracingDebug.cpp file within the Renderer/Private/RayTracing directory.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 6, but can be changed at runtime through console commands or project settings.
This variable interacts with other ray tracing debug settings, particularly with CVarRayTracingDebugHitCountPerInstanceMaxThreshold, which is defined right after it in the source code.
Developers should be aware that this variable affects the visualization of ray tracing debug information. It determines the upper limit of the heat map used to visualize triangle hit counts in ray tracing. A higher value will allow for a wider range of hit counts to be distinctly visualized, while a lower value might make it easier to spot areas with relatively high hit counts.
Best practices when using this variable include:
- Adjusting it based on the complexity of your scene and the specific debugging needs.
- Using it in conjunction with other ray tracing debug variables for a comprehensive understanding of ray tracing performance.
- Being mindful that very high values might make it difficult to distinguish between different hit count levels in the visualization.
Regarding the associated variable CVarRayTracingDebugHitCountMaxThreshold:
The purpose of CVarRayTracingDebugHitCountMaxThreshold is to store and provide access to the value set by r.RayTracing.DebugTriangleHitCount.MaxThreshold. It’s an internal representation of the console variable.
This variable is used directly in the rendering code, specifically in the RenderRayTracingDebug function of the FDeferredShadingSceneRenderer class. Its value is retrieved using the GetValueOnRenderThread() method, clamped between 1 and 100000, and then assigned to the TriangleHitCountMaxThreshold parameter of the ray tracing debug shader.
Developers should be aware that changes to r.RayTracing.DebugTriangleHitCount.MaxThreshold will be reflected in CVarRayTracingDebugHitCountMaxThreshold, and it’s this latter variable that’s actually used in the rendering code.
Best practices include using the console variable (r.RayTracing.DebugTriangleHitCount.MaxThreshold) for runtime adjustments and debugging, while being aware that the internal CVarRayTracingDebugHitCountMaxThreshold is what’s directly accessed in the code.
#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:90
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRayTracingDebugHitCountMaxThreshold(
TEXT("r.RayTracing.DebugTriangleHitCount.MaxThreshold"),
6,
TEXT("Maximum hit count threshold for debug ray tracing triangle hit count heat map visualization. (default = 6)\n")
);
static TAutoConsoleVariable<int32> CVarRayTracingDebugHitCountPerInstanceMaxThreshold(
TEXT("r.RayTracing.DebugTriangleHitCountPerInstance.MaxThreshold"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarRayTracingDebugHitCountMaxThreshold
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:89
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarRayTracingDebugHitCountMaxThreshold(
TEXT("r.RayTracing.DebugTriangleHitCount.MaxThreshold"),
6,
TEXT("Maximum hit count threshold for debug ray tracing triangle hit count heat map visualization. (default = 6)\n")
);
static TAutoConsoleVariable<int32> CVarRayTracingDebugHitCountPerInstanceMaxThreshold(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:1509
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderRayTracingDebug
Source code excerpt:
RayGenParameters->TimingScale = CVarRayTracingDebugTimingScale.GetValueOnAnyThread() / 25000.0f;
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;