VitaSmith / gust_tools

A set of utilities for dealing with Gust (Koei Tecmo) PC games files
Other
206 stars 23 forks source link

Add PS3 g1t Support #43

Closed RebootRevival closed 2 years ago

RebootRevival commented 2 years ago

PS3 texture conversion.pdf

This has been tested and works with Nights of Azure PS3.

Looks like there are a few outliers with length bytes of 28 and 34. Might by 1 or 2 others. But the same rules apply.

VitaSmith commented 2 years ago

Thanks for the report.

Any chance that you could share actual PS3 .g1t files? I just can't proceed with adding support for PS3 textures unless I have access to PS3 texture files. The document you pointed to is simply not enough.

RebootRevival commented 2 years ago

sure. I can supply my secondary script that actually processes the g1t files before submitting them to the modified g1t exe. Do you want me to package a few items and submit them here or some other way? Since submitting the request I have found that mipmap don't need to be set to 1 and I have so far been unsuccessful at repacking. I am using gimp to modify and export as dds and none of the dds exports provide a good encoding to match the dds of the original. I assume this is the issue, but I don't know. Header wise, I have been able to match that but in game I just get a blank White Box.

RebootRevival commented 2 years ago

It ended up not being as much as I thought. I took a random sampling of some files that are actually textures needing translation(instead of just basic images), and a couple actual image files. Hopefully you understand my readme and can follow the Powershell. I mostly work in C# so I try to write structured code that makes sense, but Powershell is odd if you aren't familiar with it. There is a little shorthand in it so if you need any help or anything don't hesitate to ask. PS3 Gust Tools.zip

VitaSmith commented 2 years ago

Thanks for the files. I really just need the textures, as the whole issue is that the PS3 is big endian (since the Cell CPU that powers it is derived from the PowerPC architecture, which is big endian), and therefore that the data stream must be processed in big endian mode rather than little endian mode. Then everything should map as expected.

Now, while this sounds like a very straightforward problem on paper, modifying code that was only ever designed to handle little endian data, to also handle big endian, is actually a lot of work. So it may be some time before I get to it, especially as I only ever intended gust_tools to be used with PC games...

RebootRevival commented 2 years ago

luckily it would appear that ONLY the header is actually big endian, but its particular in where its big endian. It always skips a specific section of the header, but depending on the size it may or may not continue the header in its transform. The actual data itself is not big endian. But you do need to pad the data slightly to get a proper view, no matter what. Decrypting is not difficult, but the re-encrypt has me stumped. Im not familiar with DDS formats(this is my second attempt at translating) so using gimp has been an issue. I can get close to what the original file header is like, but in general the header info appears to be inconsistent with standard DDS format(for re-encryption).

VitaSmith commented 2 years ago

Should have a working version of gust_g1t that handles PS3 files now.

This was pretty much "only" a matter of handling endianness, with the small caveat that the flags from the texture header are actually another set of 4-bit nibbles that also need to be swapped for endianness.

That's actually why you found out that you needed to add a 4 extra bytes after the header (when you actually needed to remove 12 bytes, for the extra content, because if you add 4 bytes, you fix the alignment to 16 bytes that produced garbled pixels, but you also end up move some of the content that should appear on the right to the left, and therefore your texture is incorrect). In other words, gust_g1t was already set to properly process and remove the content that resulted in a misaligned texture, but because of the endianness, we couldn't detect the bit that told us that there was extra content to remove.

Anyway, packing and unpacking of PS3 textures of type 0x08 should work with the new version of gust_tools that was just released.

RebootRevival commented 2 years ago

Tested a few texture updates in NoA and it works finally. Thanks for your help.