I am developing a simple project using Java, for Android. It is a side-scroller with a procedurally generated, infinite world. Most of the generation will be working on underground but I expect the same principles would apply to features that would be above the ground.
I have 2 coordinates. X goes Left-Right and Y goes Up-Down. I have managed to generate a density map using Perlin. What I do is looping through X and Y values, putting them in a noise function, and evaluating the resulting float to decide whether to place a specific tile or not. I have successfully created a uniform tile distribution. However I need something a bit more specialized.
You see, in order to make this interesting, I need to place various resources (Coal, Iron, Silver, Gold) as well as monster spawns in the map. I am thinking that it would be more realistic to place different resources in different depth levels. So for example, I need coal to appear between Y = -20 and Y = -50, Iron between -40 and -100, ogre spawners between -40 and -300 etc.
However, if I set these boundaries with a simple if statement like:
if (y<-20 && y>-50) {
// Generate coal
noise = perlin.getnoise(x,y,7);
if (noise>=threshold) map.put(x,y,TILE_TYPE_COAL);
}
if (y<-40 && y>-100) {
// Generate iron
noise = perlin.getnoise(x,y,7);
if (noise>=threshold) map.put(x,y,TILE_TYPE_IRON);
}
This generates sharp edges between those boundaries, like this: https://i.sstatic.net/XJGLk.jpg
I need the noise to somehow generate resources that, when digging down, would gradually appear more often, and then gradually less so. Ease in and ease out.
For example, if I set the boundaries for coal to be between -20 and -50, most of the coal should appear in the middle of this ribbon, -35, while it should appear less in -20 and -50 levels. Perhaps I need a Gaussian distribution? I don't know where to start.
To put the question in a more mathematical form:
How do I manipulate the output of a Perlin noise function depending on one of the inputs (Y) in a non-abrupt, natural way, in order to gradually increase or decrease density for specific ranges of Y?
Thanks in advance