r.RayTracing.Geometry.InstancedStaticMeshes.LowScaleCullRadius
r.RayTracing.Geometry.InstancedStaticMeshes.LowScaleCullRadius
#Overview
name: r.RayTracing.Geometry.InstancedStaticMeshes.LowScaleCullRadius
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Cull radius for small instances (default = 1000 (10m))
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.Geometry.InstancedStaticMeshes.LowScaleCullRadius is to define a cull radius for small instanced static meshes in ray tracing geometry. This setting is part of Unreal Engine’s ray tracing optimization system, specifically targeting instanced static meshes.
This setting variable is primarily used in the Unreal Engine’s rendering system, particularly in the ray tracing subsystem. It’s utilized within the Engine module, as evidenced by its location in the InstancedStaticMesh.cpp file.
The value of this variable is set as a console variable (CVar) with a default value of 1000.0f, which represents 10 meters in Unreal Engine’s unit system. This setting can be adjusted at runtime through the console or configuration files.
This variable interacts closely with two other variables:
- r.RayTracing.Geometry.InstancedStaticMeshes.LowScaleRadiusThreshold (CVarRayTracingInstancesLowScaleThreshold)
- r.RayTracing.Geometry.InstancedStaticMeshes.CullClusterRadius (CVarRayTracingInstancesCullClusterRadius)
These variables work together to optimize ray tracing performance by culling small instanced static meshes beyond a certain distance.
Developers must be aware that this variable affects the culling of small instanced static meshes in ray tracing. Adjusting this value will impact the distance at which small instances are culled, potentially affecting both performance and visual fidelity.
Best practices when using this variable include:
- Balancing between performance and visual quality. A larger value will cull more instances, improving performance but potentially reducing visual fidelity at a distance.
- Considering the scale of your game world when setting this value.
- Testing thoroughly with different values to find the optimal setting for your specific use case.
Regarding the associated variable CVarRayTracingInstancesLowScaleCullRadius:
This is the actual C++ variable that stores the value of the r.RayTracing.Geometry.InstancedStaticMeshes.LowScaleCullRadius console variable. It’s used in the GetDynamicRayTracingInstances function of the FInstancedStaticMeshSceneProxy class to determine the culling radius for small instanced static meshes.
The purpose of this variable is the same as r.RayTracing.Geometry.InstancedStaticMeshes.LowScaleCullRadius, serving as the C++ representation of the console variable.
It’s used in conjunction with CVarRayTracingInstancesLowScaleThreshold to determine which instances should be culled based on their size and distance from the viewer.
Developers should be aware that changes to the console variable will directly affect this C++ variable, and vice versa. When modifying the engine code, ensure that any changes to this variable are consistent with the intended behavior of the console variable.
Best practices for using this variable in C++ code include:
- Always access its value using the GetValueOnRenderThread() method to ensure thread-safety.
- Consider the performance implications when using this value in frequently called functions.
- Document any code that relies on or modifies this variable to maintain clarity for other developers.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:136
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarRayTracingInstancesLowScaleCullRadius(
TEXT("r.RayTracing.Geometry.InstancedStaticMeshes.LowScaleCullRadius"),
1000.0f,
TEXT("Cull radius for small instances (default = 1000 (10m))"));
static TAutoConsoleVariable<float> CVarRayTracingInstancesCullAngle(
TEXT("r.RayTracing.Geometry.InstancedStaticMeshes.CullAngle"),
2.0f,
#Associated Variable and Callsites
This variable is associated with another variable named CVarRayTracingInstancesLowScaleCullRadius
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:132
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarRayTracingInstancesLowScaleThreshold(
TEXT("r.RayTracing.Geometry.InstancedStaticMeshes.LowScaleRadiusThreshold"),
50.0f, // Instances with a radius smaller than this threshold get culled after CVarRayTracingInstancesLowScaleCullRadius
TEXT("Threshold that classifies instances as small (default = 50cm))"));
static TAutoConsoleVariable<float> CVarRayTracingInstancesLowScaleCullRadius(
TEXT("r.RayTracing.Geometry.InstancedStaticMeshes.LowScaleCullRadius"),
1000.0f,
TEXT("Cull radius for small instances (default = 1000 (10m))"));
static TAutoConsoleVariable<float> CVarRayTracingInstancesCullAngle(
TEXT("r.RayTracing.Geometry.InstancedStaticMeshes.CullAngle"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:1743
Scope (from outer to inner):
file
function void FInstancedStaticMeshSceneProxy::GetDynamicRayTracingInstances
Source code excerpt:
const float BVHCullRadius = CVarRayTracingInstancesCullClusterRadius.GetValueOnRenderThread();
const float BVHLowScaleThreshold = CVarRayTracingInstancesLowScaleThreshold.GetValueOnRenderThread();
const float BVHLowScaleRadius = CVarRayTracingInstancesLowScaleCullRadius.GetValueOnRenderThread();
const bool ApplyGeneralCulling = BVHCullRadius > 0.0f;
const bool ApplyLowScaleCulling = BVHLowScaleThreshold > 0.0f && BVHLowScaleRadius > 0.0f;
for (uint32 InstanceIndex = 0; InstanceIndex < InstanceCount; InstanceIndex++)
{
float InstanceRadius, DistanceToInstanceCenter, DistanceToInstanceStart;