ShowFlag.Fog
ShowFlag.Fog
#Overview
name: ShowFlag.Fog
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allows to override a specific showflag (works in editor and game, \
It is referenced in 25
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ShowFlag.Fog is to control the visibility of fog effects in the rendering system of Unreal Engine 5. It is a boolean flag that determines whether fog should be rendered in the scene or not.
This setting variable is primarily used by the rendering subsystem of Unreal Engine 5. Specifically, it is utilized in various modules and plugins, including:
- The main Engine module
- The Renderer module
- The Composure plugin
- The Water plugin
- The Niagara plugin
- The LevelEditor module
The value of this variable is typically set through the engine’s show flags system, which allows developers and users to toggle various rendering features on and off. It can be modified programmatically or through the engine’s user interface.
Several other variables interact with ShowFlag.Fog:
- EngineShowFlags.VolumetricFog
- EngineShowFlags.Atmosphere
- FFogUniformParameters structure
Developers should be aware of the following when using this variable:
- It affects both the editor and game viewports.
- It interacts with other rendering features like volumetric fog and atmosphere.
- It can be disabled in certain rendering scenarios, such as post-processing or specialized rendering passes.
Best practices when using this variable include:
- Consider performance implications when enabling fog, especially on lower-end hardware.
- Ensure consistency between fog settings and other atmospheric effects for visual coherence.
- Be mindful of how fog interacts with different lighting conditions and materials in your scene.
Regarding the associated variable “Fog”:
The purpose of the Fog variable is to store fog-related data and parameters used in various rendering calculations. It is closely related to ShowFlag.Fog but contains actual fog property values rather than just a visibility flag.
This variable is used in similar subsystems and modules as ShowFlag.Fog, primarily within the rendering pipeline. It is typically set and modified through the engine’s fog system and can be adjusted via Blueprint or C++ code.
Developers should be aware that the Fog variable often contains multiple properties (e.g., density, color, start distance) that collectively define the fog effect. When working with this variable, ensure all relevant properties are set correctly for the desired visual outcome.
Best practices include:
- Balancing fog density with scene visibility and performance considerations.
- Coordinating fog settings with overall lighting and atmosphere design.
- Using the appropriate fog type (e.g., exponential height fog) for your specific scene requirements.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:277
Scope: file
Source code excerpt:
SHOWFLAG_FIXED_IN_SHIPPING(0, LightRadius, SFG_Advanced, NSLOCTEXT("UnrealEd", "LightRadiusSF", "Light Radius"))
/** Draws fog, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(Fog, SFG_Normal, NSLOCTEXT("UnrealEd", "FogSF", "Fog"))
/** Draws Volumes */
SHOWFLAG_FIXED_IN_SHIPPING(0, Volumes, SFG_Advanced, NSLOCTEXT("UnrealEd", "VolumesSF", "Volumes"))
/** if this is a game viewport, needed? */
SHOWFLAG_ALWAYS_ACCESSIBLE(Game, SFG_Hidden, NSLOCTEXT("UnrealEd", "GameSF", "Game"))
/** Render objects with colors based on what the actors coloring handlers provides */
SHOWFLAG_FIXED_IN_SHIPPING(0, ActorColoration, SFG_Transient, NSLOCTEXT("UnrealEd", "ActorColorationSF", "Actor Coloration"))
#Associated Variable and Callsites
This variable is associated with another variable named Fog
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Compositing/Composure/Source/Composure/Private/ComposureUtils.cpp:23
Scope (from outer to inner):
file
function void FComposureUtils::SetEngineShowFlagsForPostprocessingOnly
Source code excerpt:
EngineShowFlags.VolumetricFog = false;
EngineShowFlags.Atmosphere = false;
EngineShowFlags.Fog = false;
#if !UE_BUILD_OPTIMIZED_SHOWFLAGS
// Development-only flags
EngineShowFlags.ReflectionOverride = false;
EngineShowFlags.DepthOfField = false;
#endif
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterInfoRendering.cpp:650
Scope (from outer to inner):
file
namespace UE::WaterInfo
function static FSceneRenderer* CreateWaterInfoSceneRenderer
Source code excerpt:
ShowFlags.SeparateTranslucency = 0;
ShowFlags.AntiAliasing = 0;
ShowFlags.Fog = 0;
ShowFlags.VolumetricFog = 0;
ShowFlags.DynamicShadows = 0;
ShowFlags.SetDisableOcclusionQueries(true);
ShowFlags.SetVirtualShadowMapPersistentData(false);
#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/NiagaraEditor/Private/Widgets/SNiagaraSystemViewport.cpp:707
Scope (from outer to inner):
file
function void FNiagaraSystemViewportClient::LoadSharedSettingsFromConfig
Source code excerpt:
{
EditorShowFlags.MotionBlur = 0;
EditorShowFlags.Fog = 0;
EditorShowFlags.SetDepthOfField(false);
GameShowFlags.MotionBlur = 0;
GameShowFlags.Fog = 0;
GameShowFlags.SetDepthOfField(false);
}
ViewportType = ViewportSharedSettings.ViewportType;
EngineShowFlags = EditorShowFlags;
LastEngineShowFlags = GameShowFlags;
#Loc: <Workspace>/Engine/Source/Editor/LevelEditor/Private/SLevelViewport.cpp:559
Scope (from outer to inner):
file
function void SLevelViewport::ConstructLevelEditorViewportClient
Source code excerpt:
{
EditorShowFlags.MotionBlur = 0;
EditorShowFlags.Fog = 0;
EditorShowFlags.SetDepthOfField(false);
GameShowFlags.MotionBlur = 0;
GameShowFlags.Fog = 0;
GameShowFlags.SetDepthOfField(false);
}
EditorShowFlags.SetSnap(1);
GameShowFlags.SetSnap(1);
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Factories/FbxSceneImportFactory.h:217
Scope (from outer to inner):
file
class class FFbxLightInfo : public TSharedFromThis<FFbxLightInfo>
Source code excerpt:
float InnerAngle;
float OuterAngle;
float Fog;
float DecayStart;
bool EnableNearAttenuation;
float NearAttenuationStart;
float NearAttenuationEnd;
bool EnableFarAttenuation;
float FarAttenuationStart;
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Factories/FbxSceneImportFactory.h:241
Scope (from outer to inner):
file
class class FFbxLightInfo : public TSharedFromThis<FFbxLightInfo>
function FFbxLightInfo
Source code excerpt:
, InnerAngle(0.0f)
, OuterAngle(0.0f)
, Fog(0.0f)
, DecayStart(0.0f)
, EnableNearAttenuation(false)
, NearAttenuationStart(0.0f)
, NearAttenuationEnd(0.0f)
, EnableFarAttenuation(false)
, FarAttenuationStart(0.0f)
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Fbx/FbxSceneImportFactory.cpp:490
Scope (from outer to inner):
file
function void FetchFbxLightInScene
Source code excerpt:
LightInfo->InnerAngle = (float)(LightAttribute->InnerAngle.Get());
LightInfo->OuterAngle = (float)(LightAttribute->OuterAngle.Get());
LightInfo->Fog = (float)(LightAttribute->Fog.Get());
LightInfo->DecayStart = (float)(LightAttribute->DecayStart.Get());
LightInfo->EnableNearAttenuation = LightAttribute->EnableNearAttenuation.Get();
LightInfo->NearAttenuationStart = (float)(LightAttribute->NearAttenuationStart.Get());
LightInfo->NearAttenuationEnd = (float)(LightAttribute->NearAttenuationEnd.Get());
LightInfo->EnableFarAttenuation = LightAttribute->EnableFarAttenuation.Get();
LightInfo->FarAttenuationStart = (float)(LightAttribute->FarAttenuationStart.Get());
#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithMaxExporter/Private/MaxMaterialsToUEPbr/DatasmithMaxVrayMaterialsToUEPbr.cpp:869
Scope (from outer to inner):
file
function void FDatasmithMaxVRayMaterialsToUEPbr::Convert
Source code excerpt:
if ( FogExpression )
{
FogExpression->SetName( TEXT("Fog") );
IDatasmithMaterialExpressionScalar* FogMultiplier = PbrMaterialElement->AddMaterialExpression< IDatasmithMaterialExpressionScalar >();
FogMultiplier->SetName( TEXT("Fog Multiplier") );
FogMultiplier->GetScalar() = VRayMaterialProperties.FogMultiplier;
IDatasmithMaterialExpressionGeneric* MultiplyFog = PbrMaterialElement->AddMaterialExpression< IDatasmithMaterialExpressionGeneric >();
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:277
Scope: file
Source code excerpt:
SHOWFLAG_FIXED_IN_SHIPPING(0, LightRadius, SFG_Advanced, NSLOCTEXT("UnrealEd", "LightRadiusSF", "Light Radius"))
/** Draws fog, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(Fog, SFG_Normal, NSLOCTEXT("UnrealEd", "FogSF", "Fog"))
/** Draws Volumes */
SHOWFLAG_FIXED_IN_SHIPPING(0, Volumes, SFG_Advanced, NSLOCTEXT("UnrealEd", "VolumesSF", "Volumes"))
/** if this is a game viewport, needed? */
SHOWFLAG_ALWAYS_ACCESSIBLE(Game, SFG_Hidden, NSLOCTEXT("UnrealEd", "GameSF", "Game"))
/** Render objects with colors based on what the actors coloring handlers provides */
SHOWFLAG_FIXED_IN_SHIPPING(0, ActorColoration, SFG_Transient, NSLOCTEXT("UnrealEd", "ActorColorationSF", "Actor Coloration"))
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:721
Scope (from outer to inner):
file
function void SetupSharedBasePassParameters
Source code excerpt:
}
SetupFogUniformParameters(GraphBuilder, View, SharedParameters.Fog);
if (View.IsInstancedStereoPass())
{
const FViewInfo& InstancedView = *View.GetInstancedView();
SharedParameters.ForwardISR = *InstancedView.ForwardLightingResources.ForwardLightData;
SetupFogUniformParameters(GraphBuilder, (FViewInfo&)InstancedView, SharedParameters.FogISR);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:739
Scope (from outer to inner):
file
function void SetupSharedBasePassParameters
Source code excerpt:
SharedParameters.ForwardISR = SharedParameters.Forward;
}
SharedParameters.FogISR = SharedParameters.Fog;
}
SharedParameters.LFV = View.LocalFogVolumeViewData.UniformParametersStruct;
SharedParameters.LightFunctionAtlas = *LightFunctionAtlas::GetGlobalParametersStruct(GraphBuilder, View);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.h:80
Scope: file
Source code excerpt:
SHADER_PARAMETER_STRUCT(FReflectionUniformParameters, Reflection)
SHADER_PARAMETER_STRUCT(FPlanarReflectionUniformParameters, PlanarReflection) // Single global planar reflection for the forward pass.
SHADER_PARAMETER_STRUCT(FFogUniformParameters, Fog)
SHADER_PARAMETER_STRUCT(FFogUniformParameters, FogISR)
SHADER_PARAMETER_STRUCT(FLocalFogVolumeUniformParameters, LFV)
SHADER_PARAMETER_STRUCT(LightFunctionAtlas::FLightFunctionAtlasGlobalParameters, LightFunctionAtlas)
SHADER_PARAMETER(uint32, UseBasePassSkylight)
END_GLOBAL_SHADER_PARAMETER_STRUCT()
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/FogRendering.cpp:415
Scope (from outer to inner):
file
function void RenderFogOnClouds
Source code excerpt:
{
RDG_EVENT_SCOPE(GraphBuilder, "ExponentialHeightFog on Clouds");
RDG_GPU_STAT_SCOPE(GraphBuilder, Fog);
if (View.IsPerspectiveProjection())
{
RDG_GPU_MASK_SCOPE(GraphBuilder, View.GPUMask);
TRDGUniformBufferRef<FFogUniformParameters> FogUniformBuffer = CreateFogUniformBuffer(GraphBuilder, View);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/FogRendering.cpp:469
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderFog
Source code excerpt:
{
RDG_EVENT_SCOPE(GraphBuilder, "ExponentialHeightFog");
RDG_GPU_STAT_SCOPE(GraphBuilder, Fog);
const bool bShouldRenderVolumetricFog = ShouldRenderVolumetricFog();
for(int32 ViewIndex = 0;ViewIndex < Views.Num();ViewIndex++)
{
const FViewInfo& View = Views[ViewIndex];
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/FogRendering.cpp:511
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderUnderWaterFog
Source code excerpt:
{
RDG_EVENT_SCOPE(GraphBuilder, "SLW::ExponentialHeightFog");
RDG_GPU_STAT_SCOPE(GraphBuilder, Fog);
FRDGTextureRef WaterDepthTexture = SceneWithoutWaterTextures.DepthTexture;
check(WaterDepthTexture);
const bool bShouldRenderVolumetricFog = ShouldRenderVolumetricFog();
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/FogRendering.cpp:555
Scope (from outer to inner):
file
function bool ShouldRenderFog
Source code excerpt:
const FEngineShowFlags EngineShowFlags = Family.EngineShowFlags;
return EngineShowFlags.Fog
&& EngineShowFlags.Materials
&& !Family.UseDebugViewPS()
&& CVarFog.GetValueOnRenderThread() == 1
&& !EngineShowFlags.StationaryLightOverlap
&& !EngineShowFlags.LightMapDensity;
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LocalFogVolumeRendering.cpp:110
Scope (from outer to inner):
file
function bool ShouldRenderLocalFogVolume
Source code excerpt:
{
const FEngineShowFlags EngineShowFlags = SceneViewFamily.EngineShowFlags;
if (Scene && Scene->HasAnyLocalFogVolume() && EngineShowFlags.Fog && !SceneViewFamily.UseDebugViewPS())
{
return ProjectSupportsLocalFogVolumes() && (CVarLocalFogVolume.GetValueOnRenderThread() > 0);
}
return false;
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileBasePassRendering.cpp:253
Scope (from outer to inner):
file
function void SetupMobileBasePassUniformParameters
Source code excerpt:
FMobileBasePassUniformParameters& BasePassParameters)
{
SetupFogUniformParameters(GraphBuilder, View, BasePassParameters.Fog);
if (View.ForwardLightingResources.ForwardLightData)
{
BasePassParameters.Forward = *View.ForwardLightingResources.ForwardLightData;
}
else
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileBasePassRendering.h:41
Scope: file
Source code excerpt:
BEGIN_GLOBAL_SHADER_PARAMETER_STRUCT(FMobileBasePassUniformParameters, )
SHADER_PARAMETER(float, AmbientOcclusionStaticFraction)
SHADER_PARAMETER_STRUCT(FFogUniformParameters, Fog)
SHADER_PARAMETER_STRUCT(FLocalFogVolumeUniformParameters, LFV)
SHADER_PARAMETER_STRUCT(FForwardLightData, Forward)
SHADER_PARAMETER_STRUCT(FForwardLightData, ForwardMMV)
SHADER_PARAMETER_STRUCT(FPlanarReflectionUniformParameters, PlanarReflection) // Single global planar reflection for the forward pass.
SHADER_PARAMETER_STRUCT(FMobileSceneTextureUniformParameters, SceneTextures)
SHADER_PARAMETER_STRUCT(FSubstrateMobileForwardPassUniformParameters, Substrate)
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileFogRendering.cpp:159
Scope (from outer to inner):
file
function void FMobileSceneRenderer::RenderFog
Source code excerpt:
const bool bUseDepthTest = CVarPixelFogDepthTest.GetValueOnRenderThread() != 0;
SCOPED_DRAW_EVENT(RHICmdList, Fog);
RHICmdList.SetViewport(View.ViewRect.Min.X, View.ViewRect.Min.Y, 0.0f, View.ViewRect.Max.X, View.ViewRect.Max.Y, 1.0f);
FGraphicsPipelineStateInitializer GraphicsPSOInit;
RHICmdList.ApplyCachedRenderTargets(GraphicsPSOInit);
GraphicsPSOInit.RasterizerState = TStaticRasterizerState<FM_Solid, CM_None>::GetRHI();
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:1541
Scope (from outer to inner):
file
function void FViewInfo::SetupUniformBufferParameters
Source code excerpt:
if (Scene->ExponentialFogs.Num() > 0)
{
FExponentialHeightFogSceneInfo& Fog = Scene->ExponentialFogs[0];
Flags |= Fog.bHoldout ? ENVCOMP_FLAG_EXPONENTIALFOG_HOLDOUT : 0;
Flags |= Fog.bRenderInMainPass ? ENVCOMP_FLAG_EXPONENTIALFOG_RENDERINMAIN : 0;
}
ViewUniformShaderParameters.EnvironmentComponentsFlags.X = Flags;
}
// This should probably be in SetupCommonViewUniformBufferParameters, but drags in too many dependencies
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SkyAtmosphereRendering.cpp:1266
Scope (from outer to inner):
file
function static void SetupSkyAtmosphereInternalCommonParameters
Source code excerpt:
InternalCommonParameters.SkyLuminanceFactor = FVector3f(SkyAtmosphereSceneProxy.GetSkyLuminanceFactor());
InternalCommonParameters.AerialPespectiveViewDistanceScale = SkyAtmosphereSceneProxy.GetAerialPespectiveViewDistanceScale();
InternalCommonParameters.FogShowFlagFactor = ViewFamily.EngineShowFlags.Fog > 0 ? 1.0f : 0.0f;
auto ValidateDistanceValue = [](float& Value)
{
Value = Value < KINDA_SMALL_NUMBER ? KINDA_SMALL_NUMBER : Value;
};
auto ValidateSampleCountValue = [](float& Value)
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:1470
Scope (from outer to inner):
file
function void FSceneRenderer::ComputeVolumetricFog
Source code excerpt:
PassParameters->LFV = View.LocalFogVolumeViewData.UniformParametersStruct;
PassParameters->Fog = FogUniformBuffer;
PassParameters->View = View.ViewUniformBuffer;
SetupVolumetricFogIntegrationParameters(PassParameters->VolumetricFogParameters, View, IntegrationData);
FVolumetricFogMaterialSetupCS::FPermutationDomain PermutationVector;
PermutationVector.Set< FPermutationUseEmissive >(bUseEmissive);
PermutationVector.Set< FPermutationLocalFogVolume >(ShouldRenderLocalFogVolumeInVolumetricFog(Scene, ViewFamily, ShouldRenderLocalFogVolume(Scene, ViewFamily)));
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:1513
Scope (from outer to inner):
file
function void FSceneRenderer::ComputeVolumetricFog
Source code excerpt:
PassParameters->View = View.ViewUniformBuffer;
PassParameters->Forward = View.ForwardLightingResources.ForwardLightUniformBuffer;
PassParameters->Fog = FogUniformBuffer;
SetupVolumetricFogIntegrationParameters(PassParameters->VolumetricFogParameters, View, IntegrationData);
PassParameters->VBufferA = IntegrationData.VBufferA;
PassParameters->VBufferB = IntegrationData.VBufferB ? IntegrationData.VBufferB : VolumetricBlackDummyTexture;
PassParameters->LocalShadowedLightScattering = LocalShadowedLightScattering;
PassParameters->ConservativeDepthTexture = ConservativeDepthTexture;