r.VolumetricFog.UpsampleJitterMultiplier
r.VolumetricFog.UpsampleJitterMultiplier
#Overview
name: r.VolumetricFog.UpsampleJitterMultiplier
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Multiplier for random offset value used to jitter the sample position of the 3D fog volume to hide fog pixelization due to sampling from a lower resolution texture.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VolumetricFog.UpsampleJitterMultiplier is to control the jittering of sample positions in the 3D fog volume to reduce pixelization artifacts when sampling from a lower resolution texture. This setting is part of Unreal Engine 5’s volumetric fog rendering system.
This setting variable is primarily used in the Renderer module, specifically in the fog rendering subsystem. Based on the callsites, it’s referenced in the FogRendering.cpp file, which is responsible for implementing various fog rendering techniques.
The value of this variable is set through a console variable (CVarUpsampleJitterMultiplier) with an initial value of 0.0f. It can be modified at runtime through console commands or programmatically.
The variable interacts directly with GVolumetricFogGridPixelSize, as seen in the code where the final jitter multiplier is calculated by multiplying the console variable value with GVolumetricFogGridPixelSize.
Developers should be aware that this variable affects the visual quality of volumetric fog. A higher value will increase the jittering effect, potentially hiding pixelization artifacts but may introduce noise. A lower value will reduce the jittering effect, potentially making pixelization more noticeable but resulting in a cleaner image.
Best practices when using this variable include:
- Adjusting it based on the specific needs of your scene and the resolution of your volumetric fog texture.
- Testing different values to find the right balance between artifact reduction and image clarity.
- Considering performance implications, as increased jittering may have a small impact on render time.
Regarding the associated variable CVarUpsampleJitterMultiplier:
The purpose of CVarUpsampleJitterMultiplier is to provide a way to control the r.VolumetricFog.UpsampleJitterMultiplier setting through the console variable system in Unreal Engine.
This variable is part of the engine’s configuration system and is used directly in the Renderer module to affect volumetric fog rendering.
The value of CVarUpsampleJitterMultiplier is set when the engine initializes the console variable system. It can be modified at runtime through console commands or programmatically.
CVarUpsampleJitterMultiplier interacts directly with the GVolumetricFogGridPixelSize global variable when calculating the final jitter multiplier.
Developers should be aware that this is a render thread safe variable (ECVF_RenderThreadSafe) and also marked as a scalability setting (ECVF_Scalability). This means it can be safely modified on the render thread and may be automatically adjusted based on the game’s scalability settings.
Best practices for using CVarUpsampleJitterMultiplier include:
- Using it to dynamically adjust the jitter multiplier based on performance needs or visual quality requirements.
- Considering its impact on different hardware configurations due to its scalability flag.
- When modifying it programmatically, ensure thread safety by using appropriate methods for accessing console variables on 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/FogRendering.cpp:32
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarUpsampleJitterMultiplier(
TEXT("r.VolumetricFog.UpsampleJitterMultiplier"),
0.0f,
TEXT("Multiplier for random offset value used to jitter the sample position of the 3D fog volume to hide fog pixelization due to sampling from a lower resolution texture."),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<bool> CVarUnderwaterFogWhenCameraIsAboveWater(
TEXT("r.Water.SingleLayer.UnderwaterFogWhenCameraIsAboveWater"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarUpsampleJitterMultiplier
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/FogRendering.cpp:31
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarUpsampleJitterMultiplier(
TEXT("r.VolumetricFog.UpsampleJitterMultiplier"),
0.0f,
TEXT("Multiplier for random offset value used to jitter the sample position of the 3D fog volume to hide fog pixelization due to sampling from a lower resolution texture."),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<bool> CVarUnderwaterFogWhenCameraIsAboveWater(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/FogRendering.cpp:283
Scope: file
Source code excerpt:
PassParameters->PS.OcclusionTextureMinMaxUV = FVector4f(LightShaftParameters.UVViewportBilinearMin, LightShaftParameters.UVViewportBilinearMax);
PassParameters->PS.WaterDepthTextureMinMaxUV = FVector4f::Zero();
PassParameters->PS.UpsampleJitterMultiplier = CVarUpsampleJitterMultiplier.GetValueOnRenderThread() * GVolumetricFogGridPixelSize;
PassParameters->PS.bOnlyOnRenderedOpaque = View.bFogOnlyOnRenderedOpaque;
PassParameters->PS.bUseWaterDepthTexture = false;
PassParameters->PS.SrcCloudDepthTexture = GSystemTextures.GetWhiteDummy(GraphBuilder);
PassParameters->PS.SrcCloudDepthSampler = TStaticSamplerState<SF_Point, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI();
PassParameters->PS.SrcCloudViewTexture = GSystemTextures.GetWhiteDummy(GraphBuilder);