r.VolumetricCloud.EnableDistantSkyLightSampling
r.VolumetricCloud.EnableDistantSkyLightSampling
#Overview
name: r.VolumetricCloud.EnableDistantSkyLightSampling
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable/disable the distant sky light contribution on clouds.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VolumetricCloud.EnableDistantSkyLightSampling is to control the distant sky light contribution on volumetric clouds in the rendering system of Unreal Engine 5.
This setting variable is primarily used by the Renderer module, specifically within the volumetric cloud rendering subsystem. It’s defined and used in the VolumetricCloudRendering.cpp file, which is part of the Runtime/Renderer component of the engine.
The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 1, meaning the distant sky light contribution is enabled by default. Developers can change this value at runtime using console commands or through project settings.
This variable interacts closely with other volumetric cloud rendering parameters, such as r.VolumetricCloud.EnableAtmosphericLightsSampling. Together, these variables control different aspects of the cloud lighting and rendering process.
Developers must be aware that this variable affects the visual quality and performance of volumetric cloud rendering. Enabling distant sky light sampling (value set to 1) provides more accurate and potentially more realistic cloud lighting, but may have a performance cost.
Best practices when using this variable include:
- Consider the performance implications when enabling this feature, especially on lower-end hardware.
- Use it in conjunction with other volumetric cloud settings for a balanced approach to visual quality and performance.
- Test the visual impact thoroughly in different lighting scenarios to ensure desired results.
The associated variable CVarVolumetricCloudEnableDistantSkyLightSampling is the actual console variable object that controls this setting. It’s used internally by the engine to retrieve the current value of the setting and apply it to the rendering process. The value of this variable is queried in the CreateCloudPassUniformBuffer function, where it’s used to set up the parameters for the volumetric cloud rendering pass.
When working with CVarVolumetricCloudEnableDistantSkyLightSampling, developers should:
- Use GetValueOnAnyThread() to safely retrieve its value from any thread.
- Be aware that changes to this variable will affect the next frame’s rendering, not immediately.
- Consider exposing this setting in the game’s graphics options menu to allow users to fine-tune their experience if appropriate for your project.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:185
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarVolumetricCloudEnableDistantSkyLightSampling(
TEXT("r.VolumetricCloud.EnableDistantSkyLightSampling"), 1,
TEXT("Enable/disable the distant sky light contribution on clouds."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarVolumetricCloudEnableAtmosphericLightsSampling(
TEXT("r.VolumetricCloud.EnableAtmosphericLightsSampling"), 1,
TEXT("Enable/disable atmospheric lights contribution on clouds."),
#Associated Variable and Callsites
This variable is associated with another variable named CVarVolumetricCloudEnableDistantSkyLightSampling
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:184
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarVolumetricCloudEnableDistantSkyLightSampling(
TEXT("r.VolumetricCloud.EnableDistantSkyLightSampling"), 1,
TEXT("Enable/disable the distant sky light contribution on clouds."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarVolumetricCloudEnableAtmosphericLightsSampling(
TEXT("r.VolumetricCloud.EnableAtmosphericLightsSampling"), 1,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:2171
Scope (from outer to inner):
file
function static TRDGUniformBufferRef<FRenderVolumetricCloudGlobalParameters> CreateCloudPassUniformBuffer
Source code excerpt:
VolumetricCloudParams.EnableAerialPerspectiveSampling = CloudRC.bSkipAerialPerspective ? 0 : 1;
VolumetricCloudParams.EnableHeightFog = VolumetricCloudParams.EnableHeightFog && !CloudRC.bSkipHeightFog ? 1 : 0;
VolumetricCloudParams.EnableDistantSkyLightSampling = CVarVolumetricCloudEnableDistantSkyLightSampling.GetValueOnAnyThread() > 0 ? 1 : 0;
VolumetricCloudParams.EnableAtmosphericLightsSampling = CVarVolumetricCloudEnableAtmosphericLightsSampling.GetValueOnAnyThread() > 0 ? 1 : 0;
VolumetricCloudParams.AerialPerspectiveRayOnlyStartDistanceKm = CloudInfo.GetVolumetricCloudSceneProxy().AerialPespectiveRayleighScatteringStartDistance;
VolumetricCloudParams.AerialPerspectiveRayOnlyFadeDistanceKmInv = 1.0f / FMath::Max(CloudInfo.GetVolumetricCloudSceneProxy().AerialPespectiveRayleighScatteringFadeDistance, 0.00001f);// One centimeter minimum
VolumetricCloudParams.AerialPerspectiveMieOnlyStartDistanceKm = CloudInfo.GetVolumetricCloudSceneProxy().AerialPespectiveMieScatteringStartDistance;
VolumetricCloudParams.AerialPerspectiveMieOnlyFadeDistanceKmInv = 1.0f / FMath::Max(CloudInfo.GetVolumetricCloudSceneProxy().AerialPespectiveMieScatteringFadeDistance, 0.00001f);// One centimeter minimum