I need that to opengl transparency things. Is there any program which saves image, for example, to png and creates and saves a mask for it too?
The png file format has full support for an alpha channel, from anywhere between a 1bpp bitmask, to an 8bpp full alpha channel.
Any paint program that supports manipulation of the alpha channel & correctly maps it onto the features of the png format should be fine.
Gimp is free, PSP has a 30 day shareware, Photoshop is expensive.
you choose your poison.
I looked at java port of nehe tutorial 20 (masking) and it used masking with png:s so why did it if png supports alpha channel? I have used pngs in java2d programs with that alpha thing and it works there but not with jogl I think. Maybe it works with better Image loader?
make sure to include the gl functions in your intialization code:
glAlphaFunc(GL_GREATER, 0.01f); // sets aplha function
glEnable(GL_ALPHA_TEST); // allows alpha channels or transperancy
as well as loading the texture make sure the format is GL_RGBA not GL_RGB
That’s cool. Doing masks for all images would be annoying.
Thanks to both for your answers.
Keep in mind GL_ALPHA_TEST is really slow.
Ok, thanks for the tip. I guess I will do some tests and look how much it slows down in my case.
Yes there is a performance hit, due to the extra check (that should go without saying), but it really is trivial.
I actually found masks to be slower.
In other words, if you want transperancy there is always going to be a performance hit.
It is really not a trivial performance hit.
It is a really heavy operation. I have no explaination, but the framerate suffers a lot.
It also depends on the values passed into glAlphaFunc. With a textures with quite sharp edges, a value of 0.9 will have a totally different impact than say 0.5, even if there is a marginally difference in actually rendered pixels.
In the cases I tried, manually sorting items, and using normal blending, is faster than using GL_ALPHA_TEST.