r.VolumetricCloud.ShadowMap.SpatialFiltering

r.VolumetricCloud.ShadowMap.SpatialFiltering

#Overview

name: r.VolumetricCloud.ShadowMap.SpatialFiltering

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.VolumetricCloud.ShadowMap.SpatialFiltering is to control the spatial filtering of volumetric cloud shadow maps in Unreal Engine 5’s rendering system. This setting variable is used to enable or disable the shadow map dilation/smoothing spatial filter and to specify the number of blur iterations.

This setting variable is primarily used in the Unreal Engine’s rendering system, specifically in the volumetric cloud rendering module. It is referenced in the VolumetricCloudRendering.cpp file, which is part of the Renderer module.

The value of this variable is set through a console variable (CVar) system, which allows for runtime configuration. It is initialized with a default value of 1, meaning the spatial filtering is enabled by default with one blur iteration.

The associated variable CVarVolumetricCloudShadowSpatialFiltering interacts directly with this setting. It is used to retrieve the value of the setting in the C++ code.

Developers must be aware that:

  1. The value represents the number of blur iterations for the spatial filter.
  2. It is clamped between 0 and 4, where 0 disables the filter, and 1-4 determines the number of blur iterations.
  3. This setting affects the visual quality and performance of volumetric cloud shadows.

Best practices when using this variable include:

  1. Experiment with different values to find the best balance between visual quality and performance for your specific use case.
  2. Consider exposing this setting to end-users for performance scaling on different hardware.
  3. Be mindful of the performance impact when increasing the number of blur iterations.

Regarding the associated variable CVarVolumetricCloudShadowSpatialFiltering:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:163

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowSpatialFiltering(
	TEXT("r.VolumetricCloud.ShadowMap.SpatialFiltering"), 1,
	TEXT("Enable/disable the shadow map dilation/smoothing spatial filter. Enabled when greater than 0 and it represents the number of blur iterations (constrained to a maximum of 4)."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarVolumetricCloudShadowTemporalFilteringNewFrameWeight(
	TEXT("r.VolumetricCloud.ShadowMap.TemporalFiltering.NewFrameWeight"), 1.0f,
	TEXT("Experimental and needs more work so disabled by default. Value between [0.0, 1.0] representing the weight of current frame's contribution. Low values can cause precision issues resulting in depth not converging over time. Disabled when set to 1."),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:162

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowSpatialFiltering(
	TEXT("r.VolumetricCloud.ShadowMap.SpatialFiltering"), 1,
	TEXT("Enable/disable the shadow map dilation/smoothing spatial filter. Enabled when greater than 0 and it represents the number of blur iterations (constrained to a maximum of 4)."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarVolumetricCloudShadowTemporalFilteringNewFrameWeight(
	TEXT("r.VolumetricCloud.ShadowMap.TemporalFiltering.NewFrameWeight"), 1.0f,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:1903

Scope (from outer to inner):

file
lambda-function

Source code excerpt:

						if (ShouldRenderCloudShadowmap(AtmosphericLight))
						{
							const int32 CloudShadowSpatialFiltering = FMath::Clamp(CVarVolumetricCloudShadowSpatialFiltering.GetValueOnAnyThread(), 0, 4);
							const uint32 Resolution1D = GetVolumetricCloudShadowMapResolution(AtmosphericLight);
							const FIntPoint Resolution2D = FIntPoint(Resolution1D, Resolution1D);
							const FIntPoint TracingResolution2D = CloudShadowTemporalEnabled ? FIntPoint(Resolution1D>>1, Resolution1D>>1) : FIntPoint(Resolution1D, Resolution1D);
							const EPixelFormat CloudShadowPixelFormat = PF_FloatR11G11B10;

							if (ViewInfo.ViewState)