r.RayTracing.Geometry.Cable.WPO.Culling

r.RayTracing.Geometry.Cable.WPO.Culling

#Overview

name: r.RayTracing.Geometry.Cable.WPO.Culling

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.Cable.WPO.Culling is to enable or disable culling for World Position Offset (WPO) evaluation for cable meshes in ray tracing. This setting variable is part of the ray tracing system in Unreal Engine 5, specifically focusing on the optimization of cable geometry rendering.

This setting variable is primarily used in the CableComponent plugin, which is part of the Runtime plugins in Unreal Engine. The CableComponent module relies on this variable to determine whether to perform culling during ray tracing calculations for cable meshes.

The value of this variable is set as a console variable (CVar) with a default value of 1, meaning culling is enabled by default. It can be changed at runtime through the console or programmatically.

The associated variable CVarRayTracingCableMeshesWPOCulling interacts directly with r.RayTracing.Geometry.Cable.WPO.Culling, as they share the same value. This variable is used in the code to check the culling state.

Developers should be aware that this variable affects the performance and accuracy of ray-traced cable meshes. When enabled (set to 1), it can improve performance by reducing unnecessary WPO evaluations for cables that are not visible or are far from the camera.

Best practices when using this variable include:

  1. Keep it enabled (set to 1) for better performance in most cases.
  2. Consider disabling it (set to 0) if you notice visual artifacts in cable rendering, especially for cables that should be visible but are being culled incorrectly.
  3. Use in conjunction with r.RayTracing.Geometry.Cable.WPO.CullingRadius to fine-tune the culling behavior.

Regarding the associated variable CVarRayTracingCableMeshesWPOCulling:

The purpose of CVarRayTracingCableMeshesWPOCulling is to provide a programmatic way to access and modify the r.RayTracing.Geometry.Cable.WPO.Culling setting within the C++ code of the CableComponent plugin.

This variable is used in the CableComponent module of the Runtime plugins in Unreal Engine 5. It’s specifically utilized in the ray tracing functionality for cable meshes.

The value of CVarRayTracingCableMeshesWPOCulling is set when the console variable r.RayTracing.Geometry.Cable.WPO.Culling is initialized. It can be accessed and potentially modified at runtime using the GetValueOnRenderThread() method.

CVarRayTracingCableMeshesWPOCulling interacts directly with r.RayTracing.Geometry.Cable.WPO.Culling, as they represent the same setting. It’s also used in conjunction with CVarRayTracingCableMeshesWPOCullingRadius to determine the culling behavior.

Developers should be aware that this variable is used in the GetDynamicRayTracingInstances function of the CableComponent to determine whether to apply WPO culling for ray tracing.

Best practices when using this variable include:

  1. Use GetValueOnRenderThread() to safely access its value in render thread operations.
  2. Consider the performance implications when modifying this value, as it affects ray tracing calculations for all cable meshes.
  3. Coordinate any changes to this variable with the associated console variable to ensure consistency in behavior.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/CableComponent/Source/CableComponent/Private/CableComponent.cpp:31

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRayTracingCableMeshesWPOCulling(
	TEXT("r.RayTracing.Geometry.Cable.WPO.Culling"),
	1,
	TEXT("Enable culling for WPO evaluation for cable meshes in ray tracing (default = 1 (Culling enabled))"));

static TAutoConsoleVariable<float> CVarRayTracingCableMeshesWPOCullingRadius(
	TEXT("r.RayTracing.Geometry.Cable.WPO.CullingRadius"),
	12000.0f, // 120 m

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/CableComponent/Source/CableComponent/Private/CableComponent.cpp:30

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<int32> CVarRayTracingCableMeshesWPOCulling(
	TEXT("r.RayTracing.Geometry.Cable.WPO.Culling"),
	1,
	TEXT("Enable culling for WPO evaluation for cable meshes in ray tracing (default = 1 (Culling enabled))"));

static TAutoConsoleVariable<float> CVarRayTracingCableMeshesWPOCullingRadius(
	TEXT("r.RayTracing.Geometry.Cable.WPO.CullingRadius"),

#Loc: <Workspace>/Engine/Plugins/Runtime/CableComponent/Source/CableComponent/Private/CableComponent.cpp:474

Scope (from outer to inner):

file
function     virtual void GetDynamicRayTracingInstances

Source code excerpt:

		bool bEvaluateWPO = bDynamicRayTracingGeometry && CVarRayTracingCableMeshesWPO.GetValueOnRenderThread() == 1;
		
		if (bEvaluateWPO && CVarRayTracingCableMeshesWPOCulling.GetValueOnRenderThread() > 0)
		{
			const FVector ViewCenter = Context.ReferenceView->ViewMatrices.GetViewOrigin();
			const FVector MeshCenter = GetBounds().Origin;
			const float CullingRadius = CVarRayTracingCableMeshesWPOCullingRadius.GetValueOnRenderThread();
			const float BoundingRadius = GetBounds().SphereRadius;