r.LocalFogVolume.UseHZB
r.LocalFogVolume.UseHZB
#Overview
name: r.LocalFogVolume.UseHZB
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Use the HZB to cull loca lfog volume away.\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.LocalFogVolume.UseHZB is to control the use of Hierarchical Z-Buffer (HZB) for culling local fog volumes in the rendering process. This setting is part of the rendering system in Unreal Engine 5, specifically related to the local fog volume rendering optimization.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, as evident from its location in the “LocalFogVolumeRendering.cpp” file within the Runtime/Renderer/Private directory.
The value of this variable is set through a console variable (CVarLocalFogVolumeUseHZB) with a default value of 1 (enabled). It can be changed at runtime using console commands or through configuration files.
This variable interacts with the View.HZB property. The combination of r.LocalFogVolume.UseHZB being enabled and View.HZB being available determines whether HZB-based culling is used for local fog volumes.
Developers should be aware that this variable affects rendering performance and visual quality. Enabling HZB culling can improve performance by reducing the number of fog volumes that need to be processed, but it may also introduce subtle visual artifacts in some cases.
Best practices when using this variable include:
- Keeping it enabled (default value of 1) for better performance in most scenarios.
- Testing the visual impact in different scenes and lighting conditions when enabled vs. disabled.
- Considering disabling it if any visual artifacts are observed and the performance impact is acceptable.
Regarding the associated variable CVarLocalFogVolumeUseHZB:
This is the actual console variable that controls the r.LocalFogVolume.UseHZB setting. It is defined as a TAutoConsoleVariable
The purpose of CVarLocalFogVolumeUseHZB is to provide a runtime-configurable way to enable or disable the use of HZB for local fog volume culling. It is used in the rendering code to determine whether to apply HZB-based culling when processing local fog volumes.
This variable is set in the same file (LocalFogVolumeRendering.cpp) and is used in the FLocalFogVolumeTiledCullingCS::FPermutationDomain to determine shader permutations.
Developers should be aware that changes to this console variable will take effect on the render thread, as indicated by the ECVF_RenderThreadSafe flag.
Best practices for using CVarLocalFogVolumeUseHZB include:
- Using it for debugging or performance testing purposes.
- Avoiding frequent changes during gameplay, as it may impact performance or visual consistency.
- Considering exposing it as a user-configurable option in graphics settings if fine-tuning is necessary for different hardware configurations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:68
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarLocalFogVolumeUseHZB(
TEXT("r.LocalFogVolume.UseHZB"), 1,
TEXT("Use the HZB to cull loca lfog volume away.\n"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarLocalFogVolumeHalfResolution(
TEXT("r.LocalFogVolume.HalfResolution"), 0,
TEXT("Set to one to render local fog volumes at half resoltuion with an upsampling to full resolution later. Only work for the mobile path for now.\n"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarLocalFogVolumeUseHZB
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:67
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarLocalFogVolumeUseHZB(
TEXT("r.LocalFogVolume.UseHZB"), 1,
TEXT("Use the HZB to cull loca lfog volume away.\n"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarLocalFogVolumeHalfResolution(
TEXT("r.LocalFogVolume.HalfResolution"), 0,
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:352
Scope: file
Source code excerpt:
FLocalFogVolumeTiledCullingCS::FPermutationDomain PermutationVector;
PermutationVector.Set<FLocalFogVolumeTiledCullingCS::FUseHZB>(View.HZB != nullptr && CVarLocalFogVolumeUseHZB.GetValueOnRenderThread());
TShaderMapRef<FLocalFogVolumeTiledCullingCS> ComputeShader(View.ShaderMap, PermutationVector);
FComputeShaderUtils::AddPass(GraphBuilder, RDG_EVENT_NAME("LocalFogVolume.TiledCulling"), PassFlag, ComputeShader, PassParameters, NumGroups);
}
/*=============================================================================