r.VolumetricCloud.SkyAO.SnapLength

r.VolumetricCloud.SkyAO.SnapLength

#Overview

name: r.VolumetricCloud.SkyAO.SnapLength

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.VolumetricCloud.SkyAO.SnapLength is to control the snapping size of the cloud sky ambient occlusion (AO) texture position to prevent flickering in the volumetric cloud rendering system.

This setting variable is primarily used in the volumetric cloud rendering subsystem of Unreal Engine 5. It is part of the renderer module, specifically the volumetric cloud rendering component.

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

The variable interacts with other volumetric cloud rendering parameters, particularly those related to sky ambient occlusion. It’s used in conjunction with other variables like CloudSkyAOStrength and GetVolumetricCloudSkyAOExtentKm to calculate various rendering parameters.

Developers should be aware that this variable affects the visual stability of volumetric clouds, especially in terms of ambient occlusion. Changing this value can impact the performance and visual quality of cloud rendering.

Best practices when using this variable include:

  1. Adjusting it carefully to find a balance between visual stability and performance.
  2. Testing different values in various lighting conditions to ensure consistent quality.
  3. Considering its impact on different hardware configurations, as it may affect performance differently on various systems.

The associated variable CVarVolumetricCloudSkyAOSnapLength is the actual console variable implementation of r.VolumetricCloud.SkyAO.SnapLength. It’s defined using TAutoConsoleVariable, which allows for runtime modification of the value.

The purpose of CVarVolumetricCloudSkyAOSnapLength is the same as r.VolumetricCloud.SkyAO.SnapLength – to control the snapping size of the cloud sky AO texture position.

This variable is used directly in the InitVolumetricCloudsForViews function of the FSceneRenderer class. It’s retrieved using the GetValueOnAnyThread() method and then used in calculations for world size snapping and volume depth range.

Developers should be aware that changes to this variable will immediately affect the volumetric cloud rendering. It’s thread-safe and can be modified on the render thread, which is important for performance considerations.

Best practices for using CVarVolumetricCloudSkyAOSnapLength include:

  1. Using it in conjunction with other volumetric cloud rendering settings for optimal results.
  2. Monitoring its impact on performance, especially in scenes with extensive cloud coverage.
  3. Considering its interaction with the sky light component and other atmospheric rendering features.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:111

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarVolumetricCloudSkyAOSnapLength(
	TEXT("r.VolumetricCloud.SkyAO.SnapLength"), 20.0f,
	TEXT("Snapping size in kilometers of the cloud sky AO texture position to avoid flickering."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricCloudSkyAOMaxResolution(
	TEXT("r.VolumetricCloud.SkyAO.MaxResolution"), 2048,
	TEXT("The maximum resolution of the texture storing ambient occlusion information for the environment lighting coming from sky light. The active resolution is controlled by the CloudAmbientOcclusionMapResolutionScale property on the Skylight component."),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:110

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarVolumetricCloudSkyAOSnapLength(
	TEXT("r.VolumetricCloud.SkyAO.SnapLength"), 20.0f,
	TEXT("Snapping size in kilometers of the cloud sky AO texture position to avoid flickering."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricCloudSkyAOMaxResolution(
	TEXT("r.VolumetricCloud.SkyAO.MaxResolution"), 2048,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:1730

Scope (from outer to inner):

file
function     void FSceneRenderer::InitVolumetricCloudsForViews

Source code excerpt:

				CloudGlobalShaderParams.CloudSkyAOStrength = GetVolumetricCloudSkyAOStrength(SkyLight);

				const float WorldSizeSnap = CVarVolumetricCloudSkyAOSnapLength.GetValueOnAnyThread() * KilometersToCentimeters;
				const float SphereDiameter = GetVolumetricCloudSkyAOExtentKm(SkyLight) * KilometersToCentimeters * 2.0f;
				const float VolumeDepthRange = (CloudProxy.LayerBottomAltitudeKm + CloudProxy.LayerHeightKm) * KilometersToCentimeters + WorldSizeSnap;
				const float NearPlane = 0.0f;
				const float FarPlane = 2.0f * VolumeDepthRange;
				const float ZScale = 1.0f / (FarPlane - NearPlane);
				const float ZOffset = -NearPlane;