Hello,
How would I display black text with a transparent background? I don’t completly get the blending function settings.
I tried creating a new font bitmap with black characters and a white background but I still can’t get it to blend properly.
I wonder if a true 32 bit image with an alpha channel would do it?
Thanks,
Gregg
Blending will work regardless of the bit depth of the texture as long as the background is black and the settings are:
Alpha for the source, one for the destination.
Not sure which version of jME you are using, but if you are using the 0.2 version, you’d create a render state:
AlphaState as1 = display.getRenderer().getAlphaState();
as1.setBlendEnabled(true);
as1.setSrcFunction(AlphaState.SB_SRC_ALPHA);
as1.setDstFunction(AlphaState.DB_ONE);
as1.setTestEnabled(true);
as1.setTestFunction(AlphaState.TF_GREATER);
text.setRenderState(as1);
where text is a text node.
If you are using the old version, just enable blending with the blend func source to GL_SRC_ALPHA and the destination to GL_ONE.
[/code]
you use a png file!
png file contains an alpha channel. So create a new Text grid in which ever tool you use. Then in photoshop, select the black and hit delete. You should get a gray and white grid in the bg indicating that its transperant. Then colour in the font using the paint bucket.
Then using this alpha state to get the desired effect:
AlphaState as1 = display.getRenderer().getAlphaState();
as1.setBlendEnabled(true);
as1.setSrcFunction(AlphaState.SB_SRC_ALPHA);
as1.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA);
as1.setTestEnabled(true);
as1.setTestFunction(AlphaState.TF_GREATER);
text.setRenderState(as1);
Hope that helps, DP
The whole area is white? As in nice big white squares? Usually that is due to the image file not being found by jme… You might try taking out the alpha state just to ensure the words are there.
No problem, simple fixes to problems are always best!
good to hear that it worked. I am actually surprised it did, because im still not so sure about the alpha state and what the paramters mean
DP
Ditto