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\$
  • \$\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 Mar 7 '16 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\$ – Josh Mar 8 '16 at 19:19
15
\$\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\$
  • \$\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\$ – The Great Duck Apr 1 '17 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.