public abstract class AbstractShadowRenderer extends java.lang.Object implements SceneProcessor, Savable, JmeCloneable, java.lang.Cloneable
| Modifier and Type | Field and Description |
|---|---|
protected AssetManager |
assetManager |
protected boolean |
debug |
protected Picture[] |
dispPic |
protected Texture2D |
dummyTex |
protected EdgeFilteringMode |
edgeFilteringMode |
protected float |
edgesThickness |
protected Vector2f |
fadeInfo |
protected float |
fadeLength |
protected RenderState |
forcedRenderState |
protected Camera |
frustumCam |
protected GeometryList |
lightReceivers |
protected Matrix4f[] |
lightViewProjectionsMatrices |
protected static java.util.logging.Logger |
logger |
protected java.util.List<Material> |
matCache
list of materials for post shadow queue geometries
|
protected int |
nbShadowMaps |
protected boolean |
needsfallBackMaterial
true if the fallback material should be used, otherwise false
|
protected Material |
postshadowMat |
protected java.lang.String |
postTechniqueName
name of the post material technique
|
protected Material |
preshadowMat |
protected AppProfiler |
prof |
protected boolean |
renderBackFacesShadows |
protected RenderManager |
renderManager |
protected CompareMode |
shadowCompareMode |
protected FrameBuffer[] |
shadowFB |
protected float |
shadowIntensity |
protected GeometryList |
shadowMapOccluders |
protected Texture2D[] |
shadowMaps |
protected float |
shadowMapSize |
protected boolean |
skipPostPass
true to skip the post pass when there are no shadow casters
|
protected ViewPort |
viewPort |
protected float |
zFarOverride
fade shadows at distance
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractShadowRenderer()
used for serialization
|
protected |
AbstractShadowRenderer(AssetManager assetManager,
int shadowMapSize,
int nbShadowMaps)
Create an abstract shadow renderer.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract boolean |
checkCulling(Camera viewCam) |
void |
cleanup()
Called when the SP is removed from the RM.
|
protected abstract void |
clearMaterialParameters(Material material)
This method is called once per frame and is responsible for clearing any
material parameters that subclasses may need to clear on the post material.
|
void |
cloneFields(Cloner cloner,
java.lang.Object original)
Implemented to perform deep cloning for this object, resolving
local cloned references using the specified cloner.
|
protected Geometry |
createFrustum(Vector3f[] pts,
int i)
debug function to create a visible frustum
|
void |
displayDebug()
For debugging purposes, "snapshot" the current frustum to the scene.
|
void |
displayFrustum() |
protected void |
displayShadowMap(Renderer r)
For debugging purposes, display depth shadow maps.
|
protected void |
doDisplayFrustumDebug(int shadowMapIndex)
responsible for displaying the frustum of the shadow cam for debug
purpose
|
EdgeFilteringMode |
getEdgeFilteringMode()
returns the edge filtering mode
|
int |
getEdgesThickness()
returns the edges thickness
|
int |
getNumShadowMaps()
Read the number of shadow maps rendered by this renderer.
|
protected abstract GeometryList |
getOccludersToRender(int shadowMapIndex,
GeometryList shadowMapOccluders)
Returns a subclass-specific geometryList containing the occluders to be
rendered in the shadow map
|
RenderState |
getPreShadowForcedRenderState()
returns the pre shadows pass render state.
|
protected abstract void |
getReceivers(GeometryList lightReceivers) |
protected abstract Camera |
getShadowCam(int shadowMapIndex)
return the shadow camera to use for rendering the shadow map according
the given index
|
CompareMode |
getShadowCompareMode()
returns the shadow compare mode
|
float |
getShadowIntensity()
Returns the shadow intensity.
|
int |
getShadowMapSize()
Read the size of each shadow map rendered by this renderer.
|
float |
getShadowZExtend()
How far the shadows are rendered in the view
|
float |
getShadowZFadeLength()
get the length over which the shadow will fade out when using a
shadowZextend
|
protected void |
initForcedRenderState() |
protected abstract void |
initFrustumCam()
delegates the initialization of the frustum cam to child renderers
|
void |
initialize(RenderManager rm,
ViewPort vp)
Initialize this shadow renderer prior to its first update.
|
boolean |
isFlushQueues()
Deprecated.
|
boolean |
isInitialized()
Test whether this shadow renderer has been initialized.
|
boolean |
isRenderBackFacesShadows()
if this processor renders back faces shadows
|
java.lang.Object |
jmeClone()
Performs a regular shallow clone of the object.
|
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 |
read(JmeImporter im)
De-serialize this instance, for example when loading from a J3O file.
|
protected void |
renderShadowMap(int shadowMapIndex) |
void |
reshape(ViewPort vp,
int w,
int h)
Called when the resolution of the viewport has been changed.
|
void |
setEdgeFilteringMode(EdgeFilteringMode filterMode)
Sets the filtering mode for shadow edges.
|
void |
setEdgesThickness(int edgesThickness)
Sets the shadow edges thickness.
|
protected abstract void |
setMaterialParameters(Material material)
This method is called once per frame and is responsible for setting any
material parameters that subclasses may need to set on the post material.
|
protected void |
setPostShadowMaterial(Material postShadowMat)
set the post shadow material for this renderer
|
protected void |
setPostShadowParams()
for internal use only
|
void |
setProfiler(AppProfiler profiler)
Sets a profiler Instance for this processor.
|
void |
setRenderBackFacesShadows(java.lang.Boolean renderBackFacesShadows)
Set to true if you want back faces shadows on geometries.
|
void |
setShadowCompareMode(CompareMode compareMode)
Sets the shadow compare mode.
|
void |
setShadowIntensity(float shadowIntensity)
Set the shadowIntensity.
|
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.
|
void |
setShadowZFadeLength(float length)
Define the length over which the shadow will fade out when using a
shadowZextend This is useful to make dynamic shadows fade into baked
shadows in the distance.
|
protected abstract void |
updateShadowCams(Camera viewCam)
Invoked once per frame to update the shadow cams according to the light
view.
|
void |
write(JmeExporter ex)
Serialize this instance, for example when saving to a J3O file.
|
protected static final java.util.logging.Logger logger
protected int nbShadowMaps
protected float shadowMapSize
protected float shadowIntensity
protected RenderManager renderManager
protected ViewPort viewPort
protected FrameBuffer[] shadowFB
protected Texture2D[] shadowMaps
protected Texture2D dummyTex
protected Material preshadowMat
protected Material postshadowMat
protected Matrix4f[] lightViewProjectionsMatrices
protected AssetManager assetManager
protected boolean debug
protected float edgesThickness
protected EdgeFilteringMode edgeFilteringMode
protected CompareMode shadowCompareMode
protected Picture[] dispPic
protected RenderState forcedRenderState
protected boolean renderBackFacesShadows
protected AppProfiler prof
protected boolean needsfallBackMaterial
protected java.lang.String postTechniqueName
protected java.util.List<Material> matCache
protected GeometryList lightReceivers
protected GeometryList shadowMapOccluders
protected float zFarOverride
protected Vector2f fadeInfo
protected float fadeLength
protected Camera frustumCam
protected boolean skipPostPass
protected AbstractShadowRenderer()
protected AbstractShadowRenderer(AssetManager assetManager, int shadowMapSize, int nbShadowMaps)
assetManager - the application asset managershadowMapSize - the size of the rendered shadow maps (512,1024,2048,
etc...)nbShadowMaps - the number of shadow maps rendered (the more shadow
maps the more quality, the fewer fps).protected void initForcedRenderState()
protected final void setPostShadowMaterial(Material postShadowMat)
postShadowMat - the desired Material (alias created)public final void setEdgeFilteringMode(EdgeFilteringMode filterMode)
EdgeFilteringMode
for more info.filterMode - the desired filtering mode (not null)public EdgeFilteringMode getEdgeFilteringMode()
EdgeFilteringModepublic final void setShadowCompareMode(CompareMode compareMode)
CompareMode for more info.compareMode - the desired compare mode (not null)public CompareMode getShadowCompareMode()
CompareModeprotected Geometry createFrustum(Vector3f[] pts, int i)
pts - optional storage for vertex positions (may be null)i - the index of the desired wire color (default=White)public void initialize(RenderManager rm, ViewPort vp)
initialize in interface SceneProcessorrm - the render managervp - the viewportprotected abstract void initFrustumCam()
public boolean isInitialized()
isInitialized in interface SceneProcessorprotected abstract void updateShadowCams(Camera viewCam)
viewCam - the scene camprotected abstract GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders)
shadowMapIndex - the index of the shadow map being renderedshadowMapOccluders - the list of occludersprotected abstract Camera getShadowCam(int shadowMapIndex)
shadowMapIndex - the index of the shadow map being renderedprotected void doDisplayFrustumDebug(int shadowMapIndex)
shadowMapIndex - the index of the shadow mappublic void postQueue(RenderQueue rq)
SceneProcessorpostQueue in interface SceneProcessorrq - The render queueprotected void renderShadowMap(int shadowMapIndex)
public void displayFrustum()
protected void displayShadowMap(Renderer r)
r - ignoredpublic void displayDebug()
protected abstract void getReceivers(GeometryList lightReceivers)
public void postFrame(FrameBuffer out)
SceneProcessorpostFrame in interface SceneProcessorout - The FB to which the scene was rendered.protected abstract void clearMaterialParameters(Material material)
material - the material that was used for the post shadow passprotected abstract void setMaterialParameters(Material material)
material - the material to use for the post shadow passprotected void setPostShadowParams()
public float getShadowZExtend()
setShadowZExtend(float zFar)public void setShadowZExtend(float zFar)
zFar - the zFar values that override the computed onepublic void setShadowZFadeLength(float length)
length - the fade length in world unitspublic float getShadowZFadeLength()
protected abstract boolean checkCulling(Camera viewCam)
viewCam - a Camera to define the view frustumpublic void preFrame(float tpf)
SceneProcessorpreFrame in interface SceneProcessortpf - Time per framepublic void cleanup()
SceneProcessorcleanup in interface SceneProcessorpublic void reshape(ViewPort vp, int w, int h)
SceneProcessorreshape in interface SceneProcessorvp - the affected ViewPortw - the new width (in pixels)h - the new height (in pixels)public float getShadowIntensity()
setShadowIntensity(float shadowIntensity)public final void setShadowIntensity(float shadowIntensity)
shadowIntensity - the darkness of the shadowpublic int getEdgesThickness()
setEdgesThickness(int edgesThickness)public int getNumShadowMaps()
public int getShadowMapSize()
public void setEdgesThickness(int edgesThickness)
edgesThickness - the desired thickness (in tenths of a pixel, default=10)@Deprecated public boolean isFlushQueues()
public RenderState getPreShadowForcedRenderState()
public void setRenderBackFacesShadows(java.lang.Boolean renderBackFacesShadows)
Material.setBoolean(String, boolean)
This also will automatically adjust the faceCullMode and the PolyOffset of the pre shadow pass.
You can modify them by using getPreShadowForcedRenderState()renderBackFacesShadows - true or false.public boolean isRenderBackFacesShadows()
public java.lang.Object jmeClone()
JmeCloneableThis 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.
jmeClone in interface JmeCloneablepublic void cloneFields(Cloner cloner, java.lang.Object original)
JmeCloneableNote: during normal clone operations the original object will not be needed as the clone has already had all of the fields shallow copied.
cloneFields in interface JmeCloneablecloner - 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 merely clone what it wants.public void setProfiler(AppProfiler profiler)
SceneProcessorsetProfiler in interface SceneProcessorprofiler - the profiler instance.public void read(JmeImporter im) throws java.io.IOException
public void write(JmeExporter ex) throws java.io.IOException