Removing FilterPostProcessors causes graphics problem


I’ve got a game, and at the start I add some FilterPostProcessors (blooms and fog). However, when I remove them at the end (when the player goes back to the “main menu”) the displays seems to stop clearing itself, and basically redraws every frame over the top of the previous frame. Are there any special rules I need to know about when removing FilterPostProcessors, or do you know what could cause this? Thanks.

What if you provide us some code, so it would be easier to give a good answer!?

1 Like

Good idea. :slight_smile: Here’s the code, it’s a straight copy of HelloJME3 but with my filters added. When you press ‘C’, it removes the filters and the graphics freeze.

import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.scs.aresdogfighter.Statics;

public class BloomCrashTest extends SimpleApplication implements ActionListener {

    private FilterPostProcessor fpp_laser_bloom, fpp_std_bloom, fogPPS;

    public static void main(String[] args){
        BloomCrashTest app = new BloomCrashTest();
        app.showSettings = false;

    public void simpleInitApp() {
        // Create filters
        fpp_laser_bloom = new FilterPostProcessor(assetManager);
        BloomFilter bloom2 = new BloomFilter(BloomFilter.GlowMode.Objects);

        fpp_std_bloom = new FilterPostProcessor(assetManager);
        BloomFilter bloom = new BloomFilter();

        fogPPS = new FilterPostProcessor(assetManager);
        FogFilter fog = new FogFilter(ColorRGBA.White, .2f, Statics.CAM_VIEW_DIST);

        // Add them to the viewport

        Box b = new Box(1, 1, 1); // create cube shape
        Geometry geom = new Geometry("Box", b);  // create cube geometry from the shape
        Material mat = new Material(assetManager,
          "Common/MatDefs/Misc/Unshaded.j3md");  // create a simple material
        mat.setColor("Color", ColorRGBA.Blue);   // set color of material to blue
        geom.setMaterial(mat);                   // set the cube's material
        rootNode.attachChild(geom);              // make the cube appear in the scene
        inputManager.addMapping("Crash", new KeyTrigger(KeyInput.KEY_C));
        inputManager.addListener(this, "Crash");

    public void onAction(String name, boolean isPressed, float tpf) {
        if (name.equals("Crash") && isPressed) {
            System.out.println("Removing filters...");

            System.out.println("Finished removing filters");

Issue is reproduced on current master (3.2). It happens, when multiple FilterPostProcessor are added to the viewport, and then any of those FilterPostProcessor is removed. Maybe FilterPostProcessor is not designed to be used in multiple instances. Need to check the JME code.

It is easy to handle the issue in your case though. Just use a single FilterPostProcessor and keep track the filters instead of post processors. You can remove filter with FilterPostProcessor.removeFilter. Your code works fine with such approach.

UPD: tests show, that bug happens, when FilterPostProcessor instances are being removed in the wrong order. Your initial code will work, if you remove post processors in the FIFO order:


I guess JME should be fixed, and order viewPort.removeProcessor should be unimportant,

I guess it won’t be fixed as multiple FPPs are neither supported nor useful. They only waste power

Thanks all. So the best “workaround” is to add multiple filters to a single FPP?

Hello, no, this is not the best workaround, it’s the intended use of the FPP. You shoudl have only one of them for each viewport.

1 Like

Just struggled with this until I found this post. If the intended purpose of the FilterPostProcessor is to have only one per viewport, shouldn’t the viewport have a getFpp() method? (So if in different parts of the code you want to manage a different filter that fpp is easily fetched?. Currently the only way is iterating over the given list with getProcessors(). Or even, a: <T extends SceneProcessor> T getProcessor(Class<T> processorType)).

No, because a ViewPort need not EVER have a fpp.

It would be like adding a specific method to ViewPort for every different scene processor implementation that might only allow one instance.

JME can’t save users from every mistake else it will become an ugly bloated slow mess.

Well, to avoid that should work the second alternative: <T extends SceneProcessor> T getProcessor(Class<T> processorType)). However, it is right that this would not be that useful for scene processors that can allow more instances to be added (but the spatial’s getControl(T) has the same issue and it is quite helpful)