XeNTaX Forum Index
Forum MultiEx Commander Tools Tools Home
It is currently Mon Oct 23, 2017 9:44 pm

All times are UTC + 1 hour


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 32 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: .tex files from unity.bms
PostPosted: Tue Jul 07, 2015 11:40 pm 
Offline
ultra-n00b

Joined: Tue Jul 07, 2015 9:21 pm
Posts: 5
Has thanked: 0 time
Have thanks: 4 times
I'm trying to figure out how to open the .tex files that result from the extracting unity .assets files with the unity.bms QuickBMS script. Specifically I'd like to open the icons from the game 'Ori and the Blind Forest', though a generic conversion tool would be nice if there is such a thing.

I looked at the hex some and noticed these things:

0x0-0x7: 1024x1024? Seems a bit large for what this is, but then again it is a relative big icon in game and they might have wanted it to scale well on 4k monitors.
0x8: 0x155570 size of file - header size
0xC-0x33: ???
0x34: 0x155570 size of file - header size


Attachments:


You do not have the required permissions to view the files attached to this post. Register to gain access.



Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Wed Jul 08, 2015 10:05 am 
Offline
veteran

Joined: Sun Apr 01, 2012 12:44 pm
Posts: 148
Has thanked: 51 times
Have thanks: 94 times
I made this quickBMS script since I wanted to extract textures from a Unity 5 game once (and there aren't any working Unity 5 texture extractors that I know of), but it's by no means universal. Still worth at least a try.

Code:
get NAME basename
string NAME += ".tga"

get WIDTH long
get HEIGHT long
get IMGSIZE long
goto 56

xmath PIXELS "IMGSIZE / 4"
math IMGSIZE += 18
log MEMORY_FILE 0 IMGSIZE

put 131072 long MEMORY_FILE
put 0 long MEMORY_FILE
put 0 long MEMORY_FILE
put WIDTH short MEMORY_FILE
put HEIGHT short MEMORY_FILE
put 32 byte MEMORY_FILE
put 8 byte MEMORY_FILE

for i = 0 < PIXELS
    get COLOR long
    reverselong COLOR
    put COLOR long MEMORY_FILE
next i

get SIZE asize MEMORY_FILE
log NAME 0 SIZE MEMORY_FILE


Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Thu Jul 09, 2015 2:53 pm 
Offline
ultra-n00b

Joined: Tue Jul 07, 2015 9:21 pm
Posts: 5
Has thanked: 0 time
Have thanks: 4 times
That script didn't not work. These textures seem to be in DXT4 or DXT5 pixel format. I'll try using your script as an example to build a DDS header. I was toying around with doing so, but I'm new to this and didn't have a nice example of bms that just replaced the header, like yours does.


Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Thu Jul 09, 2015 4:22 pm 
Offline
ultra-n00b

Joined: Tue Jul 07, 2015 9:21 pm
Posts: 5
Has thanked: 0 time
Have thanks: 4 times
I have this script working for the 1024x1024 images. It needs a bit more math to calculate pitch and mip map levels based on the size of the image, both these numbers are currently hard coded for 1024x1024 and don't seem to show up in the tex file's header. I'd also like it if it had a check that the current .tex file is actually .dds and skip it if it isn't, which I think the 4th long in a .tex file is a type field.

Also, for some reason when I try to pre-allocate the memory file I get an error about being unable to read an address. That showed up just from changing "math IMGSIZE += 18" to "math IMGSIZE += 500".

Code:
# 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 = 0xC

math PIXELS = IMGSIZE
/* For some reason these two lines cause an error,
* skipping pre-allocation for now
*/
#math IMGSIZE += 500
#log MEMORY_FILE 0 IMGSIZE
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 0x4 long MEMORY_FILE
put 0x35545844 long MEMORY_FILE
put 0 long MEMORY_FILE
put 0 long MEMORY_FILE
put 0 long MEMORY_FILE
put 0 long MEMORY_FILE
put 0 long MEMORY_FILE

#DDS Header cont.
put 0x401008 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 COLOR byte
    put COLOR byte MEMORY_FILE
next i

get SIZE asize MEMORY_FILE
log NAME 0 SIZE MEMORY_FILE

endif


EDIT:
It now works with any size image.
Pitch = Width * Height, rather than the formula specified by MS...
For mip map count I did a little loop. Hackish, but it works, at least for most files. If someone knows a saner way to do this in BMS I'd be glad to know.
I also put a check for the tex's type.


Last edited by Sigil on Thu Jul 09, 2015 8:16 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Thu Jul 09, 2015 6:08 pm 
Offline
ultra-n00b

Joined: Tue Jul 07, 2015 9:21 pm
Posts: 5
Has thanked: 0 time
Have thanks: 4 times
Hmm... all the images are mirrored vertically. I didn't notice that on the couple images I was using to test while writing the script, because they didn't look wrong upside down. I feel like fixing that would require a LOT of work though, even though it'd be nice to get the whole process automated from start to finish.


Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Thu Jul 09, 2015 6:33 pm 
Offline
ultra-n00b

Joined: Tue Jul 07, 2015 9:21 pm
Posts: 5
Has thanked: 0 time
Have thanks: 4 times
A 0x1 flag at 0x10 and/or 0x28 indicates the presence of mipmaps. I updated the script to account for this.


Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Fri Jul 10, 2015 10:36 pm 
Offline
veteran

Joined: Sun Apr 01, 2012 12:44 pm
Posts: 148
Has thanked: 51 times
Have thanks: 94 times
Cool to see that you got it working.


Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Mon Oct 12, 2015 2:46 am 
Offline
ultra-n00b

Joined: Mon Oct 12, 2015 1:16 am
Posts: 7
Has thanked: 4 times
Have thanks: 0 time
Howdy!

Where did you get the .tex format specification? I'm having trouble converting a .tex file extracted using unity.bms and I think it's because of the differences between DXT5, DXT1, etc.

When running your script, DXT5 .tex files convert successfully to dds, but the script only works for .tex files of TYPE 0x0000000c, and I have some files that have a TYPE of 0x00000003.

So far I've tested it with 3 TYPEs of files:

DXT5 (first 56 bytes):
Code:
00 02 00 00 00 02 00 00 00 00 04 00 0C 00 00 00 00 00 01 00 01 00 00 00 02 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 00 00 04 00


DXT1 (first 56 bytes):
Code:
00 02 00 00 00 02 00 00 B8 AA 02 00 0A 00 00 00 01 00 01 00 01 00 00 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 B8 AA 02 00


I have no idea what this is... R8G8B8? (first 56 bytes):
Code:
2A 03 00 00 2A 03 00 00 AC 08 1E 00 03 00 00 00 00 00 01 00 01 00 00 00 02 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 AC 08 1E 00



Can you point me in the right direction on how to convert those types of .tex to dds?


Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Mon Oct 12, 2015 11:50 am 
Offline
M-M-M-Monster veteran
M-M-M-Monster veteran
User avatar

Joined: Fri Apr 20, 2012 9:24 am
Posts: 2154
Location: Nexus, searching for Jim Kirk
Has thanked: 424 times
Have thanks: 1097 times
adabada wrote:
I have no idea what this is... R8G8B8? (first 56 bytes):
Code:
2A 03 00 00 2A 03 00 00 AC 08 1E 00 03 00 00 00 00 00 01 00 01 00 00 00 02 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 AC 08 1E 00


Can you point me in the right direction on how to convert those types of .tex to dds?
if you uploaded a sample we maybe could tell...

btw: I successfully used barti's bms script on a type 4 file (plus some beautifying in texturefinder):

(the "noise" is from the bmp to jpg conversion)


Attachments:


You do not have the required permissions to view the files attached to this post. Register to gain access.


_________________
"you can't always get things served on a silver tray"
extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip

"We are Microsoft. You will be assimilated. Resistance is Futile."


Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Mon Oct 12, 2015 5:22 pm 
Offline
ultra-n00b

Joined: Mon Oct 12, 2015 1:16 am
Posts: 7
Has thanked: 4 times
Have thanks: 0 time
Hello shakotay2, thank for the help!

Here goes some samples: https://mega.nz/#!oQBEnJrY!BvyOV9SiKuphFZEKiUy_6kboLJT35kWhh_YzgvGTRjo


Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Mon Oct 12, 2015 8:32 pm 
Offline
M-M-M-Monster veteran
M-M-M-Monster veteran
User avatar

Joined: Fri Apr 20, 2012 9:24 am
Posts: 2154
Location: Nexus, searching for Jim Kirk
Has thanked: 424 times
Have thanks: 1097 times
that's my nearest hit for your "R8G8B8":


Attachments:


You do not have the required permissions to view the files attached to this post. Register to gain access.


_________________
"you can't always get things served on a silver tray"
extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip

"We are Microsoft. You will be assimilated. Resistance is Futile."


Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Mon Oct 12, 2015 11:04 pm 
Offline
ultra-n00b

Joined: Mon Oct 12, 2015 1:16 am
Posts: 7
Has thanked: 4 times
Have thanks: 0 time
Yeah, I got something similar to that as well when using the script, but Unity Asset Explorer by Haoose manages to convert it to dds. Here is the final image:


And here is the DDS header for that image:
Code:
44 44 53 20 7C 00 00 00 07 10 00 00 2A 03 00 00 2A 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 40 00 00 00 00 00 00 00 18 00 00 00 00 00 FF 00 00 FF 00 00 FF 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00


Here's a link to the dds generates with Unity Asset Explorer: https://mega.nz/#!0IBEmZaR!Bt27XlsYKGwq ... t4eotNtUZw


Attachments:


You do not have the required permissions to view the files attached to this post. Register to gain access.



Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Thu Oct 15, 2015 11:23 pm 
Offline
ultra-n00b

Joined: Mon Oct 12, 2015 1:16 am
Posts: 7
Has thanked: 4 times
Have thanks: 0 time
anyone?


Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Fri Oct 16, 2015 11:24 am 
Offline
M-M-M-Monster veteran
M-M-M-Monster veteran
User avatar

Joined: Fri Apr 20, 2012 9:24 am
Posts: 2154
Location: Nexus, searching for Jim Kirk
Has thanked: 424 times
Have thanks: 1097 times
anyone for what? Didn't Unity Asset Explorer solve your problem?

_________________
"you can't always get things served on a silver tray"
extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip

"We are Microsoft. You will be assimilated. Resistance is Futile."


Top
 Profile  
 
 Post subject: Re: .tex files from unity.bms
PostPosted: Fri Oct 16, 2015 4:14 pm 
Offline
ultra-n00b

Joined: Mon Oct 12, 2015 1:16 am
Posts: 7
Has thanked: 4 times
Have thanks: 0 time
Not really, I'm trying to modify the script to convert the other types. Even tho UAE can convert them, It still can't open asset files from Unity 5.x without issues.

This was my original request for help:
Quote:
Where did you get the .tex format specification? I'm having trouble converting a .tex file extracted using unity.bms and I think it's because of the differences between DXT5, DXT1, etc.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page 1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: Google [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group