r.SupportLocalFogVolumes

r.SupportLocalFogVolumes

#Overview

name: r.SupportLocalFogVolumes

This variable is created as a Console Variable (cvar).

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:

  1. Renderer module
  2. RenderCore module
  3. 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:

  1. It affects shader compilation and defines (PROJECT_SUPPORTS_LOCALFOGVOLUME)
  2. It influences the shader map key string generation
  3. 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:

  1. Changing this setting requires a project restart, as it affects shader compilation
  2. It’s a read-only and render thread safe variable, meaning it shouldn’t be changed during runtime
  3. 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:

  1. Set it in the project settings rather than changing it at runtime
  2. Consider performance implications when enabling local fog volumes, especially on lower-end hardware
  3. 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 with the same name as the setting. The purpose of this variable is to provide a runtime-accessible way to query the current state of local fog volume support.

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())