r.SupportSkyAtmosphereAffectsHeightFog

r.SupportSkyAtmosphereAffectsHeightFog

#Overview

name: r.SupportSkyAtmosphereAffectsHeightFog

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.SupportSkyAtmosphereAffectsHeightFog is to enable or disable the interaction between the Sky Atmosphere component and the Height Fog in Unreal Engine 5. This setting variable is primarily related to the rendering system, specifically the atmospheric and fog effects.

Based on the callsites, this variable is primarily used in the Renderer, Engine, and RenderCore modules of Unreal Engine. It affects the SkyAtmosphere and ExponentialHeightFog components, as well as shader compilation.

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

This variable interacts with other rendering-related variables, particularly r.SupportSkyAtmosphere. The Sky Atmosphere’s effect on Height Fog is only enabled when both r.SupportSkyAtmosphere and r.SupportSkyAtmosphereAffectsHeightFog are true.

Developers should be aware that:

  1. This setting affects shader compilation, so changing it may require recompiling shaders.
  2. It’s marked as ECVF_ReadOnly, meaning it should not be changed at runtime.
  3. It impacts the visibility and behavior of certain properties in the ExponentialHeightFogComponent, such as FogInscatteringLuminance and SkyAtmosphereAmbientContributionColorScale.

Best practices when using this variable include:

  1. Ensure it’s set appropriately in project settings if you want to use Sky Atmosphere effects on Height Fog.
  2. Be aware of its impact on performance, as enabling this feature may have some performance cost.
  3. Consider the visual coherence of your scene when enabling or disabling this feature, as it affects how the sky and fog interact visually.
  4. Remember that changing this setting may require recompiling shaders, so it’s best to set it early in the development process.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:115, section: [/Script/Engine.RendererSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:40

Scope: file

Source code excerpt:

// The project setting for the sky atmosphere component to affect the height fog (disable runtime and shader code)
static TAutoConsoleVariable<int32> CVarSupportSkyAtmosphereAffectsHeightFog(
	TEXT("r.SupportSkyAtmosphereAffectsHeightFog"),
	1,
	TEXT("Enables SkyAtmosphere affecting height fog. It requires r.SupportSkyAtmosphere to be true."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

////////////////////////////////////////////////////////////////////////// Regular sky 

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Components/ExponentialHeightFogComponent.h:69

Scope (from outer to inner):

file
class        class UExponentialHeightFogComponent : public USceneComponent

Source code excerpt:

	FLinearColor FogInscatteringLuminance;

	/** Color used to modulate the SkyAtmosphere component contribution to the non directional component of the fog. Only effective when r.SupportSkyAtmosphereAffectsHeightFog>0 */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = ExponentialHeightFogComponent)
	FLinearColor SkyAtmosphereAmbientContributionColorScale;

	/** 
	 * Cubemap that can be specified for fog color, which is useful to make distant, heavily fogged scene elements match the sky.
	 * When the cubemap is specified, FogInscatteringColor is ignored and Directional inscattering is disabled. 

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/HeightFogComponent.cpp:110

Scope (from outer to inner):

file
function     bool UExponentialHeightFogComponent::CanEditChange

Source code excerpt:

		if (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(UExponentialHeightFogComponent, FogInscatteringLuminance))
		{
			static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportSkyAtmosphereAffectsHeightFog"));
			return CVar && CVar->GetValueOnAnyThread() > 0;
		}
	}

	return Super::CanEditChange(InProperty);
}

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

Scope (from outer to inner):

file
function     void GlobalBeginCompileShader

Source code excerpt:


	{
		static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SupportSkyAtmosphereAffectsHeightFog"));
		SET_SHADER_DEFINE(Input.Environment, PROJECT_SUPPORT_SKY_ATMOSPHERE_AFFECTS_HEIGHFOG, (CVar && bSupportSkyAtmosphere) ? (CVar->GetInt() != 0) : 0);
	}

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

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

Scope (from outer to inner):

file
function     static FShaderGlobalDefines FetchShaderGlobalDefines

Source code excerpt:


	{
		static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SupportSkyAtmosphereAffectsHeightFog"));
		Ret.PROJECT_SUPPORT_SKY_ATMOSPHERE_AFFECTS_HEIGHFOG = (CVar && bSupportSkyAtmosphere) ? (CVar->GetInt() != 0) : 0;
	}

	{
		static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SupportCloudShadowOnForwardLitTranslucent"));
		const bool bSupportCloudShadowOnForwardLitTranslucent = CVar && CVar->GetInt() > 0;

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/Shader.cpp:1989

Scope (from outer to inner):

file
function     void ShaderMapAppendKeyString

Source code excerpt:

			KeyString += TEXT("_SKYATM");

			static const auto CVarHeightFog = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportSkyAtmosphereAffectsHeightFog"));
			if (CVarHeightFog && CVarHeightFog->GetValueOnAnyThread() > 0)
			{
				KeyString += TEXT("_SKYHF");
			}
		}
	}