Page 1 of 4
Transparency in PNGs
Posted: Thu Jan 26, 2006 6:37
by Caligari_87
Okay, I have PNGs working for Haloguns; the question I have now is, how can I apply varying levels of translucency to the image, say for muzzle flares? If I try to convert the image to 8-bit, all my alpha information is discarded, making it either "transparent or not".
I'm working in the GIMP; can anyone give me a hand here?

Posted: Thu Jan 26, 2006 7:35
by Nash
Same problem I had in a thread below this one. :/
Posted: Thu Jan 26, 2006 7:41
by Caligari_87
I know, but I couldn't figure it out from the info that was in there.

Posted: Thu Jan 26, 2006 8:10
by Nash
Cals! I figured it out!
Okay first, prepare the images. I read that you have alpha masks mapped out nicely in the gimp so you're good to go. Save as true-colour PNG so that the alpha will be retained.
NEXT STEP: As Graf said in the other thread; Google for PNGQUANT. It's very easy to use but if you prefer a GUI version, it's available on the pngquant's page too.
Run pngquant like this:
pngquant -force 256 <your picture.png>
Voila! Your PNG is converted to 256 colours, but the alpha is still there. Your file will be saved as the original file name, with an -fs8 sufffix. Example M_DOOM.PNG will have an output of M_DOOM-fs8.png.
EDIT NOTE: Your PNG might appear screwy in your paint program (the gimp, Photoshop, etc). Don't worry. It will look great in GZDoom if imported correctly with XWE (import as raw data).
Now you probably have an assload of files to convert. You can either do it the manual way...
pngquant -force 256 pic1.png pic2.png pic3.png pic4.png pic5.png ... etc...
Or you can download the GUI.
Once your PNG has been converted to 8 bit, you can use Randy's SetPNG to apply offsets. Easy!
Rebirth's M_DOOM replacement logo with smooth alpha fade outs!
Posted: Thu Jan 26, 2006 10:51
by Graf Zahl
It's really a shame that so many graphics tools don't handle translucency information well, isn't it?
Posted: Thu Jan 26, 2006 11:46
by DaniJ
It's really a shame that so many graphics tools don't handle translucency information well, isn't it?
I've never come across this problem in Photoshop. Then again I don't use "freak, bastard love child" formats like 8bit PNG with alpha

Posted: Thu Jan 26, 2006 11:54
by Graf Zahl
What's the problem with this format? It is official PNG standard but yet I haven't found a single tool that can read it without destroying the alpha channel. Especially when the same tools are perfectly capable of reading 32 bit alpha PNGs!
Posted: Thu Jan 26, 2006 12:03
by Nash
Well then, what is THE image format that never has problems, and is made for, alpha transparency?
Posted: Thu Jan 26, 2006 12:37
by DaniJ
What's the problem with this format? It is official PNG standard but yet I haven't found a single tool that can read it without destroying the alpha channel. Especially when the same tools are perfectly capable of reading 32 bit alpha PNGs!
As I said, the format itself is considered a FREAK within the industry so practically ALL commercial/big name graphics packages don't support it (other than the abomination that is FireWorks). That format was originally designed for web use only. Also, don't forget it was a brainchild of Macromedia and since they were bought out by Adobe over a year ago you can expect to never see support in PhotoShop. As such the format has been abandoned to the mists of time.
In the "real" world of modern game graphics, this is how it works:
If your engine supports DX texture formats - use them.
If you only need greyscale info (eg bump/spec map/alpha) - use RAW or if your engine supports it (and file size doesn't matter) - use 8bit PCX and convert to 1byte per pixel at runtime)
If you only need 8bit colour (no alpha) - use PCX
If you need alpha - use PNG32bit or TGA*
Otherwise, use PNG24bit.
* If you have the benefit of DX textures this isn't a hardnfast rule. DX formats support varied levels of alpha (1bit, 4bit and 8bit) so you choose the format best suited to the texture.
If I'd known you were trying to use PNG8bit+A I would have pointed this out earlier...
Posted: Thu Jan 26, 2006 13:08
by Nash
If Randy updates SetPNG to work with true colour PNGs, all problems will be solved and people can finally sleep at night...
Posted: Thu Jan 26, 2006 17:05
by Caligari_87
Well, it works, but GZDoom seems to mess it up. Check the screenshots for what I mean.
Posted: Thu Jan 26, 2006 19:02
by Graf Zahl
DaniJ wrote:
In the "real" world of modern game graphics, this is how it works:
If your engine supports DX texture formats - use them.
If you only need greyscale info (eg bump/spec map/alpha) - use RAW or if your engine supports it (and file size doesn't matter) - use 8bit PCX and convert to 1byte per pixel at runtime)
If you only need 8bit colour (no alpha) - use PCX
If you need alpha - use PNG32bit or TGA*
Otherwise, use PNG24bit.
What is it with the 'real' world that it tends to hold on to outdated formats. PCX is as obsolete as they come.
PNG could easily replace all of these without any hassle.
Posted: Thu Jan 26, 2006 20:31
by Nash
Cals, unfortunately that's where I wasn't impressed with PNGQUANT. It doesn't seem to do a good job at whatever it's doing.
I compared an in-game screenshot of my title graphic, and the same graphic that is converted to 8-bit from WITHIN Photoshop. The Photoshop-converted graphic looks better than what PNGQUANT does to my picture.
If you observe the screenshot I posted above, you'll see several black pixels scattered messily around the picture. I don't have any God damn black pixels in the first place.
Photoshop will convert the image to 8-bit fine, although transparency will be lost).
I've tried both dithering modes that PNQUANT uses - both yielded disappointing results.
If that is supposed to prove anything, heh.
Posted: Thu Jan 26, 2006 21:00
by DaniJ
What is it with the 'real' world that it tends to hold on to outdated formats. PCX is as obsolete as they come.
PCX is still a useful format when you don't have DX around. I'm only reporting on what I've learned from taking apart other FPS games (Quake series, UT series, PainKiller, FarCry etc etc) and lots of research for jDRP. By trade I'm a web developer...
Posted: Thu Jan 26, 2006 21:01
by Caligari_87
Well, the funny thing is, that png came out looking just fine. Even in XWE the colors were still there. It's only in GZDoom that it looks screwy like that.
I'll try searching google for PNG tools...
