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.
Math.Lerp
would look like:lerp = (height1, height2, distance) => { return (1 - t) * a + t * b; }
\$\endgroup\$ – Derk Jan Speelman Aug 28 '19 at 21:30