0
\$\begingroup\$

I'm creating a little terraria-like 2D side-scroller game with TypeScript. Currently, I divide parts of the world into biomes, which each have their own properties (flat, mountainous terrain, etc.). I am using a one dimensional Perlin noise to generate the height of the terrain for each biome. Currently this is a problem for me because the borders between biomes are not at the same height. How could I make the transitions between biomes smoother?

Thank you in advance for your answers enter image description here

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Does this answer your question? How to blend biomes with procedural terrain \$\endgroup\$
    – Tyyppi_77
    Jun 28 at 10:27
  • \$\begingroup\$ I'm not sure ... technically speaking, I'd like to know if it's possible to locally add octaves to a perlin noise? it could allows to have height variations per biome in a single perlin noise which would be smooth. \$\endgroup\$
    – Ekkaia
    Jun 28 at 12:35
1
\$\begingroup\$

Conceptually, to transition between the 2 biomes smoothly, you need 2 biomes and a transition weight. That is, you do not choose between just one of them, but generate both and interpolate between their features (such as height, temperature, savagery, etc). The weight used to interpolate is also generated (preferably with a (relatively) smooth function), therefore you'll need to sample 3 different noises at once and do some math over the values.

enter image description here

Notice a smooth transition, despite the biomes' differences in maximum height and height variability.

For properties that can't be interpolated, a value may be selected based on a threshold. For example, in many games a biome type is a categorical value, it has to be either one or another, not something in between. In that case, a simplest approach is to choose a biome with a biggest weight.

\$\endgroup\$
3
  • \$\begingroup\$ Thank you very much for your answer. Which smooth function should I use? \$\endgroup\$
    – Ekkaia
    Jul 1 at 21:42
  • \$\begingroup\$ @Ekkaia You want a function that keeps the weight high for the most part of the biome, but has a fall-off on the edges. I used sin(b*π)² in my example, where b is current position in the biome, value ranging between 0.0 to 1.0. This requires to know the real bounds of the biome though. If that's unknown, you'll have to rely on very smooth / low frequency noise, e.g. perlin(x * 0.01). \$\endgroup\$ Jul 1 at 22:36
  • \$\begingroup\$ Thank you for your answer! I found another way to do it thanks to a smooth cubic function. I did some tests on Codepen, if you want you can saw them here : codepen.io/Ekkaia/pen/abWbVVN?editors=0010 \$\endgroup\$
    – Ekkaia
    Jul 2 at 0:06

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.