r.VolumetricFog.HistoryWeight
r.VolumetricFog.HistoryWeight
#Overview
name: r.VolumetricFog.HistoryWeight
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
How much the history value should be weighted each frame. This is a tradeoff between visible jittering and responsiveness.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VolumetricFog.HistoryWeight is to control the temporal stability of volumetric fog rendering in Unreal Engine 5. This setting variable is used in the rendering system, specifically for volumetric fog calculations.
This setting variable is primarily used in the Renderer module of Unreal Engine, as evidenced by its location in the VolumetricFog.cpp file within the Runtime/Renderer/Private directory.
The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 0.9f and can be modified at runtime using console commands or through project settings.
The r.VolumetricFog.HistoryWeight variable interacts directly with the GVolumetricFogHistoryWeight variable. They share the same value, with GVolumetricFogHistoryWeight being the actual variable used in the code, while r.VolumetricFog.HistoryWeight is the console variable name used for external access and modification.
Developers must be aware that this variable affects the trade-off between visible jittering and responsiveness in volumetric fog rendering. A higher value will result in more stable but less responsive fog, while a lower value will make the fog more responsive to changes but potentially more prone to visible jittering.
Best practices when using this variable include:
- Adjusting it based on the specific needs of your scene and performance requirements.
- Testing different values to find the optimal balance between stability and responsiveness for your particular use case.
- Considering the impact on different hardware configurations, as the optimal value might vary depending on the target platform.
Regarding the associated variable GVolumetricFogHistoryWeight:
The purpose of GVolumetricFogHistoryWeight is to store the actual value used in the volumetric fog calculations. It’s the internal representation of the r.VolumetricFog.HistoryWeight console variable.
This variable is used directly in the SetupVolumetricFogIntegrationParameters function within the Renderer module. It determines how much the history value should be weighted each frame in the volumetric fog calculations.
The value of GVolumetricFogHistoryWeight is set by the console variable system when r.VolumetricFog.HistoryWeight is modified.
GVolumetricFogHistoryWeight interacts with the IntegrationData.bTemporalHistoryIsValid flag to determine the final history weight used in the calculations. If temporal history is not valid, the weight is set to 0.0f, effectively disabling the history for that frame.
Developers should be aware that modifying GVolumetricFogHistoryWeight directly in code is not recommended. Instead, they should use the r.VolumetricFog.HistoryWeight console variable to ensure proper synchronization between the two.
Best practices for GVolumetricFogHistoryWeight include:
- Avoiding direct modification in code; use the console variable system instead.
- Considering the impact of this value on both visual quality and performance when adjusting it.
- Testing the effects of different values in various scenarios to understand its impact on your specific use case.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:89
Scope: file
Source code excerpt:
float GVolumetricFogHistoryWeight = .9f;
FAutoConsoleVariableRef CVarVolumetricFogHistoryWeight(
TEXT("r.VolumetricFog.HistoryWeight"),
GVolumetricFogHistoryWeight,
TEXT("How much the history value should be weighted each frame. This is a tradeoff between visible jittering and responsiveness."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
int32 GVolumetricFogHistoryMissSupersampleCount = 4;
#Associated Variable and Callsites
This variable is associated with another variable named GVolumetricFogHistoryWeight
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:87
Scope: file
Source code excerpt:
);
float GVolumetricFogHistoryWeight = .9f;
FAutoConsoleVariableRef CVarVolumetricFogHistoryWeight(
TEXT("r.VolumetricFog.HistoryWeight"),
GVolumetricFogHistoryWeight,
TEXT("How much the history value should be weighted each frame. This is a tradeoff between visible jittering and responsiveness."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
int32 GVolumetricFogHistoryMissSupersampleCount = 4;
FAutoConsoleVariableRef CVarVolumetricFogHistoryMissSupersampleCount(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:212
Scope (from outer to inner):
file
function void SetupVolumetricFogIntegrationParameters
Source code excerpt:
}
extern float GVolumetricFogHistoryWeight;
Out.HistoryWeight = IntegrationData.bTemporalHistoryIsValid ? GVolumetricFogHistoryWeight : 0.0f;
extern int32 GVolumetricFogHistoryMissSupersampleCount;
Out.HistoryMissSuperSampleCount = FMath::Clamp(GVolumetricFogHistoryMissSupersampleCount, 1, 16);
}
static const uint32 VolumetricFogGridInjectionGroupSize = 4;