Who let the doc out?

- javadoc for com.jme.post
- javadoc for com.jme.post.filters
remain SSAO, Water, shadows and HDR to complete the package

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7618 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 14 years ago
parent e90d01d6e2
commit 86eb9b5173
  1. 175
      engine/src/core/com/jme3/post/Filter.java
  2. 70
      engine/src/core/com/jme3/post/FilterPostProcessor.java
  3. 11
      engine/src/core/com/jme3/post/SceneProcessor.java
  4. 75
      engine/src/desktop-fx/com/jme3/post/filters/BloomFilter.java
  5. 81
      engine/src/desktop-fx/com/jme3/post/filters/CartoonEdgeFilter.java
  6. 28
      engine/src/desktop-fx/com/jme3/post/filters/ColorOverlayFilter.java
  7. 81
      engine/src/desktop-fx/com/jme3/post/filters/CrossHatchFilter.java
  8. 26
      engine/src/desktop-fx/com/jme3/post/filters/DepthOfFieldFilter.java
  9. 46
      engine/src/desktop-fx/com/jme3/post/filters/FadeFilter.java
  10. 16
      engine/src/desktop-fx/com/jme3/post/filters/FogFilter.java
  11. 78
      engine/src/desktop-fx/com/jme3/post/filters/LightScatteringFilter.java
  12. 39
      engine/src/desktop-fx/com/jme3/post/filters/PosterizationFilter.java
  13. 56
      engine/src/desktop-fx/com/jme3/post/filters/RadialBlurFilter.java
  14. 16
      engine/src/desktop-fx/com/jme3/post/filters/TranslucentBucketFilter.java
  15. 12
      engine/src/desktop-fx/com/jme3/post/ssao/SSAOFilter.java
  16. 27
      engine/src/desktop-fx/com/jme3/water/WaterFilter.java

@ -51,10 +51,16 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
/** /**
* Filter abstract class * Filters are 2D effects applied to the rendered scene.<br>
* Any Filter must extends this class * The filter is fed with the rendered scene image rendered in an offscreen frame buffer.<br>
* Holds a frameBuffer and a texture * This texture is applied on a fullscreen quad, with a special material.<br>
* The getMaterial must return a Material that use a GLSL shader immplementing the desired effect * This material uses a shader that aplly the desired effect to the scene texture.<br>
* <br>
* This class is abstract, any Filter must extend it.<br>
* Any filter holds a frameBuffer and a texture<br>
* The getMaterial must return a Material that use a GLSL shader immplementing the desired effect<br>
*
* @author Rémy Bouquet aka Nehon
*/ */
public abstract class Filter implements Savable { public abstract class Filter implements Savable {
@ -69,6 +75,11 @@ public abstract class Filter implements Savable {
this.name = name; this.name = name;
} }
/**
* Inner class Pass
* Pass are like filters in filters.
* Some filters will need multiple passes before the final render
*/
public class Pass { public class Pass {
protected FrameBuffer renderFrameBuffer; protected FrameBuffer renderFrameBuffer;
@ -76,28 +87,52 @@ public abstract class Filter implements Savable {
protected Texture2D depthTexture; protected Texture2D depthTexture;
protected Material passMaterial; protected Material passMaterial;
/**
* init the pass called internally
* @param renderer
* @param width
* @param height
* @param textureFormat
* @param depthBufferFormat
* @param numSamples
*/
public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSamples) { public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSamples) {
Collection<Caps> caps = renderer.getCaps(); Collection<Caps> caps = renderer.getCaps();
if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample) && caps.contains(Caps.OpenGL31)) { if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample) && caps.contains(Caps.OpenGL31)) {
renderFrameBuffer = new FrameBuffer(width, height, numSamples); renderFrameBuffer = new FrameBuffer(width, height, numSamples);
renderedTexture = new Texture2D(width, height, numSamples, textureFormat); renderedTexture = new Texture2D(width, height, numSamples, textureFormat);
// depthTexture = new Texture2D(width, height, numSamples, depthBufferFormat);
} else { } else {
renderFrameBuffer = new FrameBuffer(width, height, 1); renderFrameBuffer = new FrameBuffer(width, height, 1);
renderedTexture = new Texture2D(width, height, textureFormat); renderedTexture = new Texture2D(width, height, textureFormat);
// depthTexture = new Texture2D(width, height, depthBufferFormat);
} }
renderFrameBuffer.setColorTexture(renderedTexture); renderFrameBuffer.setColorTexture(renderedTexture);
renderFrameBuffer.setDepthBuffer(depthBufferFormat); renderFrameBuffer.setDepthBuffer(depthBufferFormat);
// renderFrameBuffer.setDepthTexture(depthTexture);
} }
/**
* init the pass called internally
* @param renderer
* @param width
* @param height
* @param textureFormat
* @param depthBufferFormat
*/
public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat) { public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat) {
init(renderer, width, height, textureFormat, depthBufferFormat, 1); init(renderer, width, height, textureFormat, depthBufferFormat, 1);
} }
/**
* init the pass called internally
* @param renderer
* @param width
* @param height
* @param textureFormat
* @param depthBufferFormat
* @param numSample
* @param material
*/
public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSample, Material material) { public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSample, Material material) {
init(renderer, width, height, textureFormat, depthBufferFormat, numSample); init(renderer, width, height, textureFormat, depthBufferFormat, numSample);
passMaterial = material; passMaterial = material;
@ -146,26 +181,51 @@ public abstract class Filter implements Savable {
} }
} }
/**
* returns the default pass texture format
* @return
*/
protected Format getDefaultPassTextureFormat() { protected Format getDefaultPassTextureFormat() {
return Format.RGBA8; return Format.RGBA8;
} }
/**
* returns the default pass depth format
* @return
*/
protected Format getDefaultPassDepthFormat() { protected Format getDefaultPassDepthFormat() {
return Format.Depth; return Format.Depth;
} }
public Filter() { /**
* contruct a Filter
*/
protected Filter() {
this("filter"); this("filter");
} }
public void init(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { /**
*
* initialize this filter
* use InitFilter for overriding filter initialization
* @param manager the assetManager
* @param renderManager the renderManager
* @param vp the viewport
* @param w the width
* @param h the height
*/
protected final void init(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
// cleanup(renderManager.getRenderer()); // cleanup(renderManager.getRenderer());
defaultPass = new Pass(); defaultPass = new Pass();
defaultPass.init(renderManager.getRenderer(), w, h, getDefaultPassTextureFormat(), getDefaultPassDepthFormat()); defaultPass.init(renderManager.getRenderer(), w, h, getDefaultPassTextureFormat(), getDefaultPassDepthFormat());
initFilter(manager, renderManager, vp, w, h); initFilter(manager, renderManager, vp, w, h);
} }
public void cleanup(Renderer r) { /**
* cleanup this filter
* @param r
*/
protected final void cleanup(Renderer r) {
processor = null; processor = null;
if (defaultPass != null) { if (defaultPass != null) {
defaultPass.cleanup(r); defaultPass.cleanup(r);
@ -180,36 +240,49 @@ public abstract class Filter implements Savable {
} }
/** /**
* This method is called once xhen the filter is added to the FilterPostProcessor * Initialization of sub classes filters
* It should contain Maerial initializations and extra passes initialization * This method is called once when the filter is added to the FilterPostProcessor
* @param manager * It should contain Material initializations and extra passes initialization
* @param manager the assetManager
* @param renderManager the renderManager
* @param vp the viewPort where this filter is rendered
* @param w the width of the filter
* @param h the height of the filter
*/
protected abstract void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h);
/**
* override this method if you have some cleanup to do
* @param r the renderer
*/ */
public abstract void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h); protected void cleanUpFilter(Renderer r) {
}
public abstract void cleanUpFilter(Renderer r); ;
/** /**
* Returns the material used for this filter. * Must return the material used for this filter.
* this method is called every frame. * this method is called every frame.
* *
* @return the material used for this filter. * @return the material used for this filter.
*/ */
public abstract Material getMaterial(); protected abstract Material getMaterial();
/** /**
* Override this method if you want to make a pre pass, before the actual rendering of the frame * Override this method if you want to make a pre pass, before the actual rendering of the frame
* @param renderManager * @param renderManager
* @param viewPort * @param viewPort
*/ */
public void postQueue(RenderManager renderManager, ViewPort viewPort) { protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
} }
/** /**
* Use this method if you want to modify parameters according to tpf before the rendering of the frame. * Override this method if you want to modify parameters according to tpf before the rendering of the frame.
* This is usefull for animated filters * This is usefull for animated filters
* Also it can be the place to render pre passes
* @param tpf the time used to render the previous frame * @param tpf the time used to render the previous frame
*/ */
public void preFrame(float tpf) { protected void preFrame(float tpf) {
} }
/** /**
@ -217,7 +290,7 @@ public abstract class Filter implements Savable {
* @param renderManager * @param renderManager
* @param viewPort * @param viewPort
*/ */
public void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) { protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
} }
/** /**
@ -243,36 +316,60 @@ public abstract class Filter implements Savable {
enabled = ic.readBoolean("enabled", true); enabled = ic.readBoolean("enabled", true);
} }
/**
* returns the name of the filter
* @return
*/
public String getName() { public String getName() {
return name; return name;
} }
/**
* Sets the name of the filter
* @param name
*/
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public FrameBuffer getRenderFrameBuffer() { /**
* returns the default pass frame buffer
* @return
*/
protected FrameBuffer getRenderFrameBuffer() {
return defaultPass.renderFrameBuffer; return defaultPass.renderFrameBuffer;
} }
public void setRenderFrameBuffer(FrameBuffer renderFrameBuffer) { /**
* sets the default pas frame buffer
* @param renderFrameBuffer
*/
protected void setRenderFrameBuffer(FrameBuffer renderFrameBuffer) {
this.defaultPass.renderFrameBuffer = renderFrameBuffer; this.defaultPass.renderFrameBuffer = renderFrameBuffer;
} }
public Texture2D getRenderedTexture() { /**
* returns the rendered texture of this filter
* @return
*/
protected Texture2D getRenderedTexture() {
return defaultPass.renderedTexture; return defaultPass.renderedTexture;
} }
public void setRenderedTexture(Texture2D renderedTexture) { /**
* sets the rendered texture of this filter
* @param renderedTexture
*/
protected void setRenderedTexture(Texture2D renderedTexture) {
this.defaultPass.renderedTexture = renderedTexture; this.defaultPass.renderedTexture = renderedTexture;
} }
/** /**
* Override this method and return true if your Filter need the depth texture * Override this method and return true if your Filter needs the depth texture
* *
* @return true if your Filter need the depth texture * @return true if your Filter need the depth texture
*/ */
public boolean isRequiresDepthTexture() { protected boolean isRequiresDepthTexture() {
return false; return false;
} }
@ -281,18 +378,22 @@ public abstract class Filter implements Savable {
* *
* @return false if your Filter does not need the scene texture * @return false if your Filter does not need the scene texture
*/ */
public boolean isRequiresSceneTexture() { protected boolean isRequiresSceneTexture() {
return true; return true;
} }
public List<Pass> getPostRenderPasses() { /**
* returns the list of the postRender passes
* @return
*/
protected List<Pass> getPostRenderPasses() {
return postRenderPasses; return postRenderPasses;
} }
public void setPostRenderPasses(List<Pass> postRenderPasses) { /**
this.postRenderPasses = postRenderPasses; * Enable or disable this filter
} * @param enabled true to enable
*/
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
if (processor != null) { if (processor != null) {
processor.setFilterState(this, enabled); processor.setFilterState(this, enabled);
@ -301,10 +402,18 @@ public abstract class Filter implements Savable {
} }
} }
/**
* returns ttrue if the filter is enabled
* @return enabled
*/
public boolean isEnabled() { public boolean isEnabled() {
return enabled; return enabled;
} }
/**
* sets a reference to the FilterPostProcessor ti which this filter is attached
* @param proc
*/
protected void setProcessor(FilterPostProcessor proc) { protected void setProcessor(FilterPostProcessor proc) {
processor = proc; processor = proc;
} }

@ -55,6 +55,11 @@ import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
/**
* A FilterPostProcessor is a processor that can apply several {@link Filter}s to a rendered scene<br>
* It manages a list of filters that will be applied in the order in which they've been added to the list
* @author Rémy Bouquet aka Nehon
*/
public class FilterPostProcessor implements SceneProcessor, Savable { public class FilterPostProcessor implements SceneProcessor, Savable {
private RenderManager renderManager; private RenderManager renderManager;
@ -81,25 +86,26 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
private int originalHeight; private int originalHeight;
private int lastFilterIndex = -1; private int lastFilterIndex = -1;
private boolean cameraInit = false; private boolean cameraInit = false;
// private boolean handleTranslucentBucket = false;
// private FrameBuffer transFrameBuffer;
// private Material transMaterial;
// private boolean isTransparencyRendered=false;
/** /**
* Create a FilterProcessor constructor * Create a FilterProcessor
* @param assetManager the Asset Manager * @param assetManager the assetManager
*/ */
public FilterPostProcessor(AssetManager assetManager) { public FilterPostProcessor(AssetManager assetManager) {
this.assetManager = assetManager; this.assetManager = assetManager;
} }
/** /**
* Don't use this constructor use FilterPostProcessor(AssetManager assetManager) * Don't use this constructor use {@link FilterPostProcessor(AssetManager assetManager)}<br>
* This constructor is used for serialization only
*/ */
public FilterPostProcessor() { public FilterPostProcessor() {
} }
/**
* Adds a filter to the filters list<br>
* @param filter the filter to add
*/
public void addFilter(Filter filter) { public void addFilter(Filter filter) {
filters.add(filter); filters.add(filter);
filter.setProcessor(this); filter.setProcessor(this);
@ -112,6 +118,10 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
} }
/**
* removes this filters from the filters list
* @param filter
*/
public void removeFilter(Filter filter) { public void removeFilter(Filter filter) {
for (Iterator<Filter> it = filters.iterator(); it.hasNext();) { for (Iterator<Filter> it = filters.iterator(); it.hasNext();) {
if (it.next() == filter) { if (it.next() == filter) {
@ -140,6 +150,11 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
reshape(vp, cam.getWidth(), cam.getHeight()); reshape(vp, cam.getWidth(), cam.getHeight());
} }
/**
* init the given filter
* @param filter
* @param vp
*/
private void initFilter(Filter filter, ViewPort vp) { private void initFilter(Filter filter, ViewPort vp) {
filter.init(assetManager, renderManager, vp, width, height); filter.init(assetManager, renderManager, vp, width, height);
if (filter.isRequiresDepthTexture()) { if (filter.isRequiresDepthTexture()) {
@ -152,6 +167,12 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
} }
} }
/**
* renders a filter on a fullscreen quad
* @param r
* @param buff
* @param mat
*/
private void renderProcessing(Renderer r, FrameBuffer buff, Material mat) { private void renderProcessing(Renderer r, FrameBuffer buff, Material mat) {
if (buff == outputBuffer) { if (buff == outputBuffer) {
fsQuad.setWidth(width); fsQuad.setWidth(width);
@ -199,7 +220,12 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
} }
Picture pic = new Picture("debug"); Picture pic = new Picture("debug");
public void renderFilterChain(Renderer r, FrameBuffer sceneFb) { /**
* iterate through the filter list and renders filters
* @param r
* @param sceneFb
*/
private void renderFilterChain(Renderer r, FrameBuffer sceneFb) {
Texture2D tex = filterTexture; Texture2D tex = filterTexture;
FrameBuffer buff = sceneFb; FrameBuffer buff = sceneFb;
boolean msDepth = depthTexture != null && depthTexture.getImage().getMultiSamples() > 1; boolean msDepth = depthTexture != null && depthTexture.getImage().getMultiSamples() > 1;
@ -305,6 +331,11 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
} }
/**
* sets the filter to enabled or disabled
* @param filter
* @param enabled
*/
protected void setFilterState(Filter filter, boolean enabled) { protected void setFilterState(Filter filter, boolean enabled) {
if (filters.contains(filter)) { if (filters.contains(filter)) {
filter.enabled = enabled; filter.enabled = enabled;
@ -312,6 +343,9 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
} }
} }
/**
* compute the index of the last filter to render
*/
private void updateLastFilterIndex() { private void updateLastFilterIndex() {
lastFilterIndex = -1; lastFilterIndex = -1;
for (int i = filters.size() - 1; i >= 0 && lastFilterIndex == -1; i--) { for (int i = filters.size() - 1; i >= 0 && lastFilterIndex == -1; i--) {
@ -423,32 +457,32 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
this.assetManager = assetManager; this.assetManager = assetManager;
} }
/**
* Writes the processor
* @param ex
* @throws IOException
*/
public void write(JmeExporter ex) throws IOException { public void write(JmeExporter ex) throws IOException {
OutputCapsule oc = ex.getCapsule(this); OutputCapsule oc = ex.getCapsule(this);
oc.write(numSamples, "numSamples", 0); oc.write(numSamples, "numSamples", 0);
oc.writeSavableArrayList((ArrayList) filters, "filters", null); oc.writeSavableArrayList((ArrayList) filters, "filters", null);
} }
/**
* Reads the processor
* @param im
* @throws IOException
*/
public void read(JmeImporter im) throws IOException { public void read(JmeImporter im) throws IOException {
InputCapsule ic = im.getCapsule(this); InputCapsule ic = im.getCapsule(this);
numSamples = ic.readInt("numSamples", 0); numSamples = ic.readInt("numSamples", 0);
filters = ic.readSavableArrayList("filters", null); filters = ic.readSavableArrayList("filters", null);
} }
/**
* For internal use only<br>
* returns the depth texture of the scene
* @return
*/
public Texture2D getDepthTexture() { public Texture2D getDepthTexture() {
return depthTexture; return depthTexture;
} }
/**
* For internal use only<br>
* returns the rendered texture of the scene
* @return
*/
public Texture2D getFilterTexture() { public Texture2D getFilterTexture() {
return filterTexture; return filterTexture;
} }

@ -37,9 +37,15 @@ import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue; import com.jme3.renderer.queue.RenderQueue;
import com.jme3.texture.FrameBuffer; import com.jme3.texture.FrameBuffer;
/**
* Scene processors are used to compute/render things before and after the classic render of the scene.
* They have to be added to a viewport and are rendered in the order they've been added
* @author Kirill Vainer aka Shadowislord aka Momoko_Fan
*/
public interface SceneProcessor { public interface SceneProcessor {
/** /**
* For internal use only<br>
* Called in the render thread to initialize the scene processor. * Called in the render thread to initialize the scene processor.
* *
* @param rm The render manager to which the SP was added to * @param rm The render manager to which the SP was added to
@ -48,6 +54,7 @@ public interface SceneProcessor {
public void initialize(RenderManager rm, ViewPort vp); public void initialize(RenderManager rm, ViewPort vp);
/** /**
* For internal use only<br>
* Called when the resolution of the viewport has been changed. * Called when the resolution of the viewport has been changed.
* @param vp * @param vp
*/ */
@ -60,6 +67,7 @@ public interface SceneProcessor {
public boolean isInitialized(); public boolean isInitialized();
/** /**
* For internal use only<br>
* Called before a frame * Called before a frame
* *
* @param tpf Time per frame * @param tpf Time per frame
@ -67,6 +75,7 @@ public interface SceneProcessor {
public void preFrame(float tpf); public void preFrame(float tpf);
/** /**
* For internal use only<br>
* Called after the scene graph has been queued, but before it is flushed. * Called after the scene graph has been queued, but before it is flushed.
* *
* @param rq The render queue * @param rq The render queue
@ -74,6 +83,7 @@ public interface SceneProcessor {
public void postQueue(RenderQueue rq); public void postQueue(RenderQueue rq);
/** /**
* For internal use only<br>
* Called after a frame has been rendered and the queue flushed. * Called after a frame has been rendered and the queue flushed.
* *
* @param out The FB to which the scene was rendered. * @param out The FB to which the scene was rendered.
@ -81,6 +91,7 @@ public interface SceneProcessor {
public void postFrame(FrameBuffer out); public void postFrame(FrameBuffer out);
/** /**
* For internal use only<br>
* Called when the SP is removed from the RM. * Called when the SP is removed from the RM.
*/ */
public void cleanup(); public void cleanup();

@ -40,36 +40,37 @@ import com.jme3.material.Material;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.post.Filter; import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
import com.jme3.texture.Image.Format; import com.jme3.texture.Image.Format;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* <code>BloomFilter</code> is used to make objects in the scene have a * BloomFilter is used to make objects in the scene have a glow effect.<br>
* "soap opera" glow effect. * There are 2 mode : Scene and Objects.<br>
* Scene mode extracts the bright parts of the scene to make them glow<br>
* Object mode make objects glow according to their material's glowMap or their GlowColor<br>
* see {@link http://jmonkeyengine.org/wiki/doku.php/jme3:advanced:bloom_and_glow} for more details
* *
* @author Nehon * @author Rémy Bouquet aka Nehon
*/ */
public class BloomFilter extends Filter { public class BloomFilter extends Filter {
/** /**
* <code>GlowMode</code> specifies if bright objects or objects * GlowMode specifies if the glow will be applied to the whole scene,or to objects that have aglow color or a glow map
* with glow map will be bloomed.
*/ */
public enum GlowMode { public enum GlowMode {
/** /**
* Apply bloom filter to bright objects in the scene. * Apply bloom filter to bright areas in the scene.
*/ */
Scene, Scene,
/** /**
* Apply bloom only to objects that have a glow map. * Apply bloom only to objects that have a glow map or a glow color.
*/ */
Objects, Objects,
/** /**
* Apply bloom to both bright objects and objects with glow map. * Apply bloom to both bright parts of the scene and objects with glow map.
*/ */
SceneAndObjects; SceneAndObjects;
} }
@ -93,14 +94,14 @@ public class BloomFilter extends Filter {
private ColorRGBA backupColor; private ColorRGBA backupColor;
/** /**
* creates a Bloom filter * Creates a Bloom filter
*/ */
public BloomFilter() { public BloomFilter() {
super("BloomFilter"); super("BloomFilter");
} }
/** /**
* Crete the bloom filter with the specific glow mode * Creates the bloom filter with the specific glow mode
* @param glowMode * @param glowMode
*/ */
public BloomFilter(GlowMode glowMode) { public BloomFilter(GlowMode glowMode) {
@ -109,7 +110,7 @@ public class BloomFilter extends Filter {
} }
@Override @Override
public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
screenWidth = (int) (w / downSamplingFactor); screenWidth = (int) (w / downSamplingFactor);
screenHeight = (int) (h / downSamplingFactor); screenHeight = (int) (h / downSamplingFactor);
// System.out.println(screenWidth + " " + screenHeight); // System.out.println(screenWidth + " " + screenHeight);
@ -178,31 +179,15 @@ public class BloomFilter extends Filter {
material.setTexture("BloomTex", verticalalBlur.getRenderedTexture()); material.setTexture("BloomTex", verticalalBlur.getRenderedTexture());
} }
@Override
public void cleanUpFilter(Renderer r) {
if (preGlowPass != null) {
preGlowPass.cleanup(r);
}
if (extractPass != null) {
extractPass.cleanup(r);
}
if (horizontalBlur != null) {
horizontalBlur.cleanup(r);
}
if (verticalalBlur != null) {
verticalalBlur.cleanup(r);
}
}
@Override @Override
public Material getMaterial() { protected Material getMaterial() {
material.setFloat("BloomIntensity", bloomIntensity); material.setFloat("BloomIntensity", bloomIntensity);
return material; return material;
} }
@Override @Override
public void postQueue(RenderManager renderManager, ViewPort viewPort) { protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
if (glowMode != GlowMode.Scene) { if (glowMode != GlowMode.Scene) {
backupColor = viewPort.getBackgroundColor(); backupColor = viewPort.getBackgroundColor();
viewPort.setBackgroundColor(ColorRGBA.Black); viewPort.setBackgroundColor(ColorRGBA.Black);
@ -216,30 +201,43 @@ public class BloomFilter extends Filter {
} }
} }
/**
* returns the bloom intensity
* @return
*/
public float getBloomIntensity() { public float getBloomIntensity() {
return bloomIntensity; return bloomIntensity;
} }
/** /**
* intensity of the bloom effect * intensity of the bloom effect default is 2.0
* @param bloomIntensity * @param bloomIntensity
*/ */
public void setBloomIntensity(float bloomIntensity) { public void setBloomIntensity(float bloomIntensity) {
this.bloomIntensity = bloomIntensity; this.bloomIntensity = bloomIntensity;
} }
/**
* returns the blur scale
* @return
*/
public float getBlurScale() { public float getBlurScale() {
return blurScale; return blurScale;
} }
/** /**
* The spread of the bloom * sets The spread of the bloom default is 1.5f
* @param blurScale * @param blurScale
*/ */
public void setBlurScale(float blurScale) { public void setBlurScale(float blurScale) {
this.blurScale = blurScale; this.blurScale = blurScale;
} }
/**
* returns the exposure cutoff<br>
* for more details see {@link setExposureCutOff(float exposureCutOff)}
* @return
*/
public float getExposureCutOff() { public float getExposureCutOff() {
return exposureCutOff; return exposureCutOff;
} }
@ -252,12 +250,18 @@ public class BloomFilter extends Filter {
this.exposureCutOff = exposureCutOff; this.exposureCutOff = exposureCutOff;
} }
/**
* returns the exposure power<br>
* form more details see {@link setExposurePower(float exposurePower)}
* @return
*/
public float getExposurePower() { public float getExposurePower() {
return exposurePower; return exposurePower;
} }
/** /**
* the power of the bloomed color * defines how many time the bloom extracted color will be multiplied by itself. default id 5.0<br>
* a high value will reduce rough edges in the bloom and somhow the range of the bloom area *
* @param exposurePower * @param exposurePower
*/ */
public void setExposurePower(float exposurePower) { public void setExposurePower(float exposurePower) {
@ -265,7 +269,8 @@ public class BloomFilter extends Filter {
} }
/** /**
* returns the downSampling factor * returns the downSampling factor<br>
* form more details see {@link setDownSamplingFactor(float downSamplingFactor)}
* @return * @return
*/ */
public float getDownSamplingFactor() { public float getDownSamplingFactor() {
@ -273,7 +278,7 @@ public class BloomFilter extends Filter {
} }
/** /**
* Sets the downSampling factor : the size of the computed texture will be divided by this factor. * Sets the downSampling factor : the size of the computed texture will be divided by this factor. default is 1 for no downsampling
* A 2 value is a good way of widening the blur * A 2 value is a good way of widening the blur
* @param downSamplingFactor * @param downSamplingFactor
*/ */

@ -55,19 +55,22 @@ public class CartoonEdgeFilter extends Filter {
private float depthThreshold = 0.1f; private float depthThreshold = 0.1f;
private float normalSensitivity = 1.0f; private float normalSensitivity = 1.0f;
private float depthSensitivity = 10.0f; private float depthSensitivity = 10.0f;
private ColorRGBA edgeColor=new ColorRGBA(0, 0, 0, 1); private ColorRGBA edgeColor = new ColorRGBA(0, 0, 0, 1);
/**
* Creates a CartoonEdgeFilter
*/
public CartoonEdgeFilter() { public CartoonEdgeFilter() {
super("CartoonEdgeFilter"); super("CartoonEdgeFilter");
} }
@Override @Override
public boolean isRequiresDepthTexture() { protected boolean isRequiresDepthTexture() {
return true; return true;
} }
@Override @Override
public void postQueue(RenderManager renderManager, ViewPort viewPort) { protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
Renderer r = renderManager.getRenderer(); Renderer r = renderManager.getRenderer();
r.setFrameBuffer(normalPass.getRenderFrameBuffer()); r.setFrameBuffer(normalPass.getRenderFrameBuffer());
renderManager.getRenderer().clearBuffers(true, true, true); renderManager.getRenderer().clearBuffers(true, true, true);
@ -78,13 +81,13 @@ public class CartoonEdgeFilter extends Filter {
} }
@Override @Override
public Material getMaterial() { protected Material getMaterial() {
material.setTexture("NormalsTexture", normalPass.getRenderedTexture()); material.setTexture("NormalsTexture", normalPass.getRenderedTexture());
return material; return material;
} }
@Override @Override
public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
normalPass = new Pass(); normalPass = new Pass();
normalPass.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth); normalPass.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth);
material = new Material(manager, "Common/MatDefs/Post/CartoonEdge.j3md"); material = new Material(manager, "Common/MatDefs/Post/CartoonEdge.j3md");
@ -97,17 +100,20 @@ public class CartoonEdgeFilter extends Filter {
material.setColor("EdgeColor", edgeColor); material.setColor("EdgeColor", edgeColor);
} }
@Override /**
public void cleanUpFilter(Renderer r) { * Return the depth sensitivity<br>
if (normalPass != null) { * for more details see {@link setDepthSensitivity(float depthSensitivity)}
normalPass.cleanup(r); * @return
} */
}
public float getDepthSensitivity() { public float getDepthSensitivity() {
return depthSensitivity; return depthSensitivity;
} }
/**
* sets the depth sensitivity<br>
* defines how much depth will influence edges, default is 10
* @param depthSensitivity
*/
public void setDepthSensitivity(float depthSensitivity) { public void setDepthSensitivity(float depthSensitivity) {
this.depthSensitivity = depthSensitivity; this.depthSensitivity = depthSensitivity;
if (material != null) { if (material != null) {
@ -115,10 +121,20 @@ public class CartoonEdgeFilter extends Filter {
} }
} }
/**
* returns the depth threshold<br>
* for more details see {@link setDepthThreshold(float depthThreshold)}
* @return
*/
public float getDepthThreshold() { public float getDepthThreshold() {
return depthThreshold; return depthThreshold;
} }
/**
* sets the depth threshold<br>
* Defines at what threshold of difference of depth an edge is outlined default is 0.1f
* @param depthThreshold
*/
public void setDepthThreshold(float depthThreshold) { public void setDepthThreshold(float depthThreshold) {
this.depthThreshold = depthThreshold; this.depthThreshold = depthThreshold;
if (material != null) { if (material != null) {
@ -126,10 +142,20 @@ public class CartoonEdgeFilter extends Filter {
} }
} }
/**
* returns the edge intensity<br>
* for more details see {@link setEdgeIntensity(float edgeIntensity) }
* @return
*/
public float getEdgeIntensity() { public float getEdgeIntensity() {
return edgeIntensity; return edgeIntensity;
} }
/**
* sets the edge intensity<br>
* Defineshow visilble will be the outlined edges
* @param edgeIntensity
*/
public void setEdgeIntensity(float edgeIntensity) { public void setEdgeIntensity(float edgeIntensity) {
this.edgeIntensity = edgeIntensity; this.edgeIntensity = edgeIntensity;
if (material != null) { if (material != null) {
@ -137,10 +163,18 @@ public class CartoonEdgeFilter extends Filter {
} }
} }
/**
* returns the width of the edges
* @return
*/
public float getEdgeWidth() { public float getEdgeWidth() {
return edgeWidth; return edgeWidth;
} }
/**
* sets the witdh of the edge in pixels default is 1
* @param edgeWidth
*/
public void setEdgeWidth(float edgeWidth) { public void setEdgeWidth(float edgeWidth) {
this.edgeWidth = edgeWidth; this.edgeWidth = edgeWidth;
if (material != null) { if (material != null) {
@ -149,10 +183,19 @@ public class CartoonEdgeFilter extends Filter {
} }
/**
* returns the normals sensitivity<br>
* form more details see {@link setNormalSensitivity(float normalSensitivity)}
* @return
*/
public float getNormalSensitivity() { public float getNormalSensitivity() {
return normalSensitivity; return normalSensitivity;
} }
/**
* sets the normals sensitivity default is 1
* @param normalSensitivity
*/
public void setNormalSensitivity(float normalSensitivity) { public void setNormalSensitivity(float normalSensitivity) {
this.normalSensitivity = normalSensitivity; this.normalSensitivity = normalSensitivity;
if (material != null) { if (material != null) {
@ -160,10 +203,20 @@ public class CartoonEdgeFilter extends Filter {
} }
} }
/**
* returns the normal threshold<br>
* for more details see {@link setNormalThreshold(float normalThreshold)}
*
* @return
*/
public float getNormalThreshold() { public float getNormalThreshold() {
return normalThreshold; return normalThreshold;
} }
/**
* sets the normal threshold default is 0.5
* @param normalThreshold
*/
public void setNormalThreshold(float normalThreshold) { public void setNormalThreshold(float normalThreshold) {
this.normalThreshold = normalThreshold; this.normalThreshold = normalThreshold;
if (material != null) { if (material != null) {
@ -185,10 +238,8 @@ public class CartoonEdgeFilter extends Filter {
*/ */
public void setEdgeColor(ColorRGBA edgeColor) { public void setEdgeColor(ColorRGBA edgeColor) {
this.edgeColor = edgeColor; this.edgeColor = edgeColor;
if(material!=null){ if (material != null) {
material.setColor("EdgeColor", edgeColor); material.setColor("EdgeColor", edgeColor);
} }
} }
} }

@ -40,44 +40,58 @@ import com.jme3.material.Material;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.post.Filter; import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
import java.io.IOException; import java.io.IOException;
/** /**
* * This filter simply multiply the whole scene by a color
* @author nehon * @author Rémy Bouquet aka Nehon
*/ */
public class ColorOverlayFilter extends Filter { public class ColorOverlayFilter extends Filter {
private ColorRGBA color = ColorRGBA.White; private ColorRGBA color = ColorRGBA.White;
/**
* creates a colorOverlayFilter with a white coor (transparent)
*/
public ColorOverlayFilter() { public ColorOverlayFilter() {
super("Color Overlay"); super("Color Overlay");
} }
/**
* creates a colorOverlayFilter with the given color
* @param color
*/
public ColorOverlayFilter(ColorRGBA color) { public ColorOverlayFilter(ColorRGBA color) {
this(); this();
this.color = color; this.color = color;
} }
@Override @Override
public Material getMaterial() { protected Material getMaterial() {
material.setColor("Color", color); material.setColor("Color", color);
return material; return material;
} }
/**
* returns the color
* @return color
*/
public ColorRGBA getColor() { public ColorRGBA getColor() {
return color; return color;
} }
/**
* sets the color
* @param color
*/
public void setColor(ColorRGBA color) { public void setColor(ColorRGBA color) {
this.color = color; this.color = color;
} }
@Override @Override
public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
material = new Material(manager, "Common/MatDefs/Post/Overlay.j3md"); material = new Material(manager, "Common/MatDefs/Post/Overlay.j3md");
} }
@ -94,8 +108,4 @@ public class ColorOverlayFilter extends Filter {
InputCapsule ic = im.getCapsule(this); InputCapsule ic = im.getCapsule(this);
color = (ColorRGBA) ic.readSavable("color", ColorRGBA.White); color = (ColorRGBA) ic.readSavable("color", ColorRGBA.White);
} }
@Override
public void cleanUpFilter(Renderer r) {
}
} }

@ -36,7 +36,6 @@ import com.jme3.material.Material;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.post.Filter; import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
/* /*
@ -64,10 +63,18 @@ public class CrossHatchFilter extends Filter {
private float lineThickness = 1.0f; private float lineThickness = 1.0f;
private float lineDistance = 4.0f; private float lineDistance = 4.0f;
/**
* Creates a crossHatch filter
*/
public CrossHatchFilter() { public CrossHatchFilter() {
super("CrossHatchFilter"); super("CrossHatchFilter");
} }
/**
* Creates a crossHatch filter
* @param lineColor the colors of the lines
* @param paperColor the paper color
*/
public CrossHatchFilter(ColorRGBA lineColor, ColorRGBA paperColor) { public CrossHatchFilter(ColorRGBA lineColor, ColorRGBA paperColor) {
this(); this();
this.lineColor = lineColor; this.lineColor = lineColor;
@ -75,12 +82,12 @@ public class CrossHatchFilter extends Filter {
} }
@Override @Override
public boolean isRequiresDepthTexture() { protected boolean isRequiresDepthTexture() {
return false; return false;
} }
@Override @Override
public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
material = new Material(manager, "Common/MatDefs/Post/CrossHatch.j3md"); material = new Material(manager, "Common/MatDefs/Post/CrossHatch.j3md");
material.setColor("LineColor", lineColor); material.setColor("LineColor", lineColor);
material.setColor("PaperColor", paperColor); material.setColor("PaperColor", paperColor);
@ -101,16 +108,13 @@ public class CrossHatchFilter extends Filter {
} }
@Override @Override
public Material getMaterial() { protected Material getMaterial() {
return material; return material;
} }
@Override /**
public void cleanUpFilter(Renderer r) {
}
/*
* Sets color used to draw lines * Sets color used to draw lines
* @param lineColor
*/ */
public void setLineColor(ColorRGBA lineColor) { public void setLineColor(ColorRGBA lineColor) {
this.lineColor = lineColor; this.lineColor = lineColor;
@ -119,8 +123,9 @@ public class CrossHatchFilter extends Filter {
} }
} }
/* /**
* Sets color used as background * Sets color used as background
* @param paperColor
*/ */
public void setPaperColor(ColorRGBA paperColor) { public void setPaperColor(ColorRGBA paperColor) {
this.paperColor = paperColor; this.paperColor = paperColor;
@ -128,10 +133,11 @@ public class CrossHatchFilter extends Filter {
material.setColor("PaperColor", paperColor); material.setColor("PaperColor", paperColor);
} }
} }
/*
/**
* Sets color influence of original image on lines drawn * Sets color influence of original image on lines drawn
* @param colorInfluenceLine
*/ */
public void setColorInfluenceLine(float colorInfluenceLine) { public void setColorInfluenceLine(float colorInfluenceLine) {
this.colorInfluenceLine = colorInfluenceLine; this.colorInfluenceLine = colorInfluenceLine;
if (material != null) { if (material != null) {
@ -139,8 +145,9 @@ public class CrossHatchFilter extends Filter {
} }
} }
/* /**
* Sets color influence of original image on non-line areas * Sets color influence of original image on non-line areas
* @param colorInfluencePaper
*/ */
public void setColorInfluencePaper(float colorInfluencePaper) { public void setColorInfluencePaper(float colorInfluencePaper) {
this.colorInfluencePaper = colorInfluencePaper; this.colorInfluencePaper = colorInfluencePaper;
@ -149,9 +156,10 @@ public class CrossHatchFilter extends Filter {
} }
} }
/* /**
* Sets line/paper color ratio for areas with values < luminance5, * Sets line/paper color ratio for areas with values < luminance5,
* really dark areas get no lines but a filled blob instead * really dark areas get no lines but a filled blob instead
* @param fillValue
*/ */
public void setFillValue(float fillValue) { public void setFillValue(float fillValue) {
this.fillValue = fillValue; this.fillValue = fillValue;
@ -160,13 +168,14 @@ public class CrossHatchFilter extends Filter {
} }
} }
/* /**
*
* Sets minimum luminance levels for lines drawn * Sets minimum luminance levels for lines drawn
* Luminance1: Top-left to down right 1 * @param luminance1 Top-left to down right 1
* Luminance2: Top-right to bottom left 1 * @param luminance2 Top-right to bottom left 1
* Luminance3: Top-left to down right 2 * @param luminance3 Top-left to down right 2
* Luminance4: Top-right to bottom left 2 * @param luminance4 Top-right to bottom left 2
* Luminance5: Blobs * @param luminance5 Blobs
*/ */
public void setLuminanceLevels(float luminance1, float luminance2, float luminance3, float luminance4, float luminance5) { public void setLuminanceLevels(float luminance1, float luminance2, float luminance3, float luminance4, float luminance5) {
this.luminance1 = luminance1; this.luminance1 = luminance1;
@ -184,8 +193,9 @@ public class CrossHatchFilter extends Filter {
} }
} }
/* /**
* Sets the thickness of lines drawn * Sets the thickness of lines drawn
* @param lineThickness
*/ */
public void setLineThickness(float lineThickness) { public void setLineThickness(float lineThickness) {
this.lineThickness = lineThickness; this.lineThickness = lineThickness;
@ -194,10 +204,11 @@ public class CrossHatchFilter extends Filter {
} }
} }
/* /**
* Sets minimum distance between lines drawn * Sets minimum distance between lines drawn
* Primary lines are drawn at 2*lineDistance * Primary lines are drawn at 2*lineDistance
* Secondary lines are drawn at lineDistance * Secondary lines are drawn at lineDistance
* @param lineDistance
*/ */
public void setLineDistance(float lineDistance) { public void setLineDistance(float lineDistance) {
this.lineDistance = lineDistance; this.lineDistance = lineDistance;
@ -206,84 +217,86 @@ public class CrossHatchFilter extends Filter {
} }
} }
/* /**
* Returns line color * Returns line color
* @return
*/ */
public ColorRGBA getLineColor() { public ColorRGBA getLineColor() {
return lineColor; return lineColor;
} }
/* /**
* Returns paper background color * Returns paper background color
* @return
*/ */
public ColorRGBA getPaperColor() { public ColorRGBA getPaperColor() {
return paperColor; return paperColor;
} }
/* /**
* Returns current influence of image colors on lines * Returns current influence of image colors on lines
*/ */
public float getColorInfluenceLine() { public float getColorInfluenceLine() {
return colorInfluenceLine; return colorInfluenceLine;
} }
/* /**
* Returns current influence of image colors on paper background * Returns current influence of image colors on paper background
*/ */
public float getColorInfluencePaper() { public float getColorInfluencePaper() {
return colorInfluencePaper; return colorInfluencePaper;
} }
/* /**
* Returns line/paper color ratio for blobs * Returns line/paper color ratio for blobs
*/ */
public float getFillValue() { public float getFillValue() {
return fillValue; return fillValue;
} }
/* /**
* Returns the thickness of the lines drawn * Returns the thickness of the lines drawn
*/ */
public float getLineThickness() { public float getLineThickness() {
return lineThickness; return lineThickness;
} }
/* /**
* Returns minimum distance between lines * Returns minimum distance between lines
*/ */
public float getLineDistance() { public float getLineDistance() {
return lineDistance; return lineDistance;
} }
/* /**
* Returns treshold for lines 1 * Returns treshold for lines 1
*/ */
public float getLuminance1() { public float getLuminance1() {
return luminance1; return luminance1;
} }
/* /**
* Returns treshold for lines 2 * Returns treshold for lines 2
*/ */
public float getLuminance2() { public float getLuminance2() {
return luminance2; return luminance2;
} }
/* /**
* Returns treshold for lines 3 * Returns treshold for lines 3
*/ */
public float getLuminance3() { public float getLuminance3() {
return luminance3; return luminance3;
} }
/* /**
* Returns treshold for lines 4 * Returns treshold for lines 4
*/ */
public float getLuminance4() { public float getLuminance4() {
return luminance4; return luminance4;
} }
/* /**
* Returns treshold for blobs * Returns treshold for blobs
*/ */
public float getLuminance5() { public float getLuminance5() {

@ -35,7 +35,6 @@ import com.jme3.asset.AssetManager;
import com.jme3.post.Filter; import com.jme3.post.Filter;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
/** /**
@ -55,23 +54,26 @@ public class DepthOfFieldFilter extends Filter {
private float xScale; private float xScale;
private float yScale; private float yScale;
/**
* Creates a DepthOfField filter
*/
public DepthOfFieldFilter() { public DepthOfFieldFilter() {
super("Depth Of Field"); super("Depth Of Field");
} }
@Override @Override
public boolean isRequiresDepthTexture() { protected boolean isRequiresDepthTexture() {
return true; return true;
} }
@Override @Override
public Material getMaterial() { protected Material getMaterial() {
return material; return material;
} }
@Override @Override
public void initFilter(AssetManager assets, RenderManager renderManager, protected void initFilter(AssetManager assets, RenderManager renderManager,
ViewPort vp, int w, int h) { ViewPort vp, int w, int h) {
material = new Material(assets, "Common/MatDefs/Post/DepthOfField.j3md"); material = new Material(assets, "Common/MatDefs/Post/DepthOfField.j3md");
material.setFloat("FocusDistance", focusDistance); material.setFloat("FocusDistance", focusDistance);
@ -85,10 +87,6 @@ public class DepthOfFieldFilter extends Filter {
material.setFloat("YScale", blurScale * yScale); material.setFloat("YScale", blurScale * yScale);
} }
@Override
public void cleanUpFilter(Renderer r) {
}
/** /**
* Sets the distance at which objects are purely in focus. * Sets the distance at which objects are purely in focus.
*/ */
@ -101,6 +99,10 @@ public class DepthOfFieldFilter extends Filter {
} }
/**
* returns the focus distance
* @return
*/
public float getFocusDistance() { public float getFocusDistance() {
return focusDistance; return focusDistance;
} }
@ -118,6 +120,10 @@ public class DepthOfFieldFilter extends Filter {
} }
/**
* returns the focus range
* @return
*/
public float getFocusRange() { public float getFocusRange() {
return focusRange; return focusRange;
} }
@ -142,6 +148,10 @@ public class DepthOfFieldFilter extends Filter {
} }
} }
/**
* returns the blur scale
* @return
*/
public float getBlurScale() { public float getBlurScale() {
return blurScale; return blurScale;
} }

@ -39,13 +39,13 @@ import com.jme3.export.OutputCapsule;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.post.Filter; import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
import java.io.IOException; import java.io.IOException;
/** /**
* *
* @author Nehon * Fade Filter allows you to make an animated fade effect on a scene.
* @author Rémy Bouquet aka Nehon
* implemented from boxjar implementation * implemented from boxjar implementation
* see http://jmonkeyengine.org/groups/graphics/forum/topic/newbie-question-general-fade-inout-effect/#post-105559 * see http://jmonkeyengine.org/groups/graphics/forum/topic/newbie-question-general-fade-inout-effect/#post-105559
*/ */
@ -56,29 +56,35 @@ public class FadeFilter extends Filter {
private float direction = 1; private float direction = 1;
private float duration = 1; private float duration = 1;
/**
* Creates a FadeFilter
*/
public FadeFilter() { public FadeFilter() {
super("Fade In/Out"); super("Fade In/Out");
} }
/**
* Creates a FadeFilter with the given duration
* @param duration
*/
public FadeFilter(float duration) { public FadeFilter(float duration) {
this(); this();
this.duration = duration; this.duration = duration;
} }
@Override @Override
public Material getMaterial() { protected Material getMaterial() {
material.setFloat("Value", value); material.setFloat("Value", value);
return material; return material;
} }
@Override @Override
public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
material = new Material(manager, "Common/MatDefs/Post/Fade.j3md"); material = new Material(manager, "Common/MatDefs/Post/Fade.j3md");
} }
@Override @Override
public void preFrame(float tpf) { protected void preFrame(float tpf) {
if (playing) { if (playing) {
value += tpf * direction / duration; value += tpf * direction / duration;
@ -95,20 +101,34 @@ public class FadeFilter extends Filter {
} }
} }
/**
* returns the duration of the effect
* @return
*/
public float getDuration() { public float getDuration() {
return duration; return duration;
} }
/**
* Sets the duration of the filter default is 1 second
* @param duration
*/
public void setDuration(float duration) { public void setDuration(float duration) {
this.duration = duration; this.duration = duration;
} }
/**
* fades the scene in (black to scene)
*/
public void fadeIn() { public void fadeIn() {
setEnabled(true); setEnabled(true);
direction = 1; direction = 1;
playing = true; playing = true;
} }
/**
* fades the scene out (scene to black)
*/
public void fadeOut() { public void fadeOut() {
setEnabled(true); setEnabled(true);
direction = -1; direction = -1;
@ -130,15 +150,21 @@ public class FadeFilter extends Filter {
duration = ic.readFloat("duration", 1); duration = ic.readFloat("duration", 1);
} }
/**
* return the current value of the fading
* can be used to chack if fade is complete (eg value=1)
* @return
*/
public float getValue() { public float getValue() {
return value; return value;
} }
/**
* sets the fade value
* can be used to force complete black or compete scene
* @param value
*/
public void setValue(float value) { public void setValue(float value) {
this.value = value; this.value = value;
} }
@Override
public void cleanUpFilter(Renderer r) {
}
} }

@ -40,13 +40,12 @@ import com.jme3.material.Material;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.post.Filter; import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
import java.io.IOException; import java.io.IOException;
/** /**
* A filter to render a fog effect * A filter to render a fog effect
* @author Nehon * @author Rémy Bouquet aka Nehon
*/ */
public class FogFilter extends Filter { public class FogFilter extends Filter {
@ -54,6 +53,9 @@ public class FogFilter extends Filter {
private float fogDensity = 0.7f; private float fogDensity = 0.7f;
private float fogDistance = 1000; private float fogDistance = 1000;
/**
* Creates a FogFilter
*/
public FogFilter() { public FogFilter() {
super("FogFilter"); super("FogFilter");
} }
@ -72,12 +74,12 @@ public class FogFilter extends Filter {
} }
@Override @Override
public boolean isRequiresDepthTexture() { protected boolean isRequiresDepthTexture() {
return true; return true;
} }
@Override @Override
public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
material = new Material(manager, "Common/MatDefs/Post/Fog.j3md"); material = new Material(manager, "Common/MatDefs/Post/Fog.j3md");
material.setColor("FogColor", fogColor); material.setColor("FogColor", fogColor);
material.setFloat("FogDensity", fogDensity); material.setFloat("FogDensity", fogDensity);
@ -85,7 +87,7 @@ public class FogFilter extends Filter {
} }
@Override @Override
public Material getMaterial() { protected Material getMaterial() {
return material; return material;
} }
@ -166,7 +168,5 @@ public class FogFilter extends Filter {
fogDistance = ic.readFloat("fogDistance", 1000); fogDistance = ic.readFloat("fogDistance", 1000);
} }
@Override
public void cleanUpFilter(Renderer r) {
}
} }

@ -41,13 +41,14 @@ import com.jme3.math.Vector3f;
import com.jme3.post.Filter; import com.jme3.post.Filter;
import com.jme3.renderer.Camera; import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
import java.io.IOException; import java.io.IOException;
/** /**
* LightScattering filters creates rays comming from a light sources
* This is often reffered as god rays.
* *
* @author nehon * @author Rémy Bouquet aka Nehon
*/ */
public class LightScatteringFilter extends Filter { public class LightScatteringFilter extends Filter {
@ -59,25 +60,32 @@ public class LightScatteringFilter extends Filter {
private float lightDensity = 1.4f; private float lightDensity = 1.4f;
private boolean adaptative = true; private boolean adaptative = true;
Vector3f viewLightPos = new Vector3f(); Vector3f viewLightPos = new Vector3f();
private boolean display=true; private boolean display = true;
private float innerLightDensity; private float innerLightDensity;
/**
* creates a lightScaterring filter
*/
public LightScatteringFilter() { public LightScatteringFilter() {
super("Light Scattering"); super("Light Scattering");
} }
/**
* Creates a lightScatteringFilter
* @param lightPosition
*/
public LightScatteringFilter(Vector3f lightPosition) { public LightScatteringFilter(Vector3f lightPosition) {
this(); this();
this.lightPosition = lightPosition; this.lightPosition = lightPosition;
} }
@Override @Override
public boolean isRequiresDepthTexture() { protected boolean isRequiresDepthTexture() {
return true; return true;
} }
@Override @Override
public Material getMaterial() { protected Material getMaterial() {
material.setVector3("LightPosition", screenLightPos); material.setVector3("LightPosition", screenLightPos);
material.setInt("NbSamples", nbSamples); material.setInt("NbSamples", nbSamples);
material.setFloat("BlurStart", blurStart); material.setFloat("BlurStart", blurStart);
@ -88,7 +96,7 @@ public class LightScatteringFilter extends Filter {
} }
@Override @Override
public void postQueue(RenderManager renderManager, ViewPort viewPort) { protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
getClipCoordinates(lightPosition, screenLightPos, viewPort.getCamera()); getClipCoordinates(lightPosition, screenLightPos, viewPort.getCamera());
// screenLightPos.x = screenLightPos.x / viewPort.getCamera().getWidth(); // screenLightPos.x = screenLightPos.x / viewPort.getCamera().getWidth();
// screenLightPos.y = screenLightPos.y / viewPort.getCamera().getHeight(); // screenLightPos.y = screenLightPos.y / viewPort.getCamera().getHeight();
@ -101,12 +109,12 @@ public class LightScatteringFilter extends Filter {
//System.err.println("screenLightPos "+screenLightPos); //System.err.println("screenLightPos "+screenLightPos);
if (adaptative) { if (adaptative) {
innerLightDensity = Math.max(lightDensity - Math.max(screenLightPos.x, screenLightPos.y), 0.0f); innerLightDensity = Math.max(lightDensity - Math.max(screenLightPos.x, screenLightPos.y), 0.0f);
}else{ } else {
innerLightDensity=lightDensity; innerLightDensity = lightDensity;
} }
} }
public Vector3f getClipCoordinates(Vector3f worldPosition, Vector3f store, Camera cam) { private Vector3f getClipCoordinates(Vector3f worldPosition, Vector3f store, Camera cam) {
float w = cam.getViewProjectionMatrix().multProj(worldPosition, store); float w = cam.getViewProjectionMatrix().multProj(worldPosition, store);
store.divideLocal(w); store.divideLocal(w);
@ -119,46 +127,92 @@ public class LightScatteringFilter extends Filter {
} }
@Override @Override
public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
material = new Material(manager, "Common/MatDefs/Post/LightScattering.j3md"); material = new Material(manager, "Common/MatDefs/Post/LightScattering.j3md");
} }
/**
* returns the blur start of the scattering
* see {@link setBlurStart(float blurStart)}
* @return
*/
public float getBlurStart() { public float getBlurStart() {
return blurStart; return blurStart;
} }
/**
* sets the blur start<br>
* at which distance from the light source the effect starts default is 0.02
* @param blurStart
*/
public void setBlurStart(float blurStart) { public void setBlurStart(float blurStart) {
this.blurStart = blurStart; this.blurStart = blurStart;
} }
/**
* returns the blur width<br>
* see {@link setBlurWidth(float blurWidth)}
* @return
*/
public float getBlurWidth() { public float getBlurWidth() {
return blurWidth; return blurWidth;
} }
/**
* sets the blur width default is 0.9
* @param blurWidth
*/
public void setBlurWidth(float blurWidth) { public void setBlurWidth(float blurWidth) {
this.blurWidth = blurWidth; this.blurWidth = blurWidth;
} }
/**
* retiurns the light density<br>
* see {@link setLightDensity(float lightDensity)}
*
* @return
*/
public float getLightDensity() { public float getLightDensity() {
return lightDensity; return lightDensity;
} }
/**
* sets how much the effect is visible over the rendered scene default is 1.4
* @param lightDensity
*/
public void setLightDensity(float lightDensity) { public void setLightDensity(float lightDensity) {
this.lightDensity = lightDensity; this.lightDensity = lightDensity;
} }
/**
* returns the light position
* @return
*/
public Vector3f getLightPosition() { public Vector3f getLightPosition() {
return lightPosition; return lightPosition;
} }
/**
* sets the light position
* @param lightPosition
*/
public void setLightPosition(Vector3f lightPosition) { public void setLightPosition(Vector3f lightPosition) {
this.lightPosition = lightPosition; this.lightPosition = lightPosition;
} }
/**
* returns the nmber of samples for the radial blur
* @return
*/
public int getNbSamples() { public int getNbSamples() {
return nbSamples; return nbSamples;
} }
/**
* sets the number of samples for the radial blur default is 50
* the higher the value the higher the quality, but the slower the performances.
* @param nbSamples
*/
public void setNbSamples(int nbSamples) { public void setNbSamples(int nbSamples) {
this.nbSamples = nbSamples; this.nbSamples = nbSamples;
} }
@ -186,8 +240,4 @@ public class LightScatteringFilter extends Filter {
lightDensity = ic.readFloat("lightDensity", 1.4f); lightDensity = ic.readFloat("lightDensity", 1.4f);
adaptative = ic.readBoolean("adaptative", true); adaptative = ic.readBoolean("adaptative", true);
} }
@Override
public void cleanUpFilter(Renderer r) {
}
} }

@ -35,7 +35,6 @@ import com.jme3.asset.AssetManager;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.post.Filter; import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
/** /**
@ -56,27 +55,34 @@ public class PosterizationFilter extends Filter {
private float gamma = 0.6f; private float gamma = 0.6f;
private float strength = 1.0f; private float strength = 1.0f;
/**
* Creates a posterization Filter
*/
public PosterizationFilter() { public PosterizationFilter() {
super("PosterizationFilter"); super("PosterizationFilter");
} }
/**
* Creates a posterization Filter with the given number of colors
* @param numColors
*/
public PosterizationFilter(int numColors) { public PosterizationFilter(int numColors) {
this(); this();
this.numColors = numColors; this.numColors = numColors;
} }
/**
* Creates a posterization Filter with the given number of colors and gamma
* @param numColors
* @param gamma
*/
public PosterizationFilter(int numColors, float gamma) { public PosterizationFilter(int numColors, float gamma) {
this(numColors); this(numColors);
this.gamma = gamma; this.gamma = gamma;
} }
@Override @Override
public boolean isRequiresDepthTexture() { protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
return false;
}
@Override
public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
material = new Material(manager, "Common/MatDefs/Post/Posterization.j3md"); material = new Material(manager, "Common/MatDefs/Post/Posterization.j3md");
material.setInt("NumColors", numColors); material.setInt("NumColors", numColors);
material.setFloat("Gamma", gamma); material.setFloat("Gamma", gamma);
@ -84,16 +90,11 @@ public class PosterizationFilter extends Filter {
} }
@Override @Override
public Material getMaterial() { protected Material getMaterial() {
return material; return material;
} }
/**
@Override
public void cleanUpFilter(Renderer r) {
}
/*
* Sets number of color levels used to draw the screen * Sets number of color levels used to draw the screen
*/ */
public void setNumColors(int numColors) { public void setNumColors(int numColors) {
@ -103,7 +104,7 @@ public class PosterizationFilter extends Filter {
} }
} }
/* /**
* Sets gamma level used to enhange visual quality * Sets gamma level used to enhange visual quality
*/ */
public void setGamma(float gamma) { public void setGamma(float gamma) {
@ -113,7 +114,7 @@ public class PosterizationFilter extends Filter {
} }
} }
/* /**
* Sets urrent strength value, i.e. influence on final image * Sets urrent strength value, i.e. influence on final image
*/ */
public void setStrength(float strength) { public void setStrength(float strength) {
@ -123,21 +124,21 @@ public class PosterizationFilter extends Filter {
} }
} }
/* /**
* Returns number of color levels used * Returns number of color levels used
*/ */
public int getNumColors() { public int getNumColors() {
return numColors; return numColors;
} }
/* /**
* Returns current gamma value * Returns current gamma value
*/ */
public float getGamma() { public float getGamma() {
return gamma; return gamma;
} }
/* /**
* Returns current strength value, i.e. influence on final image * Returns current strength value, i.e. influence on final image
*/ */
public float getStrength() { public float getStrength() {

@ -39,14 +39,13 @@ import com.jme3.export.OutputCapsule;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.post.Filter; import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
import com.jme3.shader.VarType; import com.jme3.shader.VarType;
import java.io.IOException; import java.io.IOException;
/** /**
* * Radially blurs the scene from the center of it
* @author nehon * @author Rémy Bouquet aka Nehon
*/ */
public class RadialBlurFilter extends Filter { public class RadialBlurFilter extends Filter {
@ -54,10 +53,18 @@ public class RadialBlurFilter extends Filter {
private float sampleStrength = 2.2f; private float sampleStrength = 2.2f;
private float[] samples = {-0.08f, -0.05f, -0.03f, -0.02f, -0.01f, 0.01f, 0.02f, 0.03f, 0.05f, 0.08f}; private float[] samples = {-0.08f, -0.05f, -0.03f, -0.02f, -0.01f, 0.01f, 0.02f, 0.03f, 0.05f, 0.08f};
/**
* Creates a RadialBlurFilter
*/
public RadialBlurFilter() { public RadialBlurFilter() {
super("Radial blur"); super("Radial blur");
} }
/**
* Creates a RadialBlurFilter
* @param sampleDist the distance between samples
* @param sampleStrength the strenght of each sample
*/
public RadialBlurFilter(float sampleDist, float sampleStrength) { public RadialBlurFilter(float sampleDist, float sampleStrength) {
this(); this();
this.sampleDist = sampleDist; this.sampleDist = sampleDist;
@ -65,7 +72,7 @@ public class RadialBlurFilter extends Filter {
} }
@Override @Override
public Material getMaterial() { protected Material getMaterial() {
material.setFloat("SampleDist", sampleDist); material.setFloat("SampleDist", sampleDist);
material.setFloat("SampleStrength", sampleStrength); material.setFloat("SampleStrength", sampleStrength);
@ -74,25 +81,60 @@ public class RadialBlurFilter extends Filter {
return material; return material;
} }
/**
* return the sample distance
* @return
*/
public float getSampleDistance() {
return sampleDist;
}
/**
* sets the samples distances default is 1
* @param sampleDist
*/
public void setSampleDistance(float sampleDist) {
this.sampleDist = sampleDist;
}
/**
*
* @return
* @deprecated use {@link getSampleDistance()}
*/
@Deprecated
public float getSampleDist() { public float getSampleDist() {
return sampleDist; return sampleDist;
} }
/**
*
* @param sampleDist
* @deprecated use {@link setSampleDistance(float sampleDist)}
*/
@Deprecated
public void setSampleDist(float sampleDist) { public void setSampleDist(float sampleDist) {
this.sampleDist = sampleDist; this.sampleDist = sampleDist;
} }
/**
* Returns the sample Strength
* @return
*/
public float getSampleStrength() { public float getSampleStrength() {
return sampleStrength; return sampleStrength;
} }
/**
* sets the sample streanght default is 2.2
* @param sampleStrength
*/
public void setSampleStrength(float sampleStrength) { public void setSampleStrength(float sampleStrength) {
this.sampleStrength = sampleStrength; this.sampleStrength = sampleStrength;
} }
@Override @Override
public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
material = new Material(manager, "Common/MatDefs/Blur/RadialBlur.j3md"); material = new Material(manager, "Common/MatDefs/Blur/RadialBlur.j3md");
} }
@ -111,8 +153,4 @@ public class RadialBlurFilter extends Filter {
sampleDist = ic.readFloat("sampleDist", 1.0f); sampleDist = ic.readFloat("sampleDist", 1.0f);
sampleStrength = ic.readFloat("sampleStrength", 2.2f); sampleStrength = ic.readFloat("sampleStrength", 2.2f);
} }
@Override
public void cleanUpFilter(Renderer r) {
}
} }

@ -16,7 +16,8 @@ import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Texture2D; import com.jme3.texture.Texture2D;
/** /**
* * A filter to handle translucent objects when rendering a scene with filters that uses depth like WaterFilter and SSAOFilter
* just create a TranslucentBucketFilter and add it to the Filter list of a FilterPostPorcessor
* @author Nehon * @author Nehon
*/ */
public final class TranslucentBucketFilter extends Filter { public final class TranslucentBucketFilter extends Filter {
@ -24,7 +25,7 @@ public final class TranslucentBucketFilter extends Filter {
private RenderManager renderManager; private RenderManager renderManager;
@Override @Override
public void initFilter(AssetManager manager, RenderManager rm, ViewPort vp, int w, int h) { protected void initFilter(AssetManager manager, RenderManager rm, ViewPort vp, int w, int h) {
this.renderManager = rm; this.renderManager = rm;
material = new Material(manager, "Common/MatDefs/Post/Overlay.j3md"); material = new Material(manager, "Common/MatDefs/Post/Overlay.j3md");
material.setColor("Color", ColorRGBA.White); material.setColor("Color", ColorRGBA.White);
@ -42,14 +43,15 @@ public final class TranslucentBucketFilter extends Filter {
* Override this method and return false if your Filter does not need the scene texture * Override this method and return false if your Filter does not need the scene texture
* @return * @return
*/ */
public boolean isRequiresSceneTexture() { @Override
protected boolean isRequiresSceneTexture() {
return false; return false;
} }
@Override @Override
public void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) { protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
renderManager.setCamera(viewPort.getCamera(), false); renderManager.setCamera(viewPort.getCamera(), false);
if(prevFilterBuffer != sceneBuffer){ if (prevFilterBuffer != sceneBuffer) {
renderManager.getRenderer().copyFrameBuffer(prevFilterBuffer, sceneBuffer, false); renderManager.getRenderer().copyFrameBuffer(prevFilterBuffer, sceneBuffer, false);
} }
renderManager.getRenderer().setFrameBuffer(sceneBuffer); renderManager.getRenderer().setFrameBuffer(sceneBuffer);
@ -57,14 +59,14 @@ public final class TranslucentBucketFilter extends Filter {
} }
@Override @Override
public void cleanUpFilter(Renderer r) { protected void cleanUpFilter(Renderer r) {
if (renderManager != null) { if (renderManager != null) {
renderManager.setHandleTranslucentBucket(true); renderManager.setHandleTranslucentBucket(true);
} }
} }
@Override @Override
public Material getMaterial() { protected Material getMaterial() {
return material; return material;
} }

@ -96,12 +96,12 @@ public class SSAOFilter extends Filter {
} }
@Override @Override
public boolean isRequiresDepthTexture() { protected boolean isRequiresDepthTexture() {
return true; return true;
} }
@Override @Override
public void postQueue(RenderManager renderManager, ViewPort viewPort) { protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
Renderer r = renderManager.getRenderer(); Renderer r = renderManager.getRenderer();
r.setFrameBuffer(normalPass.getRenderFrameBuffer()); r.setFrameBuffer(normalPass.getRenderFrameBuffer());
renderManager.getRenderer().clearBuffers(true, true, true); renderManager.getRenderer().clearBuffers(true, true, true);
@ -112,12 +112,12 @@ public class SSAOFilter extends Filter {
} }
@Override @Override
public Material getMaterial() { protected Material getMaterial() {
return material; return material;
} }
@Override @Override
public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
int screenWidth = w; int screenWidth = w;
int screenHeight = h; int screenHeight = h;
postRenderPasses = new ArrayList<Pass>(); postRenderPasses = new ArrayList<Pass>();
@ -270,7 +270,5 @@ public class SSAOFilter extends Filter {
bias = ic.readFloat("bias", 0.1f); bias = ic.readFloat("bias", 0.1f);
} }
@Override
public void cleanUpFilter(Renderer r) {
}
} }

@ -112,7 +112,6 @@ public class WaterFilter extends Filter {
private boolean underWater; private boolean underWater;
private float underWaterFogDistance = 120; private float underWaterFogDistance = 120;
private float causticsIntensity = 0.5f; private float causticsIntensity = 0.5f;
private RenderManager renderManager; private RenderManager renderManager;
private ViewPort viewPort; private ViewPort viewPort;
@ -130,12 +129,12 @@ public class WaterFilter extends Filter {
} }
@Override @Override
public boolean isRequiresDepthTexture() { protected boolean isRequiresDepthTexture() {
return true; return true;
} }
@Override @Override
public void preFrame(float tpf) { protected void preFrame(float tpf) {
time = time + (tpf * speed); time = time + (tpf * speed);
material.setFloat("Time", time); material.setFloat("Time", time);
Camera sceneCam = viewPort.getCamera(); Camera sceneCam = viewPort.getCamera();
@ -202,21 +201,14 @@ public class WaterFilter extends Filter {
} }
@Override @Override
public void init(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { protected Material getMaterial() {
super.init(manager, renderManager, vp, w, h);
this.renderManager=renderManager;
this.viewPort=vp;
}
@Override
public Material getMaterial() {
return material; return material;
} }
@Override @Override
public void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) { protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
this.renderManager = renderManager;
this.viewPort = vp;
reflectionPass = new Pass(); reflectionPass = new Pass();
reflectionPass.init(renderManager.getRenderer(), reflectionMapSize, reflectionMapSize, Format.RGBA8, Format.Depth); reflectionPass.init(renderManager.getRenderer(), reflectionMapSize, reflectionMapSize, Format.RGBA8, Format.Depth);
reflectionCam = new Camera(reflectionMapSize, reflectionMapSize); reflectionCam = new Camera(reflectionMapSize, reflectionMapSize);
@ -746,13 +738,6 @@ public class WaterFilter extends Filter {
this.reflectionMapSize = reflectionMapSize; this.reflectionMapSize = reflectionMapSize;
} }
@Override
public void cleanUpFilter(Renderer r) {
if (reflectionPass != null) {
reflectionPass.cleanup(r);
}
}
/** /**
* returns true if the water uses foam * returns true if the water uses foam
* @return * @return

Loading…
Cancel
Save