r.VolumetricCloud.ShadowMap.RaySampleHorizonMultiplier
r.VolumetricCloud.ShadowMap.RaySampleHorizonMultiplier
#Overview
name: r.VolumetricCloud.ShadowMap.RaySampleHorizonMultiplier
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The multipler on the sample count applied when the atmospheric light reach the horizon. Less pixels in the shadow map need to be traced, but rays need to travel a lot longer.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VolumetricCloud.ShadowMap.RaySampleHorizonMultiplier is to control the sample count for volumetric cloud shadow mapping when the atmospheric light reaches the horizon. This setting variable is part of Unreal Engine 5’s rendering system, specifically for volumetric cloud rendering and shadow mapping.
This setting variable is used in the Renderer module of Unreal Engine, particularly in the volumetric cloud rendering subsystem. It affects how the engine calculates and renders shadows cast by volumetric clouds, especially when the light source is near the horizon.
The value of this variable is set as a console variable with a default value of 2.0f. It can be modified at runtime through the console or configuration files.
The variable interacts with other cloud rendering parameters, such as CloudShadowRaySampleBaseCount and CVarVolumetricCloudShadowMapRaySampleMaxCount. It’s used in calculations to determine the final sample count for cloud shadow mapping.
Developers must be aware that this variable affects both performance and visual quality. Increasing the value will result in more accurate shadows near the horizon but may impact performance due to increased ray sampling.
Best practices when using this variable include:
- Balancing between visual quality and performance based on the target hardware.
- Testing different values to find the optimal setting for your specific scene and lighting conditions.
- Considering adjusting this value dynamically based on the camera’s position relative to the horizon.
The associated variable CVarVolumetricCloudShadowMapRaySampleHorizonMultiplier is the actual console variable that stores and provides access to this setting. It’s defined using TAutoConsoleVariable, which allows for runtime modification of the value.
The purpose of CVarVolumetricCloudShadowMapRaySampleHorizonMultiplier is the same as r.VolumetricCloud.ShadowMap.RaySampleHorizonMultiplier. It’s used internally by the engine to access and modify the setting value.
This console variable is part of the rendering system and is used in the same contexts as the original setting. Its value is typically accessed using the GetValueOnAnyThread() method, as seen in the provided code snippets.
Developers should be aware that modifying this console variable will directly affect the behavior of the volumetric cloud shadow mapping system. It’s important to use this variable in conjunction with other related settings to achieve the desired balance between visual quality and performance.
Best practices for using CVarVolumetricCloudShadowMapRaySampleHorizonMultiplier include:
- Using it for debug purposes or runtime adjustments during development.
- Documenting any changes made to this variable in project settings or configuration files.
- Considering exposing this setting through a user interface for advanced graphics options if runtime adjustment is desired in the final product.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:153
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarVolumetricCloudShadowMapRaySampleHorizonMultiplier(
TEXT("r.VolumetricCloud.ShadowMap.RaySampleHorizonMultiplier"), 2.0f,
TEXT("The multipler on the sample count applied when the atmospheric light reach the horizon. Less pixels in the shadow map need to be traced, but rays need to travel a lot longer."),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowMapMaxResolution(
TEXT("r.VolumetricCloud.ShadowMap.MaxResolution"), 2048,
TEXT("The maximum resolution of the cloud shadow map. The active resolution is controlled by the CloudShadowMapResolutionScale property on the Directional Light component."),
#Associated Variable and Callsites
This variable is associated with another variable named CVarVolumetricCloudShadowMapRaySampleHorizonMultiplier
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:152
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarVolumetricCloudShadowMapRaySampleHorizonMultiplier(
TEXT("r.VolumetricCloud.ShadowMap.RaySampleHorizonMultiplier"), 2.0f,
TEXT("The multipler on the sample count applied when the atmospheric light reach the horizon. Less pixels in the shadow map need to be traced, but rays need to travel a lot longer."),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<int32> CVarVolumetricCloudShadowMapMaxResolution(
TEXT("r.VolumetricCloud.ShadowMap.MaxResolution"), 2048,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:1702
Scope (from outer to inner):
file
function void FSceneRenderer::InitVolumetricCloudsForViews
lambda-function
Source code excerpt:
const float CloudShadowRaySampleBaseCount = 16.0f;
const float CloudShadowRayMapSampleCount = FMath::Max(4.0f, FMath::Min(CloudShadowRaySampleBaseCount * CloudShadowRaySampleCountScale, CVarVolumetricCloudShadowMapRaySampleMaxCount.GetValueOnAnyThread()));
const float RaySampleHorizonFactor = FMath::Max(0.0f, CVarVolumetricCloudShadowMapRaySampleHorizonMultiplier.GetValueOnAnyThread()-1.0f);
const float HorizonFactor = FMath::Clamp(0.2f / FMath::Abs(FVector3f::DotProduct(PlanetToCameraNormUp, -AtmopshericLightDirection)), 0.0f, 1.0f);
CloudGlobalShaderParams.CloudShadowmapSampleCount[LightIndex] = FVector4f(CloudShadowRayMapSampleCount + RaySampleHorizonFactor * CloudShadowRayMapSampleCount * HorizonFactor, 0.0f, 0.0f, 0.0f);
}
else
{
const FVector4f UpVector = FVector4f(0.0f, 0.0f, 1.0f, 0.0f);