Package com.jme3.post
Class Filter
java.lang.Object
com.jme3.post.Filter
- All Implemented Interfaces:
Savable
- Direct Known Subclasses:
AbstractShadowFilter
,AbstractShadowFilterVR
,BloomFilter
,CartoonEdgeFilter
,CartoonSSAO
,ColorOverlayFilter
,ComposeFilter
,ContrastAdjustmentFilter
,CrossHatchFilter
,DepthOfFieldFilter
,FadeFilter
,FogFilter
,FXAAFilter
,GammaCorrectionFilter
,LightScatteringFilter
,PosterizationFilter
,PssmShadowFilter
,RadialBlurFilter
,SSAOFilter
,ToneMapFilter
,TranslucentBucketFilter
,WaterFilter
Filters are 2D effects applied to the rendered scene.
The filter is fed with the rendered scene image rendered in an offscreen frame buffer.
This texture is applied on a full-screen quad with a special material.
This material uses a shader that applies the desired effect to the scene texture.
This class is abstract, any Filter must extend it.
Any filter holds a frameBuffer and a texture
The getMaterial must return a Material that use a GLSL shader implementing the desired effect
The filter is fed with the rendered scene image rendered in an offscreen frame buffer.
This texture is applied on a full-screen quad with a special material.
This material uses a shader that applies the desired effect to the scene texture.
This class is abstract, any Filter must extend it.
Any filter holds a frameBuffer and a texture
The getMaterial must return a Material that use a GLSL shader implementing the desired effect
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected Filter.Pass
protected boolean
protected Material
protected List<Filter.Pass>
protected FilterPostProcessor
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final void
cleanup this filterprotected void
override this method if you have some cleanup to doprotected Image.Format
returns the default pass depth formatprotected Image.Format
protected abstract Material
Must return the material used for this filter.getName()
returns the name of the filterprotected List<Filter.Pass>
returns the list of the postRender passesprotected Texture2D
returns the rendered texture of this filterprotected FrameBuffer
returns the default pass frame bufferprotected final void
init
(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) initialize this filter use InitFilter for overriding filter initializationprotected abstract void
initFilter
(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) Initialization of filter subclasses.boolean
returns true if the filter is enabledprotected boolean
Override this method and return true if you want the scene (input) texture to use bilinear filtering or false to use nearest filtering.protected boolean
Override this method and return true if your Filter needs the depth textureprotected boolean
Override this method and return false if your Filter does not need the scene textureprotected void
postFilter
(Renderer r, FrameBuffer buffer) This method is called right after the filter has been rendered to the framebuffer.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);protected void
setDepthTexture
(Texture depthTexture) Override if you want to do something special with the depth texture;void
setEnabled
(boolean enabled) Enable or disable this filtervoid
Sets the name of the filterprotected void
sets a reference to the FilterPostProcessor to which this filter is attachedprotected void
setRenderedTexture
(Texture2D renderedTexture) sets the rendered texture of this filterprotected void
setRenderFrameBuffer
(FrameBuffer renderFrameBuffer) sets the default pass frame buffervoid
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);
-
Field Details
-
defaultPass
-
postRenderPasses
-
material
-
enabled
protected boolean enabled -
processor
-
-
Constructor Details
-
Filter
-
Filter
protected Filter()construct a Filter
-
-
Method Details
-
getDefaultPassTextureFormat
- Returns:
- the default pass texture format
-
getDefaultPassDepthFormat
returns the default pass depth format- Returns:
- the enum value
-
init
protected final void init(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) initialize this filter use InitFilter for overriding filter initialization- Parameters:
manager
- the assetManagerrenderManager
- the renderManagervp
- the viewportw
- the widthh
- the height
-
cleanup
cleanup this filter- Parameters:
r
- the Renderer
-
initFilter
protected abstract void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) 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- Parameters:
manager
- the assetManagerrenderManager
- the renderManagervp
- the viewPort where this filter is renderedw
- the width of the filterh
- the height of the filter
-
cleanUpFilter
override this method if you have some cleanup to do- Parameters:
r
- the renderer
-
getMaterial
Must return the material used for this filter. this method is called every frame.- Returns:
- the material used for this filter.
-
setDepthTexture
Override if you want to do something special with the depth texture;- Parameters:
depthTexture
- the desired Texture
-
postQueue
Override this method if you want to make a pre pass, before the actual rendering of the frame- Parameters:
queue
- the RenderQueue
-
preFrame
protected void preFrame(float tpf) 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- Parameters:
tpf
- the time used to render the previous frame
-
postFrame
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 rendering- Parameters:
renderManager
- for renderingviewPort
- for renderingprevFilterBuffer
- the FrameBuffer of the previous filtersceneBuffer
- the FrameBuffer of the scene
-
write
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
- Parameters:
ex
- the exporter (not null)- Throws:
IOException
- from the exporter
-
read
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
- Throws:
IOException
-
getName
returns the name of the filter- Returns:
- the Filter's name
-
setName
Sets the name of the filter- Parameters:
name
- the desired name (alias created)
-
getRenderFrameBuffer
returns the default pass frame buffer- Returns:
- the pre-existing buffer
-
setRenderFrameBuffer
sets the default pass frame buffer- Parameters:
renderFrameBuffer
- the buffer to use (alias created)
-
getRenderedTexture
returns the rendered texture of this filter- Returns:
- the pre-existing texture
-
setRenderedTexture
sets the rendered texture of this filter- Parameters:
renderedTexture
- the desired Texture (alias created)
-
isRequiresDepthTexture
protected boolean isRequiresDepthTexture()Override this method and return true if your Filter needs the depth texture- Returns:
- true if your Filter need the depth texture
-
isRequiresSceneTexture
protected boolean isRequiresSceneTexture()Override this method and return false if your Filter does not need the scene texture- Returns:
- false if your Filter does not need the scene texture
-
isRequiresBilinear
protected boolean isRequiresBilinear()Override this method and return true if you want the scene (input) texture to use bilinear filtering or false to use nearest filtering. Typically, filters that perform samples in between pixels should enable bilinear filtering.- Returns:
- true to use linear filtering, false to use nearest filtering.
-
getPostRenderPasses
returns the list of the postRender passes- Returns:
- the pre-existing List
-
setEnabled
public void setEnabled(boolean enabled) Enable or disable this filter- Parameters:
enabled
- true to enable
-
isEnabled
public boolean isEnabled()returns true if the filter is enabled- Returns:
- enabled
-
setProcessor
sets a reference to the FilterPostProcessor to which this filter is attached- Parameters:
proc
- the desired FPP (alias created)
-
postFilter
This method is called right after the filter has been rendered to the framebuffer. Note that buffer will be null if the filter is the last one in the stack and has been rendered to screen- Parameters:
r
- the rendererbuffer
- the framebuffer on which the filter has been rendered.
-