From 81992c67c1ea27f35765994abbd32d53af64fa70 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Sat, 22 Nov 2025 21:50:31 -0600 Subject: [PATCH] decode_pvrt: add support for non-square textures --- gen/k_means/python/decode_pvrt.py | 49 ++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/gen/k_means/python/decode_pvrt.py b/gen/k_means/python/decode_pvrt.py index d28b78b..06a4d7b 100644 --- a/gen/k_means/python/decode_pvrt.py +++ b/gen/k_means/python/decode_pvrt.py @@ -28,7 +28,7 @@ def parse_pvrt_header(buf): print(hex(texture_type)) print(width) print(height) - assert len(indices) + len(codebook) == texture_data_size - 8 + assert len(indices) + len(codebook) == texture_data_size - 8, (len(indices) + len(codebook), texture_data_size - 8) #assert len(indices) == width * height / 4, (len(indices), width * height / 4) return PVRT( texture_data_size, @@ -51,6 +51,53 @@ def get_colors(buf, codebook_ix): colors = struct.unpack('> i) & 1) << (i * 2 + 0) + twiddle_ix |= ((x >> i) & 1) << (i * 2 + 1) + elif i < width_max: + twiddle_ix |= ((x >> i) & 1) << (i + height_max) + elif i < height_max: + twiddle_ix |= ((y >> i) & 1) << (i + width_max) + else: + break + i += 1 + + return twiddle_ix + + def from_xy(x, y): twiddle_ix = 0 i = 0