r.SkyAtmosphere.MultiScatteringLUT.HighQuality

r.SkyAtmosphere.MultiScatteringLUT.HighQuality

#Overview

name: r.SkyAtmosphere.MultiScatteringLUT.HighQuality

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.MultiScatteringLUT.HighQuality is to control the quality of multi-scattering approximation in the sky atmosphere rendering system of Unreal Engine 5. It is used to determine the number of samples used in the multi-scattering lookup table (LUT) calculation.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically in the sky atmosphere rendering subsystem. It affects the quality and performance of the sky and atmosphere rendering.

The value of this variable is set as a console variable (CVar) in the engine’s configuration system. It’s defined with a default value of 0.0f, which means the high-quality mode is disabled by default.

The associated variable CVarSkyAtmosphereMultiScatteringLUTHighQuality directly interacts with it. This variable is used to access the value set by the console command in the C++ code.

Developers must be aware that enabling this variable (setting it to a value greater than 0) will increase the number of samples used in the multi-scattering calculation from 2 to 64. This results in a more accurate approximation but also increases computational cost.

Best practices when using this variable include:

  1. Use it judiciously, as enabling high-quality mode can impact performance.
  2. Consider enabling it for scenes where high-quality atmosphere rendering is crucial for visual fidelity.
  3. Test performance impact when enabling this feature, especially on target hardware.

Regarding the associated variable CVarSkyAtmosphereMultiScatteringLUTHighQuality:

The purpose of this variable is to provide runtime access to the r.SkyAtmosphere.MultiScatteringLUT.HighQuality setting within the C++ code.

It’s used in the Renderer module, specifically in the sky atmosphere rendering system.

The value of this variable is set by the console command system and can be accessed on the render thread using GetValueOnRenderThread().

This variable directly controls whether high-quality multi-scattering is used in the rendering process.

Developers should be aware that this variable is marked as render thread safe and affects scalability, meaning it can be changed at runtime to adjust performance.

Best practices include using this variable to dynamically adjust rendering quality based on performance requirements or user settings.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarSkyAtmosphereMultiScatteringLUTHighQuality(
	TEXT("r.SkyAtmosphere.MultiScatteringLUT.HighQuality"), 0.0f,
	TEXT("The when enabled, 64 samples are used instead of 2, resulting in a more accurate multi scattering approximation (but also more expenssive).\n"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarSkyAtmosphereMultiScatteringLUTWidth(
	TEXT("r.SkyAtmosphere.MultiScatteringLUT.Width"), 32,
	TEXT(""),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Components/SkyAtmosphereComponent.h:70

Scope (from outer to inner):

file
class        class USkyAtmosphereComponent : public USceneComponent

Source code excerpt:

	/** Factor applied to multiple scattering only (after the sun light has bounced around in the atmosphere at least once). 
	 * Multiple scattering is evaluated using a dual scattering approach. 
	 * A value of 2 is recommended to better represent default atmosphere when r.SkyAtmosphere.MultiScatteringLUT.HighQuality=0. 
	 */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, interp, Category = "Atmosphere", meta = (DisplayName = "MultiScattering", UIMin = 0.0, UIMax = 2.0, ClampMin = 0.0, ClampMax = 100.0))
	float MultiScatteringFactor;

	/**
	 * Scale the atmosphere tracing sample count. Quality level scalability
	 * The sample count is still clamped according to scalability setting to 'r.SkyAtmosphere.SampleCountMax' when 'r.SkyAtmosphere.FastSkyLUT' is 0.
	 * The sample count is still clamped according to scalability setting to 'r.SkyAtmosphere.FastSkyLUT.SampleCountMax' when 'r.SkyAtmosphere.FastSkyLUT' is 1.
	 * The sample count is still clamped for aerial perspective according to  'r.SkyAtmosphere.AerialPerspectiveLUT.SampleCountMaxPerSlice'.

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarSkyAtmosphereMultiScatteringLUTHighQuality(
	TEXT("r.SkyAtmosphere.MultiScatteringLUT.HighQuality"), 0.0f,
	TEXT("The when enabled, 64 samples are used instead of 2, resulting in a more accurate multi scattering approximation (but also more expenssive).\n"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarSkyAtmosphereMultiScatteringLUTWidth(
	TEXT("r.SkyAtmosphere.MultiScatteringLUT.Width"), 32,

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

Scope (from outer to inner):

file
function     void FSceneRenderer::RenderSkyAtmosphereLookUpTables

Source code excerpt:

	PendingRDGResources.ViewResources.SetNum(Views.Num());

	const bool bHighQualityMultiScattering = CVarSkyAtmosphereMultiScatteringLUTHighQuality.GetValueOnRenderThread() > 0;
	const bool bSecondAtmosphereLightEnabled = Scene->IsSecondAtmosphereLightEnabled();
	const bool bSeparatedAtmosphereMieRayLeigh = VolumetricCloudWantsSeparatedAtmosphereMieRayLeigh(Scene);

	FRHISamplerState* SamplerLinearClamp = TStaticSamplerState<SF_Trilinear>::GetRHI();

	// Initialise common internal parameters on the sky info for this frame