Jayveer / CtxrTool

A program for converting CTXR textures from Metal Gear Solid: Master Collection to DDS and vice versa
17 stars 2 forks source link

Struct mapping & enums #4

Open emoose opened 1 year ago

emoose commented 1 year ago

Hi, great work with the tool, I've been looking into some of the stuff around texture rendering too, luckily they left a lot in the renderer.dll file that lays out some of the types/enums for it.

Came up with a 010 editor template that maps out some more of the CTXR header, figured it's worth posting in case it can help at all.

BigEndian();

enum<uint32> CBaseTexture_EFormat
{
  kFormat_A8R8G8B8 = 0x0, // DXGI_FORMAT_B8G8R8A8_UNORM
  // 0x1 isn't defined in Renderer.dll, but seems to use DXGI_FORMAT_B8G8R8X8_UNORM
  // maybe kFormat_X8R8G8B8 = 0x1,
  kFormat_A16B16G16R16F = 0x2, // DXGI_FORMAT_R16G16B16A16_FLOAT
  kFormat_R32F = 0x3, // DXGI_FORMAT_R32_FLOAT
  kFormat_D24X8 = 0x4, // DXGI_FORMAT_D24_UNORM_S8_UINT
  kFormat_DXT1 = 0x5, // DXGI_FORMAT_BC1_UNORM
  kFormat_DXT3 = 0x6, // DXGI_FORMAT_BC2_UNORM
  kFormat_DXT5 = 0x7, // DXGI_FORMAT_BC3_UNORM
  kFormat_A32B32G32R32F = 0x8, // DXGI_FORMAT_R32G32B32A32_FLOAT
  kFormat_Luminance8 = 0x9, // DXGI_FORMAT_R8_UNORM
  kFormat_D24FS8 = 0xA, // not mapped to DXGI_FORMAT?
  kFormat_Count = 0xB,
  kFormat_Invalid = 0xFFFFFFFF,
};

enum<uint32> CBaseTexture_EType
{
  kType_Normal = 0x0,
  kType_Cube = 0x1, // reads 6 * MipCount images from the file if this is set?
};

// struct is packed without padding, requires the following in VC++
// #pragma pack(push, 1)
struct CTxrHeader
{
  uint32 Magic_0;
  uint32 Version_4;
  uint16 Width_8;
  uint16 Height_A;
  uint16 Depth_C;
  CBaseTexture_EFormat Format_E;
  byte Flags_12;
  int unk_13;
  int unk_17;
  int unk_1B;
  if (Version_4 >= 6)
  {
    byte unk_1F;
    byte unk_20;
  }
  if (Version_4 >= 7)
  {
    byte unk_21;
  }
  CBaseTexture_EType TextureType_22;
  byte MipCount_26;
};
// #pragma pack(pop)

CTxrHeader Header;
Jayveer commented 1 year ago

Thanks, that's great info