Python script that converts a heightmap into tiles for UE4
Posted: Fri May 03, 2019 11:34 am
Hello people, I've written a Python script that takes a heightmap, and converts and saves it to tiles in the desired output directory with the naming scheme that Unreal Engine 4 requires.
https://gist.github.com/Czorio/a29172fb ... 7ea5e09a1e
This script requires python 3, numpy and imageio
Install numpy/imageio:
In a console:
> python -m pip install numpy imageio
Use:
> python convert_l3dt_to_ue4.py '[drive]:\[directory]\[image].png' '[drive]:\[output directory]' [tile size]
Notes:
- It has extensively been tested on a grand total of one case (32kx32k to 512x512, took roughly 10 minutes)
- Keep in mind that you need a fair bit of unused RAM, as the decompression of a large map can spike the ram usage to a few gigabytes
- Input is not checked for correctness
- The script is not destructive, mistakes will not ruin your heightmap
- Only for .png
Edit: The import for UE4 is a little iffy, I think the coordinate systems are a little different, if someone has any idea, I'd love to hear it
Edit 2: it's mostsly fixed. Remember to uncheck "flip tile Y coordinate" in the import dialog
Edit 3: Importing tiles may leave a seam at tile borders, this is easily fixed by using the smooth tool at strength 0.0 on the seams
https://gist.github.com/Czorio/a29172fb ... 7ea5e09a1e
This script requires python 3, numpy and imageio
Install numpy/imageio:
In a console:
> python -m pip install numpy imageio
Use:
> python convert_l3dt_to_ue4.py '[drive]:\[directory]\[image].png' '[drive]:\[output directory]' [tile size]
Notes:
- It has extensively been tested on a grand total of one case (32kx32k to 512x512, took roughly 10 minutes)
- Keep in mind that you need a fair bit of unused RAM, as the decompression of a large map can spike the ram usage to a few gigabytes
- Input is not checked for correctness
- The script is not destructive, mistakes will not ruin your heightmap
- Only for .png
Edit: The import for UE4 is a little iffy, I think the coordinate systems are a little different, if someone has any idea, I'd love to hear it
Edit 2: it's mostsly fixed. Remember to uncheck "flip tile Y coordinate" in the import dialog
Edit 3: Importing tiles may leave a seam at tile borders, this is easily fixed by using the smooth tool at strength 0.0 on the seams