r.SkyAtmosphere.MultiScatteringLUT.SampleCount

r.SkyAtmosphere.MultiScatteringLUT.SampleCount

#Overview

name: r.SkyAtmosphere.MultiScatteringLUT.SampleCount

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

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.SkyAtmosphere.MultiScatteringLUT.SampleCount is to control the sample count used to evaluate multi-scattering in the sky atmosphere rendering system of Unreal Engine 5. This setting variable is part of the rendering subsystem, specifically the sky atmosphere rendering module.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the SkyAtmosphereRendering component. This can be seen from the file location where the variable is defined and used: Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp.

The value of this variable is set as a console variable (CVar) with a default value of 15.0f. It can be modified at runtime through the console or programmatically.

This variable interacts with another variable named CVarSkyAtmosphereMultiScatteringLUTHighQuality, which is defined right after it in the source code. While not directly interacting, these two variables are related in their purpose of controlling the quality of multi-scattering calculations.

Developers must be aware that this variable affects the performance and quality of sky atmosphere rendering. A higher sample count will result in more accurate multi-scattering approximation but will also be more computationally expensive.

Best practices when using this variable include:

  1. Balancing quality and performance by adjusting the sample count based on the target hardware and scene requirements.
  2. Consider using it in conjunction with CVarSkyAtmosphereMultiScatteringLUTHighQuality for fine-tuning the sky atmosphere rendering quality.
  3. Profile the performance impact when modifying this value, especially on lower-end hardware.

Regarding the associated variable CVarSkyAtmosphereMultiScatteringLUTSampleCount:

The purpose of CVarSkyAtmosphereMultiScatteringLUTSampleCount is the same as r.SkyAtmosphere.MultiScatteringLUT.SampleCount, as they share the same value and are essentially the same variable. It’s the C++ representation of the console variable.

This variable is used in the SetupSkyAtmosphereInternalCommonParameters function to set the MultiScatteringSampleCount parameter of the FSkyAtmosphereInternalCommonParameters struct. This indicates that the sample count is used in the internal calculations for sky atmosphere rendering.

The value of this variable is retrieved using the GetValueOnRenderThread() method, ensuring thread-safe access in the render thread.

Developers should be aware that changes to this variable will directly affect the sky atmosphere rendering calculations. It’s important to consider the performance implications when modifying this value, especially in performance-critical scenarios.

Best practices for using this variable include:

  1. Use it in conjunction with other sky atmosphere rendering parameters for a balanced approach to quality and performance.
  2. Consider exposing this setting to end-users for graphics quality options, with appropriate ranges that balance quality and performance.
  3. Monitor its impact on frame times and adjust accordingly for different hardware targets.

#Setting Variables

#References In INI files

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

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

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

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

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

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarSkyAtmosphereMultiScatteringLUTSampleCount(
	TEXT("r.SkyAtmosphere.MultiScatteringLUT.SampleCount"), 15.0f,
	TEXT("The sample count used to evaluate multi-scattering.\n"),
	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"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

////////////////////////////////////////////////////////////////////////// Multi-scattering LUT

static TAutoConsoleVariable<float> CVarSkyAtmosphereMultiScatteringLUTSampleCount(
	TEXT("r.SkyAtmosphere.MultiScatteringLUT.SampleCount"), 15.0f,
	TEXT("The sample count used to evaluate multi-scattering.\n"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarSkyAtmosphereMultiScatteringLUTHighQuality(
	TEXT("r.SkyAtmosphere.MultiScatteringLUT.HighQuality"), 0.0f,

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

Scope (from outer to inner):

file
function     static void SetupSkyAtmosphereInternalCommonParameters

Source code excerpt:


	InternalCommonParameters.TransmittanceSampleCount = CVarSkyAtmosphereTransmittanceLUTSampleCount.GetValueOnRenderThread();
	InternalCommonParameters.MultiScatteringSampleCount = CVarSkyAtmosphereMultiScatteringLUTSampleCount.GetValueOnRenderThread();

	const FSkyAtmosphereSceneProxy& SkyAtmosphereSceneProxy = SkyInfo.GetSkyAtmosphereSceneProxy();
	InternalCommonParameters.SkyLuminanceFactor = FVector3f(SkyAtmosphereSceneProxy.GetSkyLuminanceFactor());
	InternalCommonParameters.AerialPespectiveViewDistanceScale = SkyAtmosphereSceneProxy.GetAerialPespectiveViewDistanceScale();
	InternalCommonParameters.FogShowFlagFactor = ViewFamily.EngineShowFlags.Fog > 0 ? 1.0f : 0.0f;