The Warp Room

Full Version: NST Texture Converter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[Image: FUvpbUY.jpg]

This is a multi-purpose tool for converting textures to and from the file format used by the N Sane Trilogy. Similar to CrashNSTOST, it's just a batch script, but I haven't bothered packing it all into an exe this time because it's not as complicated. The zip contains a file called NSTtextureconverter.bat and folders called stuff and output. Don't mess with the stuff folder or everything will break! And don't run the converter more than once at a time because that will also cause everything to break. Everything will probably break anyway, because I don't know what I'm doing and as always this is just some awful messy code that I wrote for my own personal use that I'm now releasing for anyone to try because it does sort of work. Hopefully someone more competent will be able to make something nicer in the future. Everything is experimental, use at your own risk etc.

Download here: (if you get a SmartScreen error click more info then run anyway)

There's no GUI or any menus in this, just drag and drop a file onto NSTtextureconverter.bat and depending on what kind of file you use, you'll get a different result:

Converting images to IGZ textures

If you use a PNG, JPG, BMP or GIF image as the input, it will be converted into a texture compatible with the N Sane Trilogy and saved as an IGZ file with the same filename as the input image in the NSTtextureconverter\output folder. You can then use Neo_Kesha's NST Explorer to import it into the game files and replace an existing texture. The conversion may sometimes fail but still produce an IGZ file which is just the header. This will crash the game if you try to use it. I haven't really determined the cause of this - it does give an error about the wrong dimensions for the file format sometimes so resizing the image can fix it, but I've also had better luck when using PhotoShop's quick PNG export option rather than the normal export menu so it might be nothing to do with dimensions at all. If the IGZ produced is more than a couple of KB in size then it'll probably be okay. If not then try resizing it first or exporting it from a different program or in a different format. The actual dimensions of the input image won't make a difference when the texture is shown in-game, it will be stretched or squashed into the correct size and aspect ratio. If you're not sure whether it's worked or not then a quick way to test it is to drag the IGZ that was created onto the converter to attempt to turn it back into a PNG.

Converting IGZ textures to images

If you use an IGZ texture file as the input, it will be converted into a PNG image which you can view or edit in whatever image software you want like any normal PNG. This will not always produce perfect results - I understand the file structure just about well enough to be able to include full compatability for most textures but there are some that will turn out a bit glitchy or even a lot glitchy. This is because there are some cases where the same piece of code could refer to two possible file formats, and I've just gone for the one that seems to be used more commonly. I've obviously missed some important code somewhere but it works most of the time and I have included a couple of extra options for IGZ>PNG conversion which you can try if the output looks incorrect:
  • If you rename the file extension to .igz3 instead of .igz, the converter will produce 3 PNG files, each one using a different encoding format. One of these should be right.
  • If you rename the file to include "keeppvr" somewhere in the filename (eg filename_keeppvr.igz or filename_keeppvr.igz3) then the converter will save a PVR file alongsdie the PNG. This is useful because with some textures, the created PNG file may have some stray pixels or artefacts. The PVR file is the original texture ripped straight from the IGZ with no conversion and can be opened and edited with an external program like PVRTexTool (my tool uses the command line version of that to create the PNGs, manually exporting PNGs from the GUI seems to give better results).
Please note, most of the files used by the game are stored as IGZs and this tool is only intended to be used for IGZ texture files. I don't know what kind of garbage it might spit out if you try using a different kind of IGZ as the input but if it's not working, make sure the IGZ file you're using is definitely a texture.

Extracting and converting textures from PAK files

If you use a PAK archive file as the input, every texture contained within the archive's textures folder will be extracted and then converted into PNG format. These files will be saved in a subfolder with the same name as the PAK file, within the NSTtextureconverter\output folder. This will take a while with some of the larger archives like levels because there are so many textures. You can check how much progress has been made by opening the folder that's been created and checking how many of the IGZ files have been converted to PNG so far. This will convert textures using the default .igz method (as opposed to the .igz3 version), so expect a few not to be converted properly (though the keeppvr trick will work with PAK files if you want to save PVR textures as well). You will still need to use the NST Explorer if you want to reimport custom textures back into the PAK file, this is just for mass extraction.

This is just a basic tool for straightforward conversion of textures, I'm not gonna go into detail about how these files actually work and how they're used in game. The game files contain a LOT of textures. The same textures can be found in many different archives but in a lot of cases only one of those instances will actually be used in-game. If you replace a texture but are still seeing the original version when you load the game, it's probably because you replaced the wrong version of that texture. I'm not gonna test every single duplicated texture to work out which ones are actually used, just employ some trial and error and common sense and you should be able to work it out eventually. If you've replaced a CavityBakedColorMap texture with a custom file and nothing seems to have changed, try replacing the ColorMap texture instead/as well. I don't know what all these different types of texture are for. Go and experiment!!

Special thanks as always to Neo_Kesha for the wonderful NST Explorer, and to pashok6798 for the Crash Bandicoot NSAMETRIOLOGY Tool - this includes a IGZ>PVR converter and studying the output of that tool is how I worked out the file structure and why I decided to try automating the conversion in the first place. If you want to take my batch script and turn it into something nicer then please feel free, I have learned enough to be able to create a simple GUI for this but I want to get back to my level editing investigations so if it works alright as it is I might not bother. I will make a video demonstrating the tool soon though, in case these instructions aren't too clear.
Ouf thats a hard to read 500 lines batch script!
how did you managed to not lose the overview when writing this XD