r.CapsuleSkyAngleScale

r.CapsuleSkyAngleScale

#Overview

name: r.CapsuleSkyAngleScale

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.CapsuleSkyAngleScale is to scale the light source angle derived from the precomputed unoccluded sky vector when a stationary skylight is present in the scene. This setting variable is primarily used in the rendering system, specifically for capsule shadow rendering.

This setting variable is utilized by the Renderer module of Unreal Engine, particularly in the capsule shadow rendering subsystem. It’s referenced in the CapsuleShadowRendering.cpp file, which is part of the runtime renderer.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands. The initial value is set to 0.6f.

The r.CapsuleSkyAngleScale variable interacts directly with the GCapsuleSkyAngleScale variable. They share the same value, with GCapsuleSkyAngleScale being the actual float variable used in the code, while r.CapsuleSkyAngleScale is the console variable name used for runtime modification.

Developers should be aware that this variable affects the calculation of the cone angle for indirect capsule shadows when a stationary skylight is present. It’s used in conjunction with GCapsuleMinSkyAngle to determine the final cone angle.

Best practices when using this variable include:

  1. Understanding its impact on the visual quality and performance of capsule shadows.
  2. Adjusting it carefully in conjunction with other related variables like GCapsuleMinSkyAngle.
  3. Testing different values in various lighting scenarios to find the optimal balance between visual quality and performance.

Regarding the associated variable GCapsuleSkyAngleScale:

The purpose of GCapsuleSkyAngleScale is to store the actual float value used in the capsule shadow rendering calculations. It’s the C++ variable that directly corresponds to the r.CapsuleSkyAngleScale console variable.

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

The value of GCapsuleSkyAngleScale is set initially to 0.6f and can be modified at runtime through the r.CapsuleSkyAngleScale console variable.

GCapsuleSkyAngleScale interacts with other variables in the capsule shadow rendering system, such as GCapsuleMinSkyAngle and GCapsuleIndirectConeAngle.

Developers should be aware that modifying GCapsuleSkyAngleScale directly in the code will not reflect runtime changes made through the console variable. Always use the console variable for runtime modifications.

Best practices for using GCapsuleSkyAngleScale include:

  1. Avoiding direct modification of the variable in code unless absolutely necessary.
  2. Using the r.CapsuleSkyAngleScale console variable for runtime adjustments and testing.
  3. Considering its impact on both visual quality and performance when adjusting its value.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:98

Scope: file

Source code excerpt:

float GCapsuleSkyAngleScale = .6f;
FAutoConsoleVariableRef CVarCapsuleSkyAngleScale(
	TEXT("r.CapsuleSkyAngleScale"),
	GCapsuleSkyAngleScale,
	TEXT("Scales the light source angle derived from the precomputed unoccluded sky vector (stationary skylight present)"),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GCapsuleMinSkyAngle = 15;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:96

Scope: file

Source code excerpt:

	);

float GCapsuleSkyAngleScale = .6f;
FAutoConsoleVariableRef CVarCapsuleSkyAngleScale(
	TEXT("r.CapsuleSkyAngleScale"),
	GCapsuleSkyAngleScale,
	TEXT("Scales the light source angle derived from the precomputed unoccluded sky vector (stationary skylight present)"),
	ECVF_Scalability | ECVF_RenderThreadSafe
	);

float GCapsuleMinSkyAngle = 15;
FAutoConsoleVariableRef CVarCapsuleMinSkyAngle(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:791

Scope (from outer to inner):

file
function     static IndirectCapsuleShadowsResources CreateIndirectCapsuleShadowsResources

Source code excerpt:

			// Stationary sky light case
			// Get the indirect shadow direction from the unoccluded sky direction
			const float ConeAngle = FMath::Max(Allocation->CurrentSkyBentNormal.W * GCapsuleSkyAngleScale * .5f * PI, GCapsuleMinSkyAngle * PI / 180.0f);
			PackedLightDirection = FVector4f(FVector3f(Allocation->CurrentSkyBentNormal), ConeAngle);
		}
		else if (SkyLight 
			&& !SkyLight->bHasStaticLighting 
			&& !SkyLight->bWantsStaticShadowing
			&& View.Family->EngineShowFlags.SkyLighting)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:928

Scope (from outer to inner):

file
function     static IndirectCapsuleShadowsResources CreateIndirectCapsuleShadowsResources

Source code excerpt:

			PassParameters->SkyLightMode = SkyLightMode;
			PassParameters->CapsuleIndirectConeAngle = GCapsuleIndirectConeAngle;
			PassParameters->CapsuleSkyAngleScale = GCapsuleSkyAngleScale;
			PassParameters->CapsuleMinSkyAngle = GCapsuleMinSkyAngle;
			PassParameters->RWComputedLightDirectionData = ComputedLightDirectionUAV;
			PassParameters->LightDirectionData = IndirectShadowLightDirectionSRV;

			FComputeShaderUtils::AddPass(
				GraphBuilder,