r.Water.SingleLayerWater.SupportCloudShadow

r.Water.SingleLayerWater.SupportCloudShadow

#Overview

name: r.Water.SingleLayerWater.SupportCloudShadow

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.Water.SingleLayerWater.SupportCloudShadow is to enable cloud shadows on SingleLayerWater materials in Unreal Engine 5. This setting variable is primarily related to the rendering system, specifically for water rendering and cloud shadow effects.

Based on the callsites, this variable is used in the Renderer module and the Engine module. It affects the SingleLayerWater rendering system and shader compilation process.

The value of this variable is set through a console variable (CVar) system. It is defined as a TAutoConsoleVariable with an initial value of 0, which means it’s disabled by default.

This variable interacts with shader compilation and definition systems. It is used to set a shader define SUPPORT_CLOUD_SHADOW_ON_SINGLE_LAYER_WATER, which affects how shaders are compiled and behave.

Developers must be aware that:

  1. This is a read-only and render thread safe variable, meaning it should not be modified during runtime.
  2. Changing this variable will affect shader compilation, potentially requiring a recompilation of shaders.
  3. It’s part of the water rendering system and specifically affects SingleLayerWater materials.

Best practices when using this variable include:

  1. Only enable it when cloud shadows on water are necessary for the project, as it may have performance implications.
  2. Consider the impact on shader compilation time and size when enabling this feature.
  3. Test thoroughly after enabling or disabling this feature, as it may affect the visual appearance of water in the game.
  4. Coordinate with the graphics programming team when modifying this setting, as it affects low-level rendering behavior.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SingleLayerWaterRendering.cpp:79

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarSupportCloudShadowOnSingleLayerWater(
	TEXT("r.Water.SingleLayerWater.SupportCloudShadow"), 0,
	TEXT("Enables cloud shadows on SingleLayerWater materials."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarWaterSingleLayerShadersSupportVSMFiltering(
	TEXT("r.Water.SingleLayer.ShadersSupportVSMFiltering"), 0,
	TEXT("Whether or not the single layer water material shaders are compiled with support for virtual shadow map filter, i.e. output main directional light luminance in a separate render target. This is preconditioned on using deferred shading and having VSM support enabled in the project."),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:8468

Scope (from outer to inner):

file
function     void GlobalBeginCompileShader

Source code excerpt:


	{
		static IConsoleVariable *CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Water.SingleLayerWater.SupportCloudShadow"));
		const bool bSupportCloudShadowOnSingleLayerWater = CVar && CVar->GetInt() > 0;
		SET_SHADER_DEFINE(Input.Environment, SUPPORT_CLOUD_SHADOW_ON_SINGLE_LAYER_WATER, bSupportCloudShadowOnSingleLayerWater ? 1 : 0);
	}

	{
		const bool bTranslucentUsesLightRectLights = GetTranslucentUsesLightRectLights();

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderGenerationUtil.cpp:413

Scope (from outer to inner):

file
function     static FShaderGlobalDefines FetchShaderGlobalDefines

Source code excerpt:


	{
		static IConsoleVariable *CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Water.SingleLayerWater.SupportCloudShadow"));
		const bool bSupportCloudShadowOnSingleLayerWater = CVar && CVar->GetInt() > 0;
		Ret.SUPPORT_CLOUD_SHADOW_ON_SINGLE_LAYER_WATER = bSupportCloudShadowOnSingleLayerWater ? 1 : 0;
	}

	{
		static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.PostProcessing.PropagateAlpha"));