public static FastNoise GetFastNoise(Chunk chunk) { int Octaves = int.Parse(Configuration.GetPropertyValue(AdvFeatureClass, "Octaves")); float Lacunarity = float.Parse(Configuration.GetPropertyValue(AdvFeatureClass, "Lacunarity")); float Gain = float.Parse(Configuration.GetPropertyValue(AdvFeatureClass, "Gain")); float Frequency = float.Parse(Configuration.GetPropertyValue(AdvFeatureClass, "Frequency")); FastNoise.FractalType fractalType = EnumUtils.Parse <FastNoise.FractalType>(Configuration.GetPropertyValue(AdvFeatureClass, "FractalType"), false); FastNoise.NoiseType noiseType = EnumUtils.Parse <FastNoise.NoiseType>(Configuration.GetPropertyValue(AdvFeatureClass, "NoiseType"), false); FastNoise fastNoise = new FastNoise(); fastNoise.SetFractalType(fractalType); fastNoise.SetNoiseType(noiseType); fastNoise.SetFractalOctaves(Octaves); fastNoise.SetFractalLacunarity(Lacunarity); fastNoise.SetFractalGain(Gain); fastNoise.SetFrequency(Frequency); fastNoise.SetSeed(chunk.GetHashCode()); var chunkPos = chunk.GetWorldPos(); String display = "Chunk and Seed: " + chunk.GetHashCode() + " Fractal Type: " + fractalType.ToString() + " Noise Type: " + noiseType.ToString() + " Position: " + chunkPos + " Octaves: " + Octaves + " Lacunarity: " + Lacunarity + " Gain: " + Gain + " Frequency: " + Frequency; AdvLogging.DisplayLog(AdvFeatureClass, display); return(fastNoise); }
public NoiseWrapper(FastNoise.NoiseType noiseType, FastNoise.FractalType fractalType, float frequency, float persistence, int octaves, int seed) { generator = new FastNoise(seed); generator.SetNoiseType(noiseType); generator.SetFractalType(fractalType); generator.SetFrequency(frequency); generator.SetFractalGain(persistence); generator.SetFractalOctaves(octaves); generator.SetFractalLacunarity(2.0f); }
public static (float[] map, float minVal, float maxVal) GetNoiseMap( int width, int height, float frequency, FastNoise.FractalType wormsMode, float sharpness, //bool isPerturbed, out FastNoise noise) { float[] map = new float[width * height]; noise = new FastNoise(WorldGen.genRand.Next()); noise.SetNoiseType(FastNoise.NoiseType.SimplexFractal); noise.SetFrequency(frequency); noise.SetFractalType(wormsMode); noise.SetFractalGain(sharpness); int coord; float min = 0, max = 0, val; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { coord = x + (y * width); val = noise.GetNoise(x, y); if (min > val) { min = val; } else if (max < val) { max = val; } map[coord] = val; } } return(map, min, max); }
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); }