r.VolumetricCloud.Shadow.ReflectionRaySampleMaxCount

r.VolumetricCloud.Shadow.ReflectionRaySampleMaxCount

#Overview

name: r.VolumetricCloud.Shadow.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.Shadow.ReflectionRaySampleMaxCount is to control the maximum number of samples taken while ray marching shadow rays in reflections for volumetric clouds. This setting is part of the rendering system, specifically for volumetric cloud shadow rendering.

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

The value of this variable is set as a console variable with a default value of 24. It can be modified at runtime through the console or configuration files.

This variable interacts with other cloud rendering parameters, particularly the ShadowReflectionViewSampleCountScaleValue in the VolumetricCloudComponent. The actual number of samples used is calculated by combining these values, as seen in the CreateCloudPassUniformBuffer function.

Developers should be aware that this variable affects the quality and performance of volumetric cloud shadows in reflections. Higher values will produce more accurate shadows but at the cost of increased rendering time.

Best practices when using this variable include:

  1. Balancing quality and performance based on target hardware.
  2. Considering the interaction with other cloud rendering settings.
  3. Using it in conjunction with scalability settings for different quality levels.

Regarding the associated variable CVarVolumetricCloudShadowReflectionRaySampleMaxCount:

This is the actual console variable implementation of r.VolumetricCloud.Shadow.ReflectionRaySampleMaxCount. It’s defined as a TAutoConsoleVariable in the Unreal Engine codebase.

The purpose of this variable is the same as r.VolumetricCloud.Shadow.ReflectionRaySampleMaxCount - to control the maximum number of samples for shadow ray marching in reflections.

It’s used directly in the rendering code to clamp the calculated sample count, ensuring that the number of samples doesn’t exceed the specified maximum.

This variable is set through the console or configuration files, and its value can be accessed at runtime using the GetValueOnAnyThread() method.

Developers should be aware that changes to this variable will take effect immediately in the rendering pipeline. It’s marked as render thread safe and scalable, meaning it can be adjusted based on quality settings.

Best practices for using this variable include:

  1. Modifying it through the appropriate console commands or configuration files.
  2. Considering its impact on performance when adjusting its value.
  3. Using it in conjunction with other volumetric cloud rendering settings for optimal 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:82

Scope: file

Source code excerpt:


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

static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowSampleAtmosphericLightShadowmap(
	TEXT("r.VolumetricCloud.Shadow.SampleAtmosphericLightShadowmap"), 1,
	TEXT("Enable the sampling of atmospheric lights shadow map in order to produce volumetric shadows."),

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

Scope: file

Source code excerpt:

	/**
	 * Scale the shadow tracing sample count in reflection views, only used with Advanced Output ray marched shadows. Quality level scalability CVARs affect the maximum range.
	 * The sample count resolution is still clamped according to scalability setting to 'r.VolumetricCloud.Shadow.ReflectionRaySampleMaxCount'.
	 */
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Cloud Tracing", meta = (UIMin = "0.05", UIMax = "8", ClampMin = "0.05", SliderExponent = 1.0))
	float ShadowReflectionViewSampleCountScaleValue;
	UPROPERTY()
	float ShadowReflectionViewSampleCountScale_DEPRECATED;
	UPROPERTY()
	float ShadowReflectionSampleCountScale_DEPRECATED;

	/**

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

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

static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowSampleAtmosphericLightShadowmap(
	TEXT("r.VolumetricCloud.Shadow.SampleAtmosphericLightShadowmap"), 1,

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

Scope (from outer to inner):

file
function     static TRDGUniformBufferRef<FRenderVolumetricCloudGlobalParameters> CreateCloudPassUniformBuffer

Source code excerpt:

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

	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;