r.RayTracing.Geometry.StaticMeshes.WPO.Culling
r.RayTracing.Geometry.StaticMeshes.WPO.Culling
#Overview
name: r.RayTracing.Geometry.StaticMeshes.WPO.Culling
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable culling for WPO evaluation for static meshes in ray tracing (default = 1 (Culling enabled))
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RayTracing.Geometry.StaticMeshes.WPO.Culling is to control the culling of World Position Offset (WPO) evaluation for static meshes in ray tracing. This setting is part of Unreal Engine 5’s ray tracing system, specifically focusing on the rendering of static meshes.
This setting variable is primarily used by the rendering system, particularly the ray tracing subsystem within Unreal Engine 5. It’s implemented in the Engine module, as evidenced by its location in the StaticMeshRender.cpp file.
The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 1, which means culling is enabled by default. Developers can modify this value at runtime using console commands or through project settings.
This variable interacts closely with another variable named CVarRayTracingStaticMeshesWPOCullingRadius, which defines the culling radius for WPO evaluation. Together, these variables control the culling behavior for static meshes in ray tracing scenarios.
Developers should be aware that enabling this culling (default behavior) can potentially improve performance by reducing unnecessary WPO evaluations for static meshes that are far from the viewer. However, it may also introduce artifacts if the culling radius is set too low, causing distant objects to lose their WPO effects.
Best practices when using this variable include:
- Keeping it enabled (value 1) for performance reasons unless specific issues arise.
- Adjusting the culling radius (CVarRayTracingStaticMeshesWPOCullingRadius) in conjunction with this setting to find the right balance between performance and visual quality.
- Testing the impact of this setting in various scenarios, especially in large environments with many static meshes.
Regarding the associated variable CVarRayTracingStaticMeshesWPOCulling:
The purpose of CVarRayTracingStaticMeshesWPOCulling is to serve as the actual console variable that controls the WPO culling for static meshes in ray tracing. It’s the implementation of the r.RayTracing.Geometry.StaticMeshes.WPO.Culling setting.
This variable is used directly in the Engine module, specifically in the FStaticMeshSceneProxy::GetDynamicRayTracingInstances function. This function is responsible for gathering ray tracing instances for static meshes.
The value of CVarRayTracingStaticMeshesWPOCulling is set through the console variable system and can be accessed at runtime using GetValueOnRenderThread().
It interacts with CVarRayTracingStaticMeshesWPOCullingRadius to determine whether WPO evaluation should be performed for a given static mesh based on its distance from the viewer.
Developers should be aware that this variable is checked on the render thread, which means changes to its value will affect rendering in real-time.
Best practices for using CVarRayTracingStaticMeshesWPOCulling include:
- Using it in conjunction with performance profiling tools to measure its impact on rendering performance.
- Considering its effect on visual consistency, especially for large open environments where distant objects might suddenly change appearance.
- Documenting any project-specific settings or modifications to this variable for team-wide consistency.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshRender.cpp:186
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRayTracingStaticMeshesWPOCulling(
TEXT("r.RayTracing.Geometry.StaticMeshes.WPO.Culling"),
1,
TEXT("Enable culling for WPO evaluation for static meshes in ray tracing (default = 1 (Culling enabled))"));
static TAutoConsoleVariable<float> CVarRayTracingStaticMeshesWPOCullingRadius(
TEXT("r.RayTracing.Geometry.StaticMeshes.WPO.CullingRadius"),
12000.0f, // 120 m
#Associated Variable and Callsites
This variable is associated with another variable named CVarRayTracingStaticMeshesWPOCulling
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshRender.cpp:185
Scope: file
Source code excerpt:
}));
static TAutoConsoleVariable<int32> CVarRayTracingStaticMeshesWPOCulling(
TEXT("r.RayTracing.Geometry.StaticMeshes.WPO.Culling"),
1,
TEXT("Enable culling for WPO evaluation for static meshes in ray tracing (default = 1 (Culling enabled))"));
static TAutoConsoleVariable<float> CVarRayTracingStaticMeshesWPOCullingRadius(
TEXT("r.RayTracing.Geometry.StaticMeshes.WPO.CullingRadius"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshRender.cpp:1904
Scope (from outer to inner):
file
function void FStaticMeshSceneProxy::GetDynamicRayTracingInstances
Source code excerpt:
bool bEvaluateWPO = bDynamicRayTracingGeometry;
if (bEvaluateWPO && CVarRayTracingStaticMeshesWPOCulling.GetValueOnRenderThread() > 0)
{
const FVector ViewCenter = Context.ReferenceView->ViewMatrices.GetViewOrigin();
const FVector MeshCenter = GetBounds().Origin;
const float CullingRadius = CVarRayTracingStaticMeshesWPOCullingRadius.GetValueOnRenderThread();
const float BoundingRadius = GetBounds().SphereRadius;