r.CapsuleIndirectConeAngle
r.CapsuleIndirectConeAngle
#Overview
name: r.CapsuleIndirectConeAngle
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Light source angle used when the indirect shadow direction is derived from precomputed indirect lighting (no stationary skylight present)
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.CapsuleIndirectConeAngle is to define the light source angle used when the indirect shadow direction is derived from precomputed indirect lighting, specifically when there is no stationary skylight present. This setting variable is primarily used in the rendering system, particularly for capsule shadow rendering.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the capsule shadow rendering component. This can be seen from the file path where the variable is referenced: Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp
.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands. The default value is set to PI / 8 (approximately 0.3927 radians or 22.5 degrees).
This variable interacts closely with its associated variable GCapsuleIndirectConeAngle. They share the same value, and GCapsuleIndirectConeAngle is used directly in the code to set the light direction for indirect shadows.
Developers must be aware that this variable affects the quality and performance of indirect shadows, particularly in scenes without a stationary skylight. Adjusting this value can impact the appearance of shadows and the overall lighting quality in the scene.
Best practices when using this variable include:
- Fine-tuning the value to achieve the desired balance between shadow quality and performance.
- Testing the variable’s impact in various lighting scenarios, especially in scenes without stationary skylights.
- Considering the interaction with other lighting and shadow-related settings.
Regarding the associated variable GCapsuleIndirectConeAngle:
The purpose of GCapsuleIndirectConeAngle is to store the actual value used in the rendering calculations for the indirect shadow cone angle. It’s a global variable that directly affects the capsule shadow rendering process.
This variable is used in several places within the CapsuleShadowRendering.cpp file, particularly in the CreateIndirectCapsuleShadowsResources function. It’s used to set the w-component of the PackedLightDirection vector, which represents the cone angle for indirect shadows.
The value of GCapsuleIndirectConeAngle is set by the r.CapsuleIndirectConeAngle console variable, allowing for runtime adjustments.
Developers should be aware that changes to r.CapsuleIndirectConeAngle will directly affect GCapsuleIndirectConeAngle, and thus the rendering of capsule shadows. This variable is crucial for determining the spread of indirect shadows, especially in scenes without a stationary skylight.
Best practices for GCapsuleIndirectConeAngle include:
- Monitoring its value when debugging shadow-related issues.
- Understanding its impact on shadow quality and performance when adjusting r.CapsuleIndirectConeAngle.
- Considering its interaction with other shadow-related variables in the rendering pipeline.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:90
Scope: file
Source code excerpt:
float GCapsuleIndirectConeAngle = PI / 8;
FAutoConsoleVariableRef CVarCapsuleIndirectConeAngle(
TEXT("r.CapsuleIndirectConeAngle"),
GCapsuleIndirectConeAngle,
TEXT("Light source angle used when the indirect shadow direction is derived from precomputed indirect lighting (no stationary skylight present)"),
ECVF_Scalability | ECVF_RenderThreadSafe
);
float GCapsuleSkyAngleScale = .6f;
#Associated Variable and Callsites
This variable is associated with another variable named GCapsuleIndirectConeAngle
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:88
Scope: file
Source code excerpt:
);
float GCapsuleIndirectConeAngle = PI / 8;
FAutoConsoleVariableRef CVarCapsuleIndirectConeAngle(
TEXT("r.CapsuleIndirectConeAngle"),
GCapsuleIndirectConeAngle,
TEXT("Light source angle used when the indirect shadow direction is derived from precomputed indirect lighting (no stationary skylight present)"),
ECVF_Scalability | ECVF_RenderThreadSafe
);
float GCapsuleSkyAngleScale = .6f;
FAutoConsoleVariableRef CVarCapsuleSkyAngleScale(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:804
Scope (from outer to inner):
file
function static IndirectCapsuleShadowsResources CreateIndirectCapsuleShadowsResources
Source code excerpt:
// Get the indirect shadow direction from the primary sky lighting direction
PackedLightDirection = FVector4f((FVector3f)ExtractedMaxDirection, GCapsuleIndirectConeAngle);
}
else if (Allocation)
{
// Static sky light or no sky light case
FSHVectorRGB2 IndirectLighting;
IndirectLighting.R = FSHVector2(Allocation->SingleSamplePacked0[0]);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:817
Scope (from outer to inner):
file
function static IndirectCapsuleShadowsResources CreateIndirectCapsuleShadowsResources
Source code excerpt:
// Get the indirect shadow direction from the primary indirect lighting direction
PackedLightDirection = FVector4f((FVector3f)ExtractedMaxDirection, GCapsuleIndirectConeAngle);
}
if (CosFadeStartAngle < 1 && !bComputeLightDataFromVolumetricLightmapOrGpuSkyEnvMapIrradiance)
{
// Fade out when nearly vertical up due to self shadowing artifacts
ShapeFadeAlpha = 1 - FMath::Clamp(2 * (-PackedLightDirection.Z - CosFadeStartAngle) / (1 - CosFadeStartAngle), 0.0f, 1.0f);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:927
Scope (from outer to inner):
file
function static IndirectCapsuleShadowsResources CreateIndirectCapsuleShadowsResources
Source code excerpt:
PassParameters->NumLightDirectionData = NumLightDataElements;
PassParameters->SkyLightMode = SkyLightMode;
PassParameters->CapsuleIndirectConeAngle = GCapsuleIndirectConeAngle;
PassParameters->CapsuleSkyAngleScale = GCapsuleSkyAngleScale;
PassParameters->CapsuleMinSkyAngle = GCapsuleMinSkyAngle;
PassParameters->RWComputedLightDirectionData = ComputedLightDirectionUAV;
PassParameters->LightDirectionData = IndirectShadowLightDirectionSRV;
FComputeShaderUtils::AddPass(