Page 2 of 3

Re: .tex files from unity.bms

Posted: Fri Oct 16, 2015 6:10 pm
by shakotay2
you're not to clear with your posts - you wrote
When running your script, DXT5 .tex files convert successfully to dds
so DXT5 is solved, isn't it? (should not be too hard to add creating of a DXT5 header to Sigil's script - assumed what this script retrieves correct height&width from the tex files; didn't check that).

For the R8G8B8 (type 3) I used irfanview with the tga file created by barti's script like such:
R8G8B8.JPG
So for this type "only" a palette problem remains but I'm too busy to deal with such.
edit: ok, stupid me forgot to switch back to 'RGB' in 'options for 24 and 32 BPP'
but not sure whether it's a palette problem or a matter of saturation.

Guess you're on your own to transform these "results" into a working script.
(except barti will sweep in again. :wink: )

Re: .tex files from unity.bms

Posted: Fri Oct 16, 2015 8:31 pm
by adabada
shakotay2 wrote:you're not to clear with your posts - you wrote
When running your script, DXT5 .tex files convert successfully to dds
so DXT5 is solved, isn't it? (should not be too hard to add creating of a DXT5 header to Sigil's script - assumed what this script retrieves correct height&width from the tex files; didn't check that).
My original post said I was able to use the script to convert DXT5 .tex files into dds, but had issue with DXT1 and R8G8B8. I apologise if that was not clear enough.

Yes, DXT5 is solved, DXT1 and R8G8B8 are the problem. The script does indeed get the correct height, width and type from the tex files, but because I can't find documentation on the structure of .tex files I don't know what else I need to convert DXT1 and R8G8B8 .text files to dds.

Re: .tex files from unity.bms

Posted: Fri Oct 16, 2015 11:51 pm
by adabada
OK, DXT1 and DXT5 now are working. All that is left is this weird R8G8B8.

Re: .tex files from unity.bms

Posted: Sat Oct 17, 2015 11:11 pm
by shakotay2
This is a working conversion chain for R8G8B8.tex (type 3):
(image width/height: 0x0000: 2A0300002A030000 -> 810 x 810)
  • delete 56 bytes header from tex file
  • load it as raw file into irfanview and save it as tga for example
  • use TheCompressonator to convert the tga to whatever DXT format you wish
This is even quicker:
  • rename R8G8B8.tex to R8G8B8.tex.data
  • load it as "Raw image data" into gimp.
  • set the offset to 56
  • export from gimp as uncompressed dds
If you want to do this by script you need to dig into pixelformats.
With an 8x8 red pixels square (8x8x3=192=0xC0 bytes= 64x24 bits) it looks like this:
R8G8B8rawToDDS.JPG
(red.dds: uncompressed)

The hurdle may be to convert the R8G8B8.tex into a plain 24 bit file as the red.raw above. -> solved

There's a good chance to get gimp's Raw image data format specs (should be the same as for R8G8B8.tex without header).

btw: the export from gimp as uncompressed dds gives the same result as with Unity Asset Explorer - only these 15 bytes differ:
8: 0F 07
14: 7E 00
15: 09 00
1C: 01 00
20: 47 00 //G
21: 49 00 //I
22:4D 00 //M
23: 50 00 //P
24: 2D 00 //-
25: 44 00 //D
26: 44 00 //D
27: 53 00 //S
28: 01 00
29: 02 00
2A: 02 00

Then I realized that you simply have to reverse the color bytes such like this: 9C854A A38741 -> 4A859C 4187A3
so here, finally, the changed script for type 3 only. It's a mix of Sigil's and barti's codes:
For other .tex than the one we handled here check for the DDS header since mine is not reliable :cry:

Code: Select all

# Unity .tex file to .dds
#
# script for QuickBMS http://quickbms.aluigi.org

get NAME basename
string NAME += ".dds"

get WIDTH long
get HEIGHT long
get IMGSIZE long
get TYPE long
get FLAGS long
goto 0x38

if TYPE = 3

xmath PIXELS "IMGSIZE / 3"
log MEMORY_FILE 0 1

xmath PITCH "WIDTH * HEIGHT"
set DDSFLAGS long 0x8100f
set MIPMAPS long 0

if FLAGS & 0x1
    math DDSFLAGS += 0x20000
    if WIDTH > HEIGHT
        for i = WIDTH > 0
            math MIPMAPS += 1
        next i / 2
    else
        for i = HEIGHT > 0
            math MIPMAPS += 1
        next i / 2
    endif
endif

#DDS Header
put 0x20534444 long MEMORY_FILE
put 124 long MEMORY_FILE
put 0xa1007 long MEMORY_FILE
put HEIGHT long MEMORY_FILE
put WIDTH long MEMORY_FILE
put PITCH long MEMORY_FILE
put 0 long MEMORY_FILE
put MIPMAPS long MEMORY_FILE
for i = 0 < 11
    put 0 long MEMORY_FILE
next i

#Pixel format struct
put 32 long MEMORY_FILE
put 0x40 long MEMORY_FILE
put 0 long MEMORY_FILE
put 24 long MEMORY_FILE

put 16711680 long MEMORY_FILE
put 65280 long MEMORY_FILE
put 255 long MEMORY_FILE
put 0 long MEMORY_FILE

#DDS Header cont.
put 0x001000 long MEMORY_FILE
put 0 long MEMORY_FILE
put 0 long MEMORY_FILE
put 0 long MEMORY_FILE
put 0 long MEMORY_FILE

for i = 0 < PIXELS
    get C1 byte
    get C2 byte
    get C3 byte
    put C3 byte MEMORY_FILE
    put C2 byte MEMORY_FILE
    put C1 byte MEMORY_FILE
next i

get SIZE asize MEMORY_FILE
log NAME 0 SIZE MEMORY_FILE

endif

Re: .tex files from unity.bms

Posted: Tue Dec 01, 2015 4:46 pm
by andeliseev
can you help with convert this file? i think its dxt1. but it simple dont work
https://www.dropbox.com/s/eegk4xxuvfqykjs/11.data?dl=0

Re: .tex files from unity.bms

Posted: Tue Dec 01, 2015 11:21 pm
by shakotay2
You guys - some bytes have changed and you are lost - aren't you? :)

This is type 0x24.
Cut the first 20 bytes from 11.data.
Change Sigil's script (for type 0x0C) like such for type 0x24:

Code: Select all

get WIDTH long
get HEIGHT long
get IMGSIZE long
get TYPE long
goto 0x28
get FLAGS long
goto 0x38

if TYPE = 0x24

math PIXELS = IMGSIZE
This is the result:
11-data_.jpg
btw: 20 bytes is: 4 bytes string length (DW), 15 chars string, zero byte for termination
Will be different for other strings.

Re: .tex files from unity.bms

Posted: Sun Dec 13, 2015 2:32 pm
by Azurfan
I have problems with the DXT1 and DXT5 textures of Dreamfall Chapters, I got the dimensions working correctly but the rest is just a mess. The game uses Unity 5 since the last update, maybe that's part of the problem, I don't know.
http://s000.tinyupload.com/index.php?fi ... 4668502156

Can anyone here share more insight on what I should do next to get this sorted out?

Re: .tex files from unity.bms

Posted: Sun Dec 13, 2015 3:16 pm
by Acewell
TextureFinder reads your tex files as just dds with a custom header.
The eye is 512x512 dxt3 and the bark is 1024x1024 dxt1, both with mipmaps and shifted by 60.

Re: .tex files from unity.bms

Posted: Mon Dec 14, 2015 9:02 pm
by Azurfan
Thank you. :D

Re: .tex files from unity.bms

Posted: Tue Feb 09, 2016 5:51 pm
by blackfoxeye
I have a .tex file which I want to convert.
I have tried the bms scripts provided here but those scripts are unable to convert this tex file.
This is from a game, which made with Unity 5.

When I tried "TextureFinder" tool I got below image.
I have attached the tex file here.

Image

Can anybody please help, how to convert it correctly.

Re: .tex files from unity.bms

Posted: Wed Mar 30, 2016 5:44 am
by Acewell
Azurfan wrote:I have problems with the DXT1 and DXT5 textures of Dreamfall Chapters, I got the dimensions working correctly but the rest is just a mess. The game uses Unity 5 since the last update, maybe that's part of the problem, I don't know.
http://s000.tinyupload.com/index.php?fi ... 4668502156

Can anyone here share more insight on what I should do next to get this sorted out?
I made a Noesis plugin that opens your sample textures for fun :D
tex_DreamfallChapters_tex.zip

Re: .tex files from unity.bms

Posted: Thu Jul 21, 2016 7:45 pm
by Tosyk
playing around with tex files without any results. Guys please point me in the right direction with this files:

https://dl.dropboxusercontent.com/u/991 ... .36.tex.7z
https://dl.dropboxusercontent.com/u/991 ... .36.tex.7z

thanks in advanced.

Re: .tex files from unity.bms

Posted: Sat Jul 23, 2016 4:32 am
by dragonzh
Tosyk wrote:playing around with tex files without any results. Guys please point me in the right direction with this files:

https://dl.dropboxusercontent.com/u/991 ... .36.tex.7z
https://dl.dropboxusercontent.com/u/991 ... .36.tex.7z

thanks in advanced.
Try UnityEX he is on site ZoG
UnityEX ZoG
Only it is necessary to carry out the export of assets.
This is the format ktx, it is supported by console.
UnityEX export name.assets -t ktx

Re: .tex files from unity.bms

Posted: Sat Jul 23, 2016 4:26 pm
by Tosyk
dragonzh wrote:Try UnityEX he is on site ZoG
UnityEX ZoG
Only it is necessary to carry out the export of assets.
This is the format ktx, it is supported by console.
UnityEX export name.assets -t ktx
thanks, the tool works but I still can't open this ktx texture with PVRTexTool. I suppose they are encrypted or something. Can you take a look:
https://dl.dropboxusercontent.com/u/991 ... tex.ktx.7z

Re: .tex files from unity.bms

Posted: Sat Jul 23, 2016 8:56 pm
by dragonzh
Tosyk wrote:
dragonzh wrote:Try UnityEX he is on site ZoG
UnityEX ZoG
Only it is necessary to carry out the export of assets.
This is the format ktx, it is supported by console.
UnityEX export name.assets -t ktx
thanks, the tool works but I still can't open this ktx texture with PVRTexTool. I suppose they are encrypted or something. Can you take a look:
https://dl.dropboxusercontent.com/u/991 ... tex.ktx.7z
UnityEX 1.4.0