This is used internally by DirectionalLights for calculating shadows.
Unlike the other shadow classes, this uses an OrthographicCamera to calculate the shadows, rather than a PerspectiveCamera. This is because light rays from a DirectionalLight are parallel. DirectionalLight usually illuminate a large scene with many objects, some close, some far away. To optimize shadow calculation in this situation, a technique called Cascaded Shadow Maps is used.
Creates a new DirectionalLightShadowCSM. This is not intended to be called directly — it is called internally by DirectionalLight.
See the base LightShadow class for common properties.
Dummy camera.
Defines the method for creating subfrustums. If true
, uses fit to scene
, else fit to cascade
method. The default is false
. Use .setCascadesFitToScene to set this value.
Defines custom method of partitioning the frustum into the subfrustums. The function should take this arguments: numCascades, near, far, breaks, exponent.
Defines the method of partitioning the frustum into the subfrustums, 0.0 linear split, 1.0 - logarifmic (i.e. puts more resolution towards the near clip plane). Only works in perspective view. Range is 0.0
to 1.0
. The default is 0.5
. Use .setExponent to set this value.
When the Fade is greater than 0.0, the size of each cascade (distance interval) is increased so that neighboring cascades overlap. Then a fade is applied in the overlapping region to provide a smooth transition between cascades. Try to use small values, else you may get rendering artifacts. Range is 0.0
to 1.0
. The default is 0.0
. Use .setFade to set this value.
Read-only flag to check if a given object is of type DirectionalLightShadowCSM.
The main frustum.
Frustum far plane distance (i.e. shadows are not visible farther this distance from camera). May be smaller than camera.far value. Range is 0.0
to Infinity
. The default is 100000
. Use .setMaxDistance to set this value.
If true
, disables cutting off the last cascade for better shadow coverage. The default is true
. Use .setNoLastCascadeCutOff to set this value.
The number of shadow cascades. Range is 1
to 4
. The default is 1
. Use .setNumCascades to set this value.
Defines how far shadow camera is moved along z axis in cascade frustum space. The larger is the value the more space the shadow will be able to cover. Should be set to high values for scenes with large or tall shadow casters. Range is 0.0
to Infinity
. The default is 100.0
. Ignored if .autoLightMargin is true
. Use .setLightMargin to set this value.
See the base LightShadow class for common methods.
Creates shadow map cascades.
Recalculates split intervals for shadow cascades. Used internally.
Inits cascades, i.e. splits the main frustum. Used internally.
Defines the method for creating subfrustums. See .cascadesFitToScene.
Defines the method of partitioning the frustum into the subfrustums, 0.0 linear split, 1.0 - logarifmic (i.e. puts more resolution towards the near clip plane). See .exponent.
Sets the value of smooth transition between cascades. See .fade.
Sets frustum far plane distance (i.e. shadows are not visible farther this distance from camera). See .maxDistance.
If set true
, disables cutting off the last cascade for better shadow coverage. See .noLastCascadeCutOff.
Defines the number of shadow cascades. See .numCascades.
Defines how far shadow camera is moved along z axis in cascade frustum space. See .lightMargin.
Recalculates positions and frustums of shadow cascades.
Recalculates frustums for shadow cascades. Must be called after changing the view camera projection matrix, .exponent, .maxDistance or any bias settings.
Updates shadow maps. Used internally.
Changes shadow map resolution.
Recalculates positions of shadow cascades.
Recalculates frustums for shadow cascades. Used internally.
The set shadow param puzzle allows to enable/disable casting or receiving shadows in a visual manner.
For more info on how to obtain the source code of this module see this page.