r.VolumetricCloud.ShadowMap.MaxResolution

r.VolumetricCloud.ShadowMap.MaxResolution

#Overview

name: r.VolumetricCloud.ShadowMap.MaxResolution

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.VolumetricCloud.ShadowMap.MaxResolution is to set the maximum resolution for the cloud shadow map in Unreal Engine 5’s volumetric cloud rendering system. This setting is part of the rendering system, specifically for managing the quality and performance of cloud shadows.

This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the volumetric cloud rendering subsystem. It’s referenced in the VolumetricCloudRendering.cpp file, which is responsible for implementing the volumetric cloud rendering features.

The value of this variable is set as a console variable with a default value of 2048. It can be modified at runtime through the console or programmatically.

This variable interacts with the CloudShadowMapResolutionScale property of the DirectionalLightComponent. The actual resolution of the cloud shadow map is determined by scaling the base resolution (512) by CloudShadowMapResolutionScale, but it’s clamped to the maximum value set by r.VolumetricCloud.ShadowMap.MaxResolution.

Developers should be aware that this variable affects the quality and performance of cloud shadows. Higher resolutions can provide more detailed shadows but at the cost of increased memory usage and potentially lower performance.

Best practices when using this variable include:

  1. Balancing quality and performance based on target hardware.
  2. Considering the scale of your game world and the importance of cloud shadow detail.
  3. Using it in conjunction with CloudShadowMapResolutionScale for fine-tuning.

Regarding the associated variable CVarVolumetricCloudShadowMapMaxResolution:

This is the actual console variable that corresponds to r.VolumetricCloud.ShadowMap.MaxResolution. It’s defined in the VolumetricCloudRendering.cpp file and is used to implement the functionality of the setting.

The purpose of this variable is the same as r.VolumetricCloud.ShadowMap.MaxResolution - to control the maximum resolution of the cloud shadow map.

It’s used in the GetVolumetricCloudShadowMapResolution function to clamp the calculated shadow map resolution. This function takes into account the CloudShadowMapResolutionScale from the DirectionalLightComponent and ensures the final resolution doesn’t exceed the maximum set by this variable.

Developers should be aware that changes to this console variable will directly affect the maximum possible resolution of cloud shadows in the game. It’s a scalability setting, meaning it can be adjusted based on different quality presets or hardware capabilities.

Best practices for using this variable include:

  1. Setting appropriate values for different scalability presets.
  2. Considering its impact on memory usage and performance when setting its value.
  3. Using it in conjunction with other volumetric cloud settings for a balanced approach to cloud rendering quality and performance.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowMapMaxResolution(
	TEXT("r.VolumetricCloud.ShadowMap.MaxResolution"), 2048,
	TEXT("The maximum resolution of the cloud shadow map. The active resolution is controlled by the CloudShadowMapResolutionScale property on the Directional Light component."),
	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)."),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Components/DirectionalLightComponent.h:222

Scope (from outer to inner):

file
class        class UDirectionalLightComponent : public ULightComponent

Source code excerpt:

	float CloudShadowExtent;
	/**
	 * Scale the cloud shadow map resolution, base resolution is 512. The resolution is still clamped to 'r.VolumetricCloud.ShadowMap.MaxResolution'.
	 */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = AtmosphereAndCloud, AdvancedDisplay, meta = (UIMin = "0.25", UIMax = "8", ClampMin = "0.25", SliderExponent = 1.0))
	float CloudShadowMapResolutionScale;
	/**
	 * Scale the shadow map tracing sample count.
	 * The sample count resolution is still clamped according to scalability setting to 'r.VolumetricCloud.ShadowMap.RaySampleMaxCount'.
	 */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = AtmosphereAndCloud, AdvancedDisplay, meta = (UIMin = "0.25", UIMax = "8", ClampMin = "0.25", SliderExponent = 1.0))

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowMapMaxResolution(
	TEXT("r.VolumetricCloud.ShadowMap.MaxResolution"), 2048,
	TEXT("The maximum resolution of the cloud shadow map. The active resolution is controlled by the CloudShadowMapResolutionScale property on the Directional Light component."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowSpatialFiltering(
	TEXT("r.VolumetricCloud.ShadowMap.SpatialFiltering"), 1,

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

Scope (from outer to inner):

file
function     static int32 GetVolumetricCloudShadowMapResolution

Source code excerpt:

	if (AtmosphericLight)
	{
		return FMath::Min( int32(512.0f * float(AtmosphericLight->GetCloudShadowMapResolutionScale())), CVarVolumetricCloudShadowMapMaxResolution.GetValueOnAnyThread());
	}
	return 32;
}

static int32 GetVolumetricCloudShadowRaySampleCountScale(const FLightSceneProxy* AtmosphericLight)
{