r.LumenScene.SurfaceCache.ResampleLighting

r.LumenScene.SurfaceCache.ResampleLighting

#Overview

name: r.LumenScene.SurfaceCache.ResampleLighting

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.LumenScene.SurfaceCache.ResampleLighting is to control whether card lighting is resampled when cards are reallocated in the Lumen scene rendering system. This setting is primarily used for the Lumen global illumination system in Unreal Engine 5.

This setting variable is used in the Lumen scene rendering subsystem, which is part of the Renderer module in Unreal Engine 5. Specifically, it’s used in the surface cache component of Lumen, which is responsible for caching and managing lighting information for scene surfaces.

The value of this variable is set using the Unreal Engine console variable system. It’s initialized to 1 (enabled) by default, but can be changed at runtime through the console or configuration files.

The associated C++ variable GLumenSceneSurfaceCacheResampleLighting directly interacts with this setting. They share the same value, with the console variable acting as an interface for developers and the C++ variable being used in the actual rendering code.

Developers should be aware that this setting is crucial for Radiosity temporal accumulation. Disabling it may affect the quality and stability of global illumination, especially in scenes with dynamic geometry or lighting changes.

Best practices when using this variable include:

  1. Keeping it enabled (set to 1) for normal usage to ensure proper Radiosity temporal accumulation.
  2. Only disabling it temporarily for debugging purposes when investigating specific issues related to card lighting or reallocation.
  3. Being cautious when changing this setting in a shipping game, as it may significantly impact visual quality and performance.

Regarding the associated variable GLumenSceneSurfaceCacheResampleLighting:

The purpose of GLumenSceneSurfaceCacheResampleLighting is to provide a C++ accessible version of the r.LumenScene.SurfaceCache.ResampleLighting setting. It’s used directly in the rendering code to determine whether to perform the resampling operation.

This variable is used in the Lumen scene rendering and surface cache systems within the Renderer module.

Its value is set by the console variable system when r.LumenScene.SurfaceCache.ResampleLighting is modified.

It interacts directly with the rendering code, controlling whether certain lighting resampling operations are performed during the Lumen scene rendering process.

Developers should be aware that modifying this variable directly in C++ code is not recommended. Instead, they should use the console variable r.LumenScene.SurfaceCache.ResampleLighting to change its value.

Best practices for this variable include:

  1. Treating it as read-only in most cases, relying on the console variable system to modify its value.
  2. Using it in conditional statements to enable or disable specific lighting resampling operations in the rendering code.
  3. Ensuring that any code depending on this variable gracefully handles both enabled and disabled states.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneRendering.cpp:186

Scope: file

Source code excerpt:

int32 GLumenSceneSurfaceCacheResampleLighting = 1;
FAutoConsoleVariableRef CVarLumenSceneSurfaceCacheResampleLighting(
	TEXT("r.LumenScene.SurfaceCache.ResampleLighting"),
	GLumenSceneSurfaceCacheResampleLighting,
	TEXT("Whether to resample card lighting when cards are reallocated.  This is needed for Radiosity temporal accumulation but can be disabled for debugging."),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarLumenSceneSurfaceCacheNaniteMultiView(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneRendering.cpp:184

Scope: file

Source code excerpt:

);

int32 GLumenSceneSurfaceCacheResampleLighting = 1;
FAutoConsoleVariableRef CVarLumenSceneSurfaceCacheResampleLighting(
	TEXT("r.LumenScene.SurfaceCache.ResampleLighting"),
	GLumenSceneSurfaceCacheResampleLighting,
	TEXT("Whether to resample card lighting when cards are reallocated.  This is needed for Radiosity temporal accumulation but can be disabled for debugging."),
	ECVF_RenderThreadSafe
);

static TAutoConsoleVariable<int32> CVarLumenSceneSurfaceCacheNaniteMultiView(
	TEXT("r.LumenScene.SurfaceCache.NaniteMultiView"),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSceneRendering.cpp:1314

Scope: file

Source code excerpt:

	FResampledCardCaptureAtlas& CardCaptureAtlas)
{
	if (GLumenSceneSurfaceCacheResampleLighting
		&& FrameTemporaries.PageTableBufferSRV
		&& FrameTemporaries.CardBufferSRV)
	{
		AllocateResampledCardCaptureAtlas(GraphBuilder, LumenSceneData.GetCardCaptureAtlasSize(), CardCaptureAtlas);

		FRDGUploadData<FUintVector4> CardCaptureRectArray(GraphBuilder, CardPagesToRender.Num());

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenSurfaceCache.cpp:419

Scope: file

Source code excerpt:

		check(LumenRadiosity::GetAtlasDownsampleFactor() == 1);

		extern int32 GLumenSceneSurfaceCacheResampleLighting;
		const bool bResample = GLumenSceneSurfaceCacheResampleLighting != 0 && ResampledCardCaptureAtlas.DirectLighting != nullptr;
		const bool bRadiosityEnabled = LumenRadiosity::IsEnabled(ViewFamily);

		FCopyCardCaptureLightingToAtlasParameters* PassParameters = GraphBuilder.AllocParameters<FCopyCardCaptureLightingToAtlasParameters>();

		PassParameters->RenderTargets[0] = FRenderTargetBinding(FrameTemporaries.DirectLightingAtlas, ERenderTargetLoadAction::ELoad, 0);
		PassParameters->RenderTargets[1] = FRenderTargetBinding(FrameTemporaries.FinalLightingAtlas, ERenderTargetLoadAction::ELoad, 0);