[Tool] GibbedTools - TDX Texture converter

The 2016 reincarnation of Carmageddon! Discuss, mod and troubleshoot!
User avatar
Trent
mindless
Posts: 2951
Joined: Wed Apr 05, 2000 9:08 am

[Tool] GibbedTools - TDX Texture converter

Post by Trent »

GibbedTools

This is a modified version of the GibbedTools package created by the Magic The Gathering modding community, I added support for Carmageddon: Reincarnation textures and normal maps.

Download it here: http://trent.incarnated.co.uk/downloads/GibbedTools.zip

Instructions

Installation

Extract the RAR file to a folder somewhere, it doesn't matter where.

Decompiling TDX files

Drag the TDX file onto Gibbed.Duels.TdxConvert.exe and it will automagically make a PNG image of the same name. When you open the PNG it will probably be mostly transparent, this is because the transparency controls how reflective the surface is. In Photoshop you can use Layer->Layer Mask->From Transparency to create an alpha channel from the image's opacity, you can then fill the alpha channel with white to make it opaque. However, it is a good idea to copy the contents of the alpha channel into a new layer so you can put it back into the alpha channel after you've finished editing the texture.

Compiling Textures to TDX files

Most textures can be compiled by dragging the PNG file over CompressDXT5.bat, which will create a TDX file of the same name using DXT5 compression.

However if you're compiling a Normal Map you must use CompressNormals.bat instead as Normal Maps require their own compression algorithm.

Source Code

The source code for the GibbedTools is provided, you can open the Gibbed.Duels.TdxConvert.sln in Visual Studio (you can use VS Express) and edit it to your heart's content. It is written in C# so it's fairly easy to understand. You can probably tell which bits of code are mine by how bad they are (e.g. everything in BC5Unorm.cs)
a.k.a. Brent
User avatar
Deamon
turbo bastard
Posts: 401
Joined: Sun Aug 21, 2005 4:01 pm

[Tool] GibbedTools - TDX Texture converter

Post by Deamon »

Thanks for the tool! Found some cool images in the tdx files, and some interesting unused stuff too :)
User avatar
HEX1GON
turbo bastard
Posts: 261
Joined: Wed Apr 02, 2014 12:28 pm

[Tool] GibbedTools - TDX Texture converter

Post by HEX1GON »

When converting an iOS TDX it causes it to crash :(
User avatar
Trent
mindless
Posts: 2951
Joined: Wed Apr 05, 2000 9:08 am

[Tool] GibbedTools - TDX Texture converter

Post by Trent »

HEX1GON wrote:When converting an iOS TDX it causes it to crash :(
Yeah iOS uses a completely different compression method. I've tried to implement support for it but haven't managed to get it working. I ended up just using Noesis for batch exporting iOS TDX files. Grab it from here: http://oasis.xentax.com/index.php?content=downloads
a.k.a. Brent
User avatar
HEX1GON
turbo bastard
Posts: 261
Joined: Wed Apr 02, 2014 12:28 pm

[Tool] GibbedTools - TDX Texture converter

Post by HEX1GON »

Perfect! Thanks. Now if only the wheel positioning wasn't such a pain in the ass. :P
User avatar
Glumok
mechanic
Posts: 39
Joined: Fri Apr 11, 2014 1:38 am

[Tool] GibbedTools - TDX Texture converter

Post by Glumok »

EDIT: I've seen your post here, could it be related?

.

Hey Trent, it seems there is something wrong with the converter, with generated .png with Photoshop. My modified texture is always fucked up, so I did some tests, to see where the problem comes from. I tested with both vanilla texture by Stainless and modified texture by me.

My 3 tests :
- vanilla texture, NOT opened in Photoshop:

converted .tdx to .png with "Gibbed.Duels.TdxConvert.exe", then directly reconverted to .tdx with "CompressDXT5.bat" and the result is ok (texture is not fucked up in game).

- vanilla texture opened in Photoshop, saved as .png:

converted .tdx to .png, openend .png into Photoshop, directly saved as .png and the result is not ok (see pic 1 below).

- vanilla texture opened in Photoshop, converted to .tif:

converted .tdx to .png, opened .png into Photoshop, directly saved as .tif and the result is not ok (see pic 2 below).

So, in conclusion, I guess it has something to do with how Photoshop export .png (with or without compression). Any idea about how "CompressDXT5.bat" could deal with generated .png file with Photoshop?

PIC 1 - TDX > PNG (photoshop) > TDX:


PIC 2 - TDX > PNG > TIF (photoshop) > TDX:
User avatar
Trent
mindless
Posts: 2951
Joined: Wed Apr 05, 2000 9:08 am

[Tool] GibbedTools - TDX Texture converter

Post by Trent »

Try using the updated version: http://trent.incarnated.co.uk/downloads/GibbedTools.zip

I have literally no idea why it's doing that as I've extracted, edited and recompiled numerous textures without a single problem. The TIF isn't working because TIF is not a supported format. Can you post the actual texture? Original, edited and converted back from TDX after you ran it through CompressDXT5.bat?
a.k.a. Brent
User avatar
Glumok
mechanic
Posts: 39
Joined: Fri Apr 11, 2014 1:38 am

[Tool] GibbedTools - TDX Texture converter

Post by Glumok »

Well, I did test with .tif because it keeps transparency too and it seems to be converted with DXT5 compression (the texture is about the whole car, not only the interior).

I give a try to the new version of your tool and will post my result here! :)

EDIT: you can't drag and drop the .png onto "CompressDXT5.bat" with the new version? It used to work before.

I edited the "CompressDXT5.bat" by replacing "%~dp0\Gibbed.Duels.TdxConvert.exe --d5 "%1"" with the old "Gibbed.Duels.TdxConvert.exe --d5 %1" and drag and drop works again, I get a .dxt output, but "CompressDXT5.bat" doesn't quit...
User avatar
Trent
mindless
Posts: 2951
Joined: Wed Apr 05, 2000 9:08 am

[Tool] GibbedTools - TDX Texture converter

Post by Trent »

Glumok wrote:Well, I did test with .tif because it keeps transparency too and it seems to be converted with DXT5 compression (the texture is about the whole car, not only the interior).

I give a try to the new version of your tool and will post my result here! :)


EDIT: you can't drag and drop the .png onto "CompressDXT5.bat" with the new version? It used to work before.

PNGs keep their transparency too. The car's body work material uses that transparency for shininess and reflectivity though, not actual transparency.

You should have no problems dragging a png onto the CompressDXT5.bat in this version either. I have just uploaded another version as it seems I left in a debug line which held the window open until you press a button so I'd advise grabbing it again.

Edit: Yes the difference in the BAT file is to allow it to compress the files to the folder their in instead of to the GibbedTools folder.
a.k.a. Brent
User avatar
HEX1GON
turbo bastard
Posts: 261
Joined: Wed Apr 02, 2014 12:28 pm

[Tool] GibbedTools - TDX Texture converter

Post by HEX1GON »

I have no issues either and I've even made a skin recently which still keeps transparency.

Make a shortcut and add this to the end
--d5 FILENAME.png

I tried making a bat but it just wouldn't work, probably lack of cmdline skills but I haven't had issues ever with this method.
User avatar
Glumok
mechanic
Posts: 39
Joined: Fri Apr 11, 2014 1:38 am

[Tool] GibbedTools - TDX Texture converter

Post by Glumok »

Yes I was already aware about transparency with .png and the effect of it in game. ;)

Is the latest latest version here http://trent.incarnated.co.uk/downloads/GibbedTools.rar ?
User avatar
Trent
mindless
Posts: 2951
Joined: Wed Apr 05, 2000 9:08 am

[Tool] GibbedTools - TDX Texture converter

Post by Trent »

Glumok wrote:Yes I was already aware about transparency with .png and the effect of it in game. ;)

Is the latest latest version here http://trent.incarnated.co.uk/downloads/GibbedTools.rar ?
No it's http://trent.incarnated.co.uk/downloads/GibbedTools.zip

I just edited my sig to replace the old version, forgot it was in there!
a.k.a. Brent
User avatar
Glumok
mechanic
Posts: 39
Joined: Fri Apr 11, 2014 1:38 am

[Tool] GibbedTools - TDX Texture converter

Post by Glumok »

Ok, got the good latest version :)

Unfortunately, I still can't drag-and-drop .png onto "CompressDXT5.bat", as it quits as soon as I drop the file on it. I know it should be possible using command line but drag-and-drop is so much user friendly!

Hex1gon, I don't get what shortcut I must create with --d5 FILENAME.png? Make a shortcut to "CompressDXT5.bat" and in the proprieties add --d5 FILENAME.png (where "FILENAME.png" is the name of my texture?)

Thanks in advance, modding texture is fun! :D
User avatar
Trent
mindless
Posts: 2951
Joined: Wed Apr 05, 2000 9:08 am

[Tool] GibbedTools - TDX Texture converter

Post by Trent »

what directories are the GribbedTools and the image in? I think that may happen if the path is way too long, the new bat effectively adds the full path of GibbedTools to it before calling to make sure it's running in the correct place.

You could try opening Command Prompt, navigating to the GibbedTools directory and running:

Gibbed.Duels.TdxConvert.exe --d5 "path\to\your\image.png"

Where the path\to\your\image.png is the path to your image and the filename ;)
a.k.a. Brent
User avatar
Glumok
mechanic
Posts: 39
Joined: Fri Apr 11, 2014 1:38 am

[Tool] GibbedTools - TDX Texture converter

Post by Glumok »

I think I know what the problem was: I had renamed "GibbedTools" folder (by adding a short description in the folder name, to remember what this software is for) :) Used to not cause any problem with the previous release.

Drag-and-drop is working well, but I still get the same result once in game... :/



As noted on the picture, I wonder if it could be related to opacity of the texture. For all the outside paint-job of the car, I put opacity at 100%, everywhere else (including part of the texture for the inside of the car) it uses the vanilla transparency (somewhere 10% opacity?)

Excuse me being stupid but, drag-and-drop .png onto "CompressDXT5.bat" or using Command Prompt with Gibbed.Duels.TdxConvert.exe --d5 "path\image.png" doesn't give the same result? I didn't try with Command Prompt command.

If you want to look at my current modified texture, here is a link to download it: http://we.tl/eifp0biVsf
User avatar
Trent
mindless
Posts: 2951
Joined: Wed Apr 05, 2000 9:08 am

[Tool] GibbedTools - TDX Texture converter

Post by Trent »

Glumok wrote:
Excuse me being stupid but, drag-and-drop .png onto "CompressDXT5.bat" or using Command Prompt with Gibbed.Duels.TdxConvert.exe --d5 "path\image.png" doesn't give the same result? I didn't try with Command Prompt command.
They should give exactly the same results.

If the inside is the same texture as the outside then I'm baffled, it can't be the tool as either the whole texture would be screwed or none of it would. I do know that if opacity is too low, like 0%, then Photoshop does not save the pixel colour. If you want to package up your pngs and TDX files and send them over to me I'll take a look tomorrow and see if I can figure out what's going on.
a.k.a. Brent
User avatar
Glumok
mechanic
Posts: 39
Joined: Fri Apr 11, 2014 1:38 am

[Tool] GibbedTools - TDX Texture converter

Post by Glumok »

It would be very kind of you, Trent!

As posted in my previous post, here is a link to download my modified .png texture (with transparency from the vanilla texture): http://we.tl/eifp0biVsf

Also, the link to download the current .dxt file generated from my .png: http://we.tl/ov0gfUvGem

EDIT: I did some other tests (this time with no transparency at all, texture opacity is 100%), here are the results: (TEST01 are made using "CompressDXT5.bat" for generating Mipmaps. TEST02 are made using "CompressDXT5NoMip.bat" for no Mipmaps)



So, my guess is it could have something to do with generated mipmaps. What do you think?
User avatar
HEX1GON
turbo bastard
Posts: 261
Joined: Wed Apr 02, 2014 12:28 pm

[Tool] GibbedTools - TDX Texture converter

Post by HEX1GON »

On the topic of image quality, I also noticed with reflections that if it's set to very high the cars are extremely bright. I was testing on CFC and it turned out like this with high settings:



There's a major leap in HIGH and VERY HIGH... well to me at least. It's odd that you're getting blurry car textures on low though I don't get that at all with my skins :\
User avatar
Glumok
mechanic
Posts: 39
Joined: Fri Apr 11, 2014 1:38 am

[Tool] GibbedTools - TDX Texture converter

Post by Glumok »

HEX1GON wrote:It's odd that you're getting blurry car textures on low though I don't get that at all with my skins :\
Do you export them with or without mipmaps? Without them, the texture will be always at full resolution, therefore not blurry (but obviously without the advantages of mipmaps). On a side note, black Flat Cat looks sexy!
User avatar
dvine
hit n run
Posts: 222
Joined: Thu Mar 29, 2012 2:00 am

[Tool] GibbedTools - TDX Texture converter

Post by dvine »

HEX1GON wrote:
Holy Shit! When did this happen? This should be the official fatcat! Not going to lie...
User avatar
FatCat
mindless
Posts: 2643
Joined: Mon Jan 30, 2012 5:16 am

[Tool] GibbedTools - TDX Texture converter

Post by FatCat »

HEX1GON wrote:
It's gorgeous, you should also have the wheels be golden too. :D
User avatar
HEX1GON
turbo bastard
Posts: 261
Joined: Wed Apr 02, 2014 12:28 pm

[Tool] GibbedTools - TDX Texture converter

Post by HEX1GON »

Glumok wrote:
Do you export them with or without mipmaps? Without them, the texture will be always at full resolution, therefore not blurry (but obviously without the advantages of mipmaps). On a side note, black Flat Cat looks sexy!
Ahhh that must be why then. I haven't really touched skins much other than converting to PNG then back to TDX without compression. I somewhat noticed with 'nilla skins they are not as blurry as your screenshots :|

Sorry to high jack your thread with the FC :<

dvine wrote:
Holy Shit! When did this happen? This should be the official fatcat! Not going to lie...
Hehe, thanks for that. I made the skin last night, got a little bored :P I might finish it up soon and release it :) took a while to get the damn gold right as the chrome on the inside of the fins and bumpers are "clouded" and look like shit on low reflection quality. Reason why I didn't release it at all at the current state.

FatCat wrote:
It's gorgeous, you should also have the wheels be golden too. :D
I was thinking about that too, Otis like his bling after all :P
User avatar
Trent
mindless
Posts: 2951
Joined: Wed Apr 05, 2000 9:08 am

[Tool] GibbedTools - TDX Texture converter

Post by Trent »

Glumok wrote:EDIT: I did some other tests (this time with no transparency at all, texture opacity is 100%), here are the results: (TEST01 are made using "CompressDXT5.bat" for generating Mipmaps. TEST02 are made using "CompressDXT5NoMip.bat" for no Mipmaps)

So, my guess is it could have something to do with generated mipmaps. What do you think?

It's not a mipmap problem. When compressing C:R's textures you should ALWAYS use mipmaps. Mipmaps are what allow the texture quality setting to work, so without them then everyone will always load the full resolution texture no matter what the settings, in this case the 4096 x 4096 resolution, which would kill the performance for people with load end cards. I left the no-mipmap bats for people who want to edit the C1 textures or make low res textures themselves.

The problem was because you somehow managed to mangle the texture. The top quarter of the texture looks empty but that's where the cockpit textures are. Removing the transparency from the original version and your version reveals this:


I copied the cockpit from the original texture onto your texture and it worked perfectly (excuse the Depth Of Field blur):


The fixed PNG is uploaded at: http://trent.incarnated.co.uk/Eagle_paint_d_hex_fixed.png

When working with the car textures in Photoshop I would recommend the first thing you do the following steps:

1) go to Layer->Layer Mask->From Transparency

2) Go to the Channels tab

3) Make the new Mask channel visible, select it and hide the RGB channels

4) Select all and copy

5) Show the RGB channels again, hide the Mask channel and make sure the RGB channels are selected.

6) Paste in a new layer containing the Mask data and hide the layer.

7) Go back to the mask channel and fill it in white

Now you have a document set up where you can see the whole of the texture but still have the transparency information safe. I assume you already save your working document as a PSD but if you don't then I would recommend it. When you want to save it as a PNG again you simply copy the contents of the layer you made and paste it back into the mask channel. If you have multiple layers you will need to merge them down to the base layer and keep the masking information when PS asks you.
a.k.a. Brent
User avatar
FatCat
mindless
Posts: 2643
Joined: Mon Jan 30, 2012 5:16 am

[Tool] GibbedTools - TDX Texture converter

Post by FatCat »

Woah, is that some type of carmageddon chat? I wanna come too! :D
User avatar
Trent
mindless
Posts: 2951
Joined: Wed Apr 05, 2000 9:08 am

[Tool] GibbedTools - TDX Texture converter

Post by Trent »

Yeah it's #carmageddon on the slashnet irc server. There's a link in Errol's sig.
a.k.a. Brent
User avatar
Glumok
mechanic
Posts: 39
Joined: Fri Apr 11, 2014 1:38 am

[Tool] GibbedTools - TDX Texture converter

Post by Glumok »

Damn, Trent, you're right! Thanks for the Alpha Channel trick, very useful on this one. I would never have thought it could be related to that (well, I'm working everyday with Photoshop since only the past 15 years...). I've checked my PSD, I can't get what went wrong in the process, but will find!

EDIT: after a long battle I thought I was going to lose, I've finaly discovered what was wrong: it was a mix of Preferences in Photoshop and the way I made my PNG. I have to first flat the entire image, then switch it to layer, and only then add the transparency. If I add the transparency on my grouped layers, then switch it to layer and export, artifacts fucks all up my render. Pardon my French but, putain de bordel sa mère la truie !

Anyway:
User avatar
Toshiba-3
アルカリ (単3形)
Posts: 5227
Joined: Sun Jun 08, 2003 12:14 am
Location: Bleak City

[Tool] GibbedTools - TDX Texture converter

Post by Toshiba-3 »

Sa grosse putain d'mère... au moins maintenant ça marche :B
Image / carmageddon add-ons at road reaction
User avatar
Espyo
road raged psycho
Posts: 1287
Joined: Sat May 28, 2011 10:43 am

[Tool] GibbedTools - TDX Texture converter

Post by Espyo »

Is it bad that I only understood the swears?

...Is it bad that I assumed that they were swears?
User avatar
Glumok
mechanic
Posts: 39
Joined: Fri Apr 11, 2014 1:38 am

[Tool] GibbedTools - TDX Texture converter

Post by Glumok »

Well assumed, Espyo. :)
User avatar
Eviron
hit n run
Posts: 108
Joined: Wed Dec 11, 2013 3:37 pm

[Tool] GibbedTools - TDX Texture converter

Post by Eviron »

I've just started fiddling around with this great tool. The previous version didn't convert the png-files back to .tdx for me but with the newest version it's now working. :) Just did some simple stuff, I think there are other people around that will and already have done impressive things with it I won't provide due to my lack of patience with modding. ^^

Blue Caddy + C1 Artwork Billboard


Blue Eagle


Anyone know what causes the strange pink reflection here?
User avatar
KakkaHousu
speed freak
Posts: 566
Joined: Fri Nov 15, 2013 5:53 pm

[Tool] GibbedTools - TDX Texture converter

Post by KakkaHousu »

Anyone know what causes the strange pink reflection here?

Do you decompiled enviroment setup.lol with Trent´s decompiler? That causes me weird pink/purple reflections & shadows.
User avatar
Errol
Toxic Ranger
Posts: 1160
Joined: Wed Apr 05, 2000 12:16 pm
Location: Sunny Wales

[Tool] GibbedTools - TDX Texture converter

Post by Errol »

KakkaHousu wrote:Do you decompiled enviroment setup.lol with Trent´s decompiler? That causes me weird pink/purple reflections & shadows.
Interesting. I'll look into that.
User avatar
Eviron
hit n run
Posts: 108
Joined: Wed Dec 11, 2013 3:37 pm

[Tool] GibbedTools - TDX Texture converter

Post by Eviron »

KakkaHousu wrote:Do you decompiled enviroment setup.lol with Trent´s decompiler? That causes me weird pink/purple reflections & shadows.

Nope, haven't touched anything besides tdx-files yet. Just changed the color to blue, added some RGB-noise and compiled it back. And it's just like that on the modded car, all other reflections, shadows etc. are still as they suppose to be.
User avatar
Trent
mindless
Posts: 2951
Joined: Wed Apr 05, 2000 9:08 am

[Tool] GibbedTools - TDX Texture converter

Post by Trent »

Epic necroposting bump for the awesome.

As AlexTSK helped me discover and mentioned in his thread, normal maps were not being compressed with the correct method using GibbedTools so they were a bit buggy in game. I had thought my BC5Unorm compression code was fucked in the ear and needed a massive amount of debugging, but it turns out the compression code was fine it just wasn't hooked into GibbedTool's main code correctly. I've got it fixed now so I'll try to get a build released asap. Just thought you guys would like to know :)
a.k.a. Brent
User avatar
AlexTSK
mindless
Posts: 2859
Joined: Sun Dec 18, 2011 1:12 pm
Location: South Africa

[Tool] GibbedTools - TDX Texture converter

Post by AlexTSK »

Fantastic news Trent, really really looking forward to it :) thanks very much for looking into it!