r.Shadow.RecordInteractionShadowPrimitives

r.Shadow.RecordInteractionShadowPrimitives

#Overview

name: r.Shadow.RecordInteractionShadowPrimitives

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.Shadow.RecordInteractionShadowPrimitives is to control the recording of interaction shadow primitives in the rendering system of Unreal Engine 5. This setting is specifically related to the shadow rendering subsystem.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, as evidenced by its location in the “LightSceneInfo.cpp” file within the Renderer’s private directory.

The value of this variable is set through the FAutoConsoleVariableRef constructor, which creates a console variable that can be modified at runtime. By default, it is set to 1 (enabled).

This variable interacts directly with the associated variable GRecordInteractionShadowPrimitives. They share the same value, with the console variable r.Shadow.RecordInteractionShadowPrimitives controlling the value of GRecordInteractionShadowPrimitives.

Developers must be aware that this variable affects the behavior of shadow rendering, particularly for non-directional lights. It determines whether interaction shadow primitives are recorded for these lights.

Best practices when using this variable include:

  1. Understanding its impact on performance and visual quality before modifying it.
  2. Testing thoroughly after changing its value, as it may affect shadow rendering across the entire scene.
  3. Using it in conjunction with other shadow-related settings for optimal results.

Regarding the associated variable GRecordInteractionShadowPrimitives:

The purpose of GRecordInteractionShadowPrimitives is to serve as the internal representation of the r.Shadow.RecordInteractionShadowPrimitives console variable within the engine’s C++ code.

This variable is used directly in the FLightSceneInfo constructor to initialize the bRecordInteractionShadowPrimitives member variable. It affects non-directional lights, as directional lights are explicitly excluded from this behavior.

The value of GRecordInteractionShadowPrimitives is set by the console variable system and can be changed at runtime.

Developers should be aware that changes to r.Shadow.RecordInteractionShadowPrimitives will directly affect GRecordInteractionShadowPrimitives, which in turn influences the behavior of FLightSceneInfo instances for non-directional lights.

Best practices for using GRecordInteractionShadowPrimitives include:

  1. Avoiding direct modification of this variable in code, instead using the console variable for changes.
  2. Considering its performance implications, especially in scenes with many non-directional lights.
  3. Using it in conjunction with other lighting and shadow optimizations for best results.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

static int32 GRecordInteractionShadowPrimitives = 1;
FAutoConsoleVariableRef CVarRecordInteractionShadowPrimitives(
	TEXT("r.Shadow.RecordInteractionShadowPrimitives"),
	GRecordInteractionShadowPrimitives,
	TEXT(""),
	ECVF_RenderThreadSafe);

void FLightSceneInfoCompact::Init(FLightSceneInfo* InLightSceneInfo)
{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightSceneInfo.cpp:21

Scope: file

Source code excerpt:

	);

static int32 GRecordInteractionShadowPrimitives = 1;
FAutoConsoleVariableRef CVarRecordInteractionShadowPrimitives(
	TEXT("r.Shadow.RecordInteractionShadowPrimitives"),
	GRecordInteractionShadowPrimitives,
	TEXT(""),
	ECVF_RenderThreadSafe);

void FLightSceneInfoCompact::Init(FLightSceneInfo* InLightSceneInfo)
{
	LightSceneInfo = InLightSceneInfo;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightSceneInfo.cpp:47

Scope (from outer to inner):

file
function     FLightSceneInfo::FLightSceneInfo

Source code excerpt:


FLightSceneInfo::FLightSceneInfo(FLightSceneProxy* InProxy, bool InbVisible)
	: bRecordInteractionShadowPrimitives(!!GRecordInteractionShadowPrimitives && InProxy->GetLightType() != ELightComponentType::LightType_Directional)
	, DynamicInteractionOftenMovingPrimitiveList(NULL)
	, DynamicInteractionStaticPrimitiveList(NULL)
	, Proxy(InProxy)
	, Id(INDEX_NONE)
	, DynamicShadowMapChannel(-1)
	, bPrecomputedLightingIsValid(InProxy->GetLightComponent()->IsPrecomputedLightingValid())