r.SkyAtmosphere.SampleCountMin

r.SkyAtmosphere.SampleCountMin

#Overview

name: r.SkyAtmosphere.SampleCountMin

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.SampleCountMin is to set the minimum sample count used to compute sky and atmosphere scattering and transmittance in Unreal Engine 5’s rendering system.

This setting variable is primarily used by the rendering system, specifically the Sky Atmosphere rendering module. It is part of the Unreal Engine’s atmospheric and sky rendering subsystem.

The value of this variable is set through a console variable (CVar) in the engine’s configuration. It’s defined in the SkyAtmosphereRendering.cpp file with a default value of 2.0.

This variable interacts with several other variables related to sky atmosphere rendering, including r.SkyAtmosphere.SampleCountMax, which sets the maximum sample count. Together, these variables define the range of samples used in the rendering calculations.

Developers should be aware that:

  1. The minimum value is clamped to 1, even if a lower value is set.
  2. This variable directly affects rendering quality and performance. A higher value will result in better quality but may impact performance.
  3. It’s marked as render thread safe and scalable, meaning it can be adjusted at runtime and scales with different quality settings.

Best practices when using this variable include:

  1. Balancing between visual quality and performance based on the target hardware.
  2. Using it in conjunction with r.SkyAtmosphere.SampleCountMax to define an appropriate range.
  3. Testing different values to find the optimal balance for your specific scene and performance requirements.

Regarding the associated variable CVarSkyAtmosphereSampleCountMin:

This is the actual C++ variable that stores the console variable. It’s used internally by the engine to access the value set by r.SkyAtmosphere.SampleCountMin.

The purpose of CVarSkyAtmosphereSampleCountMin is to provide a programmatic interface to the r.SkyAtmosphere.SampleCountMin setting. It’s used in the SetupSkyAtmosphereInternalCommonParameters function to set the SampleCountMin parameter for internal calculations.

Developers should be aware that:

  1. This variable is accessed using the GetValueOnRenderThread() method, ensuring thread-safe access.
  2. Changes to r.SkyAtmosphere.SampleCountMin will be reflected in this variable.

Best practices include:

  1. Using this variable for reading the value in C++ code rather than directly accessing the console variable.
  2. Being aware of potential performance implications when frequently reading this value, especially in performance-critical code paths.

#Setting Variables

#References In INI files

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

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

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

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

Location: <Workspace>/Engine/Config/BaseScalability.ini:741, 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:48

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarSkyAtmosphereSampleCountMin(
	TEXT("r.SkyAtmosphere.SampleCountMin"), 2.0f,
	TEXT("The minimum sample count used to compute sky/atmosphere scattering and transmittance.\n")
	TEXT("The minimal value will be clamped to 1.\n"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarSkyAtmosphereSampleCountMax(
	TEXT("r.SkyAtmosphere.SampleCountMax"), 32.0f,

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

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

static TAutoConsoleVariable<float> CVarSkyAtmosphereSampleCountMin(
	TEXT("r.SkyAtmosphere.SampleCountMin"), 2.0f,
	TEXT("The minimum sample count used to compute sky/atmosphere scattering and transmittance.\n")
	TEXT("The minimal value will be clamped to 1.\n"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarSkyAtmosphereSampleCountMax(

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

Scope (from outer to inner):

file
function     static void SetupSkyAtmosphereInternalCommonParameters

Source code excerpt:

	const float AerialPerspectiveBaseSampleCountPerSlice = 1.0f;

	InternalCommonParameters.SampleCountMin = CVarSkyAtmosphereSampleCountMin.GetValueOnRenderThread();
	InternalCommonParameters.SampleCountMax = FMath::Min(SkyAtmosphereBaseSampleCount * SkyInfo.GetSkyAtmosphereSceneProxy().GetTraceSampleCountScale(), float(CVarSkyAtmosphereSampleCountMax.GetValueOnRenderThread()));
	float DistanceToSampleCountMaxInv = CVarSkyAtmosphereDistanceToSampleCountMax.GetValueOnRenderThread();

	InternalCommonParameters.FastSkySampleCountMin = CVarSkyAtmosphereFastSkyLUTSampleCountMin.GetValueOnRenderThread();
	InternalCommonParameters.FastSkySampleCountMax = FMath::Min(SkyAtmosphereBaseSampleCount * SkyInfo.GetSkyAtmosphereSceneProxy().GetTraceSampleCountScale(), float(CVarSkyAtmosphereFastSkyLUTSampleCountMax.GetValueOnRenderThread()));
	float FastSkyDistanceToSampleCountMaxInv = CVarSkyAtmosphereFastSkyLUTDistanceToSampleCountMax.GetValueOnRenderThread();