- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.2k
Closed
Labels
defectSomething that is supposed to work, but doesn't. Less severe than a "bug"Something that is supposed to work, but doesn't. Less severe than a "bug"
Milestone
Description
I've been converting apps to use resizable windows. Mostly this just involves invoking AppSettings.setResizable() and adjusting the GUI layout each time the window gets resized.
I've encountered an issue involving filters in resizable windows, and I believe it's a bug in the Engine. When I resize a window to a new aspect ratio, the rendered scene gets squashed to "fit" the new aspect ratio. This only happens when there are filters. In an unfiltered scene, no squashing occurs.
Here's a simple testcase based on TestCartoonEdge:
package jme3test.post;
import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.CartoonEdgeFilter;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.Spatial.CullHint;
import com.jme3.system.AppSettings;
import com.jme3.texture.Texture;
public class TestIssueXXXX extends SimpleApplication {
    private FilterPostProcessor fpp;
    public static void main(String[] args) {
        AppSettings s = new AppSettings(true);
        s.setResizable(true);
        TestIssueXXXX app = new TestIssueXXXX();
        app.setSettings(s);
        app.start();
    }
    private void setupFilters() {
        fpp = new FilterPostProcessor(assetManager);
        int numSamples = getContext().getSettings().getSamples();
        if (numSamples > 0) {
            fpp.setNumSamples(numSamples);
        }
        CartoonEdgeFilter toon = new CartoonEdgeFilter();
        toon.setEdgeColor(ColorRGBA.Yellow);
        fpp.addFilter(toon);
        viewPort.addProcessor(fpp);
    }
    private void makeToonish(Spatial spatial) {
        if (spatial instanceof Node) {
            Node n = (Node) spatial;
            for (Spatial child : n.getChildren()) {
                makeToonish(child);
            }
        } else if (spatial instanceof Geometry) {
            Geometry g = (Geometry) spatial;
            Material m = g.getMaterial();
            if (m.getMaterialDef().getMaterialParam("UseMaterialColors") != null) {
                Texture t = assetManager.loadTexture("Textures/ColorRamp/toon.png");
                m.setTexture("ColorRamp", t);
                m.setBoolean("UseMaterialColors", true);
                m.setColor("Specular", ColorRGBA.Black);
                m.setColor("Diffuse", ColorRGBA.White);
                m.setBoolean("VertexLighting", true);
            }
        }
    }
    private void setupLighting() {
        DirectionalLight dl = new DirectionalLight();
        dl.setDirection(new Vector3f(-1, -1, 1).normalizeLocal());
        dl.setColor(new ColorRGBA(2, 2, 2, 1));
        rootNode.addLight(dl);
    }
    private void setupModel() {
        Spatial model = assetManager.loadModel("Models/MonkeyHead/MonkeyHead.mesh.xml");
        makeToonish(model);
        rootNode.attachChild(model);
    }
    @Override
    public void simpleInitApp() {
        viewPort.setBackgroundColor(ColorRGBA.Gray);
        flyCam.setDragToRotate(true);
        setupLighting();
        setupModel();
        setupFilters();
    }
}Ali-RS
Metadata
Metadata
Assignees
Labels
defectSomething that is supposed to work, but doesn't. Less severe than a "bug"Something that is supposed to work, but doesn't. Less severe than a "bug"