r.ContactShadows.OverrideLengthInWS

r.ContactShadows.OverrideLengthInWS

#Overview

name: r.ContactShadows.OverrideLengthInWS

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.OverrideLengthInWS is to determine whether the contact shadow length override is specified in world space units or screen space units. This setting variable is part of the rendering system, specifically related to contact shadows.

This setting variable is primarily used in the Renderer module of Unreal Engine, as evidenced by its location in the LightRendering.cpp file. It’s closely tied to the contact shadows rendering functionality.

The value of this variable is set through a console variable (CVarContactShadowsOverrideLengthInWS) with a default value of false. This means by default, the contact shadow length override is specified in screen space units.

This variable interacts closely with r.ContactShadows.OverrideLength. While r.ContactShadows.OverrideLength specifies the actual length value, r.ContactShadows.OverrideLengthInWS determines how that length value should be interpreted (world space or screen space).

Developers must be aware that changing this variable will affect how the r.ContactShadows.OverrideLength value is interpreted. If set to true, the length will be in world space units, which might require different values compared to screen space units.

Best practices when using this variable include:

  1. Coordinate its use with r.ContactShadows.OverrideLength for consistent results.
  2. Consider the implications on performance and visual quality when switching between world space and screen space units.
  3. Test thoroughly in different scenarios to ensure desired contact shadow behavior.

Regarding the associated variable CVarContactShadowsOverrideLengthInWS:

The purpose of CVarContactShadowsOverrideLengthInWS is to implement the r.ContactShadows.OverrideLengthInWS setting as a console variable in the engine’s C++ code.

This variable is used in the Renderer module, specifically in the light rendering system. It’s defined and used in the LightRendering.cpp file.

The value of this variable is set when the r.ContactShadows.OverrideLengthInWS console command is used. Its default value is false.

It interacts directly with the GetLightContactShadowParameters function, where its value is retrieved to determine how to interpret the contact shadow length.

Developers should be aware that this is the actual C++ variable that controls the behavior specified by r.ContactShadows.OverrideLengthInWS. Changes to this variable will immediately affect the contact shadow rendering.

Best practices for this variable include:

  1. Use the console command to modify it rather than changing the code directly.
  2. Be cautious when reading its value, as it’s accessed using GetValueOnAnyThread(), which suggests it could be accessed from multiple threads.
  3. Consider the performance implications of frequently querying this value in performance-critical code paths.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarContactShadowsOverrideLengthInWS(
	TEXT("r.ContactShadows.OverrideLengthInWS"),
	false,
	TEXT("Whether r.ContactShadows.OverrideLength is in world space units or in screen space units."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarContactShadowsOverrideShadowCastingIntensity(
	TEXT("r.ContactShadows.OverrideShadowCastingIntensity"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<bool> CVarContactShadowsOverrideLengthInWS(
	TEXT("r.ContactShadows.OverrideLengthInWS"),
	false,
	TEXT("Whether r.ContactShadows.OverrideLength is in world space units or in screen space units."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarContactShadowsOverrideShadowCastingIntensity(

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

Scope (from outer to inner):

file
function     void GetLightContactShadowParameters

Source code excerpt:

	{
		OutLength = CVarContactShadowsOverrideLength.GetValueOnAnyThread();
		bOutLengthInWS = CVarContactShadowsOverrideLengthInWS.GetValueOnAnyThread();
	}

	if (CVarContactShadowsOverrideShadowCastingIntensity.GetValueOnAnyThread() >= 0.0f)
	{
		OutCastingIntensity = CVarContactShadowsOverrideShadowCastingIntensity.GetValueOnAnyThread();
	}