FilterPostProcessor issues on custom viewport

I’m rendering spaceships to an image and want to add some eye candy to it. In order for it to work, I create an offscreen viewport (2 of them actually, one for background and one for the actual spaceship) and a framebuffer.
When I add a FilterPostProcessor to the viewport nothing happens, since it is empty. But if I add any filters to the fpp, the output image goes bananas, no matter which filter I use.
Example of a render without fpp:

Example of a render with fpp which has a filter (FXAA in this case, but results are the same if I use anything else):

As you can see, the background becomes black and some colors go very weird.

Here is the code that sets everything up:

    renderCam = new Camera(1280, 720);
    renderCam.setLocation(new Vector3f(20, 20, 20));
    renderCam.lookAt(new Vector3f(0, -5, 0), Vector3f.UNIT_Y);
    Camera c =;
    renderCam.setFrustum(c.getFrustumNear(), c.getFrustumFar(), c.getFrustumLeft(), c.getFrustumRight(), c.getFrustumTop(), c.getFrustumBottom());
    renderCam.setFrustumPerspective(45f, 16f/9f, 1f, 1000f);

    //Create a background
    bgViewport = renderManager.createPreView("background", renderCam);
    bgViewport.setClearFlags(true, true, true);
    bgPic = new Picture("background");
    bgPic.setImage(, "assets/img/menu/workshopbackground.jpg", false);
    bgPic.setPosition(0, 0);

    renderingViewport = renderManager.createPreView("imageRenderer", renderCam);
    renderingViewport.setClearFlags(false, true, true);

    dl = new DirectionalLight(new Vector3f(1, -1, -2));

    DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(, 1024, 2);
    dlsr.getPreShadowForcedRenderState().setPolyOffset(6, 3);

    FilterPostProcessor fpp = new FilterPostProcessor(;
    FXAAFilter fxaa = new FXAAFilter();


    fbuff = new FrameBuffer(1280, 720, 1);


I always set fpp.setSamples to the Appsettings Value for AA Samples, but I dont know how relevant that is for offscreen rendering

FXAA is used only for demonstration here. Same thing happens with any other filter. Thanks for the tip though.

I mean FPP’s Setting of setNumSamples. I remember it making problems when not being equal to the value of the Viewport/appSettings. But for a custom viewport you might not have antialiasing at all in general?

Tried to set the clear depth to false too?

what is “this”?

On a side note, why are you rendering the fixed image in a separate viewport?

Havent tested turning those off yet. Will try.

You can safely ignore the addProcessor(this); line, because that this is just a class that writes render result to file in postFrame().

I have a separate viewport for the background instead of a quad behind the ship so I can move the camera and dont have to care about moving the background quad.

@Darkchaos I tried fpp.setNumSamples(8) with my aa was set to 8 and whole screen went black.

Well there are much easier way to do that.
make a 1,1 quad, make a geom from it and put it in the sky bucket. Set the cull hint to never and put it in the root node wherever you want. then make a custom j3md for it. Use the post.vert shader in the engine (projects a quad to full screen). then just have frag shader that does a texture fetch.
You’ll have a fixed image background.

You have to love shaders :wink:

Plus, if you dont need transparency you can render thw background after the ship model and the magical depth buffer automatically saves you a few texture fetches

yep, the sky bucket is rendered after the opaque bucket

Disabling clearing the depth and stencil buffers didn’t change a thing, sadly. I’ll check if it works without having the color buffer clearing disabled.

EDIT: Even with all clear flags set to true, I still get the same problem.

I guess the chaining with the frame buffer is wonky… it’s an edge case for the FPP and i’m not surprised it fails…
Yet… you should consider the workaround, it will be both easier and… well it will work :stuck_out_tongue: