Open brokeDude2901 opened 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))
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)
From https://github.com/klensy/wt-tools/blob/dev/src/wt_tools/ddsx_unpack.py