# unity – Blending Biomes in Procedural terrain generation

I’ve recently picked up procedural generation and it’s been going great – until I decided to give Biomes a shot. With my current setup, I can assign a specific point in my world a biome based on its current height in a “global” biome noise generated with Simplex. The issue i’m having (and many others it seems) is to blend these biomes with eachother – while still being able to decide what goes where.

I tried blending it on my own by simply generating a height with a weight-value that could help with blending a biome with its neighbor. I calculated the weight by getting the distance normalized in a 0 to 1 scale, using this as a percentage. So if the “heaviest” biome had a weight of 0.8, the other neighboring biome would then have 0.2.

``````float totalHeight = (mainBiome * weight) + (otherBiome * (1f - weight));
``````

However this didn’t work out as I still got cliff-like borders between different height biomes.

Then I found an algorithm at Parzivail.com that actually worked perfectly in blending a biome with its surrounding biomes. The only issue is that it’s pretty much only based on the index of my biomes-array.

``````float totalHeight = 0.0f;
float n = biomes.Length;
for (int i = 0; i < n; i++)
{
float left = (i - 1f) / (n - 1);
float right = (i + 1f) / (n - 1);
if (left < noiseHeight && noiseHeight < right)
{
var layer = biomes(i);
float w = -Mathf.Abs((n - 1) * noiseHeight - i) + 1f;

layer.Evaluate(x, y, sampleCenter);

totalHeight += w * layer.Height;
layer.Weight = w;
}
}
``````

(desmos.com visualization)

I’ve tried modifying it in order to determine biomes based on temperaute and not only height, but whatever I do seems to bring the cliffs back.

Current implementation with seamless transition

How would I change my way of doing this, so I could set up the placement of biomes in a better way and not be forced to use my array indexes?