Transparency in PNGs

Advanced OpenGL source port fork from ZDoom, picking up where ZDoomGL left off.
[Home] [Download] [Git builds (Win)] [Git builds (Mac)] [Wiki] [Repo] [Bugs&Suggestions]

Moderator: Graf Zahl

User avatar
Caligari_87
Posts: 45
Joined: Tue Nov 08, 2005 18:26
Location: Salt Lake City, Utah
Contact:

Transparency in PNGs

Post 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?

8)
User avatar
Nash
Developer
Developer
Posts: 1226
Joined: Sun Sep 25, 2005 1:49
Location: Kuala Lumpur, Malaysia
Contact:

Post by Nash »

Same problem I had in a thread below this one. :/
User avatar
Caligari_87
Posts: 45
Joined: Tue Nov 08, 2005 18:26
Location: Salt Lake City, Utah
Contact:

Post by Caligari_87 »

I know, but I couldn't figure it out from the info that was in there.

8)
User avatar
Nash
Developer
Developer
Posts: 1226
Joined: Sun Sep 25, 2005 1:49
Location: Kuala Lumpur, Malaysia
Contact:

Post 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!

Image

Rebirth's M_DOOM replacement logo with smooth alpha fade outs!
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Post by Graf Zahl »

It's really a shame that so many graphics tools don't handle translucency information well, isn't it?
DaniJ
Posts: 130
Joined: Sat Oct 08, 2005 19:22

Post 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 :lol:
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Post 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!
User avatar
Nash
Developer
Developer
Posts: 1226
Joined: Sun Sep 25, 2005 1:49
Location: Kuala Lumpur, Malaysia
Contact:

Post by Nash »

Well then, what is THE image format that never has problems, and is made for, alpha transparency?
DaniJ
Posts: 130
Joined: Sat Oct 08, 2005 19:22

Post 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...
User avatar
Nash
Developer
Developer
Posts: 1226
Joined: Sun Sep 25, 2005 1:49
Location: Kuala Lumpur, Malaysia
Contact:

Post by Nash »

If Randy updates SetPNG to work with true colour PNGs, all problems will be solved and people can finally sleep at night...
User avatar
Caligari_87
Posts: 45
Joined: Tue Nov 08, 2005 18:26
Location: Salt Lake City, Utah
Contact:

Post by Caligari_87 »

Well, it works, but GZDoom seems to mess it up. Check the screenshots for what I mean.
Attachments
How it looks in GZDoom
How it looks in GZDoom
DOOM0000.png (61.12 KiB) Viewed 2951 times
the source file from PNGQUANT and SetPNG
the source file from PNGQUANT and SetPNG
Fire01.PNG-fs8.png (8.87 KiB) Viewed 2951 times
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Post 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.
User avatar
Nash
Developer
Developer
Posts: 1226
Joined: Sun Sep 25, 2005 1:49
Location: Kuala Lumpur, Malaysia
Contact:

Post 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.
DaniJ
Posts: 130
Joined: Sat Oct 08, 2005 19:22

Post 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...
User avatar
Caligari_87
Posts: 45
Joined: Tue Nov 08, 2005 18:26
Location: Salt Lake City, Utah
Contact:

Post 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...

8)
Locked

Return to “GZDoom”