ShowFlag.VolumetricFog
ShowFlag.VolumetricFog
#Overview
name: ShowFlag.VolumetricFog
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 26
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ShowFlag.VolumetricFog is to control the visibility of volumetric fog in Unreal Engine 5’s rendering pipeline. This setting variable is used to enable or disable the rendering of volumetric fog effects in the scene.
-
The volumetric fog system is part of Unreal Engine’s rendering subsystem, specifically the lighting and atmospheric effects 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 or off.
-
This variable interacts closely with other fog-related variables and systems, such as exponential height fog and light functions.
-
Developers must be aware that enabling volumetric fog can have performance implications, especially on lower-end hardware, as it’s a computationally expensive effect.
-
Best practices include:
- Using this flag in conjunction with other fog settings for optimal visual results.
- Considering performance impacts when enabling volumetric fog, especially for mobile platforms.
- Utilizing the flag for debugging and fine-tuning fog effects during development.
The associated variable VolumetricFog is used in various parts of the rendering pipeline to actually implement the volumetric fog effect. It’s used in shader parameters, texture creation, and rendering passes related to volumetric fog. This variable is typically used to store and pass fog-related data throughout the rendering process.
Developers should be aware that:
- VolumetricFog is used in multiple rendering passes, including light function rendering and final integration.
- It’s often used in conjunction with other rendering features like light functions and global illumination.
- The variable is part of larger parameter structures used in shaders and compute operations.
Best practices for using VolumetricFog include:
- Ensuring proper initialization of fog-related data structures.
- Optimizing fog calculations for performance, especially on mobile platforms.
- Coordinating its use with other atmospheric and lighting effects for consistent visual results.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:349
Scope: file
Source code excerpt:
SHOWFLAG_ALWAYS_ACCESSIBLE(LumenGlobalIllumination, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "LumenGlobalIlluminationSF", "Lumen Global Illumination"))
/** SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(VolumetricFog, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "VolumetricFogSF", "Volumetric Fog"))
/** Visualize screen space reflections, for developer (by default off): */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeSSR, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeSSR", "Screen Space Reflections"))
/** Visualize the Shading Models, mostly or debugging and profiling */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeShadingModels, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeShadingModels", "Shading Models"))
/** Visualize the senses configuration of AIs' PawnSensingComponent */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeSenses, SFG_Advanced, NSLOCTEXT("UnrealEd", "VisualizeSenses", "Senses"))
#Loc: <Workspace>/Engine/Plugins/Experimental/CinematicPrestreaming/Source/CinematicPrestreamingEditor/Private/CinePrestreamingRecorderSetting.cpp:30
Scope (from outer to inner):
file
function UCinePrestreamingRecorderSetting::UCinePrestreamingRecorderSetting
Source code excerpt:
ShowFlagsToDisable.Add("ShowFlag.Lighting");
ShowFlagsToDisable.Add("ShowFlag.Atmosphere");
ShowFlagsToDisable.Add("ShowFlag.VolumetricFog");
ShowFlagsToDisable.Add("ShowFlag.VolumetricLightmap");
ShowFlagsToDisable.Add("ShowFlag.LumenGlobalIllumiination");
ShowFlagsToDisable.Add("ShowFlag.LumenReflections");
ShowFlagsToDisable.Add("ShowFlag.AmbientOcclusion");
ShowFlagsToDisable.Add("ShowFlag.DistanceFieldAO");
}
#Associated Variable and Callsites
This variable is associated with another variable named VolumetricFog
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Compositing/Composure/Source/Composure/Private/ComposureUtils.cpp:18
Scope (from outer to inner):
file
function void FComposureUtils::SetEngineShowFlagsForPostprocessingOnly
Source code excerpt:
EngineShowFlags.Translucency = false;
EngineShowFlags.AntiAliasing = false;
EngineShowFlags.MotionBlur = false;
EngineShowFlags.Bloom = false;
EngineShowFlags.EyeAdaptation = false;
EngineShowFlags.VolumetricFog = false;
EngineShowFlags.Atmosphere = false;
EngineShowFlags.Fog = false;
#if !UE_BUILD_OPTIMIZED_SHOWFLAGS
// Development-only flags
EngineShowFlags.ReflectionOverride = false;
EngineShowFlags.DepthOfField = false;
#endif
}
// static
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterInfoRendering.cpp:648
Scope (from outer to inner):
file
namespace UE::WaterInfo
function static FSceneRenderer* CreateWaterInfoSceneRenderer
Source code excerpt:
ShowFlags.ScreenPercentage = 0;
ShowFlags.Translucency = 0;
ShowFlags.SeparateTranslucency = 0;
ShowFlags.AntiAliasing = 0;
ShowFlags.Fog = 0;
ShowFlags.VolumetricFog = 0;
ShowFlags.DynamicShadows = 0;
ShowFlags.SetDisableOcclusionQueries(true);
ShowFlags.SetVirtualShadowMapPersistentData(false);
FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(
Params.RenderTarget,
Params.Scene,
ShowFlags)
.SetRealtimeUpdate(false)
.SetResolveScene(false));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Components/LightComponent.h:154
Scope: file
Source code excerpt:
FLightingChannels LightingChannels;
/**
* The light function material to be applied to this light.
* Note that only non-lightmapped lights (UseDirectLightMap=False) can have a light function.
* Light functions are supported within VolumetricFog, but only for Directional, Point and Spot lights. Rect lights are not supported.
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=LightFunction)
TObjectPtr<class UMaterialInterface> LightFunctionMaterial;
#if WITH_EDITORONLY_DATA
/** When clearing the light func, e.g. because the light is made static, this field remembers the last value */
UPROPERTY(Transient)
TObjectPtr<class UMaterialInterface> StashedLightFunctionMaterial;
#endif
/** Scales the light function projection. X and Y scale in the directions perpendicular to the light's direction, Z scales along the light direction. */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=LightFunction, meta=(AllowPreserveRatio = "true"))
FVector LightFunctionScale;
/** IES texture (light profiles from real world measured data) */
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:346
Scope: file
Source code excerpt:
/** Distance field AO, for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(DistanceFieldAO, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "DistanceFieldAOSF", "Distance Field Ambient Occlusion"))
/** Lumen GI */
SHOWFLAG_ALWAYS_ACCESSIBLE(LumenGlobalIllumination, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "LumenGlobalIlluminationSF", "Lumen Global Illumination"))
/** SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(VolumetricFog, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "VolumetricFogSF", "Volumetric Fog"))
/** Visualize screen space reflections, for developer (by default off): */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeSSR, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeSSR", "Screen Space Reflections"))
/** Visualize the Shading Models, mostly or debugging and profiling */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeShadingModels, SFG_Visualize, NSLOCTEXT("UnrealEd", "VisualizeShadingModels", "Shading Models"))
/** Visualize the senses configuration of AIs' PawnSensingComponent */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeSenses, SFG_Advanced, NSLOCTEXT("UnrealEd", "VisualizeSenses", "Senses"))
/** Visualize LOD Coloration */
SHOWFLAG_FIXED_IN_SHIPPING(0, LODColoration, SFG_Hidden, NSLOCTEXT("UnrealEd", "VisualizeLODColoration", "Visualize LOD Coloration"))
/** Visualize HLOD Coloration */
SHOWFLAG_FIXED_IN_SHIPPING(0, HLODColoration, SFG_Hidden, NSLOCTEXT("UnrealEd", "VisualizeHLODColoration", "Visualize HLOD Coloration"))
/** Visualize screen quads */
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightFunctionAtlas.cpp:284
Scope (from outer to inner):
file
namespace LightFunctionAtlas
function void FLightFunctionAtlas::BeginSceneFrame
Source code excerpt:
// We propagate bLightFunctionAtlasEnabled to all the views to ease later shader parameter decision and binding for lighting, shadow or volumetric fog for instance (avoid sending lots of parameters all over the place)
LightFunctionAtlasSceneData.SetData(this, bLightFunctionAtlasEnabled);
if (bLightFunctionAtlasEnabled)
{
if (bVolumetricFogRequestsLF) { LightFunctionAtlasSceneData.AddSystem(ELightFunctionAtlasSystem::VolumetricFog); }
if (bDeferredlightingRequestsLF) { LightFunctionAtlasSceneData.AddSystem(ELightFunctionAtlasSystem::DeferredLighting); }
if (bManyLightsRequestsLF) { LightFunctionAtlasSceneData.AddSystem(ELightFunctionAtlasSystem::ManyLights); }
if (bLumenRequestsLF) { LightFunctionAtlasSceneData.AddSystem(ELightFunctionAtlasSystem::Lumen); }
}
for (uint32 ViewIndex=0,ViewCount=Views.Num();ViewIndex<ViewCount;++ViewIndex)
{
Views[ViewIndex].LightFunctionAtlasViewData = FLightFunctionAtlasViewData(&LightFunctionAtlasSceneData, ViewIndex);
}
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightFunctionAtlas.h:33
Scope (from outer to inner):
file
namespace LightFunctionAtlas
Source code excerpt:
SHADER_PARAMETER(float, Slot_UVSize)
END_GLOBAL_SHADER_PARAMETER_STRUCT()
enum class ELightFunctionAtlasSystem
{
VolumetricFog,
DeferredLighting,
ManyLights,
Lumen,
};
struct FLightFunctionAtlas;
struct FLightFunctionAtlasSceneData
{
void SetData(FLightFunctionAtlas* InLightFunctionAtlas, bool bInLightFunctionAtlasEnabled)
{
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenTranslucencyVolumeLighting.h:36
Scope: file
Source code excerpt:
SHADER_PARAMETER(FVector3f, TranslucencyGIGridZParams)
SHADER_PARAMETER(uint32, TranslucencyGIGridPixelSizeShift)
SHADER_PARAMETER(FIntVector, TranslucencyGIGridSize)
END_SHADER_PARAMETER_STRUCT()
// Used by VolumetricFog and HeterogeneousVolumes
BEGIN_GLOBAL_SHADER_PARAMETER_STRUCT(FLumenTranslucencyLightingUniforms, )
SHADER_PARAMETER_STRUCT_INCLUDE(FLumenTranslucencyLightingParameters, Parameters)
END_GLOBAL_SHADER_PARAMETER_STRUCT()
extern FLumenTranslucencyLightingParameters GetLumenTranslucencyLightingParameters(
FRDGBuilder& GraphBuilder,
const FLumenTranslucencyGIVolume& LumenTranslucencyGIVolume,
const FLumenFrontLayerTranslucency& LumenFrontLayerTranslucency
);
// Used by Translucency Lighting pipeline shaders
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:487
Scope: file
Source code excerpt:
FASTVRAM_CVAR(DistanceFieldAOBentNormal, 0);
FASTVRAM_CVAR(DistanceFieldIrradiance, 0);
FASTVRAM_CVAR(DistanceFieldShadows, 1);
FASTVRAM_CVAR(Distortion, 1);
FASTVRAM_CVAR(ScreenSpaceShadowMask, 1);
FASTVRAM_CVAR(VolumetricFog, 1);
FASTVRAM_CVAR(SeparateTranslucency, 0);
FASTVRAM_CVAR(SeparateTranslucencyModulate, 0);
FASTVRAM_CVAR(ScreenSpaceAO,0);
FASTVRAM_CVAR(SSR, 0);
FASTVRAM_CVAR(DBufferA, 0);
FASTVRAM_CVAR(DBufferB, 0);
FASTVRAM_CVAR(DBufferC, 0);
FASTVRAM_CVAR(DBufferMask, 0);
FASTVRAM_CVAR(DOFSetup, 1);
FASTVRAM_CVAR(DOFReduce, 1);
FASTVRAM_CVAR(DOFPostfilter, 1);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:687
Scope (from outer to inner):
file
function void FFastVramConfig::Update
Source code excerpt:
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldAOBentNormal, DistanceFieldAOBentNormal);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldIrradiance, DistanceFieldIrradiance);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DistanceFieldShadows, DistanceFieldShadows);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_Distortion, Distortion);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_ScreenSpaceShadowMask, ScreenSpaceShadowMask);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_VolumetricFog, VolumetricFog);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_SeparateTranslucency, SeparateTranslucency);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_SeparateTranslucencyModulate, SeparateTranslucencyModulate);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_ScreenSpaceAO, ScreenSpaceAO);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_SSR, SSR);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DBufferA, DBufferA);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DBufferB, DBufferB);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DBufferC, DBufferC);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DBufferMask, DBufferMask);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DOFSetup, DOFSetup);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DOFReduce, DOFReduce);
bDirty |= UpdateTextureFlagFromCVar(CVarFastVRam_DOFPostfilter, DOFPostfilter);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.h:2837
Scope: file
Source code excerpt:
ETextureCreateFlags DistanceFieldShadows;
ETextureCreateFlags DistanceFieldIrradiance;
ETextureCreateFlags DistanceFieldAOConfidence;
ETextureCreateFlags Distortion;
ETextureCreateFlags ScreenSpaceShadowMask;
ETextureCreateFlags VolumetricFog;
ETextureCreateFlags SeparateTranslucency;
ETextureCreateFlags SeparateTranslucencyModulate;
ETextureCreateFlags ScreenSpaceAO;
ETextureCreateFlags SSR;
ETextureCreateFlags DBufferA;
ETextureCreateFlags DBufferB;
ETextureCreateFlags DBufferC;
ETextureCreateFlags DBufferMask;
ETextureCreateFlags DOFSetup;
ETextureCreateFlags DOFReduce;
ETextureCreateFlags DOFPostfilter;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:-2
Scope: file
Source code excerpt:
// Copyright Epic Games, Inc. All Rights Reserved.
/*=============================================================================
VolumetricFog.cpp
=============================================================================*/
#include "VolumetricFog.h"
#include "BasePassRendering.h"
#include "FogRendering.h"
#include "RendererPrivate.h"
#include "ScenePrivate.h"
#include "SceneUtils.h"
#include "GlobalDistanceField.h"
#include "GlobalDistanceFieldParameters.h"
#include "DistanceFieldAmbientOcclusion.h"
#include "DistanceFieldLightingShared.h"
#include "VolumetricFogShared.h"
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:194
Scope (from outer to inner):
file
function void SetupVolumetricFogIntegrationParameters
Source code excerpt:
void SetupVolumetricFogIntegrationParameters(
FVolumetricFogIntegrationParameters& Out,
FViewInfo& View,
const FVolumetricFogIntegrationParameterData& IntegrationData)
{
Out.VolumetricFog = View.VolumetricFogResources.VolumetricFogGlobalData;
FMatrix44f UnjitteredInvTranslatedViewProjectionMatrix = FMatrix44f(View.ViewMatrices.ComputeInvProjectionNoAAMatrix() * View.ViewMatrices.GetTranslatedViewMatrix().GetTransposed());
Out.UnjitteredClipToTranslatedWorld = UnjitteredInvTranslatedViewProjectionMatrix;
FMatrix TranslatedWorldToWorld = FTranslationMatrix(-View.ViewMatrices.GetPreViewTranslation());
FMatrix44f UnjitteredTranslatedViewProjectionMatrix = FMatrix44f(TranslatedWorldToWorld * View.PrevViewInfo.ViewMatrices.GetViewMatrix() * View.PrevViewInfo.ViewMatrices.ComputeProjectionNoAAMatrix());
Out.UnjitteredPrevTranslatedWorldToClip = UnjitteredTranslatedViewProjectionMatrix;
int32 OffsetCount = IntegrationData.FrameJitterOffsetValues.Num();
for (int32 i = 0; i < OffsetCount; ++i)
{
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:256
Scope (from outer to inner):
file
class class FVolumetricFogMaterialSetupCS : public FGlobalShader
Source code excerpt:
FGlobalShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
OutEnvironment.SetDefine(TEXT("THREADGROUP_SIZE"), VolumetricFogGridInjectionGroupSize);
}
};
IMPLEMENT_GLOBAL_SHADER(FVolumetricFogMaterialSetupCS, "/Engine/Private/VolumetricFog.usf", "MaterialSetupCS", SF_Compute);
/** Vertex shader used to write to a range of slices of a 3d volume texture. */
class FWriteToBoundingSphereVS : public FGlobalShader
{
DECLARE_GLOBAL_SHADER(FWriteToBoundingSphereVS);
SHADER_USE_PARAMETER_STRUCT(FWriteToBoundingSphereVS, FGlobalShader);
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
SHADER_PARAMETER_STRUCT_INCLUDE(FVolumetricFogIntegrationParameters, VolumetricFogParameters)
SHADER_PARAMETER(FMatrix44f, ViewToVolumeClip)
SHADER_PARAMETER(FVector2f, ClipRatio)
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:279
Scope (from outer to inner):
file
class class FVolumetricFogMaterialSetupCS : public FGlobalShader
Source code excerpt:
FGlobalShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
OutEnvironment.CompilerFlags.Add(CFLAG_VertexToGeometryShader);
}
};
IMPLEMENT_GLOBAL_SHADER(FWriteToBoundingSphereVS, "/Engine/Private/VolumetricFog.usf", "WriteToBoundingSphereVS", SF_Vertex);
BEGIN_SHADER_PARAMETER_STRUCT(FInjectShadowedLocalLightCommonParameters, )
SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, ViewUniformBuffer)
SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FDeferredLightUniformStruct, DeferredLight)
SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FLightFunctionAtlasGlobalParameters, LightFunctionAtlas)
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, WhiteDummyTexture)
SHADER_PARAMETER_STRUCT_INCLUDE(FVolumetricFogIntegrationParameters, VolumetricFogParameters)
SHADER_PARAMETER(float, PhaseG)
SHADER_PARAMETER(float, InverseSquaredLightDistanceBiasScale)
SHADER_PARAMETER(uint32, LightFunctionAtlasLightIndex)
END_SHADER_PARAMETER_STRUCT()
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:725
Scope (from outer to inner):
file
function void FSceneRenderer::RenderLocalLightsForVolumetricFog
Source code excerpt:
}
}
}
// Setup the light function atlas
const bool bUseLightFunctionAtlas = LightFunctionAtlas::IsEnabled(View, ELightFunctionAtlasSystem::VolumetricFog);
TRDGUniformBufferRef<FLightFunctionAtlasGlobalParameters> LightFunctionAtlasGlobalParameters = LightFunctionAtlas::BindGlobalParameters(GraphBuilder, View);
// Now voxelise all the light we have just gathered.
bool bClearExecuted = false;
if (LightsToInject.Num() > 0)
{
for (int32 LightIndex = 0; LightIndex < LightsToInject.Num(); LightIndex++)
{
const FLightSceneInfo* LightSceneInfo = LightsToInject[LightIndex];
const FVisibleLightInfo& VisibleLightInfo = VisibleLightInfos[LightSceneInfo->Id];
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:1085
Scope (from outer to inner):
file
function BEGIN_SHADER_PARAMETER_STRUCT
Source code excerpt:
FGlobalShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
OutEnvironment.SetDefine(TEXT("THREADGROUP_SIZE"), VolumetricFogIntegrationGroupSize);
}
};
IMPLEMENT_GLOBAL_SHADER(FVolumetricFogFinalIntegrationCS, "/Engine/Private/VolumetricFog.usf", "FinalIntegrationCS", SF_Compute);
bool DoesPlatformSupportVolumetricFogVoxelization(const FStaticShaderPlatform Platform)
{
return !IsMobilePlatform(Platform);
}
bool ShouldRenderVolumetricFog(const FScene* Scene, const FSceneViewFamily& ViewFamily)
{
return ShouldRenderFog(ViewFamily)
&& Scene
&& GVolumetricFog
&& ViewFamily.EngineShowFlags.VolumetricFog
&& Scene->ExponentialFogs.Num() > 0
&& Scene->ExponentialFogs[0].bEnableVolumetricFog
&& Scene->ExponentialFogs[0].VolumetricFogDistance > 0;
}
FVector GetVolumetricFogGridZParams(float VolumetricFogStartDistance, float NearPlane, float FarPlane, int32 GridSizeZ)
{
// S = distribution scale
// B, O are solved for given the z distances of the first+last slice, and the # of slices.
//
// slice = log2(z*B + O) * S
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:1325
Scope (from outer to inner):
file
function void FSceneRenderer::ComputeVolumetricFog
Source code excerpt:
const FExponentialHeightFogSceneInfo& FogInfo = Scene->ExponentialFogs[0];
TRACE_CPUPROFILER_EVENT_SCOPE(FSceneRenderer::ComputeVolumetricFog);
QUICK_SCOPE_CYCLE_COUNTER(STAT_VolumetricFog);
RDG_CSV_STAT_EXCLUSIVE_SCOPE(GraphBuilder, VolumetricFog);
RDG_GPU_STAT_SCOPE(GraphBuilder, VolumetricFog);
for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
{
FViewInfo& View = Views[ViewIndex];
RDG_GPU_MASK_SCOPE(GraphBuilder, View.GPUMask);
// Allocate texture using scene render targets size so we do not reallocate every frame when dynamic resolution is used in order to avoid resources allocation hitches.
const FIntPoint BufferSize = View.GetSceneTexturesConfig().Extent;
int32 VolumetricFogGridPixelSize;
const FIntVector VolumetricFogResourceGridSize = GetVolumetricFogResourceGridSize(View, VolumetricFogGridPixelSize);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:1352
Scope (from outer to inner):
file
function void FSceneRenderer::ComputeVolumetricFog
Source code excerpt:
{
IntegrationData.FrameJitterOffsetValues[FrameOffsetIndex] = VolumetricFogTemporalRandom(View.Family->FrameNumber - FrameOffsetIndex);
}
// Mobile has limited capacities with SRV binding so do not enable atlas sampling on there.
const bool bUseLightFunctionAtlas = LightFunctionAtlas::IsEnabled(*Scene, ELightFunctionAtlasSystem::VolumetricFog) && !IsMobilePlatform(View.GetShaderPlatform());
const bool bUseTemporalReprojection =
GVolumetricFogTemporalReprojection
&& View.ViewState
&& !IsMobilePlatform(View.GetShaderPlatform());
IntegrationData.bTemporalHistoryIsValid =
bUseTemporalReprojection
&& !View.bCameraCut
&& !View.bPrevTransformsReset
&& ViewFamily.bRealtimeUpdate
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:1435
Scope (from outer to inner):
file
function void FSceneRenderer::ComputeVolumetricFog
Source code excerpt:
TRDGUniformBufferRef<FFogUniformParameters> FogUniformBuffer = CreateFogUniformBuffer(GraphBuilder, View);
FRDGTextureDesc VolumeDesc = GetVolumetricFogRDGTextureDesc(VolumetricFogResourceGridSize);
FRDGTextureDesc VolumeDescFastVRAM = VolumeDesc;
VolumeDescFastVRAM.Flags |= GFastVRamConfig.VolumetricFog;
IntegrationData.VBufferA = GraphBuilder.CreateTexture(VolumeDescFastVRAM, TEXT("VolumetricFog.VBufferA"));
IntegrationData.VBufferA_UAV = GraphBuilder.CreateUAV(FRDGTextureUAVDesc(IntegrationData.VBufferA));
IntegrationData.VBufferB = nullptr;
IntegrationData.VBufferB_UAV = nullptr;
if (bUseEmissive)
{
IntegrationData.VBufferB = GraphBuilder.CreateTexture(VolumeDescFastVRAM, TEXT("VolumetricFog.VBufferB"));
IntegrationData.VBufferB_UAV = GraphBuilder.CreateUAV(FRDGTextureUAVDesc(IntegrationData.VBufferB));
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.h:-2
Scope: file
Source code excerpt:
// Copyright Epic Games, Inc. All Rights Reserved.
/*=============================================================================
VolumetricFog.h
=============================================================================*/
#pragma once
#include "RHIDefinitions.h"
#include "SceneView.h"
#include "SceneRendering.h"
// Grid size for resource allocation to be independent of dynamic resolution
extern FIntVector GetVolumetricFogResourceGridSize(const FViewInfo& View, int32& OutVolumetricFogGridPixelSize);
// Grid size for the view rectangle within the allocated resource
extern FIntVector GetVolumetricFogViewGridSize(const FViewInfo& View, int32& OutVolumetricFogGridPixelSize);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFogLightFunction.cpp:234
Scope: file
Source code excerpt:
}
// Now render the texture
{
FRDGTextureDesc LightFunctionTextureDesc = FRDGTextureDesc::Create2D(LightFunctionResolution, PF_G8, FClearValueBinding::None, TexCreate_ShaderResource | TexCreate_RenderTargetable);
LightFunctionTextureDesc.Flags |= GFastVRamConfig.VolumetricFog;
FRDGTexture* LightFunctionTexture = GraphBuilder.CreateTexture(LightFunctionTextureDesc, TEXT("VolumetricFog.LightFunction"));
OutDirectionalLightFunctionTexture = LightFunctionTexture;
const FMaterialRenderProxy* MaterialProxyForRendering = OutDirectionalLightSceneInfo->Proxy->GetLightFunctionMaterial();
const FMaterial& Material = MaterialProxyForRendering->GetMaterialWithFallback(Scene->GetFeatureLevel(), MaterialProxyForRendering);
FVolumetricFogLightFunctionParameters* PassParameters = GraphBuilder.AllocParameters<FVolumetricFogLightFunctionParameters>();
PassParameters->RenderTargets[0] = FRenderTargetBinding(LightFunctionTexture, ERenderTargetLoadAction::ENoAction);
PassParameters->SceneTextures = SceneTextures.UniformBuffer;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFogShared.h:8
Scope: file
Source code excerpt:
BEGIN_GLOBAL_SHADER_PARAMETER_STRUCT(FVoxelizeVolumePassUniformParameters, )
SHADER_PARAMETER_STRUCT(FSceneTextureUniformParameters, SceneTextures)
SHADER_PARAMETER(FMatrix44f, ViewToVolumeClip)
SHADER_PARAMETER(FVector2f, ClipRatio)
SHADER_PARAMETER(FVector4f, FrameJitterOffset0)
SHADER_PARAMETER_STRUCT(FVolumetricFogGlobalData, VolumetricFog)
SHADER_PARAMETER(FVector3f, RenderVolumetricCloudParametersCloudLayerCenterKm)
SHADER_PARAMETER(float, RenderVolumetricCloudParametersPlanetRadiusKm)
SHADER_PARAMETER(float, RenderVolumetricCloudParametersBottomRadiusKm)
SHADER_PARAMETER(float, RenderVolumetricCloudParametersTopRadiusKm)
END_GLOBAL_SHADER_PARAMETER_STRUCT()
extern FVector3f VolumetricFogTemporalRandom(uint32 FrameNumber);
struct FVolumetricFogIntegrationParameterData
{
FVolumetricFogIntegrationParameterData() :
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFogShared.h:35
Scope: file
Source code excerpt:
FRDGTexture* LightScattering;
FRDGTextureUAV* LightScatteringUAV;
};
BEGIN_SHADER_PARAMETER_STRUCT(FVolumetricFogIntegrationParameters, )
SHADER_PARAMETER_STRUCT_REF(FVolumetricFogGlobalData, VolumetricFog)
SHADER_PARAMETER(FMatrix44f, UnjitteredClipToTranslatedWorld)
SHADER_PARAMETER(FMatrix44f, UnjitteredPrevTranslatedWorldToClip)
SHADER_PARAMETER_ARRAY(FVector4f, FrameJitterOffsets, [16])
SHADER_PARAMETER(float, HistoryWeight)
SHADER_PARAMETER(uint32, HistoryMissSuperSampleCount)
END_SHADER_PARAMETER_STRUCT()
void SetupVolumetricFogIntegrationParameters(
FVolumetricFogIntegrationParameters& Out,
FViewInfo& View,
const FVolumetricFogIntegrationParameterData& IntegrationData);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFogVoxelization.cpp:56
Scope (from outer to inner):
file
function TRDGUniformBufferRef<FVoxelizeVolumePassUniformParameters> CreateVoxelizeVolumePassUniformBuffer
Source code excerpt:
Parameters->ViewToVolumeClip.M[2][0] += Jitter.X;
Parameters->ViewToVolumeClip.M[2][1] += Jitter.Y;
Parameters->FrameJitterOffset0 = IntegrationData.FrameJitterOffsetValues[0];
SetupVolumetricFogGlobalData(View, Parameters->VolumetricFog);
if (CloudInfo)
{
const FVolumetricCloudCommonShaderParameters& CloudGlobalShaderParams = CloudInfo->GetVolumetricCloudCommonShaderParameters();
Parameters->RenderVolumetricCloudParametersCloudLayerCenterKm = CloudGlobalShaderParams.CloudLayerCenterKm;
Parameters->RenderVolumetricCloudParametersPlanetRadiusKm = CloudGlobalShaderParams.PlanetRadiusKm;
Parameters->RenderVolumetricCloudParametersBottomRadiusKm = CloudGlobalShaderParams.BottomRadiusKm;
Parameters->RenderVolumetricCloudParametersTopRadiusKm = CloudGlobalShaderParams.TopRadiusKm;
}
else
{