r.LocalFogVolume
r.LocalFogVolume
#Overview
name: r.LocalFogVolume
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
LocalFogVolume components are rendered when this is not 0, otherwise ignored.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.LocalFogVolume is to control the rendering of LocalFogVolume components in Unreal Engine 5. It acts as a runtime ON/OFF toggle for local fog volume rendering.
This setting variable is primarily used by the rendering system, specifically for fog volume rendering. Based on the callsites, it’s part of the Renderer module in Unreal Engine 5.
The value of this variable is set as a console variable (CVar) with a default value of 1, meaning local fog volumes are rendered by default. It can be changed at runtime through the console or programmatically.
The r.LocalFogVolume variable interacts closely with another variable named CVarSupportLocalFogVolumes. While r.LocalFogVolume is a runtime toggle, CVarSupportLocalFogVolumes appears to be a project-level setting that determines whether local fog volumes are supported at all.
Developers should be aware that this variable is render thread safe (ECVF_RenderThreadSafe), meaning it can be safely accessed from the render thread. They should also note that setting this to 0 will cause LocalFogVolume components to be ignored during rendering.
Best practices for using this variable include:
- Use it for debugging or performance testing, toggling local fog volumes on and off as needed.
- Be cautious about disabling it in production builds unless you’re certain you don’t need local fog volumes.
- Consider the interaction with the project-level setting (CVarSupportLocalFogVolumes) when making changes.
Regarding the associated variable CVarLocalFogVolume:
The purpose of CVarLocalFogVolume is essentially the same as r.LocalFogVolume. It’s the actual TAutoConsoleVariable object that represents the r.LocalFogVolume setting in the code.
This variable is used directly in the rendering code to determine whether local fog volumes should be rendered. It’s accessed in the ShouldRenderLocalFogVolume function, which checks if the value is greater than 0.
The value of CVarLocalFogVolume is set when the r.LocalFogVolume console command is used.
CVarLocalFogVolume interacts with the Scene object, EngineShowFlags, and the ProjectSupportsLocalFogVolumes() function to determine if local fog volumes should be rendered.
Developers should be aware that this variable is accessed on the render thread (GetValueOnRenderThread()), which is consistent with its thread-safe nature.
Best practices for using CVarLocalFogVolume include:
- Access it using GetValueOnRenderThread() when in render thread code.
- Remember that it’s a boolean-like integer (0 for off, >0 for on) when interpreting its value.
- Consider caching its value if you need to check it frequently, to avoid repeated calls to GetValueOnRenderThread().
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:11
Scope: file
Source code excerpt:
// The runtime ON/OFF toggle
static TAutoConsoleVariable<int32> CVarLocalFogVolume(
TEXT("r.LocalFogVolume"), 1,
TEXT("LocalFogVolume components are rendered when this is not 0, otherwise ignored."),
ECVF_RenderThreadSafe);
// The project setting (disable runtime and shader code)
static TAutoConsoleVariable<int32> CVarSupportLocalFogVolumes(
TEXT("r.SupportLocalFogVolumes"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarLocalFogVolume
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:10
Scope: file
Source code excerpt:
// The runtime ON/OFF toggle
static TAutoConsoleVariable<int32> CVarLocalFogVolume(
TEXT("r.LocalFogVolume"), 1,
TEXT("LocalFogVolume components are rendered when this is not 0, otherwise ignored."),
ECVF_RenderThreadSafe);
// The project setting (disable runtime and shader code)
static TAutoConsoleVariable<int32> CVarSupportLocalFogVolumes(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:112
Scope (from outer to inner):
file
function bool ShouldRenderLocalFogVolume
Source code excerpt:
if (Scene && Scene->HasAnyLocalFogVolume() && EngineShowFlags.Fog && !SceneViewFamily.UseDebugViewPS())
{
return ProjectSupportsLocalFogVolumes() && (CVarLocalFogVolume.GetValueOnRenderThread() > 0);
}
return false;
}
bool ShouldRenderLocalFogVolumeDuringHeightFogPass(const FScene* Scene, const FSceneViewFamily& SceneViewFamily)
{