I'm going to use Perlin noise to generate some terrain for a sidescroller.
I'm not going to explain exactly how Perlin noise works since I'm too lazy, I'm not an expert, and there's many pages about it on the internet.
Basically, Perlin noise is like a random number generator, except it has a pattern. That might have been a bad explanation. It's been used to generate things like clouds, heightmaps, etc. 3D Perlin noise has been used for Minecraft.
In my situation I'm going to use 2D Perlin noise. Here's a result:
This might be usable in some top-down exploration game or an expansive cave game, but this is not what I want. I want a fairly clear ground, meaning the bottom would be more solid. To do this I incorporate something along with Perlin noise: a bias that depends on the y-value, or altitude. I simply do something like add "- y" to the code so it'll be like:
value = noise - y
meaning the less y is, or the lower the altitude, the more likely the value will be solid (positive).
A result:
That's more like it. You can multiply the bias to have "chaotic" or "controlled" terrain.
Scale the bias by 0.1 (less bias):
See the floating island? That's basically what caused the ones in Minecraft.
In contrast, scale the bias by 10 (more bias):
Now it's more boring...that's familiar...
To create even more of a variety of terrain roughness, you can combine different noise octaves, which you can read somewhere else.
.png)
.png)
.png)
.png)
No comments:
Post a Comment