Alpha Blending Idea
Alright, I have an idea of how to filter out a specific color, but it only works for exactly red, green,or blue colors. Say you''re blending out (0,0,255). You would make an alpha channel out of the blue channel, and then use glAlphaFunc(GL_LESSTHAN(or whatever),1.0f). That way, it will mask out only exact blue, which would be 1.0 on the alpha channel. would that work?
Marathon Redux: MY mega project.http://marathonredux.forerunners.org
Sure, it would work. But if you have to copy the red/green/blue channel into the alpha channel, why not just add an if-statement and fill the alpha channel based on the color? Then you can set the alpha channel based on any color, not just the three primary colors.
Probably the safest (not to mention the most rational) way is to fill the alpha channel so that it either equals (R+G+B)/3 or 1 if R > 0 || G > 0 || B > 0, 0 otherwise. There might be applications for different kind of alpha channels, but there''s none that I can think of.
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Is there a function for creating an alpha channel dynamically? Because then you could do all kinds of crazy stuff, like, "Filter out red and yellow and beige".....or, maybe it''s not so crazy.
Marathon Redux: MY mega project.http://marathonredux.forerunners.org
quote:
Original post by dogan
Is there a function for creating an alpha channel dynamically? Because then you could do all kinds of crazy stuff, like, "Filter out red and yellow and beige".....or, maybe it''s not so crazy.
No, there isn''t (if glAux or SDL don''t do that for you which I don''t know). I personally load the image, make it 4/3 its size and set every fourth byte to the alpha value.
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
And how can you do that?
(Sorry, I''m not very good at working with binary data objects)
(Sorry, I''m not very good at working with binary data objects)
Marathon Redux: MY mega project.http://marathonredux.forerunners.org
Do you know how to load an image?
Once you have the data loaded into a buffer and you know the size of the buffer, you create a new buffer that also accommodates the alpha channel (for a 24 bit bitmap that''ll be 4/3 the original size), copy 3 byte blocks from the original buffer and add a new byte as the alpha channel in the place of the fourth byte. Once you''re done, just delete the original buffer. Then, of course, you''ll have to create the texture with GL_RGBA or GL_BGRA, not GL_RGB or GL_BRG.
If this doesn''t make sense to you, try to learn how to load a bitmap yourself - that''ll give you the understanding you need to work with both images as well as binary data (googling or running a search in this forum is a place to start if you''re reluctant to try it out yourself - this isn''t something you should particularly need a tutorial for, btw).
Otherwise I already answered your question in my previous post (but you just didn''t know how to interpret it). If you have any (more specific) questions, just ask.
Cheers
Once you have the data loaded into a buffer and you know the size of the buffer, you create a new buffer that also accommodates the alpha channel (for a 24 bit bitmap that''ll be 4/3 the original size), copy 3 byte blocks from the original buffer and add a new byte as the alpha channel in the place of the fourth byte. Once you''re done, just delete the original buffer. Then, of course, you''ll have to create the texture with GL_RGBA or GL_BGRA, not GL_RGB or GL_BRG.
If this doesn''t make sense to you, try to learn how to load a bitmap yourself - that''ll give you the understanding you need to work with both images as well as binary data (googling or running a search in this forum is a place to start if you''re reluctant to try it out yourself - this isn''t something you should particularly need a tutorial for, btw).
Otherwise I already answered your question in my previous post (but you just didn''t know how to interpret it). If you have any (more specific) questions, just ask.
Cheers
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement