import java.util.List;
/**
- * Filter abstract class
- * Any Filter must extends this class
- * Holds a frameBuffer and a texture
- * The getMaterial must return a Material that use a GLSL shader immplementing the desired effect
+ * Filters are 2D effects applied to the rendered scene.<br>
+ * The filter is fed with the rendered scene image rendered in an offscreen frame buffer.<br>
+ * This texture is applied on a fullscreen quad, with a special material.<br>
+ * 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 {
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 {
protected FrameBuffer renderFrameBuffer;
protected Texture2D depthTexture;
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) {
Collection<Caps> caps = renderer.getCaps();
if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample) && caps.contains(Caps.OpenGL31)) {
renderFrameBuffer = new FrameBuffer(width, height, numSamples);
- renderedTexture = new Texture2D(width, height, numSamples, textureFormat);
- // depthTexture = new Texture2D(width, height, numSamples, depthBufferFormat);
+ renderedTexture = new Texture2D(width, height, numSamples, textureFormat);
} else {
renderFrameBuffer = new FrameBuffer(width, height, 1);
renderedTexture = new Texture2D(width, height, textureFormat);
- // depthTexture = new Texture2D(width, height, depthBufferFormat);
}
renderFrameBuffer.setColorTexture(renderedTexture);
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) {
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) {
init(renderer, width, height, textureFormat, depthBufferFormat, numSample);
passMaterial = material;
}
}
+ /**
+ * returns the default pass texture format
+ * @return
+ */
protected Format getDefaultPassTextureFormat() {
return Format.RGBA8;
}
+ /**
+ * returns the default pass depth format
+ * @return
+ */
protected Format getDefaultPassDepthFormat() {
return Format.Depth;
}
- public Filter() {
+ /**
+ * contruct a Filter
+ */
+ protected 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());
defaultPass = new Pass();
defaultPass.init(renderManager.getRenderer(), w, h, getDefaultPassTextureFormat(), getDefaultPassDepthFormat());
initFilter(manager, renderManager, vp, w, h);
}
- public void cleanup(Renderer r) {
+ /**
+ * cleanup this filter
+ * @param r
+ */
+ protected final void cleanup(Renderer r) {
processor = null;
if (defaultPass != null) {
defaultPass.cleanup(r);
}
/**
- * This method is called once xhen the filter is added to the FilterPostProcessor
- * It should contain Maerial initializations and extra passes initialization
- * @param manager
+ * 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
+ * @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.
*
* @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
* @param renderManager
* @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
+ * Also it can be the place to render pre passes
* @param tpf the time used to render the previous frame
*/
- public void preFrame(float tpf) {
+ protected void preFrame(float tpf) {
}
/**
* @param renderManager
* @param viewPort
*/
- public void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
+ protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
}
/**
enabled = ic.readBoolean("enabled", true);
}
+ /**
+ * returns the name of the filter
+ * @return
+ */
public String getName() {
return name;
}
+ /**
+ * Sets the name of the filter
+ * @param name
+ */
public void setName(String name) {
this.name = name;
}
- public FrameBuffer getRenderFrameBuffer() {
+ /**
+ * returns the default pass frame buffer
+ * @return
+ */
+ protected FrameBuffer getRenderFrameBuffer() {
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;
}
- public Texture2D getRenderedTexture() {
+ /**
+ * returns the rendered texture of this filter
+ * @return
+ */
+ protected Texture2D getRenderedTexture() {
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;
}
/**
- * 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
*/
- public boolean isRequiresDepthTexture() {
+ protected boolean isRequiresDepthTexture() {
return false;
}
-
- /**
+
+ /**
* Override this method and 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;
}
- public List<Pass> getPostRenderPasses() {
+ /**
+ * returns the list of the postRender passes
+ * @return
+ */
+ protected List<Pass> getPostRenderPasses() {
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) {
if (processor != null) {
processor.setFilterState(this, enabled);
}
}
+ /**
+ * returns ttrue if the filter is enabled
+ * @return enabled
+ */
public boolean isEnabled() {
return enabled;
}
+ /**
+ * sets a reference to the FilterPostProcessor ti which this filter is attached
+ * @param proc
+ */
protected void setProcessor(FilterPostProcessor proc) {
processor = proc;
}
import java.util.Iterator;\r
import java.util.List;\r
\r
+/**\r
+ * A FilterPostProcessor is a processor that can apply several {@link Filter}s to a rendered scene<br>\r
+ * It manages a list of filters that will be applied in the order in which they've been added to the list\r
+ * @author Rémy Bouquet aka Nehon\r
+ */\r
public class FilterPostProcessor implements SceneProcessor, Savable {\r
\r
private RenderManager renderManager;\r
private int originalHeight;\r
private int lastFilterIndex = -1;\r
private boolean cameraInit = false;\r
-// private boolean handleTranslucentBucket = false;\r
-// private FrameBuffer transFrameBuffer;\r
-// private Material transMaterial;\r
-// private boolean isTransparencyRendered=false;\r
\r
/**\r
- * Create a FilterProcessor constructor\r
- * @param assetManager the Asset Manager\r
+ * Create a FilterProcessor \r
+ * @param assetManager the assetManager\r
*/\r
public FilterPostProcessor(AssetManager assetManager) {\r
this.assetManager = assetManager;\r
}\r
\r
/**\r
- * Don't use this constructor use FilterPostProcessor(AssetManager assetManager)\r
+ * Don't use this constructor use {@link FilterPostProcessor(AssetManager assetManager)}<br>\r
+ * This constructor is used for serialization only\r
*/\r
public FilterPostProcessor() {\r
}\r
\r
+ /**\r
+ * Adds a filter to the filters list<br>\r
+ * @param filter the filter to add\r
+ */\r
public void addFilter(Filter filter) {\r
filters.add(filter);\r
filter.setProcessor(this);\r
\r
}\r
\r
+ /**\r
+ * removes this filters from the filters list\r
+ * @param filter \r
+ */\r
public void removeFilter(Filter filter) {\r
for (Iterator<Filter> it = filters.iterator(); it.hasNext();) {\r
if (it.next() == filter) {\r
reshape(vp, cam.getWidth(), cam.getHeight());\r
}\r
\r
+ /**\r
+ * init the given filter\r
+ * @param filter\r
+ * @param vp \r
+ */\r
private void initFilter(Filter filter, ViewPort vp) {\r
filter.init(assetManager, renderManager, vp, width, height);\r
if (filter.isRequiresDepthTexture()) {\r
}\r
}\r
\r
+ /**\r
+ * renders a filter on a fullscreen quad\r
+ * @param r\r
+ * @param buff\r
+ * @param mat \r
+ */\r
private void renderProcessing(Renderer r, FrameBuffer buff, Material mat) {\r
if (buff == outputBuffer) {\r
fsQuad.setWidth(width);\r
}\r
Picture pic = new Picture("debug");\r
\r
- public void renderFilterChain(Renderer r, FrameBuffer sceneFb) {\r
+ /**\r
+ * iterate through the filter list and renders filters\r
+ * @param r\r
+ * @param sceneFb \r
+ */\r
+ private void renderFilterChain(Renderer r, FrameBuffer sceneFb) {\r
Texture2D tex = filterTexture;\r
FrameBuffer buff = sceneFb;\r
boolean msDepth = depthTexture != null && depthTexture.getImage().getMultiSamples() > 1;\r
}\r
renderFilterChain(renderer, sceneBuffer);\r
renderManager.setCamera(viewPort.getCamera(), false);\r
- \r
+\r
renderer.setFrameBuffer(outputBuffer);\r
\r
}\r
\r
}\r
\r
+ /**\r
+ * sets the filter to enabled or disabled\r
+ * @param filter\r
+ * @param enabled \r
+ */\r
protected void setFilterState(Filter filter, boolean enabled) {\r
if (filters.contains(filter)) {\r
filter.enabled = enabled;\r
}\r
}\r
\r
+ /**\r
+ * compute the index of the last filter to render\r
+ */\r
private void updateLastFilterIndex() {\r
lastFilterIndex = -1;\r
for (int i = filters.size() - 1; i >= 0 && lastFilterIndex == -1; i--) {\r
this.assetManager = assetManager;\r
}\r
\r
- /**\r
- * Writes the processor\r
- * @param ex\r
- * @throws IOException\r
- */\r
public void write(JmeExporter ex) throws IOException {\r
OutputCapsule oc = ex.getCapsule(this);\r
oc.write(numSamples, "numSamples", 0);\r
oc.writeSavableArrayList((ArrayList) filters, "filters", null);\r
}\r
\r
- /**\r
- * Reads the processor\r
- * @param im\r
- * @throws IOException\r
- */\r
public void read(JmeImporter im) throws IOException {\r
InputCapsule ic = im.getCapsule(this);\r
numSamples = ic.readInt("numSamples", 0);\r
filters = ic.readSavableArrayList("filters", null);\r
}\r
\r
+ /**\r
+ * For internal use only<br>\r
+ * returns the depth texture of the scene\r
+ * @return \r
+ */\r
public Texture2D getDepthTexture() {\r
return depthTexture;\r
}\r
\r
+ /**\r
+ * For internal use only<br>\r
+ * returns the rendered texture of the scene\r
+ * @return \r
+ */\r
public Texture2D getFilterTexture() {\r
return filterTexture;\r
}\r
import com.jme3.renderer.queue.RenderQueue;
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 {
/**
+ * For internal use only<br>
* Called in the render thread to initialize the scene processor.
*
* @param rm The render manager to which the SP was added to
public void initialize(RenderManager rm, ViewPort vp);
/**
+ * For internal use only<br>
* Called when the resolution of the viewport has been changed.
* @param vp
*/
public boolean isInitialized();
/**
+ * For internal use only<br>
* Called before a frame
*
* @param tpf Time per frame
public void preFrame(float tpf);
/**
+ * For internal use only<br>
* Called after the scene graph has been queued, but before it is flushed.
*
* @param rq The render queue
public void postQueue(RenderQueue rq);
/**
+ * For internal use only<br>
* Called after a frame has been rendered and the queue flushed.
*
* @param out The FB to which the scene was rendered.
public void postFrame(FrameBuffer out);
/**
+ * For internal use only<br>
* Called when the SP is removed from the RM.
*/
public void cleanup();
import com.jme3.math.ColorRGBA;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
import com.jme3.texture.Image.Format;
import java.io.IOException;
import java.util.ArrayList;
/**
- * <code>BloomFilter</code> is used to make objects in the scene have a
- * "soap opera" glow effect.
- *
- * @author Nehon
+ * BloomFilter is used to make objects in the scene have a glow effect.<br>
+ * 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 Rémy Bouquet aka Nehon
*/
public class BloomFilter extends Filter {
/**
- * <code>GlowMode</code> specifies if bright objects or objects
- * with glow map will be bloomed.
+ * GlowMode specifies if the glow will be applied to the whole scene,or to objects that have aglow color or a glow map
*/
public enum GlowMode {
/**
- * Apply bloom filter to bright objects in the scene.
+ * Apply bloom filter to bright areas in the 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,
/**
- * 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;
}
private ColorRGBA backupColor;
/**
- * creates a Bloom filter
+ * Creates a Bloom filter
*/
public BloomFilter() {
super("BloomFilter");
}
/**
- * Crete the bloom filter with the specific glow mode
+ * Creates the bloom filter with the specific glow mode
* @param glowMode
*/
public BloomFilter(GlowMode glowMode) {
}
@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);
screenHeight = (int) (h / downSamplingFactor);
// System.out.println(screenWidth + " " + screenHeight);
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
- public Material getMaterial() {
+ protected Material getMaterial() {
material.setFloat("BloomIntensity", bloomIntensity);
return material;
}
@Override
- public void postQueue(RenderManager renderManager, ViewPort viewPort) {
+ protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
if (glowMode != GlowMode.Scene) {
backupColor = viewPort.getBackgroundColor();
viewPort.setBackgroundColor(ColorRGBA.Black);
}
}
+ /**
+ * returns the bloom intensity
+ * @return
+ */
public float getBloomIntensity() {
return bloomIntensity;
}
/**
- * intensity of the bloom effect
+ * intensity of the bloom effect default is 2.0
* @param bloomIntensity
*/
public void setBloomIntensity(float bloomIntensity) {
this.bloomIntensity = bloomIntensity;
}
+ /**
+ * returns the blur scale
+ * @return
+ */
public float getBlurScale() {
return blurScale;
}
/**
- * The spread of the bloom
+ * sets The spread of the bloom default is 1.5f
* @param blurScale
*/
public void setBlurScale(float blurScale) {
this.blurScale = blurScale;
}
+ /**
+ * returns the exposure cutoff<br>
+ * for more details see {@link setExposureCutOff(float exposureCutOff)}
+ * @return
+ */
public float getExposureCutOff() {
return exposureCutOff;
}
this.exposureCutOff = exposureCutOff;
}
+ /**
+ * returns the exposure power<br>
+ * form more details see {@link setExposurePower(float exposurePower)}
+ * @return
+ */
public float getExposurePower() {
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
*/
public void setExposurePower(float exposurePower) {
}
/**
- * returns the downSampling factor
+ * returns the downSampling factor<br>
+ * form more details see {@link setDownSamplingFactor(float downSamplingFactor)}
* @return
*/
public float getDownSamplingFactor() {
}
/**
- * 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
* @param downSamplingFactor
*/
private float depthThreshold = 0.1f;
private float normalSensitivity = 1.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() {
super("CartoonEdgeFilter");
}
@Override
- public boolean isRequiresDepthTexture() {
+ protected boolean isRequiresDepthTexture() {
return true;
}
@Override
- public void postQueue(RenderManager renderManager, ViewPort viewPort) {
+ protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
Renderer r = renderManager.getRenderer();
r.setFrameBuffer(normalPass.getRenderFrameBuffer());
renderManager.getRenderer().clearBuffers(true, true, true);
}
@Override
- public Material getMaterial() {
+ protected Material getMaterial() {
material.setTexture("NormalsTexture", normalPass.getRenderedTexture());
return material;
}
@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.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth);
material = new Material(manager, "Common/MatDefs/Post/CartoonEdge.j3md");
material.setColor("EdgeColor", edgeColor);
}
- @Override
- public void cleanUpFilter(Renderer r) {
- if (normalPass != null) {
- normalPass.cleanup(r);
- }
- }
-
+ /**
+ * Return the depth sensitivity<br>
+ * for more details see {@link setDepthSensitivity(float depthSensitivity)}
+ * @return
+ */
public float getDepthSensitivity() {
return depthSensitivity;
}
+ /**
+ * sets the depth sensitivity<br>
+ * defines how much depth will influence edges, default is 10
+ * @param depthSensitivity
+ */
public void setDepthSensitivity(float depthSensitivity) {
this.depthSensitivity = depthSensitivity;
if (material != null) {
}
}
+ /**
+ * returns the depth threshold<br>
+ * for more details see {@link setDepthThreshold(float depthThreshold)}
+ * @return
+ */
public float getDepthThreshold() {
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) {
this.depthThreshold = depthThreshold;
if (material != null) {
}
}
+ /**
+ * returns the edge intensity<br>
+ * for more details see {@link setEdgeIntensity(float edgeIntensity) }
+ * @return
+ */
public float getEdgeIntensity() {
return edgeIntensity;
}
+ /**
+ * sets the edge intensity<br>
+ * Defineshow visilble will be the outlined edges
+ * @param edgeIntensity
+ */
public void setEdgeIntensity(float edgeIntensity) {
this.edgeIntensity = edgeIntensity;
if (material != null) {
}
}
+ /**
+ * returns the width of the edges
+ * @return
+ */
public float getEdgeWidth() {
return edgeWidth;
}
+ /**
+ * sets the witdh of the edge in pixels default is 1
+ * @param edgeWidth
+ */
public void setEdgeWidth(float edgeWidth) {
this.edgeWidth = edgeWidth;
if (material != null) {
}
+ /**
+ * returns the normals sensitivity<br>
+ * form more details see {@link setNormalSensitivity(float normalSensitivity)}
+ * @return
+ */
public float getNormalSensitivity() {
return normalSensitivity;
}
+ /**
+ * sets the normals sensitivity default is 1
+ * @param normalSensitivity
+ */
public void setNormalSensitivity(float normalSensitivity) {
this.normalSensitivity = normalSensitivity;
if (material != null) {
}
}
+ /**
+ * returns the normal threshold<br>
+ * for more details see {@link setNormalThreshold(float normalThreshold)}
+ *
+ * @return
+ */
public float getNormalThreshold() {
return normalThreshold;
}
+ /**
+ * sets the normal threshold default is 0.5
+ * @param normalThreshold
+ */
public void setNormalThreshold(float normalThreshold) {
this.normalThreshold = normalThreshold;
if (material != null) {
*/
public void setEdgeColor(ColorRGBA edgeColor) {
this.edgeColor = edgeColor;
- if(material!=null){
+ if (material != null) {
material.setColor("EdgeColor", edgeColor);
}
}
-
-
}
import com.jme3.math.ColorRGBA;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
import java.io.IOException;
/**
- *
- * @author nehon
+ * This filter simply multiply the whole scene by a color
+ * @author Rémy Bouquet aka Nehon
*/
public class ColorOverlayFilter extends Filter {
private ColorRGBA color = ColorRGBA.White;
+ /**
+ * creates a colorOverlayFilter with a white coor (transparent)
+ */
public ColorOverlayFilter() {
super("Color Overlay");
}
+ /**
+ * creates a colorOverlayFilter with the given color
+ * @param color
+ */
public ColorOverlayFilter(ColorRGBA color) {
this();
this.color = color;
}
@Override
- public Material getMaterial() {
+ protected Material getMaterial() {
material.setColor("Color", color);
return material;
}
+ /**
+ * returns the color
+ * @return color
+ */
public ColorRGBA getColor() {
return color;
}
+ /**
+ * sets the color
+ * @param color
+ */
public void setColor(ColorRGBA color) {
this.color = color;
}
@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");
}
InputCapsule ic = im.getCapsule(this);
color = (ColorRGBA) ic.readSavable("color", ColorRGBA.White);
}
-
- @Override
- public void cleanUpFilter(Renderer r) {
- }
}
import com.jme3.math.ColorRGBA;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
/*
private float lineThickness = 1.0f;
private float lineDistance = 4.0f;
+ /**
+ * Creates a crossHatch filter
+ */
public 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) {
this();
this.lineColor = lineColor;
}
@Override
- public boolean isRequiresDepthTexture() {
+ protected boolean isRequiresDepthTexture() {
return false;
}
@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.setColor("LineColor", lineColor);
material.setColor("PaperColor", paperColor);
}
@Override
- public Material getMaterial() {
+ protected Material getMaterial() {
return material;
}
- @Override
- public void cleanUpFilter(Renderer r) {
- }
-
- /*
+ /**
* Sets color used to draw lines
+ * @param lineColor
*/
public void setLineColor(ColorRGBA lineColor) {
this.lineColor = lineColor;
}
}
- /*
+ /**
* Sets color used as background
+ * @param paperColor
*/
public void setPaperColor(ColorRGBA paperColor) {
this.paperColor = paperColor;
material.setColor("PaperColor", paperColor);
}
}
- /*
+
+ /**
* Sets color influence of original image on lines drawn
+ * @param colorInfluenceLine
*/
-
public void setColorInfluenceLine(float colorInfluenceLine) {
this.colorInfluenceLine = colorInfluenceLine;
if (material != null) {
}
}
- /*
+ /**
* Sets color influence of original image on non-line areas
+ * @param colorInfluencePaper
*/
public void setColorInfluencePaper(float colorInfluencePaper) {
this.colorInfluencePaper = colorInfluencePaper;
}
}
- /*
+ /**
* Sets line/paper color ratio for areas with values < luminance5,
* really dark areas get no lines but a filled blob instead
+ * @param fillValue
*/
public void setFillValue(float fillValue) {
this.fillValue = fillValue;
}
}
- /*
+ /**
+ *
* Sets minimum luminance levels for lines drawn
- * Luminance1: Top-left to down right 1
- * Luminance2: Top-right to bottom left 1
- * Luminance3: Top-left to down right 2
- * Luminance4: Top-right to bottom left 2
- * Luminance5: Blobs
+ * @param luminance1 Top-left to down right 1
+ * @param luminance2 Top-right to bottom left 1
+ * @param luminance3 Top-left to down right 2
+ * @param luminance4 Top-right to bottom left 2
+ * @param luminance5 Blobs
*/
public void setLuminanceLevels(float luminance1, float luminance2, float luminance3, float luminance4, float luminance5) {
this.luminance1 = luminance1;
}
}
- /*
+ /**
* Sets the thickness of lines drawn
+ * @param lineThickness
*/
public void setLineThickness(float lineThickness) {
this.lineThickness = lineThickness;
}
}
- /*
+ /**
* Sets minimum distance between lines drawn
* Primary lines are drawn at 2*lineDistance
* Secondary lines are drawn at lineDistance
+ * @param lineDistance
*/
public void setLineDistance(float lineDistance) {
this.lineDistance = lineDistance;
}
}
- /*
+ /**
* Returns line color
+ * @return
*/
public ColorRGBA getLineColor() {
return lineColor;
}
- /*
+ /**
* Returns paper background color
+ * @return
*/
public ColorRGBA getPaperColor() {
return paperColor;
}
- /*
+ /**
* Returns current influence of image colors on lines
*/
public float getColorInfluenceLine() {
return colorInfluenceLine;
}
- /*
+ /**
* Returns current influence of image colors on paper background
*/
public float getColorInfluencePaper() {
return colorInfluencePaper;
}
- /*
+ /**
* Returns line/paper color ratio for blobs
*/
public float getFillValue() {
return fillValue;
}
- /*
+ /**
* Returns the thickness of the lines drawn
*/
public float getLineThickness() {
return lineThickness;
}
- /*
+ /**
* Returns minimum distance between lines
*/
public float getLineDistance() {
return lineDistance;
}
- /*
+ /**
* Returns treshold for lines 1
*/
public float getLuminance1() {
return luminance1;
}
- /*
+ /**
* Returns treshold for lines 2
*/
public float getLuminance2() {
return luminance2;
}
- /*
+ /**
* Returns treshold for lines 3
*/
public float getLuminance3() {
return luminance3;
}
- /*
+ /**
* Returns treshold for lines 4
*/
public float getLuminance4() {
return luminance4;
}
- /*
+ /**
* Returns treshold for blobs
*/
public float getLuminance5() {
import com.jme3.post.Filter;
import com.jme3.material.Material;
import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
/**
private float xScale;
private float yScale;
+ /**
+ * Creates a DepthOfField filter
+ */
public DepthOfFieldFilter() {
super("Depth Of Field");
}
@Override
- public boolean isRequiresDepthTexture() {
+ protected boolean isRequiresDepthTexture() {
return true;
}
@Override
- public Material getMaterial() {
+ protected Material getMaterial() {
return material;
}
@Override
- public void initFilter(AssetManager assets, RenderManager renderManager,
+ protected void initFilter(AssetManager assets, RenderManager renderManager,
ViewPort vp, int w, int h) {
material = new Material(assets, "Common/MatDefs/Post/DepthOfField.j3md");
material.setFloat("FocusDistance", focusDistance);
material.setFloat("FocusRange", focusRange);
-
+
xScale = 1.0f / w;
yScale = 1.0f / h;
material.setFloat("YScale", blurScale * yScale);
}
- @Override
- public void cleanUpFilter(Renderer r) {
- }
-
/**
* Sets the distance at which objects are purely in focus.
*/
}
+ /**
+ * returns the focus distance
+ * @return
+ */
public float getFocusDistance() {
return focusDistance;
}
}
+ /**
+ * returns the focus range
+ * @return
+ */
public float getFocusRange() {
return focusRange;
}
}
}
+ /**
+ * returns the blur scale
+ * @return
+ */
public float getBlurScale() {
return blurScale;
}
import com.jme3.material.Material;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
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
* see http://jmonkeyengine.org/groups/graphics/forum/topic/newbie-question-general-fade-inout-effect/#post-105559
*/
private float direction = 1;
private float duration = 1;
+ /**
+ * Creates a FadeFilter
+ */
public FadeFilter() {
super("Fade In/Out");
}
+ /**
+ * Creates a FadeFilter with the given duration
+ * @param duration
+ */
public FadeFilter(float duration) {
this();
this.duration = duration;
}
@Override
- public Material getMaterial() {
+ protected Material getMaterial() {
material.setFloat("Value", value);
return material;
}
-
@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");
}
@Override
- public void preFrame(float tpf) {
+ protected void preFrame(float tpf) {
if (playing) {
value += tpf * direction / duration;
}
}
+ /**
+ * returns the duration of the effect
+ * @return
+ */
public float getDuration() {
return duration;
}
+ /**
+ * Sets the duration of the filter default is 1 second
+ * @param duration
+ */
public void setDuration(float duration) {
this.duration = duration;
}
+ /**
+ * fades the scene in (black to scene)
+ */
public void fadeIn() {
setEnabled(true);
direction = 1;
playing = true;
}
+ /**
+ * fades the scene out (scene to black)
+ */
public void fadeOut() {
setEnabled(true);
direction = -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() {
return value;
}
+ /**
+ * sets the fade value
+ * can be used to force complete black or compete scene
+ * @param value
+ */
public void setValue(float value) {
this.value = value;
}
-
- @Override
- public void cleanUpFilter(Renderer r) {
- }
}
import com.jme3.math.ColorRGBA;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
import java.io.IOException;
/**
* A filter to render a fog effect
- * @author Nehon
+ * @author Rémy Bouquet aka Nehon
*/
public class FogFilter extends Filter {
private float fogDensity = 0.7f;
private float fogDistance = 1000;
+ /**
+ * Creates a FogFilter
+ */
public FogFilter() {
super("FogFilter");
}
}
@Override
- public boolean isRequiresDepthTexture() {
+ protected boolean isRequiresDepthTexture() {
return true;
}
@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.setColor("FogColor", fogColor);
material.setFloat("FogDensity", fogDensity);
}
@Override
- public Material getMaterial() {
+ protected Material getMaterial() {
return material;
}
fogDistance = ic.readFloat("fogDistance", 1000);
}
- @Override
- public void cleanUpFilter(Renderer r) {
- }
+
}
import com.jme3.post.Filter;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
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 {
private float lightDensity = 1.4f;
private boolean adaptative = true;
Vector3f viewLightPos = new Vector3f();
- private boolean display=true;
+ private boolean display = true;
private float innerLightDensity;
+ /**
+ * creates a lightScaterring filter
+ */
public LightScatteringFilter() {
super("Light Scattering");
}
+ /**
+ * Creates a lightScatteringFilter
+ * @param lightPosition
+ */
public LightScatteringFilter(Vector3f lightPosition) {
this();
this.lightPosition = lightPosition;
}
@Override
- public boolean isRequiresDepthTexture() {
+ protected boolean isRequiresDepthTexture() {
return true;
}
@Override
- public Material getMaterial() {
+ protected Material getMaterial() {
material.setVector3("LightPosition", screenLightPos);
material.setInt("NbSamples", nbSamples);
material.setFloat("BlurStart", blurStart);
}
@Override
- public void postQueue(RenderManager renderManager, ViewPort viewPort) {
+ protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
getClipCoordinates(lightPosition, screenLightPos, viewPort.getCamera());
// screenLightPos.x = screenLightPos.x / viewPort.getCamera().getWidth();
// screenLightPos.y = screenLightPos.y / viewPort.getCamera().getHeight();
//System.err.println("screenLightPos "+screenLightPos);
if (adaptative) {
innerLightDensity = Math.max(lightDensity - Math.max(screenLightPos.x, screenLightPos.y), 0.0f);
- }else{
- innerLightDensity=lightDensity;
+ } else {
+ 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);
store.divideLocal(w);
}
@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");
}
+ /**
+ * returns the blur start of the scattering
+ * see {@link setBlurStart(float blurStart)}
+ * @return
+ */
public float getBlurStart() {
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) {
this.blurStart = blurStart;
}
+ /**
+ * returns the blur width<br>
+ * see {@link setBlurWidth(float blurWidth)}
+ * @return
+ */
public float getBlurWidth() {
return blurWidth;
}
+ /**
+ * sets the blur width default is 0.9
+ * @param blurWidth
+ */
public void setBlurWidth(float blurWidth) {
this.blurWidth = blurWidth;
}
+ /**
+ * retiurns the light density<br>
+ * see {@link setLightDensity(float lightDensity)}
+ *
+ * @return
+ */
public float getLightDensity() {
return lightDensity;
}
+ /**
+ * sets how much the effect is visible over the rendered scene default is 1.4
+ * @param lightDensity
+ */
public void setLightDensity(float lightDensity) {
this.lightDensity = lightDensity;
}
+ /**
+ * returns the light position
+ * @return
+ */
public Vector3f getLightPosition() {
return lightPosition;
}
+ /**
+ * sets the light position
+ * @param lightPosition
+ */
public void setLightPosition(Vector3f lightPosition) {
this.lightPosition = lightPosition;
}
+ /**
+ * returns the nmber of samples for the radial blur
+ * @return
+ */
public int getNbSamples() {
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) {
this.nbSamples = nbSamples;
}
lightDensity = ic.readFloat("lightDensity", 1.4f);
adaptative = ic.readBoolean("adaptative", true);
}
-
- @Override
- public void cleanUpFilter(Renderer r) {
- }
}
import com.jme3.material.Material;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
/**
private float gamma = 0.6f;
private float strength = 1.0f;
+ /**
+ * Creates a posterization Filter
+ */
public PosterizationFilter() {
super("PosterizationFilter");
}
+ /**
+ * Creates a posterization Filter with the given number of colors
+ * @param numColors
+ */
public PosterizationFilter(int numColors) {
this();
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) {
this(numColors);
this.gamma = gamma;
}
@Override
- public boolean isRequiresDepthTexture() {
- return false;
- }
-
- @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/Posterization.j3md");
material.setInt("NumColors", numColors);
material.setFloat("Gamma", gamma);
}
@Override
- public Material getMaterial() {
+ protected Material getMaterial() {
return material;
}
-
- @Override
- public void cleanUpFilter(Renderer r) {
- }
-
- /*
+ /**
* Sets number of color levels used to draw the screen
*/
public void setNumColors(int numColors) {
}
}
- /*
+ /**
* Sets gamma level used to enhange visual quality
*/
public void setGamma(float gamma) {
}
}
- /*
+ /**
* Sets urrent strength value, i.e. influence on final image
*/
public void setStrength(float strength) {
}
}
- /*
+ /**
* Returns number of color levels used
*/
public int getNumColors() {
return numColors;
}
- /*
+ /**
* Returns current gamma value
*/
public float getGamma() {
return gamma;
}
- /*
+ /**
* Returns current strength value, i.e. influence on final image
*/
public float getStrength() {
import com.jme3.material.Material;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
-import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
import com.jme3.shader.VarType;
import java.io.IOException;
/**
- *
- * @author nehon
+ * Radially blurs the scene from the center of it
+ * @author Rémy Bouquet aka Nehon
*/
public class RadialBlurFilter extends Filter {
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};
+ /**
+ * Creates a RadialBlurFilter
+ */
public RadialBlurFilter() {
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) {
this();
this.sampleDist = sampleDist;
}
@Override
- public Material getMaterial() {
+ protected Material getMaterial() {
material.setFloat("SampleDist", sampleDist);
material.setFloat("SampleStrength", sampleStrength);
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() {
return sampleDist;
}
+ /**
+ *
+ * @param sampleDist
+ * @deprecated use {@link setSampleDistance(float sampleDist)}
+ */
+ @Deprecated
public void setSampleDist(float sampleDist) {
this.sampleDist = sampleDist;
}
+ /**
+ * Returns the sample Strength
+ * @return
+ */
public float getSampleStrength() {
return sampleStrength;
}
+ /**
+ * sets the sample streanght default is 2.2
+ * @param sampleStrength
+ */
public void setSampleStrength(float sampleStrength) {
this.sampleStrength = sampleStrength;
}
@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");
}
sampleDist = ic.readFloat("sampleDist", 1.0f);
sampleStrength = ic.readFloat("sampleStrength", 2.2f);
}
-
- @Override
- public void cleanUpFilter(Renderer r) {
- }
}
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
*/
public final class TranslucentBucketFilter extends Filter {
private RenderManager renderManager;
@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;
material = new Material(manager, "Common/MatDefs/Post/Overlay.j3md");
material.setColor("Color", ColorRGBA.White);
}
renderManager.setHandleTranslucentBucket(false);
}
-
- /**
+
+ /**
* Override this method and return false if your Filter does not need the scene texture
* @return
*/
- public boolean isRequiresSceneTexture() {
+ @Override
+ protected boolean isRequiresSceneTexture() {
return false;
}
@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);
- if(prevFilterBuffer != sceneBuffer){
+ if (prevFilterBuffer != sceneBuffer) {
renderManager.getRenderer().copyFrameBuffer(prevFilterBuffer, sceneBuffer, false);
}
renderManager.getRenderer().setFrameBuffer(sceneBuffer);
}
@Override
- public void cleanUpFilter(Renderer r) {
+ protected void cleanUpFilter(Renderer r) {
if (renderManager != null) {
renderManager.setHandleTranslucentBucket(true);
}
}
@Override
- public Material getMaterial() {
+ protected Material getMaterial() {
return material;
}
}
@Override
- public boolean isRequiresDepthTexture() {
+ protected boolean isRequiresDepthTexture() {
return true;
}
@Override
- public void postQueue(RenderManager renderManager, ViewPort viewPort) {
+ protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
Renderer r = renderManager.getRenderer();
r.setFrameBuffer(normalPass.getRenderFrameBuffer());
renderManager.getRenderer().clearBuffers(true, true, true);
}
@Override
- public Material getMaterial() {
+ protected Material getMaterial() {
return material;
}
@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 screenHeight = h;
postRenderPasses = new ArrayList<Pass>();
bias = ic.readFloat("bias", 0.1f);
}
- @Override
- public void cleanUpFilter(Renderer r) {
- }
+
}
private boolean underWater;
private float underWaterFogDistance = 120;
private float causticsIntensity = 0.5f;
-
private RenderManager renderManager;
private ViewPort viewPort;
}
@Override
- public boolean isRequiresDepthTexture() {
+ protected boolean isRequiresDepthTexture() {
return true;
}
@Override
- public void preFrame(float tpf) {
+ protected void preFrame(float tpf) {
time = time + (tpf * speed);
material.setFloat("Time", time);
Camera sceneCam = viewPort.getCamera();
float planeDistance = plane.pseudoDistance(vars.vect1);
vars.vect2.set(plane.getNormal()).multLocal(planeDistance * 2.0f);
vars.vect3.set(vars.vect1.subtractLocal(vars.vect2)).subtractLocal(loc).normalizeLocal().negateLocal();
-
+
reflectionCam.lookAt(targetLocation, vars.vect3);
assert vars.unlock();
}
renderManager.setCamera(sceneCam, false);
renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer());
-
-
+
+
underWater = false;
} else {
underWater = true;
}
@Override
- public void init(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
- super.init(manager, renderManager, vp, w, h);
- this.renderManager=renderManager;
- this.viewPort=vp;
- }
-
-
- @Override
- public Material getMaterial() {
+ protected Material getMaterial() {
return material;
}
@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.init(renderManager.getRenderer(), reflectionMapSize, reflectionMapSize, Format.RGBA8, Format.Depth);
reflectionCam = new Camera(reflectionMapSize, reflectionMapSize);
this.reflectionMapSize = reflectionMapSize;
}
- @Override
- public void cleanUpFilter(Renderer r) {
- if (reflectionPass != null) {
- reflectionPass.cleanup(r);
- }
- }
-
/**
* returns true if the water uses foam
* @return