Class AbstractShadowFilter<T extends AbstractShadowRenderer>

java.lang.Object
com.jme3.post.Filter
com.jme3.shadow.AbstractShadowFilter<T>
All Implemented Interfaces:
Savable, JmeCloneable, Cloneable
Direct Known Subclasses:
DirectionalLightShadowFilter, PointLightShadowFilter, SpotLightShadowFilter

public abstract class AbstractShadowFilter<T extends AbstractShadowRenderer> extends Filter implements Cloneable, JmeCloneable
Generic abstract filter that holds common implementations for the different shadow filters
  • Field Details

  • Constructor Details

    • AbstractShadowFilter

      protected AbstractShadowFilter()
      used for serialization
    • AbstractShadowFilter

      protected AbstractShadowFilter(AssetManager manager, int shadowMapSize, T shadowRenderer)
      Abstract class constructor
      Parameters:
      manager - the application asset manager
      shadowMapSize - the size of the rendered shadowmaps (512,1024,2048, etc...)
      shadowRenderer - the shadowRenderer to use for this Filter
  • Method Details

    • getMaterial

      protected Material getMaterial()
      Description copied from class: Filter
      Must return the material used for this filter. this method is called every frame.
      Specified by:
      getMaterial in class Filter
      Returns:
      the material used for this filter.
    • isRequiresDepthTexture

      protected boolean isRequiresDepthTexture()
      Description copied from class: Filter
      Override this method and return true if your Filter needs the depth texture
      Overrides:
      isRequiresDepthTexture in class Filter
      Returns:
      true if your Filter need the depth texture
    • getShadowMaterial

      public Material getShadowMaterial()
    • preFrame

      protected void preFrame(float tpf)
      Description copied from class: Filter
      Override this method if you want to modify parameters according to tpf before the rendering of the frame. This is useful for animated filters Also it can be the place to render pre passes
      Overrides:
      preFrame in class Filter
      Parameters:
      tpf - the time used to render the previous frame
    • postQueue

      protected void postQueue(RenderQueue queue)
      Description copied from class: Filter
      Override this method if you want to make a pre pass, before the actual rendering of the frame
      Overrides:
      postQueue in class Filter
      Parameters:
      queue - the RenderQueue
    • postFrame

      protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer)
      Description copied from class: Filter
      Override this method if you want to make a pass just after the frame has been rendered and just before the filter rendering
      Overrides:
      postFrame in class Filter
      Parameters:
      renderManager - for rendering
      viewPort - for rendering
      prevFilterBuffer - the FrameBuffer of the previous filter
      sceneBuffer - the FrameBuffer of the scene
    • initFilter

      protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h)
      Description copied from class: Filter
      Initialization of filter subclasses. This method is called once when the filter is added to the FilterPostProcessor It should contain Material initializations and extra passes initialization
      Specified by:
      initFilter in class Filter
      Parameters:
      manager - the assetManager
      renderManager - the renderManager
      vp - the viewPort where this filter is rendered
      w - the width of the filter
      h - the height of the filter
    • getShadowZExtend

      public float getShadowZExtend()
      How far the shadows are rendered in the view
      Returns:
      shadowZExtend
      See Also:
    • setShadowZExtend

      public void setShadowZExtend(float zFar)
      Set the distance from the eye where the shadows will be rendered default value is dynamically computed to the shadow casters/receivers union bound zFar, capped to view frustum far value.
      Parameters:
      zFar - the zFar values that override the computed one
    • setShadowZFadeLength

      public void setShadowZFadeLength(float length)
      Define the length over which the shadow will fade out when using a shadowZextend
      Parameters:
      length - the fade length in world units
    • getShadowZFadeLength

      public float getShadowZFadeLength()
      get the length over which the shadow will fade out when using a shadowZextend
      Returns:
      the fade length in world units
    • getShadowIntensity

      public float getShadowIntensity()
      returns the shadow intensity
      Returns:
      shadowIntensity
      See Also:
    • setShadowIntensity

      public final void setShadowIntensity(float shadowIntensity)
      Set the shadowIntensity, the value should be between 0 and 1, a 0 value gives a bright and invisible shadow, a 1 value gives a pitch black shadow, default is 0.7
      Parameters:
      shadowIntensity - the darkness of the shadow
    • getEdgesThickness

      public int getEdgesThickness()
      returns the edges thickness
      Returns:
      edgesThickness
      See Also:
    • setEdgesThickness

      public void setEdgesThickness(int edgesThickness)
      Sets the shadow edges thickness. Default is 10. Setting it to lower values can help reduce the jagged effect of shadow edges.
      Parameters:
      edgesThickness - the desired thickness (in tenths of a pixel, default=10)
    • isFlushQueues

      @Deprecated public boolean isFlushQueues()
      Deprecated.
      isFlushQueues does nothing and is kept only for backward compatibility
      Returns:
      false
    • setShadowCompareMode

      public final void setShadowCompareMode(CompareMode compareMode)
      sets the shadow compare mode see CompareMode for more info
      Parameters:
      compareMode - the desired mode
    • getShadowCompareMode

      public CompareMode getShadowCompareMode()
      returns the shadow compare mode
      Returns:
      the shadowCompareMode
      See Also:
    • setEdgeFilteringMode

      public final void setEdgeFilteringMode(EdgeFilteringMode filterMode)
      Sets the filtering mode for shadow edges see EdgeFilteringMode for more info
      Parameters:
      filterMode - the desired mode
    • setRenderBackFacesShadows

      public void setRenderBackFacesShadows(Boolean renderBackFacesShadows)
      !! WARNING !! this parameter is defaulted to true for the ShadowFilter. Setting it to true, may produce edges artifacts on shadows. * Set to true if you want back faces shadows on geometries. Note that back faces shadows will be blended over dark lighten areas and may produce overly dark lighting. Setting this parameter will override this parameter for ALL materials in the scene. This also will automatically adjust the faceCullMode and the PolyOffset of the pre shadow pass. You can modify them by using getPreShadowForcedRenderState() If you want to set it differently for each material in the scene you have to use the ShadowRenderer instead of the shadow filter.
      Parameters:
      renderBackFacesShadows - true or false.
    • isRenderBackFacesShadows

      public boolean isRenderBackFacesShadows()
      if this filter renders back faces shadows
      Returns:
      true if this filter renders back faces shadows
    • getPreShadowForcedRenderState

      public RenderState getPreShadowForcedRenderState()
      returns the pre shadows pass render state. use it to adjust the RenderState parameters of the pre shadow pass. Note that this will be overridden if the preShadow technique in the material has a ForcedRenderState
      Returns:
      the pre shadow render state.
    • getEdgeFilteringMode

      public EdgeFilteringMode getEdgeFilteringMode()
      returns the edge filtering mode
      Returns:
      the enum value
      See Also:
    • getNumShadowMaps

      public int getNumShadowMaps()
      Read the number of shadow maps rendered by this filter.
      Returns:
      count
    • getShadowMapSize

      public int getShadowMapSize()
      Read the size of each shadow map rendered by this filter.
      Returns:
      a map's height (which is also its width, in pixels)
    • jmeClone

      public AbstractShadowFilter<T> jmeClone()
      Description copied from interface: JmeCloneable
      Performs a regular shallow clone of the object. Some fields may also be cloned but generally only if they will never be shared with other objects. (For example, local Vector3fs and so on.)

      This method is separate from the regular clone() method so that objects might still maintain their own regular java clone() semantics (perhaps even using Cloner for those methods). However, because Java's clone() has specific features in the sense of Object's clone() implementation, it's usually best to have some path for subclasses to bypass the public clone() method that might be cloning fields and instead get at the superclass protected clone() methods. For example, through super.jmeClone() or another protected clone method that some base class eventually calls super.clone() in.

      Specified by:
      jmeClone in interface JmeCloneable
      Returns:
      a new instance
    • cloneFields

      public void cloneFields(Cloner cloner, Object original)
      Description copied from interface: JmeCloneable
      Implemented to perform deep cloning for this object, resolving local cloned references using the specified cloner. The object can call cloner.clone(fieldValue) to deep clone any of its fields.

      Note: during normal clone operations the original object will not be needed as the clone has already had all of the fields shallow copied.

      Specified by:
      cloneFields in interface JmeCloneable
      Parameters:
      cloner - The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.
      original - The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.
    • write

      public void write(JmeExporter ex) throws IOException
      Description copied from class: Filter
      Override this method if you want to save extra properties when the filter is saved else only basic properties of the filter will be saved This method should always begin by super.write(ex);
      Specified by:
      write in interface Savable
      Overrides:
      write in class Filter
      Parameters:
      ex - the exporter (not null)
      Throws:
      IOException - from the exporter
    • read

      public void read(JmeImporter im) throws IOException
      Description copied from class: Filter
      Override this method if you want to load extra properties when the filter is loaded else only basic properties of the filter will be loaded This method should always begin by super.read(im);
      Specified by:
      read in interface Savable
      Overrides:
      read in class Filter
      Throws:
      IOException