r.RayTracing.Geometry.GeometryCache

r.RayTracing.Geometry.GeometryCache

#Overview

name: r.RayTracing.Geometry.GeometryCache

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.GeometryCache is to control the inclusion of geometry cache primitives in ray tracing effects within Unreal Engine 5. This setting variable is primarily used in the rendering system, specifically for ray tracing.

This setting variable is utilized by the GeometryCache plugin, which is part of the Unreal Engine’s runtime plugins. Based on the callsites, it’s clear that this variable is used within the GeometryCache module, particularly in the GeometryCacheSceneProxy class.

The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 1, which means geometry cache is enabled in ray tracing by default.

The associated variable CVarRayTracingGeometryCache directly interacts with r.RayTracing.Geometry.GeometryCache. They share the same value and purpose.

Developers must be aware that this variable affects the performance and visual quality of ray tracing effects. Enabling geometry cache in ray tracing (value = 1) will include these primitives in the ray tracing calculations, potentially improving visual quality but at the cost of performance.

Best practices when using this variable include:

  1. Consider the performance impact when enabling geometry cache in ray tracing, especially for complex scenes.
  2. Use it in conjunction with other ray tracing settings for optimal results.
  3. Test the impact of enabling/disabling this feature on both visual quality and performance in your specific use case.

Regarding the associated variable CVarRayTracingGeometryCache:

The purpose of CVarRayTracingGeometryCache is identical to r.RayTracing.Geometry.GeometryCache. It’s the actual console variable implementation that controls the inclusion of geometry cache primitives in ray tracing effects.

This variable is used within the GeometryCache plugin, specifically in the GeometryCacheSceneProxy class. It’s checked in the GetDynamicRayTracingInstances function to determine whether to proceed with including geometry cache in ray tracing calculations.

The value of CVarRayTracingGeometryCache is set at initialization and can be modified at runtime through the console or configuration files.

Developers should be aware that this variable directly controls the behavior of geometry cache in ray tracing. When its value is 0, the GetDynamicRayTracingInstances function will return early, effectively disabling geometry cache in ray tracing.

Best practices for using CVarRayTracingGeometryCache include:

  1. Use it for debugging or performance testing by toggling it at runtime.
  2. Consider exposing it as a user-configurable setting if the performance impact is significant in your game.
  3. Monitor its value when troubleshooting ray tracing issues related to geometry cache.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/GeometryCache/Source/GeometryCache/Private/GeometryCacheSceneProxy.cpp:42

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRayTracingGeometryCache(
	TEXT("r.RayTracing.Geometry.GeometryCache"),
	1,
	TEXT("Include geometry cache primitives in ray tracing effects (default = 1 (geometry cache enabled in ray tracing))"));

/**
* All vertex information except the position.
*/

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/GeometryCache/Source/GeometryCache/Private/GeometryCacheSceneProxy.cpp:41

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarRayTracingGeometryCache(
	TEXT("r.RayTracing.Geometry.GeometryCache"),
	1,
	TEXT("Include geometry cache primitives in ray tracing effects (default = 1 (geometry cache enabled in ray tracing))"));

/**
* All vertex information except the position.

#Loc: <Workspace>/Engine/Plugins/Runtime/GeometryCache/Source/GeometryCache/Private/GeometryCacheSceneProxy.cpp:496

Scope (from outer to inner):

file
function     void FGeometryCacheSceneProxy::GetDynamicRayTracingInstances

Source code excerpt:

void FGeometryCacheSceneProxy::GetDynamicRayTracingInstances(FRayTracingMaterialGatheringContext& Context, TArray<FRayTracingInstance>& OutRayTracingInstances)
{
	if (!CVarRayTracingGeometryCache.GetValueOnRenderThread())
	{
		return;
	}

	FRHICommandListBase& RHICmdList = FRHICommandListImmediate::Get();