public OverworldGeneratorV2() { Preset = new WorldGeneratorPreset(); //Preset.BiomeSize = 1f; //Preset = JsonConvert.DeserializeObject<WorldGeneratorPreset>("{\"coordinateScale\":175.0,\"heightScale\":75.0,\"lowerLimitScale\":512.0,\"upperLimitScale\":512.0,\"depthNoiseScaleX\":200.0,\"depthNoiseScaleZ\":200.0,\"depthNoiseScaleExponent\":0.5,\"mainNoiseScaleX\":165.0,\"mainNoiseScaleY\":106.61267,\"mainNoiseScaleZ\":165.0,\"baseSize\":8.267606,\"stretchY\":13.387607,\"biomeDepthWeight\":1.2,\"biomeDepthOffset\":0.2,\"biomeScaleWeight\":3.4084506,\"biomeScaleOffset\":0.0,\"seaLevel\":63,\"useCaves\":true,\"useDungeons\":true,\"dungeonChance\":7,\"useStrongholds\":true,\"useVillages\":true,\"useMineShafts\":true,\"useTemples\":true,\"useMonuments\":true,\"useRavines\":true,\"useWaterLakes\":true,\"waterLakeChance\":49,\"useLavaLakes\":true,\"lavaLakeChance\":80,\"useLavaOceans\":false,\"fixedBiome\":-1,\"biomeSize\":8,\"riverSize\":5,\"dirtSize\":33,\"dirtCount\":10,\"dirtMinHeight\":0,\"dirtMaxHeight\":256,\"gravelSize\":33,\"gravelCount\":8,\"gravelMinHeight\":0,\"gravelMaxHeight\":256,\"graniteSize\":33,\"graniteCount\":10,\"graniteMinHeight\":0,\"graniteMaxHeight\":80,\"dioriteSize\":33,\"dioriteCount\":10,\"dioriteMinHeight\":0,\"dioriteMaxHeight\":80,\"andesiteSize\":33,\"andesiteCount\":10,\"andesiteMinHeight\":0,\"andesiteMaxHeight\":80,\"coalSize\":17,\"coalCount\":20,\"coalMinHeight\":0,\"coalMaxHeight\":128,\"ironSize\":9,\"ironCount\":20,\"ironMinHeight\":0,\"ironMaxHeight\":64,\"goldSize\":9,\"goldCount\":2,\"goldMinHeight\":0,\"goldMaxHeight\":32,\"redstoneSize\":8,\"redstoneCount\":8,\"redstoneMinHeight\":0,\"redstoneMaxHeight\":16,\"diamondSize\":8,\"diamondCount\":1,\"diamondMinHeight\":0,\"diamondMaxHeight\":16,\"lapisSize\":7,\"lapisCount\":1,\"lapisCenterHeight\":16,\"lapisSpread\":16}"); // Preset = JsonConvert.DeserializeObject<WorldGeneratorPreset>( // "{\"useCaves\":true,\"useStrongholds\":true,\"useVillages\":true,\"useMineShafts\":true,\"useTemples\":true,\"useRavines\":true,\"useMonuments\":true,\"useMansions\":true,\"useLavaOceans\":false,\"useWaterLakes\":true,\"useLavaLakes\":true,\"useDungeons\":true,\"fixedBiome\":-3,\"biomeSize\":4,\"seaLevel\":63,\"riverSize\":4,\"waterLakeChance\":4,\"lavaLakeChance\":80,\"dungeonChance\":8,\"dirtSize\":33,\"dirtCount\":10,\"dirtMinHeight\":0,\"dirtMaxHeight\":255,\"gravelSize\":33,\"gravelCount\":8,\"gravelMinHeight\":0,\"gravelMaxHeight\":255,\"graniteSize\":33,\"graniteCount\":10,\"graniteMinHeight\":0,\"graniteMaxHeight\":80,\"dioriteSize\":33,\"dioriteCount\":10,\"dioriteMinHeight\":0,\"dioriteMaxHeight\":80,\"andesiteSize\":33,\"andesiteCount\":10,\"andesiteMinHeight\":0,\"andesiteMaxHeight\":80,\"coalSize\":17,\"coalCount\":20,\"coalMinHeight\":0,\"coalMaxHeight\":128,\"ironSize\":9,\"ironCount\":20,\"ironMinHeight\":0,\"ironMaxHeight\":64,\"goldSize\":9,\"goldCount\":2,\"goldMinHeight\":0,\"goldMaxHeight\":32,\"redstoneSize\":8,\"redstoneCount\":8,\"redstoneMinHeight\":0,\"redstoneMaxHeight\":16,\"diamondSize\":8,\"diamondCount\":1,\"diamondMinHeight\":0,\"diamondMaxHeight\":16,\"lapisSize\":7,\"lapisCount\":1,\"lapisMinHeight\":0,\"lapisMaxHeight\":32,\"coordinateScale\":684,\"heightScale\":684,\"mainNoiseScaleX\":80,\"mainNoiseScaleY\":160,\"mainNoiseScaleZ\":80,\"depthNoiseScaleX\":200,\"depthNoiseScaleZ\":200,\"depthNoiseScaleExponent\":0.5,\"biomeDepthWeight\":1,\"biomeDepthOffset\":0,\"biomeScaleWeight\":1,\"biomeScaleOffset\":1,\"lowerLimitScale\":512,\"upperLimitScale\":512,\"baseSize\":8.5,\"stretchY\":12,\"lapisCenterHeight\":16,\"lapisSpread\":16}");; int seed = Environment.TickCount; InitBiomeProviders(seed); for (int i = 0; i < SimplexInstanceCount; i++) { this._simplexNoiseInstances[i] = new SimplexPerlin(seed + i, NoiseQuality.Fast); } for (int i = 0; i < CellularInstanceCount; i++) { this._cellularNoiseInstances[i] = new SpacedCellularNoise(seed + i); } // BiomeList = new BiomeBase[256]; for (int i = 0; i < _weightings.Length; i++) { _weightings[i] = new float[256]; } for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { float limit = MathF.Pow((56f * 56f), 0.7F); for (int mapX = 0; mapX < SampleArraySize; mapX++) { for (int mapZ = 0; mapZ < SampleArraySize; mapZ++) { float xDist = (x - (mapX - SampleSize) * 8); float zDist = (z - (mapZ - SampleSize) * 8); float distanceSquared = xDist * xDist + zDist * zDist; float distance = MathF.Pow(distanceSquared, 0.7F); float weight = 1f - distance / limit; if (weight < 0) { weight = 0; } _weightings[mapX * SampleArraySize + mapZ][x * 16 + z] = weight; } } } } var totalBiomes = BiomeProvider.Biomes.ToArray(); BeachBiome = new bool[256]; LandBiome = new bool[256]; OceanBiome = new bool[256]; foreach (var biome in totalBiomes) { BeachBiome[biome.Id] = ((biome.Type & BiomeType.Beach) != 0);// || ((biome.Type & BiomeType.River) != 0); LandBiome[biome.Id] = (biome.Type & BiomeType.Land) != 0; OceanBiome[biome.Id] = (biome.Type & BiomeType.Ocean) != 0; } // BeachBiome = totalBiomes.Select(x => (x.Type.HasFlag(BiomeType.Beach))).ToArray(); // LandBiome = totalBiomes.Select(x => (x.Type.HasFlag(BiomeType.Land))).ToArray(); // OceanBiome = totalBiomes.Select(x => (x.Type.HasFlag(BiomeType.Ocean))).ToArray(); }
public NoiseProvider(WorldGeneratorPreset generatorPreset, int seed) { GeneratorPreset = generatorPreset; Seed = seed; FastRandom = new FastRandom(seed); var mainLimitNoise = new SimplexPerlin(seed + FastRandom.Next(), NoiseQuality.Fast); var mainLimitFractal = new LibNoise.Filter.MultiFractal() { Primitive3D = mainLimitNoise, Primitive2D = mainLimitNoise, Frequency = MainNoiseFrequency, OctaveCount = 4, Lacunarity = MainNoiseLacunarity, Gain = MainNoiseGain, SpectralExponent = MainNoiseSpectralExponent }; TerrainNoise = new ScaleableNoise() { XScale = 1f / GeneratorPreset.CoordinateScale, YScale = 1f / GeneratorPreset.HeightScale, ZScale = 1f / GeneratorPreset.CoordinateScale, Primitive3D = mainLimitFractal, Primitive2D = mainLimitFractal }; //turbulence; var baseHeightNoise = new SimplexPerlin(seed + FastRandom.Next(), NoiseQuality.Fast); var fractal = new Voronoi() { Primitive2D = new ScaleableNoise() { Primitive2D = baseHeightNoise, XScale = 1f / GeneratorPreset.CoordinateScale, ZScale = 1f / GeneratorPreset.CoordinateScale }, OctaveCount = 1, Frequency = 1.295f, SpectralExponent = 0.25f //Distance = true // Distance = false }; BaseHeightNoise = new ScaleableNoise() { Primitive2D = fractal, XScale = 1f / 8f, ZScale = 1f / 8f }; var depthNoise = new SimplexPerlin(seed + FastRandom.Next(), NoiseQuality.Fast); var depthNoiseFractal = new RidgedMultiFractal() { Primitive2D = depthNoise, Primitive3D = depthNoise, Frequency = DepthFrequency, Lacunarity = DepthLacunarity, Gain = DepthNoiseGain, OctaveCount = 2, SpectralExponent = (float)GeneratorPreset.DepthNoiseScaleExponent }; DepthNoise = new ScaleableNoise { Primitive2D = depthNoiseFractal, Primitive3D = depthNoiseFractal, XScale = 1f / GeneratorPreset.MainNoiseScaleX, YScale = 1f / GeneratorPreset.MainNoiseScaleY, ZScale = 1f / GeneratorPreset.MainNoiseScaleZ }; var rainSimplex = new SimplexPerlin(seed + FastRandom.Next(), NoiseQuality.Fast); var rainVoronoi = new WorldGenerator.Utils.Noise.Voronoi { Primitive3D = rainSimplex, Primitive2D = rainSimplex, Distance = false, Frequency = RainFallFrequency, OctaveCount = 2 }; var biomeScaling = (32.3345885f) * GeneratorPreset.BiomeSize; var rainNoise = new WorldGenerator.Utils.Noise.ScaleableNoise() { Primitive2D = rainVoronoi, Primitive3D = rainVoronoi, XScale = 1f / biomeScaling, YScale = 1f / biomeScaling, ZScale = 1f / biomeScaling }; // GeneratorPreset.bi IModule2D tempSimplex = new SimplexPerlin(seed + FastRandom.Next(), NoiseQuality.Fast); var tempVoronoi = new WorldGenerator.Utils.Noise.Voronoi { Primitive2D = tempSimplex, Distance = false, Frequency = TemperatureFrequency, OctaveCount = 2, SpectralExponent = 0.25f }; /*var tempNoise = new ScaleableNoise() * { * Primitive2D = tempVoronoi, * Primitive3D = tempVoronoi, * XScale = 1f / biomeScaling, * YScale = 1f / biomeScaling, * ZScale = 1f / biomeScaling * }; */ TempNoise = new ScaleableNoise() { Primitive2D = tempVoronoi, // Primitive3D = tempSimplex, XScale = 1f / biomeScaling, YScale = 1f / biomeScaling, ZScale = 1f / biomeScaling }; RainNoise = rainNoise; }