r.Shadow.RadiusThreshold

r.Shadow.RadiusThreshold

#Overview

name: r.Shadow.RadiusThreshold

The value of this variable can be defined or overridden in .ini config files. 13 .ini config files referencing this setting variable.

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 r.Shadow.RadiusThreshold is to control the culling of shadow casters in the rendering system based on their screen space size. This setting is part of Unreal Engine’s shadow rendering optimization system.

The Unreal Engine subsystem that primarily relies on this setting variable is the Renderer module, specifically the shadow rendering component. It’s also utilized in the MovieRenderPipelineCore plugin for high-quality offline rendering.

The value of this variable is set through the console variable system. It’s defined as an FAutoConsoleVariableRef in the Renderer module, which allows it to be modified at runtime through console commands or configuration files.

This variable interacts with other shadow-related variables, such as r.Shadow.DistanceScale and r.ShadowQuality. Together, these variables control various aspects of shadow rendering quality and performance.

Developers must be aware that this variable affects performance and visual quality. A lower value will allow smaller objects to cast shadows, potentially increasing visual fidelity but at the cost of performance. A higher value will cull more shadow casters, improving performance but potentially reducing shadow detail for small objects.

Best practices when using this variable include:

  1. Balancing it with other shadow-related settings for optimal performance and visual quality.
  2. Testing different values in various scenarios to find the right balance for your specific game or application.
  3. Consider exposing this setting to end-users as a scalability option, allowing them to adjust shadow detail based on their hardware capabilities.
  4. When using the MovieRenderPipeline for high-quality offline rendering, you may want to set this to a lower value to capture more shadow detail.
  5. Monitor performance impact when adjusting this value, especially in scenes with many small objects.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseScalability.ini:133, section: [ShadowQuality@0]

Location: <Workspace>/Engine/Config/BaseScalability.ini:157, section: [ShadowQuality@1]

Location: <Workspace>/Engine/Config/BaseScalability.ini:181, section: [ShadowQuality@2]

Location: <Workspace>/Engine/Config/BaseScalability.ini:208, section: [ShadowQuality@3]

Location: <Workspace>/Engine/Config/BaseScalability.ini:235, section: [ShadowQuality@Cine]

Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:53, section: [ShadowQuality@0]

Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:62, section: [ShadowQuality@1]

Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:71, section: [ShadowQuality@2]

Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:80, section: [ShadowQuality@3]

Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:53, section: [ShadowQuality@0]

Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:62, section: [ShadowQuality@1]

Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:71, section: [ShadowQuality@2]

Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:80, section: [ShadowQuality@3]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowSetup.cpp:52

Scope: file

Source code excerpt:

static float GMinScreenRadiusForShadowCaster = 0.01f;
static FAutoConsoleVariableRef CVarMinScreenRadiusForShadowCaster(
	TEXT("r.Shadow.RadiusThreshold"),
	GMinScreenRadiusForShadowCaster,
	TEXT("Cull shadow casters if they are too small, value is the minimal screen space bounding sphere radius"),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

extern int GEnableNonNaniteVSM;

#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineCore/Private/MoviePipelineGameOverrideSetting.cpp:84

Scope (from outer to inner):

file
function     void UMoviePipelineGameOverrideSetting::ApplyCVarSettings

Source code excerpt:

		MOVIEPIPELINE_STORE_AND_OVERRIDE_CVAR_INT(PreviousShadowDistanceScale, TEXT("r.Shadow.DistanceScale"), ShadowDistanceScale, bOverrideValues);
		MOVIEPIPELINE_STORE_AND_OVERRIDE_CVAR_INT(PreviousShadowQuality, TEXT("r.ShadowQuality"), 5, bOverrideValues);
		MOVIEPIPELINE_STORE_AND_OVERRIDE_CVAR_FLOAT(PreviousShadowRadiusThreshold, TEXT("r.Shadow.RadiusThreshold"), ShadowRadiusThreshold, bOverrideValues);
	}

	if (bOverrideViewDistanceScale)
	{
		MOVIEPIPELINE_STORE_AND_OVERRIDE_CVAR_INT(PreviousViewDistanceScale, TEXT("r.ViewDistanceScale"), ViewDistanceScale, bOverrideValues);
	}

#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineCore/Private/MoviePipelineGameOverrideSetting.cpp:206

Scope (from outer to inner):

file
function     void UMoviePipelineGameOverrideSetting::BuildNewProcessCommandLineArgsImpl

Source code excerpt:

	{
		InOutDeviceProfileCvars.Add(FString::Printf(TEXT("r.Shadow.DistanceScale=%d"), ShadowDistanceScale));
		InOutDeviceProfileCvars.Add(FString::Printf(TEXT("r.Shadow.RadiusThreshold=%f"), ShadowRadiusThreshold));
		InOutDeviceProfileCvars.Add(TEXT("r.ShadowQuality=5"));
	}

	if (bOverrideViewDistanceScale)
	{
		InOutDeviceProfileCvars.Add(FString::Printf(TEXT("r.ViewDistanceScale=%d"), ViewDistanceScale));