PDA

View Full Version : Converting .Texture to .DDS



GrumpyOldMan
12-15-2006, 01:51
Hi All

Playing around with the files that came with mt_unit_xmls.rar (sorry can't find the download link again), converting the uncompressed .TEXTURE files to .DDS files is fairly simple. You just strip the first 48 bytes from the .TEXTURE file and save the result as .DDS file. So extracting the .TEXTURE information to a DDS is fairly simple. However finding out the information to put back into a TEXTURE file may be more difficult, but probably do-able.

For anybody else that wants to have a guess at the .TEXTURE header information, the values for the EN_Peasant_Padded_england.TEXTURE are :-

(by 32 words)
1
48
0
7562340
1237572
51208848
1235648
576
0
2084197989
3
1024(depth/width of texture)

My guess (and it's just that) would be that it would be pretty safe to use a silmilar header for a similar texture -ie cloth for cloth, mail for mail, etc. But when the unpacker comes out we'll know more :2thumbsup: .

Cheers

GrumpyOldMan

Epistolary Richard
12-16-2006, 01:44
Interesting info - maybe we're not too far away from adding a new texture to the game? :thumbsup:

I've added it to the researchwiki (https://forums.totalwar.org/vb/showthread.php?t=70886).

Casuir
12-16-2006, 20:57
I've been looking at the texture files in a hexeditor and comparing them, noticed some things. Between files of the same size and dxt type theres no change in the header, between files of the same size and different dxt types one byte changes, the 29th. This is 10 for DXT5 and 40 for DXT1. This applies to textures for units. Between textures for units ant those for other types of models, such as those in the attachment sets and new vegetations folder the 17th and 18th and 25th and 26th bytes change values.

My guess is that as the header is only changing between different types of models and dxt formats, it should be safe to strip out the header, edit the dds and reinsert the header and try it ingame. I've made an attempt to do this but I only have the demo and it doesnt seem to use unpacked files so it came to nowt. If anyone else wants to try it the file is here: http://rapidshare.com/files/7762805/test.rar.html
Unzip into the data folder, it should replace french chivalric or dismounted knights.

Casuir
12-16-2006, 21:25
Never mind, I got it to work, never read the bit about the command line :embarassed:
Screenies:
https://img186.imageshack.us/img186/5737/image1hg9.jpg (https://imageshack.us)
https://img174.imageshack.us/img174/3231/image3vc7.jpg (https://imageshack.us)

I probably should have done something a bit better looking but it works.

Casuir
12-17-2006, 12:15
Couple more tests, mounts buildings and banners:

https://img98.imageshack.us/img98/2666/gendarmecr7.jpg (https://imageshack.us)
https://img88.imageshack.us/img88/7811/kilroybz4.jpg (https://imageshack.us)
https://img80.imageshack.us/img80/1273/bannerstq9.jpg (https://imageshack.us)


I've only noticed one other byte changing between files, the 46th seems to change value depending on the size of the file, although I've noticed two files of different dimensions but same area having the same value. Likewise I've noticed two files of the same dxt type having different values for the 29th byte, 10 and 20. I havent noticed two different dxt formats using the same value though. The other two byte sequences dont seem to have any effect ingame if you change them to those used by another type of model. Other than that I havent noticed any other changes between the headers in different files than those 6 bytes.

Epistolary Richard
12-17-2006, 13:08
Apparently we weren't far away at all! This is great news - I'm going to have to try this out :thumbsup:

wilddog
12-17-2006, 13:51
Out of interest what hex editor software is available or do people recommend?

alpaca
12-17-2006, 14:00
I use Hex Workshop

Dave1984
12-17-2006, 14:51
I apologise if I appear stupid, but I do not have any experience with hex editors or understanding binary.
Using GrumpyOldMan's converter, opening the .dds in photoshop (with .dds plugin) the file opens as blank.

Opening the file with a hex editor (such as Hex Workshop) obviously displays the file in it's binary form (OK I'm striking out here, I don't know if that's what it's called) but it is not readable to the untrained eye.
So when you all talk of deleting this byte or that byte, and the 46th byte changing between files, what does it mean, and how can those of us without hex editor knowledge apply it to converting the files so that we can begin reskinning?

Thanks guys!

Throumbaris
12-17-2006, 15:03
That is totally A+ work there! Is there any chance of us seeing a converter?

Casuir
12-17-2006, 15:21
I dont use hex commander but the process with it should be similar. Make a copy of and open up the texture file you want to edit in your hex editor. Write down the numbers highlighted here:

https://img147.imageshack.us/img147/309/hextw4.th.jpg (https://img147.imageshack.us/my.php?image=hextw4.jpg)

Delete them then save and exit. Change the file extension from .texture to .dds. Open it up in your graphics program and make note of the format, ie DXT1 or DXT5 and no. of mipmaps. Do your editing and save the file with the same settings. Now open up the dds in your hex editor and insert the hex string you deleted at the start. Compare it with the original file to make sure its correct. Save, exit and rename the files so the new one is used by the model. Start your game with the --io.file_first switch and you should be able to see your changes ingame. Remember to delete the two files that cause the game to crash as well.

Dave1984
12-17-2006, 16:20
I dont use hex commander but the process with it should be similar. Make a copy of and open up the texture file you want to edit in your hex editor. Write down the numbers highlighted here:

https://img147.imageshack.us/img147/309/hextw4.th.jpg (https://img147.imageshack.us/my.php?image=hextw4.jpg)

Delete them then save and exit. Change the file extension from .texture to .dds. Open it up in your graphics program and make note of the format, ie DXT1 or DXT5 and no. of mipmaps. Do your editing and save the file with the same settings. Now open up the dds in your hex editor and insert the hex string you deleted at the start. Compare it with the original file to make sure its correct. Save, exit and rename the files so the new one is used by the model. Start your game with the --io.file_first switch and you should be able to see your changes ingame. Remember to delete the two files that cause the game to crash as well.


Thanks Casuir, that's much appreciated.

On opening the file in photoshop, it shows up fine but has replicated itself exactly on the right several times, each time progressively smaller. Is this normal?

Casuir
12-17-2006, 16:52
Those are mipmaps, they're smaller versions of the same texture the game engine uses when the model is further away to save memory. There should be a popup box when you open the files in photoshop which asks you if you want to load them:
https://img132.imageshack.us/img132/9127/mipmapsse2.jpg (https://imageshack.us)
Uncheck it, when you save the file there'll be a dialogue which asks you if you want to generate them, make 11 if its 1024*1024. It'll ask you the format to save it as well, if there was an alpha channel DXT5 if not DXT1.

Done some looking at the Normal maps, should be relatively simple to create some, just get the normal filter plugin for photoshop from nvidias website and apply it to your texture. By changing the scale to 6 in the settings dialog I got something which came very close to CA's own normal map for the texture I was using.

Theres an alpha channel in the normal map dds as well, this seems to be what controls the specular lighting. I deleted it from one of the textures and this was the result:
https://img142.imageshack.us/img142/5356/gendarme2ct3.th.jpg (https://img142.imageshack.us/my.php?image=gendarme2ct3.jpg)
Same texture as the one on the gendarmes above, no alpha in the normal map, no shiny bits.

Epistolary Richard
12-17-2006, 23:35
Okay, tried it out - totally worked.
https://img208.imageshack.us/img208/1445/sherwoodlrd9.jpg (https://imageshack.us)

Absolutely great. Just wanted to give a couple of reminders of things that Casuir already said but I forgot!

1) My photoshop defaulted to DXT3 - but use DXT5 for unit textures.

2) Don't use this with a mod folder (might have to redo the path to do that) instead use:
[io]
file_first = true
in the .cfg file or --io.file_first in the command line

3) Remember to delete the two files that cause the game to crash as well:
data\descr_geography_new.txt
data\descr_geography_new.db



BTW I'm using XVI32 as a hex editor, is there a quick way to paste the header back in? I had to retype it by hand :dizzy2:

Lovasìjász
12-18-2006, 02:06
I'll wait until someone makes a converter program, or CA throws us a bone..:coffeenews:

Myrddraal
12-18-2006, 05:04
Wow, nice find!

alpaca
12-18-2006, 17:18
If anybody has time to test a basic version of a converter tool, please send me a PM with your MSN address.

Casuir
12-18-2006, 17:24
BTW I'm using XVI32 as a hex editor, is there a quick way to paste the header back in? I had to retype it by hand :dizzy2:

Yeah there is, sorry didnt actually look for one till you asked. Use the Block <n> chars in the edit menu, enter 48 with decimal checked and the header will be highlighted. You can cut and paste the header now but if you use the clipboard for anything else (like photoshop) the string will be lost. Best way to do it would be open up the original and copy and paste the header from that.

hgtm
12-18-2006, 19:20
couple of questions:
1.I was trying to add some textures using adobe photoshop,but when I try to convert it to .DDS it doesen't work(it's not combatibile)
2.Does it works with 3DSmax???
3. when trying covert .DDS file to .texture file(for editing the texture) i can't set the numbers very good:
1
48
0
7562582
1237572
51208848
1233649
556
0
2084197939
3
1024
can you say how to correct it???
and 4:does it works with an other width(512)???
eg:
1
48
0
7562582
1237572
51208848
1233649
556
0
2084197939
3
512

Hybris
12-18-2006, 20:16
to be honest: im too lazy to do all the stuff with the hex commander. Does anyone code a program to speed this things up? me - and i guess the total war community too - is waiting for it.:yes:

kaya
12-18-2006, 20:17
hey guys i got all the tools you talk about but i just can't find the unit texture files where are the files for me to mod the unit texture, please someone help me

Casuir
12-18-2006, 20:50
data/unit_models/units/ after you unpack the files.

-hgtm, I'm not sure exactly what you're doing, if you follow the steps above it should work. You shouldnt be using 3dsmax at all, thats for 3d models not 3d textures.

Did a bit more testing and the two bytes which seem to relate to dxt type and file size dont have any effect ingame if you change them to different value. Given that the dxt type and file dimensions are in the dds portion of the file im guessing they're for reference only.

Lovasìjász
12-19-2006, 04:49
so.....how do you convert back to .texture ? or do I have to?

Epistolary Richard
12-19-2006, 09:53
Yes, you have to. It's a matter of reinserting the header in the hex editor and then saving it as a .texture file.

Dave1984
12-19-2006, 15:24
How does one find out what the dxt type of the file is in the first place?

LorDBulA
12-19-2006, 15:58
If you think that you have enough knowledge to create automated converter please send me a pm.
Taking whole research into one post with explained header (size + purpose + possible values) and samples Original Texture / Stript to dds / Changed Texture converted back to M2TW format.
I can create stand alone converter for you.
Please also add what other options will be useful for skinners.
I am not a skinner so your input will help make this tool easy in use for you.
I also hope you can help to test this.

iamnew
12-20-2006, 02:55
if somebody give me information how can convert .dds to .texture i will create tools for it

i already created .texture to .dds converter but i haven't permitions to post url here

iamnew
12-20-2006, 03:02
you can download .texture to .dds converter

http://www.twcenter.net/forums/downloads.php?do=file&id=961

Lovasìjász
12-20-2006, 03:17
you can download .texture to .dds converter

http://www.twcenter.net/forums/downloads.php?do=file&id=961


You kick ass! ~:cheers: :jumping:

Do I have to convert them back to be used by the game or can I just use the .dds files?

edit: nevermind, I do have to, but is there a tool for it, too?

regardless, i'm satisfied now just to view comfortably all the texture files..:-)


edit: '/4 hrs later/ wow, people this much interested in this? or this sub forum is dead as a doornail?

Monkwarrior
12-20-2006, 09:56
Thanks a lot, iamnew. :2thumbsup:

Please, keep us informed if you are able to build a tool to convert .dds to .texture.

Thanks again. :beam:

alpaca
12-20-2006, 16:04
Well just to let you know, I wrote an apparently working texture/dds converter (both ways), thanks to Casuir's testing. However there's one file that can't be converted yet (I guess using an old dds version or something), but I'm not in the mood today to work on it and release it :P
Will do that tomorrow.

Lovasìjász
12-21-2006, 03:15
Well just to let you know, I wrote an apparently working texture/dds converter (both ways), thanks to Casuir's testing. However there's one file that can't be converted yet (I guess using an old dds version or something), but I'm not in the mood today to work on it and release it :P
Will do that tomorrow.

you're trying to keep us on the edge??

Anyway, don't let that one file hold you up, (which file is it?) there are thousands of .texture files in the game, we can live without that one file. :jumping:

alpaca
12-21-2006, 14:05
Well they're actually a few more as Casuir pointed out to me today, it's basically a problem with another dds format (gotta check it out). The main problem wasn't the file but that the script doesn't have any output which always confuses people ;)

methoz
12-26-2006, 00:49
can you help me? how to make trans.texture? (i know how to make dds and expotr to texture) but.. trans ?

Eufarius
05-16-2007, 03:00
how do you add skins in milkshape 1.7 to the model you have? ( NOOB question need a LOT of help):dizzy2: :help: :wall:

Vuk
05-18-2007, 18:53
Is there a converter to convert it from .dds to .texture?

Thanks in advance baby doll hunny poos!

Vuk

self.Pythong
12-26-2008, 19:28
I'm currently creating a software tool to convert a .texture file into a .dds file type. I know nothing about the game, nor have I ever played it. I just stumbled into this forum on a Google query. Conversion between the two files are as simple as creating a hello, world application. Please mind the two newbie programmers above, who've failed to create a simple tool to covert a dds file into a texture file; vice versa. I will post the download link to my tool shortly after I upload it to a file hosting web server.

- bgfx.net { my website }
- epiccoders@hotmail.com { my msn }

artinjulio
01-10-2009, 17:57
how convert DDS file modified in photoshop back to .TEXTURE?

Makanyane
01-10-2009, 22:51
try the links from this thread I - Alpaca's converter works both ways....

https://forums.totalwar.org/vb/showthread.php?t=75726