Author Topic: Preferable textures for fast gameplay  (Read 1376 times)

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
Preferable textures for fast gameplay
« on: 20 August 2011, 03:37:38 »
Would converting all my .tga textures to .jpg or .png increase in-game performance in any way?
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Preferable textures for fast gameplay
« Reply #1 on: 20 August 2011, 07:22:47 »
No, but jpg would typically speed up downloads and both might slow down loading slightly.

Removing unnecessary e.g. alpha channels is good though, and generally making sure they are no larger than necessary, and both height and width are a power of 2.

Mipmapping and texture compression make the biggest impact, but these are engine options not artist options.

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Preferable textures for fast gameplay
« Reply #2 on: 20 August 2011, 08:38:16 »
I strongly advise against using JPG though, as it's a lossly format, so each time you save, unless you remember to keep the source PNG, etc, you will lose data. As well, the compression causes deformation in the images. JPG is something that should be used for quick screenshots that won't likely be used again in the future, mods should always be redistributed with a lossless format, to allower modders to make use of your media.

PNG can even be smaller than JPG at times, such as when the colors fit into an 8-bit palette (256 colors). For example, save a pure black image at 1000x1000 pixels and it's 16.2 KB JPG, but only 5.2 KB PNG. And pushing this image through PNGGauntlet, a powerful PNG optimizer, I compressed it to a mere 216 bytes, 4% the original size! Admitingly, that doesn't work the same way in the detail that most images have, the lossless compression and transparency are a fair trade off.

To ensure compatibility, please only use power of two images, as others can crash or cause problems on older cards. GAE restricts images to powers of two for this reasoning.
« Last Edit: 20 August 2011, 08:51:33 by Omega »
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
Re: Preferable textures for fast gameplay
« Reply #3 on: 20 August 2011, 13:08:30 »
No, but jpg would typically speed up downloads and both might slow down loading slightly.
How would they slow down loading?

Mipmapping and texture compression make the biggest impact, but these are engine options not artist options.

Mipmapping? I've never sen an option for that on MG or is that a GAE thing?

PNG can even be smaller than JPG at times, such as when the colors fit into an 8-bit palette (256 colors). For example, save a pure black image at 1000x1000 pixels and it's 16.2 KB JPG, but only 5.2 KB PNG. And pushing this image through PNGGauntlet, a powerful PNG optimizer, I compressed it to a mere 216 bytes, 4% the original size! Admitingly, that doesn't work the same way in the detail that most images have, the lossless compression and transparency are a fair trade off.

I just remembered JPG don't have an alpha channel, so i cant use em for much anyways. Maybe ill convert to png to save space, but i wont have time to do that now, maybe for a later version. Ill try PNGGauntlet too.

All my textures are powers of 2 and most are relatively small. only big buildings use 512 textures rest are either 128 or 256 depending on their size.
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Preferable textures for fast gameplay
« Reply #4 on: 21 August 2011, 04:30:58 »
Mipmapping and texture compression make the biggest impact, but these are engine options not artist options.

Mipmapping? I've never sen an option for that on MG or is that a GAE thing?
Mipmapping refers to reducing the size of textures when the camera is zoomed out, to try and reduce the resources needed to display the larger area. For example, you may be using a 512x512 texture on that building, but when zoomed way out, it could easily be a 64x64 texture without any noticeable difference, which is what mipmapping is for. I am as confused as you, though, whether or not there is mipmapping in either engines. I once noted that older versions of Mrise crashed in GAE during a loading stage named "generating mipmaps", but later someone mentioned something about Glest not having mipmaps in a forum post, so as to whether or not there is any in Glest, I haven't a clue, but there certainly should be!

PNG can even be smaller than JPG at times, such as when the colors fit into an 8-bit palette (256 colors). For example, save a pure black image at 1000x1000 pixels and it's 16.2 KB JPG, but only 5.2 KB PNG. And pushing this image through PNGGauntlet, a powerful PNG optimizer, I compressed it to a mere 216 bytes, 4% the original size! Admitingly, that doesn't work the same way in the detail that most images have, the lossless compression and transparency are a fair trade off.

I just remembered JPG don't have an alpha channel, so i cant use em for much anyways. Maybe ill convert to png to save space, but i wont have time to do that now, maybe for a later version. Ill try PNGGauntlet too.
I should probably note a few things for the record, before someone else points them out. Firstly, JPG usually gives smaller size than PNG, since most images won't be 8-bit, but rather 24-bit (no alpha) or 32-bit (alpha). 8-bit can only have 256 colors and one alpha channel, so is pretty limited (GIFs are 8-bit, for example), whereas a 32-bit image has 8 bits for each red, green, and blue, plus 8 bits for a full transparency channel, allowing partial transparency, something most units in Glest will likely have (if not, then they lack teamcolor, at the very least).

On the long run, JPG usually ends up considerably smaller than PNG (in one test, the swordman texture became about 80 KB as a JPG and 131 KB as an optimized PNG). Normally, PNG will also be far, far smaller than TGA, since TGA is completely uncompressed and unoptimized (it's basically a bitmap image with an alpha channel). However, once you put the file in an archive, such as a 7z, they become roughly the same, and TGA can even be marginally smaller (for example, the swordman texture as a TGA in a 7z was only 108 KB, while the PNG in a 7z was 134 KB). The reason for this is because PNG is already compressed, while TGA is not. Thus, 7z cannot compress the PNG files (which often end up slightly larger compressed), but can apply its very effective compression to TGAs.

However, Glest and MegaGlest require that the mods not be in an archive, which means that the swordman texture will be a full 256 KB in TGA, whereas the PNG is a nicer 133 KB. Only GAE can have mods remain in an archive, which makes TGA slightly smaller in GAE, but massively larger in MG.

However, there's also the issue of compatibility. Pretty much every editor, image viewer, etc can handle PNG, which is one of the most used image formats in the world, whereas TGA is less supported, and many people won't even see one, normally. If you wanted to upload an image online, PNG would work, but TGA would usually not.

All in all, the bottom line is that PNG and TGA have different instances in where they can be smaller sizes. However, I consider PNGs to be far easier to use and more versatile, not to mention that I do all my working in regular folders, not a compressed archive, which makes them easier on the hard drive, and particularly so when uploading online. As an end result, I am using only PNG images in the next version of Apocalyptic Dawn.

So what about JPG? Well, lossly compression and no transparency is a huge downfall. It's a great format for quick screenshots and such where I don't expect anyone to want to edit or reuse the file, and where speed and size is a must, but it has no real place in the textures of a Glest Mod.
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
Re: Preferable textures for fast gameplay
« Reply #5 on: 21 August 2011, 04:55:57 »
Yes mipmapping really should be a feature... Is this similar to MG texture compression?

Interesting, so png would be better for less hard drive space for an unpackaged mod, but tga would be better for a zipped mod or downloading. I guess ill stay with tga since it would package better and be less download time for players. ^^ I don't mind not being able to view textures on a viewer since I would be editing it in Photoshop anyways.

Thanks man!
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Preferable textures for fast gameplay
« Reply #6 on: 25 August 2011, 12:53:18 »
I also suggest using PNGs at least for all bigger textures. 64x64 ground textures are not so important, but all model textures should use png.
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

 

anything