r.RayTracing.Culling.UseMinDrawDistance
r.RayTracing.Culling.UseMinDrawDistance
#Overview
name: r.RayTracing.Culling.UseMinDrawDistance
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Use min draw distance for culling
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.Culling.UseMinDrawDistance is to control whether the ray tracing system uses the minimum draw distance for culling objects in the scene. This setting is part of the ray tracing culling system in Unreal Engine 5’s rendering pipeline.
Based on the Callsites section, this setting variable is primarily used in the Renderer module, specifically within the ray tracing subsystem. It’s implemented in the RayTracingInstanceCulling.cpp file, which suggests it’s part of the instance culling mechanism for ray tracing.
The value of this variable is set as a console variable using TAutoConsoleVariable. It’s initialized with a default value of 1 (enabled) and can be changed at runtime through the console or configuration files.
This variable interacts with other ray tracing culling variables, such as CVarRayTracingCullingGroupIds and CVarRayTracingCullingPerInstance, as seen in the FRayTracingCullingParameters::Init function.
Developers should be aware that this variable affects the culling behavior in ray tracing. When enabled (set to 1), it will use the minimum draw distance as part of the culling criteria. This can potentially improve performance by reducing the number of objects that need to be processed for ray tracing, but it may also affect visual quality if not configured correctly.
Best practices when using this variable include:
- Testing the impact on performance and visual quality with different settings.
- Considering the interaction with other culling variables and overall ray tracing settings.
- Adjusting the minimum draw distance values for objects in the scene to work effectively with this culling method.
Regarding the associated variable CVarRayTracingCullingUseMinDrawDistance:
This is the actual console variable object that controls the r.RayTracing.Culling.UseMinDrawDistance setting. It’s defined as a static TAutoConsoleVariable
The purpose of CVarRayTracingCullingUseMinDrawDistance is to provide a programmatic way to access and modify the r.RayTracing.Culling.UseMinDrawDistance setting within the C++ code.
This variable is used in the FRayTracingCullingParameters::Init function to set the bCullMinDrawDistance flag, which determines whether minimum draw distance culling is applied during ray tracing.
Developers should be aware that changes to this variable will take effect on the render thread, as indicated by the ECVF_RenderThreadSafe flag used in its declaration.
Best practices for using CVarRayTracingCullingUseMinDrawDistance include:
- Accessing its value using GetValueOnRenderThread() when needed in render thread code.
- Considering thread safety when modifying or reading this value from different threads.
- Using this variable in conjunction with other ray tracing culling parameters for optimal performance and quality balance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingInstanceCulling.cpp:36
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRayTracingCullingUseMinDrawDistance(
TEXT("r.RayTracing.Culling.UseMinDrawDistance"),
1,
TEXT("Use min draw distance for culling"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRayTracingCullingGroupIds(
TEXT("r.RayTracing.Culling.UseGroupIds"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarRayTracingCullingUseMinDrawDistance
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingInstanceCulling.cpp:35
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRayTracingCullingUseMinDrawDistance(
TEXT("r.RayTracing.Culling.UseMinDrawDistance"),
1,
TEXT("Use min draw distance for culling"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRayTracingCullingGroupIds(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingInstanceCulling.cpp:78
Scope (from outer to inner):
file
function void FRayTracingCullingParameters::Init
Source code excerpt:
bIsRayTracingFarField = Lumen::UseFarField(*View.Family);
bCullUsingGroupIds = CVarRayTracingCullingGroupIds.GetValueOnRenderThread() != 0;
bCullMinDrawDistance = CVarRayTracingCullingUseMinDrawDistance.GetValueOnRenderThread() != 0;
bUseInstanceCulling = CVarRayTracingCullingPerInstance.GetValueOnRenderThread() != 0 && bCullAllObjects;
}
namespace RayTracing
{
bool ShouldConsiderCulling(const FRayTracingCullingParameters& CullingParameters, const FBoxSphereBounds& ObjectBounds, float MinDrawDistance)