Jump to content
  • Advertisement
Sign in to follow this  
DarkCybo1

Alpha transparency??

This topic is 4820 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
Are you filling your alpha channel? USe photoshop to do that. Also, set AlphaBlendEnable=TRUE

Luck!
Guimo

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites

glAlphaFunc(GL_GREATER,0.0f); //<--- Any value above 0 passes the alpha test
glEnable(GL_ALPHA_TEST);

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Wow, having to add the alpha mask for every image is annoying. Oh well...

Thanks for the help though, I got it to work!

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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. ;)

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!