October 18, 20241 yr Hello, help me solve the problem with the Noesis plugin. it incorrectly shows the ps2 swizzle 4bpp texture, but some programs also do this incorrectly. thanks in advance if use MummGGTool: width = 64, height = 32, bpp = 4 inside Noesis i use: data = rapi.imageUntwiddlePS2(data, width, height, 4) data = rapi.imageDecodeRawPal(data, palette, width, height, 4, 'r8g8b8a8', 1) if width = 32, height = 64 if width = 64, height = 32 if use "Console Texture Explorer": s0000_023.zip
October 18, 20241 yr Solution It looks like the data is in blocks of 32x32 (0x200 bytes), so you need to untwiddle each block separately and then join them together to get your final image.
October 19, 20241 yr Author 22 hours ago, DKDave said: It looks like the data is in blocks of 32x32 (0x200 bytes) thank its true, i so suspected it. but the first program led me astray offtopic: I found the code on github and 8bits work well, but 4bits look bad, what's wrong with them? swizzle_ps2.py need: have: Spoiler def unswizzle_ps2_8bit(image_data, img_width, img_height): unswizzled_data = bytearray(img_width * img_height) for y in range(img_height): for x in range(img_width): block_location = (y & (~0xF)) * img_width + (x & (~0xF)) * 2 swap_selector = (((y + 2) >> 2) & 0x1) * 4 pos_y = (((y & (~3)) >> 1) + (y & 1)) & 0x7 column_location = pos_y * img_width * 2 + ((x + swap_selector) & 0x7) * 4 byte_num = ((y >> 1) & 1) + ((x >> 2) & 2) swizzle_id = block_location + column_location + byte_num unswizzled_data[y * img_width + x] = image_data[swizzle_id] return unswizzled_data def unswizzle_ps2_4bit(image_data, img_width, img_height): pixels = bytearray(img_width * img_height) for i in range(img_width * img_height // 2): index = image_data[i] id2 = (index >> 4) & 0xF id1 = index & 0xF pixels[i * 2] = id1 pixels[i * 2 + 1] = id2 new_pixels = unswizzle_ps2_8bit(pixels, img_width, img_height) unswizzled_data = bytearray(img_width * img_height) for i in range(img_width * img_height // 2): idx1 = new_pixels[i * 2] idx2 = new_pixels[i * 2 + 1] idx = ((idx2 << 4) | idx1) & 0xFF unswizzled_data[i] = idx return unswizzled_data en013_01.zip
Create an account or sign in to comment