Package com.jme3.shadow
Class AbstractShadowRendererVR
java.lang.Object
com.jme3.shadow.AbstractShadowRendererVR
- All Implemented Interfaces:
Savable,SceneProcessor
- Direct Known Subclasses:
DirectionalLightShadowRendererVR
Abstract shadow renderer that holds commons feature to have for a shadow
renderer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AssetManagerprotected booleanprotected Picture[]protected Texture2Dprotected EdgeFilteringModeprotected floatprotected Vector2fprotected floatprotected RenderStateprotected Cameraprotected GeometryListprotected Matrix4f[]list of materials for post shadow queue geometriesprotected intprotected booleantrue if the fallback material should be used, otherwise falseprotected Materialprotected Stringname of the post material techniqueprotected Materialprotected AppProfilerprotected booleanprotected RenderManagerprotected CompareModeprotected FrameBuffer[]protected floatprotected GeometryListprotected Texture2D[]protected floatprotected booleantrue to skip the post pass when there are no shadow castersprotected ViewPortprotected floatfade shadows at distance -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedused for serializationprotectedAbstractShadowRendererVR(AssetManager assetManager, int shadowMapSize, int nbShadowMaps) Create an abstract shadow renderer. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleancheckCulling(Camera viewCam) returns true if the light source bounding box is in the view frustumvoidcleanup()Called when the SP is removed from the RM.protected abstract voidclearMaterialParameters(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.protected GeometrycreateFrustum(Vector3f[] pts, int i) debug function to create a visible frustumvoidFor debugging purposes, "snapshot" the current frustum to the scene.voidForce the frustum to be displayed.protected voidFor debugging purposes, display depth shadow maps.protected voiddoDisplayFrustumDebug(int shadowMapIndex) responsible for displaying the frustum of the shadow cam for debug purposeGet the edge filtering mode.intreturns the edges thicknessprotected abstract GeometryListgetOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders) Returns a subclass-specific geometryList containing the occluders to be rendered in the shadow mapReturns the pre shadows pass render state.protected abstract voidgetReceivers(GeometryList lightReceivers) protected abstract CameragetShadowCam(int shadowMapIndex) return the shadow camera to use for rendering the shadow map according the given indexreturns the shadow compare modefloatReturns the shadow intensity.floatHow far the shadows are rendered in the viewfloatget the length over which the shadow will fade out when using a shadowZextendprotected voidprotected abstract voiddelegates the initialization of the frustum cam to child renderersvoidinitialize(RenderManager rm, ViewPort vp) Initialize this shadow renderer prior to its first update.booleanDeprecated.This method does nothing now and is kept only for backward compatibility.booleanTest whether this shadow renderer has been initialized.booleanif this processor renders back faces shadowsvoidpostFrame(FrameBuffer out) Called after a frame has been rendered and the queue flushed.voidpostQueue(RenderQueue rq) Called after the scene graph has been queued, but before it is flushed.voidpreFrame(float tpf) Called before a framevoidread(JmeImporter im) De-serialize this instance, for example when loading from a J3O file.protected voidrenderShadowMap(int shadowMapIndex) voidCalled when the resolution of the viewport has been changed.final voidsetEdgeFilteringMode(EdgeFilteringMode filterMode) Sets the filtering mode for shadow edges.voidsetEdgesThickness(int edgesThickness) Sets the shadow edge thickness.protected abstract voidsetMaterialParameters(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 final voidsetPostShadowMaterial(Material postShadowMat) set the post shadow material for this rendererprotected voidfor internal use onlyvoidsetProfiler(AppProfiler profiler) Sets a profiler Instance for this processor.voidsetRenderBackFacesShadows(Boolean renderBackFacesShadows) Set to true if you want back faces shadows on geometries.final voidsetShadowCompareMode(CompareMode compareMode) Sets the shadow compare mode.final voidsetShadowIntensity(float shadowIntensity) Set the shadowIntensity.voidsetShadowZExtend(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.voidsetShadowZFadeLength(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 voidupdateShadowCams(Camera viewCam) Invoked once per frame to update the shadow cams according to the light view.voidwrite(JmeExporter ex) Serialize this instance, for example when saving to a J3O file.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.jme3.post.SceneProcessor
rescale
-
Field Details
-
nbShadowMaps
protected int nbShadowMaps -
shadowMapSize
protected float shadowMapSize -
shadowIntensity
protected float shadowIntensity -
renderManager
-
viewPort
-
shadowFB
-
shadowMaps
-
dummyTex
-
preshadowMat
-
postshadowMat
-
lightViewProjectionsMatrices
-
assetManager
-
debug
protected boolean debug -
edgesThickness
protected float edgesThickness -
edgeFilteringMode
-
shadowCompareMode
-
dispPic
-
forcedRenderState
-
renderBackFacesShadows
protected boolean renderBackFacesShadows -
profiler
-
needsfallBackMaterial
protected boolean needsfallBackMaterialtrue if the fallback material should be used, otherwise false -
postTechniqueName
name of the post material technique -
matCache
list of materials for post shadow queue geometries -
lightReceivers
-
shadowMapOccluders
-
zFarOverride
protected float zFarOverridefade shadows at distance -
fadeInfo
-
fadeLength
protected float fadeLength -
frustumCam
-
skipPostPass
protected boolean skipPostPasstrue to skip the post pass when there are no shadow casters
-
-
Constructor Details
-
AbstractShadowRendererVR
protected AbstractShadowRendererVR()used for serialization -
AbstractShadowRendererVR
Create an abstract shadow renderer. Subclasses invoke this constructor.- Parameters:
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).
-
-
Method Details
-
initForcedRenderState
protected void initForcedRenderState() -
setPostShadowMaterial
set the post shadow material for this renderer- Parameters:
postShadowMat-
-
setEdgeFilteringMode
Sets the filtering mode for shadow edges. SeeEdgeFilteringModefor more info.- Parameters:
filterMode- the desired filter mode (not null)
-
getEdgeFilteringMode
Get the edge filtering mode.- Returns:
- the edge filtering mode.
-
setShadowCompareMode
Sets the shadow compare mode. SeeCompareModefor more info.- Parameters:
compareMode- the desired compare mode (not null)
-
getShadowCompareMode
returns the shadow compare mode- Returns:
- the shadowCompareMode
- See Also:
-
createFrustum
debug function to create a visible frustum -
initialize
Initialize this shadow renderer prior to its first update.- Specified by:
initializein interfaceSceneProcessor- Parameters:
rm- the render managervp- the viewport
-
initFrustumCam
protected abstract void initFrustumCam()delegates the initialization of the frustum cam to child renderers -
isInitialized
public boolean isInitialized()Test whether this shadow renderer has been initialized.- Specified by:
isInitializedin interfaceSceneProcessor- Returns:
- true if initialized, otherwise false
-
updateShadowCams
Invoked once per frame to update the shadow cams according to the light view.- Parameters:
viewCam- the scene cam
-
getOccludersToRender
protected abstract GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders) Returns a subclass-specific geometryList containing the occluders to be rendered in the shadow map- Parameters:
shadowMapIndex- the index of the shadow map being renderedshadowMapOccluders- the list of occluders- Returns:
- a list of occluders
-
getShadowCam
return the shadow camera to use for rendering the shadow map according the given index- Parameters:
shadowMapIndex- the index of the shadow map being rendered- Returns:
- the shadowCam
-
setProfiler
Description copied from interface:SceneProcessorSets a profiler Instance for this processor.- Specified by:
setProfilerin interfaceSceneProcessor- Parameters:
profiler- the profiler instance.
-
doDisplayFrustumDebug
protected void doDisplayFrustumDebug(int shadowMapIndex) responsible for displaying the frustum of the shadow cam for debug purpose- Parameters:
shadowMapIndex-
-
postQueue
Description copied from interface:SceneProcessorCalled after the scene graph has been queued, but before it is flushed.- Specified by:
postQueuein interfaceSceneProcessor- Parameters:
rq- The render queue
-
renderShadowMap
protected void renderShadowMap(int shadowMapIndex) -
displayFrustum
public void displayFrustum()Force the frustum to be displayed. -
displayShadowMap
For debugging purposes, display depth shadow maps. -
displayDebug
public void displayDebug()For debugging purposes, "snapshot" the current frustum to the scene. -
getReceivers
-
postFrame
Description copied from interface:SceneProcessorCalled after a frame has been rendered and the queue flushed.- Specified by:
postFramein interfaceSceneProcessor- Parameters:
out- The FB to which the scene was rendered.
-
clearMaterialParameters
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.- Parameters:
material- the material that was used for the post shadow pass
-
setMaterialParameters
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.- Parameters:
material- the material to use for the post shadow pass
-
setPostShadowParams
protected void setPostShadowParams()for internal use only -
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 This is useful to make dynamic shadows fade into baked shadows in the distance.- 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
-
checkCulling
returns true if the light source bounding box is in the view frustum- Returns:
- true if box in frustum
-
preFrame
public void preFrame(float tpf) Description copied from interface:SceneProcessorCalled before a frame- Specified by:
preFramein interfaceSceneProcessor- Parameters:
tpf- Time per frame
-
cleanup
public void cleanup()Description copied from interface:SceneProcessorCalled when the SP is removed from the RM.- Specified by:
cleanupin interfaceSceneProcessor
-
reshape
Description copied from interface:SceneProcessorCalled when the resolution of the viewport has been changed.- Specified by:
reshapein interfaceSceneProcessor- Parameters:
vp- the affected ViewPortw- the new width (in pixels)h- the new height (in pixels)
-
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. The 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 edge thickness. Default is 1. Setting it to lower values can help to reduce the jagged effect of the shadow edges.- Parameters:
edgesThickness- the shadow edge thickness.
-
isFlushQueues
Deprecated.This method does nothing now and is kept only for backward compatibility.This method does nothing now and is kept only for backward compatibility.- Returns:
false
-
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.
-
setRenderBackFacesShadows
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. Also note that setting this parameter will override this parameter for ALL materials in the scene. You can alternatively change this parameter on a single material usingMaterial.setBoolean(String, boolean)This also will automatically adjust the faceCullMode and the PolyOffset of the pre shadow pass. You can modify them by usinggetPreShadowForcedRenderState()- Parameters:
renderBackFacesShadows- true or false.
-
isRenderBackFacesShadows
public boolean isRenderBackFacesShadows()if this processor renders back faces shadows- Returns:
- true if this processor renders back faces shadows
-
read
De-serialize this instance, for example when loading from a J3O file.- Specified by:
readin interfaceSavable- Parameters:
im- importer (not null)- Throws:
IOException
-
write
Serialize this instance, for example when saving to a J3O file.- Specified by:
writein interfaceSavable- Parameters:
ex- exporter (not null)- Throws:
IOException
-