r.Mobile.PixelFogQuality
r.Mobile.PixelFogQuality
#Overview
name: r.Mobile.PixelFogQuality
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Exponentional height fog rendering quality.\n0 - basic per-pixel fog1 - all per-pixel fog features (second fog, directional inscattering, aerial perspective)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Mobile.PixelFogQuality is to control the quality of exponential height fog rendering in mobile environments within Unreal Engine 5. This setting variable is specifically designed for the rendering system, focusing on fog effects in mobile game development.
This setting variable is primarily used in the Renderer module of Unreal Engine, specifically in the mobile fog rendering subsystem. This can be seen from the file location “Engine/Source/Runtime/Renderer/Private/MobileFogRendering.cpp”.
The value of this variable is set using a console variable (CVar) system. It’s defined with a default value of 1, which enables all per-pixel fog features including second fog, directional inscattering, and aerial perspective.
The variable interacts closely with its associated variable CVarPixelFogQuality. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable affects the quality and performance trade-off in mobile fog rendering. A value of 0 provides basic per-pixel fog, while a value of 1 enables all per-pixel fog features, which may have performance implications on mobile devices.
Best practices when using this variable include:
- Consider the target mobile hardware capabilities when setting this value.
- Test thoroughly with different values to find the optimal balance between visual quality and performance.
- Be aware that changing this value at runtime may affect the game’s performance and visual consistency.
Regarding the associated variable CVarPixelFogQuality:
The purpose of CVarPixelFogQuality is to provide a programmatic way to access and modify the r.Mobile.PixelFogQuality setting within the C++ code of Unreal Engine.
This variable is used directly in the Renderer module, specifically in the mobile fog rendering system. It’s used to determine the level of fog quality to apply during rendering.
The value of CVarPixelFogQuality is set when r.Mobile.PixelFogQuality is set, as they share the same underlying value.
CVarPixelFogQuality interacts closely with the Scene’s ExponentialFogs and the SkyAtmosphere rendering. It’s used to determine whether to render aerial perspective effects.
Developers should be aware that this variable is accessed on the render thread (GetValueOnRenderThread()), which is important for thread safety in rendering code.
Best practices for using CVarPixelFogQuality include:
- Always access it using GetValueOnRenderThread() when in render thread code.
- Be cautious about changing its value during runtime, as it may affect ongoing rendering processes.
- Consider caching its value if used frequently in performance-critical sections of code.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileFogRendering.cpp:23
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarPixelFogQuality(
TEXT("r.Mobile.PixelFogQuality"),
1,
TEXT("Exponentional height fog rendering quality.\n")
TEXT("0 - basic per-pixel fog")
TEXT("1 - all per-pixel fog features (second fog, directional inscattering, aerial perspective)"),
ECVF_Scalability | ECVF_RenderThreadSafe);
#Associated Variable and Callsites
This variable is associated with another variable named CVarPixelFogQuality
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileFogRendering.cpp:22
Scope: file
Source code excerpt:
DECLARE_GPU_STAT(MobileFog);
static TAutoConsoleVariable<int32> CVarPixelFogQuality(
TEXT("r.Mobile.PixelFogQuality"),
1,
TEXT("Exponentional height fog rendering quality.\n")
TEXT("0 - basic per-pixel fog")
TEXT("1 - all per-pixel fog features (second fog, directional inscattering, aerial perspective)"),
ECVF_Scalability | ECVF_RenderThreadSafe);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MobileFogRendering.cpp:147
Scope (from outer to inner):
file
function void FMobileSceneRenderer::RenderFog
Source code excerpt:
}
const int32 PixelFogQuality = CVarPixelFogQuality.GetValueOnRenderThread();
const bool bUseHeightFog = Scene->ExponentialFogs.Num() > 0 && ShouldRenderFog(*View.Family);
const bool bUseAerialPerspective = PixelFogQuality > 0 && ShouldRenderSkyAtmosphere(Scene, View.Family->EngineShowFlags);
if (!bUseAerialPerspective && !bUseHeightFog)
{
RenderLocalFogVolumeMobileLambda();