r.SupportStationarySkylight

r.SupportStationarySkylight

#Overview

name: r.SupportStationarySkylight

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.SupportStationarySkylight is to enable or disable shader permutations for Stationary and Dynamic Skylights in Unreal Engine’s rendering system.

This setting variable is primarily used by the rendering system, specifically in the base pass rendering module. It affects the compilation and use of certain shader permutations related to skylight rendering.

The Unreal Engine subsystems that rely on this setting variable are:

  1. The Renderer module
  2. The RenderCore module

The value of this variable is set as a console variable (CVar) with a default value of 1, meaning it’s enabled by default. It’s defined in the BasePassRendering.cpp file.

This variable interacts with other variables, notably:

  1. r.SupportAllShaderPermutations: If this is set, it can force all shader permutations regardless of r.SupportStationarySkylight’s value.
  2. It’s used in conjunction with material parameters and translucency checks to determine shader compilation.

Developers should be aware that:

  1. This variable is marked as read-only and render thread safe, meaning it shouldn’t be changed during runtime.
  2. Changing this variable can affect the compilation of shaders, potentially impacting performance and visual quality.
  3. It’s used in shader permutation decisions for both compute shaders (TBasePassCS) and pixel shaders (TBasePassPS).

Best practices when using this variable:

  1. Keep it enabled (set to 1) unless you have specific reasons to disable stationary and dynamic skylight shader permutations.
  2. Consider the interaction with r.SupportAllShaderPermutations when making changes.
  3. Be aware that changing this variable may require shader recompilation.

Regarding the associated variable CVarSupportStationarySkylight:

The purpose of CVarSupportStationarySkylight is to provide a programmatic way to access the value of r.SupportStationarySkylight within the C++ code.

It’s used in the RenderCore module, specifically in the FReadOnlyCVARCache class, which caches the values of various rendering-related console variables for quick access.

The value of CVarSupportStationarySkylight is set by finding the console variable data for “r.SupportStationarySkylight” using the console manager.

This variable interacts with other cached variables in the FReadOnlyCVARCache, and its value is used to determine whether stationary skylights should be enabled in the rendering process.

Developers should be aware that:

  1. This variable provides a faster way to access the r.SupportStationarySkylight setting in performance-critical code paths.
  2. It’s part of a system designed to reduce the overhead of frequently checking console variable values.

Best practices when using this variable:

  1. Use CVarSupportStationarySkylight for frequent checks of the r.SupportStationarySkylight setting in rendering code.
  2. Be aware that changes to r.SupportStationarySkylight may not be immediately reflected in CVarSupportStationarySkylight if the cache hasn’t been updated.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:65

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarSupportStationarySkylight(
	TEXT("r.SupportStationarySkylight"),
	1,
	TEXT("Enables Stationary and Dynamic Skylight shader permutations."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarSupportLowQualityLightmaps(
	TEXT("r.SupportLowQualityLightmaps"),

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

Scope (from outer to inner):

file
function     void FReadOnlyCVARCache::Initialize

Source code excerpt:

	UE_LOG(LogInit, Log, TEXT("Initializing FReadOnlyCVARCache"));

	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"));

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.h:444

Scope (from outer to inner):

file
class        class TBasePassCS : public TBasePassComputeShaderBaseType<LightMapPolicyType>
function     static bool ShouldCompilePermutation

Source code excerpt:

	{
		// Only compile skylight version for lit materials, and if the project allows them.
		static const auto SupportStationarySkylight = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportStationarySkylight"));
		static const auto SupportAllShaderPermutations = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));

		const bool IsSingleLayerWater = Parameters.MaterialParameters.ShadingModels.HasShadingModel(MSM_SingleLayerWater);

		const bool bTranslucent = IsTranslucentBlendMode(Parameters.MaterialParameters);
		const bool bForceAllPermutations = SupportAllShaderPermutations && SupportAllShaderPermutations->GetValueOnAnyThread() != 0;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.h:583

Scope (from outer to inner):

file
class        class TBasePassPS : public TBasePassPixelShaderBaseType<LightMapPolicyType>
function     static bool ShouldCompilePermutation

Source code excerpt:

	{
		// Only compile skylight version for lit materials, and if the project allows them.
		static const auto SupportStationarySkylight = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportStationarySkylight"));
		static const auto SupportAllShaderPermutations = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));

		const bool IsSingleLayerWater = Parameters.MaterialParameters.ShadingModels.HasShadingModel(MSM_SingleLayerWater);

		const bool bTranslucent = IsTranslucentBlendMode(Parameters.MaterialParameters);
		const bool bForceAllPermutations = SupportAllShaderPermutations && SupportAllShaderPermutations->GetValueOnAnyThread() != 0;

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
function     void FReadOnlyCVARCache::Initialize

Source code excerpt:

	UE_LOG(LogInit, Log, TEXT("Initializing FReadOnlyCVARCache"));

	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"));

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

Scope (from outer to inner):

file
function     void FReadOnlyCVARCache::Initialize

Source code excerpt:

	const bool bForceAllPermutations = CVarSupportAllShaderPermutations && CVarSupportAllShaderPermutations->GetValueOnAnyThread() != 0;

	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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:64

Scope: file

Source code excerpt:

	TEXT("Wait for completion of parallel render thread tasks at the end of the base pass. A more granular version of r.RHICmdFlushRenderThreadTasks. If either r.RHICmdFlushRenderThreadTasks or r.RHICmdFlushRenderThreadTasksBasePass is > 0 we will flush."));

static TAutoConsoleVariable<int32> CVarSupportStationarySkylight(
	TEXT("r.SupportStationarySkylight"),
	1,
	TEXT("Enables Stationary and Dynamic Skylight shader permutations."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarSupportLowQualityLightmaps(