java.lang.UnsupportedOperationException: FrameBuffer already initialized. when setting numSamples on FilterPostProcessor

I’m having the same issue with any filter that requires a depth texture.

It can be reproduced whenever the FPP is initialized + contains a non-depth-texture-required filter and a depth-texture-required filter is added.

If the FPP isn’t initialized or it doesn’t contains a non-depth-texture-required filter there is no problem.

A very simple example test-case:

public class Main extends SimpleApplication implements ActionListener {

    public static void main(String[] args) { new Main().start(); }

    FilterPostProcessor fpp;

    @Override
    public void simpleInitApp() {
        fpp = new FilterPostProcessor(assetManager);
        fpp.addFilter(new BloomFilter());

        viewPort.addProcessor(fpp);

        inputManager.addListener(this, "add");
        inputManager.addMapping("add", new KeyTrigger(KeyInput.KEY_F));
    }

    @Override
    public void onAction(String name, boolean isPressed, float tpf) {
        if(isPressed) return;

        System.out.println("Adding filter");
        fpp.addFilter(new FogFilter());
    }
}

When we press the F key to add a new filter, we get the exception. If we replace the BloomFilter (doesn’t require depth) by the DepthOfFieldFilter (requires depth) or we don’t add any, the exception is gone.
If we replace the FogFilter by the RadialBlurFilter the exception is also gone.

My system specs are (Ubuntu 18.04):

INFO: Running on jMonkeyEngine 3.2-stable
 * Branch: HEAD
 * Git Hash: f85624a
 * Build Date: 2018-01-21
INFO: LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: null
 * Driver Version: null
 * Scaling Factor: 1
INFO: OpenGL Renderer Information
 * Vendor: NVIDIA Corporation
 * Renderer: GeForce GTX 980 Ti/PCIe/SSE2
 * OpenGL Version: 4.6.0 NVIDIA 390.48
 * GLSL Version: 4.60 NVIDIA
 * Profile: Compatibility

The same happens with lwjgl3:

INFO: LWJGL 3.1.2 build 29 context running on thread main
 * Graphics Adapter: GLFW 3.3.0 X11 GLX EGL clock_gettime /dev/js shared

This issue appears to be there for long now. This other post seems to be related: Post processor filters' order

2 Likes