r.VolumetricCloud.Shadow.SampleAtmosphericLightShadowmap

r.VolumetricCloud.Shadow.SampleAtmosphericLightShadowmap

#Overview

name: r.VolumetricCloud.Shadow.SampleAtmosphericLightShadowmap

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.Shadow.SampleAtmosphericLightShadowmap is to enable the sampling of atmospheric lights shadow map in order to produce volumetric shadows for volumetric clouds.

This setting variable is primarily used in the rendering system, specifically for volumetric cloud rendering and shadowing. It is part of the Unreal Engine’s volumetric cloud rendering subsystem.

Based on the callsites, this variable is used in the Renderer module, particularly in the VolumetricCloudRendering.cpp file. It’s part of the volumetric cloud rendering pipeline and affects how cloud shadows are rendered.

The value of this variable is set as a console variable (CVar) with a default value of 1 (enabled). It can be changed at runtime through the console or project settings.

This variable interacts with other parts of the volumetric cloud rendering system. For example, it’s used in conjunction with bSkipAtmosphericLightShadowmap to determine whether to sample the light shadowmap for volumetric clouds.

Developers should be aware that this setting can impact performance and visual quality. Enabling it allows for more realistic cloud shadows but may come at a performance cost.

Best practices when using this variable include:

  1. Consider the performance impact when enabling this feature, especially on lower-end hardware.
  2. Use it in conjunction with other volumetric cloud settings for the best visual results.
  3. Test thoroughly in different lighting conditions to ensure the desired visual outcome.

The associated variable CVarVolumetricCloudShadowSampleAtmosphericLightShadowmap is the actual console variable that controls this setting. It’s defined as an int32 with the same default value of 1.

This console variable is used in the FVolumetricCloudRenderViewMeshProcessor constructor to determine whether to sample the light shadowmap. It’s also used in the RenderVolumetricCloudsInternal function to decide whether to sample the virtual shadow map.

When working with this variable, developers should:

  1. Use GetValueOnRenderThread() or GetValueOnAnyThread() to access its current value safely.
  2. Be aware that changes to this variable will affect the rendering pipeline in real-time.
  3. Consider exposing this setting in the game’s graphics options if fine-tuning of cloud shadows is desired.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowSampleAtmosphericLightShadowmap(
	TEXT("r.VolumetricCloud.Shadow.SampleAtmosphericLightShadowmap"), 1,
	TEXT("Enable the sampling of atmospheric lights shadow map in order to produce volumetric shadows."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

// The project setting for the cloud shadow to affect all translucenct surface not relying on the translucent lighting volume (enable/disable runtime and shader code).  This is not implemented on mobile as VolumetricClouds are not available on these platforms.
static TAutoConsoleVariable<int32> CVarSupportCloudShadowOnForwardLitTranslucent(
	TEXT("r.SupportCloudShadowOnForwardLitTranslucent"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowSampleAtmosphericLightShadowmap(
	TEXT("r.VolumetricCloud.Shadow.SampleAtmosphericLightShadowmap"), 1,
	TEXT("Enable the sampling of atmospheric lights shadow map in order to produce volumetric shadows."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

// The project setting for the cloud shadow to affect all translucenct surface not relying on the translucent lighting volume (enable/disable runtime and shader code).  This is not implemented on mobile as VolumetricClouds are not available on these platforms.
static TAutoConsoleVariable<int32> CVarSupportCloudShadowOnForwardLitTranslucent(

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

Scope (from outer to inner):

file
class        class FVolumetricCloudRenderViewMeshProcessor : public FMeshPassProcessor
function     FVolumetricCloudRenderViewMeshProcessor

Source code excerpt:

		: FMeshPassProcessor(EMeshPass::Num, Scene, FeatureLevel, InViewIfDynamicMeshCommand, InDrawListContext)
		, bVolumetricCloudPerSampleAtmosphereTransmittance(ShouldUsePerSampleAtmosphereTransmittance(Scene, InViewIfDynamicMeshCommand))
		, bVolumetricCloudSampleLightShadowmap(!bSkipAtmosphericLightShadowmap && CVarVolumetricCloudShadowSampleAtmosphericLightShadowmap.GetValueOnAnyThread() > 0)
		, bVolumetricCloudSecondLight(bSecondAtmosphereLightEnabled)
		, bCloudDebugViewModeEnabled(bCloudDebugViewModeEnabledIn)
	{
		PassDrawRenderState.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());

		if (bShouldViewRenderVolumetricRenderTarget || bCloudDebugViewModeEnabled)

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

Scope (from outer to inner):

file
function     void FSceneRenderer::RenderVolumetricCloudsInternal

Source code excerpt:

		GetOutputTexturesWithFallback(GraphBuilder, CloudRC, CloudColorCubeTextureUAV, CloudColor0TextureUAV, CloudColor1TextureUAV, CloudDepthTextureUAV);

		bool bSampleVirtualShadowMap = (!bCloudDebugViewModeEnabled && !bSkipAtmosphericLightShadowmap && CVarVolumetricCloudShadowSampleAtmosphericLightShadowmap.GetValueOnRenderThread() > 0);

		FRenderVolumetricCloudRenderViewCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FRenderVolumetricCloudRenderViewCS::FParameters>();
		PassParameters->OutputViewRect = FVector4f(0.f, 0.f, Desc.Extent.X, Desc.Extent.Y);
		PassParameters->bBlendCloudColor = !bShouldViewRenderVolumetricRenderTarget && !bCloudDebugViewModeEnabled;
		PassParameters->TargetCubeFace = CloudRC.RenderTargets.Output[0].GetArraySlice();
		PassParameters->VolumetricCloudRenderViewParamsUB = CloudPassUniformBuffer;