xbox ps3 swizzled dds

Textures, recreate headers, conversions, algorithms and parsing of image files
h3x3r
Posts: 165
Joined: Wed Jun 01, 2016 5:53 pm

xbox ps3 swizzled dds

Post by h3x3r »

Hey there. I need to figure out which pixel format uses this dds. If anyone know, please shere info. Thanks! It's PS3 swizzled and dimension are 256x128
It should look like this:
Image
spiritovod
Posts: 719
Joined: Sat Sep 28, 2019 7:00 pm

Re: xbox ps3 swizzled dds

Post by spiritovod »

It looks like there is only one channel in the file (or paletted image without palette), because data is not compressed and 256 * 128 = exactly file size (1 byte per pixel). You can decode it for example as r8_snorm + swizzling in rawtex. It's not the original image, at least not without other supplementary data, like palette or something.
h3x3r
Posts: 165
Joined: Wed Jun 01, 2016 5:53 pm

Re: xbox ps3 swizzled dds

Post by h3x3r »

Thanks spirit for clarify... So there's no other way how to de-swizzle data without using pixel format? That colored image is captured by ninja ripper and saved as DXT5 which coresponds to the size of swizzled dds.
spiritovod
Posts: 719
Joined: Sat Sep 28, 2019 7:00 pm

Re: xbox ps3 swizzled dds

Post by spiritovod »

DXT5 is compressed format, where 4x4 block is encoded with 16 bytes, which corresponds to 1 byte per pixel as well, that's why the size is the same. But like it was already said above, the raw data you've provided looks more like non-compressed paletted image, so you need palette to reconstruct it - though in this case palette seems to be 16 colors only - unless the game is using shader-based coloring or something.
h3x3r
Posts: 165
Joined: Wed Jun 01, 2016 5:53 pm

Re: xbox ps3 swizzled dds

Post by h3x3r »

O.K figured it out. Thanks for hints spirit...
It was morton order + i found that palette table which was in the texture file.

Noesis code:

Code: Select all

  if rwTexPixelFormat == 11:
        untwid = bytearray()
        for x in range(rwTexWidth):
            for y in range(rwTexHeight):
                idx = noesis.morton2D(x, y)
                untwid += data[idx * 1:idx * 1 + 1]
        data = rapi.imageDecodeRawPal(untwid, bs.palette, rwTexWidth, rwTexHeight, 8, "b8 g8 r8 a8")
        texFmt = noesis.NOESISTEX_RGBA32
EDiT: Well seems like i am struggle with textures which don't have same width/height.
I solved textures with height power of two of width. But when it comes on power of four of width then i am lost.
This is code for height power of two of width. Means "width == height *2"

Code: Select all

idx = noesis.morton2D(y, x)
rwUntwid += data[idx * 2:idx * 2 + 2]
I must also swap x,y.

But how to on "width == height *4"?

EDiT: Got it. With this function: data = rapi.imageFromMortonOrder