klensy / wt-tools

War Thunder resource extraction tools
132 stars 38 forks source link

Any light on how to extract UHQ (4K) Texture properly ? #86

Open brokeDude2901 opened 5 months ago

brokeDude2901 commented 5 months ago

From https://github.com/klensy/wt-tools/blob/dev/src/wt_tools/ddsx_unpack.py

if parsed_data.header.flags.FLG_REV_MIP_ORDER:
        # Reverse MIPMAP order (from smallest -> biggest to biggest -> smallest)
        if texture_format in [b'DXT1', b'DXT5']:
            # https://docs.microsoft.com/en-us/windows/win32/direct3ddds/dds-file-layout-for-textures
            def get_dxt1_size(t_width, t_height, dxt_version):
                dxt_size = max(1, (t_width + 3) // 4) * max(1, (t_height + 3) // 4)
                if dxt_version == b'DXT1':
                    return dxt_size * 8
                elif dxt_version == b'DXT5':
                    return dxt_size * 16
                else:
                    print("unknown dxt version: {}", dxt_version)
                    return

            pos = 0
            images = []
            for level in range(parsed_data.header.levels - 1, -1, -1):
                width = parsed_data.header.w // (2 ** level)
                height = parsed_data.header.h // (2 ** level)
                size = get_dxt1_size(width, height, texture_format)
                images.append(d_data[pos:pos + size])
                pos += size

            d_data = bytearray()
            for image in reversed(images):
                d_data.extend(image)

        elif parsed_data.header.levels > 1:
            # left unpacked data as is
            print("Dunno how to re-order mipmaps for format {}".format(texture_format))
brokeDude2901 commented 4 hours ago

Nevermind, I figured it out on Windows 11, don't use the release (https://github.com/klensy/wt-tools/releases/tag/v0.2.2.8)

  1. git clone https://github.com/klensy/wt-tools
  2. install python 3.10
  3. install Desktop Development with C++ from https://visualstudio.microsoft.com/visual-cpp-build-tools/
  4. pip install -r requirements.txt
  5. put "oo2core_6_win64.dll" under "wt-tools/tree/dev/src/wt_tools/formats"
  6. python3 ./UserData/wt-tools/src/wt_tools/dxp_unpack.py ./content.hq\uhq_vehicles\res\uhq_vehicles_tanks\usa_m1a1_hc_usmc.dxp.bin
  7. python3 ./UserData/wt-tools/src/wt_tools/ddsx_unpack.py ./content.hq\uhq_vehicles\res\uhq_vehicles_tanks\usa_m1a1_hc_usmc.dxp.bin_u