com.jme3.post
Class Filter

java.lang.Object
  extended by com.jme3.post.Filter
All Implemented Interfaces:
Savable
Direct Known Subclasses:
BloomFilter, CartoonEdgeFilter, ColorOverlayFilter, CrossHatchFilter, DepthOfFieldFilter, FadeFilter, FogFilter, FXAAFilter, GammaCorrectionFilter, LightScatteringFilter, PosterizationFilter, RadialBlurFilter, SSAOFilter, TranslucentBucketFilter, WaterFilter

public abstract class Filter
extends java.lang.Object
implements Savable

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 fullscreen quad, with a special material.
This material uses a shader that aplly 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 immplementing the desired effect


Nested Class Summary
 class Filter.Pass
          Inner class Pass Pass are like filters in filters.
 
Field Summary
protected  Filter.Pass defaultPass
           
protected  boolean enabled
           
protected  Material material
           
protected  java.util.List<Filter.Pass> postRenderPasses
           
protected  FilterPostProcessor processor
           
 
Constructor Summary
protected Filter()
          contruct a Filter
  Filter(java.lang.String name)
           
 
Method Summary
protected  void cleanup(Renderer r)
          cleanup this filter
protected  void cleanUpFilter(Renderer r)
          override this method if you have some cleanup to do
protected  Image.Format getDefaultPassDepthFormat()
          returns the default pass depth format
protected  Image.Format getDefaultPassTextureFormat()
          returns the default pass texture format
protected abstract  Material getMaterial()
          Must return the material used for this filter.
 java.lang.String getName()
          returns the name of the filter
protected  java.util.List<Filter.Pass> getPostRenderPasses()
          returns the list of the postRender passes
protected  Texture2D getRenderedTexture()
          returns the rendered texture of this filter
protected  FrameBuffer getRenderFrameBuffer()
          returns the default pass frame buffer
protected  void init(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h)
          initialize this filter use InitFilter for overriding filter initialization
protected abstract  void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h)
          Initialization of sub classes filters This method is called once when the filter is added to the FilterPostProcessor It should contain Material initializations and extra passes initialization
 boolean isEnabled()
          returns ttrue if the filter is enabled
protected  boolean isRequiresDepthTexture()
          Override this method and return true if your Filter needs the depth texture
protected  boolean isRequiresSceneTexture()
          Override this method and return false if your Filter does not need the scene texture
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
protected  void postQueue(RenderManager renderManager, ViewPort viewPort)
          Override this method if you want to make a pre pass, before the actual rendering of the frame
protected  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 filter
 void setName(java.lang.String name)
          Sets the name of the filter
protected  void setProcessor(FilterPostProcessor proc)
          sets a reference to the FilterPostProcessor ti which this filter is attached
protected  void setRenderedTexture(Texture2D renderedTexture)
          sets the rendered texture of this filter
protected  void setRenderFrameBuffer(FrameBuffer renderFrameBuffer)
          sets the default pas frame buffer
 void 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);
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultPass

protected Filter.Pass defaultPass

postRenderPasses

protected java.util.List<Filter.Pass> postRenderPasses

material

protected Material material

enabled

protected boolean enabled

processor

protected FilterPostProcessor processor
Constructor Detail

Filter

public Filter(java.lang.String name)

Filter

protected Filter()
contruct a Filter

Method Detail

getDefaultPassTextureFormat

protected Image.Format getDefaultPassTextureFormat()
returns the default pass texture format

Returns:

getDefaultPassDepthFormat

protected Image.Format getDefaultPassDepthFormat()
returns the default pass depth format

Returns:

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 assetManager
renderManager - the renderManager
vp - the viewport
w - the width
h - the height

cleanup

protected final void cleanup(Renderer r)
cleanup this filter

Parameters:
r -

initFilter

protected abstract void initFilter(AssetManager manager,
                                   RenderManager renderManager,
                                   ViewPort vp,
                                   int w,
                                   int h)
Initialization of sub classes filters 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 assetManager
renderManager - the renderManager
vp - the viewPort where this filter is rendered
w - the width of the filter
h - the height of the filter

cleanUpFilter

protected void cleanUpFilter(Renderer r)
override this method if you have some cleanup to do

Parameters:
r - the renderer

getMaterial

protected abstract Material getMaterial()
Must return the material used for this filter. this method is called every frame.

Returns:
the material used for this filter.

setDepthTexture

protected void setDepthTexture(Texture depthTexture)
Override if you want to do something special with the depth texture;

Parameters:
depthTexture -

postQueue

protected void postQueue(RenderManager renderManager,
                         ViewPort viewPort)
Override this method if you want to make a pre pass, before the actual rendering of the frame

Parameters:
renderManager -
viewPort -

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 usefull 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 -
viewPort -
prevFilterBuffer -
sceneBuffer -

write

public void write(JmeExporter ex)
           throws java.io.IOException
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 interface Savable
Parameters:
ex -
Throws:
java.io.IOException

read

public void read(JmeImporter im)
          throws java.io.IOException
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 interface Savable
Throws:
java.io.IOException

getName

public java.lang.String getName()
returns the name of the filter

Returns:
the Filter's name

setName

public void setName(java.lang.String name)
Sets the name of the filter

Parameters:
name -

getRenderFrameBuffer

protected FrameBuffer getRenderFrameBuffer()
returns the default pass frame buffer

Returns:

setRenderFrameBuffer

protected void setRenderFrameBuffer(FrameBuffer renderFrameBuffer)
sets the default pas frame buffer

Parameters:
renderFrameBuffer -

getRenderedTexture

protected Texture2D getRenderedTexture()
returns the rendered texture of this filter

Returns:

setRenderedTexture

protected void setRenderedTexture(Texture2D renderedTexture)
sets the rendered texture of this filter

Parameters:
renderedTexture -

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

getPostRenderPasses

protected java.util.List<Filter.Pass> getPostRenderPasses()
returns the list of the postRender passes

Returns:

setEnabled

public void setEnabled(boolean enabled)
Enable or disable this filter

Parameters:
enabled - true to enable

isEnabled

public boolean isEnabled()
returns ttrue if the filter is enabled

Returns:
enabled

setProcessor

protected void setProcessor(FilterPostProcessor proc)
sets a reference to the FilterPostProcessor ti which this filter is attached

Parameters:
proc -