ShadowMapping
Description
Performs computations for shadow mapping.
A full computation cycle is made of these steps:
-
Configure the following values according to the current scene settings:
-
Configure FilterIn. The cull flags of this filter will be used to collect terrain mesh sectors that act as shadow receivers (see ShadowCascade.Receivers).
-
Configure FilterOut. Sector marks will be output to this filter for the render batches of the terrain mesh sectors that act as shadow casters (see ShadowCascade.Casters).
-
Optionally tweak the IMeshBoundMinSize.MinSize and IMeshBoundMinRadius.MinRadius settings, to adjust the behaviour of these internally used objects:
-
TerrainBounds
This object collects the terrain mesh sectors that will act as shadow receivers. Collecting too many mesh sectors will waste CPU cycles, but collecting too few mesh sectors will reduce shadow frustum fitting, which reduces shadow quality and performance, since more geometry will need to be rendered into the shadowmap. -
FrustumCulling
This object will compute the set of mesh sectors that act as shadow casters and thus need to be rendered into the shadowmap. Tweaking can reduce the number of collected mesh sectors, while keeping the triangle count reasonably low, since mesh sectors usually have less triangles when farther away from the view point.
-
-
Call Compute, optionally specifying a collector delegate for additional shadow receivers.
-
Perform triangulation of the terrain mesh (see Triangulation), including the mesh sector marks of FilterOut.
-
Render the shadowmap batches (see ShadowCascade.Casters) into the shadowmap, using the shadow projection matrix (see ShadowCascade.ShadowProjection).
-
Render the terrain mesh and other 3D geometry, using the shadow map texture and the shadow matrix to compute dynamic shadows (see ShadowCascade.ShadowMatrix resp. ShadowCascade.ShadowMatrixLocal).
ShadowMapping objects act as resource handles and produce ShadowMappingResource resource objects. ShadowMapping objects with compatible settings will produce the same ShadowMappingResource resource objects.
Public / Methods
CascadeCullZ
Returns the Z-range in view-space of the given shadow cascade, to be used for culling shadow casters.
Public / Attributes
CameraFrustum
The camera frustum to use for clipping the bounding boxes of the shadow receivers (see ShadowCascade.Receivers).
CascadeOverlap
The relative overlap of the shadow cascades, along the view direction.
The cascade overlap is applied by shifting the far splitting plane away from the view point, by the amount S
:
S = Zfar * O
where Zfar
is the view-space Z-coordinate of the far splitting plane of the cascade (see ShadowCascade.ViewRangeZ) and O
is the configured cascade overlap.
The cascade overlap is not applied to the last cascade.
The default value is 0.1
.
CascadeRange
The fixed Z-range (in camera-space) of the whole shadow volume, before being split into cascades.
This range only influences the Z-slices of the shadow cascades. All collected shadow receivers will be covered by the shadow maps.
If the given range is empty (see RangeD.IsEmpty), the Z-range will be determined automatically from the collected shadow receivers.
The default value is RangeD.Pos.
FilterOut
The output mesh filter that will receive marks for each terrain part that acts as a shadow receiver.
LightFix
Controls the amount of light-bleeding correction.
Light-bleeding may occur in shadowed areas that have multiple occluders. Defaults to 0.25
.