r.SkyAtmosphere.DistanceToSampleCountMax
r.SkyAtmosphere.DistanceToSampleCountMax
#Overview
name: r.SkyAtmosphere.DistanceToSampleCountMax
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The distance in kilometer after which SampleCountMax samples will be used to ray march the atmosphere.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.SkyAtmosphere.DistanceToSampleCountMax is to control the distance at which the maximum number of samples will be used for ray marching the atmosphere in the Sky Atmosphere rendering system of Unreal Engine 5.
This setting variable is primarily used by the rendering system, specifically the Sky Atmosphere rendering module. It is part of the Renderer subsystem in Unreal Engine 5.
The value of this variable is set through a console variable (CVar) named CVarSkyAtmosphereDistanceToSampleCountMax. It is initialized with a default value of 150.0f kilometers and can be modified at runtime.
The associated variable CVarSkyAtmosphereDistanceToSampleCountMax interacts directly with r.SkyAtmosphere.DistanceToSampleCountMax, as they share the same value. This CVar is used in the SetupSkyAtmosphereInternalCommonParameters function to set the DistanceToSampleCountMaxInv parameter.
Developers should be aware that this variable affects the quality and performance of the sky atmosphere rendering. A higher value will result in using the maximum sample count at greater distances, potentially improving visual quality but at the cost of performance.
Best practices when using this variable include:
- Adjusting it based on the scale of your scene and the desired balance between visual quality and performance.
- Testing different values to find the optimal setting for your specific use case.
- Considering the interaction with other sky atmosphere settings, such as sample count min and max.
Regarding the associated variable CVarSkyAtmosphereDistanceToSampleCountMax:
The purpose of CVarSkyAtmosphereDistanceToSampleCountMax is to provide a programmatic interface to control the r.SkyAtmosphere.DistanceToSampleCountMax setting within the engine’s code.
This variable is used in the Renderer module, specifically in the Sky Atmosphere rendering system.
The value of CVarSkyAtmosphereDistanceToSampleCountMax is set when the CVar is initialized and can be modified at runtime through console commands or code.
It interacts directly with the r.SkyAtmosphere.DistanceToSampleCountMax setting and is used to retrieve the current value in the SetupSkyAtmosphereInternalCommonParameters function.
Developers should be aware that modifying this CVar will directly affect the sky atmosphere rendering. It’s thread-safe and can be changed on the render thread.
Best practices for using CVarSkyAtmosphereDistanceToSampleCountMax include:
- Using it to dynamically adjust the sky atmosphere rendering based on runtime conditions.
- Ensuring any modifications are made on the correct thread (render thread in this case).
- Considering the performance implications when changing this value, especially in performance-critical scenarios.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:60
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarSkyAtmosphereDistanceToSampleCountMax(
TEXT("r.SkyAtmosphere.DistanceToSampleCountMax"), 150.0f,
TEXT("The distance in kilometer after which SampleCountMax samples will be used to ray march the atmosphere."),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<int32> CVarSkyAtmosphereSampleLightShadowmap(
TEXT("r.SkyAtmosphere.SampleLightShadowmap"), 1,
TEXT("Enable the sampling of atmospheric lights shadow map in order to produce volumetric shadows."),
#Associated Variable and Callsites
This variable is associated with another variable named CVarSkyAtmosphereDistanceToSampleCountMax
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:59
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarSkyAtmosphereDistanceToSampleCountMax(
TEXT("r.SkyAtmosphere.DistanceToSampleCountMax"), 150.0f,
TEXT("The distance in kilometer after which SampleCountMax samples will be used to ray march the atmosphere."),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<int32> CVarSkyAtmosphereSampleLightShadowmap(
TEXT("r.SkyAtmosphere.SampleLightShadowmap"), 1,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:1248
Scope (from outer to inner):
file
function static void SetupSkyAtmosphereInternalCommonParameters
Source code excerpt:
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();
InternalCommonParameters.CameraAerialPerspectiveVolumeDepthResolution = float(CameraAerialPerspectiveVolumeDepthResolution);