r.RayTracing.Debug.InstanceOverlap.BoundingBoxScale
r.RayTracing.Debug.InstanceOverlap.BoundingBoxScale
#Overview
name: r.RayTracing.Debug.InstanceOverlap.BoundingBoxScale
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Scaling factor for instance bounding box extent for avoiding z-fighting. (default = 1.001)\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.Debug.InstanceOverlap.BoundingBoxScale is to provide a scaling factor for instance bounding box extents in ray tracing debug visualization. This setting is specifically used to avoid z-fighting issues when rendering debug information for ray tracing instances.
This setting variable is primarily used in the Renderer module of Unreal Engine 5, specifically within the ray tracing debug subsystem. It’s part of the ray tracing debugging tools that help developers visualize and troubleshoot ray tracing-related issues.
The value of this variable is set through the Unreal Engine console variable system. It’s defined with a default value of 1.001f, which means the bounding boxes are slightly enlarged by 0.1% to prevent z-fighting.
This variable interacts with other ray tracing debug settings, particularly those related to instance overlap visualization. It’s used in conjunction with CVarRayTracingDebugInstanceOverlapShowWireframe, which determines whether to show the wireframe representation of the instances.
Developers must be aware that this variable affects the visual representation of ray tracing instances in debug mode. Adjusting this value can help in situations where z-fighting is occurring in the debug visualization, but it doesn’t affect the actual ray tracing calculations in the game.
Best practices when using this variable include:
- Only modify it when experiencing z-fighting issues in ray tracing debug visualization.
- Keep the value close to 1.0 to maintain accurate representation of instance sizes.
- Use in conjunction with other ray tracing debug tools for comprehensive troubleshooting.
Regarding the associated variable CVarRayTracingDebugInstanceOverlapBoundingBoxScale:
This is the actual console variable object that stores and manages the r.RayTracing.Debug.InstanceOverlap.BoundingBoxScale setting. It’s defined using the TAutoConsoleVariable template, which is part of Unreal Engine’s console variable system.
The purpose of this variable is the same as r.RayTracing.Debug.InstanceOverlap.BoundingBoxScale - it’s the implementation detail that allows the engine to access and modify the setting value.
This variable is used directly in the ray tracing debug rendering code. Specifically, it’s accessed in the RayTracingDrawInstances function to set the bounding box extent scale for the vertex shader parameters.
Developers should be aware that changes to this console variable will take effect on the render thread, as evidenced by the use of GetValueOnRenderThread() when accessing its value.
Best practices for using this variable include:
- Access it using the GetValueOnRenderThread() method when used in render thread operations.
- Avoid frequent changes to this value during runtime, as it may impact performance.
- Consider exposing this setting through the game’s debug menu if frequent adjustments are necessary during development.
#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:72
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarRayTracingDebugInstanceOverlapBoundingBoxScale(
TEXT("r.RayTracing.Debug.InstanceOverlap.BoundingBoxScale"),
1.001f,
TEXT("Scaling factor for instance bounding box extent for avoiding z-fighting. (default = 1.001)\n")
);
static TAutoConsoleVariable<int32> CVarRayTracingDebugInstanceOverlapShowWireframe(
TEXT("r.RayTracing.Debug.InstanceOverlap.ShowWireframe"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarRayTracingDebugInstanceOverlapBoundingBoxScale
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:71
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<float> CVarRayTracingDebugInstanceOverlapBoundingBoxScale(
TEXT("r.RayTracing.Debug.InstanceOverlap.BoundingBoxScale"),
1.001f,
TEXT("Scaling factor for instance bounding box extent for avoiding z-fighting. (default = 1.001)\n")
);
static TAutoConsoleVariable<int32> CVarRayTracingDebugInstanceOverlapShowWireframe(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:1179
Scope (from outer to inner):
file
function static void RayTracingDrawInstances
Source code excerpt:
PassParameters->VS.Scene = View.GetSceneUniforms().GetBuffer(GraphBuilder);
PassParameters->VS.InstanceGPUSceneIndices = GraphBuilder.CreateSRV(InstanceGPUSceneIndexBuffer);
PassParameters->VS.BoundingBoxExtentScale = CVarRayTracingDebugInstanceOverlapBoundingBoxScale.GetValueOnRenderThread();
PassParameters->PS.View = View.ViewUniformBuffer;
const uint32 NumInstances = InstanceGPUSceneIndexBuffer->GetSize() / InstanceGPUSceneIndexBuffer->GetStride();
PassParameters->RenderTargets[0] = FRenderTargetBinding(OutputTexture, bWireframe ? ERenderTargetLoadAction::ELoad : ERenderTargetLoadAction::EClear);