r.VolumetricCloud.ReflectionRaySampleMaxCount

r.VolumetricCloud.ReflectionRaySampleMaxCount

#Overview

name: r.VolumetricCloud.ReflectionRaySampleMaxCount

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.VolumetricCloud.ReflectionRaySampleMaxCount is to control the maximum number of samples taken while ray marching primary rays in reflections for volumetric clouds. This setting is part of Unreal Engine 5’s volumetric cloud rendering system.

This setting variable is primarily used in the Renderer module of Unreal Engine, specifically within the volumetric cloud rendering subsystem. It’s defined in the VolumetricCloudRendering.cpp file, which is part of the Renderer module.

The value of this variable is set as a console variable (CVar) with an initial value of 80. It can be modified at runtime through console commands or programmatically.

This variable interacts with other settings related to volumetric cloud rendering, particularly those affecting reflection quality and performance. It’s used in conjunction with the ReflectionViewSampleCountScale property of the VolumetricCloudComponent to determine the final sample count.

Developers should be aware that this variable directly impacts the quality and performance of volumetric cloud reflections. Higher values will result in better quality reflections but at the cost of increased rendering time.

Best practices for using this variable include:

  1. Adjusting it based on the target hardware and performance requirements.
  2. Using it in combination with ReflectionViewSampleCountScale for fine-tuning.
  3. Testing different values to find the optimal balance between quality and performance.

Regarding the associated variable CVarVolumetricCloudReflectionRaySampleMaxCount:

This is the actual console variable that stores the value for r.VolumetricCloud.ReflectionRaySampleMaxCount. It’s defined as a TAutoConsoleVariable in the Unreal Engine codebase.

The purpose of this variable is the same as r.VolumetricCloud.ReflectionRaySampleMaxCount - to control the maximum number of samples for volumetric cloud reflections.

It’s used directly in the CreateCloudPassUniformBuffer function to set the SampleCountMax parameter for volumetric cloud rendering. This function is likely called during the rendering pipeline setup for volumetric clouds.

When using this variable, developers should note that it’s accessed using GetValueOnAnyThread(), which means it can be safely read from any thread. However, changes to this value might not take effect immediately in all rendering contexts.

Best practices for CVarVolumetricCloudReflectionRaySampleMaxCount include:

  1. Using it for dynamic adjustments to reflection quality during gameplay or in response to performance metrics.
  2. Considering its impact on both visual quality and performance when modifying it.
  3. Coordinating its use with other volumetric cloud rendering settings for consistent results.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarVolumetricCloudReflectionRaySampleMaxCount(
	TEXT("r.VolumetricCloud.ReflectionRaySampleMaxCount"), 80,
	TEXT("The maximum number of samples taken while ray marching primary rays in reflections."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricCloudStepSizeOnZeroConservativeDensity(
	TEXT("r.VolumetricCloud.StepSizeOnZeroConservativeDensity"), 1,
	TEXT("Raymarch step size when a sample giving zero conservative density is encountered. If > 1, performance will likely improve but banding artifacts can show up if too large."),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Components/VolumetricCloudComponent.h:88

Scope: file

Source code excerpt:

	/**
	 * Scale the tracing sample count in reflection views. Quality level scalability CVARs affect the maximum range.
	 * The sample count resolution is still clamped according to scalability setting to 'r.VolumetricCloud.ReflectionRaySampleMaxCount'.
	 */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Cloud Tracing", meta = (UIMin = "0.05", UIMax = "8", ClampMin = "0.05", SliderExponent = 1.0))
	float ReflectionViewSampleCountScaleValue;
	UPROPERTY()
	float ReflectionViewSampleCountScale_DEPRECATED;
	UPROPERTY()
	float ReflectionSampleCountScale_DEPRECATED;

	/**

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarVolumetricCloudReflectionRaySampleMaxCount(
	TEXT("r.VolumetricCloud.ReflectionRaySampleMaxCount"), 80,
	TEXT("The maximum number of samples taken while ray marching primary rays in reflections."),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricCloudStepSizeOnZeroConservativeDensity(
	TEXT("r.VolumetricCloud.StepSizeOnZeroConservativeDensity"), 1,

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

Scope (from outer to inner):

file
function     static TRDGUniformBufferRef<FRenderVolumetricCloudGlobalParameters> CreateCloudPassUniformBuffer

Source code excerpt:

		VolumetricCloudParams.VolumetricCloud.SampleCountMax = FMath::Max(2.0f, FMath::Min(
			UVolumetricCloudComponent::BaseViewRaySampleCount * CloudInfo.GetVolumetricCloudSceneProxy().ReflectionViewSampleCountScale,
			CVarVolumetricCloudReflectionRaySampleMaxCount.GetValueOnAnyThread()));
		VolumetricCloudParams.VolumetricCloud.ShadowSampleCountMax = FMath::Max(2.0f, FMath::Min(
			UVolumetricCloudComponent::BaseShadowRaySampleCount * CloudInfo.GetVolumetricCloudSceneProxy().ShadowReflectionViewSampleCountScale,
			CVarVolumetricCloudShadowReflectionRaySampleMaxCount.GetValueOnAnyThread()));
	}

	VolumetricCloudParams.EnableAerialPerspectiveSampling = CloudRC.bSkipAerialPerspective ? 0 : 1;