public FractalNoiseGenerator(FractalNoiseType noiseType, int seed, float frequency, float fractalGain, FastNoise.Interp interpolation, FastNoise.FractalType fractalType, int octaves, float lacunarity) { fastNoise = new FastNoise(seed); switch (noiseType) { case FractalNoiseType.Perlin: fastNoise.SetNoiseType(FastNoise.NoiseType.PerlinFractal); break; case FractalNoiseType.Simplex: fastNoise.SetNoiseType(FastNoise.NoiseType.SimplexFractal); break; case FractalNoiseType.Value: fastNoise.SetNoiseType(FastNoise.NoiseType.ValueFractal); break; } fastNoise.SetFrequency(frequency); fastNoise.SetFractalGain(fractalGain); fastNoise.SetInterp(interpolation); fastNoise.SetFractalType(fractalType); fastNoise.SetFractalOctaves(octaves); fastNoise.SetFractalLacunarity(lacunarity); }
public static ValueMap FractalNoise(int seed, Vector2Int size, Vector2 offset, FractalNoiseType noiseType, FastNoise.FractalType fractalType, int depth, float frequency = 0.02f) { var noise = new FastNoise(seed); noise.SetFractalType(fractalType); noise.SetFractalOctaves(depth); noise.SetFrequency(frequency); ValueMap output = ScriptableObject.CreateInstance <ValueMap>(); output.Initialize(size.x, size.y); for (int x = 0; x < size.x; x++) { for (int y = 0; y < size.y; y++) { float value = 0; if (noiseType == FractalNoiseType.Cubic) { value = noise.GetCubicFractal(offset.x + x, offset.y + y); } else if (noiseType == FractalNoiseType.Perlin) { value = noise.GetPerlinFractal(offset.x + x, offset.y + y); } else if (noiseType == FractalNoiseType.Value) { value = noise.GetValueFractal(offset.x + x, offset.y + y); } output[x, y] = value; } } return(output); }