用于确定到底哪些地方是沼泽或森林 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18private float[,] GenerateNoiseMap(int width,int height,float lacunarity,int seed)
{
Random.InitState(seed);
//如果lacunaryity是整数会生成重复的值
lacunarity += 0.1f;
//噪声是为了顶点服务的
float[,] noiseMap = new float[width-1,height-1];
float offsetX = Random.Range(-10000f, 10000f);
float offsetY = Random.Range(-10000f, 10000f);
for (int x = 0; x < width - 1; x++)
{
for (int y=0;y<height -1;y++)
{
noiseMap[x, y] = Mathf.PerlinNoise(x*lacunarity+offsetX,y*lacunarity+offsetY);//对应坐标的噪声值
}
}
return noiseMap;
}