r.VolumetricCloud
r.VolumetricCloud
#Overview
name: r.VolumetricCloud
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
VolumetricCloud components are rendered when this is not 0, otherwise ignored.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VolumetricCloud is to control the rendering of volumetric cloud components in Unreal Engine 5. It serves as a runtime toggle for enabling or disabling volumetric cloud rendering.
This setting variable is primarily used in the rendering system, specifically for volumetric cloud rendering. Based on the callsites, it’s clear that the Renderer module relies on this variable, as it’s defined and used within the VolumetricCloudRendering.cpp file.
The value of this variable is set using a TAutoConsoleVariable, which means it can be adjusted at runtime through console commands. By default, it’s set to 1, enabling volumetric cloud rendering.
The r.VolumetricCloud variable interacts with several other variables and systems:
- It’s used in conjunction with material validity checks to determine if volumetric clouds should be rendered.
- It’s used in both render thread and game thread contexts.
- It’s considered alongside engine show flags for atmosphere and clouds.
Developers must be aware of the following when using this variable:
- Setting it to 0 will disable volumetric cloud rendering entirely.
- It affects both the render thread and game thread, so changes may impact performance in both areas.
- It’s marked as render thread safe and scalable, meaning it can be adjusted for different quality settings.
Best practices when using this variable include:
- Use it for debugging or performance optimization by toggling volumetric clouds on/off.
- Consider exposing it as a user-facing graphics option for performance scaling.
- Be cautious when changing its value during gameplay, as it might affect visual consistency.
Regarding the associated variable CVarVolumetricCloud:
The purpose of CVarVolumetricCloud is the same as r.VolumetricCloud, as they share the same value and functionality. It’s the actual C++ variable that holds the console variable’s value.
CVarVolumetricCloud is used directly in the C++ code to check the current state of volumetric cloud rendering. It’s accessed using GetValueOnRenderThread() and GetValueOnGameThread() methods, depending on the context.
Developers should be aware that CVarVolumetricCloud is the internal representation of the r.VolumetricCloud console variable, and any changes to one will affect the other. When working with volumetric cloud rendering in C++ code, it’s preferable to use CVarVolumetricCloud for consistency and type safety.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:35
Scope: file
Source code excerpt:
// The runtime ON/OFF toggle
static TAutoConsoleVariable<int32> CVarVolumetricCloud(
TEXT("r.VolumetricCloud"), 1,
TEXT("VolumetricCloud components are rendered when this is not 0, otherwise ignored."),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarVolumetricCloudDistanceToSampleMaxCount(
TEXT("r.VolumetricCloud.DistanceToSampleMaxCount"), 15.0f,
TEXT("Distance in kilometers over which the total number of ray samples will be evenly distributed. Before that, the number of ray samples will span 1 to SampleCountMax, for for tracing distance ranging from 0 to DistanceToSampleCountMax (kilometers)."),
#Associated Variable and Callsites
This variable is associated with another variable named CVarVolumetricCloud
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:34
Scope: file
Source code excerpt:
// The runtime ON/OFF toggle
static TAutoConsoleVariable<int32> CVarVolumetricCloud(
TEXT("r.VolumetricCloud"), 1,
TEXT("VolumetricCloud components are rendered when this is not 0, otherwise ignored."),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarVolumetricCloudDistanceToSampleMaxCount(
TEXT("r.VolumetricCloud.DistanceToSampleMaxCount"), 15.0f,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:264
Scope (from outer to inner):
file
function bool ShouldRenderVolumetricCloud
Source code excerpt:
}
return CVarVolumetricCloud.GetValueOnRenderThread() > 0 && bCloudMaterialValid;
}
return false;
}
bool ShouldRenderVolumetricCloudWithBlueNoise_GameThread(const FScene* Scene, const FSceneView& View)
{
// We cannot use Scene->HasVolumetricCloud() here because the proxy is set form the render thread.
// We cannot use View.Family->EngineShowFlags.Atmosphere && View.Family->EngineShowFlags.Cloud because those could cause sync loading texture during gameplay when toggled.
return CVarVolumetricCloud.GetValueOnGameThread() > 0;
}
bool ShouldViewVisualizeVolumetricCloudConservativeDensity(const FViewInfo& ViewInfo, const FEngineShowFlags& EngineShowFlags)
{
return (!!EngineShowFlags.VisualizeVolumetricCloudConservativeDensity || !!EngineShowFlags.VisualizeVolumetricCloudEmptySpaceSkipping)
&& !ViewInfo.bIsReflectionCapture
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:319
Scope (from outer to inner):
file
function bool VolumetricCloudWantsSeparatedAtmosphereMieRayLeigh
Source code excerpt:
{
const FVolumetricCloudRenderSceneInfo* VCloud = Scene->GetVolumetricCloudSceneInfo();
if (VCloud && CVarVolumetricCloud.GetValueOnRenderThread() > 0)
{
const FVolumetricCloudSceneProxy& VCloudProxy = VCloud->GetVolumetricCloudSceneProxy();
return VCloudProxy.AerialPespectiveMieScatteringStartDistance > 0.0f || VCloudProxy.AerialPespectiveRayleighScatteringStartDistance > 0.0f;
}
return false;
}