r.VolumetricFog.InverseSquaredLightDistanceBiasScale

r.VolumetricFog.InverseSquaredLightDistanceBiasScale

#Overview

name: r.VolumetricFog.InverseSquaredLightDistanceBiasScale

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.InverseSquaredLightDistanceBiasScale is to scale the amount added to the inverse squared falloff denominator in volumetric fog calculations. This setting is part of the rendering system, specifically the volumetric fog subsystem.

This setting variable is primarily used in the Renderer module of Unreal Engine 5, 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’s initialized with a default value of 1.0f but can be modified at runtime.

The associated variable GInverseSquaredLightDistanceBiasScale directly interacts with r.VolumetricFog.InverseSquaredLightDistanceBiasScale. They share the same value, with GInverseSquaredLightDistanceBiasScale being the C++ variable used in the actual rendering calculations.

Developers must be aware that this variable affects the visual quality of volumetric fog, particularly in how it handles light falloff. It’s designed to remove the spike from inverse squared falloff that causes extreme aliasing in volumetric fog rendering.

Best practices when using this variable include:

  1. Adjusting it carefully, as it can significantly impact the appearance of fog in scenes with strong lighting contrasts.
  2. Testing changes in various lighting conditions to ensure consistent visual quality.
  3. Considering performance implications, as it’s marked with ECVF_Scalability, indicating it may affect rendering performance.

Regarding the associated variable GInverseSquaredLightDistanceBiasScale:

The purpose of GInverseSquaredLightDistanceBiasScale is to store and provide the actual value used in volumetric fog calculations for scaling the inverse squared light distance bias.

This variable is used directly in the rendering calculations within the Volumetric Fog system. It’s referenced in the FVolumetricFogMaterialSetupCS class and the ComputeVolumetricFog function, which are key components of the volumetric fog rendering pipeline.

The value of GInverseSquaredLightDistanceBiasScale is set by the console variable system through r.VolumetricFog.InverseSquaredLightDistanceBiasScale.

As mentioned earlier, it directly interacts with r.VolumetricFog.InverseSquaredLightDistanceBiasScale, serving as the in-code representation of the console variable’s value.

Developers should be aware that changes to this variable will immediately affect volumetric fog calculations in the renderer. It’s used in shader parameter setup and fog computation, so modifications will have a direct impact on the visual output.

Best practices for using GInverseSquaredLightDistanceBiasScale include:

  1. Avoiding direct manipulation of this variable in code; instead, use the console variable for adjustments.
  2. Considering its impact when debugging or optimizing volumetric fog rendering.
  3. Being cautious of potential performance implications when modifying its value, as it affects per-frame rendering calculations.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

float GInverseSquaredLightDistanceBiasScale = 1.0f;
FAutoConsoleVariableRef CVarInverseSquaredLightDistanceBiasScale(
	TEXT("r.VolumetricFog.InverseSquaredLightDistanceBiasScale"),
	GInverseSquaredLightDistanceBiasScale,
	TEXT("Scales the amount added to the inverse squared falloff denominator.  This effectively removes the spike from inverse squared falloff that causes extreme aliasing."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GVolumetricFogEmissive = 1;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	);

float GInverseSquaredLightDistanceBiasScale = 1.0f;
FAutoConsoleVariableRef CVarInverseSquaredLightDistanceBiasScale(
	TEXT("r.VolumetricFog.InverseSquaredLightDistanceBiasScale"),
	GInverseSquaredLightDistanceBiasScale,
	TEXT("Scales the amount added to the inverse squared falloff denominator.  This effectively removes the spike from inverse squared falloff that causes extreme aliasing."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

int32 GVolumetricFogEmissive = 1;
FAutoConsoleVariableRef CVarVolumetricFogEmissive(

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

Scope (from outer to inner):

file
class        class FVolumetricFogMaterialSetupCS : public FGlobalShader

Source code excerpt:

	OutCommonParameters.ViewUniformBuffer = View.ViewUniformBuffer;
	OutCommonParameters.PhaseG = FogInfo.VolumetricFogScatteringDistribution;
	OutCommonParameters.InverseSquaredLightDistanceBiasScale = GInverseSquaredLightDistanceBiasScale;

	FDeferredLightUniformStruct* DeferredLightStruct = GraphBuilder.AllocParameters<FDeferredLightUniformStruct>();
	*DeferredLightStruct = GetDeferredLightParameters(View, *LightSceneInfo);
	OutCommonParameters.DeferredLight = GraphBuilder.CreateUniformBuffer(DeferredLightStruct);

	return true;

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

Scope (from outer to inner):

file
function     void FSceneRenderer::ComputeVolumetricFog

Source code excerpt:


			PassParameters->PhaseG = FogInfo.VolumetricFogScatteringDistribution;
			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);