If you ever made track textures for MTM2 or Evo 1 / 2, you know of the dreaded two-pixel overlap required for seamless textures in game. There are various reasons to want to reassemble old texture patterns, e.g. upscaling for the new HD engine, but the two-pixel overlap makes the process a bit of a nightmare. So, here is a Python script I wrote with copilot a while back that reassembles texture patterns seamlessly with the two-pixel overlap removed. I have further updated it with upscaling options and normal map generation (though normal maps may eventually go another direction for track textures).
The script is run via command line, and here is my workflow for the experiment I did with the Sidewinder Canyon textures:
-I first extracted all of the Sidewinder art into a folder (using dummiesman's Poddy too, but use whatever, e.g. Traxx).
-Next, I converted all .raw files to .png using dummiesman's tool Triraw (both tools available at 4x4evolution.net unter Modding Utilities). Note: my script requires .png input currently, and I find it useful to have because then you can preview everything right in the Windows file manager (Tip: switch view to large icons).
-Next, I visually inspected the art to figure out what the patterns might look like, their total size (e.g. 18 by 18 tiles), and the prefix used on each pattern.
Example: the biggest pattern in Sidewinder has prefix SND4E. It is 18 tiles wide by 18 tiles tall. There are missing "filler" tiles missing in the pattern as these are replaced in game by a single tile. The numbering starts at 00 and ends at 323. This is 324 total tiles in the pattern, and I found the width through visual inspection in the file manager. The height of the pattern is given by 324/18 = 18.
-I was ready to recompile the pattern. So, I copied bufferundo.py into my art folder. Right click inside the folder, in open space and not on a file. Choose "Open in Terminal". This opens a command line already inside the directory of your art.
-To run the script you type
python bufferundo.py <tile_dir> <prefix> <fallback_tile> <grid_w> <grid_h> <tile_power>
Here, since we have our terminal open inside the art directory itself,
<tile_dir> = .
<prefix> = SD4DE
<fallback_tile> = SN4DE187.PNG (or any copy of that tile by another name, e.g. SN4DRC00.PNG which would be the first tile that you load in Traxx, and the one that is used to fill the entire grid at first).
<grid_w> = 18 (the width of the pattern)
<grid_h> = 18 (also the height of the pattern)
<tile_power> = 8 (This is the exponent for how large you want your upscaled tiles. I wanted 256 by 256 tiles, and 2^8 = 256. So, I entered 8 there.)
-There are some Python dependencies: pillow, numpy, scipy, and (optionally but recommended for GPU acceleration if you have one) pyopencl. The script may prompt you to install this if you don't have them. If not, just run from the terminal:
pip install pillow numpy scipy pyopencl
-Running the script
python bufferundo.py . SN4DE SN4DE187.PNG 18 18 8
generates the full pattern image in the art directory for you to inspect, in this case SN4DE.png.
-It prompts you to inspect the image and confirm whether it looks correct. If it doesn't look correct, answer n and retry with different grid size. If it does and all you want is the original pattern, answer n and the script will exit leaving the pattern. If you want to continue with upscaling, answer y and continue with the rest of the options.
-If you choose to continue, you can choose from different upscaling algorithms and after different sharpening effects (see Readme for both).
-It then generates an upscaled image for you to inspect. If you like it, continue. If not, you can try a different algorithm or sharpening effect and inspect again, ad infinitium.
-When you are happy with the upscaled pattern, you can choose to generate a normal map for the pattern or none. Again you'll be prompted to inspect.
-When you are satisfied, it will proceed to slice everything into textures of your chosen size, 256 by 256 in this example, and will put them in a directory SN4DE_HD (in this example).
-Finally, you make an HD art pod, put all these files inside the ART folder in that pod and mount it above the track whose textures you want to replace.
Beware: new numbered tiles will be generated where the filler tile was used, and you can choose not to include these in your pod to save space.
There is lots of room for experimentation here, and I am happy to receive feedback.
The most recent Sidewinder art is here (36 megs, just mount above SNAKE.POD): https://drive.google.com/file/d/1R4KSVz ... drive_link
The script is here and also attached (check the readme for more info): https://drive.google.com/file/d/15L4yOD ... sp=sharing
Bufferundo: MTM2 Texture Pattern Reconstructor and Upscaler
Bufferundo: MTM2 Texture Pattern Reconstructor and Upscaler
You do not have the required permissions to view the files attached to this post.