L3DT users' wiki
Large 3D terrain generator

Stitching heightmaps

Author Aaron
Date 29-Mar-2012

Not infrequently, users have asked how to stitch together two or more heightmaps to make one seamless map. This tutorial should, I hope, answer those questions.

This tutorial only covers stitching heightmaps, and does not cover stitching together other map types such as textures or design maps.

Required tools

To follow this tutorial you will need L3DT v12.03 build 3 or later. Earlier versions did not support tile blending, and so will not be suitable for this activity.

Input requirements

The height data can be from any source, and in any file format that is supported by L3DT. However, it is recommended that 'proper' heightmap file formats be used, such as TER (Terragen), BT (VTP), HFZ (L3DT), or GeoTIFF (various). Bitmaps or other image formats are not recommended, as these do not preserve vertical scaling between tiles, which could make it harder for you to match up the heights and slopes of neighbouring tiles.

The heightfield tiles do not have to be square, but the tiles must all be exactly the same size in pixels.

In this example, I will stitch together six 512×512 pixel heightfield files to produce one 1536×1024 pixel heightmap with a 3×2 aspect ratio. The six tiles were created separately in L3DT using a batch script and the 'designable map' algorithm.

Loading the first tile

To load the first heightmap, use the ‘File→Import→Heightmap’ menu option. The first tile should be the south-western most of the set, for reasons that will become obvious later. Once you have imported the first heightmap, the display should look something like this:

The first heightfield tile

Loading the second tile

To load the second tile, use the 'File→Import→Merge heightmaps' menu option. This will open the 'Merge Heightmaps' window, shown below:

The 'merge heightmaps' window.

The 'merge heightmaps' window can be used to either apply a heightmap-based overlay (such as a volcano) over an existing heightmap, or to stitch a second heightfield onto the edge of the first. We want the latter option. Consequently, we need to un-check the 'stretch to fit' checkbox, and then enter in the appropriate X and Y position offsets.

The position offsets are measured in pixels from the southwest corner of the first map, with X increasing from west to east, and Y increasing from south to north. In this case, the tile I'm loading is immediately to the east of the first tile, so the Y offset is 0, and the X offset is the width of the first tile, which is 512 pixels. The table below shows the X/Y coordinates for each of the tiles in my 3×2 map. Note that the (0,0) tile has already been loaded, and the (512,0) tile about to be loaded.

0, 512 512, 512 1024, 512
0,0 512, 0 1024, 0

With the appropriate settings applied, the 'merge heightmaps' window should look like this:

The 'merge heightmaps' window, when loading the second tile.

Once the tile has been loaded, the heightfield will re-draw, showing the second tile to the east of the first:

The heightfield, with two tiles loaded.

Don't be alarmed at the sharp edge between the two tiles. That will be cleared up in the final processing stage, after all tiles have been loaded.

Loading subsequent tiles

The same process is repeated for the other tiles, again using the 'File→Import→Merge heightmaps' menu option.

The third tile in this set is to the east of the second. Consulting my little table of coordinates, we see that the offsets to use are X=1024 and Y=0.

0, 512 512, 512 1024, 512
0,0 512, 0 1024, 0

The settings in the 'merge heightmaps' window are thus:

The 'merge heightmaps' window, loading the third tile.

…and the resulting heightmap, now with the southernmost three tiles loaded, looks like:

The heightfield, with three tiles loaded.

If you make a mistake with the coordinates and import your heightmap tile in the wrong location, you can use the 'undo' feature to undo the change.

You can in fact load the tiles in any order you please, and you can use negative offsets to place tiles to the west or south of the current map dimensions. However, for simplicity's sake, I recommend you load maps in L3DT's raster order, which means first loading the southernmost row of tiles from west to east, then stepping to the next row to the north, and loading that row from west to east (rinse, repeat.) Following my own advice, and my little table of coordinates (below), the fourth tile to be loaded will be X=0, Y=512:

0, 512 512, 512 1024, 512
0,0 512, 0 1024, 0

In the 'merge heightmaps' window, the correct settings look like:

The 'merge heightmaps' window, loading the fourth tile.

…and the resultant heightmap looks like:

The heightmap, with four tiles loaded.

Repeating the process for the remaining two tiles, we end up with our combined 3×2 tile array:

The combined 3×2 heightmap.

Viewing the map in 3D using Sapphire, we can see the sharp seams at the tile edges, which are of course due to the fact that I've loaded six completely unrelated and unmatched heightfield maps next to one another.

The 3×2 combined heightmap in 3D, viewed from the northwest corner, looking to the southeast.

We shall now proceed to fix the seams…

Blending the heightmap edges

To smooth the tile edges, we use the 'Operations→Heightfield→Edge blending→Blend tile edges' menu option1). This will open the placeholderesque 'tile blend settings' window, shown below:

The 'tile blend settings' window.

In this window, we must set the X and Y tile size, which in this particular case are both 512 pixels. We also need to set the blend depth, which is the with of the interior border around a tile edge that will be modified to match up with the neighbouring tile. In this case I will use the default value, which is 100 pixels. To edit any of these settings, double-click the left mouse button on them.

Once the tiles have been blended, the smoothly blended heightmap will be redrawn:

The combined 3×2 heightmap, now with blended edges.

In 3D, we can see that the borders are no longer visible.

The blended heightmap in 3D.


The current release of the blending plugin can produce streaking artefacts in the blended border area, in a direction perpendicular to the tile edge. If these streaks are problematic, users are recommended to use the smoothing tools in the Sapphire 3D editor to remove the artefacts.

Comments or feedback

If you find any errors in this tutorial or would like to suggest any changes, please use this forum thread.

Cheerio, Aaron.

1) Before L3DT v14.06, this option was 'Extensions→atEdgeBlender→Blend tile edges' in the menu.
tutorials/l3dt/stitching_heightmaps.txt · Last modified: 2017/08/31 06:19 (external edit)
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki