Tomb Raider Legend - .raw

Textures, recreate headers, conversions, algorithms and parsing of image files
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Tomb Raider Legend - .raw

Post by AnonBaiter »

So I tried to write this script:

Code: Select all

endian big
get RAW_SIZE asize
idstring "\x21WAR"
get OFFSET long
get SIZE long
get ZERO threebyte
get DUMMY2 byte
get ZERO2 threebyte
get TYPE byte
get HEIGHT1 short
get HEIGHT2 short
get WIDTH1 short
get WIDTH2 short
get DIMENSIONS long
get BITS long
get DUMMY8 long
get DUMMY9 long
get DUMMY10 long
get DUMMY11 long
get DUMMY12 long
get DUMMY13 long
get DUMMY14 long
get DUMMY15 long
savepos OFFSET
goto 0x70
get NEXT_OFF longlong

callfunction DDS 1

startfunction DDS
   endian little
   set MEMORY_FILE binary "\x44\x44\x53\x20\x7c\x00\x00\x00\x07\x10\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\x00\x00\x00\x00\xff\x0a\x10\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
   get NAME basename
   string NAME + ".dds"

   putvarchr MEMORY_FILE 0xc WIDTH2 short
   putvarchr MEMORY_FILE 0x10 HEIGHT2 short
   putvarchr MEMORY_FILE 0x50 0x41 byte

   append
   log MEMORY_FILE 0x80 SIZE
   append

   get DDS_SIZE asize MEMORY_FILE
   log NAME 0 DDS_SIZE MEMORY_FILE
endfunction
So I get this kind of structure and all, but I'm not experient when it comes to converting these kind of images to a readable image file format(such as dds, png, tga and so on). Any tips, or maybe a solution?
Last edited by AnonBaiter on Fri Dec 09, 2016 7:20 pm, edited 3 times in total.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: Tomb Raider Legend - .raw

Post by AnonBaiter »

Okay, I'm close to decoding the format. Although I'm afraid the colors might be looking incorrect...
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Tomb Raider Legend - .raw

Post by Acewell »

i know you're trying to do this with QuickBMS but this is what i got when converted with Noesis :D
7B714552.png


its 1024x1024 rgba32

edit
turns out to be argb instead of rgba :D
Last edited by Acewell on Sat Dec 10, 2016 12:27 am, edited 2 times in total.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: Tomb Raider Legend - .raw

Post by AnonBaiter »

Acewell wrote:its 1024x1024 rgba32

Can you elaborate on what the .dds header looks like with that format? texconv.exe and texconvex.exe has a list of formats to choose from:

Code: Select all

   <format>: R8G8B8 A8R8G8B8 X8R8G8B8 R5G6B5 X1R5G5B5 A1R5G5B5 A4R4G4B4 R3G3B2
      A8 A8R3G3B2 X4R4G4B4 A2B10G10R10 A8B8G8R8 X8B8G8R8 G16R16 A2R10G10B10
      A16B16G16R16 A8P8 P8 L8 A8L8 A4L4 V8U8 L6V5U5 X8L8V8U8 Q8W8V8U8 V16U16
      A2W10V10U10 UYVY R8G8_B8G8 YUY2 G8R8_G8B8 DXT1 DXT2 DXT3 DXT4 DXT5
      D16_LOCKABLE D32F_LOCKABLE L16 Q16W16V16U16 R16F G16R16F A16B16G16R16F
      R32F G32R32F A32B32G32R32F CxV8U8

Code: Select all

   <format>: R32G32B32A32_FLOAT R32G32B32A32_UINT R32G32B32A32_SINT
      R32G32B32_FLOAT R32G32B32_UINT R32G32B32_SINT R16G16B16A16_FLOAT
      R16G16B16A16_UNORM R16G16B16A16_UINT R16G16B16A16_SNORM
      R16G16B16A16_SINT R32G32_FLOAT R32G32_UINT R32G32_SINT
      R10G10B10A2_UNORM R10G10B10A2_UINT R11G11B10_FLOAT R8G8B8A8_UNORM
      R8G8B8A8_UNORM_SRGB R8G8B8A8_UINT R8G8B8A8_SNORM R8G8B8A8_SINT
      R16G16_FLOAT R16G16_UNORM R16G16_UINT R16G16_SNORM R16G16_SINT
      R32_FLOAT R32_UINT R32_SINT R8G8_UNORM R8G8_UINT R8G8_SNORM
      R8G8_SINT R16_FLOAT R16_UNORM R16_UINT R16_SNORM R16_SINT
      R8_UNORM R8_UINT R8_SNORM R8_SINT A8_UNORM R9G9B9E5_SHAREDEXP
      R8G8_B8G8_UNORM G8R8_G8B8_UNORM BC1_UNORM BC1_UNORM_SRGB BC2_UNORM
      BC2_UNORM_SRGB BC3_UNORM BC3_UNORM_SRGB BC4_UNORM BC4_SNORM
      BC5_UNORM BC5_SNORM B8G8R8A8_UNORM* B8G8R8X8_UNORM*
      B8G8R8A8_UNORM_SRGB* B8G8R8X8_UNORM_SRGB* BC6H_UF16* BC6H_SF16*
      BC7_UNORM* BC7_UNORM_SRGB*

      * == DXGI 1.1/Direct3D 11 format
Besides, there's a good chance the "rgba32" you're talking about could be "A8R8G8B8". Here is an excerpt from format.h:

Code: Select all

{
    D3DFMT_A4L4,            TEXT("A4L4"),           TYPE_UNSIGNED,   8,     TRUE,   IDS_FMTDESC_A4L4,
    D3DFMT_A8,              TEXT("A8"),             TYPE_UNSIGNED,   8,     TRUE,   IDS_FMTDESC_A8,
    D3DFMT_L8,              TEXT("L8"),             TYPE_UNSIGNED,   8,     FALSE,  IDS_FMTDESC_L8,
    D3DFMT_P8,              TEXT("P8"),             TYPE_UNSIGNED,   8,     FALSE,  IDS_FMTDESC_P8,
    D3DFMT_R3G3B2,          TEXT("R3G3B2"),         TYPE_UNSIGNED,   8,     FALSE,  IDS_FMTDESC_R3G3B2,
    D3DFMT_A1R5G5B5,        TEXT("A1R5G5B5"),       TYPE_UNSIGNED,   16,    TRUE,   IDS_FMTDESC_A1R5G5B5,
    D3DFMT_A4R4G4B4,        TEXT("A4R4G4B4"),       TYPE_UNSIGNED,   16,    TRUE,   IDS_FMTDESC_A4R4G4B4,
    D3DFMT_A8L8,            TEXT("A8L8"),           TYPE_UNSIGNED,   16,    TRUE,   IDS_FMTDESC_A8L8,
    D3DFMT_A8P8,            TEXT("A8P8"),           TYPE_UNSIGNED,   16,    TRUE,   IDS_FMTDESC_A8P8,
    D3DFMT_A8R3G3B2,        TEXT("A8R3G3B2"),       TYPE_UNSIGNED,   16,    TRUE,   IDS_FMTDESC_A8R3G3B2,
    D3DFMT_L16,             TEXT("L16"),            TYPE_UNSIGNED,   16,    FALSE,  IDS_FMTDESC_L16,
    D3DFMT_R5G6B5,          TEXT("R5G6B5"),         TYPE_UNSIGNED,   16,    FALSE,  IDS_FMTDESC_R5G6B5,
    D3DFMT_X1R5G5B5,        TEXT("X1R5G5B5"),       TYPE_UNSIGNED,   16,    FALSE,  IDS_FMTDESC_X1R5G5B5,
    D3DFMT_X4R4G4B4,        TEXT("X4R4G4B4"),       TYPE_UNSIGNED,   16,    FALSE,  IDS_FMTDESC_X4R4G4B4,
    D3DFMT_R8G8B8,          TEXT("R8G8B8"),         TYPE_UNSIGNED,   24,    FALSE,  IDS_FMTDESC_R8G8B8,
    D3DFMT_A2B10G10R10,     TEXT("A2B10G10R10"),    TYPE_UNSIGNED,   32,    TRUE,   IDS_FMTDESC_A2B10G10R10,
    D3DFMT_A2R10G10B10,     TEXT("A2R10G10B10"),    TYPE_UNSIGNED,   32,    TRUE,   IDS_FMTDESC_A2R10G10B10,
    D3DFMT_A8B8G8R8,        TEXT("A8B8G8R8"),       TYPE_UNSIGNED,   32,    TRUE,   IDS_FMTDESC_A8B8G8R8,
    D3DFMT_A8R8G8B8,        TEXT("A8R8G8B8"),       TYPE_UNSIGNED,   32,    TRUE,   IDS_FMTDESC_A8R8G8B8,
    D3DFMT_G16R16,          TEXT("G16R16"),         TYPE_UNSIGNED,   32,    FALSE,  IDS_FMTDESC_G16R16,
    D3DFMT_X8B8G8R8,        TEXT("X8B8G8R8"),       TYPE_UNSIGNED,   32,    FALSE,  IDS_FMTDESC_X8B8G8R8,
    D3DFMT_X8R8G8B8,        TEXT("X8R8G8B8"),       TYPE_UNSIGNED,   32,    FALSE,  IDS_FMTDESC_X8R8G8B8,
    D3DFMT_A16B16G16R16,    TEXT("A16B16G16R16"),   TYPE_UNSIGNED,   64,    TRUE,   IDS_FMTDESC_A16B16G16R16,
   
    D3DFMT_CxV8U8,          TEXT("CxV8U8"),         TYPE_SIGNED,     16,    FALSE,  IDS_FMTDESC_CxV8U8,
    D3DFMT_V8U8,            TEXT("V8U8"),           TYPE_SIGNED,     16,    FALSE,  IDS_FMTDESC_V8U8,
    D3DFMT_Q8W8V8U8,        TEXT("Q8W8V8U8"),       TYPE_SIGNED,     32,    TRUE,   IDS_FMTDESC_Q8W8V8U8,
    D3DFMT_V16U16,          TEXT("V16U16"),         TYPE_SIGNED,     32,    FALSE,  IDS_FMTDESC_V16U16,
    D3DFMT_Q16W16V16U16,    TEXT("Q16W16V16U16"),   TYPE_SIGNED,     64,    TRUE,   IDS_FMTDESC_Q16W16V16U16,
   
    D3DFMT_L6V5U5,          TEXT("L6V5U5"),         TYPE_MIXED,      16,    FALSE,  IDS_FMTDESC_L6V5U5,
    D3DFMT_A2W10V10U10,     TEXT("A2W10V10U10"),    TYPE_MIXED,      32,    FALSE,  IDS_FMTDESC_A2W10V10U10,
    D3DFMT_X8L8V8U8,        TEXT("X8L8V8U8"),       TYPE_MIXED,      32,    FALSE,  IDS_FMTDESC_X8L8V8U8,
   
    D3DFMT_DXT1,            TEXT("DXT1"),           TYPE_FOUR_CC,    4,     TRUE,   IDS_FMTDESC_DXT1,
    D3DFMT_DXT2,            TEXT("DXT2"),           TYPE_FOUR_CC,    8,     FALSE,  IDS_FMTDESC_DXT2,
    D3DFMT_DXT3,            TEXT("DXT3"),           TYPE_FOUR_CC,    8,     TRUE,   IDS_FMTDESC_DXT3,
    D3DFMT_DXT4,            TEXT("DXT4"),           TYPE_FOUR_CC,    8,     FALSE,  IDS_FMTDESC_DXT4,
    D3DFMT_DXT5,            TEXT("DXT5"),           TYPE_FOUR_CC,    8,     TRUE,   IDS_FMTDESC_DXT5,
    D3DFMT_G8R8_G8B8,       TEXT("G8R8_G8B8"),      TYPE_FOUR_CC,    16,    FALSE,  IDS_FMTDESC_G8R8_G8B8,
    D3DFMT_R8G8_B8G8,       TEXT("R8G8_B8G8"),      TYPE_FOUR_CC,    16,    FALSE,  IDS_FMTDESC_R8G8_B8G8,
    D3DFMT_UYVY,            TEXT("UYVY"),           TYPE_FOUR_CC,    16,    FALSE,  IDS_FMTDESC_UYVY,
    D3DFMT_YUY2,            TEXT("YUY2"),           TYPE_FOUR_CC,    16,    FALSE,  IDS_FMTDESC_YUY2,   

    D3DFMT_R16F,            TEXT("R16F"),           TYPE_FLOAT,      16,    FALSE,  IDS_FMTDESC_R16F,
    D3DFMT_G16R16F,         TEXT("G16R16F"),        TYPE_FLOAT,      32,    FALSE,  IDS_FMTDESC_G16R16F, 
    D3DFMT_A16B16G16R16F,   TEXT("A16B16G16R16F"),  TYPE_FLOAT,      64,    TRUE,   IDS_FMTDESC_A16B16G16R16F,

    D3DFMT_R32F,            TEXT("R32F"),           TYPE_IEEE,       32,    FALSE,  IDS_FMTDESC_R32F,
    D3DFMT_G32R32F,         TEXT("G32R32F"),        TYPE_IEEE,       64,    FALSE,  IDS_FMTDESC_G32R32F,
    D3DFMT_A32B32G32R32F,   TEXT("A32B32G32R32F"),  TYPE_IEEE,       128,   TRUE,   IDS_FMTDESC_A32B32G32R32F,
};
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Tomb Raider Legend - .raw

Post by Acewell »

AnonBaiter wrote:Can you elaborate on what the .dds header looks like with that format?

its raw image data not dxt so no dds header, you would use a suitable format and
header for that, i guess tga would do it, i usually just let the tools fix this stuff :)

edit
AnonBaiter wrote:Besides, there's a good chance the "rgba32" you're talking about could be "A8R8G8B8".

yep "argb" works with the 128 byte header, problem solved :D
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: Tomb Raider Legend - .raw

Post by AnonBaiter »

Well, I'm going to stick with .tga as you suggested.
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Tomb Raider Legend - .raw

Post by Acewell »

here is a Noesis python script made for kicks that will open your sample :D
tex_TombRaiderLegend_raw.zip
Last edited by Acewell on Sat Dec 10, 2016 2:32 am, edited 1 time in total.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: Tomb Raider Legend - .raw

Post by AnonBaiter »

Now you beat me to it!
But what about this? These two files seems to be using a different TGA codec...
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Tomb Raider Legend - .raw

Post by Acewell »

they are the same type, but it looks like the width stored in the new samples is incorrect. :shock:
both samples say A0 when it should be C0, maybe there is flag that triggers the 32 pixel addition :?

edit
i made an adjustment to the previous script to try fixing this :D
need to test it with more of those samples though