Filter postQueue method now takes a RenderQueue as parameter like SceneProcessor instead of the RenderManager and ViewPort.

Filters that were using those attributes now properly keep a reference on them in the filterInit method.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9777 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 12 years ago
parent 7f740a0cd4
commit 0e733ff100
  1. 7
      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/filters/LightScatteringFilter.java
  4. 7
      engine/src/core-effects/com/jme3/post/ssao/SSAOFilter.java
  5. 5
      engine/src/core/com/jme3/post/Filter.java
  6. 2
      engine/src/core/com/jme3/post/FilterPostProcessor.java

@ -41,6 +41,7 @@ import com.jme3.math.ColorRGBA;
import com.jme3.post.Filter;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.texture.Image.Format;
import java.io.IOException;
import java.util.ArrayList;
@ -91,6 +92,8 @@ public class BloomFilter extends Filter {
private Material hBlurMat;
private int screenWidth;
private int screenHeight;
private RenderManager renderManager;
private ViewPort viewPort;
/**
* Creates a Bloom filter
@ -110,6 +113,8 @@ public class BloomFilter extends Filter {
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
this.renderManager = renderManager;
this.viewPort = vp;
screenWidth = (int) Math.max(1, (w / downSamplingFactor));
screenHeight = (int) Math.max(1, (h / downSamplingFactor));
// System.out.println(screenWidth + " " + screenHeight);
@ -186,7 +191,7 @@ public class BloomFilter extends Filter {
}
@Override
protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
protected void postQueue(RenderQueue queue) {
if (glowMode != GlowMode.Scene) {
renderManager.getRenderer().setBackgroundColor(ColorRGBA.BlackNoAlpha);
renderManager.getRenderer().setFrameBuffer(preGlowPass.getRenderFrameBuffer());

@ -39,6 +39,7 @@ import com.jme3.post.Filter.Pass;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.texture.Image.Format;
/**
@ -56,6 +57,8 @@ public class CartoonEdgeFilter extends Filter {
private float normalSensitivity = 1.0f;
private float depthSensitivity = 10.0f;
private ColorRGBA edgeColor = new ColorRGBA(0, 0, 0, 1);
private RenderManager renderManager;
private ViewPort viewPort;
/**
* Creates a CartoonEdgeFilter
@ -70,7 +73,7 @@ public class CartoonEdgeFilter extends Filter {
}
@Override
protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
protected void postQueue(RenderQueue queue) {
Renderer r = renderManager.getRenderer();
r.setFrameBuffer(normalPass.getRenderFrameBuffer());
renderManager.getRenderer().clearBuffers(true, true, true);
@ -88,6 +91,8 @@ public class CartoonEdgeFilter extends Filter {
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
this.renderManager = renderManager;
this.viewPort = vp;
normalPass = new Pass();
normalPass.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth);
material = new Material(manager, "Common/MatDefs/Post/CartoonEdge.j3md");

@ -42,6 +42,7 @@ import com.jme3.post.Filter;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import java.io.IOException;
/**
@ -62,6 +63,7 @@ public class LightScatteringFilter extends Filter {
Vector3f viewLightPos = new Vector3f();
private boolean display = true;
private float innerLightDensity;
private ViewPort viewPort;
/**
* creates a lightScaterring filter
@ -96,7 +98,7 @@ public class LightScatteringFilter extends Filter {
}
@Override
protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
protected void postQueue(RenderQueue queue) {
getClipCoordinates(lightPosition, screenLightPos, viewPort.getCamera());
// screenLightPos.x = screenLightPos.x / viewPort.getCamera().getWidth();
// screenLightPos.y = screenLightPos.y / viewPort.getCamera().getHeight();
@ -128,6 +130,7 @@ public class LightScatteringFilter extends Filter {
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
this.viewPort = vp;
material = new Material(manager, "Common/MatDefs/Post/LightScattering.j3md");
}

@ -44,6 +44,7 @@ import com.jme3.post.Filter.Pass;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.shader.VarType;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture;
@ -75,6 +76,8 @@ public class SSAOFilter extends Filter {
// private Material downSampleMat;
// private Pass downSamplePass;
private float downSampleFactor = 1f;
private RenderManager renderManager;
private ViewPort viewPort;
/**
* Create a Screen Space Ambient Occlusion Filter
@ -104,7 +107,7 @@ public class SSAOFilter extends Filter {
}
@Override
protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
protected void postQueue(RenderQueue queue) {
Renderer r = renderManager.getRenderer();
r.setFrameBuffer(normalPass.getRenderFrameBuffer());
renderManager.getRenderer().clearBuffers(true, true, true);
@ -121,6 +124,8 @@ public class SSAOFilter extends Filter {
@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
this.renderManager = renderManager;
this.viewPort = vp;
int screenWidth = w;
int screenHeight = h;
postRenderPasses = new ArrayList<Pass>();

@ -38,6 +38,7 @@ import com.jme3.renderer.Caps;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.Renderer;
import com.jme3.renderer.ViewPort;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture;
@ -97,7 +98,7 @@ public abstract class Filter implements Savable {
public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSamples, boolean renderDepth) {
Collection<Caps> caps = renderer.getCaps();
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);
renderFrameBuffer.setDepthBuffer(depthBufferFormat);
if (renderDepth) {
@ -291,7 +292,7 @@ public abstract class Filter implements Savable {
* @param renderManager
* @param viewPort
*/
protected void postQueue(RenderManager renderManager, ViewPort viewPort) {
protected void postQueue(RenderQueue queue) {
}
/**

@ -211,7 +211,7 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
for (Iterator<Filter> it = filters.iterator(); it.hasNext();) {
Filter filter = it.next();
if (filter.isEnabled()) {
filter.postQueue(renderManager, viewPort);
filter.postQueue(rq);
}
}

Loading…
Cancel
Save