Alpha transparency??

Started by
11 comments, last by RuneLancer 18 years, 9 months ago
How can I draw textures where parts of the texture is transparent, and other parts are opaque? When I draw a texture like this in my program, the parts that are supposed to be transparent appear as white. Included code would also be a great help.
Hey babe.
Advertisement
Are you filling your alpha channel? USe photoshop to do that. Also, set AlphaBlendEnable=TRUE

Luck!
Guimo
Photoshop? :(
I have Paint Shop Pro, can I still do it?

And what do you mean AlphaBlendEnable = TRUE? I already have Blending enabled if that's what you mean..
Hey babe.

glAlphaFunc(GL_GREATER,0.0f); //<--- Any value above 0 passes the alpha test
glEnable(GL_ALPHA_TEST);
In PSP 7.x, you use a mask. There are different ways to do it.

You can add a new mask from different images, or using different methods to generate them based off the image you already have. (Or you can paint by hand), then when you are done, save your mask to the alpha channel (Only 1).

Then you can delete your mask, because it's been exported to the alpha channel, and it's no longer needed, and tell the program NOT to merge the mask with the image layer. Then save as .tga. (if you leave the mask it will turn all masked pixels white)
Quote:Original post by Vampyre_Dark
In PSP 7.x, you use a mask. There are different ways to do it.

You can add a new mask from different images, or using different methods to generate them based off the image you already have. (Or you can paint by hand), then when you are done, save your mask to the alpha channel (Only 1).

Then you can delete your mask, because it's been exported to the alpha channel, and it's no longer needed, and tell the program NOT to merge the mask with the image layer. Then save as .tga. (if you leave the mask it will turn all masked pixels white)


Are you saying do this in OpenGl or in a paint program, because I am sick of loading a image and a mask all the time and I dont have Photoshop to put in the transparency layer.

My Current Project Angels 22 (4E5)
Wow, having to add the alpha mask for every image is annoying. Oh well...

Thanks for the help though, I got it to work!
Hey babe.
Quote:Original post by DarkCybo1
Wow, having to add the alpha mask for every image is annoying. Oh well...
Thanks for the help though, I got it to work!
It takes less then 2 seconds, auto generate a mask from the image data, and save it out to the file's alpha channel. Note that the mask is not the alpha channel, it's a mask within the program only. You have to manually export the alpha channel and then delete the mask. If you don't delete the mask, it will get merged with the image layer when you save, causing all those pixels to go white (which you may not want).
Quote:Original post by SirSapo
Are you saying do this in OpenGl or in a paint program, because I am sick of loading a image and a mask all the time and I dont have Photoshop to put in the transparency layer.
Quote:Original post by Vampyre_Dark
In PSP 7.x
Use GIMP?
It's pretty simple.



Notice the outside of each sprite: it's all pinkish-purple (0xFF00FF). You can pick any color you want, but make sure it's something that isn't used and won't be used elsewhere in your sprites. 0xFF00FF is a good one, so is lime green (0x00FF00). You can use white or black, just make sure you keep in mind not to use those while drawing (ie, if you have to use black in your sprite, use 0x080808 instead of 0x0000000.)

When loading, make the texture color format GL_RGBA. If you encounter a pixel set to your mask color (say, 0xFF00FF) write 0x00 to the alpha channel (AARRGGBB), otherwise write 0xFF.

When drawing, make sure alpha testing is enabled and that you've set an alpha function (glAlphaFunc(GL_LESS, 0.05f); is what I use.) Your sprite will automatically be masked. ;)
Quote:Original post by RuneLancer

If you encounter a pixel set to your mask color (say, 0xFF00FF) write 0x00 to the alpha channel (AARRGGBB), otherwise write 0xFF.


I'm a beginner at this..how would I do this part?
Hey babe.

This topic is closed to new replies.

Advertisement