Viewport sizing and the FIlterPostProcessor

this is kind of related to the other post i just made about trying to make PIP viewport, but this is a different issue. Im trying to add the same scene processors to my “main” and my “pip” viewport so they look the same. this is the code i have right now:

// creates a viewport along the right side of the screen taking up percentage of the screen
private void createPipVerticalRight(float percentage) {
Camera cam2 = cam.clone();
cam2.resize(Math.round(cam.getWidth() * percentage), cam.getHeight(), true);
cam2.setViewPort((1 - percentage) / percentage, 1 / percentage, 0, 1);

            ViewPort view2 = renderManager.createMainView("Right PIP", cam2);
            view2.setClearFlags(true, true, true);

            PssmShadowRenderer shadow = new PssmShadowRenderer(assetManager, 1024, 3);
            shadow.setDirection(new Vector3f(0, -1, -2));



however my test scene also uses the filter post processor with an ssao filter

FilterPostProcessor fpp2 = new FilterPostProcessor(assetManager);
SSAOFilter ssaoFilter2 = new SSAOFilter(12.940201f, 43.928635f, 0.32999992f, 0.6059958f);

this causes my pip viewport to get moved from the right side of the screen, and i think its being stretched or something, because i only see the sky in my scene rather than the cube thats in it.

I tried this with a few other filters (toon, gray scale…) and they all caused the same problem, the only way the problem doesnt occur is if i add a FPP to the viewport with no filters added to it. (the shadow renderer does not cause this issue, just the fpp when filters are added to it)

ive tried resetting the camera settings after adding the fpp, but it didnt seem to have an effect.


to better clarify

i can do

cam2.setViewPort(0, 1, 0, 1);

and put it along the left side of the screen. but when i try to do

cam2.setViewPort((1 - percentage) / percentage, 1 / percentage, 0, 1);

it goes haywire. it seems to lose understanding of its dimensions with the filters added somehow…

if you do

cam2.setViewPort(0.5f, 1.5f, 0, 1);

it seems to be moved by the correct amount but looks to be somehow getting clipped off. it doesnt want to draw anything outside of the 0,1,0,1 portion of the screen.

What version of JME do you use? (don’t tell me nightly please)
I spent a lot of time making multi viewports work with filters and each time there is a change to it it’s kind of a nightmare to keep this feature to work…
However, the TestMultiViewsFilter test case is working for me, and it has a similar use case as yours, could you try it? If it works could you produce a test case of your own?

I’m using the stable release (i think its 3.0.5 now).

ive seen the test multi file. if you just add a fpp to a view it doesnt cause the bug, its when you resize the view AND add the fpp.

ive added my code into the test multi file here:

im expecting the view4 to span 100% of the width and 40% of the height across the top of the screen. If you comment out the line where I add the bloom filter to the viewport it behaves as it should.

i tried to figure out what was causing this issue today… i think the problem is with fpp.preframe(float) particularly line 320

if (!cameraInit) {
viewPort.getCamera().resize(width, height, true);
viewPort.getCamera().setViewPort(0, 1, 0, 1);

i wanted to test toying around with preframe but all of the private and protected stuff in the package makes it difficult to just extend and modify. i think id have to download the source and modify it directly.

but until i try that, is there a reason for the camera viewport stuff in FPP? I guess this might be a little more directed to you @nehon . im guessing its a workaround/fix for another issue but what is the other issue? if im able to fix this id rather not break something else.

Sorry i missed your previous post. Stable doesn’t have the changes of fpp,could you test with nightly?

i just tested on nightly, its closer to being “correct”. the viewport is atleast in the correct spot on the screen in nightly, but its always black (despite even that its background color is yellow)