r.VolumetricFog.Jitter

r.VolumetricFog.Jitter

#Overview

name: r.VolumetricFog.Jitter

This variable is created as a Console Variable (cvar).

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.VolumetricFog.Jitter is to control whether jitter is applied to each frame’s volumetric fog computation, achieving temporal super sampling in the volumetric fog rendering process.

This setting variable is primarily used in the rendering system, specifically for the volumetric fog subsystem within Unreal Engine 5. It is part of the Renderer module, 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, as indicated by the FAutoConsoleVariableRef declaration. It can be modified at runtime using console commands or through project settings.

The associated variable GVolumetricFogJitter directly interacts with r.VolumetricFog.Jitter. They share the same value, with GVolumetricFogJitter being the actual integer variable used in the code logic.

Developers should be aware that this variable affects the quality and performance of volumetric fog rendering. When enabled (set to 1), it applies jitter to achieve temporal super sampling, which can improve visual quality but may have a performance cost.

Best practices when using this variable include:

  1. Consider the performance implications when enabling jitter, especially on lower-end hardware.
  2. Use in conjunction with other volumetric fog settings for optimal results.
  3. Test the visual impact and performance with different values in various scenarios.

Regarding the associated variable GVolumetricFogJitter:

The purpose of GVolumetricFogJitter is to serve as the internal representation of the r.VolumetricFog.Jitter setting within the engine’s C++ code.

It is used in the Renderer module, specifically in the volumetric fog rendering process. The variable is checked in several locations to determine whether to apply jitter to the fog computation.

The value of GVolumetricFogJitter is set by the console variable system when r.VolumetricFog.Jitter is modified.

GVolumetricFogJitter interacts with other variables and systems, such as GVolumetricFogTemporalReprojection and GLightScatteringSampleJitterMultiplier, to control the behavior of volumetric fog rendering.

Developers should be aware that modifying GVolumetricFogJitter directly in code is not recommended. Instead, they should use the r.VolumetricFog.Jitter console variable or project settings to control this feature.

Best practices for using GVolumetricFogJitter include:

  1. Treat it as a read-only variable in most cases, relying on the console variable system for modifications.
  2. Consider its impact on related systems, such as temporal reprojection and light scattering, when adjusting volumetric fog settings.
  3. Use it in conjunction with other volumetric fog parameters for fine-tuning rendering quality and performance.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:81

Scope: file

Source code excerpt:

int32 GVolumetricFogJitter = 1;
FAutoConsoleVariableRef CVarVolumetricFogJitter(
	TEXT("r.VolumetricFog.Jitter"),
	GVolumetricFogJitter,
	TEXT("Whether to apply jitter to each frame's volumetric fog computation, achieving temporal super sampling."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GVolumetricFogHistoryWeight = .9f;

#Associated Variable and Callsites

This variable is associated with another variable named GVolumetricFogJitter. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:79

Scope: file

Source code excerpt:

	);

int32 GVolumetricFogJitter = 1;
FAutoConsoleVariableRef CVarVolumetricFogJitter(
	TEXT("r.VolumetricFog.Jitter"),
	GVolumetricFogJitter,
	TEXT("Whether to apply jitter to each frame's volumetric fog computation, achieving temporal super sampling."),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GVolumetricFogHistoryWeight = .9f;
FAutoConsoleVariableRef CVarVolumetricFogHistoryWeight(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:184

Scope (from outer to inner):

file
function     FVector3f VolumetricFogTemporalRandom

Source code excerpt:

	FVector3f RandomOffsetValue(.5f, .5f, .5f);

	if (GVolumetricFogJitter && GVolumetricFogTemporalReprojection)
	{
		RandomOffsetValue = FVector3f(Halton(FrameNumber & 1023, 2), Halton(FrameNumber & 1023, 3), Halton(FrameNumber & 1023, 5));
	}

	return RandomOffsetValue;
}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:489

Scope (from outer to inner):

file
function     static void RenderRaytracedDirectionalShadowVolume

Source code excerpt:

		PassParameters->View = View.ViewUniformBuffer;
		PassParameters->Forward = View.ForwardLightingResources.ForwardLightUniformBuffer;
		PassParameters->LightScatteringSampleJitterMultiplier = GVolumetricFogJitter ? GLightScatteringSampleJitterMultiplier : 0;
		SetupVolumetricFogIntegrationParameters(PassParameters->VolumetricFogParameters, View, IntegrationData);

		TShaderRef<FRayTraceDirectionalLightVolumeShadowMapRGS> RayGenerationShader = View.ShaderMap->GetShader<FRayTraceDirectionalLightVolumeShadowMapRGS>();
		ClearUnusedGraphResources(RayGenerationShader, PassParameters);

		const uint32 DispatchSize = VolumetricFogResourceGridSize.X * VolumetricFogResourceGridSize.Y * VolumetricFogResourceGridSize.Z;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:1610

Scope (from outer to inner):

file
function     void FSceneRenderer::ComputeVolumetricFog

Source code excerpt:

			PassParameters->InverseSquaredLightDistanceBiasScale = GInverseSquaredLightDistanceBiasScale;
			PassParameters->UseDirectionalLightShadowing = bUseDirectionalLightShadowing ? 1.0f : 0.0f;
			PassParameters->LightScatteringSampleJitterMultiplier = GVolumetricFogJitter ? GLightScatteringSampleJitterMultiplier : 0;
			PassParameters->UseHeightFogColors = FVector2f(
				OverrideDirectionalLightInScatteringUsingHeightFog(View, FogInfo) ? 1.0f : 0.0f,
				OverrideSkyLightInScatteringUsingHeightFog(View, FogInfo) ? 1.0f : 0.0f);

			FMatrix44f CloudWorldToLightClipShadowMatrix = FMatrix44f::Identity;
			float CloudShadowmap_FarDepthKm = 0.0f;