r.VolumetricFog.ConservativeDepth
r.VolumetricFog.ConservativeDepth
#Overview
name: r.VolumetricFog.ConservativeDepth
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
[Experimental] Whether to allow the volumetric to use conservative depth to accelerate computations.
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VolumetricFog.ConservativeDepth is to control whether the volumetric fog system uses conservative depth to accelerate computations in Unreal Engine’s rendering system.
This setting variable is primarily used in the volumetric fog rendering subsystem of Unreal Engine. It’s part of the renderer module, specifically in the VolumetricFog.cpp file.
The value of this variable is set through the console variable system in Unreal Engine. It’s defined as an FAutoConsoleVariableRef, which means it can be changed at runtime through console commands or configuration files.
The associated variable GVolumetricFogConservativeDepth directly interacts with r.VolumetricFog.ConservativeDepth. They share the same value, with GVolumetricFogConservativeDepth being the actual integer variable used in the C++ code.
Developers should be aware that this feature is marked as [Experimental] in the code comments. This suggests that it may not be fully stable or optimized, and its behavior might change in future engine versions.
When using this variable, developers should consider:
- It affects performance and visual quality of volumetric fog rendering.
- It’s a scalability option, as indicated by the ECVF_Scalability flag.
- It’s render thread safe (ECVF_RenderThreadSafe), meaning it can be changed without causing thread safety issues.
Best practices for using this variable include:
- Testing thoroughly in different scenarios to ensure it doesn’t introduce visual artifacts.
- Using it as part of a broader performance optimization strategy for volumetric fog.
- Being cautious about enabling it in production builds due to its experimental nature.
Regarding the associated variable GVolumetricFogConservativeDepth:
- It’s an integer variable used internally in the C++ code to control the conservative depth feature.
- It’s checked in multiple places to determine whether to use conservative depth textures and calculations.
- When GVolumetricFogConservativeDepth is greater than 0, the conservative depth feature is enabled.
- It affects the creation and use of conservative depth textures in the volumetric fog rendering process.
- It also interacts with temporal reprojection features when enabled.
Developers should be aware that changing GVolumetricFogConservativeDepth directly is not recommended. Instead, they should use the r.VolumetricFog.ConservativeDepth console variable to control this feature.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:130
Scope: file
Source code excerpt:
int32 GVolumetricFogConservativeDepth = 0;
FAutoConsoleVariableRef CVarVolumetricFogConservativeDepth(
TEXT("r.VolumetricFog.ConservativeDepth"),
GVolumetricFogConservativeDepth,
TEXT("[Experimental] Whether to allow the volumetric to use conservative depth to accelerate computations."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
int GVolumetricFogInjectRaytracedLights = 0;
#Associated Variable and Callsites
This variable is associated with another variable named GVolumetricFogConservativeDepth
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:128
Scope: file
Source code excerpt:
);
int32 GVolumetricFogConservativeDepth = 0;
FAutoConsoleVariableRef CVarVolumetricFogConservativeDepth(
TEXT("r.VolumetricFog.ConservativeDepth"),
GVolumetricFogConservativeDepth,
TEXT("[Experimental] Whether to allow the volumetric to use conservative depth to accelerate computations."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
int GVolumetricFogInjectRaytracedLights = 0;
FAutoConsoleVariableRef CVarVolumetricInjectRaytracedLights(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:776
Scope (from outer to inner):
file
function void FSceneRenderer::RenderLocalLightsForVolumetricFog
Source code excerpt:
PassParameters->VirtualShadowMapSamplingParameters = VirtualShadowMapArray.GetSamplingParameters(GraphBuilder);
PassParameters->ConservativeDepthTexture = ConservativeDepthTexture;
PassParameters->UseConservativeDepthTexture = GVolumetricFogConservativeDepth > 0 ? 1 : 0;
PassParameters->VirtualShadowMapId = VirtualShadowMapId;
const FProjectedShadowInfo* ProjectedShadowInfo = GetShadowForInjectionIntoVolumetricFog(VisibleLightInfo);
const bool bDynamicallyShadowed = ProjectedShadowInfo != NULL;
GetVolumeShadowingShaderParameters(GraphBuilder, View, LightSceneInfo, ProjectedShadowInfo, PassParameters->VolumeShadowingShaderParameters);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:1375
Scope (from outer to inner):
file
function void FSceneRenderer::ComputeVolumetricFog
Source code excerpt:
FRDGTextureRef ConservativeDepthTexture;
// To use a depth target format, and depth tests, we will have to render depth from a PS depth output. Keeping it simple for now with all the tests happening in shader.
if (GVolumetricFogConservativeDepth > 0)
{
FIntPoint ConservativeDepthTextureSize = FIntPoint(VolumetricFogViewGridSize.X, VolumetricFogViewGridSize.Y);
ConservativeDepthTexture = GraphBuilder.CreateTexture(FRDGTextureDesc::Create2D(ConservativeDepthTextureSize, PF_R16F,
FClearValueBinding::Black, TexCreate_RenderTargetable | TexCreate_ShaderResource | TexCreate_UAV), TEXT("VolumetricFog.ConservativeDepthTexture"));
AddGenerateConservativeDepthBufferPass(View, GraphBuilder, ConservativeDepthTexture, GetVolumetricFogGridPixelSize());
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:1520
Scope (from outer to inner):
file
function void FSceneRenderer::ComputeVolumetricFog
Source code excerpt:
PassParameters->LocalShadowedLightScattering = LocalShadowedLightScattering;
PassParameters->ConservativeDepthTexture = ConservativeDepthTexture;
PassParameters->UseConservativeDepthTexture = GVolumetricFogConservativeDepth > 0 ? 1 : 0;
PassParameters->UseEmissive = bUseEmissive ? 1 : 0;
if (GVolumetricFogConservativeDepth > 0 && bUseTemporalReprojection && View.ViewState->PrevLightScatteringConservativeDepthTexture.IsValid())
{
PassParameters->PrevConservativeDepthTexture = GraphBuilder.RegisterExternalTexture(View.ViewState->PrevLightScatteringConservativeDepthTexture);
FIntVector TextureSize = View.ViewState->PrevLightScatteringConservativeDepthTexture->GetDesc().GetSize();
PassParameters->PrevConservativeDepthTextureSize = FVector2f(TextureSize.X, TextureSize.Y);
}
else
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:1753
Scope (from outer to inner):
file
function void FSceneRenderer::ComputeVolumetricFog
Source code excerpt:
}
if (bUseTemporalReprojection && GVolumetricFogConservativeDepth > 0)
{
GraphBuilder.QueueTextureExtraction(ConservativeDepthTexture, &View.ViewState->PrevLightScatteringConservativeDepthTexture);
}
else if (View.ViewState)
{
View.ViewState->PrevLightScatteringConservativeDepthTexture = NULL;