com.jme3.shadow
Class PssmShadowRenderer

java.lang.Object
  extended by com.jme3.shadow.PssmShadowRenderer
All Implemented Interfaces:
SceneProcessor

public class PssmShadowRenderer
extends java.lang.Object
implements SceneProcessor

PssmShadow renderer use Parrallel Split Shadow Mapping technique (pssm)
It splits the view frustum in several parts and compute a shadow map for each one.
splits are distributed so that the closer they are from the camera, the smaller they are to maximize the resolution used of the shadow map.
This result in a better quality shadow than standard shadow mapping.
for more informations on this read this http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html


Nested Class Summary
static class PssmShadowRenderer.CompareMode
          Specifies the shadow comparison mode
static class PssmShadowRenderer.FilterMode
          FilterMode specifies how shadows are filtered
 
Constructor Summary
PssmShadowRenderer(AssetManager manager, int size, int nbSplits)
          Create a PSSM Shadow Renderer More info on the technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html
PssmShadowRenderer(AssetManager manager, int size, int nbSplits, Material postShadowMat)
          Create a PSSM Shadow Renderer More info on the technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html
 
Method Summary
 void cleanup()
          Called when the SP is removed from the RM.
 void displayDebug()
          For dubuging purpose Allow to "snapshot" the current frustrum to the scene
 Vector3f getDirection()
          returns the light direction used by the processor
 int getEdgesThickness()
          returns the edges thickness
see setEdgesThickness(int edgesThickness)
 float getLambda()
          returns the labda parameter
see setLambda(float lambda)
 float getShadowIntensity()
          returns the shdaow intensity
see setShadowIntensity(float shadowIntensity)
 float getShadowZExtend()
          How far the shadows are rendered in the view see setShadowZExtend(float zFar)
 void initialize(RenderManager rm, ViewPort vp)
          Called in the render thread to initialize the scene processor.
 boolean isFlushQueues()
          returns true if the PssmRenderer flushed the shadow queues
 boolean isInitialized()
           
 void postFrame(FrameBuffer out)
          Called after a frame has been rendered and the queue flushed.
 void postQueue(RenderQueue rq)
          Called after the scene graph has been queued, but before it is flushed.
 void preFrame(float tpf)
          Called before a frame
 void reshape(ViewPort vp, int w, int h)
          Called when the resolution of the viewport has been changed.
 void setCompareMode(PssmShadowRenderer.CompareMode compareMode)
          sets the shadow compare mode see PssmShadowRenderer.CompareMode for more info
 void setDirection(Vector3f direction)
          Sets the light direction to use to compute shadows
 void setEdgesThickness(int edgesThickness)
          Sets the shadow edges thickness.
 void setFilterMode(PssmShadowRenderer.FilterMode filterMode)
          Sets the filtering mode for shadow edges see PssmShadowRenderer.FilterMode for more info
 void setFlushQueues(boolean flushQueues)
          Set this to false if you want to use several PssmRederers to have multiple shadows cast by multiple light sources.
 void setLambda(float lambda)
           
 void setShadowIntensity(float shadowIntensity)
          Set the shadowIntensity, the value should be between 0 and 1, a 0 value gives a bright and invisilble shadow, a 1 value gives a pitch black shadow, default is 0.7
 void setShadowZExtend(float zFar)
          Set the distance from the eye where the shadows will be rendered default value is dynamicaly computed to the shadow casters/receivers union bound zFar, capped to view frustum far value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PssmShadowRenderer

public PssmShadowRenderer(AssetManager manager,
                          int size,
                          int nbSplits)
Create a PSSM Shadow Renderer More info on the technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html

Parameters:
manager - the application asset manager
size - the size of the rendered shadowmaps (512,1024,2048, etc...)
nbSplits - the number of shadow maps rendered (the more shadow maps the more quality, the less fps).
nbSplits - the number of shadow maps rendered (the more shadow maps the more quality, the less fps).

PssmShadowRenderer

public PssmShadowRenderer(AssetManager manager,
                          int size,
                          int nbSplits,
                          Material postShadowMat)
Create a PSSM Shadow Renderer More info on the technique at http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html

Parameters:
manager - the application asset manager
size - the size of the rendered shadowmaps (512,1024,2048, etc...)
nbSplits - the number of shadow maps rendered (the more shadow maps the more quality, the less fps).
postShadowMat - the material used for post shadows if you need to override it *
Method Detail

setFilterMode

public final void setFilterMode(PssmShadowRenderer.FilterMode filterMode)
Sets the filtering mode for shadow edges see PssmShadowRenderer.FilterMode for more info

Parameters:
filterMode -

setCompareMode

public final void setCompareMode(PssmShadowRenderer.CompareMode compareMode)
sets the shadow compare mode see PssmShadowRenderer.CompareMode for more info

Parameters:
compareMode -

initialize

public void initialize(RenderManager rm,
                       ViewPort vp)
Description copied from interface: SceneProcessor
Called in the render thread to initialize the scene processor.

Specified by:
initialize in interface SceneProcessor
Parameters:
rm - The render manager to which the SP was added to
vp - The viewport to which the SP is assigned

isInitialized

public boolean isInitialized()
Specified by:
isInitialized in interface SceneProcessor
Returns:
True if initialize() has been called on this SceneProcessor, false if otherwise.

getDirection

public Vector3f getDirection()
returns the light direction used by the processor

Returns:

setDirection

public void setDirection(Vector3f direction)
Sets the light direction to use to compute shadows

Parameters:
direction -

postQueue

public void postQueue(RenderQueue rq)
Description copied from interface: SceneProcessor
Called after the scene graph has been queued, but before it is flushed.

Specified by:
postQueue in interface SceneProcessor
Parameters:
rq - The render queue

displayDebug

public void displayDebug()
For dubuging purpose Allow to "snapshot" the current frustrum to the scene


postFrame

public void postFrame(FrameBuffer out)
Description copied from interface: SceneProcessor
Called after a frame has been rendered and the queue flushed.

Specified by:
postFrame in interface SceneProcessor
Parameters:
out - The FB to which the scene was rendered.

preFrame

public void preFrame(float tpf)
Description copied from interface: SceneProcessor
Called before a frame

Specified by:
preFrame in interface SceneProcessor
Parameters:
tpf - Time per frame

cleanup

public void cleanup()
Description copied from interface: SceneProcessor
Called when the SP is removed from the RM.

Specified by:
cleanup in interface SceneProcessor

reshape

public void reshape(ViewPort vp,
                    int w,
                    int h)
Description copied from interface: SceneProcessor
Called when the resolution of the viewport has been changed.

Specified by:
reshape in interface SceneProcessor

getLambda

public float getLambda()
returns the labda parameter
see setLambda(float lambda)

Returns:
lambda

setLambda

public void setLambda(float lambda)

getShadowZExtend

public float getShadowZExtend()
How far the shadows are rendered in the view see setShadowZExtend(float zFar)

Returns:
shadowZExtend

setShadowZExtend

public void setShadowZExtend(float zFar)
Set the distance from the eye where the shadows will be rendered default value is dynamicaly 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

getShadowIntensity

public float getShadowIntensity()
returns the shdaow intensity
see setShadowIntensity(float shadowIntensity)

Returns:
shadowIntensity

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 invisilble 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
see setEdgesThickness(int edgesThickness)

Returns:
edgesThickness

setEdgesThickness

public void setEdgesThickness(int edgesThickness)
Sets the shadow edges thickness. default is 1, setting it to lower values can help to reduce the jagged effect of the shadow edges

Parameters:
edgesThickness -

isFlushQueues

public boolean isFlushQueues()
returns true if the PssmRenderer flushed the shadow queues

Returns:
flushQueues

setFlushQueues

public void setFlushQueues(boolean flushQueues)
Set this to false if you want to use several PssmRederers to have multiple shadows cast by multiple light sources. Make sure the last PssmRenderer in the stack DO flush the queues, but not the others

Parameters:
flushQueues -