Author Topic: Texture formats -- tga, png, jpg  (Read 8422 times)

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Texture formats -- tga, png, jpg
« on: 27 February 2011, 05:22:26 »
I'm sensing a trend here.  There's been a lot of banter in various threads about texture formats lately, and which ones should/shouldn't be used in mods.  Rather than cluttering everyone's threads, feel free to discuss in this thread the pros and cons, the whats and whys, and whatever other issues you need to get off your chest about texture formats.

Specifically, the issue at hand is lossy jpg versus lossless png, and whether the long-term inability for jpg images to be altered and realtered without degradation is worth the reduced file size.

Discuss.

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Texture formats -- tga, png, jpg
« Reply #1 on: 27 February 2011, 06:40:33 »
Another aspect is dds which is also (usually) lossy.  Are there the same concerns about that too?

There are scripts for loading g3d back into blender, but that is also lossy - is making blends available to other modders also desirable?

I've previously written packing scripts for mods that attempt all kinds of optimisations for reducing downloads and diffs.

It occurs to me that just as software, you might have both source and binary downloads available, where the 'source' pack contains the .blends and any other original artworks too.  Tools can help get this right.

(Are ther examples of people editing others art for real?)

ultifd

  • Airship
  • ********
  • Posts: 4,443
  • The Glest Video Guy :) The one and only. :P
    • View Profile
    • My Youtube Channel
Re: Texture formats -- tga, png, jpg
« Reply #2 on: 27 February 2011, 07:49:00 »
Ultimately PNG wins...That doesn't give any reason to not support JPG or TGA with either engine though. Maybe they somehow can optimize the quality JPG or downsize the filesize of TGA in the future, who knows. If people can't get the fact that people are still using JPG for any reason, they should just chill... People will eventually use PNG. What's good about TGA though? I kinda always had bad experience with it, well first of all when I first downloaded Glest; Google Picasa couldn't load them correctly. :P

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Texture formats -- tga, png, jpg
« Reply #3 on: 27 February 2011, 08:11:39 »
 Jpeg doesn't support transparency, so is a good replacement for all the bmps in the system if we aren't using compressed textures inside the engine.

Png is a replacement for tga but the gains when the mod is distributed compressed are modest.  Typical textures don't compress well losslessly, whether png or tga in a compressed archive.

Dds seems good being the lossy compressed texture with alpha support and fast loading on most ati and nvidia cards.  As long as it can be loaded by some lib for those opengl users without the extension.

Both jpeg and dds have varying quality to bitrate depending on tools - the nvidia dds packers can take several minutes to compress each texture as optimally as possible.

I've heard people complaining that load is slow on windows and I speculate that the d3d is slower to init than opengl, as its hard to blame the filesystem or archive support.
« Last Edit: 27 February 2011, 08:16:20 by will »

ultifd

  • Airship
  • ********
  • Posts: 4,443
  • The Glest Video Guy :) The one and only. :P
    • View Profile
    • My Youtube Channel
Re: Texture formats -- tga, png, jpg
« Reply #4 on: 9 March 2011, 07:46:30 »
But what's the benefit of TGA? I don't understand why people use it if PNG is just as good but not as big...

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Texture formats -- tga, png, jpg
« Reply #5 on: 9 March 2011, 08:14:47 »
PNG could also replace BMP.

PNG has to be decoded when loaded; this is no longer a performance problem.

Does blender etc support PNG textures?

But personally I come down to think engines ought to prefer DDS.

(Now I've read up on DDS I understand it is exactly the same compression as I met previously in the PowerVR world and I'm happy with its trade-offs.)

I hope the Glest 4.0 uses SOIL and this put choices in the hands of the content providers, not needing to navigate the texture formats supported by each engine.
« Last Edit: 9 March 2011, 08:17:41 by will »

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Texture formats -- tga, png, jpg
« Reply #6 on: 9 March 2011, 09:14:05 »
But what's the benefit of TGA? I don't understand why people use it if PNG is just as good but not as big...
TGA is a little smaller when compressed, as PNG can actually become bigger when put into an archive.  In my opinion, it's not a big enough difference to make it worthwhile.  I keep my (uncompressed) working directory inside my Dropbox, so I use PNG because of the constant synchronization.

PNG could also replace BMP.
It does.  Try it with an icon in GAE. ;)

Quote
Does blender etc support PNG textures?
Absolutely.

Quote
But personally I come down to think engines ought to prefer DDS.
How feasible is that?  The impression I get is that it's a pain in the ass to work with DDS because it needs special exporters, and I couldn't find a way to do it in a batch.

ultifd

  • Airship
  • ********
  • Posts: 4,443
  • The Glest Video Guy :) The one and only. :P
    • View Profile
    • My Youtube Channel
Re: Texture formats -- tga, png, jpg
« Reply #7 on: 9 March 2011, 09:26:26 »
TGA is a little smaller when compressed, as PNG can actually become bigger when put into an archive.  In my opinion, it's not a big enough difference to make it worthwhile.  I keep my (uncompressed) working directory inside my Dropbox, so I use PNG because of the constant synchronization.
Yeah, well even if that's true, what mainly matters the uncompressed size... So I think I'll I should ask titi to convert all the TGAs to PNGs in the megapack, later.

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Texture formats -- tga, png, jpg
« Reply #8 on: 9 March 2011, 09:28:49 »
Quote
But personally I come down to think engines ought to prefer DDS.
How feasible is that?  The impression I get is that it's a pain in the ass to work with DDS because it needs special exporters, and I couldn't find a way to do it in a batch.

Depends if mod packing scripts become widely used.  The ATI and NVidia DDS converters used by game studios can take arbitrarily long depending on the quality setting of course.

PNG (and BMP/TGA) are lossless, of course - and that's a bigger subject perhaps.

My plans for GlestNG is to auto-pack in the engine.  If you give GlestNG a piece of artwork, it'll actually store a cached DDS translation hidden away - but that translation will be the fast kind of conversion the GPU driver's auto-convert does, rather than the higher quality slow offline conversion that you can do with the ATI and NVidia tools (or a mod packing tool that uses them or does its own optimisation) so there is benefit in people doing the high-quality conversions before uploading mods.
« Last Edit: 9 March 2011, 10:12:02 by will »

ChupaReaper

  • Guest
Re: Texture formats -- tga, png, jpg
« Reply #9 on: 10 March 2011, 18:14:06 »
PNG has always been my favourite format, the whole of my website just about uses it as well (gifs and jpegs used for large images and photos, gifs for alpha and animation) an animated png would be interesting unfortunately the only type I know is the fireworks animated png.
With my mod for GAE, I had to use TGA at first which is ok but having the alpha in a separate channel was very annoying and also windows can't preview them, though there are ways to have tgas displayed in explorer.
Now that PNG is supported, all my new textures are PNG format, though buttons are still BMP as they don't need alpha and are quite small, however I may start using png for them too in my third faction. I like PNG for its good compression, it's alpha and the fact that it's lossless and it's widely supported which is a bonus.
I've worked with dds before and it's very annoying especially now that I can't get the dds tools to work in Photoshop CS5 and that it's not a very supported format when it comes to modding. Having dds being used by the engine at runtime or via mod packers or whatever is ok though, so long as I don't have to constantly use some weird tools to convert tga/png/bmp to dds every time I want to make a slight change. As a 'background mechanism' dds is fine especially if it reduces memory strains which are a big problem for my mod at the minute, though it's more the g3d model format than the 2d mipmaps 'overload' that's a problem now.

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Texture formats -- tga, png, jpg
« Reply #10 on: 10 March 2011, 23:42:30 »
Here's some stats from a random - hopefully representative - texture:

262,162 texture_archer.tga  
104,164 texture_archer.tga.xz
 43,832 texture_archer.dds  
 27,748 texture_archer.dds.xz

108,519 texture_archer.png (for comparison)

As you can see, it goes from ~100KB down to ~26KB for the download, and the size of the originals - ~250KB down to ~41KB - is indicative for how much texture memory is being used.

DDS is lossy, but it is good enough lossy for all mainstream games.
« Last Edit: 11 March 2011, 07:43:30 by will »

ChupaReaper

  • Guest
Re: Texture formats -- tga, png, jpg
« Reply #11 on: 11 March 2011, 00:19:00 »
I woudln't like to use dds really but thinking about it, it would be useful for normal maps and specular maps as they can be generated from the diffuse with a few tools directly into dds format and a bit of quality loss isn't so big as it's the diffuse map that needs most of the detail which could be in png or tga.

hailstone

  • GAE Team
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: Texture formats -- tga, png, jpg
« Reply #12 on: 11 March 2011, 08:12:07 »
Don't think of normal and specular maps as images. Any loss in quality is going to affect the lighting.
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Texture formats -- tga, png, jpg
« Reply #13 on: 11 March 2011, 08:22:57 »
Depends if mod packing scripts become widely used.  The ATI and NVidia DDS converters used by game studios can take arbitrarily long depending on the quality setting of course.
Doing each one by hand is troublesome, but I'd certainly do the conversion if it were automated with a packing script like that.

Quote
PNG (and BMP/TGA) are lossless, of course - and that's a bigger subject perhaps.
People just need to hang onto their source files (ideally *.xcf with layers), or have them packed by the script (I seem to recall this being discussed before).

Quote
My plans for GlestNG is to auto-pack in the engine.  If you give GlestNG a piece of artwork, it'll actually store a cached DDS translation hidden away - but that translation will be the fast kind of conversion the GPU driver's auto-convert does, rather than the higher quality slow offline conversion that you can do with the ATI and NVidia tools (or a mod packing tool that uses them or does its own optimisation) so there is benefit in people doing the high-quality conversions before uploading mods.
So would that increase load times or what?  Would it only need to be run the first time?

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Texture formats -- tga, png, jpg
« Reply #14 on: 11 March 2011, 08:32:17 »
Quote
People just need to hang onto their source files (ideally *.xcf with layers), or have them packed by the script (I seem to recall this being discussed before).

absolutely; the mod packing script ought to generate an archive file of the mod, a "source archive" too with the originals, and any deltas.

Quote
So would that increase load times or what?  Would it only need to be run the first time?

That was to reduce load times both locally and for games where you have to automagically download those files you don't have yet.

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Texture formats -- tga, png, jpg
« Reply #15 on: 11 March 2011, 19:50:26 »
Paint.NET has addons to both export to DDS and to automate actions (aka: a macro). Albeit, finding the download for them from the Paint.NET site might be a hassel...
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert