r.SupportPointLightWholeSceneShadows

r.SupportPointLightWholeSceneShadows

#Overview

name: r.SupportPointLightWholeSceneShadows

This variable is created as a Console Variable (cvar).

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.SupportPointLightWholeSceneShadows is to enable or disable shadow-casting for point lights in the rendering system. This setting is primarily used in the Unreal Engine’s rendering subsystem.

The Unreal Engine’s renderer module relies on this setting variable, as evident from its usage in the ShadowDepthRendering.cpp file. It’s part of the shadow rendering system, specifically for point lights.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 (enabled) in the ShadowDepthRendering.cpp file.

This variable interacts with other rendering-related variables, such as r.SupportAllShaderPermutations. It’s used in conjunction with these variables to determine whether certain shader permutations should be compiled.

Developers must be aware that this variable is marked as read-only and render thread safe (ECVF_ReadOnly | ECVF_RenderThreadSafe). This means it should not be changed during runtime and is intended to be set at engine startup or through configuration files.

Best practices when using this variable include:

  1. Consider performance implications when enabling point light shadows, as they can be computationally expensive.
  2. Use in conjunction with other shadow and lighting settings for optimal visual quality and performance balance.
  3. Be cautious about disabling it, as it may affect the visual fidelity of scenes that rely on point light shadows.

Regarding the associated variable CVarSupportPointLightWholeSceneShadows:

This is the actual console variable object that corresponds to the r.SupportPointLightWholeSceneShadows setting. It’s used internally by the engine to access and modify the setting’s value.

The purpose of CVarSupportPointLightWholeSceneShadows is to provide a programmatic interface for the r.SupportPointLightWholeSceneShadows setting within the engine’s code.

It’s used in the renderer module and the render core module, indicating its importance in the rendering pipeline.

The value of this variable is typically set through the console variable system, but it can also be accessed and potentially modified through code using the IConsoleManager.

This variable interacts closely with other rendering-related console variables and is often used in conditional statements to determine rendering behavior.

Developers should be aware that this variable is part of the engine’s internal console variable system and should be accessed using the appropriate API calls rather than directly.

Best practices for using CVarSupportPointLightWholeSceneShadows include:

  1. Use the IConsoleManager to access its value rather than accessing it directly.
  2. Consider caching its value for performance-critical sections of code, as demonstrated in the ReadOnlyCVARCache class.
  3. Be aware of its read-only nature and avoid attempting to modify it during runtime unless absolutely necessary.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:281

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarSupportPointLightWholeSceneShadows(
	TEXT("r.SupportPointLightWholeSceneShadows"),
	1,
	TEXT("Enables shadowcasting point lights."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static bool MobileUsesPerspectiveCorrectShadowPermutation(EShaderPlatform ShaderPlatform)
{

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ReadOnlyCVARCache.cpp:64

Scope (from outer to inner):

file
function     void FReadOnlyCVARCache::Initialize

Source code excerpt:

	const auto CVarSupportStationarySkylight = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportStationarySkylight"));
	const auto CVarSupportLowQualityLightmaps = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportLowQualityLightmaps"));
	const auto CVarSupportPointLightWholeSceneShadows = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportPointLightWholeSceneShadows"));
	const auto CVarSupportAllShaderPermutations = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));	
	const auto CVarVertexFoggingForOpaque = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VertexFoggingForOpaque"));	
	const auto CVarAllowStaticLighting = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.AllowStaticLighting"));
	const auto CVarSupportSkyAtmosphere = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportSkyAtmosphere"));
	
	const auto CVarMobileHDR = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MobileHDR"));

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.h:2091

Scope (from outer to inner):

file
class        class FSceneRenderer : public FSceneRendererBase

Source code excerpt:


#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	/** Lights added if wholescenepointlight shadow would have been rendered (ignoring r.SupportPointLightWholeSceneShadows). Used for warning about unsupported features. */
	TArray<FString, SceneRenderingAllocator> UsedWholeScenePointLightNames;
#endif
	/** Feature level being rendered */
	ERHIFeatureLevel::Type FeatureLevel;
	EShaderPlatform ShaderPlatform;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ReadOnlyCVARCache.cpp:64

Scope (from outer to inner):

file
function     void FReadOnlyCVARCache::Initialize

Source code excerpt:

	const auto CVarSupportStationarySkylight = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportStationarySkylight"));
	const auto CVarSupportLowQualityLightmaps = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportLowQualityLightmaps"));
	const auto CVarSupportPointLightWholeSceneShadows = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportPointLightWholeSceneShadows"));
	const auto CVarSupportAllShaderPermutations = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));	
	const auto CVarVertexFoggingForOpaque = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VertexFoggingForOpaque"));	
	const auto CVarAllowStaticLighting = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.AllowStaticLighting"));
	const auto CVarSupportSkyAtmosphere = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportSkyAtmosphere"));
	
	const auto CVarMobileHDR = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MobileHDR"));

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ReadOnlyCVARCache.cpp:82

Scope (from outer to inner):

file
function     void FReadOnlyCVARCache::Initialize

Source code excerpt:


	bEnableStationarySkylight = !CVarSupportStationarySkylight || CVarSupportStationarySkylight->GetValueOnAnyThread() != 0 || bForceAllPermutations;
	bEnablePointLightShadows = !CVarSupportPointLightWholeSceneShadows || CVarSupportPointLightWholeSceneShadows->GetValueOnAnyThread() != 0 || bForceAllPermutations;
	bEnableLowQualityLightmaps = !CVarSupportLowQualityLightmaps || CVarSupportLowQualityLightmaps->GetValueOnAnyThread() != 0 || bForceAllPermutations;
	bAllowStaticLighting = CVarAllowStaticLighting->GetValueOnAnyThread() != 0;
	bSupportSkyAtmosphere = !CVarSupportSkyAtmosphere || CVarSupportSkyAtmosphere->GetValueOnAnyThread() != 0 || bForceAllPermutations;

	// mobile
	bMobileHDR = CVarMobileHDR->GetValueOnAnyThread() == 1;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:280

Scope: file

Source code excerpt:

};

static TAutoConsoleVariable<int32> CVarSupportPointLightWholeSceneShadows(
	TEXT("r.SupportPointLightWholeSceneShadows"),
	1,
	TEXT("Enables shadowcasting point lights."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static bool MobileUsesPerspectiveCorrectShadowPermutation(EShaderPlatform ShaderPlatform)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:318

Scope (from outer to inner):

file
class        class TShadowDepthVS : public FShadowDepthVS
function     static bool ShouldCompilePermutation

Source code excerpt:

		static const auto SupportAllShaderPermutationsVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));
		const bool bForceAllPermutations = SupportAllShaderPermutationsVar && SupportAllShaderPermutationsVar->GetValueOnAnyThread() != 0;
		const bool bSupportPointLightWholeSceneShadows = CVarSupportPointLightWholeSceneShadows.GetValueOnAnyThread() != 0 || bForceAllPermutations;

		// Mobile only needs OutputDepth, and optionally PerspectiveCorrect
		if (!IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM5) &&
			!(ShaderMode == VertexShadowDepth_OutputDepth || 
				(ShaderMode == VertexShadowDepth_PerspectiveCorrect && MobileUsesPerspectiveCorrectShadowPermutation(Platform))))
		{