[SOLVED] Transparency for my tree!

Hey guys,



Oooh, I am pulling my ruddy hair out again! I followed the wiki on adding transparency to my textures. But still the leaves come out with a white frame. I'm sure the background is transparent, so now I don't know what to do!



Here's the code snippet:


    private void addTrees() {
        Node rootNodeTransparent = new Node("Transparent");
        rootNode.attachChild(rootNodeTransparent);

        BlendState tpState = DisplaySystem.getDisplaySystem().getRenderer().createBlendState();
        tpState.setEnabled(true);
        tpState.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
        tpState.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
        tpState.setBlendEnabled(true);
        tpState.setTestEnabled(true);
        tpState.setTestFunction(BlendState.TestFunction.GreaterThan);
        tpState.setReference(0.1f);
        rootNodeTransparent.setRenderState(tpState);
        rootNodeTransparent.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
        rootNodeTransparent.setLightCombineMode(Spatial.LightCombineMode.Replace);

        // convenience method that loads a JME tree 0,10,0 with scale x5. Adds it to the rootNodeTransparent Node
        loadSceneObject(rootNodeTransparent, new File("/Blender Work/trees/tree2/tree2-jme.xml"), new Vector3f(0f, 10f, 0f), 5f);

        /* We activate two-sided transparency (?) */
        DisplaySystem.getDisplaySystem().getRenderer().getQueue().setTwoPassTransparency(true);
        ZBufferState zstate = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();
        zstate.setWritable(false);
        zstate.setEnabled(false);

        rootNodeTransparent.updateRenderState();
    }



But it's still no good  :? Images below... Please can somebody put me out of my misery!? Do I have something switched on that maybe I shouldn't I've been tinkering for hours now, and still can't spot it!

This post is rather recent take a look:

http://www.jmonkeyengine.com/forum/index.php?topic=11905.0

Erm… Thanks SomethingNew.



I did look at this thread (I always search beforehand). My code is near-on identical to it, which frustrates me somewhat. I changed the TestFunction to GreaterThanOrEqualTo, but that doesn't make any difference either.



I'm using GIMP's alpha background. I wonder if I need to look to see what that is?



Ho hum!



Richard

SOLVED!



Thank goodness for SceneMonitor is all I can say. I must have tried every ruddy setting under the sun. It turns out that the “applyMode” specified on the texture itself was “Decal”, whereas it should be “Replace”. I exported using hottbj exporter, and I can’t (yet) find the setting in Blender that makes this adjustment. So I make the adjustment to the XML myself and it’s all good:



             <texture>

               <com.jme.image.Texture2D apply=“Replace” wrapS=“Repeat” wrapT=“Repeat”>

                 <textureKey class=“com.jme.util.TextureKey” file=“t1_c.png” protocol=“file”/>

               </com.jme.image.Texture2D>

             </texture>



I guess “Replace” is the default property for textures which is why others aren’t experiencing my woes.



I just wish I understood half of what these settings actually mean!  :roll:



[EDIT] In Blender, it’s the “Map To” pull-down list that maps to the “applyMode” setting in JME. Blaine did mention that this should be “Multiply”, which maps to “Combine” in JME (the default Blender “Mix” setting is the one that maps to “Decal”). Combine is a little dark for my tastes, so it looks like it’s a manual fix right now.