-1

I am trying to get a natural looking landscape like the game Terraria. I use a cellular automaton to generate caves and 1d Perlin noise for surface. The result is something like this: my prototype

But this is not satisfactory to me because the original goal was to get something like that: what i want to get

I know that in the second case, Perlin noise is also used, but I have absolutely no idea how to achieve exactly this. Can someone suggest how I can achieve the second case with Perlin noise or not and/or give appropriate links on this topic ?

Makc 22999
  • 3
  • 1
  • 2

1 Answers1

0

What I would do:

  1. Use Simplex not Perlin for your 2D noise. Simplex avoids a lot of the visible grid alignment characteristic of Perlin. You can see in this image, that the Perlin on the top follows 45 and 90 degree directions a lot. The noise I created/use/recommend would be this, specifically the Noise2_XBeforeY function since it has the triangle grid rotated to try to look best for a Terraria-style game. (EDIT: Since you are using Python, you could use this)

  2. Start with abs(noise(frequency*x, frequency*y)) < threshold ? cave : leave_solid. Adjust frequency threshold until they produce the desired size/distribution.

  3. Improve the shape and variation of caves by using fractal noise. abs(noiseA(frequency*x, frequency*y) + noiseB(2*frequency*x, 2*frequency*y)*0.5 + ...) < threshold ? cave : leave_solid

  4. Compare against the height to make the caves get smaller as you go up. Replace threshold with some function of how far underground you are, e.g. threshold = f(height(y) - y), where f(t) = something like t / (t + 1). Notice how height(y) - y gets bigger the further underground you are (assuming Y goes negative as you go down), and t / (t + 1) preserves the increasingness but smoothly prevents it from exceeding 1. f(t) = t / (t + 1) probably won't work on its own, so you'll probably need to generalize it like f(t) = thresholdMax * t / (thresholdIncreaseRate * t + 1). Pick values for thresholdMax and thresholdIncreaseRate which suit your purposes best.

KdotJPG
  • 811
  • 4
  • 6