Package com.jme3.shadow
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
-
Nested Class Summary
Nested classes/interfaces inherited from class com.jme3.post.Filter
Filter.Pass
-
Field Summary
Fields inherited from class com.jme3.post.Filter
defaultPass, enabled, material, postRenderPasses, processor
-
Constructor Summary
ModifierConstructorDescriptionprotected
used for serializationprotected
AbstractShadowFilter
(AssetManager manager, int shadowMapSize, T shadowRenderer) Abstract class constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
cloneFields
(Cloner cloner, Object original) Implemented to perform deep cloning for this object, resolving local cloned references using the specified cloner.returns the edge filtering modeint
returns the edges thicknessprotected Material
Must return the material used for this filter.int
Read the number of shadow maps rendered by this filter.returns the pre shadows pass render state.returns the shadow compare modefloat
returns the shadow intensityint
Read the size of each shadow map rendered by this filter.float
How far the shadows are rendered in the viewfloat
get the length over which the shadow will fade out when using a shadowZextendprotected void
initFilter
(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) Initialization of filter subclasses.boolean
Deprecated.boolean
if this filter renders back faces shadowsprotected boolean
Override this method and return true if your Filter needs the depth texturejmeClone()
Performs a regular shallow clone of the object.protected void
postFrame
(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) Override this method if you want to make a pass just after the frame has been rendered and just before the filter renderingprotected void
postQueue
(RenderQueue queue) Override this method if you want to make a pre pass, before the actual rendering of the frameprotected void
preFrame
(float tpf) Override this method if you want to modify parameters according to tpf before the rendering of the frame.void
read
(JmeImporter im) 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);final void
setEdgeFilteringMode
(EdgeFilteringMode filterMode) Sets the filtering mode for shadow edges seeEdgeFilteringMode
for more infovoid
setEdgesThickness
(int edgesThickness) Sets the shadow edges thickness.void
setRenderBackFacesShadows
(Boolean renderBackFacesShadows) !! WARNING !! this parameter is defaulted to true for the ShadowFilter.final void
setShadowCompareMode
(CompareMode compareMode) sets the shadow compare mode seeCompareMode
for more infofinal 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.7void
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.void
setShadowZFadeLength
(float length) Define the length over which the shadow will fade out when using a shadowZextendvoid
write
(JmeExporter ex) 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);Methods inherited from class com.jme3.post.Filter
cleanup, cleanUpFilter, getDefaultPassDepthFormat, getDefaultPassTextureFormat, getName, getPostRenderPasses, getRenderedTexture, getRenderFrameBuffer, init, isEnabled, isRequiresBilinear, isRequiresSceneTexture, postFilter, setDepthTexture, setEnabled, setName, setProcessor, setRenderedTexture, setRenderFrameBuffer
-
Field Details
-
shadowRenderer
-
viewPort
-
-
Constructor Details
-
AbstractShadowFilter
protected AbstractShadowFilter()used for serialization -
AbstractShadowFilter
Abstract class constructor- Parameters:
manager
- the application asset managershadowMapSize
- the size of the rendered shadowmaps (512,1024,2048, etc...)shadowRenderer
- the shadowRenderer to use for this Filter
-
-
Method Details
-
getMaterial
Description copied from class:Filter
Must return the material used for this filter. this method is called every frame.- Specified by:
getMaterial
in classFilter
- 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 classFilter
- Returns:
- true if your Filter need the depth texture
-
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 -
postQueue
Description copied from class:Filter
Override this method if you want to make a pre pass, before the actual rendering of the frame -
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 -
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 classFilter
- Parameters:
manager
- the assetManagerrenderManager
- the renderManagervp
- the viewPort where this filter is renderedw
- the width of the filterh
- 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.isFlushQueues does nothing and is kept only for backward compatibility- Returns:
- false
-
setShadowCompareMode
sets the shadow compare mode seeCompareMode
for more info- Parameters:
compareMode
- the desired mode
-
getShadowCompareMode
returns the shadow compare mode- Returns:
- the shadowCompareMode
- See Also:
-
setEdgeFilteringMode
Sets the filtering mode for shadow edges seeEdgeFilteringMode
for more info- Parameters:
filterMode
- the desired mode
-
setRenderBackFacesShadows
!! 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 usinggetPreShadowForcedRenderState()
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
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
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
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 interfaceJmeCloneable
- Returns:
- a new instance
-
cloneFields
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 interfaceJmeCloneable
- 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
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 interfaceSavable
- Overrides:
write
in classFilter
- Parameters:
ex
- the exporter (not null)- Throws:
IOException
- from the exporter
-
read
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 interfaceSavable
- Overrides:
read
in classFilter
- Throws:
IOException
-