Blended Texture

I’m trying to put text in front of my hud and it’s blended.

On this image, down is the version with a black hud : the text is clear, and up is the version with a textured hud : the text is blended.

Any idea ?

Thank you.

you text is transparent all the time. the only difference is that on black background the contrast is higher, that's why it looks "right".

depending on how you generate the text, you'll have to make sure the letters aren't transparent (only the background of the text has to be transparent)

Here is the code where I create my Text :

Node hudNode = new Node("hudNode");
Texture hudTexture = TextureManager.loadTexture("media/display/hud.png", Texture.MM_LINEAR, Texture.FM_LINEAR, 1, true);

TextureState ts = display.getRenderer().createTextureState();
Quad hud = new Quad("hud", display.getWidth(), display.getHeight()/6);
hud.setLocalTranslation(new Vector3f(display.getWidth()/2,display.getHeight()/12,0));
Text2D textSelectedUnits = new Font2D().createText("textSelectedUnits", 10, 0);
textSelectedUnits.setLocalTranslation(new Vector3f(100, 40, -0.0001f));


I want to verify the transparency of my objects as you said but I can't find where is defined which kind of 3D object is a Text2D ...  :|

I don't know if you solved this problem, but I had it also.

Now I use this to create my Text:

   String DEFAULT_FONT = "catan/data/images/defaultfont.tga";
   TextureState defaultFontTextureState;

   Text text = new Text( name, textInicial );
   defaultFontTextureState = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
   defaultFontTextureState.setTexture( TextureManager.loadTexture( SimpleGame.class
               .getClassLoader().getResource( DEFAULT_FONT ), Texture.MM_LINEAR_LINEAR,
                   Texture.FM_LINEAR, Image.GUESS_FORMAT_NO_S3TC, 1.0f, true ) );
   defaultFontTextureState.setEnabled( true );
   AlphaState as1 = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
   as1.setBlendEnabled( true );
   text.setRenderState( defaultFontTextureState );
   text.setRenderState( as1);

And change your DEFAULT_FONT source.

Yeah I think the alpha blending mode set up for fonts is incorrect. It should be src_alpha, one_minus_src_alpha for correct alpha blending.

If you use Text.createDefaultTextLabel(String, String) you'll get a Text object with a correctly set alphastate and texturestate.