So I'm trying to make a simplified Terraria style world using Perlin noise. I got that working and the terrain is randomized. However the terrain always looks like like a weird cosines curve. Hills and bottoms with different heights repeating. The effect I want to achieve is something similar to this:
Where the terrain is mostly flat looking and sometimes a large mountain will appear.
Is there an algorithm or "noise" that could achieve this effect or what other things do I need to do?
Answer
You want to mix different wave lengths with different levels of intensity.
E.G. Have one long wave, that has a high intensity, and a short wave with low intensity.
Now add the two(or more) waves together. Black line being long waves and high intensity.
Red line being short waves with low intensity.
Green being the final result.
float getHeight(float x) {
float longWave = getNoise(x / 100) * 20;
float shortWave = getNoise(x);
return longWave + shortWave;
}
Eventually add more waves, maybe using different noise algorithms. Play around with the values. To get more interesting results you could also try to multiply different wave lengths, make them exponential etc...
No comments:
Post a Comment