following my previous post on random world map generation, I used several algorithms and obtained results similar to this: https://i.stack.imgur.com/YG26W.png (the height values are quantisied for viewing but they go from 1 to 500 before quantisation). Now I am trying to improve the "lakes", as you can see, the water bodies that are inside the map are always at 0 altitude, which means that every lake would be at the ocean level. I am willing to keep these "ocean-level lakes" (or remove them), but I would like suggestion on how to create from this heightmap real lakes that would be possibly at any height, while keeping most of the altitude structure (ie mountains positions, etc)



2 Answers 2


I don't think you really understand what you've generated here. You've created a height map. The colors only indicate how high or low something is. Blue could signify sea water level, but if you don't want to it doesn't have too. If you want lakes that are above sea level then you simply have to pick an area that is enclosed by higher ground and make water there.

  • 1
    \$\begingroup\$ I even deleted my answer. I come from a mathematical/physics way of thinking and my solution over-complicated the problem. Since you are creating the terrain, it's a waste of resources to find lake points after creation when you can just make them from start. \$\endgroup\$
    – Diego
    Oct 22, 2011 at 13:55

Assuming that's a terrain map and not a heightmap you've generated (since I see what looks like sand, grass, snow, rock)...

See AmitP's page on procedural terrain generation. He goes into this in some detail. Of course, he doesn't use Perlin noise, but a different approach. However, the general idea is the same: You need to determine the straight skeleton, which is like an edge-centroid for a non-convex polygon such as your landmass. There are a number of ways you can go about the general idea though. Given that you have a Perlin noise bitmap, you might simply detect any land-based pixels, and determine their distance from the nearest pixel of the ocean water body only (not lakes). Then you will know where the "spine" of the island should lie. Using that information, you can evaluate inland lakes individually and modify the perlin noise map accordingly to create height gradients. Only once you have done this, will you be able to set your lake's water surface levels.

You don't have to throw this approach away. But you will need to do a whole lot more work if you want to turn this into a height map. Usually, Perlin is used to generate the heightmap, as such, and you produce the terrain types from there. But nothing says you can't do it the other way around (again, see straight skeleton formation). This would involve:

  1. Use your existent terrain bitmap to generate a heightmap which is greyscale only. At this stage, you will only have two colours: Black, and one shade of grey. Your one shade of gray would represent a single uniform height across your island, black would represent the sea.
  2. Using the straight skeleton, determine distance from the shore per grey pixel, and change the shade of grey to set it's height accordingly (i.e. distance from beach is very low and is a very dark gray, almost black, whereas pixels close to the spine are white).
  3. You'd then need to perturb each one up or down slightly (darker or lighter shade of white) to get a more organic feel to the whole terrain.

All in all, I agree with RoyT -- It's not so easy to use what you have done as a heightmap, only as a terrain/biome map.

Re getting lake surfaces at correct heights, there are more realistic (and more complex) approaches. Fluid dynamics approaches such as cellular automata could get you a lot further in this regard.

  • \$\begingroup\$ Sorry but it is an height-map, I just added colors that represent the potential terrain \$\endgroup\$
    – lezebulon
    Oct 22, 2011 at 12:53
  • 3
    \$\begingroup\$ Why focus on lake "surfaces"? Instead, look at all the randomly generated "anti-peaks"/falls in the terrain that are complete (ie. no way for the water to escape), and fill them all with water. That's how nature makes lakes. In any climate other than really dry ones (where it evaporates before the body becomes big enough), water will gather where it lays still, and if there naturally occuring "pots", most likely it will have water in it. \$\endgroup\$
    – Tor Valamo
    Oct 23, 2011 at 18:25
  • \$\begingroup\$ @TorValamo 'Why focus on lake "surfaces"?' Because that's what the OP asked about before editing his/her post ;) Dr Evil pinky-to-mouth gesture \$\endgroup\$
    – Engineer
    Oct 25, 2011 at 12:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .