i am using speedtree to make trees but for their example trees they have all files in targa, well from my comparison targa files are much larger than png files so why are they used? i am not clear about it so if anyone can clarify it that would be great thanks
Replies
but most of the time it doesnt matter, as images are composed and exported from another tool to png - and its not the intended workflow to edit the resulting images.
for unity it doesnt really matter which source files you use for textures.
For example if you have a 12mb png image and a 76mb targa no matter which one you choose the build size would be 4mb for both (the numbers are random)
I guess png would be fine though. The only difference is that targa is able to contain the alpha map for transparency.
http://www.fnordware.com/superpng/
If you only have transparency as an alpha channel and you want to make a PNG, you need to convert that channel to transparent pixels in the layer. Go to the Channels tab and CTRL + click on the alpha channel (or select that channel and press the "Load As Selection" button) to load it as a selection, go back to the Layers tab and click on the "Add layer mask" button (it's a square with a hole on it), which will make a layer mask from the selection.
Then you can save as a PNG straight away, or right-click the layer mask and select "Apply Layer Mask" to apply the mask directly as pixel transparency.
To save the PNG with transparency, you can use...
- File -> Save As (and choose PNG format), or
- File -> Save For Web (and choose the PNG - 24 format) where you can explicitly tick the 'Transparency' option to export with transparency or if you don't, it flattens with a white background.
PS: To make an alpha channel out of a transparent layer, select a layer and go to menu Layer -> Layer Mask -> From Transparency, it makes a layer mask from it and makes the layer pixels opaque (with bleeding and such).
Then you can go to the Channels tab and duplicate the "Layer (n) Mask" channel or else when you delete the layer mask that temporary mask channel will also be removed. The duplicate stays there, and when you save it as a TGA it will be considered as the alpha channel (if you tick the Alpha Channels option in the Save As dialog, of course).
Make sure to fully test all the variables of the solution you end up going for, as this stuff goes much deeper than just "transparent or not". For instance in some circumstances you can end up with the transparent pixels being effectively deleted, which might not sound like a big deal at first but can bite you in the butt later. If you go for PNG, then at the very least use SuperPNG for maximum control.
I'd personally always favor TGA if possible simply because it is raw and straightforward. It also saves really fast - I just ran a test recently, and saving 3 big folders from a 4k PSD to TGAs using an automated file saving script took 10 seconds, whereas the same thing with regular PNGs took over a minute. That's the kind of stuff I am talking about when suggesting you to test all variables of a given solution.
In general you want to work in such a way that you the content creator can always access the fully editable source data, with all the conversions/compression being taken care of transparently later down the pipe. For instance the game might use some advance DXT compression, but you should never have to even worry about that (and this is where the Technical Artists/tool guys come into play). But of course this also all depends on team size.
Good luck !
(So all that said ... you are now seeing why many people like to use TGAs. In practice it might not sound like a big difference, but being able to clearly see transparency as a channel in Photoshop with a guarantee that no pixels being ever "destroyed" in the saving process is a serious relief. Now of course in practice a pipeline can very well be established around the PNG format, but I personally feel like it's asking for trouble.)
Ironically I am pretty sure that internally PNG is a regular RGBA format, with 4 distinct channels, but there are definitely optimisations going on during saving that affect what is "under the transparency". And if I remember correctly (based on a post by an Adobe engineer) the somewhat odd way Photoshop displays it is dictated by the format rules.
So from there that leaves you with TGA (non destructive) or DDS (highly destructive), which explains why so many tools and artists rely on the (unfortunately heavy) TGA format. As said earlier it really shouldn't matter in the end because a solid pipeline would take whatever you give it (PSDs, TGAs) and then compresses it as needed to create the (most likely DDS) files actually used by the game at runtime, which is definitely not PNG anyways.
DXT is the destructive, lossy compression format you're thinking of.
DDS is merely a container, which can contain different types of compressed or non-compressed image data.
Another vote for TGA format over PNG, at least for game development use. Shaders typically don't work well with PNG since they usually need alpha as a separate channel. TGA gives you this.
You can also use RLE compression for TGA which is a lossless compression. Basically blank or solid-color areas get compressed a lot.