Archived

This topic is now archived and is closed to further replies.

marauder

What's faster? Masking or Alpha Channel

Recommended Posts

marauder    122
Hi, i''m working on a 2D RPG engine. The player is a round object, so I want the black border to disappear. Since i do not know how to make only ONE color in a bitmap transparent with the alpha channel method, i used the masking trick to do it. NeHe''s Tutorial''s which I read til chapter 7 or so, aren''t using the alpha channel of bitmaps, so i took the easier method by doing the mask method. I guess that''s a bit slower than the alpha channel method, right? And does someone know where to find infos on using the alpha channel method? Thanks german hardware board www.hardwareboard.com

Share this post


Link to post
Share on other sites
duckbob    122
masking should be faster then alpha blending, nor would you want to use alpha for what your doing...just as a note, you don''t normaly want to use black as a mask color, use hot pink or some color you wouldn''t be using in your sprites

Share this post


Link to post
Share on other sites
Null and Void    1088
quote:
Original post by duckbob
masking should be faster then alpha blending, nor would you want to use alpha for what your doing...

Not nescessarily. The draw back caused by the alpha blending could be offset by the lack of binding a new texture and only being single pass. Personally I''d use alpha testing in this situation, it still requires an alpha channel (not so bad) but it''s single pass and has less overhead than full alpha blending.

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
Dredge-Master    175
depends on how you load it.

if you are using the AUX_RGBImageLoad or a similar function, just reallocate the memory of data to 4*sizeX*sizeY, then shift each 3byte block across and add in an alpha channel. This alpha byte could be 255 by default, but if lets say the values of r, g and b are 0,0,0 (black) it will make it 0 instead.

This is a simple way to convert it at load time. You could try other formats which support alpha channels, but the above is simple to implement and you can just use ms-paint to make your images.



Beer - the love catalyst
good ol'' homepage

Share this post


Link to post
Share on other sites
dfawcett    122
blah blah blah.. stick with masking.. every time i see a question about transparent color every jumps on the damn alpha channel band wagon. masking is easy and you dont need to shift that and the other.. black is fine, and if you need to, use 1,1,1 as the black you can see.

you dont even need to have a separate bitmap for the mask(in file form that is) once you get the hang of masking you can come up with a routine that picks any number that have 0,0,0 and set the to 255,255,255 any thing else will then be 0,0,0. and bam you got a mask. pass that information as the texture and your set to go.

Share this post


Link to post
Share on other sites
saeZ    122
Throwing my spoon in the wagon or something.
I agree with dfawcett on masking. I don''t know much about the alpha channel method, but if masking works, why change it? When I started my ogl-iso engine, blitting the sprites was my first problem.
I tried masking and it worked. I haven''t even considered changing the method since. Only thing I had to add was a function which creates the mask automatically. Well, that''s pretty much of a necessity, but anyhoo..

saeZ
http://www.geocities.com/saezee

Share this post


Link to post
Share on other sites
marauder    122
thanks for your replies.

that''s the result of my rpg engine til now.
i have found a very effective way to animate one or more textures in a level at the same time with infinite frames.

crate morph effect : http://www.hw-board.de/snake/rpg_morph.zip
water wave effect : http://www.hw-board.de/snake/rpg.zip

german hardware board
www.hardwareboard.com

Share this post


Link to post
Share on other sites