Class CascadeShadowMap

java.lang.Object
gaiasky.util.gdx.model.gltf.scene3d.scene.CascadeShadowMap
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable

public class CascadeShadowMap extends Object implements com.badlogic.gdx.utils.Disposable
  • Field Details

    • lights

      public final com.badlogic.gdx.utils.Array<DirectionalShadowLight> lights
    • attribute

      public final CascadeShadowMapAttribute attribute
    • cascadeCount

      protected final int cascadeCount
    • splitRates

      protected final DoubleArray splitRates
    • projection

      protected Matrix4D projection
      Attributes used for the CSM camera, which does not cover the same range as the full camera.
    • view

      protected Matrix4D view
      Attributes used for the CSM camera, which does not cover the same range as the full camera.
    • combined

      protected Matrix4D combined
      Attributes used for the CSM camera, which does not cover the same range as the full camera.
    • frustum

      protected FrustumDouble frustum
    • CAM_NEAR_CSM

      public double CAM_NEAR_CSM
      Camera near value for the cascaded shadow maps.
    • CAM_FAR_CSM

      public double CAM_FAR_CSM
      Camera far value for the cascaded shadow maps.
  • Constructor Details

    • CascadeShadowMap

      public CascadeShadowMap(int cascadeCount)
      Parameters:
      cascadeCount - How many extra cascades.
  • Method Details

    • dispose

      public void dispose()
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
    • getSplitDistance

      public double getSplitDistance(int layer)
    • setCascades

      public void setCascades(ICamera sceneCamera, DirectionalShadowLight baseLight, double lightDepthFactor, double splitDivisor)
      Setup base light and extra cascades based on scene camera frustum. With automatic split rates.
      Parameters:
      sceneCamera - The camera used to render the scene (frustum should be up-to-date).
      baseLight - The default shadow light, used for far shadows.
      lightDepthFactor - Shadow box depth factor, depends on the scene. Must be >= 1. Greater than 1 means more objects cast shadows but less precision. A 1 value restricts shadow box depth to the frustum (only visible objects by the scene camera).
      splitDivisor - Describe how to split scene camera frustum. . With a value of 4, far cascade covers the range: 1/4 to 1/1, next cascade, the range 1/16 to 1/4, and so on. The closest one covers the remaining starting from 0. When used with 2 extra cascades (3 areas), split points are: 0.0, 1/16, 1/4, 1.0.
    • setCascades

      public void setCascades(ICamera sceneCamera, DirectionalShadowLight base, double lightDepthFactor, DoubleArray splitRates)
      Setup base light and extra cascades based on scene camera frustum. With user defined split rates.
      Parameters:
      sceneCamera - The camera used to render the scene (frustum should be up-to-date).
      base - The default shadow light, used for far shadows.
      lightDepthFactor - Shadow box depth factor, depends on the scene. Must be >= 1. Greater than 1 means more objects cast shadows but less precision. A 1 value restricts shadow box depth to the frustum (only visible objects by the scene camera).
      splitRates - Describe how to split scene camera frustum. The first 2 values define near and far rate for the closest cascade, Second and third value define near and far rate for the second cascade, and so on. When used with 2 extra cascades (3 areas), 4 split rates are expected. Eg: [0.0, 0.1, 0.3, 1.0].
    • syncExtraCascades

      protected void syncExtraCascades(DirectionalShadowLight base)
      Create or recreate, if necessary ,extra cascades with same resolution as the default shadow light.
      Parameters:
      base - The default shadow light.
    • createLight

      protected DirectionalShadowLight createLight(int width, int height)
      Allow subclass to use their own shadow light implementation.
      Returns:
      a new directional shadow light.
    • updateCSM

      public void updateCSM(com.badlogic.gdx.graphics.PerspectiveCamera cam, Vector3D position, Vector3D direction, Vector3D up)