Water & Earth

Thus far, I’ve explained the basic premise of SagaSim and described how to generate a basic landscape through fractal noise. Now, it’s time to put that noise to work and create land masses!

One of the input parameters to the world generator is “water percentage.” Maybe you want a world that’s like Earth, where roughly 70% of the surface is covered by water. Maybe you want much more land, so you go down to 50%. Maybe you want no ocean at all, so you put in 0%. There is no point in putting in 100%, though, since it means no biomes or climate data would be generated (sorry.) Anyway, let’s start with 70%. I’m generating a larger map this time, so you can really see the features of the landscape.

basic noise map

Perlin noise before any additional processing.

Where does the land end and the water begin? You can’t tell from this map. Instead, I have an algorithm that “normalizes” the map. What it does is go through each pixel, put it in an array (a list), and then it slices the array at whatever point you entered as your water percentage. So, if you chose 70% and had an image that’s 10,000 pixels in total (100×100), the value of the pixel at index 7000 would represent our new “base” color. All pixels below that will be turned to black, then all the pixels above index 7000 get adjusted. Since the sea level value will likely be some shade of gray, and we’re turning it into black, we therefore need to tweak all the lighter-colored pixels so that they now start just one shade above black. In computer graphics parlance, this is known as “stretching the histogram.” Let’s see what the map looks like after this processing has been done:

normalized noise map

Map after normalizing the sea level.

Now, the locations of land masses are much clearer. But the world generator takes one more step to make clear the distinction between ocean and land: it creates a “mask” where all land is white, and all water is black. That way, it’s never ambiguous as to whether a given pixel is meant to be land or ocean. (Rivers are another story, and will be covered in a future post.)

water mask

Map converted to water mask. White is land, black is water.

Much clearer, isn’t it? You can also see that there are five distinct continents, as well as some smaller islands. Here are a few more water masks to illustrate the variety of landforms you can get just by tweaking some of the world generation parameters:

water mask example

Water mask generated from 0.2 persistence, 4 octaves, lacunarity of 8, 70% water coverage.

water mask example

Water mask generated from 0.8 persistence, 8 octaves, lacunarity of 2, 30% water coverage.

water mask example

Water mask generated from 0.2 persistence, 4 octaves, lacunarity of 16, 50% water coverage.

As you can see, there’s plenty of variety to be had by messing with the world generation parameters.

So, now we’ve got our land and oceans set up. Next time, we move on to terrain and climate!

Leave a Reply

Your email address will not be published.

* Copy This Password *

* Type Or Paste Password Here *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge