r.VolumetricFog.InjectRaytracedLights

r.VolumetricFog.InjectRaytracedLights

#Overview

name: r.VolumetricFog.InjectRaytracedLights

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.InjectRaytracedLights is to control whether lights with ray-traced shadows are injected into volumetric fog in Unreal Engine 5’s rendering system.

This setting variable is primarily used by the volumetric fog rendering subsystem within Unreal Engine’s renderer module. It directly affects how ray-traced shadows interact with volumetric fog in the scene.

The value of this variable is set through the Unreal Engine console variable system. It’s defined as an integer with an initial value of 0, which means it’s disabled by default. Developers can enable it by setting it to 1 through console commands or project settings.

The associated variable GVolumetricFogInjectRaytracedLights directly interacts with r.VolumetricFog.InjectRaytracedLights. They share the same value and purpose within the engine.

Developers must be aware of several things when using this variable:

  1. It only affects scenes with ray-traced lights and volumetric fog.
  2. It requires hardware support for ray tracing (GRHISupportsRayTracing and GRHISupportsRayTracingShaders must be true).
  3. Enabling this feature may have performance implications, especially in complex scenes with many lights.

Best practices when using this variable include:

  1. Only enable it when necessary, as it can impact performance.
  2. Test thoroughly on target hardware to ensure acceptable performance.
  3. Consider using it in conjunction with other volumetric fog and ray tracing settings for optimal visual quality and performance.

Regarding the associated variable GVolumetricFogInjectRaytracedLights:

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

int GVolumetricFogInjectRaytracedLights = 0;
FAutoConsoleVariableRef CVarVolumetricInjectRaytracedLights(
	TEXT("r.VolumetricFog.InjectRaytracedLights"),
	GVolumetricFogInjectRaytracedLights,
	TEXT("Whether lights with ray traced shadows are injected into volumetric fog"),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GLightScatteringSampleJitterMultiplier = 0;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

int GVolumetricFogInjectRaytracedLights = 0;
FAutoConsoleVariableRef CVarVolumetricInjectRaytracedLights(
	TEXT("r.VolumetricFog.InjectRaytracedLights"),
	GVolumetricFogInjectRaytracedLights,
	TEXT("Whether lights with ray traced shadows are injected into volumetric fog"),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GLightScatteringSampleJitterMultiplier = 0;
FAutoConsoleVariableRef CVarLightScatteringSampleJitterMultiplier(

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

Scope (from outer to inner):

file
function     static void RenderRaytracedDirectionalShadowVolume

Source code excerpt:

		&& GRHISupportsRayTracing
		&& GRHISupportsRayTracingShaders
		&& GVolumetricFogInjectRaytracedLights;

	if (!bUseRaytracedShadows)
	{
		return;
	}

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

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::PrepareRayTracingVolumetricFogShadows

Source code excerpt:

void FDeferredShadingSceneRenderer::PrepareRayTracingVolumetricFogShadows(const FViewInfo& View, const FScene& Scene, TArray<FRHIRayTracingShader*>& OutRayGenShaders)
{
	const bool bEnabled = Scene.bHasRayTracedLights && ::ShouldRenderVolumetricFog(&Scene, *View.Family) && GVolumetricFogInjectRaytracedLights;
	if (!bEnabled)
	{
		return;
	}

	for (int32 TemporalReprojection = 0; TemporalReprojection < 2; ++TemporalReprojection)

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

Scope (from outer to inner):

file
function     bool LightHasRayTracedShadows

Source code excerpt:

bool LightHasRayTracedShadows(const FLightSceneInfo* LightSceneInfo)
{
	return ShouldRenderRayTracingShadowsForLight(*LightSceneInfo->Proxy) && GVolumetricFogInjectRaytracedLights;
}

bool LightNeedsSeparateInjectionIntoVolumetricFogForOpaqueShadow(const FViewInfo& View, const FLightSceneInfo* LightSceneInfo, const FVisibleLightInfo& VisibleLightInfo)
{
	const FLightSceneProxy* LightProxy = LightSceneInfo->Proxy;