r.ContactShadows.NonShadowCastingIntensity

r.ContactShadows.NonShadowCastingIntensity

#Overview

name: r.ContactShadows.NonShadowCastingIntensity

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.ContactShadows.NonShadowCastingIntensity is to control the intensity of contact shadows for non-shadow casting objects in the rendering system. However, it’s important to note that this variable is deprecated, and developers should now use the parameters on the Light Component directly instead.

This setting variable is primarily related to the Renderer module of Unreal Engine 5, specifically within the scene rendering subsystem. It’s referenced in the SceneRendering.cpp file, which is a core part of the rendering pipeline.

The value of this variable is set through the console variable system, as evidenced by the TAutoConsoleVariable declaration in ConsoleManager.cpp. It’s initialized with a default value of 0.0f.

While there are no direct interactions with other variables shown in the provided code, it’s used in conjunction with other rendering-related checks and settings, such as static lighting and mobile-specific rendering features.

Developers must be aware of several important points when dealing with this variable:

  1. It is deprecated, and its functionality has been moved to the Light Component.
  2. The variable is marked with ECVF_Scalability and ECVF_RenderThreadSafe flags, indicating it’s related to scalability settings and is safe to modify from the render thread.
  3. It’s checked in the rendering pipeline to display warnings if used, suggesting that it might still have some effect but is not the recommended way to control this feature.

Best practices when dealing with this variable include:

  1. Avoid using this console variable in new code or projects.
  2. Instead, use the equivalent settings directly on the Light Component for controlling contact shadow intensity for non-shadow casting objects.
  3. If encountering this variable in existing projects, consider refactoring to use the Light Component parameters instead.
  4. Be aware of potential performance implications when enabling or adjusting contact shadow settings, especially on mobile platforms.
  5. Always refer to the most up-to-date Unreal Engine documentation for current best practices in lighting and shadow rendering.

#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:3743

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarContactShadowsNonShadowCastingIntensity(
	TEXT("r.ContactShadows.NonShadowCastingIntensity"),
	0.0f,
	TEXT("DEPRECATED. Please use the parameters on the Light Component directly instead.\n"),
	ECVF_Scalability | ECVF_RenderThreadSafe);

// Changing this causes a full shader recompile
static TAutoConsoleVariable<int32> CVarAllowStaticLighting(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:3781

Scope (from outer to inner):

file
function     void FSceneRenderer::OnRenderFinish

Source code excerpt:

		}

		static const auto ContactShadowNonCastingIntensityCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.ContactShadows.NonShadowCastingIntensity"));
		const bool bContactShadowIntensityCvarUsed = ContactShadowNonCastingIntensityCVar && ContactShadowNonCastingIntensityCVar->GetFloat() != 0.0f;

		// Mobile-specific warnings
		const bool bMobile = (FeatureLevel <= ERHIFeatureLevel::ES3_1);
		const bool bShowMobileLowQualityLightmapWarning = bMobile && !FReadOnlyCVARCache::EnableLowQualityLightmaps() && IsStaticLightingAllowed();
		const bool bShowMobileDynamicCSMWarning = bMobile && Scene->NumMobileStaticAndCSMLights_RenderThread > 0 && !(FReadOnlyCVARCache::MobileEnableStaticAndCSMShadowReceivers() && FReadOnlyCVARCache::MobileAllowDistanceFieldShadows());

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:4011

Scope (from outer to inner):

file
lambda-function

Source code excerpt:

						if (bContactShadowIntensityCvarUsed)
						{
							static const FText Message = NSLOCTEXT("Renderer", "ContactShadowsIntensityCvar", "r.ContactShadows.NonShadowCastingIntensity is set but ignored. Use setting on the Light Component instead.");
							Writer.DrawLine(Message);
						}

						if (bLocalFogVolumeInSceneButProjectDisabled)
						{
							static const FText Message = NSLOCTEXT("Renderer", "LocalFogVolumeDisabled", "There are Local Fog Volumes in the scene, but your project does not support rendering them. This can be enabled from the project settings panel (r.SupportLocalFogVolumes).");