r.SkyAtmosphere.FastSkyLUT.DistanceToSampleCountMax

r.SkyAtmosphere.FastSkyLUT.DistanceToSampleCountMax

#Overview

name: r.SkyAtmosphere.FastSkyLUT.DistanceToSampleCountMax

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.FastSkyLUT.DistanceToSampleCountMax is to control the distance at which the maximum number of samples will be used for ray marching the atmosphere in the fast sky light lookup table (LUT) calculation for the Sky Atmosphere rendering system in Unreal Engine 5.

This setting variable is primarily used in the rendering system, specifically for the Sky Atmosphere rendering module. It is part of the optimization techniques used to balance performance and visual quality when rendering atmospheric effects.

The value of this variable is set as a console variable (CVar) with a default value of 150.0f, representing 150 kilometers. It can be modified at runtime through the console or configuration files.

The associated variable CVarSkyAtmosphereFastSkyLUTDistanceToSampleCountMax interacts directly with this setting. They share the same value and purpose.

Developers should be aware that this variable affects the trade-off between rendering quality and performance. A higher value will result in using the maximum sample count for ray marching at greater distances, potentially improving visual quality at the cost of performance.

Best practices when using this variable include:

  1. Adjusting it based on the scale and requirements of your specific scene.
  2. Balancing it with other Sky Atmosphere settings for optimal performance and visual quality.
  3. Testing different values to find the sweet spot for your project’s needs.

Regarding the associated variable CVarSkyAtmosphereFastSkyLUTDistanceToSampleCountMax:

This is the actual console variable that stores and provides access to the r.SkyAtmosphere.FastSkyLUT.DistanceToSampleCountMax value. It is defined using TAutoConsoleVariable, which allows for runtime modification.

The variable is used in the SetupSkyAtmosphereInternalCommonParameters function to set up internal parameters for Sky Atmosphere rendering. It directly influences the calculation of sample counts for ray marching, affecting the balance between rendering quality and performance.

Developers should treat this variable identically to r.SkyAtmosphere.FastSkyLUT.DistanceToSampleCountMax, as they represent the same setting. When modifying one, the other will reflect the same change.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarSkyAtmosphereFastSkyLUTDistanceToSampleCountMax(
	TEXT("r.SkyAtmosphere.FastSkyLUT.DistanceToSampleCountMax"), 150.0f,
	TEXT("Fast sky distance in kilometer after which at which SampleCountMax samples will be used to ray march the atmosphere."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarSkyAtmosphereFastSkyLUTWidth(
	TEXT("r.SkyAtmosphere.FastSkyLUT.Width"), 192,
	TEXT(""),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarSkyAtmosphereFastSkyLUTDistanceToSampleCountMax(
	TEXT("r.SkyAtmosphere.FastSkyLUT.DistanceToSampleCountMax"), 150.0f,
	TEXT("Fast sky distance in kilometer after which at which SampleCountMax samples will be used to ray march the atmosphere."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarSkyAtmosphereFastSkyLUTWidth(
	TEXT("r.SkyAtmosphere.FastSkyLUT.Width"), 192,

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

Scope (from outer to inner):

file
function     static void SetupSkyAtmosphereInternalCommonParameters

Source code excerpt:

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

	InternalCommonParameters.CameraAerialPerspectiveVolumeDepthResolution = float(CameraAerialPerspectiveVolumeDepthResolution);
	InternalCommonParameters.CameraAerialPerspectiveVolumeDepthResolutionInv = 1.0f / InternalCommonParameters.CameraAerialPerspectiveVolumeDepthResolution;
	InternalCommonParameters.CameraAerialPerspectiveVolumeDepthSliceLengthKm = CameraAerialPerspectiveVolumeDepthSliceLengthKm;
	InternalCommonParameters.CameraAerialPerspectiveVolumeDepthSliceLengthKmInv = 1.0f / CameraAerialPerspectiveVolumeDepthSliceLengthKm;
	InternalCommonParameters.CameraAerialPerspectiveSampleCountPerSlice = FMath::Max(AerialPerspectiveBaseSampleCountPerSlice, FMath::Min(2.0f * SkyInfo.GetSkyAtmosphereSceneProxy().GetTraceSampleCountScale(), float(CVarSkyAtmosphereAerialPerspectiveLUTSampleCountMaxPerSlice.GetValueOnRenderThread())));