BitmapText transparency?

For some reason I cannot seem to get those black corners removed from my bitmaptext.

The best result i've gotten doesn't have any black corners except the text becomes transparent in the brighter parts of my scene (see image).

Here is my current code:

BlendState as1 = DisplaySystem.getDisplaySystem().getRenderer().createBlendState();
   as1.setBlendEnabled(true);
   as1.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
   as1.setDestinationFunction(BlendState.DestinationFunction.One);
   as1.setTestEnabled(true);
   as1.setTestFunction(BlendState.TestFunction.GreaterThan);
   as1.setEnabled(true);

        BitmapFont fnt = BitmapFontLoader.loadDefaultFont();

        BitmapText txt = new BitmapText(fnt, false);
        txt.setSize(32);
        txt.setAlignment(Align.Left);
        txt.setDefaultColor(ColorRGBA.orange.clone());
        txt.setText("TEST_TEST_TEST_TEST_TEST");
        txt.setRenderState(as1);
        txt.updateRenderState();
        txt.update();
        txt.setLocalTranslation(25, 300, 0);
        attachChild(txt);



thanks

hi, first I think you don't need to set a BlendState, the text has one. Second, you have the wrong DestinationFunction, it should be:


as1.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);



dhdd

when i set that destination function i get this. I also get the same result if i remove the blend state.

any other suggestions on what to do to get rid of the black ?  :?

hi, yes, that is the correct blendstate function.



Call txt.update(); before txt.updateRenderState();

that made no difference…  :expressionless:

damn, then it must be something on the higher-up nodes which you attach the text so. Otherwise the code above but without the BlendState should work. Which RenderStates do you have attached to any parent Nodes?

Maybe the font doesn't have an alpha channel?

maybe that is the problem, but im stuck on one thing while loading my own font:

URL fontFile =
                 getClass().getClassLoader().getResource("jmetest/data/texture/angelFont.fnt");
                 URL textureFile =
                 getClass().getClassLoader().getResource("jmetest/data/texture/angelFont.png");
BitmapFont fnt = BitmapFontLoader.load(textureFile,
                    fontFile);


This is in the testBitmapFont. I'm wondering what is the difference between textureFile and fontFile.
I have a single png file for the font. How can i load it? Also, what formats does it support?
Momoko_Fan said:

Maybe the font doesn't have an alpha channel?


Nope, he uses the default font from the test package, which works fine.

@satrix: for each BitmapFont you need 2 files:
- a .fnt file that describes the font (texture space per character, kerning, etc.). This is a normal text file
- a texture file that has all the characters on it and it must match the .fnt files description. This image can have any format jme supports for textures.

EDIT: take a look at this tool: http://www.angelcode.com/products/bmfont/

thanks for your help and suggestions guys, I created my own font with the font editor and the blending worked!  :smiley:

not sure why the default font doesn't work though.