1)Select a file texture from which you want to change and extract it with Gildor tools(Extractor)
I selected a file with Sub Zero texture - char_subzero_a.xxx
2)Select the texture file you want to edit from the extracted folder. The file extension must be .Texture2D
I chose this texture: char_subzero_a\Textures\SubZero_A1_Diff.Texture2D
Now we need to extract the body of the texture frome this file.
To do this we need to know the size of the header of Texture2D and the size of the texture.
NOTE: You can parse the file format and know the offset and size of the texture. But I did not analyze the format and used a stupid method.Textures in the format of the game have the same file size as the DXT5 textures.
So just create the texture with expected size in Photoshop and save it in DDS DXT5 with mipmaps. Compare the size of the resulting file with a Texture2d file.
When you pick the right texture size, the files will be almost the same size.
Attachment:
screen1.jpg [ 209.29 KiB | Viewed 13043 times ]
In my case, the texture size was 2048*2048(All character costumes textures that I saw was 2048*2048)
Now we know the size of the texture and can calculate the size of the texture body.
Texture body size in this format or in DXT5 is Width*Height.
2048*2048=4194304
Convert this value to hexadecimal system. This can be done with a windows calculator.
4194304 -> 0x400000
Convert the height and width. it is useful to us later.
2048 -> 0x800
3)Open the Texture2d file in hex editor. I use HxD, but it could be any hex editor.
I noticed that after each texture or mip level specified its size vertically and horizontally, 4 bytes each in the reverse order(Little Endian).
Select a block from the beginning of the file, lenght is 0x400000 from the previous step.
From the end of the selection are looking for a texture size in hex system, 4 bytes each in reverse order. In my case: 00080000 00080000
Select the bytes from the end of last selection to the size of the texture and look at the size of the new selection. This is the size of the header. In this case: 0x11B
Attachment:
screen2.jpg [ 3.57 MiB | Viewed 13043 times ]
Now go to offset 0x11B
Attachment:
screen3.jpg [ 70.16 KiB | Viewed 13043 times ]
Select 0x400000 bytes from this offset and copy to new file. This is the texture body.
Open the Header file from the archive which I have attached to the message.
Attachment:
Header.rar [132 Bytes]
Downloaded 462 times
This header is for the 2048*2048 texture. If your texture is a different size, you need to edit the bytes marked in the screenshot for your size obtained in step 2.
Attachment:
screen4.jpg [ 266.21 KiB | Viewed 13043 times ]
Insert the header before the body of the texture and save with .DDS extension.
Attachment:
screen5.jpg [ 731.35 KiB | Viewed 13043 times ]
4)Now we need to convert the texture into an editable format.
Download the source code frome here
http://directxtex.codeplex.com/And compile the texconv program.
Run the program with the following arguments.
texconv.exe -f R8G8B8A8_UNORM -ft DDS -px ed_ -m 1 filename.ddsWhere filename is the name of the texturefile.
As a result, you get a texture named "ed_filename.dds". It can be edited in Photoshop.
NOTE: The program can convert the texture, only if your video card supports DirectX 10 or 11. I'm not exactly sure which one of them.5)Now we can open the texture in Photoshop.
It looks weird. All we need to do is swap the red and blue channels.
Attachment:
Screen6.jpg [ 686.34 KiB | Viewed 13043 times ]
Now you can edit in Photoshop textures from the game.
How to insert them back, I will teach in the next tutorial.