{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreihnseit6dgcir5ofdnjc7nbysgqtre65beq4sgxq6frk7ry7zuamq",
    "uri": "at://did:plc:dxjzgxe7cvirxkwfjr2tjspt/app.bsky.feed.post/3mfd4ccxajbk2"
  },
  "path": "/t/cartoonedgefilter-makes-the-entire-background-black/49419#post_1",
  "publishedAt": "2026-02-20T04:02:30.000Z",
  "site": "https://hub.jmonkeyengine.org",
  "tags": [
    "@author",
    "@Override"
  ],
  "textContent": "I am using an offscreen viewport to render an object to a texture. I need the texture to be transparent, but as soon as I apply the CartoonEdgeFilter, it makes the background of the texture black:\n\n\n\nThis is an example where I reproduced this issue:\n\n\n    package com.mygame;\n\n    import com.jme3.app.SimpleApplication;\n    import com.jme3.material.Material;\n    import com.jme3.material.RenderState;\n    import com.jme3.math.ColorRGBA;\n    import com.jme3.math.FastMath;\n    import com.jme3.math.Quaternion;\n    import com.jme3.post.FilterPostProcessor;\n    import com.jme3.post.filters.CartoonEdgeFilter;\n    import com.jme3.renderer.RenderManager;\n    import com.jme3.renderer.ViewPort;\n    import com.jme3.scene.Geometry;\n    import com.jme3.scene.Node;\n    import com.jme3.scene.shape.Box;\n    import com.jme3.texture.FrameBuffer;\n    import com.jme3.texture.FrameBuffer.FrameBufferTarget;\n    import com.jme3.texture.Image.Format;\n    import com.jme3.texture.Texture2D;\n    import com.jme3.ui.Picture;\n\n    /**\n     * This is the Main Class of your Game. You should only do initialization here.\n     * Move your Logic into AppStates or Controls\n     *\n     * @author normenhansen\n     */\n    public class Main extends SimpleApplication {\n\n        public static void main(String[] args) {\n            Main app = new Main();\n            app.start();\n        }\n\n        @Override\n        public void simpleInitApp() {\n\n            // The object we want to have an edge\n            Box b = new Box(1, 1, 1);\n            Geometry geom = new Geometry(\"Box\", b);\n            Material mat = new Material(assetManager, \"Common/MatDefs/Misc/Unshaded.j3md\");\n            mat.setColor(\"Color\", ColorRGBA.Blue);\n            geom.setMaterial(mat);\n\n\n            Node offscreenNode = new Node(\"OffscreenNode\");\n            offscreenNode.attachChild(geom);\n            offscreenNode.updateGeometricState();\n\n\n            int w = 512;\n            int h = 512;\n\n            ViewPort offView = renderManager.createPreView(\"OffscreenView\", cam.clone());\n            offView.setClearFlags(false, true, true);\n            offView.setBackgroundColor(new ColorRGBA(0, 0, 0, 0)); // Transparant!\n            offView.attachScene(offscreenNode);\n\n            //Offscreen framebuffer\n            FrameBuffer offBuffer = new FrameBuffer(w, h, 1);\n            Texture2D offTex = new Texture2D(w, h, Format.RGBA8);\n            offBuffer.setDepthTarget(FrameBufferTarget.newTarget(Format.Depth));\n            offBuffer.addColorTarget(FrameBufferTarget.newTarget(offTex));\n            offView.setOutputFrameBuffer(offBuffer);\n\n            // Create the Toon-filter\n            FilterPostProcessor fpp = new FilterPostProcessor(assetManager);\n            fpp.setNumSamples(1);\n            CartoonEdgeFilter toon = new CartoonEdgeFilter();\n            toon.setEdgeIntensity(1.0f);\n            toon.setEdgeWidth(4.0f);\n            toon.setNormalThreshold(0.5f);\n            toon.setDepthThreshold(0.8f);\n\n            fpp.addFilter(toon);\n            offView.addProcessor(fpp);\n\n            Picture pic = new Picture(\"Resultaat\");\n            pic.setTexture(assetManager, offTex, true);\n            pic.setWidth(w);\n            pic.setHeight(h);\n            pic.setPosition(settings.getWidth() / 2f - w / 2f, settings.getHeight() / 2f - h / 2f);\n\n            pic.getMaterial().getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);\n\n            guiNode.attachChild(pic);\n\n\n            geom.setLocalRotation(new Quaternion().fromAngles(FastMath.QUARTER_PI, FastMath.QUARTER_PI, 0));\n\n\n            viewPort.setBackgroundColor(ColorRGBA.DarkGray);\n\n\n            offscreenNode.updateLogicalState(0f);\n            offscreenNode.updateGeometricState();\n        }\n\n        @Override\n        public void simpleUpdate(float tpf) {\n            //TODO: add update code\n        }\n\n        @Override\n        public void simpleRender(RenderManager rm) {\n            //TODO: add render code\n        }\n    }\n\n\nHow do I get the background to be transparent?",
  "title": "CartoonEdgeFilter makes the entire background black"
}