0

As the title suggests I want to use perlin noise to make a randomly generated terrain using tiles that I have made with a pixel width of 32x32, I've had a little look at perlin noise but it seems very confusing and it would be great if anyone could point me into a good direction

I'll give some details into what i want to add into the game if that is needed

it will be a sort of like Minecraft game but topdown 2d, it will have the normal stuff like grass, water, sand, dirt, trees, bushes, rocks, forests, maybe already made structures? like towns or something but that would probably be used with a different type of noise I would think

Hopefully all that helps and thank you for any help you can give!

Dylan Roff
  • 11
  • 2

2 Answers2

1

I'll simplify your case to a black/white example where your map only consists of two types of tiles, e.g. grass and sand.

Now you can go over your map and determine for every tile if it should be sand or grass by sampling the noise function at the position of the tile; if your noise creates values in the range [0, 1] you could just split it in the middle and say every tile with a value below .5 is sand, every other tile is grass.

Now a next step to consider is how to handle edges. There are two possibilities to take here.

Addendum: I think Unity has out-of-the-box solutions for this, but in case you want or have to implement it yourself:

1. Option: Have tiles for every neighbour-combination: If you look at this tileset from Pokemon, you see in the top left corner a sand tile. This can be used in case all eight neighbours are also sand. Next to it is a tile with a grass edge on the left. This can be used for the case that all three left neighbours are grass, like this:

And that pattern goes on. you basically have a tile option for every 8² possible neighbour-combinations. (Note that Pokemon does not have all combinations).

Also notable here is that you have a clear 'background'-tile. In Pokemons case the grass. The edges are drawn onto the sand tiles.

2. Option: Have tiles for in between your sampled points. This is called Wang-Tiles, more details here.

Adding more than two types of tiles

If you want more than two types of tiles you have also multiple options.

1. Option: Multiple tile types from one noise function. You could sample your noise function kind of like a heightmap and say everything below .2 is water, everything between .2 and .3 is sand, between .3 and .8 is grass and above .8 is snow. This just uses one noise function, so it is rather simple, but you will likely recognize the layers (meaning snow will never be generated next to sand or water).

2. Option: A multi-noise biome system (like minecraft does if I'm not mistaken). You can e.g. use two separate noise functions to sample temperature and precipitation (again, like minecraft if I'm not mistaken) and then look up the value on a chart to determine the biome (which can determine the ground tile type). Here is an example of such a biome map:

biome chart

3. Option: This is just a placeholder to tell you that there are other (infinite) ways to determine the floor texture for your game. Have a look at my collection of resources, I'm sure you'll find something there.

Mix your methods!

In the end what you probably want to go for is complex logic to determine your ground type. Mix and match the methods you find. E.g. use some biome map, but additionally a height map to determine where water is. Or add another noise layer that determines corruption from an evil force. Or you have a separate noise functions for vegetation. The possibilities are endless.

Ardor
  • 154
  • 11
0

I found it really useful to use perlin noise for terrain generation and a manhattan style voronoi diagram for biomes/environments

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 20 '23 at 23:11