コード例 #1
0
ファイル: Program.cs プロジェクト: thedanieldude1/DanielCode
		public static IModule GetEarthModule(int seed, int resolution)
		{
			if(true) {
				double factor = 1.0/resolution;
				FastNoise Continentsprescale = new FastNoise(seed);
				Continentsprescale.Frequency = 1*factor;

				ScaleBiasOutput Continents = new ScaleBiasOutput(Continentsprescale);
				Continents.Scale = .65;
				Continents.Bias = .35;

				FastBillow LowLands = new FastBillow(seed);
				LowLands.Frequency = .4*factor;
				ScaleBiasOutput LowLandsScaled = new ScaleBiasOutput(LowLands);
				LowLandsScaled.Scale = 0.1;
				LowLandsScaled.Bias = 0.5;

				FastRidgedMultifractal Mountains = new FastRidgedMultifractal(seed);
				Mountains.Frequency = 1*factor;
				Mountains.Lacunarity = 2;
				Mountains.OctaveCount = 16;

				ScaleBiasOutput MountainsScaledpreturb = new ScaleBiasOutput(Mountains);
				MountainsScaledpreturb.Scale = 0.4;
				MountainsScaledpreturb.Bias = 0.85;
				//FastTurbulence MountainsFinal = new FastTurbulence(MountainsScaled)
				FastTurbulence MountainsScaled = new FastTurbulence(MountainsScaledpreturb);
				MountainsScaled.Frequency = 50*factor;
				MountainsScaled.Power = 0.1;
				FastNoise LandFilterprescale = new FastNoise(seed+1);
				LandFilterprescale.Frequency = .6*factor;
				ScaleBiasOutput LandFilter = new ScaleBiasOutput(LandFilterprescale);
				LandFilter.Bias = 0;

				Select LandFinal1 = new Select(LandFilter, LowLandsScaled, MountainsScaled);
				LandFinal1.SetBounds(0, 100);
				LandFinal1.EdgeFalloff = (.5);
				//AbsoluteOutput LandFinal = new AbsoluteOutput(LandFinal1);
				var LandFinal = new ScaleBiasOutput(LandFinal1);

				FastBillow Ocean = new FastBillow(seed);
				Ocean.Frequency = .5*factor;
				ScaleBiasOutput OceanScaled = new ScaleBiasOutput(Ocean);
				OceanScaled.Scale = 0.1;
				OceanScaled.Bias = 0.1;

				Select Final = new Select(Continents, new Constant(0), new Constant(1));
				Final.SetBounds(0, 100);
				//Final.EdgeFalloff=(0.5);
				Select Finalx = new Select(Continents, LandFinal, OceanScaled);
				Finalx.SetBounds(0, 100);
				//Finalx.EdgeFalloff=(0.5);
				Select Final2 = new Select(LandFinal1, new Constant(.5), new Constant(.3));
				Final2.SetBounds(0, 100);
				//Final2.EdgeFalloff = .5;
				Select Final3 = new Select(Finalx, Final, Final2);
				Final3.SetBounds(0, 100);
				var outpoot = /*new AbsoluteOutput*/new VoronoiRelaxed() { Frequency = 4*factor,RelaxationFactor=1 ,Seed=seed};	
				var fin = new Select(Continentsprescale, new Constant(-1), outpoot);
				fin.SetBounds(0, 100);		//Final3.EdgeFalloff = .5;
				//fin.EdgeFalloff=0.05;
				var zones = /*new VoronoiLarge(new VoronoiLarge(*/new VoronoiLarge(fin) { Frequency = factor*20, RelaxationFactor = .75 };//){Frequency=factor*8,RelaxationFactor=0}){Frequency=factor*16,RelaxationFactor=0};
				var fin2 = zones;
				return fin2;
			}
			else {
				double factor = 1.0/resolution;
				FastNoise fastPlanetContinents = new FastNoise(seed);
				fastPlanetContinents.Frequency = 1.5*factor;

				FastBillow fastPlanetLowlands = new FastBillow();
				fastPlanetLowlands.Frequency = 4*factor;
				LibNoise.Modifiers.ScaleBiasOutput fastPlanetLowlandsScaled = new ScaleBiasOutput(fastPlanetLowlands);
				fastPlanetLowlandsScaled.Scale = 0.2;
				fastPlanetLowlandsScaled.Bias = 0.5;

				FastRidgedMultifractal fastPlanetMountainsBase = new FastRidgedMultifractal(seed);
				fastPlanetMountainsBase.Frequency = 4*factor;

				ScaleBiasOutput fastPlanetMountainsScaled = new ScaleBiasOutput(fastPlanetMountainsBase);
				fastPlanetMountainsScaled.Scale = 0.4;
				fastPlanetMountainsScaled.Bias = 0.85;

				FastTurbulence fastPlanetMountains = new FastTurbulence(fastPlanetMountainsScaled);
				fastPlanetMountains.Power = 0.1;
				fastPlanetMountains.Frequency = 50*factor;

				FastNoise fastPlanetLandFilter = new FastNoise(seed+1);
				fastPlanetLandFilter.Frequency = 6*factor;

				Select fastPlanetLand = new Select(fastPlanetLandFilter, fastPlanetLowlandsScaled, fastPlanetMountains);
				fastPlanetLand.SetBounds(0, 1000);
				fastPlanetLand.EdgeFalloff = 0.5;

				FastBillow fastPlanetOceanBase = new FastBillow(seed);
				fastPlanetOceanBase.Frequency = 15*factor;
				ScaleOutput fastPlanetOcean = new ScaleOutput(fastPlanetOceanBase, 0.1);

				Select fastPlanetFinal = new Select(fastPlanetContinents, fastPlanetOcean, fastPlanetLand);
				fastPlanetFinal.SetBounds(0, 1000);
				fastPlanetFinal.EdgeFalloff = 0.5;
				return fastPlanetFinal;
			}
		}
コード例 #2
0
        public void Init()
        {
            int Seed = m.GetSeed();

            BiomeBase.Frequency = (0.2);
            BiomeBase.Seed = (Seed - 1);
            BiomeSelect = new ScaleBiasOutput(BiomeBase);
            BiomeSelect.Scale = (2.5);
            BiomeSelect.Bias = (2.5);
            mountainTerrainBase.Seed = (Seed + 1);
            mountainTerrain = new ScaleBiasOutput(mountainTerrainBase);
            mountainTerrain.Scale = (0.5);
            mountainTerrain.Bias = (0.5);
            jaggieEdges = new Select(jaggieControl, terrainType, plain);
            plain.Value = (0.5);
            jaggieEdges.SetBounds(0.5, 1.0);
            jaggieEdges.EdgeFalloff = (0.11);
            jaggieControl.Seed = (Seed + 20);
            baseFlatTerrain.Seed = (Seed);
            baseFlatTerrain.Frequency = (0.2);
            flatTerrain = new ScaleBiasOutput(baseFlatTerrain);
            flatTerrain.Scale = (0.125);
            flatTerrain.Bias = (0.07);
            baseWater.Seed = (Seed - 1);
            water = new ScaleBiasOutput(baseWater);
            water.Scale = (0.3);
            water.Bias = (-0.5);
            terrainType.Seed = (Seed + 2);
            terrainType.Frequency = (0.5);
            terrainType.Persistence = (0.25);
            terrainType2.Seed = (Seed + 7);
            terrainType2.Frequency = (0.5);
            terrainType2.Persistence = (0.25);
            waterTerrain = new Select(terrainType2, water, flatTerrain);
            waterTerrain.EdgeFalloff = (0.1);
            waterTerrain.SetBounds(-0.5, 1.0);
            secondTerrain = new Select(terrainType, mountainTerrain, waterTerrain);
            secondTerrain.EdgeFalloff = (0.3);
            secondTerrain.SetBounds(-0.5, 1.0);
            finalTerrain = new Select(jaggieEdges, secondTerrain, waterTerrain);
            finalTerrain.EdgeFalloff = (0.2);
            finalTerrain.SetBounds(-0.3, 1.0);
            flowers.Seed = (Seed + 10);
            flowers.Frequency = (3);

            // Set up us the Perlin-noise module.
            caveNoise.Seed = (Seed + 22);
            caveNoise.Frequency = (1.0 / cavessize);
            caveNoise.OctaveCount = (4);
        }
コード例 #3
0
ファイル: LibNoiseTests.cs プロジェクト: jimmylarkin/River
        private static void Run(int octaves, double persistence, double frequency, double lacunarity)
        {
            string fileName = string.Format("O{3}_P{0:N3}_F{1:N3}.png", persistence, frequency, lacunarity, octaves);
              Billow billow = new Billow();
              billow.Frequency = frequency;
              billow.NoiseQuality = NoiseQuality.High;
              billow.Seed = 0;
              billow.OctaveCount = octaves;
              billow.Lacunarity = lacunarity;
              billow.Persistence = persistence;

              ScaleBiasOutput scaledBillow = new ScaleBiasOutput(billow);
              scaledBillow.Bias = -0.75;
              scaledBillow.Scale = 0.125;

              RidgedMultifractal ridged = new RidgedMultifractal();
              ridged.Frequency = frequency;
              ridged.NoiseQuality = NoiseQuality.High;
              ridged.Seed = 0;
              ridged.OctaveCount = octaves;
              ridged.Lacunarity = lacunarity;

              Perlin perlin = new Perlin();
              perlin.Frequency = frequency;
              perlin.NoiseQuality = NoiseQuality.High;
              perlin.Seed = 0;
              perlin.OctaveCount = octaves;
              perlin.Lacunarity = lacunarity;
              perlin.Persistence = persistence;

              Select selector = new Select(perlin, ridged, scaledBillow);
              selector.SetBounds(0, 1000);
              selector.EdgeFalloff = 0.5;
              IModule module = selector;
              //RidgedMultifractal module = new RidgedMultifractal();
              //((RidgedMultifractal)module).Frequency = frequency;
              //((RidgedMultifractal)module).NoiseQuality = NoiseQuality.High;
              //((RidgedMultifractal)module).Seed = 0;
              //((RidgedMultifractal)module).OctaveCount = octaves;
              //((RidgedMultifractal)module).Lacunarity = lacunarity;
              //((RidgedMultifractal)module).Persistence = persistence;
              Pen blackPen = new Pen(Color.Black, 1);
              Font arialFont = new Font("Arial", 8);

              double min = double.MaxValue;
              double max = double.MinValue;
              double avg = 0;

              using (Bitmap b = new Bitmap(300, 2500))
              {
            using (Graphics g = Graphics.FromImage(b))
            {
              g.Clear(Color.White);
              for (int i = 0; i < 5000; i++)
              {
            var value = module.GetValue(i, 0, 0);
            avg += value;
            if (value < min)
            {
              min = value;
            }
            if (value > max)
            {
              max = value;
            }
            g.DrawRectangle(blackPen, 150 + (int)System.Math.Round(value * 100), i / 2, 1, 1);
              }
              avg /= 5000;
              g.DrawString(string.Format("Samples: {0:N3}\r\nMin: {1:N3}\r\nMax: {2:N3}\r\nAverage: {3:N3}", 5000, min, max, avg), arialFont, Brushes.DarkBlue, 5f, 60f);
              g.DrawString(string.Format("Frequency: {0:N3}\r\nPersistence: {1:N3}\r\nLacunarity: {2:N3}\r\nOctaves: {3:N3}", frequency, persistence, lacunarity, octaves), arialFont, Brushes.DarkGreen, 5f, 5f);
            }
            b.Save(@"Combined\" + fileName, ImageFormat.Png);
              }
        }