Page 1 of 1

Gibbed Tools modified to support compressing of images

PostPosted: 23 May 2013, 23:13
by RiiakShiNal
This post is to give everyone a modified version of Rick's great Gibbed Tools. The modified version supports compressing of images to DXT1, DXT3, and DXT5 in addition to default uncompressed TDXs.

The only real visible changes for users is the addition of some command line parameters for TdxConvert:
--d1, --dxt1 - Compress image to DXT1 format when converting to TDX.
--d3, --dxt3 - Compress image to DXT3 format when converting to TDX.
--d5, --dxt5 - Compress image to DXT5 format when converting to TDX.
--nomip - Do not create MipMaps when compressing to TDX.

Notes:
  • Now will automatically convert to closest multiple of four (MoF) image size when compressing images to TDX and will automatically create MipMaps for DXT compressed images (unless user specifies --nomip as a command line parameter).
  • While the TdxConvert program will accept images of any size for compression (and will decompress them properly) the game will only accept the compressed images if both width and height are multiples of 4.

This is based on Gibbed Tools r6_b10, I only added a relatively small amount of code so I take no credit. All credit should go to Rick (aka Gibbed).

If you are looking to compress one or more images via drag and drop then you can use these batch files:
TdxConvertDXT1.bat | Open
Code: Select all
@echo off
for %%A in (%*) do (
Gibbed.Duels.TdxConvert.exe --dxt1 %%A
)
TdxConvertDXT3.bat | Open
Code: Select all
@echo off
for %%A in (%*) do (
Gibbed.Duels.TdxConvert.exe --dxt3 %%A
)
TdxConvertDXT5.bat | Open
Code: Select all
@echo off
for %%A in (%*) do (
Gibbed.Duels.TdxConvert.exe --dxt5 %%A
)
To be honest I don't really think this is important enough for it's own thread, but I also didn't want to clutter Rick's thread with modifications that he doesn't support (because he didn't make them).

Change History:
  • February 9th, 2014
    • Removed even mipmap sizing as it was apparently causing the mipmap image appearance corruption. The mipmap sizing is not stored in the TDX and the game apparently expects the mipmaps to be 1/2 of each dimension truncated to a whole integer and doesn't care if the integer is an odd number.
  • July 5th, 2013
    • Fixed a bug with already MoF sizes.
    • Added automatic Multiple of Four (MoF) image sizing when compressing to TDX (no change in sizing will occur if converting uncompressed or if already MoF sized).
    • Added generation of MipMap chain when compressing to TDX (--nomip parameter will disable).

Re: Gibbed Tools modified to support compressing of images

PostPosted: 05 Jul 2013, 17:48
by RiiakShiNal
Sorry for the double-post, but I added MipMap generation and automatic MoF sizing to it. Attachments in the original post have been updated.

I figured if I didn't add a post no-one would notice.

Re: Gibbed Tools modified to support compressing of images

PostPosted: 05 Jul 2013, 18:27
by thefiremind
I tried to use your updated tool for the 1024x1024 image, and it resized to 1028x1028. Why? 1024 is MoF already.

Re: Gibbed Tools modified to support compressing of images

PostPosted: 05 Jul 2013, 19:01
by RiiakShiNal
thefiremind wrote:I tried to use your updated tool for the 1024x1024 image, and it resized to 1028x1028. Why? 1024 is MoF already.
Due to a bug, sorry about that, now fixed.

Re: Gibbed Tools modified to support compressing of images

PostPosted: 08 Nov 2013, 13:48
by thefiremind
Since I wasn't sure if I was the only one who experienced the following issue, I waited a long time before reporting it, but I just read this and I'm pretty sure it's the same issue.
You see, your modified Gibbed Tools work perfectly for me for all kinds of DotP art except for one: tokens. When I compress a token picture, I see it scrambled in game:
token.png
Official 3/3 Beast token recompressed with your tools
token.png (18.96 KiB) Viewed 17129 times
This happens only while the card is laid on the battlefield: when I zoom in, the picture is fine.

Re: Gibbed Tools modified to support compressing of images

PostPosted: 09 Nov 2013, 00:47
by RiiakShiNal
It seems to happen because of the dimensions, I see it when I compress images too. It seems to be more pronounced if the source X dimension is not evenly divisible by 8 or 16. According to some source I read on the web when you drop down one level and the current level has an odd dimension you are supposed to truncate the decimal after dividing by 2 (which I do when calculating the mipmaps), if the dimension is 1 however it remains at 1 until both dimensions are 1x1 at which point mipmap generation ceases. I'm not sure exactly where the problem is and I have been looking into it so I'm not yet sure if the problem is in the image created by the DXT compression library or if the problem is in how the game handles such situations. It is possible that the source I read was wrong (as there don't seem to be that many sources on manual generation) and you are supposed to round the decimal (in which case it would always round up due to being .5). Some sizes show this problem while other sizes don't (this seems to be static sizes that work always work sizes that don't always don't), so a current workaround is to resize the image up or down to a size that does work properly.

In short, I am aware of the problem and I am trying to find a good solution. Regardless though right now updates are going to be slow as I am having some hardware problems (one of the fans in my laptop died [this isn't a big problem] and I have 2 hard drives going bad [they are still at the early stages of going bad, but it is still causing some major problems]). My laptop is my development machine (as well as e-mail) so this is slowing me down.

Re: Gibbed Tools modified to support compressing of images

PostPosted: 09 Nov 2013, 10:30
by thefiremind
Well, the problem doesn't bother me much: I kept using Eglin's tool for compressing token images, and your tools for everything else. I just wanted to be sure that you are aware of it. :)

Re: Gibbed Tools modified to support compressing of images

PostPosted: 02 Dec 2013, 16:57
by Drakno
What other programs should I have installed for gibbed tools to work? At the moment it instantly crushes

Re: Gibbed Tools modified to support compressing of images

PostPosted: 02 Dec 2013, 22:49
by RiiakShiNal
Gibbed Tools uses the .Net 4.0 Framework which is not included, but that should be the only requirement. It should also work with Mono assuming Mono has support for the .Net 4.0 interfaces.

Re: Gibbed Tools modified to support compressing of images

PostPosted: 10 Feb 2014, 01:10
by RiiakShiNal
I have just updated the Modified Gibbed Tools to put in a fix for the scrambled mipmaps as reported earlier.

It seems the problem is that the TDX format does not store the mipmap sizes and the game expects the sizes to be 1/2 of each dimension with any decimals truncated. So if we have a 388x316 image the sizes that the game expects should be as follows:
  • 388x316
  • 194x158
  • 97x79
  • 48x39
  • 24x19
  • 12x9
  • 6x4
  • 3x2
  • 1x1

A token with size 356x512 should now have these image & mipmap sizes:
  • 356x512
  • 178x256
  • 89x128
  • 44x64
  • 22x32
  • 11x16
  • 5x8
  • 2x4
  • 1x2
  • 1x1

The TdxConvert program will now output the compressed TDX to these specifications. So this should solve the last of the issues regarding the compression to TDX.