r.CapsuleShadowsFullResolution
r.CapsuleShadowsFullResolution
#Overview
name: r.CapsuleShadowsFullResolution
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to compute capsule shadows at full resolution.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.CapsuleShadowsFullResolution is to control whether capsule shadows are computed at full resolution in Unreal Engine 5’s rendering system.
-
This setting variable is primarily used in the rendering system, specifically for capsule shadow rendering.
-
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, as evidenced by its usage in the CapsuleShadowRendering.cpp file.
-
The value of this variable is set through the console variable system. It’s defined as an FAutoConsoleVariableRef, which allows it to be changed at runtime through console commands or configuration files.
-
The variable interacts directly with its associated C++ variable GCapsuleShadowsFullResolution. They share the same value, with the console variable providing an interface to modify the C++ variable.
-
Developers must be aware that this variable affects the resolution at which capsule shadows are computed. When set to 1 (true), shadows are computed at full resolution, which may impact performance but provide higher quality shadows.
-
Best practices when using this variable include:
- Consider the performance implications of enabling full resolution capsule shadows, especially on lower-end hardware.
- Use this setting in conjunction with other shadow quality settings for optimal balance between visual quality and performance.
- Test thoroughly with both values (0 and 1) to ensure your game performs well in both scenarios.
Regarding the associated variable GCapsuleShadowsFullResolution:
-
Its purpose is to store the actual boolean value determining whether capsule shadows should be computed at full resolution.
-
It’s used directly in the rendering code to determine the downsampling factor for capsule shadows and to set shader permutations.
-
The value is set by the console variable system when r.CapsuleShadowsFullResolution is modified.
-
It interacts with other parts of the rendering system, particularly in the GetCapsuleShadowDownsampleFactor() function and in shader permutation setup.
-
Developers should be aware that this variable is used in performance-critical rendering code, so frequent changes to its value during runtime might have implications on frame rate stability.
-
Best practices include ensuring that any code that depends on this variable can handle runtime changes smoothly, and considering caching its value locally in performance-critical loops rather than accessing it repeatedly.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:58
Scope: file
Source code excerpt:
int32 GCapsuleShadowsFullResolution = 0;
FAutoConsoleVariableRef CVarCapsuleShadowsFullResolution(
TEXT("r.CapsuleShadowsFullResolution"),
GCapsuleShadowsFullResolution,
TEXT("Whether to compute capsule shadows at full resolution."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
float GCapsuleMaxDirectOcclusionDistance = 400;
#Associated Variable and Callsites
This variable is associated with another variable named GCapsuleShadowsFullResolution
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:56
Scope: file
Source code excerpt:
);
int32 GCapsuleShadowsFullResolution = 0;
FAutoConsoleVariableRef CVarCapsuleShadowsFullResolution(
TEXT("r.CapsuleShadowsFullResolution"),
GCapsuleShadowsFullResolution,
TEXT("Whether to compute capsule shadows at full resolution."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
float GCapsuleMaxDirectOcclusionDistance = 400;
FAutoConsoleVariableRef CVarCapsuleMaxDirectOcclusionDistance(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:150
Scope (from outer to inner):
file
function int32 GetCapsuleShadowDownsampleFactor
Source code excerpt:
int32 GetCapsuleShadowDownsampleFactor()
{
return GCapsuleShadowsFullResolution ? 1 : 2;
}
FIntPoint GetBufferSizeForCapsuleShadows(const FViewInfo& View)
{
return FIntPoint::DivideAndRoundDown(View.GetSceneTexturesConfig().Extent, GetCapsuleShadowDownsampleFactor());
}
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:610
Scope (from outer to inner):
file
function bool FDeferredShadingSceneRenderer::RenderCapsuleDirectShadows
Source code excerpt:
FCapsuleShadowingUpsamplePS::FPermutationDomain PermutationVector;
PermutationVector.Set<FCapsuleShadowingUpsamplePS::FUpsampleRequired>(!GCapsuleShadowsFullResolution);
PermutationVector.Set<FCapsuleShadowingUpsamplePS::FApplySSAO>(false);
auto PixelShader = View.ShaderMap->GetShader<FCapsuleShadowingUpsamplePS>(PermutationVector);
FUpsampleCapsuleShadowParameters* PassParameters = GraphBuilder.AllocParameters<FUpsampleCapsuleShadowParameters>();
PassParameters->RenderTargets[0] = FRenderTargetBinding(ScreenShadowMaskTexture, ERenderTargetLoadAction::ELoad);
PassParameters->SceneTextures = SceneTexturesUniformBuffer;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/CapsuleShadowRendering.cpp:1093
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderIndirectCapsuleShadows
Source code excerpt:
FCapsuleShadowingUpsamplePS::FPermutationDomain PermutationVector;
PermutationVector.Set<FCapsuleShadowingUpsamplePS::FUpsampleRequired>(!GCapsuleShadowsFullResolution);
PermutationVector.Set<FCapsuleShadowingUpsamplePS::FApplySSAO>(RenderTargetCount > 1);
auto PixelShader = View.ShaderMap->GetShader<FCapsuleShadowingUpsamplePS>(PermutationVector);
FUpsampleCapsuleShadowParameters* PassParameters = GraphBuilder.AllocParameters<FUpsampleCapsuleShadowParameters>();
for (int32 Index = 0; Index < RenderTargetCount; ++Index)
{