r.RayTracing.DebugVisualizationMode.OpaqueOnly
r.RayTracing.DebugVisualizationMode.OpaqueOnly
#Overview
name: r.RayTracing.DebugVisualizationMode.OpaqueOnly
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Sets whether the view mode rendes opaque objects only (default = 1, render only opaque objects, 0 = render all objects)
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.DebugVisualizationMode.OpaqueOnly is to control the rendering of objects in the ray tracing debug visualization mode. It determines whether only opaque objects are rendered or if all objects are rendered.
This setting variable is primarily used in the ray tracing subsystem of Unreal Engine 5’s rendering module. It is specifically utilized in the debug visualization features of the ray tracing system.
The value of this variable is set through the console variable system in Unreal Engine. It is defined as a TAutoConsoleVariable with a default value of 1, meaning it will render only opaque objects by default.
The associated variable CVarRayTracingDebugModeOpaqueOnly directly interacts with r.RayTracing.DebugVisualizationMode.OpaqueOnly. They share the same value and are used interchangeably in the code.
Developers should be aware that this variable affects the debug visualization of ray tracing. When set to 1 (default), only opaque objects will be rendered in the debug view, which can be useful for isolating issues with opaque geometry. When set to 0, all objects (including transparent ones) will be rendered.
Best practices when using this variable include:
- Use it in conjunction with other ray tracing debug tools to isolate rendering issues.
- Be aware that changing this value may impact performance, especially when rendering all objects.
- Remember to reset it to the default value (1) after debugging to ensure normal visualization behavior.
Regarding the associated variable CVarRayTracingDebugModeOpaqueOnly:
This is the actual C++ variable that controls the behavior defined by r.RayTracing.DebugVisualizationMode.OpaqueOnly. It is used in various ray tracing debug functions, such as RayTracingPerformPicking and RayTracingPerformHitStatsPerPrimitive.
The value of CVarRayTracingDebugModeOpaqueOnly is typically accessed using the GetValueOnRenderThread() method, ensuring thread-safe access in the rendering pipeline.
Developers should note that this variable directly impacts the behavior of ray tracing debug visualizations and should be used carefully when debugging ray tracing issues in their projects.
#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:41
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarRayTracingDebugModeOpaqueOnly(
TEXT("r.RayTracing.DebugVisualizationMode.OpaqueOnly"),
1,
TEXT("Sets whether the view mode rendes opaque objects only (default = 1, render only opaque objects, 0 = render all objects)"),
ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarRayTracingDebugTimingScale(
#Associated Variable and Callsites
This variable is associated with another variable named CVarRayTracingDebugModeOpaqueOnly
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:40
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarRayTracingDebugModeOpaqueOnly(
TEXT("r.RayTracing.DebugVisualizationMode.OpaqueOnly"),
1,
TEXT("Sets whether the view mode rendes opaque objects only (default = 1, render only opaque objects, 0 = render all objects)"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:835
Scope (from outer to inner):
file
function static FRDGBufferRef RayTracingPerformPicking
Source code excerpt:
RayGenParameters->InstancesDebugData = GraphBuilder.CreateSRV(Scene->RayTracingScene.InstanceDebugBuffer);
RayGenParameters->TLAS = Scene->RayTracingScene.GetLayerView(ERayTracingSceneLayer::Base);
RayGenParameters->OpaqueOnly = CVarRayTracingDebugModeOpaqueOnly.GetValueOnRenderThread();
RayGenParameters->InstanceBuffer = GraphBuilder.CreateSRV(Scene->RayTracingScene.InstanceBuffer);
RayGenParameters->ViewUniformBuffer = View.ViewUniformBuffer;
RayGenParameters->SceneUniformBuffer = GetSceneUniformBufferRef(GraphBuilder, View); // TODO: use a separate params structure
RayGenParameters->PickingOutput = GraphBuilder.CreateUAV(PickingBuffer);
GraphBuilder.AddPass(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:1076
Scope (from outer to inner):
file
function static FRDGBufferRef RayTracingPerformHitStatsPerPrimitive
Source code excerpt:
FRayTracingDebugHitStatsRGS::FParameters* RayGenParameters = GraphBuilder.AllocParameters<FRayTracingDebugHitStatsRGS::FParameters>();
RayGenParameters->TLAS = Scene->RayTracingScene.GetLayerView(ERayTracingSceneLayer::Base);
RayGenParameters->OpaqueOnly = CVarRayTracingDebugModeOpaqueOnly.GetValueOnRenderThread();
RayGenParameters->ViewUniformBuffer = View.ViewUniformBuffer;
RayGenParameters->SceneUniformBuffer = GetSceneUniformBufferRef(GraphBuilder, View); // TODO: use a separate params structure
RayGenParameters->RayTracingDebugHitStatsUniformBuffer = DebugHitStatsUniformBuffer;
AddClearUAVPass(GraphBuilder, DebugHitStatsUniformBufferParameters->HitStatsOutput, 0, ERDGPassFlags::Compute);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:1508
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderRayTracingDebug
Source code excerpt:
RayGenParameters->ShouldUsePreExposure = View.Family->EngineShowFlags.Tonemapper;
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;