r.SupportLocalFogVolumes
r.SupportLocalFogVolumes
#Overview
name: r.SupportLocalFogVolumes
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables local fog volume rendering and shader code.
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.SupportLocalFogVolumes is to enable or disable local fog volume rendering and shader code in Unreal Engine’s rendering system. This setting variable is part of the project’s fog and atmospheric effects subsystem.
The Unreal Engine subsystems that rely on this setting variable are:
- Renderer module
- RenderCore module
- Engine module (specifically the RendererSettings)
The value of this variable is set through a console variable (CVar) named CVarSupportLocalFogVolumes. It is initialized with a default value of 1, meaning local fog volumes are enabled by default.
This variable interacts with other variables and systems:
- It affects shader compilation and defines (PROJECT_SUPPORTS_LOCALFOGVOLUME)
- It influences the shader map key string generation
- It’s used in conjunction with r.LocalFogVolume.ApplyOnTranslucent for additional control over translucent surfaces
Developers must be aware of the following when using this variable:
- Changing this setting requires a project restart, as it affects shader compilation
- It’s a read-only and render thread safe variable, meaning it shouldn’t be changed during runtime
- Disabling this feature when local fog volumes are present in the scene will result in a warning message
Best practices when using this variable include:
- Set it in the project settings rather than changing it at runtime
- Consider performance implications when enabling local fog volumes, especially on lower-end hardware
- Use in conjunction with other fog-related settings for fine-tuned control over atmospheric effects
Regarding the associated variable CVarSupportLocalFogVolumes:
This is the actual console variable that controls the r.SupportLocalFogVolumes setting. It’s defined as a TAutoConsoleVariable
Developers should use the ProjectSupportsLocalFogVolumes() function to check if local fog volumes are supported in the current project configuration, rather than directly accessing the CVarSupportLocalFogVolumes variable. This function returns true if the value of CVarSupportLocalFogVolumes is greater than 0.
When working with CVarSupportLocalFogVolumes, keep in mind that it’s marked as ECVF_ReadOnly and ECVF_RenderThreadSafe, meaning it should not be modified during runtime and is safe to access from the render thread.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:17
Scope: file
Source code excerpt:
// The project setting (disable runtime and shader code)
static TAutoConsoleVariable<int32> CVarSupportLocalFogVolumes(
TEXT("r.SupportLocalFogVolumes"),
1,
TEXT("Enables local fog volume rendering and shader code."),
ECVF_ReadOnly | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarLocalFogVolumeRenderDuringHeightFogPass(
TEXT("r.LocalFogVolume.RenderDuringHeightFogPass"), 0,
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/RendererSettings.h:877
Scope: file
Source code excerpt:
/**
"Local fog volume components can will need to be applied on translucent, and opaque in forward, so resources will need to be bound to apply aerial perspective on transparent surfaces (and all surfaces on mobile via per vertex evaluation)."
"It requires r.SupportLocalFogVolumes to be true."
*/
UPROPERTY(config, EditAnywhere, Category = Optimizations, meta = (
ConsoleVariable = "r.SupportLocalFogVolumes", DisplayName = "Support Local Fog Volumes",
ToolTip = "Local fog volume components can will need to be applied on translucent, and opaque in forward, so resources will need to be bound to apply aerial perspective on transparent surfaces (and all surfaces on mobile via per vertex evaluation). It requires r.SupportLocalFogVolumes to be true.",
ConfigRestartRequired = true))
uint32 bSupportLocalFogVolumes : 1;
/**
"Enable cloud shadow on translucent surface. This is evaluated per vertex to reduce GPU cost. The cloud system requires extra samplers/textures to be bound to vertex shaders."
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:8443
Scope (from outer to inner):
file
function void GlobalBeginCompileShader
Source code excerpt:
bool bSupportLocalFogVolumes = false;
{
static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SupportLocalFogVolumes"));
bSupportLocalFogVolumes = CVar && CVar->GetInt() > 0;
SET_SHADER_DEFINE(Input.Environment, PROJECT_SUPPORTS_LOCALFOGVOLUME, (bSupportLocalFogVolumes ? 1 : 0));
}
{
static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.LocalFogVolume.ApplyOnTranslucent"));
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/Shader.cpp:1959
Scope (from outer to inner):
file
function void ShaderMapAppendKeyString
Source code excerpt:
bool bSupportLocalFogVolumes = false;
{
static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SupportLocalFogVolumes"));
bSupportLocalFogVolumes = CVar && CVar->GetInt() > 0;
if (bSupportLocalFogVolumes)
{
KeyString += TEXT("_LFV");
}
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:4017
Scope (from outer to inner):
file
lambda-function
Source code excerpt:
if (bLocalFogVolumeInSceneButProjectDisabled)
{
static const FText Message = NSLOCTEXT("Renderer", "LocalFogVolumeDisabled", "There are Local Fog Volumes in the scene, but your project does not support rendering them. This can be enabled from the project settings panel (r.SupportLocalFogVolumes).");
Writer.DrawLine(Message);
}
#if !UE_BUILD_SHIPPING
if (bStereoView)
{
#Associated Variable and Callsites
This variable is associated with another variable named CVarSupportLocalFogVolumes
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:16
Scope: file
Source code excerpt:
// The project setting (disable runtime and shader code)
static TAutoConsoleVariable<int32> CVarSupportLocalFogVolumes(
TEXT("r.SupportLocalFogVolumes"),
1,
TEXT("Enables local fog volume rendering and shader code."),
ECVF_ReadOnly | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarLocalFogVolumeRenderDuringHeightFogPass(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:104
Scope (from outer to inner):
file
function bool ProjectSupportsLocalFogVolumes
Source code excerpt:
bool ProjectSupportsLocalFogVolumes()
{
return CVarSupportLocalFogVolumes.GetValueOnRenderThread() > 0;
}
bool ShouldRenderLocalFogVolume(const FScene* Scene, const FSceneViewFamily& SceneViewFamily)
{
const FEngineShowFlags EngineShowFlags = SceneViewFamily.EngineShowFlags;
if (Scene && Scene->HasAnyLocalFogVolume() && EngineShowFlags.Fog && !SceneViewFamily.UseDebugViewPS())