- Made the FilterPostProcessor cleanup delete framebuffers and textures form memory.

- Changed the way the filter porcessor handle the rendering of the filter; depth right is not disabled anymore when it sjouldn't alowing a filter to output depth with gl_FragDepth if needed

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10955 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
rem..om 11 years ago
parent 81b458cc4b
commit 147ff8796d
  1. 8
      engine/src/core-effects/com/jme3/post/filters/BloomFilter.java
  2. 7
      engine/src/core-effects/com/jme3/post/filters/CartoonEdgeFilter.java
  3. 5
      engine/src/core-effects/com/jme3/post/ssao/SSAOFilter.java
  4. 6
      engine/src/core-effects/com/jme3/water/WaterFilter.java
  5. 7
      engine/src/core/com/jme3/post/Filter.java
  6. 20
      engine/src/core/com/jme3/post/FilterPostProcessor.java

@ -40,6 +40,7 @@ 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.renderer.queue.RenderQueue; import com.jme3.renderer.queue.RenderQueue;
import com.jme3.texture.Image.Format; import com.jme3.texture.Image.Format;
@ -216,6 +217,13 @@ public class BloomFilter extends Filter {
} }
} }
@Override
protected void cleanUpFilter(Renderer r) {
if (glowMode != GlowMode.Scene) {
preGlowPass.cleanup(r);
}
}
/** /**
* returns the bloom intensity * returns the bloom intensity
* @return * @return

@ -105,6 +105,13 @@ public class CartoonEdgeFilter extends Filter {
material.setColor("EdgeColor", edgeColor); material.setColor("EdgeColor", edgeColor);
} }
@Override
protected void cleanUpFilter(Renderer r) {
normalPass.cleanup(r);
}
/** /**
* Return the depth sensitivity<br> * Return the depth sensitivity<br>
* for more details see {@link #setDepthSensitivity(float depthSensitivity)} * for more details see {@link #setDepthSensitivity(float depthSensitivity)}

@ -188,6 +188,11 @@ public class SSAOFilter extends Filter {
} }
@Override
protected void cleanUpFilter(Renderer r) {
normalPass.cleanup(r);
}
/** /**
* Return the bias<br> * Return the bias<br>
* see {@link #setBias(float bias)} * see {@link #setBias(float bias)}

@ -44,6 +44,7 @@ import com.jme3.post.Filter;
import com.jme3.post.Filter.Pass; import com.jme3.post.Filter.Pass;
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 com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
@ -282,6 +283,11 @@ public class WaterFilter extends Filter {
} }
@Override
protected void cleanUpFilter(Renderer r) {
reflectionPass.cleanup(r);
}
@Override @Override
public void write(JmeExporter ex) throws IOException { public void write(JmeExporter ex) throws IOException {
super.write(ex); super.write(ex);

@ -191,6 +191,11 @@ public abstract class Filter implements Savable {
} }
public void cleanup(Renderer r) { public void cleanup(Renderer r) {
r.deleteFrameBuffer(renderFrameBuffer);
r.deleteImage(renderedTexture.getImage());
if(depthTexture!=null){
r.deleteImage(depthTexture.getImage());
}
} }
} }
@ -437,4 +442,4 @@ public abstract class Filter implements Savable {
protected void setProcessor(FilterPostProcessor proc) { protected void setProcessor(FilterPostProcessor proc) {
processor = proc; processor = proc;
} }
} }

@ -182,17 +182,19 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
viewPort.getCamera().setViewPort(left, right, bottom, top); viewPort.getCamera().setViewPort(left, right, bottom, top);
viewPort.getCamera().update(); viewPort.getCamera().update();
renderManager.setCamera( viewPort.getCamera(), false); renderManager.setCamera( viewPort.getCamera(), false);
if (mat.getAdditionalRenderState().isDepthWrite()) {
mat.getAdditionalRenderState().setDepthTest(false);
mat.getAdditionalRenderState().setDepthWrite(false);
}
}else{ }else{
viewPort.getCamera().resize(buff.getWidth(), buff.getHeight(), false); viewPort.getCamera().resize(buff.getWidth(), buff.getHeight(), false);
viewPort.getCamera().setViewPort(0, 1, 0, 1); viewPort.getCamera().setViewPort(0, 1, 0, 1);
viewPort.getCamera().update(); viewPort.getCamera().update();
renderManager.setCamera( viewPort.getCamera(), false); renderManager.setCamera( viewPort.getCamera(), false);
mat.getAdditionalRenderState().setDepthTest(true);
mat.getAdditionalRenderState().setDepthWrite(true);
} }
if (mat.getAdditionalRenderState().isDepthWrite()) {
mat.getAdditionalRenderState().setDepthTest(false);
mat.getAdditionalRenderState().setDepthWrite(false);
}
fsQuad.setMaterial(mat); fsQuad.setMaterial(mat);
fsQuad.updateGeometricState(); fsQuad.updateGeometricState();
@ -375,6 +377,14 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
viewPort.getCamera().setViewPort(left, right, bottom, top); viewPort.getCamera().setViewPort(left, right, bottom, top);
viewPort.setOutputFrameBuffer(outputBuffer); viewPort.setOutputFrameBuffer(outputBuffer);
viewPort = null; viewPort = null;
renderManager.getRenderer().deleteFrameBuffer(renderFrameBuffer);
if(depthTexture!=null){
renderManager.getRenderer().deleteImage(depthTexture.getImage());
}
renderManager.getRenderer().deleteImage(filterTexture.getImage());
if(renderFrameBufferMS != null){
renderManager.getRenderer().deleteFrameBuffer(renderFrameBufferMS);
}
for (Filter filter : filters) { for (Filter filter : filters) {
filter.cleanup(renderer); filter.cleanup(renderer);
} }
@ -549,4 +559,4 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
viewPort.setOutputFrameBuffer(renderFrameBuffer); viewPort.setOutputFrameBuffer(renderFrameBuffer);
} }
} }
} }

Loading…
Cancel
Save