r.VolumetricFog.LightScatteringSampleJitterMultiplier

r.VolumetricFog.LightScatteringSampleJitterMultiplier

#Overview

name: r.VolumetricFog.LightScatteringSampleJitterMultiplier

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.VolumetricFog.LightScatteringSampleJitterMultiplier is to control the amount of jittering applied to world sample positions when generating the 3D fog volume in Unreal Engine’s volumetric fog system. This setting is part of the rendering system, specifically the volumetric fog rendering subsystem.

This setting variable is primarily used in the Renderer module of Unreal Engine, as evidenced by its references in the VolumetricFog.cpp file.

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 configuration files.

The associated variable GLightScatteringSampleJitterMultiplier interacts directly with r.VolumetricFog.LightScatteringSampleJitterMultiplier. They share the same value, with GLightScatteringSampleJitterMultiplier being the C++ variable that stores the actual value used in the rendering code.

Developers must be aware that this variable is only effective when volumetric fog jittering is enabled. The code checks for GVolumetricFogJitter before applying the jitter multiplier. Additionally, this setting is marked as render thread safe and scalable, meaning it can be adjusted for different performance levels.

Best practices when using this variable include:

  1. Only modify it when fine-tuning the appearance of volumetric fog.
  2. Use in conjunction with r.VolumetricFog.Jitter to enable/disable the jittering effect.
  3. Be cautious with high values as they may introduce visible artifacts.
  4. Test the impact on performance, especially on lower-end hardware.

Regarding the associated variable GLightScatteringSampleJitterMultiplier:

The purpose of GLightScatteringSampleJitterMultiplier is to store the actual jitter multiplier value used in the volumetric fog rendering calculations. It directly corresponds to the console variable r.VolumetricFog.LightScatteringSampleJitterMultiplier.

This variable is used in the Renderer module, specifically in the volumetric fog rendering code.

Its value is set by the console variable system when r.VolumetricFog.LightScatteringSampleJitterMultiplier is modified.

It interacts with GVolumetricFogJitter, which determines whether jittering is applied at all.

Developers should be aware that this variable is used directly in shader parameters and rendering calculations. Changes to this value will immediately affect the appearance of volumetric fog in the scene.

Best practices for using GLightScatteringSampleJitterMultiplier include:

  1. Avoid modifying it directly in C++ code; instead, use the console variable to ensure consistency.
  2. Consider the performance implications when adjusting this value, especially in performance-critical scenarios.
  3. Use it in conjunction with other volumetric fog settings for optimal visual results.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

float GLightScatteringSampleJitterMultiplier = 0;
FAutoConsoleVariableRef CVarLightScatteringSampleJitterMultiplier(
	TEXT("r.VolumetricFog.LightScatteringSampleJitterMultiplier"),
	GLightScatteringSampleJitterMultiplier,
	TEXT("Multiplier for random offset value used to jitter each world sample position when generating the 3D fog volume. Enable/disable with r.VolumetricFog.Jitter"),
	ECVF_RenderThreadSafe | ECVF_Scalability
);

static int32 GetVolumetricFogGridPixelSize()

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

float GLightScatteringSampleJitterMultiplier = 0;
FAutoConsoleVariableRef CVarLightScatteringSampleJitterMultiplier(
	TEXT("r.VolumetricFog.LightScatteringSampleJitterMultiplier"),
	GLightScatteringSampleJitterMultiplier,
	TEXT("Multiplier for random offset value used to jitter each world sample position when generating the 3D fog volume. Enable/disable with r.VolumetricFog.Jitter"),
	ECVF_RenderThreadSafe | ECVF_Scalability
);

static int32 GetVolumetricFogGridPixelSize()
{

#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;