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

Classes

class  FCullObjectsForShadowCS
 
class  FShadowObjectCullVS
 
class  FShadowObjectCullPS
 
class  FDistanceFieldShadowingCS
 
class  FDistanceFieldShadowingUpsamplePS
 
class  FShadowTileVS
 
class  FComputeCulledObjectStartOffsetCS
 

Macros

#define MAX_NUM_SHADOW_CONVEX_HULL_PLANES   (12)
 

Enumerations

enum  EDistanceFieldShadowingType { DFS_DirectionalLightScatterTileCulling , DFS_DirectionalLightTiledCulling , DFS_PointLightTiledCulling }
 

Functions

FAutoConsoleVariableRef CVarDistanceFieldShadowing (TEXT("r.DistanceFieldShadowing"), GDistanceFieldShadowing, TEXT("Whether the distance field shadowing feature is allowed."), ECVF_Scalability|ECVF_RenderThreadSafe)
 
FAutoConsoleVariableRef CVarDFShadowQuality (TEXT("r.DFShadowQuality"), GDFShadowQuality, TEXT(" 0:off, 1:low (20 steps, no SSS), 2:medium (32 steps, no SSS), 3:high (64 steps, SSS, default)"), ECVF_Scalability|ECVF_RenderThreadSafe)
 
FAutoConsoleVariableRef CVarFullResolutionDFShadowing (TEXT("r.DFFullResolution"), GFullResolutionDFShadowing, TEXT("1 = full resolution distance field shadowing, 0 = half resolution with bilateral upsample."), ECVF_Scalability|ECVF_RenderThreadSafe)
 
FAutoConsoleVariableRef CVarShadowCullTileWorldSize (TEXT("r.DFShadowCullTileWorldSize"), GShadowCullTileWorldSize, TEXT("World space size of a tile used for culling for directional lights."), ECVF_Scalability|ECVF_RenderThreadSafe)
 
FAutoConsoleVariableRef CVarAverageObjectsPerShadowCullTile (TEXT("r.DFShadowAverageObjectsPerCullTile"), GAverageObjectsPerShadowCullTile, TEXT("Determines how much memory should be allocated in distance field object culling data structures. Too much = memory waste, too little = flickering due to buffer overflow."), ECVF_RenderThreadSafe|ECVF_ReadOnly)
 
FAutoConsoleVariableRef CVarHeightFieldShadowing (TEXT("r.HeightFieldShadowing"), GHeightFieldShadowing, TEXT("Whether the height field shadowing feature is allowed."), ECVF_Scalability|ECVF_RenderThreadSafe)
 
FAutoConsoleVariableRef CVarHFShadowQuality (TEXT("r.HFShadowQuality"), GHFShadowQuality, TEXT(" 0:off, 1:low (8 steps), 2:medium (16 steps, default), 3:high (32 steps, hole aware)"), ECVF_Scalability|ECVF_RenderThreadSafe)
 
FAutoConsoleVariableRef CVarAverageHeightFieldObjectsPerShadowCullTile (TEXT("r.HFShadowAverageObjectsPerCullTile"), GAverageHeightFieldObjectsPerShadowCullTile, TEXT("Determines how much memory should be allocated in height field object culling data structures. Too much = memory waste, too little = flickering due to buffer overflow."), ECVF_RenderThreadSafe|ECVF_ReadOnly)
 
int32 GetDFShadowDownsampleFactor ()
 
FIntPoint GetBufferSizeForDFShadows (const FViewInfo &View)
 
FIntRect GetScissorRectForDFShadows (FIntRect ScissorRect)
 
 IMPLEMENT_GLOBAL_SHADER (FCullObjectsForShadowCS, "/Engine/Private/DistanceFieldShadowing.usf", "CullObjectsForShadowCS", SF_Compute)
 
 IMPLEMENT_GLOBAL_SHADER (FShadowObjectCullVS, "/Engine/Private/DistanceFieldShadowing.usf", "ShadowObjectCullVS", SF_Vertex)
 
 IMPLEMENT_GLOBAL_SHADER (FShadowObjectCullPS, "/Engine/Private/DistanceFieldShadowing.usf", "ShadowObjectCullPS", SF_Pixel)
 
int32 GetDFShadowQuality ()
 
int32 GetHFShadowQuality ()
 
 IMPLEMENT_GLOBAL_SHADER (FDistanceFieldShadowingCS, "/Engine/Private/DistanceFieldShadowing.usf", "DistanceFieldShadowingCS", SF_Compute)
 
 IMPLEMENT_GLOBAL_SHADER (FDistanceFieldShadowingUpsamplePS, "/Engine/Private/DistanceFieldShadowing.usf", "DistanceFieldShadowingUpsamplePS", SF_Pixel)
 
bool UseShadowIndirectDraw (EShaderPlatform ShaderPlatform)
 
 IMPLEMENT_GLOBAL_SHADER (FShadowTileVS, "/Engine/Private/DistanceFieldShadowing.usf", "ShadowTileVS", SF_Vertex)
 
 IMPLEMENT_SHADER_TYPE (, FComputeCulledObjectStartOffsetCS, TEXT("/Engine/Private/DistanceFieldShadowing.usf"), TEXT("ComputeCulledTilesStartOffsetCS"), SF_Compute)
 
void ScatterObjectsToShadowTiles (FRDGBuilder &GraphBuilder, const FViewInfo &View, const FMatrix &WorldToShadowValue, float ShadowBoundingRadius, bool bCountingPass, EDistanceFieldPrimitiveType PrimitiveType, FIntPoint LightTileDimensions, FRDGBufferRef ObjectIndirectArguments, const FDistanceFieldObjectBufferParameters &ObjectBufferParameters, const FDistanceFieldCulledObjectBufferParameters &CulledObjectBufferParameters, const FLightTileIntersectionParameters &LightTileIntersectionParameters)
 
void AllocateDistanceFieldCulledObjectBuffers (FRDGBuilder &GraphBuilder, uint32 MaxObjects, FRDGBufferRef &OutObjectIndirectArguments, FDistanceFieldCulledObjectBufferParameters &OutParameters)
 
void CullDistanceFieldObjectsForLight (FRDGBuilder &GraphBuilder, const FViewInfo &View, const FLightSceneProxy *LightSceneProxy, EDistanceFieldPrimitiveType PrimitiveType, const FMatrix &WorldToShadowValue, int32 NumPlanes, const FPlane *PlaneData, const FVector &PrePlaneTranslation, const FVector4f &ShadowBoundingSphere, float ShadowBoundingRadius, bool bCullingForDirectShadowing, bool bCullHeighfieldsNotInAtlas, const FDistanceFieldObjectBufferParameters &ObjectBufferParameters, FDistanceFieldCulledObjectBufferParameters &CulledObjectBufferParameters, FLightTileIntersectionParameters &LightTileIntersectionParameters)
 
bool SupportsDistanceFieldShadows (ERHIFeatureLevel::Type FeatureLevel, EShaderPlatform ShaderPlatform)
 
bool SupportsHeightFieldShadows (ERHIFeatureLevel::Type FeatureLevel, EShaderPlatform ShaderPlatform)
 
bool ShouldPrepareForDistanceFieldShadows (const FSceneRenderUpdateInputs &SceneUpdateInputs)
 
bool ShouldPrepareHeightFieldScene (const FSceneRenderUpdateInputs &SceneUpdateInputs)
 
void GetDistanceFieldShadowRange (const FProjectedShadowInfo *ProjectedShadowInfo, EDistanceFieldPrimitiveType PrimitiveType, float &OutMinDepth, float &OutMaxDepth)
 
void RayTraceShadows (FRDGBuilder &GraphBuilder, bool bAsyncCompute, const FMinimalSceneTextures &SceneTextures, FRDGTextureRef OutputTexture, const FViewInfo &View, const FIntRect &ScissorRect, const FIntRect &DownsampledScissorRect, const FDistanceFieldSceneData &DistanceFieldSceneData, const FProjectedShadowInfo *ProjectedShadowInfo, EDistanceFieldPrimitiveType PrimitiveType, bool bHasPrevOutput, FRDGTextureRef PrevOutputTexture, const FDistanceFieldObjectBufferParameters &ObjectBufferParameters, const FDistanceFieldCulledObjectBufferParameters &CulledObjectBufferParameters, const FLightTileIntersectionParameters &LightTileIntersectionParameters)
 

Variables

int32 GDistanceFieldShadowing = 1
 
int32 GDFShadowQuality = 3
 
int32 GFullResolutionDFShadowing = 0
 
int32 GShadowScatterTileCulling = 1
 
FAutoConsoleVariableRef CVarShadowScatterTileCulling (TEXT("r.DFShadowScatterTileCulling"), GShadowScatterTileCulling, TEXT("Whether to use the rasterizer to scatter objects onto the tile grid for culling."), ECVF_RenderThreadSafe)
 
float GShadowCullTileWorldSize = 200.0f
 
float GDFShadowTwoSidedMeshDistanceBiasScale = 1.0f
 
FAutoConsoleVariableRef CVarShadowTwoSidedMeshDistanceBiasScale (TEXT("r.DFShadow.TwoSidedMeshDistanceBiasScale"), GDFShadowTwoSidedMeshDistanceBiasScale, TEXT("Scale applied to distance bias when calculating distance field shadows of two sided meshes. This is useful to get tree shadows to match up with standard shadow mapping."), ECVF_RenderThreadSafe)
 
int32 GAverageObjectsPerShadowCullTile = 128
 
int32 GDFShadowAsyncCompute = 0
 
int32 GHFShadowQuality = 2
 
int32 GAverageHeightFieldObjectsPerShadowCullTile = 16
 
int32 GDFShadowCompactCulledObjects = 1
 
bool GDFShadowCullingSubsampleDepth = false
 
int32 const GDistanceFieldShadowTileSizeX = 8
 
int32 const GDistanceFieldShadowTileSizeY = 8
 
const uint32 ComputeCulledObjectStartOffsetGroupSize = 8
 

Macro Definition Documentation

◆ MAX_NUM_SHADOW_CONVEX_HULL_PLANES

#define MAX_NUM_SHADOW_CONVEX_HULL_PLANES   (12)

Enumeration Type Documentation

◆ EDistanceFieldShadowingType

Enumerator
DFS_DirectionalLightScatterTileCulling 
DFS_DirectionalLightTiledCulling 
DFS_PointLightTiledCulling 

Function Documentation

◆ AllocateDistanceFieldCulledObjectBuffers()

void AllocateDistanceFieldCulledObjectBuffers ( FRDGBuilder GraphBuilder,
uint32  MaxObjects,
FRDGBufferRef OutObjectIndirectArguments,
FDistanceFieldCulledObjectBufferParameters OutParameters 
)

◆ CullDistanceFieldObjectsForLight()

void CullDistanceFieldObjectsForLight ( FRDGBuilder GraphBuilder,
const FViewInfo View,
const FLightSceneProxy LightSceneProxy,
EDistanceFieldPrimitiveType  PrimitiveType,
const FMatrix WorldToShadowValue,
int32  NumPlanes,
const FPlane PlaneData,
const FVector PrePlaneTranslation,
const FVector4f ShadowBoundingSphere,
float  ShadowBoundingRadius,
bool  bCullingForDirectShadowing,
bool  bCullHeighfieldsNotInAtlas,
const FDistanceFieldObjectBufferParameters ObjectBufferParameters,
FDistanceFieldCulledObjectBufferParameters CulledObjectBufferParameters,
FLightTileIntersectionParameters LightTileIntersectionParameters 
)

◆ CVarAverageHeightFieldObjectsPerShadowCullTile()

FAutoConsoleVariableRef CVarAverageHeightFieldObjectsPerShadowCullTile ( TEXT("r.HFShadowAverageObjectsPerCullTile")  ,
GAverageHeightFieldObjectsPerShadowCullTile  ,
TEXT("Determines how much memory should be allocated in height field object culling data structures. Too much = memory waste, too little = flickering due to buffer overflow." ,
ECVF_RenderThreadSafe ECVF_ReadOnly 
)

◆ CVarAverageObjectsPerShadowCullTile()

FAutoConsoleVariableRef CVarAverageObjectsPerShadowCullTile ( TEXT("r.DFShadowAverageObjectsPerCullTile")  ,
GAverageObjectsPerShadowCullTile  ,
TEXT("Determines how much memory should be allocated in distance field object culling data structures. Too much = memory waste, too little = flickering due to buffer overflow." ,
ECVF_RenderThreadSafe ECVF_ReadOnly 
)

◆ CVarDFShadowQuality()

FAutoConsoleVariableRef CVarDFShadowQuality ( TEXT("r.DFShadowQuality")  ,
GDFShadowQuality  ,
TEXT(" 0:off, 1:low (20 steps, no SSS), 2:medium (32 steps, no SSS), 3:high (64 steps, SSS, default)")  ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ CVarDistanceFieldShadowing()

FAutoConsoleVariableRef CVarDistanceFieldShadowing ( TEXT("r.DistanceFieldShadowing")  ,
GDistanceFieldShadowing  ,
TEXT("Whether the distance field shadowing feature is allowed." ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ CVarFullResolutionDFShadowing()

FAutoConsoleVariableRef CVarFullResolutionDFShadowing ( TEXT("r.DFFullResolution")  ,
GFullResolutionDFShadowing  ,
TEXT("1 = full resolution distance field shadowing, 0 = half resolution with bilateral upsample." ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ CVarHeightFieldShadowing()

FAutoConsoleVariableRef CVarHeightFieldShadowing ( TEXT("r.HeightFieldShadowing")  ,
GHeightFieldShadowing  ,
TEXT("Whether the height field shadowing feature is allowed." ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ CVarHFShadowQuality()

FAutoConsoleVariableRef CVarHFShadowQuality ( TEXT("r.HFShadowQuality")  ,
GHFShadowQuality  ,
TEXT(" 0:off, 1:low (8 steps), 2:medium (16 steps, default), 3:high (32 steps, hole aware)")  ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ CVarShadowCullTileWorldSize()

FAutoConsoleVariableRef CVarShadowCullTileWorldSize ( TEXT("r.DFShadowCullTileWorldSize")  ,
GShadowCullTileWorldSize  ,
TEXT("World space size of a tile used for culling for directional lights." ,
ECVF_Scalability ECVF_RenderThreadSafe 
)

◆ GetBufferSizeForDFShadows()

FIntPoint GetBufferSizeForDFShadows ( const FViewInfo View)

◆ GetDFShadowDownsampleFactor()

int32 GetDFShadowDownsampleFactor ( )

◆ GetDFShadowQuality()

int32 GetDFShadowQuality ( )

◆ GetDistanceFieldShadowRange()

void GetDistanceFieldShadowRange ( const FProjectedShadowInfo ProjectedShadowInfo,
EDistanceFieldPrimitiveType  PrimitiveType,
float OutMinDepth,
float OutMaxDepth 
)

◆ GetHFShadowQuality()

int32 GetHFShadowQuality ( )

◆ GetScissorRectForDFShadows()

FIntRect GetScissorRectForDFShadows ( FIntRect  ScissorRect)

◆ IMPLEMENT_GLOBAL_SHADER() [1/6]

IMPLEMENT_GLOBAL_SHADER ( FCullObjectsForShadowCS  ,
"/Engine/Private/DistanceFieldShadowing.usf"  ,
"CullObjectsForShadowCS"  ,
SF_Compute   
)

◆ IMPLEMENT_GLOBAL_SHADER() [2/6]

IMPLEMENT_GLOBAL_SHADER ( FDistanceFieldShadowingCS  ,
"/Engine/Private/DistanceFieldShadowing.usf"  ,
"DistanceFieldShadowingCS"  ,
SF_Compute   
)

◆ IMPLEMENT_GLOBAL_SHADER() [3/6]

IMPLEMENT_GLOBAL_SHADER ( FDistanceFieldShadowingUpsamplePS  ,
"/Engine/Private/DistanceFieldShadowing.usf"  ,
"DistanceFieldShadowingUpsamplePS"  ,
SF_Pixel   
)

◆ IMPLEMENT_GLOBAL_SHADER() [4/6]

IMPLEMENT_GLOBAL_SHADER ( FShadowObjectCullPS  ,
"/Engine/Private/DistanceFieldShadowing.usf"  ,
"ShadowObjectCullPS"  ,
SF_Pixel   
)

◆ IMPLEMENT_GLOBAL_SHADER() [5/6]

IMPLEMENT_GLOBAL_SHADER ( FShadowObjectCullVS  ,
"/Engine/Private/DistanceFieldShadowing.usf"  ,
"ShadowObjectCullVS"  ,
SF_Vertex   
)

◆ IMPLEMENT_GLOBAL_SHADER() [6/6]

IMPLEMENT_GLOBAL_SHADER ( FShadowTileVS  ,
"/Engine/Private/DistanceFieldShadowing.usf"  ,
"ShadowTileVS"  ,
SF_Vertex   
)

◆ IMPLEMENT_SHADER_TYPE()

IMPLEMENT_SHADER_TYPE ( FComputeCulledObjectStartOffsetCS  ,
TEXT("/Engine/Private/DistanceFieldShadowing.usf" ,
TEXT("ComputeCulledTilesStartOffsetCS")  ,
SF_Compute   
)

◆ RayTraceShadows()

void RayTraceShadows ( FRDGBuilder GraphBuilder,
bool  bAsyncCompute,
const FMinimalSceneTextures SceneTextures,
FRDGTextureRef  OutputTexture,
const FViewInfo View,
const FIntRect ScissorRect,
const FIntRect DownsampledScissorRect,
const FDistanceFieldSceneData DistanceFieldSceneData,
const FProjectedShadowInfo ProjectedShadowInfo,
EDistanceFieldPrimitiveType  PrimitiveType,
bool  bHasPrevOutput,
FRDGTextureRef  PrevOutputTexture,
const FDistanceFieldObjectBufferParameters ObjectBufferParameters,
const FDistanceFieldCulledObjectBufferParameters CulledObjectBufferParameters,
const FLightTileIntersectionParameters LightTileIntersectionParameters 
)

◆ ScatterObjectsToShadowTiles()

void ScatterObjectsToShadowTiles ( FRDGBuilder GraphBuilder,
const FViewInfo View,
const FMatrix WorldToShadowValue,
float  ShadowBoundingRadius,
bool  bCountingPass,
EDistanceFieldPrimitiveType  PrimitiveType,
FIntPoint  LightTileDimensions,
FRDGBufferRef  ObjectIndirectArguments,
const FDistanceFieldObjectBufferParameters ObjectBufferParameters,
const FDistanceFieldCulledObjectBufferParameters CulledObjectBufferParameters,
const FLightTileIntersectionParameters LightTileIntersectionParameters 
)

◆ ShouldPrepareForDistanceFieldShadows()

bool ShouldPrepareForDistanceFieldShadows ( const FSceneRenderUpdateInputs SceneUpdateInputs)

◆ ShouldPrepareHeightFieldScene()

bool ShouldPrepareHeightFieldScene ( const FSceneRenderUpdateInputs SceneUpdateInputs)

◆ SupportsDistanceFieldShadows()

bool SupportsDistanceFieldShadows ( ERHIFeatureLevel::Type  FeatureLevel,
EShaderPlatform  ShaderPlatform 
)

◆ SupportsHeightFieldShadows()

bool SupportsHeightFieldShadows ( ERHIFeatureLevel::Type  FeatureLevel,
EShaderPlatform  ShaderPlatform 
)

◆ UseShadowIndirectDraw()

bool UseShadowIndirectDraw ( EShaderPlatform  ShaderPlatform)

Variable Documentation

◆ ComputeCulledObjectStartOffsetGroupSize

const uint32 ComputeCulledObjectStartOffsetGroupSize = 8

◆ CVarShadowScatterTileCulling

FAutoConsoleVariableRef CVarShadowScatterTileCulling(TEXT("r.DFShadowScatterTileCulling"), GShadowScatterTileCulling, TEXT("Whether to use the rasterizer to scatter objects onto the tile grid for culling."), ECVF_RenderThreadSafe) ( TEXT("r.DFShadowScatterTileCulling")  ,
GShadowScatterTileCulling  ,
TEXT("Whether to use the rasterizer to scatter objects onto the tile grid for culling." ,
ECVF_RenderThreadSafe   
)

◆ CVarShadowTwoSidedMeshDistanceBiasScale

FAutoConsoleVariableRef CVarShadowTwoSidedMeshDistanceBiasScale(TEXT("r.DFShadow.TwoSidedMeshDistanceBiasScale"), GDFShadowTwoSidedMeshDistanceBiasScale, TEXT("Scale applied to distance bias when calculating distance field shadows of two sided meshes. This is useful to get tree shadows to match up with standard shadow mapping."), ECVF_RenderThreadSafe) ( TEXT("r.DFShadow.TwoSidedMeshDistanceBiasScale")  ,
GDFShadowTwoSidedMeshDistanceBiasScale  ,
TEXT("Scale applied to distance bias when calculating distance field shadows of two sided meshes. This is useful to get tree shadows to match up with standard shadow mapping." ,
ECVF_RenderThreadSafe   
)

◆ GAverageHeightFieldObjectsPerShadowCullTile

int32 GAverageHeightFieldObjectsPerShadowCullTile = 16

◆ GAverageObjectsPerShadowCullTile

int32 GAverageObjectsPerShadowCullTile = 128

◆ GDFShadowAsyncCompute

int32 GDFShadowAsyncCompute = 0

◆ GDFShadowCompactCulledObjects

int32 GDFShadowCompactCulledObjects = 1

◆ GDFShadowCullingSubsampleDepth

bool GDFShadowCullingSubsampleDepth = false

◆ GDFShadowQuality

int32 GDFShadowQuality = 3

◆ GDFShadowTwoSidedMeshDistanceBiasScale

float GDFShadowTwoSidedMeshDistanceBiasScale = 1.0f

◆ GDistanceFieldShadowing

int32 GDistanceFieldShadowing = 1

◆ GDistanceFieldShadowTileSizeX

int32 const GDistanceFieldShadowTileSizeX = 8

◆ GDistanceFieldShadowTileSizeY

int32 const GDistanceFieldShadowTileSizeY = 8

◆ GFullResolutionDFShadowing

int32 GFullResolutionDFShadowing = 0

◆ GHFShadowQuality

int32 GHFShadowQuality = 2

◆ GShadowCullTileWorldSize

float GShadowCullTileWorldSize = 200.0f

◆ GShadowScatterTileCulling

int32 GShadowScatterTileCulling = 1