How to make your own floating island – Dev Blog 28

Another Friday arrives, and another blog post is added to the growing collection we have here. This week we have been working on a couple of as yet announced features, as well as heavily looking into performance optimisations – it’s been a very productive week, framerate is up and memory footprint is down. So while we are not quite ready to talk about the unannounced features, let us talk about terrain generation in Fringe Planet.

Floating island

We have spoken in detail about the floating mini biomes, as well as how ores are seeded through out the island. But how do we generate the floating island that your peons will call home? The floating island creation process has two main stages – creating the top, then creating the underside of the island. Both of these have certain stages, which we shall go into detail here.  The more observant readers will notice how the floating islands in the various screenshots look very similar – this is because everything is done via procedural generation, and to speed up development we use the same seed (a number that is used to create everything) over and over. This allows us to cache the terrain for super fast load times as well as providing a consistent landscape for bug testing.

The Top

The top

The first step, should be familiar to anyone who has ever looked into procedural generation. We create a heightmap using the diamond square algorithm. This algorithm can be described very simply – first you create a grid of points, and in each one of the grid’s corners you pick a random number. Then you take the middle point, and that is the average of all four corners (with a slight random offset). Then you divide that grid into four more grids and repeat the process – but instead of picking random numbers, you use the already picked numbers (as well as a small random offset). Once you’ve done this four times you repeat this process over and over again (with the grid getting smaller every single time) until every point on the grid has a number associated with it. Each and every number on the grid now refers to the height of an imaginary landscape.  It’s very easy to visualise this data, by normalising it to a value between 0 and 255 and assigning it to a colour channel. For example, a pixel in the image below with a value of 0 would indicate the lowest possible point on the map. A full bright value of 255 would indicate the highest point on the map. We use green to illustrate this, because green just happens to be our favourite colour!

Height map from the diamond square algorithm

You will notice that the top left of the image has brighter shades of green than bottom middle of the image – this indicates that the top left is much higher than the bottom middle.  This is the raw landscape that will become the top of the floating island. There are a couple of things that we will do to this heightmap to make it more appropriate for Fringe Planet. By design, the majority of islands should have some relatively flat ground in the middle, and it’s nice if that the flat land is surrounded by hills (to protect from the wind) – so we generate an “offset map”.  This offset map is procedurally generated as well (so it’s never quite the same). An “offset amp” will look something like this:

Offset map

There is just one more map to create now, and this will be used to generate both the top and the underneath. This is the “erosion map” – again it is procedurally generated. This is used along the edges of the island to give a slightly rocky, but natural looking edge – avoiding straight lines. This erosion map looks something like this :

Erosion mapTaking these three images we can produce the top side of the island. We add the offset map to the height map and then subtract the erosion map (remember, every shade of green is a number between 0 and 255, so instead of images these are grids of numbers). When do that we end up with an image that will look like this :

All combined maps for the top of the island

This image will form the heightmap for the top of our island.

The Underside

The Underside

The underside is a radically different landscape to what is on top. Rough stalactites protrude out, cracked land creates an uneven surface, chunks of smooth material seem to be have been eroded by some process. Some huge gaps exist either due to impacts or material simply breaking away somehow. It’s completely unlike anything you would find on Earth. However, the steps to create it are very similar to how we produced the top of the island.  Firstly we create a new heightmap – however we normalise this one so the values between 0 and 31 instead of 0 and 255. This gives us a much smoother heightmap. Then we create the “spike map” – this is created using perlin noise and a preset number of sharp spikes, and smooth hills (all using the seed mentioned before).

Spike map

Where the green rapidly gets brighter (just below the top left corner, for instance) this shows us a spike, the paler and darker smoother spots represent the smoother hills.  Combining these two images, gets us this incredibly bright image :

Once we have this data, we use the same erosion map used on the top so that both the underside and the top of the island are the same shape and size. Due to the way our voxel engine works, this image is removed from the voxels under the island (greener = more voxels removed from the bottom, darker indicates less removed).  With both of these parts now complete, we have the shape of our floating island.

The Result

A blank slate

We now have a floating islands full of a special voxel type that indicates it hasn’t been processed yet. The next step is too determine where soil, fertile soil, sand and rock goes. Once that has done we will populate the island with the various ores. You can read more about the ores in this blog post.

 

There is a lot more to read about Fringe Planet… why not try:

Leave a Reply

Your email address will not be published. Required fields are marked *