r.VertexFoggingForOpaque
r.VertexFoggingForOpaque
#Overview
name: r.VertexFoggingForOpaque
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Causes opaque materials to use per-vertex fogging, which costs less and integrates properly with MSAA. Only supported with forward shading.
It is referenced in 12
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VertexFoggingForOpaque is to control whether opaque materials use per-vertex fogging in forward shading. This setting is part of the rendering system, specifically for fog effects.
This setting is primarily used by the Unreal Engine’s forward rendering path. It’s referenced in various parts of the rendering pipeline, including shader compilation and base pass rendering.
The value of this variable is set through the console variable system. It’s defined as a TAutoConsoleVariable with a default value of 1 (enabled).
This variable interacts closely with bVertexFoggingForOpaque, which appears to be a bool that directly reflects the state of r.VertexFoggingForOpaque in various parts of the code.
Developers should be aware that:
- This setting only applies when using forward shading.
- Changing this value causes a full shader recompile, which can be time-consuming.
- It affects performance and visual quality - per-vertex fogging is less expensive but may be less accurate than per-pixel fogging.
- The actual behavior can be overridden by platform-specific settings (see TargetPlatform->GetHeightFogModeForOpaque()).
Best practices when using this variable:
- Only modify it if you’re specifically optimizing for performance in forward shading scenarios.
- Be prepared for a shader recompile when changing this value.
- Test the visual impact thoroughly, as it can affect the appearance of fog in your game.
- Consider platform-specific implications, as some platforms may override this setting.
Regarding the associated variable bVertexFoggingForOpaque: This is a boolean variable that directly reflects the state of r.VertexFoggingForOpaque in various parts of the code. It’s used to actually implement the behavior controlled by r.VertexFoggingForOpaque.
The bVertexFoggingForOpaque variable is typically set based on the value of r.VertexFoggingForOpaque, but it can also be influenced by platform-specific settings. It’s used in shader compilation to determine whether to enable vertex fogging for opaque materials.
Developers should be aware that while r.VertexFoggingForOpaque controls the overall setting, bVertexFoggingForOpaque is what’s actually used in the implementation. Changes to r.VertexFoggingForOpaque will typically be reflected in bVertexFoggingForOpaque, but platform-specific overrides can cause them to differ.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/RendererSettings.h:598
Scope (from outer to inner):
file
class class URendererSettings : public UDeveloperSettings
Source code excerpt:
UPROPERTY(config, EditAnywhere, Category=ForwardRenderer, meta=(
ConsoleVariable="r.VertexFoggingForOpaque",
ToolTip="Causes opaque materials to use per-vertex fogging, which costs slightly less. Only supported with forward shading. Changing this setting requires restarting the editor.",
ConfigRestartRequired=true))
uint32 bVertexFoggingForOpaque:1;
UPROPERTY(config, EditAnywhere, Category=Translucency, meta=(
ConsoleVariable="r.SeparateTranslucency",
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:54
Scope: file
Source code excerpt:
// Changing this causes a full shader recompile
static TAutoConsoleVariable<int32> CVarVertexFoggingForOpaque(
TEXT("r.VertexFoggingForOpaque"),
1,
TEXT("Causes opaque materials to use per-vertex fogging, which costs less and integrates properly with MSAA. Only supported with forward shading."),
ECVF_ReadOnly | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasksBasePass(
TEXT("r.RHICmdFlushRenderThreadTasksBasePass"),
#Loc: <Workspace>/Engine/Source/Developer/TargetPlatform/Public/Interfaces/ITargetPlatformSettings.h:200
Scope (from outer to inner):
file
class class ITargetPlatformSettings
Source code excerpt:
/**
* Gets an integer representing the height fog mode for opaque materials on a platform.
* @return 0 if no override (i.e. use r.VertexFoggingForOpaque from project settings); 1 if pixel fog; 2 if vertex fog.
*/
virtual int32 GetHeightFogModeForOpaque() const = 0;
/**
* Gets whether the platform uses Mobile AO
*/
virtual bool UsesMobileAmbientOcclusion() const = 0;
/**
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:8415
Scope (from outer to inner):
file
function void GlobalBeginCompileShader
Source code excerpt:
{
static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.VertexFoggingForOpaque"));
bool bVertexFoggingForOpaque = false;
if (bForwardShading)
{
bVertexFoggingForOpaque = CVar ? (CVar->GetInt() != 0) : 0;
if (TargetPlatform)
{
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderGenerationUtil.cpp:369
Scope (from outer to inner):
file
function static FShaderGlobalDefines FetchShaderGlobalDefines
Source code excerpt:
{
static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.VertexFoggingForOpaque"));
Ret.PROJECT_VERTEX_FOGGING_FOR_OPAQUE = Ret.FORWARD_SHADING && (CVar ? (CVar->GetInt() != 0) : 0);
}
{
static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DisableVertexFog"));
Ret.PROJECT_MOBILE_DISABLE_VERTEX_FOG = CVar ? (CVar->GetInt() != 0) : 0;
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ReadOnlyCVARCache.cpp:66
Scope (from outer to inner):
file
function void FReadOnlyCVARCache::Initialize
Source code excerpt:
const auto CVarSupportPointLightWholeSceneShadows = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportPointLightWholeSceneShadows"));
const auto CVarSupportAllShaderPermutations = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));
const auto CVarVertexFoggingForOpaque = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VertexFoggingForOpaque"));
const auto CVarAllowStaticLighting = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.AllowStaticLighting"));
const auto CVarSupportSkyAtmosphere = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportSkyAtmosphere"));
const auto CVarMobileHDR = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MobileHDR"));
const auto CVarMobileAllowMovableDirectionalLights = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.AllowMovableDirectionalLights"));
const auto CVarMobileEnableStaticAndCSMShadowReceivers = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.EnableStaticAndCSMShadowReceivers"));
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/Shader.cpp:1937
Scope (from outer to inner):
file
function void ShaderMapAppendKeyString
Source code excerpt:
{
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VertexFoggingForOpaque"));
bool bVertexFoggingForOpaque = CVar && CVar->GetValueOnAnyThread() > 0;
if (TargetPlatform)
{
const int32 PlatformHeightFogMode = TargetPlatform->GetHeightFogModeForOpaque();
if (PlatformHeightFogMode == 1)
{
#Associated Variable and Callsites
This variable is associated with another variable named bVertexFoggingForOpaque
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/RendererSettings.h:601
Scope (from outer to inner):
file
class class URendererSettings : public UDeveloperSettings
Source code excerpt:
ToolTip="Causes opaque materials to use per-vertex fogging, which costs slightly less. Only supported with forward shading. Changing this setting requires restarting the editor.",
ConfigRestartRequired=true))
uint32 bVertexFoggingForOpaque:1;
UPROPERTY(config, EditAnywhere, Category=Translucency, meta=(
ConsoleVariable="r.SeparateTranslucency",
ToolTip="Allow translucency to be rendered to a separate render targeted and composited after depth of field. Prevents translucency from appearing out of focus."))
uint32 bSeparateTranslucency:1;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:8416
Scope (from outer to inner):
file
function void GlobalBeginCompileShader
Source code excerpt:
{
static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.VertexFoggingForOpaque"));
bool bVertexFoggingForOpaque = false;
if (bForwardShading)
{
bVertexFoggingForOpaque = CVar ? (CVar->GetInt() != 0) : 0;
if (TargetPlatform)
{
const int32 PlatformHeightFogMode = TargetPlatform->GetHeightFogModeForOpaque();
if (PlatformHeightFogMode == 1)
{
bVertexFoggingForOpaque = false;
}
else if (PlatformHeightFogMode == 2)
{
bVertexFoggingForOpaque = true;
}
}
}
SET_SHADER_DEFINE(Input.Environment, PROJECT_VERTEX_FOGGING_FOR_OPAQUE, bVertexFoggingForOpaque);
}
{
static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DisableVertexFog"));
SET_SHADER_DEFINE(Input.Environment, PROJECT_MOBILE_DISABLE_VERTEX_FOG, CVar ? (CVar->GetInt() != 0) : 0);
}
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/Shader.cpp:1938
Scope (from outer to inner):
file
function void ShaderMapAppendKeyString
Source code excerpt:
{
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VertexFoggingForOpaque"));
bool bVertexFoggingForOpaque = CVar && CVar->GetValueOnAnyThread() > 0;
if (TargetPlatform)
{
const int32 PlatformHeightFogMode = TargetPlatform->GetHeightFogModeForOpaque();
if (PlatformHeightFogMode == 1)
{
bVertexFoggingForOpaque = false;
}
else if (PlatformHeightFogMode == 2)
{
bVertexFoggingForOpaque = true;
}
}
if (bVertexFoggingForOpaque)
{
KeyString += TEXT("_VFO");
}
}
bool bSupportLocalFogVolumes = false;
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ReadOnlyCVARCache.cpp:66
Scope (from outer to inner):
file
function void FReadOnlyCVARCache::Initialize
Source code excerpt:
const auto CVarSupportPointLightWholeSceneShadows = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportPointLightWholeSceneShadows"));
const auto CVarSupportAllShaderPermutations = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));
const auto CVarVertexFoggingForOpaque = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VertexFoggingForOpaque"));
const auto CVarAllowStaticLighting = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.AllowStaticLighting"));
const auto CVarSupportSkyAtmosphere = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportSkyAtmosphere"));
const auto CVarMobileHDR = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MobileHDR"));
const auto CVarMobileAllowMovableDirectionalLights = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.AllowMovableDirectionalLights"));
const auto CVarMobileEnableStaticAndCSMShadowReceivers = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.EnableStaticAndCSMShadowReceivers"));
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:53
Scope: file
Source code excerpt:
// Changing this causes a full shader recompile
static TAutoConsoleVariable<int32> CVarVertexFoggingForOpaque(
TEXT("r.VertexFoggingForOpaque"),
1,
TEXT("Causes opaque materials to use per-vertex fogging, which costs less and integrates properly with MSAA. Only supported with forward shading."),
ECVF_ReadOnly | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasksBasePass(