示例#1
0
        static float FBM(float x, float z, float offset, int octaves, float pers) // creates fractal brownian motion with PerlinNoise
        {
            float total     = 0;
            float frequency = 1;
            float amplitude = 1;
            float maxValue  = 0;

            for (int i = 0; i < octaves; i++)
            {
                total     += Noise.Generate((x + offset) * frequency, (z + offset) * frequency) * amplitude;
                maxValue  += amplitude;
                amplitude *= pers;
                frequency *= 2;
            }
            return(total / maxValue);
        }
示例#2
0
 public static float TreeGeneration(Vector2 position, float offset, float scale)
 {
     return(Noise.Generate((position.x + 0.1f) / Chunk.chunkSize * scale + offset, (position.y + 0.1f) / Chunk.chunkSize * scale + offset));
 }
示例#3
0
 public static int GetNoise(int x, int y, int z, float scale, int max)
 {
     return(Mathf.FloorToInt((Noise.Generate(x * scale, y * scale, z * scale) + 1f) * (max / 2f)));
 }