r.RayTracing.DynamicGeometryLastRenderTimeUpdateDistance
r.RayTracing.DynamicGeometryLastRenderTimeUpdateDistance
#Overview
name: r.RayTracing.DynamicGeometryLastRenderTimeUpdateDistance
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Dynamic geometries within this distance will have their LastRenderTime updated, so that visibility based ticking (like skeletal mesh) can work when the component is not directly visible in the view (but reflected).
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.DynamicGeometryLastRenderTimeUpdateDistance is to control the distance threshold for updating the LastRenderTime of dynamic geometries in ray tracing scenarios. This setting is part of the ray tracing system in Unreal Engine 5.
This setting variable is primarily used in the Renderer module, specifically within the ray tracing subsystem. It’s referenced in the RayTracing.cpp file, which is part of the core rendering functionality for ray tracing features.
The value of this variable is set using a TAutoConsoleVariable, which means it can be adjusted at runtime through console commands or configuration files. The default value is set to 5000.0 units.
This variable interacts closely with the visibility system and component updating mechanism. It determines which dynamic geometries should have their LastRenderTime updated based on their distance from the viewer, even if they’re not directly visible but potentially reflected in ray-traced surfaces.
Developers should be aware that this variable affects performance and visual consistency. Setting it too high might cause unnecessary updates to objects far from the camera, while setting it too low might cause visual inconsistencies in reflections or other ray-traced effects.
Best practices for using this variable include:
- Adjusting it based on the scale and requirements of your specific scene.
- Monitoring performance impact when changing this value.
- Considering the trade-off between visual accuracy and performance.
Regarding the associated variable CVarRayTracingDynamicGeometryLastRenderTimeUpdateDistance:
This is the actual console variable that stores and provides access to the r.RayTracing.DynamicGeometryLastRenderTimeUpdateDistance value. It’s used in the same context and for the same purpose as described above.
The value of this variable is accessed using the GetValueOnRenderThread() method, which ensures thread-safe access to the current value.
Developers should use this variable when they need to programmatically access or modify the distance threshold in C++ code. It’s important to note that changes to this variable will immediately affect the ray tracing behavior, so it should be used cautiously and with consideration for potential performance impacts.
Best practices for using CVarRayTracingDynamicGeometryLastRenderTimeUpdateDistance include:
- Accessing it only on the render thread to avoid race conditions.
- Considering caching its value if used frequently to reduce overhead.
- Using it in conjunction with other ray tracing settings for a cohesive rendering strategy.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracing.cpp:41
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarRayTracingDynamicGeometryLastRenderTimeUpdateDistance(
TEXT("r.RayTracing.DynamicGeometryLastRenderTimeUpdateDistance"),
5000.0f,
TEXT("Dynamic geometries within this distance will have their LastRenderTime updated, so that visibility based ticking (like skeletal mesh) can work when the component is not directly visible in the view (but reflected)."));
static TAutoConsoleVariable<int32> CVarRayTracingAutoInstance(
TEXT("r.RayTracing.AutoInstance"),
1,
#Associated Variable and Callsites
This variable is associated with another variable named CVarRayTracingDynamicGeometryLastRenderTimeUpdateDistance
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracing.cpp:40
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarRayTracingDynamicGeometryLastRenderTimeUpdateDistance(
TEXT("r.RayTracing.DynamicGeometryLastRenderTimeUpdateDistance"),
5000.0f,
TEXT("Dynamic geometries within this distance will have their LastRenderTime updated, so that visibility based ticking (like skeletal mesh) can work when the component is not directly visible in the view (but reflected)."));
static TAutoConsoleVariable<int32> CVarRayTracingAutoInstance(
TEXT("r.RayTracing.AutoInstance"),
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracing.cpp:1018
Scope (from outer to inner):
file
namespace RayTracing
function bool GatherWorldInstancesForView
Source code excerpt:
}
if (CVarRayTracingDynamicGeometryLastRenderTimeUpdateDistance.GetValueOnRenderThread() > 0.0f)
{
if (FVector::Distance(SceneProxy->GetActorPosition(), View.ViewMatrices.GetViewOrigin()) < CVarRayTracingDynamicGeometryLastRenderTimeUpdateDistance.GetValueOnRenderThread())
{
// Update LastRenderTime for components so that visibility based ticking (like skeletal meshes) can get updated
// We are only doing this for dynamic geometries now
SceneInfo->LastRenderTime = CurrentWorldTime;
SceneInfo->UpdateComponentLastRenderTime(CurrentWorldTime, /*bUpdateLastRenderTimeOnScreen=*/true);
}