r.ContactShadows
r.ContactShadows
#Overview
name: r.ContactShadows
The value of this variable can be defined or overridden in .ini config files. 8
.ini config files referencing this setting variable.
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0: disabled.\n 1: enabled.\n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ContactShadows is to control the rendering of contact shadows in Unreal Engine 5. Contact shadows are a visual effect that enhances the realism of object interactions by simulating small-scale shadowing where objects meet or are in close proximity.
This setting variable is primarily used by the rendering system, specifically in the context of lighting and shadow calculations. Based on the callsites, we can see that it’s utilized in the following Unreal Engine subsystems and modules:
- The core rendering module (Runtime/Renderer)
- The functional testing module (Developer/FunctionalTesting)
The value of this variable is set through the console variable system, as evident from its declaration using TAutoConsoleVariable. It’s initialized with a default value of 1, meaning contact shadows are enabled by default.
This variable interacts with other rendering-related variables, particularly those controlling various aspects of lighting and shadows. For example, it’s used alongside other console variables in the FAutomationTestScreenshotEnvSetup class, which suggests it’s part of a broader set of rendering configuration options.
Developers should be aware of the following when using this variable:
- It’s a binary switch (0 for disabled, 1 for enabled).
- It affects the visual quality and performance of the rendering pipeline.
- It’s marked with ECVF_Scalability and ECVF_RenderThreadSafe flags, indicating it can be adjusted for performance scaling and is safe to modify from the render thread.
Best practices when using this variable include:
- Consider the performance impact of enabling contact shadows, especially on lower-end hardware.
- Use it in conjunction with other shadow and lighting settings for a cohesive visual style.
- Test the visual impact and performance with and without contact shadows enabled to find the optimal setting for your project.
- Be aware that it can be overridden or disabled by other engine systems, such as the EngineShowFlags.
When modifying this setting, developers should ensure they’re balancing visual quality with performance requirements, especially in performance-critical scenarios or on platforms with limited resources.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:55, section: [ShadowQuality@0]
- INI Section:
ShadowQuality@0
- Raw value:
0
- Is Array:
False
Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:64, section: [ShadowQuality@1]
- INI Section:
ShadowQuality@1
- Raw value:
0
- Is Array:
False
Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:73, section: [ShadowQuality@2]
- INI Section:
ShadowQuality@2
- Raw value:
0
- Is Array:
False
Location: <Workspace>/Engine/Config/Android/AndroidScalability.ini:82, section: [ShadowQuality@3]
- INI Section:
ShadowQuality@3
- Raw value:
0
- Is Array:
False
Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:55, section: [ShadowQuality@0]
- INI Section:
ShadowQuality@0
- Raw value:
0
- Is Array:
False
Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:64, section: [ShadowQuality@1]
- INI Section:
ShadowQuality@1
- Raw value:
0
- Is Array:
False
Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:73, section: [ShadowQuality@2]
- INI Section:
ShadowQuality@2
- Raw value:
0
- Is Array:
False
Location: <Workspace>/Engine/Config/IOS/IOSScalability.ini:82, section: [ShadowQuality@3]
- INI Section:
ShadowQuality@3
- Raw value:
0
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:3736
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarContactShadows(
TEXT("r.ContactShadows"),
1,
TEXT(" 0: disabled.\n"
" 1: enabled.\n"),
ECVF_Scalability | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarContactShadowsNonShadowCastingIntensity(
#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Private/AutomationBlueprintFunctionLibrary.cpp:245
Scope (from outer to inner):
file
function FAutomationTestScreenshotEnvSetup::FAutomationTestScreenshotEnvSetup
Source code excerpt:
, ScreenSpaceReflectionQuality(TEXT("r.SSR.Quality"))
, EyeAdaptationQuality(TEXT("r.EyeAdaptationQuality"))
, ContactShadows(TEXT("r.ContactShadows"))
, TonemapperGamma(TEXT("r.TonemapperGamma"))
, TonemapperSharpen(TEXT("r.Tonemapper.Sharpen"))
, ScreenPercentage(TEXT("r.ScreenPercentage"))
, DynamicResTestScreenPercentage(TEXT("r.DynamicRes.TestScreenPercentage"))
, DynamicResOperationMode(TEXT("r.DynamicRes.OperationMode"))
, SecondaryScreenPercentage(TEXT("r.SecondaryScreenPercentage.GameViewport"))
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:601
Scope (from outer to inner):
file
function FDeferredLightUniformStruct GetDeferredLightParameters
Source code excerpt:
Out.VolumetricScatteringIntensity = LightSceneInfo.Proxy->GetVolumetricScatteringIntensity();
static auto* ContactShadowsCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.ContactShadows"));
Out.ContactShadowLength = 0;
Out.ContactShadowCastingIntensity = 1.0f;
Out.ContactShadowNonCastingIntensity = 0.0f;
if (ContactShadowsCVar && ContactShadowsCVar->GetValueOnRenderThread() != 0 && View.Family->EngineShowFlags.ContactShadows)
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Shadows/ScreenSpaceShadows.cpp:458
Scope (from outer to inner):
file
function void RenderScreenSpaceShadows
Source code excerpt:
FRDGTextureRef ScreenShadowMaskTexture)
{
static auto* ContactShadowsCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.ContactShadows"));
if (ContactShadowsCVar && ContactShadowsCVar->GetValueOnRenderThread() == 0)
{
return;
}