landscape.NonNaniteVirtualShadowMapInvalidationLODAttenuationExponent

landscape.NonNaniteVirtualShadowMapInvalidationLODAttenuationExponent

#Overview

name: landscape.NonNaniteVirtualShadowMapInvalidationLODAttenuationExponent

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of landscape.NonNaniteVirtualShadowMapInvalidationLODAttenuationExponent is to control the shape of the attenuation curve for virtual shadow map page invalidation rates in non-Nanite landscapes. This setting variable is part of the rendering system, specifically for landscape rendering and shadow mapping.

This variable is primarily used in the Landscape module of Unreal Engine, as evidenced by its location in the LandscapeRender.cpp file. It’s particularly relevant for the rendering thread and scalability settings, as indicated by the ECVF_RenderThreadSafe | ECVF_Scalability flags.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through the console. Its default value is 2.0f.

This variable interacts closely with its associated C++ variable GLandscapeNonNaniteVirtualShadowMapInvalidationLODAttenuationExponent. They share the same value, with the console variable acting as an interface for runtime modification.

Developers should be aware that this variable affects the performance and visual quality trade-off for non-Nanite landscapes. It determines how aggressively the engine invalidates virtual shadow map pages based on the Level of Detail (LOD) of the landscape. A higher value will result in a steeper attenuation curve, potentially reducing shadow map updates for distant or lower-detail areas of the landscape.

Best practices when using this variable include:

  1. Experimenting with different values to find the optimal balance between performance and visual quality for your specific landscape.
  2. Consider adjusting this value dynamically based on the scene complexity or performance requirements.
  3. Be cautious when modifying this value, as it can have a significant impact on both rendering performance and shadow quality.

Regarding the associated variable GLandscapeNonNaniteVirtualShadowMapInvalidationLODAttenuationExponent:

This is the actual C++ variable that stores the value of the console variable. It’s used directly in the rendering code, specifically in the FLandscapeComponentSceneProxy::ShouldInvalidateShadows function. This function determines whether shadows should be invalidated for a given landscape component based on the LOD and view parameters.

The variable is used in a power function (FMath::Pow) to calculate the attenuation factor for shadow invalidation. This allows for non-linear attenuation of shadow updates based on the landscape’s LOD, which can help optimize performance by reducing shadow updates for less visually important parts of the landscape.

Developers working directly with the C++ code should be aware of this variable when dealing with landscape rendering and shadow systems, especially if they’re optimizing or modifying the shadow invalidation logic for non-Nanite landscapes.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeRender.cpp:192

Scope: file

Source code excerpt:

float GLandscapeNonNaniteVirtualShadowMapInvalidationLODAttenuationExponent = 2.0f;
FAutoConsoleVariableRef CVarLandscapeNonNaniteVirtualShadowMapInvalidationLODAttenuationExponent(
	TEXT("landscape.NonNaniteVirtualShadowMapInvalidationLODAttenuationExponent"),
	GLandscapeNonNaniteVirtualShadowMapInvalidationLODAttenuationExponent,
	TEXT("For non-Nanite landscape, controls the shape of the curve of the attenuation of the virtual shadow map pages' invalidation rate (1 - X^N), where X is the relative LOD value (LODValue/NumMips in the [0,1] range) and N, the CVar"),
	ECVF_RenderThreadSafe | ECVF_Scalability
);

#if WITH_EDITOR

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeRender.cpp:190

Scope: file

Source code excerpt:

);

float GLandscapeNonNaniteVirtualShadowMapInvalidationLODAttenuationExponent = 2.0f;
FAutoConsoleVariableRef CVarLandscapeNonNaniteVirtualShadowMapInvalidationLODAttenuationExponent(
	TEXT("landscape.NonNaniteVirtualShadowMapInvalidationLODAttenuationExponent"),
	GLandscapeNonNaniteVirtualShadowMapInvalidationLODAttenuationExponent,
	TEXT("For non-Nanite landscape, controls the shape of the curve of the attenuation of the virtual shadow map pages' invalidation rate (1 - X^N), where X is the relative LOD value (LODValue/NumMips in the [0,1] range) and N, the CVar"),
	ECVF_RenderThreadSafe | ECVF_Scalability
);

#if WITH_EDITOR
extern TAutoConsoleVariable<int32> CVarLandscapeShowDirty;

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeRender.cpp:4562

Scope (from outer to inner):

file
function     bool FLandscapeComponentSceneProxy::ShouldInvalidateShadows

Source code excerpt:

		MaxDeltaLODAttenuationFactor = FMath::Clamp(1.0f - (SourceLODValue / LODSettings.VirtualShadowMapInvalidationLimitLOD), 0.0f, 1.0f);
		// Now that we're in the [0,1] range, apply an exponent to have a non-linear attenuation : 
		MaxDeltaLODAttenuationFactor = FMath::Pow(MaxDeltaLODAttenuationFactor, GLandscapeNonNaniteVirtualShadowMapInvalidationLODAttenuationExponent);
	}

	const double AttenuatedMaxDelta = MaxDelta * MaxDeltaLODAttenuationFactor;

	bool bShouldInvalidateShadow = (AttenuatedMaxDelta > VirtualShadowMapInvalidationHeightErrorThreshold);