r.RayTracing.Geometry.StaticMeshes.WPO.CullingRadius

r.RayTracing.Geometry.StaticMeshes.WPO.CullingRadius

#Overview

name: r.RayTracing.Geometry.StaticMeshes.WPO.CullingRadius

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.RayTracing.Geometry.StaticMeshes.WPO.CullingRadius is to control the culling radius for World Position Offset (WPO) evaluation in ray tracing effects for static meshes. It defines a distance threshold beyond which WPO evaluation is skipped for performance optimization.

This setting variable is primarily used in the rendering system, specifically for ray tracing optimization in Unreal Engine 5. It is utilized in the StaticMeshRender module, which is part of the Engine’s core rendering functionality.

The value of this variable is set using a TAutoConsoleVariable, which allows it to be changed at runtime through console commands. Its default value is 12000.0f (120 meters).

The associated variable CVarRayTracingStaticMeshesWPOCullingRadius directly interacts with r.RayTracing.Geometry.StaticMeshes.WPO.CullingRadius, as they share the same value and purpose.

Developers must be aware that this variable affects performance and visual quality in ray tracing effects. Setting it too low may result in visual artifacts for distant objects, while setting it too high may negatively impact performance.

Best practices when using this variable include:

  1. Adjusting it based on the scale and requirements of your specific scene.
  2. Testing different values to find the optimal balance between performance and visual quality.
  3. Considering the typical viewing distances in your game or application when setting this value.

Regarding the associated variable CVarRayTracingStaticMeshesWPOCullingRadius:

Its purpose is identical to r.RayTracing.Geometry.StaticMeshes.WPO.CullingRadius, serving as the actual console variable that controls the culling radius for WPO evaluation in ray tracing.

This variable is used in the FStaticMeshSceneProxy::GetDynamicRayTracingInstances function to determine whether WPO should be evaluated for a given static mesh instance. It compares the distance between the view center and the mesh center against the culling radius plus the mesh’s bounding radius.

The value of this variable is set through the TAutoConsoleVariable declaration and can be modified at runtime using console commands.

Developers should be aware that this variable directly affects the culling behavior for WPO evaluation in ray tracing. Adjusting it can have significant impacts on both performance and visual fidelity, especially for scenes with many static meshes or large open areas.

Best practices for using CVarRayTracingStaticMeshesWPOCullingRadius include:

  1. Profiling your application to determine the optimal value for your specific use case.
  2. Considering the trade-off between performance gains from culling and potential visual artifacts from skipping WPO evaluation.
  3. Potentially exposing this setting as a configurable option for end-users to adjust based on their hardware capabilities.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshRender.cpp:191

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarRayTracingStaticMeshesWPOCullingRadius(
	TEXT("r.RayTracing.Geometry.StaticMeshes.WPO.CullingRadius"),
	12000.0f, // 120 m
	TEXT("Do not evaluate world position offset for static meshes outside of this radius in ray tracing effects (default = 12000 (120m))"));


/** Initialization constructor. */
FStaticMeshSceneProxy::FStaticMeshSceneProxy(UStaticMeshComponent* InComponent, bool bForceLODsShareStaticLighting)

#Associated Variable and Callsites

This variable is associated with another variable named CVarRayTracingStaticMeshesWPOCullingRadius. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshRender.cpp:190

Scope: file

Source code excerpt:

	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
	TEXT("Do not evaluate world position offset for static meshes outside of this radius in ray tracing effects (default = 12000 (120m))"));


/** Initialization constructor. */

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshRender.cpp:1908

Scope (from outer to inner):

file
function     void FStaticMeshSceneProxy::GetDynamicRayTracingInstances

Source code excerpt:

		const FVector ViewCenter = Context.ReferenceView->ViewMatrices.GetViewOrigin();
		const FVector MeshCenter = GetBounds().Origin;
		const float CullingRadius = CVarRayTracingStaticMeshesWPOCullingRadius.GetValueOnRenderThread();
		const float BoundingRadius = GetBounds().SphereRadius;

		if (FVector(ViewCenter - MeshCenter).Size() > (CullingRadius + BoundingRadius))
		{
			bEvaluateWPO = false;
		}