# How to merge 2D biomes?

I'm making a map generation script which generates different biomes: "land", "beach", "ocean" using perlin noise but the problem is that each biomes is at different heights for example i use

height = (int)PerlinNoise (seed,x,90,10,15); //for land
height = (int)PerlinNoise (seed,x,70,10,5); //for beach
height = (int)PerlinNoise (seed,x,20,10,35); //for ocean


This is the method:

float PerlinNoise( int seed, float x, float height, float scale, float roughness){
Vector2 originPoint = new Vector2 ((seed + mapSize.x / 2) * roughness / mapSize.x, 0);

float xCoord = (seed + x) * roughness / mapSize.x;

return (Mathf.PerlinNoise (xCoord, 0) * scale) + height;
}


But my problem is merging between biomes, when i generate the terrain each biome just jumps down/up to the required height how can i fix this? I've tried using a lerp function but the map is generated left-right. Is there a way i can implement this in the PerlinNoise method so that if i supply the previous height and a weight it returns the next height as if the biomes where going to merge.

• You could define biome-centers or biome-chunks and then linearly interpolate between those points: float height = Math.Lerp(height1, height2, distance) – Vengarioth Nov 30 '16 at 10:19
• You should be sampling the same noise data, not one for each biome type. Take a look at jgallant.com/… – jgallant Nov 30 '16 at 10:20
• Possible duplicate: gamedev.stackexchange.com/questions/55712/… – MichaelHouse Nov 30 '16 at 15:14