Class ParallelSplitShadowMapPass

java.lang.Object
com.ardor3d.renderer.pass.Pass
com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass
All Implemented Interfaces:
Serializable

public class ParallelSplitShadowMapPass extends Pass
A pass providing a parallel split shadow mapping (PSSM) layer across the top of an existing scene.
See Also:
  • Field Details

    • SCALE_BIAS_MATRIX

      public static final ReadOnlyMatrix4 SCALE_BIAS_MATRIX
      Bias matrix from [-1, 1] to [0, 1].
    • _initialised

      protected boolean _initialised
      True once the pass has been initialized.
    • _reinitSplitsDirty

      protected boolean _reinitSplitsDirty
      Flag for updating texture splits when number of splits changed.
    • _reinitTextureSizeDirty

      protected boolean _reinitTextureSizeDirty
      Flag for updating texture renderer when texture size changed.
    • _MIN_SPLITS

      public static final int _MIN_SPLITS
      Minimum number of splits allowed
      See Also:
    • _MAX_SPLITS

      public static final int _MAX_SPLITS
      Maximum number of splits allowed
      See Also:
    • _numOfSplits

      protected int _numOfSplits
      Number of splits used.
    • _receiverBounds

      protected BoundingBox _receiverBounds
      Bounding of scene for packing frustum.
    • hasValidBounds

      protected boolean hasValidBounds
      Indicates if we have any valid reciever bounds to use for frustum packing
    • _pssmCam

      protected PSSMCamera _pssmCam
      Special camera with functionality for packing frustum etc.
    • _light

      protected Light _light
      Light that casts the shadow.
    • _shadowTextureStoreFormat

      protected TextureStoreFormat _shadowTextureStoreFormat
      Store format to use for the shadow textures.
  • Constructor Details

    • ParallelSplitShadowMapPass

      public ParallelSplitShadowMapPass(Light light, int shadowMapSize, int numOfSplits)
      Create a pssm shadow map pass casting shadows from a light with the direction given.
      Parameters:
      light - the directional light
      shadowMapSize - The size of the shadow map texture
      numOfSplits - the number of splits
  • Method Details

    • init

      public void init(Renderer r)
      Initialize the pass render states.
      Parameters:
      r - the renderer
    • reinit

      public void reinit(Renderer r)
    • doRender

      protected void doRender(Renderer r)
      Render the pass.
      Specified by:
      doRender in class Pass
      Parameters:
      r - the Renderer
    • updateShadowMaps

      public void updateShadowMaps(Renderer r)
    • renderShadowedScene

      public void renderShadowedScene(Renderer r)
      Render the overlay scene with shadows.
      Parameters:
      r - The renderer to use
    • isInitialised

      public boolean isInitialised()
      Checks if this pass is initialized.
      Returns:
      true, if is initialized
    • getShadowOffsetState

      public OffsetState getShadowOffsetState()
      Returns:
      the offset state used for drawing the shadow textures.
    • getShadowPassOffsetState

      public OffsetState getShadowPassOffsetState()
      Returns:
      the offset state used when drawing the shadow overlay pass.
    • getShadowMapTexture

      public Texture2D getShadowMapTexture(int index)
      Gets the shadow map texture.
      Parameters:
      index - the index
      Returns:
      the shadow map texture
    • getNumOfSplits

      public int getNumOfSplits()
      Gets the number of splits.
      Returns:
      the number of splits
    • setNumOfSplits

      public void setNumOfSplits(int numOfSplits)
      Sets the number of frustum splits and thus the number of shadow textures created by this pass. More splits creates crisper shadows at the cost of increased texture memory.
      Parameters:
      numOfSplits - the new number of splits
    • getShadowMapSize

      public int getShadowMapSize()
      Gets the shadow map size.
      Returns:
      the shadow map size
    • setShadowMapSize

      public void setShadowMapSize(int shadowMapSize)
      Sets the shadow map size.
      Parameters:
      shadowMapSize - the new shadow map size
    • getMaxShadowDistance

      public double getMaxShadowDistance()
      Gets the maximum distance for shadowing.
      Returns:
      max distance
      See Also:
    • setMaxShadowDistance

      public void setMaxShadowDistance(double maxShadowDistance)
      Sets the maximum distance for shadowing.
      Parameters:
      maxShadowDistance - distance to set
      See Also:
    • getMinimumLightDistance

      public double getMinimumLightDistance()
      Gets the minimum z distance for the light.
      Returns:
      the minimumLightDistance
    • setMinimumLightDistance

      public void setMinimumLightDistance(double minimumLightDistance)
      Sets the minimum z distance for the light.
      Parameters:
      minimumLightDistance - the minimumLightDistance to set
    • getShadowColor

      public ReadOnlyColorRGBA getShadowColor()
      Gets shadow color and transparency.
      Returns:
      the shadowColor
    • setShadowColor

      public void setShadowColor(ReadOnlyColorRGBA shadowColor)
      Sets shadow color and transparency.
      Parameters:
      shadowColor - the shadowColor to set
    • getShadowRenderCallback

      public ShadowRenderCallback getShadowRenderCallback()
    • setShadowRenderCallback

      public void setShadowRenderCallback(ShadowRenderCallback callback)
    • cleanUp

      public void cleanUp()
      Clean up.
      Overrides:
      cleanUp in class Pass
      See Also:
    • clear

      public void clear()
      Remove the contents of the pass.
    • isUpdateMainCamera

      public boolean isUpdateMainCamera()
      Returns:
      the updateMainCamera
    • setUpdateMainCamera

      public void setUpdateMainCamera(boolean updateMainCamera)
      Parameters:
      updateMainCamera - True (the default) if we want to copy the current rendering camera into this pass for use in shadow generation. False if we will manage our shadow camera elsewhere.
      See Also:
    • isDrawDebug

      public boolean isDrawDebug()
      Returns:
      the drawDebug
    • setDrawDebug

      public void setDrawDebug(boolean drawDebug)
      Parameters:
      drawDebug - True if we want to draw camera and light frustums for debugging purposes. Default is false.
    • isDrawShaderDebug

      public boolean isDrawShaderDebug()
      Returns:
      the drawShaderDebug
    • setDrawShaderDebug

      public void setDrawShaderDebug(boolean drawShaderDebug)
      Parameters:
      drawShaderDebug - True if we want to draw debug colors over the shadows, showing which level they come from.
    • isUseSceneTexturing

      public boolean isUseSceneTexturing()
      Returns:
      the useSceneTexturing
    • setUseSceneTexturing

      public void setUseSceneTexturing(boolean useSceneTexturing)
      Parameters:
      useSceneTexturing - True if we want to factor in texturing to shadows; useful for casting shadows against alpha-tested textures. Default is false.
    • isUseObjectCullFace

      public boolean isUseObjectCullFace()
    • setUseObjectCullFace

      public void setUseObjectCullFace(boolean useObjectCullFace)
      Parameters:
      useObjectCullFace - True if we want to use the culling set on the objects instead of always culling front face (which is done for shadow precision). Default is false.
    • isRenderShadowedScene

      public boolean isRenderShadowedScene()
    • setRenderShadowedScene

      public void setRenderShadowedScene(boolean renderShadowedScene)
      Parameters:
      renderShadowedScene - When true (the default) the generated shadow map textures are drawn over the scene in a separate blend pass. If false, the shadows are generated, but not applied.
    • getPssmCam

      public PSSMCamera getPssmCam()
      Returns:
      the camera used internally to generate shadows.
    • getShadowTextureStoreFormat

      public TextureStoreFormat getShadowTextureStoreFormat()
      Returns:
      the texture store format to use for the shadow textures on the next call to init/setNumOfSplits.
    • setShadowTextureStoreFormat

      public void setShadowTextureStoreFormat(TextureStoreFormat shadowTextureStoreFormat)
      Parameters:
      shadowTextureStoreFormat - - the texture store format to use for the shadow textures. Only has an affect if called prior to calling init on this pass (or if called before calling setNumOfSplits(int)).
    • setPssmShader

      public void setPssmShader(GLSLShaderObjectsState pssmShader)
    • isKeepMainShader

      public boolean isKeepMainShader()
    • setKeepMainShader

      public void setKeepMainShader(boolean keepMainShader)
    • addBoundsReceiver

      public void addBoundsReceiver(Spatial spatial)
    • setFiltering

      public void setFiltering(ParallelSplitShadowMapPass.Filter filter)
    • getDiscardShadowFragmentsBlendState

      public BlendState getDiscardShadowFragmentsBlendState()