r.VolumetricCloud.EmptySpaceSkipping.StartTracingSliceBias

r.VolumetricCloud.EmptySpaceSkipping.StartTracingSliceBias

#Overview

name: r.VolumetricCloud.EmptySpaceSkipping.StartTracingSliceBias

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.EmptySpaceSkipping.StartTracingSliceBias is to control the starting point of ray tracing for volumetric clouds by biasing the start depth with a certain number of slices. This setting is part of the volumetric cloud rendering system in Unreal Engine 5.

This setting variable is primarily used in the Renderer module, specifically within the volumetric cloud rendering subsystem. It’s referenced in the VolumetricCloudRendering.cpp file, which is responsible for rendering volumetric clouds in the engine.

The value of this variable is set through a console variable (CVar) system, allowing it to be adjusted at runtime. It’s initialized with a default value of 0.0f, meaning no bias by default.

This variable interacts closely with the empty space skipping optimization technique used in volumetric cloud rendering. It’s used in conjunction with other variables related to empty space skipping, such as CVarVolumetricCloudEmptySpaceSkippingSampleCorners.

Developers should be aware that this variable can affect the performance and visual quality of volumetric clouds. A negative value (-1) means biasing one slice towards the viewpoint, which could potentially improve performance by starting the ray tracing closer to the visible cloud area. However, setting this value incorrectly could lead to visual artifacts or missed cloud details.

Best practices when using this variable include:

  1. Experiment with small adjustments to find the optimal balance between performance and visual quality.
  2. Consider the scene’s specific requirements and the typical viewing distances of clouds.
  3. Test thoroughly across different scenarios to ensure the chosen value doesn’t cause issues in edge cases.

Regarding the associated variable CVarVolumetricCloudEmptySpaceSkippingStartTracingSliceBias:

This is the actual console variable that stores and provides access to the r.VolumetricCloud.EmptySpaceSkipping.StartTracingSliceBias value. It’s defined as a TAutoConsoleVariable, allowing for runtime adjustments.

The purpose of this variable is to provide a way to access and modify the start tracing slice bias value from both C++ code and the console. It’s used directly in the rendering code to set the StartTracingSliceBias parameter in the volumetric cloud rendering pass.

Developers should be aware that changes to this variable will take effect on the render thread, as indicated by the ECVF_RenderThreadSafe flag. It’s also marked with ECVF_Scalability, suggesting that it can be used for performance scaling.

When working with this variable, developers should:

  1. Use GetValueOnRenderThread() when accessing its value in render thread code.
  2. Consider exposing this setting in user-facing graphics options if fine-tuning of cloud rendering is desired.
  3. Be cautious when modifying this value dynamically, as it could cause sudden changes in cloud appearance or performance.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarVolumetricCloudEmptySpaceSkippingStartTracingSliceBias(
	TEXT("r.VolumetricCloud.EmptySpaceSkipping.StartTracingSliceBias"), 0.0f,
	TEXT("The number of slices to bias the start depth with. A valuie of -1 means a bias of one slice towards the view point."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricCloudEmptySpaceSkippingSampleCorners(
	TEXT("r.VolumetricCloud.EmptySpaceSkipping.SampleCorners"), 1,
	TEXT("0 means center samples only, >0 means corner are also sampled."),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarVolumetricCloudEmptySpaceSkippingStartTracingSliceBias(
	TEXT("r.VolumetricCloud.EmptySpaceSkipping.StartTracingSliceBias"), 0.0f,
	TEXT("The number of slices to bias the start depth with. A valuie of -1 means a bias of one slice towards the view point."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricCloudEmptySpaceSkippingSampleCorners(
	TEXT("r.VolumetricCloud.EmptySpaceSkipping.SampleCorners"), 1,

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

Scope (from outer to inner):

file
function     void FSceneRenderer::RenderVolumetricCloudsInternal

Source code excerpt:

			PassParameters->StartTracingDistanceTextureResolution = FVector2f(EmptySpaceSkippingTextureResolution.X, EmptySpaceSkippingTextureResolution.Y);
			PassParameters->StartTracingSampleVolumeDepth = GetEmptySpaceSkippingVolumeDepth();
			PassParameters->StartTracingSliceBias = CVarVolumetricCloudEmptySpaceSkippingStartTracingSliceBias.GetValueOnRenderThread();

			const bool bCloudEmptySpaceSkippingDebug = false;
			//if (bCloudEmptySpaceSkippingDebug)
			//{
			//	ShaderPrint::SetEnabled(true);
			//	ShaderPrint::RequestSpaceForLines(65536);