r.RayTracing.Culling.Radius

r.RayTracing.Culling.Radius

#Overview

name: r.RayTracing.Culling.Radius

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.Culling.Radius is to control the camera culling radius for objects behind the camera in ray tracing effects. It sets a distance threshold beyond which objects are culled from ray tracing calculations, optimizing performance.

This setting variable is primarily used in the Unreal Engine’s rendering system, specifically in the ray tracing subsystem. It’s referenced in the RayTracingInstanceCulling.cpp file, which is part of the Renderer module.

The value of this variable is set using a console variable (CVarRayTracingCullingRadius) with a default value of 30000.0f (300 meters). Developers can modify this value at runtime using console commands or through project settings.

The associated variable CVarRayTracingCullingRadius interacts directly with r.RayTracing.Culling.Radius. It’s used to retrieve the current value of the culling radius in the GetRayTracingCullingRadius() function and when initializing FRayTracingCullingParameters.

Developers should be aware that:

  1. This variable affects performance and visual quality in ray tracing effects.
  2. The value is in Unreal units (1 unit = 1 cm), so 30000 units equal 300 meters.
  3. Changing this value may impact both performance and the appearance of distant objects in ray-traced scenes.

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 relationship between this variable and other ray tracing settings.

Regarding the associated variable CVarRayTracingCullingRadius: Its purpose is to provide a programmatic interface to access and modify the r.RayTracing.Culling.Radius value within the engine’s C++ code. It’s used in the same rendering subsystem and allows for thread-safe access to the culling radius value. The value is typically retrieved using the GetValueOnRenderThread() method, ensuring proper synchronization with the render thread. Developers should use this variable when they need to access or modify the culling radius from within C++ code, rather than directly accessing the console variable.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingInstanceCulling.cpp:24

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarRayTracingCullingRadius(
	TEXT("r.RayTracing.Culling.Radius"),
	30000.0f,
	TEXT("Do camera culling for objects behind the camera outside of this radius in ray tracing effects (default = 30000 (300m))"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarRayTracingCullingAngle(
	TEXT("r.RayTracing.Culling.Angle"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingInstanceCulling.cpp:23

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarRayTracingCullingRadius(
	TEXT("r.RayTracing.Culling.Radius"),
	30000.0f,
	TEXT("Do camera culling for objects behind the camera outside of this radius in ray tracing effects (default = 30000 (300m))"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarRayTracingCullingAngle(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingInstanceCulling.cpp:60

Scope (from outer to inner):

file
function     float GetRayTracingCullingRadius

Source code excerpt:

float GetRayTracingCullingRadius()
{
	return CVarRayTracingCullingRadius.GetValueOnRenderThread();
}

void FRayTracingCullingParameters::Init(FViewInfo& View)
{
	CullingMode = RayTracing::GetCullingMode(View.Family->EngineShowFlags);
	CullingRadius = CVarRayTracingCullingRadius.GetValueOnRenderThread();
	FarFieldCullingRadius = Lumen::GetFarFieldMaxTraceDistance();
	CullAngleThreshold = CVarRayTracingCullingAngle.GetValueOnRenderThread();
	AngleThresholdRatio = FMath::Tan(FMath::Min(89.99f, CullAngleThreshold) * PI / 180.0f);
	AngleThresholdRatioSq = FMath::Square(AngleThresholdRatio);
	ViewOrigin = View.ViewMatrices.GetViewOrigin();
	TranslatedViewOrigin = FVector3f(ViewOrigin + View.ViewMatrices.GetPreViewTranslation());