r.Lumen.Reflections.FixedStateFrameIndex

r.Lumen.Reflections.FixedStateFrameIndex

#Overview

name: r.Lumen.Reflections.FixedStateFrameIndex

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.Lumen.Reflections.FixedStateFrameIndex is to override the View.StateFrameIndex for debugging Lumen Reflections in Unreal Engine 5’s rendering system.

This setting variable is primarily used in the Lumen Reflections subsystem, which is part of the Renderer module in Unreal Engine 5. Based on the callsites, it’s specifically utilized in the LumenReflections.cpp file.

The value of this variable is set through a console variable (CVar) named GVarLumenReflectionsFixedStateFrameIndex. It’s initialized with a default value of -1, indicating that by default, it doesn’t override the View.StateFrameIndex.

The associated variable GVarLumenReflectionsFixedStateFrameIndex interacts directly with r.Lumen.Reflections.FixedStateFrameIndex. They share the same value and purpose.

Developers must be aware that this variable is intended for debugging purposes only. When set to a value greater than or equal to 0, it will override the normal StateFrameIndex calculation, which could affect the behavior of Lumen Reflections.

Best practices when using this variable include:

  1. Only use it for debugging purposes.
  2. Set it back to -1 (or remove the override) when not actively debugging to ensure normal Lumen Reflection behavior.
  3. Be cautious when using in production environments as it may affect performance or visual quality.

Regarding the associated variable GVarLumenReflectionsFixedStateFrameIndex:

Its purpose is to provide a programmatic way to access and modify the r.Lumen.Reflections.FixedStateFrameIndex value within the C++ code.

It’s used in the Lumen Reflections subsystem of the Renderer module, specifically in the RenderLumenReflections function of the FDeferredShadingSceneRenderer class.

The value is set when the console variable is initialized and can be modified at runtime through console commands.

It interacts directly with the r.Lumen.Reflections.FixedStateFrameIndex CVar, effectively controlling the same functionality.

Developers should be aware that this variable is checked on the render thread (GetValueOnRenderThread()), which means changes to it will be applied on the next frame render.

Best practices include using this variable cautiously and only for its intended debugging purpose, ensuring it’s reset to its default value (-1) when not in use to maintain normal Lumen Reflection behavior.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:288

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int> GVarLumenReflectionsFixedStateFrameIndex(
	TEXT("r.Lumen.Reflections.FixedStateFrameIndex"),
	-1,
	TEXT("Whether to override View.StateFrameIndex for debugging Lumen Reflections."),
	ECVF_RenderThreadSafe
);

float GetLumenReflectionSpecularScale()

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:287

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int> GVarLumenReflectionsFixedStateFrameIndex(
	TEXT("r.Lumen.Reflections.FixedStateFrameIndex"),
	-1,
	TEXT("Whether to override View.StateFrameIndex for debugging Lumen Reflections."),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflections.cpp:1058

Scope (from outer to inner):

file
function     FRDGTextureRef FDeferredShadingSceneRenderer::RenderLumenReflections

Source code excerpt:

		ReflectionTracingParameters.PreIntegratedGFSampler = TStaticSamplerState<SF_Bilinear, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI();
		uint32 StateFrameIndex = View.ViewState ? View.ViewState->GetFrameIndex() : 0;
		if (GVarLumenReflectionsFixedStateFrameIndex.GetValueOnRenderThread() >= 0)
		{
			StateFrameIndex = GVarLumenReflectionsFixedStateFrameIndex.GetValueOnRenderThread();
		}

		ReflectionTracingParameters.ReflectionsStateFrameIndex = StateFrameIndex;
		ReflectionTracingParameters.ReflectionsStateFrameIndexMod8 = StateFrameIndex % 8;
		ReflectionTracingParameters.ReflectionsRayDirectionFrameIndex = StateFrameIndex % FMath::Clamp(CVarLumenReflectionTemporalMaxRayDirections.GetValueOnRenderThread(), 1, 128);
	}