r.SkyAtmosphere.AerialPerspectiveLUT.FastApplyOnOpaque

r.SkyAtmosphere.AerialPerspectiveLUT.FastApplyOnOpaque

#Overview

name: r.SkyAtmosphere.AerialPerspectiveLUT.FastApplyOnOpaque

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

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.SkyAtmosphere.AerialPerspectiveLUT.FastApplyOnOpaque is to control the application of atmospheric fog on opaque surfaces using a low-resolution camera frustum/froxel volume. This setting is part of Unreal Engine’s rendering system, specifically the Sky Atmosphere rendering module.

This setting variable is primarily used in the SkyAtmosphereRendering subsystem of Unreal Engine 5. It’s referenced in the file SkyAtmosphereRendering.cpp, which is part of the Renderer module.

The value of this variable is set through a console variable (CVarSkyAtmosphereAerialPerspectiveApplyOnOpaque) with a default value of 1 (enabled). It can be changed at runtime using console commands or through engine configuration files.

This variable interacts closely with other Sky Atmosphere rendering settings, particularly those related to fast sky rendering and depth testing. It’s used in conjunction with CVarSkyAtmosphereFastSkyLUT and CVarSkyAtmosphereAerialPerspectiveDepthTest.

Developers should be aware that while enabling this feature can improve performance, it may result in visual artifacts, especially in scenes with high-frequency details like earth shadows or scattering lobes. The trade-off between performance and visual quality should be carefully considered.

Best practices when using this variable include:

  1. Testing the visual impact in various lighting conditions and with different scene complexities.
  2. Considering disabling it for cinematics or close-up shots where visual artifacts might be more noticeable.
  3. Using it in conjunction with other Sky Atmosphere settings to find the optimal balance between performance and visual quality.

Regarding the associated variable CVarSkyAtmosphereAerialPerspectiveApplyOnOpaque:

The purpose of CVarSkyAtmosphereAerialPerspectiveApplyOnOpaque is to provide a programmatic way to control the r.SkyAtmosphere.AerialPerspectiveLUT.FastApplyOnOpaque setting within the engine’s C++ code.

This console variable is defined and used within the SkyAtmosphereRendering module. It’s used to retrieve the current setting value in various parts of the rendering pipeline, particularly in the RenderSkyAtmosphere function.

The value of this variable is set when the engine initializes the console variables, but it can be changed at runtime through console commands.

CVarSkyAtmosphereAerialPerspectiveApplyOnOpaque interacts directly with the rendering pipeline, influencing how atmospheric fog is applied to opaque surfaces.

Developers should be aware that changes to this variable will immediately affect the rendering pipeline. It’s marked as render thread safe and scalable, meaning it can be adjusted for different quality settings.

Best practices for using this variable include:

  1. Using it for dynamic adjustments to sky atmosphere rendering based on performance metrics or quality settings.
  2. Considering its impact on both visual quality and performance when making changes.
  3. Testing any changes thoroughly across a range of hardware configurations to ensure consistent results.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseScalability.ini:626, section: [EffectsQuality@0]

Location: <Workspace>/Engine/Config/BaseScalability.ini:653, section: [EffectsQuality@1]

Location: <Workspace>/Engine/Config/BaseScalability.ini:680, section: [EffectsQuality@2]

Location: <Workspace>/Engine/Config/BaseScalability.ini:707, section: [EffectsQuality@3]

Location: <Workspace>/Engine/Config/BaseScalability.ini:735, section: [EffectsQuality@Cine]

Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:145, section: [EffectsQuality@0]

Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:158, section: [EffectsQuality@1]

Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:171, section: [EffectsQuality@2]

Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:184, section: [EffectsQuality@3]

Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:145, section: [EffectsQuality@0]

Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:158, section: [EffectsQuality@1]

Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:171, section: [EffectsQuality@2]

Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:184, section: [EffectsQuality@3]

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarSkyAtmosphereAerialPerspectiveApplyOnOpaque(
	TEXT("r.SkyAtmosphere.AerialPerspectiveLUT.FastApplyOnOpaque"), 1,
	TEXT("When enabled, the low resolution camera frustum/froxel volume containing atmospheric fog\n")
	TEXT(", usually used for fog on translucent surface, is used to render fog on opaque.\n")
	TEXT("It is faster but can result in visual artefacts if there are some high frequency details\n")
	TEXT("such as earth shadow or scattering lob."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarSkyAtmosphereAerialPerspectiveApplyOnOpaque(
	TEXT("r.SkyAtmosphere.AerialPerspectiveLUT.FastApplyOnOpaque"), 1,
	TEXT("When enabled, the low resolution camera frustum/froxel volume containing atmospheric fog\n")
	TEXT(", usually used for fog on translucent surface, is used to render fog on opaque.\n")
	TEXT("It is faster but can result in visual artefacts if there are some high frequency details\n")
	TEXT("such as earth shadow or scattering lob."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

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

Scope (from outer to inner):

file
function     void FSceneRenderer::RenderSkyAtmosphere

Source code excerpt:

	const FAtmosphereSetup& Atmosphere = SkyAtmosphereSceneProxy.GetAtmosphereSetup();
	SkyRC.bFastSky = CVarSkyAtmosphereFastSkyLUT.GetValueOnRenderThread() > 0;
	SkyRC.bFastAerialPerspective = CVarSkyAtmosphereAerialPerspectiveApplyOnOpaque.GetValueOnRenderThread() > 0;
	SkyRC.bFastAerialPerspectiveDepthTest = CVarSkyAtmosphereAerialPerspectiveDepthTest.GetValueOnRenderThread() > 0;
	SkyRC.bSecondAtmosphereLightEnabled = Scene->IsSecondAtmosphereLightEnabled();

	SkyAtmosphereLightShadowData LightShadowData;
	SkyRC.bShouldSampleOpaqueShadow = ShouldSkySampleAtmosphereLightsOpaqueShadow(*Scene, VisibleLightInfos, LightShadowData);
	SkyRC.bUseDepthBoundTestIfPossible = true;

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

Scope (from outer to inner):

file
function     void FSceneRenderer::RenderSkyAtmosphere

Source code excerpt:


#if WITH_EDITOR
	if (CVarSkyAtmosphereFastSkyLUT.GetValueOnAnyThread() == 0 && CVarSkyAtmosphereAerialPerspectiveApplyOnOpaque.GetValueOnAnyThread() > 0)
	{
		for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
		{
			const FViewInfo& View = Views[ViewIndex];

			AddDrawCanvasPass(GraphBuilder, {}, View, FScreenPassRenderTarget(SceneTextures.Color.Target, View.ViewRect, ERenderTargetLoadAction::ELoad),