5
\$\begingroup\$

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:

enter image description here

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?

\$\endgroup\$
2
  • \$\begingroup\$ You could try layering your noise, or change the way you use your noise to determine height, you could, for example, generate a top-down heightmap and for each pixel remove it if the height is lower than the distance from the pixel to the bottom of the image. \$\endgroup\$
    – Niels
    Commented Mar 7, 2016 at 14:00
  • \$\begingroup\$ You've posted what you want but not what you have, which might help tailor the solutions to the specific issue you've got. \$\endgroup\$
    – user1430
    Commented Mar 8, 2016 at 19:19

1 Answer 1

14
\$\begingroup\$

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. enter image description here 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...

\$\endgroup\$
1
  • \$\begingroup\$ I would like to point out as well that the waves must be built so that their sum is not periodic as well. One way to accomplish this is to not have their periods be rational multiples of each other. \$\endgroup\$
    – user64742
    Commented Apr 1, 2017 at 21:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .