Hi, It looks like there is a potential bug between 3.0 and 3.1.0-beta1.
I was testing my new multiple viewport code, and I was getting quite mad that I am unable to figure out what’s the issue between my test project and the main program, till I realized, it must be the jmonkey version.
So on 3.0.+:
I create a preview, render the texture, apply ComposeFilter on main viewport: preview appears in main viewport
In 3.1.0-beta1:
Same steps, but main viewport remains black.
Do you by any chance add multiple fpps to the same viewport?
That’s what i had. In 3.0 it worked but broke with 3.1 (it’s Bad behavior anyway)
No, I tried to check everything, and finally I came to the conclusion that it is the engine that does this.
I tested with an app containing nothing but a preview with red background rendered into texture, 1 compose filter on an empty mainview with blacknoalpha background. I changed the engine version between 3.0.10 and 3.1.0-beta1 and this works only in 3.0.10.
Yesterday I had the energy to reapply my stashed changes and revert the engine version and it works now with the more complex functionality.
I created an issue for this:
opened 09:48AM - 08 May 16 UTC
Hi,
I tried using ComposeFilter to combine several previews into one mainviewport via ComposeFilter, but this seems to be breaking in 3.1.0-beta.
My...
To be investigated
bug
nehon
May 8, 2016, 2:08pm
4
If you created a test case it could be nice to include it.
Good point. I think I will include it in two pieces.
First, the combined viewport:
/*
Copyright © 2016, ZoltanTheHun
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package com.codebetyars.skyhussars.engine;
import com.jme3.math.ColorRGBA;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Node;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture2D;
public class CombinedViewport {
private final Camera cam;
private final ViewPort viewPort;
private Texture2D colorBuffer;
private final float fov;
private final float near;
private final float far;
private final float aspect;
private final String name;
private final Node node;
public CombinedViewport(String name,
RenderManager renderManager,
Camera mainCam,
float fov,
float near,
float far,
Node node
) {
this.name = name;
this.cam = mainCam.clone();
this.viewPort = renderManager.createPreView(name, cam);
this.fov = fov;
this.near = near;
this.far = far;
this.aspect = (float) mainCam.getWidth() / (float) mainCam.getHeight();
this.node = node;
setupView();
}
private void setupView() {
cam.setFrustumPerspective(fov, aspect, near, far);
FrameBuffer offBuffer = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1);
colorBuffer = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8);
colorBuffer.setMinFilter(Texture.MinFilter.Trilinear);
colorBuffer.setMagFilter(Texture.MagFilter.Bilinear);
offBuffer.setDepthBuffer(Image.Format.Depth);
offBuffer.setColorTexture(colorBuffer);
viewPort.setBackgroundColor(ColorRGBA.BlackNoAlpha);
viewPort.setOutputFrameBuffer(offBuffer);
viewPort.setClearFlags(true, true, true);
viewPort.attachScene(node);
}
public Texture2D colorBuffer() {
return colorBuffer;
}
public Camera cam() {
return cam;
}
public ViewPort viewPort() {
return viewPort;
}
public String name() {
return name;
}
public void fov(float f) {
cam.setFrustumPerspective(fov, aspect, near, far);
}
}
And the main code mostly:
mainViewPort = renderManager.getMainViews().get(0);
viewPorts.add(new CombinedViewport("nearView", renderManager, mainCam, fov, 0.5f, 310f, rootNode));
viewPorts.add(new CombinedViewport("farView", renderManager, mainCam, fov, 300f, 200000f, rootNode));
mainViewPort.setBackgroundColor(ColorRGBA.BlackNoAlpha);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
viewPorts.forEach(viewPort -> {
fpp.addFilter(new ComposeFilter(viewPort.colorBuffer()));
});
mainViewPort.addProcessor(fpp);
The test code was even simpler, but I reverted that when I restored the stash, maybe I can post it the next time I can get some time on coding.
Hi, another thing which I noticed, that 3.1.0-beta1 had some strange shadow artifacts. I don’t have the energy to reproduce them now, but I thought it is good to mention.
nehon
May 10, 2016, 5:55am
9
Well, to be honest it doesn’t help much no. “Strange shadow artifacts” is kind of vague.
At least you could post a screen shot
Sorry for not being useful. It was another late night coding session and I was unable to go on. Tonight i will go back to a version where I used 3.1 and take some screenshots.