View Full Version : Texture mapping with alpha channel on
I'm writing my own C++ class to print text on the screen using texture mapped quads.
I'd like to get rid of the background color of the texture (black), so that I can draw text transparently. Then I need to turn on blending.
Now, how can I create a 32 bit depth texture ?
Can I do it with Photoshop ?
08-26-2003, 11:04 AM
Almost every image tool that supports masks can write them as an alphachannel to a fileformat that supports it (like TGA, PNG).
And yes, you can create masks in Photoshop too and it can also save them as the alphachannel into TGA or PNG (or other formats).
Another approach would be to blend your text with glBlendFunc (GL_ONE, GL_ONE) (i think).
This way you "add" your text to the scene. But since adding 0 to something doesnīt change anything, only your text (white, blue, green, whatever you want, except black) will show up. The black background of the text wonīt show up.
This is much easier than adding a 4th channel to your text-texture. And the edges of the text will be smoother.
BTW: On Neheīs page under "Downloads" you can get the "Bitmap Font Builder". Itīs a nice tool to create bitmap fonts:
That only works for white text, ot it will become a bit transparent. ( since pure blue + red will become magenta, if font = blue and background for that pixel is red)
If you want single colored characters you can minimize the memoryusage by using a pure alpha map, and then set the color of the char with glColor3f(), texenv to GL_REPLACE, and glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
or if you want multicolored chars you must use an RGBA map if you dont want the char transparent in any way.
And for a character builder that are a bit more flexible i suggest mine http://www.opengl.org/discussion_boards/ubb/smile.gif http://mazy.annat.nu/fonture
08-28-2003, 01:44 AM
I'd also prefer Alphamasking, even if the borders of the chars won't be as smooth as if you'd use bleding, but blending eats much more fillrate then alphamasking, so that it would be a lot slower to draw a bigger text with blending than with alphamasking.
Thanks you all.
Can you help me create a 32bit-depth alpha bitmap ?
I can't create it with Photoshop, please provide some web link where I can find any tips......
08-29-2003, 02:02 AM
Take a look at the helpfile that comes with photoshop.It tells you exactly how to create a mask, and then save it to TGA as a 32Bit image.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.