Skip to main content
gamedev.net
🔒 Locked

transparentcy

Started by Kackurot 6 replies 500+ views
Original Post
Kackurot
Kackurot
Does anyone here know how to use transparentcy for 2d sprites. Im trying to block out the transparent color for the sprite. I am making an 2d rpg using gl instead of dx7. Can someone pls help. [file:///C:/My%20Documents/kack.gif]
[file:///C:/My%20Documents/kack.gif]
krez
krez
create your sprites with an alpha channel, and use alpha blending.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
Kackurot
Kackurot
Can I get some example code and how to use alpha in a paint program?
[file:///C:/My%20Documents/kack.gif]
krez
krez
if you mean the paint program that comes with windows, it can''t do that. in fact, bitmaps can''t, so you''ll have to use PNG or GIF or TGA or your own custom format or something.

you can use Gimp or Paint Shop Pro to create these.

i just use my own custom format, so i''m sorry i don''t have a lot of information on these other programs.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
Myopic Rhino
Myopic Rhino
You can avoid having to create the alpha channel in an image program by simply iterating through your image as you load it, adding an alpha value, and setting alpha to zero for the transparent color and 255 everywhere else.
Ilici
Ilici
quote:
Original post by Myopic Rhino
You can avoid having to create the alpha channel in an image program by simply iterating through your image as you load it, adding an alpha value, and setting alpha to zero for the transparent color and 255 everywhere else.


Well if you do that in your texture manager you''ll get into trouble when you want textures for which you calculate the alpha in some other way (average, etc).

The best way is to use a 32 bit image format like TGA (or make your own as i did) and calculate the alpha plane in some editor (Photoshop) or write an utility for generating alpha channels (make this utility to be able to create color-keyd sprites, alpha = (R + G + B) / 3, or to load a greyscale alpha plane from another file).

[ My Site ]
All your source are belong to us
/*ilici*/
Myopic Rhino
Myopic Rhino
quote:
Original post by Ilici
Well if you do that in your texture manager you'll get into trouble when you want textures for which you calculate the alpha in some other way (average, etc).

Why would you get into trouble? You could easily parameterize it, make different functions, etc., to do the right thing all the time. My own image management code does this; it's extremely flexible and powerful, and I've never had a problem with it. When you've got sprite art which is already color keyed (which is what the OP is asking about), my approach seems more straightforward.

Ilici
Ilici
Yep, just for color-keying it''s no use to store the Alpha component, but I had many textures which i didn''t know anything about and had to load them for the world. i did not know how to generate the alpha for each one so i created my own format and the converter calculated alpha by some algo of choice. check out my basecode for the format and converter + loads of other goodies.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.