convert .tex to dds

Textures, recreate headers, conversions, algorithms and parsing of image files
adabada
Posts: 3
Joined: Thu Oct 15, 2015 10:20 pm

convert .tex to dds

Post by adabada »

Howdy folks,

I'm trying to convert .tex files extracted with quick bms (unity.bms script) to dds, but I'm having some trouble finding the .tex specification in order to adjust the conversion script.

Here is the conversion script I'm using, taken from here http://forum.xentax.com/viewtopic.php?f ... 0&p=111140:

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


This script works fine (the alpha mask not so much) for DXT5 files, but not for others. Unity Asset Extractor by Haoose can successfully convert all these .tex files to dds without problem.

Some sample files in case anyone wants to run tests: https://mega.nz/#!oQBEnJrY!BvyOV9SiKuph ... _YzgvGTRjo

Could anyone point me in the right direction as to where I can find more information on the .tex spec? I'm trying to adapt this script to work with DXT1 and "R8G8B8" formats.

Thanks!
adabada
Posts: 3
Joined: Thu Oct 15, 2015 10:20 pm

Re: convert .tex to dds

Post by adabada »

anyone?