r.RayTracing.Culling.UseGroupIds

r.RayTracing.Culling.UseGroupIds

#Overview

name: r.RayTracing.Culling.UseGroupIds

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.UseGroupIds is to control the culling method used in ray tracing. Specifically, it determines whether to use aggregate ray tracing group ID bounds for culling instead of primitive or instance bounds.

This setting variable is primarily used in the ray tracing subsystem of Unreal Engine 5’s rendering module. Based on the callsites, it’s utilized in the RayTracingInstanceCulling.cpp file, which is part of the Renderer module.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0, meaning it’s disabled by default. Developers can change this value at runtime using console commands or through configuration files.

The associated variable CVarRayTracingCullingGroupIds directly interacts with r.RayTracing.Culling.UseGroupIds. They share the same value and purpose.

Developers must be aware that enabling this variable (setting it to a non-zero value) will change the culling behavior in ray tracing. Instead of using primitive or instance bounds, the system will use aggregate ray tracing group ID bounds for culling when they are defined.

Best practices when using this variable include:

  1. Testing performance with both enabled and disabled states, as the optimal setting may vary depending on the scene complexity and hardware.
  2. Considering the impact on visual quality, as different culling methods may affect which objects are included in ray tracing calculations.
  3. Using in conjunction with other ray tracing culling options for optimal performance.

Regarding the associated variable CVarRayTracingCullingGroupIds:

The purpose of CVarRayTracingCullingGroupIds is the same as r.RayTracing.Culling.UseGroupIds. It’s an internal representation of the console variable in the C++ code.

This variable is used in the Renderer module, specifically in the ray tracing culling system.

Its value is set through the TAutoConsoleVariable template, which ties it to the r.RayTracing.Culling.UseGroupIds console command.

It interacts directly with the r.RayTracing.Culling.UseGroupIds setting and is used to retrieve the current value in the C++ code.

Developers should be aware that this variable is accessed on the render thread, as indicated by the GetValueOnRenderThread() method used in the code.

Best practices include ensuring thread-safety when accessing this variable and considering its performance implications in the ray tracing pipeline.

#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:42

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRayTracingCullingGroupIds(
	TEXT("r.RayTracing.Culling.UseGroupIds"),
	0,
	TEXT("Cull using aggregate ray tracing group id bounds when defined instead of primitive or instance bounds."),
	ECVF_RenderThreadSafe);

RayTracing::ECullingMode RayTracing::GetCullingMode(const FEngineShowFlags& ShowFlags)
{

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarRayTracingCullingGroupIds(
	TEXT("r.RayTracing.Culling.UseGroupIds"),
	0,
	TEXT("Cull using aggregate ray tracing group id bounds when defined instead of primitive or instance bounds."),
	ECVF_RenderThreadSafe);

RayTracing::ECullingMode RayTracing::GetCullingMode(const FEngineShowFlags& ShowFlags)

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

Scope (from outer to inner):

file
function     void FRayTracingCullingParameters::Init

Source code excerpt:

	bCullByRadiusOrDistance = CullingMode == RayTracing::ECullingMode::DistanceOrSolidAngle;
	bIsRayTracingFarField = Lumen::UseFarField(*View.Family);
	bCullUsingGroupIds = CVarRayTracingCullingGroupIds.GetValueOnRenderThread() != 0;
	bCullMinDrawDistance = CVarRayTracingCullingUseMinDrawDistance.GetValueOnRenderThread() != 0;
	bUseInstanceCulling = CVarRayTracingCullingPerInstance.GetValueOnRenderThread() != 0 && bCullAllObjects;
}

namespace RayTracing
{