Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've seen tilesets of the game Braid, and for each tileset in the main folder there is an alpha map for it in "alpha" folder.

I wonder, why just not to draw your image as it is (with transparent parts where you want), export to PNG format and parse it to RGBA texture?

Why would one use a separate alpha map for this, is there some kind of performance benefit?

share|improve this question
    
What format braid uses for textures? – HolyBlackCat Mar 19 at 14:26
    
probably not possible due to copyright but I really would like to take a look at the files – Benedikt S. Vogler Mar 19 at 15:54
    
Benedikt, yes you cannot use these images in game or share with someone, but you can look in game folder and find package.zip:) Inside it there is "pieces" folder. – MrKnyaz Mar 19 at 18:50
    
HolyBlackCat, it uses jpeg format. – MrKnyaz Mar 19 at 19:03
up vote 6 down vote accepted

The idea of using a separate transparency map is a bit of a throwback to an earlier era, where we would use black-and-white bitmaps as transparency masks to draw sprites.

That said, it's still a perfectly viable technique today. There's really no appreciable performance difference between using a color and alpha map versus one color map containing alpha as an additional color component. There may be some minor issues regarding disk or memory footprint, but those will mostly be irrelevant in the grand scheme of things.

A good reason to use separate image sources like this today is not for game runtime performance but authoring performance. If you only have tools available to you that don't work well with images containing alpha channels, or you simply prefer to work this way, it can be more efficient for you to do so rather than in a context where the alpha is embedded into the color.

Similarly if you've chosen a particular image format that doesn't support embedded alpha channels for other important reasons, you may end up using this "separate mask image" technique.

share|improve this answer

Sometimes RGBA compresses worse than RGB and A separately.

Also it is known technique to use JPG for resources, where game could sacrifice some picture quality in favor of smaller size (e.g. backgrounds). Standard JPG does not support Alphas, so resource has to be split into two - RGB + A. Note that also allows for different compression ratios. E.g. some RGBs is more forgiving to higher compression ratio artifacts.

*as well noted in comments, JPG allows for different formats and even user-defined chunks that can include anything, yet majority of loaders will provide for just common JFIF / RGB data.

share|improve this answer
1  
This is an excellent point that I tend to forget. – Josh Petrie Mar 19 at 16:07
    
Thank you for your answer. I think background is a very good place to use this technique. – MrKnyaz Mar 19 at 19:00
1  
"JPEG does not support alphas" - Java has no problem reading and writing JPEGs with alpha, but most other programs won't read them correctly. I don't know whether it's using a non-standard extension, or a standard extension that's just not widely supported. – immibis Mar 19 at 22:10
2  
@immibis JPEG supports an arbitrary number of components, but doesn't define what they are. JFIF, the most common format JPEG compression is used with, says there can only be 1 or 3 components, either grey scale or Y/Cr/Cb. Most JPEG decoders only know how to handle JFIF files. – Ross Ridge Mar 20 at 0:31
    
Isn't it kinda pointless since any images loaded into graphics card memory become bitmaps and take up the same memory space for the same resolution as any other image format, compressed or not? I don't think hard drive space matters as much as video ram today. Correct me if I'm wrong. – user1306322 Mar 20 at 8:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.