UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
CapsuleShadowRendering.cpp File Reference

Classes

class  FComputeLightDirectionFromVolumetricLightmapCS
 
class  FCapsuleShadowingCS
 
class  FCapsuleShadowingUpsampleVS
 
class  FCapsuleShadowingUpsamplePS
 
struct  IndirectCapsuleShadowsResources
 

Enumerations

enum class  ECapsuleShadowingType {
  DirectionalLightTiledCulling , PointLightTiledCulling , IndirectTiledCulling , MovableSkylightTiledCulling ,
  MovableSkylightTiledCullingGatherFromReceiverBentNormal , MAX
}
 
enum class  EIndirectShadowingPrimitiveTypes { CapsuleShapes , MeshDistanceFields , CapsuleShapesAndMeshDistanceFields , MAX }
 
enum class  ELightSourceMode { Punctual = 0 , FromCapsule = 1 , FromReceiver = 2 }
 

Functions

 DECLARE_GPU_STAT_NAMED (CapsuleShadows, TEXT("Capsule Shadows"))
 
FAutoConsoleVariableRef CVarCapsuleShadows (TEXT("r.CapsuleShadows"), GCapsuleShadows, TEXT("Whether to allow capsule shadowing on skinned components with bCastCapsuleDirectShadow or bCastCapsuleIndirectShadow enabled."), ECVF_Scalability|ECVF_RenderThreadSafe)
 
FAutoConsoleVariableRef CVarCapsuleDirectShadows (TEXT("r.CapsuleDirectShadows"), GCapsuleDirectShadows, TEXT("Whether to allow capsule direct shadowing on skinned components with bCastCapsuleDirectShadow enabled."), ECVF_Scalability|ECVF_RenderThreadSafe)
 
FAutoConsoleVariableRef CVarCapsuleIndirectShadows (TEXT("r.CapsuleIndirectShadows"), GCapsuleIndirectShadows, TEXT("Whether to allow capsule indirect shadowing on skinned components with bCastCapsuleIndirectShadow enabled."), ECVF_Scalability|ECVF_RenderThreadSafe)
 
FAutoConsoleVariableRef CVarCapsuleShadowsFullResolution (TEXT("r.CapsuleShadowsFullResolution"), GCapsuleShadowsFullResolution, TEXT("Whether to compute capsule shadows at full resolution."), ECVF_Scalability|ECVF_RenderThreadSafe)
 
FAutoConsoleVariableRef CVarCapsuleMaxDirectOcclusionDistance (TEXT("r.CapsuleMaxDirectOcclusionDistance"), GCapsuleMaxDirectOcclusionDistance, TEXT("Maximum cast distance for direct shadows from capsules. This has a big impact on performance."), ECVF_Scalability|ECVF_RenderThreadSafe)
 
FAutoConsoleVariableRef CVarCapsuleMaxIndirectOcclusionDistance (TEXT("r.CapsuleMaxIndirectOcclusionDistance"), GCapsuleMaxIndirectOcclusionDistance, TEXT("Maximum cast distance for indirect shadows from capsules. This has a big impact on performance."), ECVF_Scalability|ECVF_RenderThreadSafe)
 
FAutoConsoleVariableRef CVarCapsuleShadowFadeAngleFromVertical (TEXT("r.CapsuleShadowFadeAngleFromVertical"), GCapsuleShadowFadeAngleFromVertical, TEXT("Angle from vertical up to start fading out the indirect shadow, to avoid self shadowing artifacts."), ECVF_Scalability|ECVF_RenderThreadSafe)
 
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)
 
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)
 
FAutoConsoleVariableRef CVarCapsuleMinSkyAngle (TEXT("r.CapsuleMinSkyAngle"), GCapsuleMinSkyAngle, TEXT("Minimum light source angle derived from the precomputed unoccluded sky vector (stationary skylight present)"), ECVF_Scalability|ECVF_RenderThreadSafe)
 
 IMPLEMENT_GLOBAL_SHADER (FComputeLightDirectionFromVolumetricLightmapCS, "/Engine/Private/CapsuleShadowShaders.usf", "ComputeLightDirectionFromVolumetricLightmapCS", SF_Compute)
 
int32 GetCapsuleShadowDownsampleFactor ()
 
FIntPoint GetBufferSizeForCapsuleShadows (const FViewInfo &View)
 
 IMPLEMENT_GLOBAL_SHADER (FCapsuleShadowingCS, "/Engine/Private/CapsuleShadowShaders.usf", "CapsuleShadowingCS", SF_Compute)
 
 IMPLEMENT_GLOBAL_SHADER (FCapsuleShadowingUpsampleVS, "/Engine/Private/CapsuleShadowShaders.usf", "CapsuleShadowingUpsampleVS", SF_Vertex)
 
 IMPLEMENT_GLOBAL_SHADER (FCapsuleShadowingUpsamplePS, "/Engine/Private/CapsuleShadowShaders.usf", "CapsuleShadowingUpsamplePS", SF_Pixel)
 
void SetupCapsuleShadowingParameters (FRDGBuilder &GraphBuilder, FCapsuleShadowingCS::FParameters &Parameters, ECapsuleShadowingType ShadowingType, FRDGTextureUAVRef OutputUAV, FIntPoint TileDimensions, FRDGTextureRef ReceiverBentNormalTexture, FVector2D NumGroups, const FLightSceneInfo *LightSceneInfo, const FIntRect &ScissorRect, int32 DownsampleFactor, float MaxOcclusionDistance, const FScene *Scene, const FViewInfo &View, const uint32 ViewIndex, uint32 NumShadowCapsules, FRDGBufferSRVRef ShadowCapsuleShapesBuffer, uint32 NumMeshDistanceFieldCasters, FRDGBufferSRVRef MeshDistanceFieldCasterIndicesSRV, FRDGBufferSRVRef LightDirectionDataSRV, FRDGBufferUAVRef CapsuleTileIntersectionCountsUAV)
 
bool ShouldPrepareForDFInsetIndirectShadow (EShaderPlatform ShaderPlatform, const FEngineShowFlags &EngineShowFlags)
 

Variables

int32 GCapsuleShadows = 1
 
int32 GCapsuleDirectShadows = 1
 
int32 GCapsuleIndirectShadows = 1
 
int32 GCapsuleShadowsFullResolution = 0
 
float GCapsuleMaxDirectOcclusionDistance = 400
 
float GCapsuleMaxIndirectOcclusionDistance = 200
 
float GCapsuleShadowFadeAngleFromVertical = PI / 3
 
float GCapsuleIndirectConeAngle = PI / 8
 
float GCapsuleSkyAngleScale = .6f
 
float GCapsuleMinSkyAngle = 15
 
const int32 GComputeLightDirectionFromVolumetricLightmapGroupSize = 64
 
int32 GShadowShapeTileSize = 8
 

Enumeration Type Documentation

◆ ECapsuleShadowingType

Enumerator
DirectionalLightTiledCulling 
PointLightTiledCulling 
IndirectTiledCulling 
MovableSkylightTiledCulling 
MovableSkylightTiledCullingGatherFromReceiverBentNormal 
MAX 

◆ EIndirectShadowingPrimitiveTypes

Enumerator
CapsuleShapes 
MeshDistanceFields 
CapsuleShapesAndMeshDistanceFields 
MAX 

◆ ELightSourceMode

enum class ELightSourceMode
strong
Enumerator
Punctual 
FromCapsule 
FromReceiver 

Function Documentation

◆ CVarCapsuleDirectShadows()

FAutoConsoleVariableRef CVarCapsuleDirectShadows ( TEXT("r.CapsuleDirectShadows")  ,
GCapsuleDirectShadows  ,
TEXT("Whether to allow capsule direct shadowing on skinned components with bCastCapsuleDirectShadow enabled." ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ CVarCapsuleIndirectConeAngle()

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 
)

◆ CVarCapsuleIndirectShadows()

FAutoConsoleVariableRef CVarCapsuleIndirectShadows ( TEXT("r.CapsuleIndirectShadows")  ,
GCapsuleIndirectShadows  ,
TEXT("Whether to allow capsule indirect shadowing on skinned components with bCastCapsuleIndirectShadow enabled." ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ CVarCapsuleMaxDirectOcclusionDistance()

FAutoConsoleVariableRef CVarCapsuleMaxDirectOcclusionDistance ( TEXT("r.CapsuleMaxDirectOcclusionDistance")  ,
GCapsuleMaxDirectOcclusionDistance  ,
TEXT("Maximum cast distance for direct shadows from capsules. This has a big impact on performance." ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ CVarCapsuleMaxIndirectOcclusionDistance()

FAutoConsoleVariableRef CVarCapsuleMaxIndirectOcclusionDistance ( TEXT("r.CapsuleMaxIndirectOcclusionDistance")  ,
GCapsuleMaxIndirectOcclusionDistance  ,
TEXT("Maximum cast distance for indirect shadows from capsules. This has a big impact on performance." ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ CVarCapsuleMinSkyAngle()

FAutoConsoleVariableRef CVarCapsuleMinSkyAngle ( TEXT("r.CapsuleMinSkyAngle")  ,
GCapsuleMinSkyAngle  ,
TEXT("Minimum light source angle derived from the precomputed unoccluded sky vector (stationary skylight present)")  ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ CVarCapsuleShadowFadeAngleFromVertical()

FAutoConsoleVariableRef CVarCapsuleShadowFadeAngleFromVertical ( TEXT("r.CapsuleShadowFadeAngleFromVertical")  ,
GCapsuleShadowFadeAngleFromVertical  ,
TEXT("Angle from vertical up to start fading out the indirect shadow, to avoid self shadowing artifacts." ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ CVarCapsuleShadows()

FAutoConsoleVariableRef CVarCapsuleShadows ( TEXT("r.CapsuleShadows")  ,
GCapsuleShadows  ,
TEXT("Whether to allow capsule shadowing on skinned components with bCastCapsuleDirectShadow or bCastCapsuleIndirectShadow enabled." ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ CVarCapsuleShadowsFullResolution()

FAutoConsoleVariableRef CVarCapsuleShadowsFullResolution ( TEXT("r.CapsuleShadowsFullResolution")  ,
GCapsuleShadowsFullResolution  ,
TEXT("Whether to compute capsule shadows at full resolution." ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ CVarCapsuleSkyAngleScale()

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 
)

◆ DECLARE_GPU_STAT_NAMED()

DECLARE_GPU_STAT_NAMED ( CapsuleShadows  ,
TEXT("Capsule Shadows"  
)

◆ GetBufferSizeForCapsuleShadows()

FIntPoint GetBufferSizeForCapsuleShadows ( const FViewInfo View)

◆ GetCapsuleShadowDownsampleFactor()

int32 GetCapsuleShadowDownsampleFactor ( )

◆ IMPLEMENT_GLOBAL_SHADER() [1/4]

IMPLEMENT_GLOBAL_SHADER ( FCapsuleShadowingCS  ,
"/Engine/Private/CapsuleShadowShaders.usf"  ,
"CapsuleShadowingCS"  ,
SF_Compute   
)

◆ IMPLEMENT_GLOBAL_SHADER() [2/4]

IMPLEMENT_GLOBAL_SHADER ( FCapsuleShadowingUpsamplePS  ,
"/Engine/Private/CapsuleShadowShaders.usf"  ,
"CapsuleShadowingUpsamplePS"  ,
SF_Pixel   
)

◆ IMPLEMENT_GLOBAL_SHADER() [3/4]

IMPLEMENT_GLOBAL_SHADER ( FCapsuleShadowingUpsampleVS  ,
"/Engine/Private/CapsuleShadowShaders.usf"  ,
"CapsuleShadowingUpsampleVS"  ,
SF_Vertex   
)

◆ IMPLEMENT_GLOBAL_SHADER() [4/4]

IMPLEMENT_GLOBAL_SHADER ( FComputeLightDirectionFromVolumetricLightmapCS  ,
"/Engine/Private/CapsuleShadowShaders.usf"  ,
"ComputeLightDirectionFromVolumetricLightmapCS"  ,
SF_Compute   
)

◆ SetupCapsuleShadowingParameters()

void SetupCapsuleShadowingParameters ( FRDGBuilder GraphBuilder,
FCapsuleShadowingCS::FParameters &  Parameters,
ECapsuleShadowingType  ShadowingType,
FRDGTextureUAVRef  OutputUAV,
FIntPoint  TileDimensions,
FRDGTextureRef  ReceiverBentNormalTexture,
FVector2D  NumGroups,
const FLightSceneInfo LightSceneInfo,
const FIntRect ScissorRect,
int32  DownsampleFactor,
float  MaxOcclusionDistance,
const FScene Scene,
const FViewInfo View,
const uint32  ViewIndex,
uint32  NumShadowCapsules,
FRDGBufferSRVRef  ShadowCapsuleShapesBuffer,
uint32  NumMeshDistanceFieldCasters,
FRDGBufferSRVRef  MeshDistanceFieldCasterIndicesSRV,
FRDGBufferSRVRef  LightDirectionDataSRV,
FRDGBufferUAVRef  CapsuleTileIntersectionCountsUAV 
)

◆ ShouldPrepareForDFInsetIndirectShadow()

bool ShouldPrepareForDFInsetIndirectShadow ( EShaderPlatform  ShaderPlatform,
const FEngineShowFlags EngineShowFlags 
)

Variable Documentation

◆ GCapsuleDirectShadows

int32 GCapsuleDirectShadows = 1

◆ GCapsuleIndirectConeAngle

float GCapsuleIndirectConeAngle = PI / 8

◆ GCapsuleIndirectShadows

int32 GCapsuleIndirectShadows = 1

◆ GCapsuleMaxDirectOcclusionDistance

float GCapsuleMaxDirectOcclusionDistance = 400

◆ GCapsuleMaxIndirectOcclusionDistance

float GCapsuleMaxIndirectOcclusionDistance = 200

◆ GCapsuleMinSkyAngle

float GCapsuleMinSkyAngle = 15

◆ GCapsuleShadowFadeAngleFromVertical

float GCapsuleShadowFadeAngleFromVertical = PI / 3

◆ GCapsuleShadows

int32 GCapsuleShadows = 1

◆ GCapsuleShadowsFullResolution

int32 GCapsuleShadowsFullResolution = 0

◆ GCapsuleSkyAngleScale

float GCapsuleSkyAngleScale = .6f

◆ GComputeLightDirectionFromVolumetricLightmapGroupSize

const int32 GComputeLightDirectionFromVolumetricLightmapGroupSize = 64

◆ GShadowShapeTileSize

int32 GShadowShapeTileSize = 8