Hello everyone,
I’ve been struggling with a problem recently. I found some discussions in the hub but I couldn’t come to a conclusion on my own.
I wanted to ask before I possibly waste a lot of time in an bad solution, perhaps someone can guide me in the right direction.
My scene is divided in multiple view ports (far away, close and very close) with the last two view ports having the “clear color” flag disabled. Everything is good until I try to apply post processing filters.
Looking into the FilterPostProcessor
class, without a deep understanding on how all this works, I can see that the it uses its own FrameBuffer
which replaces the one in the ViewPort
:
private void setupViewPortFrameBuffer() {
if (renderFrameBufferMS != null) {
viewPort.setOutputFrameBuffer(renderFrameBufferMS);
} else {
viewPort.setOutputFrameBuffer(renderFrameBuffer);
}
}
I don’t know why this is necessary but I believe this breaks the filters when there are multiple overlapping view ports, because the “background” is thrown away and replaced.
I want to have filters in my scene, some filters could only be applied to the middle view port (e.g. simple drop shadows) and others to the latest (e.g. color overlay).
I wanted to try copying the FilterPostProcessor
’s code and modify it to hopefully solve my case, but many of the Filter
methods are protected
so I’d have to copy that as well and then I’d have to also rewrite any existing filter implementation.
It seems a lot of work and it makes me think I’m missing something, there should be a better way.
Here I made a simple example reproducing what I want to do:
This is the result without the FilterPostProcessor
:
This is when I enable it. Notice the first view port (purple background with a cube) is hidden and the front view port doesn’t clear the buffer (I moved the camera to show it) and gets the filter applied.
tl;dr. add filters to multiple view port setup, how can I do it?