r.LumenScene.Radiosity.SpatialFilterProbes.KernelSize

r.LumenScene.Radiosity.SpatialFilterProbes.KernelSize

#Overview

name: r.LumenScene.Radiosity.SpatialFilterProbes.KernelSize

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.Radiosity.SpatialFilterProbes.KernelSize is to control the kernel size for spatial filtering of probes in the Lumen radiosity system. This setting variable is part of Unreal Engine 5’s rendering system, specifically the Lumen global illumination solution.

The Lumen radiosity system relies on this setting variable to determine the extent of spatial filtering applied to probes. It is primarily used in the LumenRadiosity module, which is part of the Renderer subsystem.

The value of this variable is set through the Unreal Engine console variable system. It’s defined as an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands or configuration files.

This variable interacts directly with GLumenRadiositySpatialFilterProbesKernelSize, which is the associated C++ variable that stores the actual value used in the rendering code.

Developers must be aware that increasing the kernel size reduces noise in the radiosity calculations but can also increase light leaking. As stated in the comment, “Larger kernels reduce noise but increase leaking.” This trade-off should be carefully considered when adjusting this value.

Best practices when using this variable include:

  1. Start with the default value (1) and adjust incrementally.
  2. Monitor both noise reduction and light leaking when making changes.
  3. Consider performance implications, as larger kernel sizes may increase computational cost.
  4. Use in conjunction with other Lumen settings for optimal results.

Regarding the associated variable GLumenRadiositySpatialFilterProbesKernelSize:

The purpose of GLumenRadiositySpatialFilterProbesKernelSize is to store the actual integer value used in the Lumen radiosity calculations for the spatial filter kernel size.

This variable is used directly in the rendering code, specifically in the LumenRadiosity.cpp file. It’s checked to determine if spatial filtering should be applied and to what extent.

The value of this variable is set by the console variable system, mirroring the value of r.LumenScene.Radiosity.SpatialFilterProbes.KernelSize.

It interacts with other variables in the radiosity system, such as GLumenRadiositySpatialFilterProbes, to control the behavior of the spatial filtering process.

Developers should be aware that this variable is used in shader permutations, specifically in setting up the FLumenRadiositySpatialFilterProbeRadiance shader. The value is clamped between 0 and 2 when used in this context.

Best practices for using this variable include:

  1. Avoid direct manipulation; instead, use the console variable to ensure consistency.
  2. Consider the impact on shader permutations when changing this value.
  3. Be mindful of the clamping behavior when used in shader setup.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenRadiosity.cpp:49

Scope: file

Source code excerpt:

int32 GLumenRadiositySpatialFilterProbesKernelSize = 1;
FAutoConsoleVariableRef CVarLumenRadiositySpatialFilterProbesKernelSize(
	TEXT("r.LumenScene.Radiosity.SpatialFilterProbes.KernelSize"),
	GLumenRadiositySpatialFilterProbesKernelSize,
	TEXT("Larger kernels reduce noise but increase leaking."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GRadiosityFilteringProbePlaneWeighting = 1;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

int32 GLumenRadiositySpatialFilterProbesKernelSize = 1;
FAutoConsoleVariableRef CVarLumenRadiositySpatialFilterProbesKernelSize(
	TEXT("r.LumenScene.Radiosity.SpatialFilterProbes.KernelSize"),
	GLumenRadiositySpatialFilterProbesKernelSize,
	TEXT("Larger kernels reduce noise but increase leaking."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GRadiosityFilteringProbePlaneWeighting = 1;
FAutoConsoleVariableRef CVarRadiosityFilteringProbePlaneWeighting(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenRadiosity.cpp:870

Scope: file

Source code excerpt:

	}

	if (GLumenRadiositySpatialFilterProbes && GLumenRadiositySpatialFilterProbesKernelSize > 0)
	{
		//@todo - use temporary buffer based off of CardUpdateContext.UpdateAtlasSize which is smaller
		FRDGTextureRef FilteredTraceRadianceAtlas = GraphBuilder.CreateTexture(
			FRDGTextureDesc::Create2D(RadiosityFrameTemporaries.ProbeTracingAtlasSize, PF_FloatRGB, FClearValueBinding::Black, TexCreate_ShaderResource | TexCreate_UAV),
			TEXT("Lumen.Radiosity.FilteredTraceRadianceAtlas"));

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenRadiosity.cpp:895

Scope: file

Source code excerpt:

			PermutationVector.Set<FLumenRadiositySpatialFilterProbeRadiance::FPlaneWeighting>(GRadiosityFilteringProbePlaneWeighting != 0);
			PermutationVector.Set<FLumenRadiositySpatialFilterProbeRadiance::FProbeOcclusion>(RadiosityFrameTemporaries.bUseProbeOcclusion);
			PermutationVector.Set<FLumenRadiositySpatialFilterProbeRadiance::FKernelSize>(FMath::Clamp<int32>(GLumenRadiositySpatialFilterProbesKernelSize, 0, 2));
			auto ComputeShader = GlobalShaderMap->GetShader<FLumenRadiositySpatialFilterProbeRadiance>(PermutationVector);

			FComputeShaderUtils::AddPass(
				GraphBuilder,
				RDG_EVENT_NAME("SpatialFilterProbes"),
				ComputePassFlags,