Important information: this site is currently scheduled to go offline indefinitely by end of the year.

.tex files from unity.bms

The Original Forum. Game archives, full of resources. How to open them? Get help here.
Sigil
ultra-n00b
Posts: 5
Joined: Tue Jul 07, 2015 9:21 pm
Been thanked: 5 times

.tex files from unity.bms

Post by Sigil »

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
You do not have the required permissions to view the files attached to this post.
barti
veteran
Posts: 148
Joined: Sun Apr 01, 2012 12:44 pm
Has thanked: 51 times
Been thanked: 102 times

Re: .tex files from unity.bms

Post by barti »

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: Select all

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
Sigil
ultra-n00b
Posts: 5
Joined: Tue Jul 07, 2015 9:21 pm
Been thanked: 5 times

Re: .tex files from unity.bms

Post by Sigil »

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.
Sigil
ultra-n00b
Posts: 5
Joined: Tue Jul 07, 2015 9:21 pm
Been thanked: 5 times

Re: .tex files from unity.bms

Post by Sigil »

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: 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 = 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.
Sigil
ultra-n00b
Posts: 5
Joined: Tue Jul 07, 2015 9:21 pm
Been thanked: 5 times

Re: .tex files from unity.bms

Post by Sigil »

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.
Sigil
ultra-n00b
Posts: 5
Joined: Tue Jul 07, 2015 9:21 pm
Been thanked: 5 times

Re: .tex files from unity.bms

Post by Sigil »

A 0x1 flag at 0x10 and/or 0x28 indicates the presence of mipmaps. I updated the script to account for this.
barti
veteran
Posts: 148
Joined: Sun Apr 01, 2012 12:44 pm
Has thanked: 51 times
Been thanked: 102 times

Re: .tex files from unity.bms

Post by barti »

Cool to see that you got it working.
adabada
ultra-n00b
Posts: 7
Joined: Mon Oct 12, 2015 1:16 am
Has thanked: 4 times

Re: .tex files from unity.bms

Post by adabada »

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: Select all

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: Select all

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: Select all

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?
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4288
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1150 times
Been thanked: 2243 times

Re: .tex files from unity.bms

Post by shakotay2 »

adabada wrote:I have no idea what this is... R8G8B8? (first 56 bytes):

Code: Select all

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):
button-arrow-base_type4.JPG
(the "noise" is from the bmp to jpg conversion)
You do not have the required permissions to view the files attached to this post.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
adabada
ultra-n00b
Posts: 7
Joined: Mon Oct 12, 2015 1:16 am
Has thanked: 4 times

Re: .tex files from unity.bms

Post by adabada »

Hello shakotay2, thank for the help!

Here goes some samples: https://mega.nz/#!oQBEnJrY!BvyOV9SiKuph ... _YzgvGTRjo
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4288
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1150 times
Been thanked: 2243 times

Re: .tex files from unity.bms

Post by shakotay2 »

that's my nearest hit for your "R8G8B8":
test2_2.JPG
You do not have the required permissions to view the files attached to this post.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
adabada
ultra-n00b
Posts: 7
Joined: Mon Oct 12, 2015 1:16 am
Has thanked: 4 times

Re: .tex files from unity.bms

Post by adabada »

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:
Capture.PNG
And here is the DDS header for that image:

Code: Select all

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
You do not have the required permissions to view the files attached to this post.
adabada
ultra-n00b
Posts: 7
Joined: Mon Oct 12, 2015 1:16 am
Has thanked: 4 times

Re: .tex files from unity.bms

Post by adabada »

anyone?
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4288
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1150 times
Been thanked: 2243 times

Re: .tex files from unity.bms

Post by shakotay2 »

anyone for what? Didn't Unity Asset Explorer solve your problem?
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
adabada
ultra-n00b
Posts: 7
Joined: Mon Oct 12, 2015 1:16 am
Has thanked: 4 times

Re: .tex files from unity.bms

Post by adabada »

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:
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.
Post Reply