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); }
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)); }
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))); }