View Full Version : TGAs, transparency and PSP

13th Aug 2006, 13:59
I don't know how many of you use TGAs for textures, but if you ever want to and use PSP, or anything other than a pre-Adobe version of Photoshop, then you should read this.

First of all, for those who are asking, "Why use TGA? I can get transparency using a GIF and palette index 0." Well, that's true, but GIF transparency is binary, meaning a pixel is either completely opaque or completely transparent. Of course by combining that with the Renderer > transparency (alpha) value you can have an object or AI texture which has both completely and partially transparent areas, but you're still limited to only two levels of transparency. Using TGAs allows you to have 256 levels of transparency on every pixel in the texture, so you can have gradual fades from opaque to transparent, for example. I'm not going into how to do that in this post, but it's possible and not too hard to do by making a mask using gradient fills and whatnot.

All that being said, as you may guess I've been working with TGA textures lately. The iron gates which I posted at TTLG recently (still being polished up by Vigil, available very soon) use TGA textures, and in developing them with Vigil, we discovered that all the TGAs I saved through my graphics editor, PSP 7.04, had problems. The completely transparent areas were fine, but in the partially transparent areas (areas where the mask is grey rather than black or white), the base texture was lightened and became whitish. This manifests as a greyish fringe on the borders of the opaque parts, where it's supposed to be partially transparent to suggest depth and smoothness.

After doing some research, I discovered this post (http://adam.wincustomize.com/Articles.aspx?SID=59&AID=74756), titled "How dare you touch my alpha channel!" by Adam Najmanowicz. He was upset by the fact that Adobe farked this up in the recent versions of Photoshop, and so he wrote this handy tool (http://www.najmanowicz.com/temp/AlphaConv.zip) which allows you to convert from PNG to TGA. Since PSP handles transparency properly in PNG files (so long as you setup your prefs correctly), it provides a solution for those of us who use PSP and other editors that mangle TGA transparency.

Here's what you need to do once you have the AlphaConv tool:

When you have your TGA ready to go, make sure you've saved the mask to an alpha channel. Then, save it as a PNG file, making sure the alpha channel is saved too.
To do that in PSP7, Save As..., choose PNG, and then click Run Optimizer from the Save As dialog. On the Transparency tab, make sure to select Alpha channel transparency, and Existing image or layer transparency.
Then just launch the AlphaConv tool and drag the PNG file onto its window, and it will spit out a TGA file in the same directory as the PNG file.

14th Aug 2006, 01:59
Coincidentally I've been using this exact procedure for importing fonts into T3Ed, the only difference being the use of DDS Converter to make the DDS files required by T3Ed instead of TGAs. If you haven't set the transparency in the image up yet, it may help to use Layers menu -> New Mask Layer -> From Image... Select Source Luminance and it will create a mask kind of like a greyscale version of the image. If the texture is on a black background then that will at least give you the correct outlines, allowing you to tweak the mask by hand before saving (PNG) and converting.

14th Aug 2006, 02:06
That's exactly what I did to get the initial masks for the iron gates that Vigil and I are working on, although in PSP7 it's not under the Layers menu, there's a separate Masks menu.

14th Aug 2006, 02:57
PSP 8 here. Re-reading my post it sounds like I was trying to give you advice, I actually meant it for anyone else who happens to wander by. I'm sure you're more than capable of setting up alpha channels!