r.VolumetricCloud.ShadowMap

r.VolumetricCloud.ShadowMap

#Overview

name: r.VolumetricCloud.ShadowMap

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 is to enable or disable the shadow map for volumetric clouds in Unreal Engine 5’s rendering system. This setting is specifically used when the scene contains a DirectionalLight component with Cast Cloud Shadows enabled.

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

The value of this variable is set through a console variable (CVarVolumetricCloudShadowMap) with a default value of 1 (enabled). It can be changed at runtime using console commands or through engine configuration files.

The associated variable CVarVolumetricCloudShadowMap interacts directly with r.VolumetricCloud.ShadowMap, as they share the same value. This console variable is used in the ShouldRenderCloudShadowmap function to determine whether cloud shadows should be rendered.

Developers must be aware that this setting only takes effect when there’s a DirectionalLight component in the scene with Cast Cloud Shadows enabled. If these conditions are not met, changing this setting will have no visible effect.

Best practices when using this variable include:

  1. Only enable it when volumetric cloud shadows are necessary for the scene, as it may have performance implications.
  2. Ensure that the DirectionalLight component is properly set up with Cast Cloud Shadows enabled when expecting this setting to have an effect.
  3. Use in conjunction with other volumetric cloud settings for optimal visual results and performance.

Regarding the associated variable CVarVolumetricCloudShadowMap:

This is a TAutoConsoleVariable that directly controls the r.VolumetricCloud.ShadowMap setting. It’s defined in the same file (VolumetricCloudRendering.cpp) and is used to implement the actual functionality of enabling or disabling the cloud shadow map.

The purpose of CVarVolumetricCloudShadowMap is to provide a programmatic way to control the cloud shadow map feature. It’s used in the rendering code to determine whether to render the cloud shadow map or not.

This variable is primarily used in the Renderer module, specifically in the volumetric cloud rendering subsystem.

The value of CVarVolumetricCloudShadowMap is set when the engine initializes, but can be changed at runtime through console commands or script.

It interacts directly with the ShouldRenderCloudShadowmap function, which checks its value to determine if cloud shadows should be rendered.

Developers should be aware that changing this variable will have an immediate effect on the rendering of cloud shadows, potentially affecting both visual quality and performance.

Best practices for using CVarVolumetricCloudShadowMap include:

  1. Use it for debugging or performance tuning purposes.
  2. Consider exposing it as a user-configurable setting in graphics options if cloud shadow quality is an important factor in your game.
  3. Be cautious about changing its value frequently during gameplay, as it may cause noticeable visual changes.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowMap(
	TEXT("r.VolumetricCloud.ShadowMap"), 1,
	TEXT("Enable/disable the shadow map, only if the scene contains a DirectionalLight component with Cast Cloud Shadows enabled on it."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowMapDebug(
	TEXT("r.VolumetricCloud.ShadowMap.Debug"), 0,
	TEXT("Print information to debug the cloud shadow map."),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

////////////////////////////////////////////////////////////////////////// Cloud shadow map

static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowMap(
	TEXT("r.VolumetricCloud.ShadowMap"), 1,
	TEXT("Enable/disable the shadow map, only if the scene contains a DirectionalLight component with Cast Cloud Shadows enabled on it."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowMapDebug(
	TEXT("r.VolumetricCloud.ShadowMap.Debug"), 0,

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

Scope (from outer to inner):

file
function     static bool ShouldRenderCloudShadowmap

Source code excerpt:

static bool ShouldRenderCloudShadowmap(const FLightSceneProxy* AtmosphericLight)
{
	return CVarVolumetricCloudShadowMap.GetValueOnRenderThread() > 0 && AtmosphericLight && AtmosphericLight->GetCastCloudShadows();
}

bool ShouldVolumetricCloudTraceWithMinMaxDepth(const FViewInfo& ViewInfo)
{
	if (ViewInfo.ViewState)
	{