L3DT users' community
Large 3D terrain generator

Python script that converts a heightmap into tiles for UE4

Cool programs, tutorials, texture libraries, et cetera.

Python script that converts a heightmap into tiles for UE4

Postby Czorio » 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

> python convert_l3dt_to_ue4.py '[drive]:\[directory]\[image].png' '[drive]:\[output directory]' [tile size]

- 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
New member
Posts: 3
Joined: Tue Apr 23, 2019 10:41 pm

Return to Useful resources

Who is online

Users browsing this forum: No registered users and 1 guest