Download

Tiled Landscape

I’ve seen that creating tiled landscapes is the way to go as far as getting large maps loaded. Unfortunately, as I do this mostly for fun, purchasing the $250 version of World Machine to get tiled heightmaps is out of the question. I’ve been trying to get around this by using ImageMagick to split my large heightmap (as a .r16 file) into 64 smaller chunks (using the method described here), which I then rename using a little python script into the terrain-x0_y0.r16 format I’ve seen used in the wiki for the “Import Tiled Landscape” button.

I then try and use that button, but when I try to select the terrain-x#_y#.r16 files, I don’t see any change in the “Import Tiled Landscape” window, other than a slight increase in width.

154db3bb5e.jpg

I tried adding the sections manually with a larger division (4 chunks), but I’m getting some weird issues where the edges of the terrains don’t match up properly:

3dd1b240cc.jpg

Am I missing something obvious here? (I’ve never done much with large terrains before).

I…kind of got it.

So a major issue was resolution - rather than looking up supported heightmap resolutions, I assumed that they were powers of two plus one. Oops.

I fixed the resolution of my large heightmap, and made it 4040x4040, so I could then split it into 64 505x505 pieces, using the ImageMagick command (contained in a batch file):


convert -size 4040x4040 -endian LSB -depth 16 gray:output.raw -crop 8x8@ +repage -endian LSB -depth 16 gray:Tiled_RAW	errain_%%d.raw

Then I used a Python script to rename all those files:


import os

fncount = 0
countx = 0
county = 0
while county < 8:
    os.rename(("terrain_" + str(fncount) + ".raw"), ("terrain_x" + str(countx) + "_y" + str(county) + ".r16"))
    fncount += 1
    countx += 1

    if countx > 7:
        county += 1
        countx = 0


I could then import the heightmaps en masse, using the “Import Tiled Landscape” window. Success!

Until I realized that the heightmaps had a terracing effect (something I’ve noticed happening with 8-bit files, which confuses me) and didn’t line up properly.

I’m going to make my set-up more closely match the wiki tutorial by changing resolutions and matching settings. Hopefully that’ll work (and this process will save some other folks the $250 of upgrading to the higher tier of WorldMachine).

What do you mean by a “terracing effect”? Is there an unholy amount of terracing applied to the terrain that didn’t exist in WM? Import your heightmap straight from WM without tiled landscapes and see if the problem is still there. I’m going to guess that it’s being caused by ImageMagicK, probably by how it’s saving the files.

Adjacent heightmap tiles should have exactly same values on borders. For example last row in x0_y0 tile should match first row in x0_y1 tile. World machine has option for this “Share edge vertices”.

Resolution of a tile can be calculated like this:
ResolutionX = ComponetsNumXSectionNumXSectionQuadsNumX+1

ComponentsNumX = number of landscape components in a row
SectionNumX= number of sections per component row
SectionQuadsNumX= number of quads per section row

For example landscape tile with 8x8 components where each component has 1x1 sections and each section has 63x63 quads will have heightmap with resolution
8163 + 1 = 505x505.

There is a limited choice for number of sections and quads per section, you can find all possible values in landscape creation tool.

Try 16 bit greyscale.

It looks like ImageMagick is having some issues with maintaining the 16 bit values, which is unfortunate. “Unholy amount of terracing” is definitely an accurate statement.

Thanks for the info - since I don’t have access to tiling options in World Machine, I’ll have to figure out a way of slicing the heightmap accordingly. Just to be sure - if I’m following along with the wiki, I’d have 4x4 tiles of size 2017. Since they’re sharing vertices, I’d end up with a large heightmap of (2016x4)+1=8065.

I should hopefully be able to use the crop tool in Photoshop, then - I kind of wish it were possible to automate the slicing, given the number of crops I’ll be making, but honestly I’ll take what I can get :slight_smile:

After several failed attempts at other methods, I found Photoshop’s scripting reference.


var absoluteSavePath = "D:\\Users\\aszecsei\\Documents\\Tiled\\"

doc = app.activeDocument; 

var tiles = prompt("How many tiles do you want?", 4, "Tile Amount");
var tileSize = ((doc.height-1)/tiles)+1;
var tileOffset = tileSize-1;
for(var x=0; x<tiles; x++)
{
    for(var y=0; y<tiles; y++)
    {
        app.documents[0].duplicate();
        var bounds = [x*tileOffset, y*tileOffset, x*tileOffset + tileSize, y*tileOffset+tileSize];
        active = app.activeDocument;
        active.crop(bounds);
        saveOptions = new RawSaveOptions();
        active.saveAs(new File(absoluteSavePath + "tile_x" + x + "_y" + y + ".raw"), saveOptions, true);
        active.close(SaveOptions.DONOTSAVECHANGES);
    }
}

Imported everything in, and it all turned out nicely.

I’ll make a few edits to the code (make the “tile” name user-defined on run, figure out how to get relative save paths working, add a menu option) and release the plugin for anyone to use.