Package com.ardor3d.extension.shadow.map
Class ParallelSplitShadowMapPass
java.lang.Object
com.ardor3d.renderer.pass.Pass
com.ardor3d.extension.shadow.map.ParallelSplitShadowMapPass
- All Implemented Interfaces:
Serializable
A pass providing a parallel split shadow mapping (PSSM) layer across the top of an existing scene.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Shadow filter techniques -
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
True once the pass has been initialized.protected Light
Light that casts the shadow.static final int
Maximum number of splits allowedstatic final int
Minimum number of splits allowedprotected int
Number of splits used.protected PSSMCamera
Special camera with functionality for packing frustum etc.protected BoundingBox
Bounding of scene for packing frustum.protected boolean
Flag for updating texture splits when number of splits changed.protected boolean
Flag for updating texture renderer when texture size changed.protected TextureStoreFormat
Store format to use for the shadow textures.protected boolean
Indicates if we have any valid reciever bounds to use for frustum packingstatic final ReadOnlyMatrix4
Bias matrix from [-1, 1] to [0, 1].Fields inherited from class com.ardor3d.renderer.pass.Pass
_context, _enabled, _passStates, _spatials
-
Constructor Summary
ConstructorDescriptionParallelSplitShadowMapPass
(Light light, int shadowMapSize, int numOfSplits) Create a pssm shadow map pass casting shadows from a light with the direction given. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBoundsReceiver
(Spatial spatial) void
cleanUp()
Clean up.void
clear()
Remove the contents of the pass.protected void
Render the pass.double
Gets the maximum distance for shadowing.double
Gets the minimum z distance for the light.int
Gets the number of splits.Gets shadow color and transparency.int
Gets the shadow map size.getShadowMapTexture
(int index) Gets the shadow map texture.void
Initialize the pass render states.boolean
boolean
boolean
Checks if this pass is initialized.boolean
boolean
boolean
boolean
boolean
void
void
Render the overlay scene with shadows.void
setDrawDebug
(boolean drawDebug) void
setDrawShaderDebug
(boolean drawShaderDebug) void
void
setKeepMainShader
(boolean keepMainShader) void
setMaxShadowDistance
(double maxShadowDistance) Sets the maximum distance for shadowing.void
setMinimumLightDistance
(double minimumLightDistance) Sets the minimum z distance for the light.void
setNumOfSplits
(int numOfSplits) Sets the number of frustum splits and thus the number of shadow textures created by this pass.void
setPssmShader
(GLSLShaderObjectsState pssmShader) void
setRenderShadowedScene
(boolean renderShadowedScene) void
setShadowColor
(ReadOnlyColorRGBA shadowColor) Sets shadow color and transparency.void
setShadowMapSize
(int shadowMapSize) Sets the shadow map size.void
setShadowRenderCallback
(ShadowRenderCallback callback) void
setShadowTextureStoreFormat
(TextureStoreFormat shadowTextureStoreFormat) void
setUpdateMainCamera
(boolean updateMainCamera) void
setUseObjectCullFace
(boolean useObjectCullFace) void
setUseSceneTexturing
(boolean useSceneTexturing) void
Methods inherited from class com.ardor3d.renderer.pass.Pass
add, clearPassState, clearPassStates, contains, doRender, doUpdate, get, isEnabled, remove, renderPass, renderPass, setEnabled, setPassState, size, updatePass
-
Field Details
-
SCALE_BIAS_MATRIX
Bias matrix from [-1, 1] to [0, 1]. -
_initialised
protected boolean _initialisedTrue once the pass has been initialized. -
_reinitSplitsDirty
protected boolean _reinitSplitsDirtyFlag for updating texture splits when number of splits changed. -
_reinitTextureSizeDirty
protected boolean _reinitTextureSizeDirtyFlag for updating texture renderer when texture size changed. -
_MIN_SPLITS
public static final int _MIN_SPLITSMinimum number of splits allowed- See Also:
-
_MAX_SPLITS
public static final int _MAX_SPLITSMaximum number of splits allowed- See Also:
-
_numOfSplits
protected int _numOfSplitsNumber of splits used. -
_receiverBounds
Bounding of scene for packing frustum. -
hasValidBounds
protected boolean hasValidBoundsIndicates if we have any valid reciever bounds to use for frustum packing -
_pssmCam
Special camera with functionality for packing frustum etc. -
_light
Light that casts the shadow. -
_shadowTextureStoreFormat
Store format to use for the shadow textures.
-
-
Constructor Details
-
ParallelSplitShadowMapPass
Create a pssm shadow map pass casting shadows from a light with the direction given.- Parameters:
light
- the directional lightshadowMapSize
- The size of the shadow map texturenumOfSplits
- the number of splits
-
-
Method Details
-
init
Initialize the pass render states.- Parameters:
r
- the renderer
-
reinit
-
doRender
Render the pass. -
updateShadowMaps
-
renderShadowedScene
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
- Returns:
- the offset state used for drawing the shadow textures.
-
getShadowPassOffsetState
- Returns:
- the offset state used when drawing the shadow overlay pass.
-
getShadowMapTexture
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
Gets shadow color and transparency.- Returns:
- the shadowColor
-
setShadowColor
Sets shadow color and transparency.- Parameters:
shadowColor
- the shadowColor to set
-
getShadowRenderCallback
-
setShadowRenderCallback
-
cleanUp
public void cleanUp()Clean up. -
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
- Returns:
- the camera used internally to generate shadows.
-
getShadowTextureStoreFormat
- Returns:
- the texture store format to use for the shadow textures on the next call to init/setNumOfSplits.
-
setShadowTextureStoreFormat
- 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 callingsetNumOfSplits(int)
).
-
setPssmShader
-
isKeepMainShader
public boolean isKeepMainShader() -
setKeepMainShader
public void setKeepMainShader(boolean keepMainShader) -
addBoundsReceiver
-
setFiltering
-
getDiscardShadowFragmentsBlendState
-