r.VolumetricCloud.Shadow.ViewRaySampleMaxCount
r.VolumetricCloud.Shadow.ViewRaySampleMaxCount
#Overview
name: r.VolumetricCloud.Shadow.ViewRaySampleMaxCount
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The maximum number of samples taken while ray marching shadow rays.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VolumetricCloud.Shadow.ViewRaySampleMaxCount is to control the maximum number of samples taken while ray marching shadow rays for volumetric clouds in primary views. This setting is part of the rendering system, specifically for volumetric cloud shadows.
This setting variable is primarily used in the Renderer module of Unreal Engine 5, as evidenced by its references in the VolumetricCloudRendering.cpp file. It’s also referenced in the Engine module, specifically in the VolumetricCloudComponent class.
The value of this variable is set as a console variable (CVar) with a default value of 80. It can be modified at runtime through the console or configuration files.
This variable interacts with the ShadowViewSampleCountScale property of the VolumetricCloudComponent. The actual number of samples used is calculated by multiplying the base sample count with the ShadowViewSampleCountScale, and then clamping the result to the maximum defined by this CVar.
Developers should be aware that this variable directly affects the quality and performance of volumetric cloud shadows. Higher values will result in better quality shadows but at the cost of increased rendering time.
Best practices when using this variable include:
- Adjusting it based on the target platform’s performance capabilities.
- Using it in conjunction with the ShadowViewSampleCountScale property for fine-tuning.
- Considering the balance between visual quality and performance impact.
Regarding the associated variable CVarVolumetricCloudShadowViewRaySampleMaxCount:
This is the actual console variable that stores the value for r.VolumetricCloud.Shadow.ViewRaySampleMaxCount. It’s defined in the Renderer module and is used to control the maximum sample count at runtime.
The purpose of this variable is the same as r.VolumetricCloud.Shadow.ViewRaySampleMaxCount, but it provides the actual implementation for runtime modification and access.
This variable is used directly in the rendering code to clamp the calculated sample count. It’s important for developers to use this variable when they need to access or modify the value in C++ code, rather than trying to access the r.VolumetricCloud.Shadow.ViewRaySampleMaxCount string directly.
Best practices for using this variable include:
- Using it for runtime adjustments of the shadow quality.
- Considering its impact on performance when modifying it dynamically.
- Using it in conjunction with other volumetric cloud rendering settings for a balanced approach to quality and 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:77
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarVolumetricCloudShadowViewRaySampleMaxCount(
TEXT("r.VolumetricCloud.Shadow.ViewRaySampleMaxCount"), 80,
TEXT("The maximum number of samples taken while ray marching shadow rays."),
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."),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Components/VolumetricCloudComponent.h:99
Scope: file
Source code excerpt:
/**
* Scale the shadow tracing sample count in primary 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.ViewRaySampleMaxCount'.
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Cloud Tracing", meta = (UIMin = "0.05", UIMax = "8", ClampMin = "0.05", SliderExponent = 1.0))
float ShadowViewSampleCountScale;
/**
* 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;
#Associated Variable and Callsites
This variable is associated with another variable named CVarVolumetricCloudShadowViewRaySampleMaxCount
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:76
Scope: file
Source code excerpt:
////////////////////////////////////////////////////////////////////////// Shadow tracing
static TAutoConsoleVariable<float> CVarVolumetricCloudShadowViewRaySampleMaxCount(
TEXT("r.VolumetricCloud.Shadow.ViewRaySampleMaxCount"), 80,
TEXT("The maximum number of samples taken while ray marching shadow rays."),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarVolumetricCloudShadowReflectionRaySampleMaxCount(
TEXT("r.VolumetricCloud.Shadow.ReflectionRaySampleMaxCount"), 24,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:1614
Scope (from outer to inner):
file
function void FSceneRenderer::InitVolumetricCloudsForViews
Source code excerpt:
CloudGlobalShaderParams.SampleCountMin = FMath::Max(0, CVarVolumetricCloudSampleMinCount.GetValueOnAnyThread());
CloudGlobalShaderParams.SampleCountMax = FMath::Max(2.0f, FMath::Min(UVolumetricCloudComponent::BaseViewRaySampleCount * CloudProxy.ViewSampleCountScale, CVarVolumetricCloudViewRaySampleMaxCount.GetValueOnAnyThread()));
CloudGlobalShaderParams.ShadowSampleCountMax = FMath::Max(2.0f, FMath::Min(UVolumetricCloudComponent::BaseShadowRaySampleCount * CloudProxy.ShadowViewSampleCountScale, CVarVolumetricCloudShadowViewRaySampleMaxCount.GetValueOnAnyThread()));
CloudGlobalShaderParams.ShadowTracingMaxDistance = KilometersToCentimeters * FMath::Max(0.1f, CloudProxy.ShadowTracingDistance);
CloudGlobalShaderParams.InvDistanceToSampleCountMax = 1.0f / FMath::Max(1.0f, KilometersToCentimeters * CVarVolumetricCloudDistanceToSampleMaxCount.GetValueOnAnyThread());
CloudGlobalShaderParams.StopTracingTransmittanceThreshold = FMath::Clamp(CloudProxy.StopTracingTransmittanceThreshold, 0.0f, 1.0f);
auto PrepareCloudShadowMapLightData = [&](FLightSceneProxy* AtmosphericLight, int LightIndex)
{