r.ContactShadows.OverrideNonShadowCastingIntensity

r.ContactShadows.OverrideNonShadowCastingIntensity

#Overview

name: r.ContactShadows.OverrideNonShadowCastingIntensity

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.OverrideNonShadowCastingIntensity is to allow overriding the contact shadow non-casting intensity for all directional lights in the rendering system. This setting variable is primarily used for debugging purposes in Unreal Engine’s rendering subsystem.

The Unreal Engine rendering module relies on this setting variable, as evident from its location in the LightRendering.cpp file within the Renderer source directory.

The value of this variable is set through the console variable system in Unreal Engine. It is initialized with a default value of -1.0f, which effectively disables the override functionality.

This variable interacts with the associated variable CVarContactShadowsOverrideNonShadowCastingIntensity, which is an instance of TAutoConsoleVariable. They share the same value and purpose.

Developers must be aware of the following when using this variable:

  1. The override is only active when the value is greater than or equal to 0.
  2. It affects all directional lights in the scene.
  3. It is primarily intended for debugging purposes and should generally be left disabled in production builds.

Best practices when using this variable include:

  1. Only enable it temporarily for debugging contact shadow issues.
  2. Reset the value to -1.0f (or lower) when debugging is complete to disable the override.
  3. Be cautious when using it in production environments, as it may impact performance or visual quality.

Regarding the associated variable CVarContactShadowsOverrideNonShadowCastingIntensity:

The purpose of CVarContactShadowsOverrideNonShadowCastingIntensity is to provide a programmatic interface for the r.ContactShadows.OverrideNonShadowCastingIntensity setting within the C++ code of the Unreal Engine.

This variable is used in the rendering subsystem, specifically in the light rendering module, to control the override of contact shadow non-casting intensity.

The value of this variable is set through the Unreal Engine’s console variable system, which allows for runtime modification of engine parameters.

It interacts directly with the r.ContactShadows.OverrideNonShadowCastingIntensity setting, effectively serving as its in-code representation.

Developers should be aware that:

  1. This variable is of type TAutoConsoleVariable, which means it can be modified at runtime.
  2. Its value is checked in the GetLightContactShadowParameters function to determine if the override should be applied.

Best practices for using this variable include:

  1. Accessing its value using the GetValueOnAnyThread() method when needed in rendering code.
  2. Avoiding direct modification of this variable outside of the console variable system to maintain consistency with the r.ContactShadows.OverrideNonShadowCastingIntensity setting.
  3. Using it judiciously and primarily for debugging purposes, as it affects all directional lights in the scene.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:169

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarContactShadowsOverrideNonShadowCastingIntensity(
	TEXT("r.ContactShadows.OverrideNonShadowCastingIntensity"),
	-1.0f,
	TEXT("Allows overriding the contact shadow non casting intensity for all directional lights.\n")
	TEXT("Disabled when < 0.\n")
	TEXT("Should generally be left disabled outside of debugging."),
	ECVF_RenderThreadSafe);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:168

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarContactShadowsOverrideNonShadowCastingIntensity(
	TEXT("r.ContactShadows.OverrideNonShadowCastingIntensity"),
	-1.0f,
	TEXT("Allows overriding the contact shadow non casting intensity for all directional lights.\n")
	TEXT("Disabled when < 0.\n")
	TEXT("Should generally be left disabled outside of debugging."),
	ECVF_RenderThreadSafe);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:253

Scope (from outer to inner):

file
function     void GetLightContactShadowParameters

Source code excerpt:

	}

	if (CVarContactShadowsOverrideNonShadowCastingIntensity.GetValueOnAnyThread() >= 0.0f)
	{
		OutNonCastingIntensity = CVarContactShadowsOverrideNonShadowCastingIntensity.GetValueOnAnyThread();
	}

	if (!bOutLengthInWS)
	{
		// Multiply by 2 for screen space in order to preserve old values after introducing multiply by View.ClipToView[1][1] in shader.
		OutLength *= 2.0f;