public TerrainModule(int seed) { _seed = seed; RidgedMultifractal mountains = new RidgedMultifractal(); mountains.Seed = seed; mountains.Frequency = 0.5; Billow hills = new Billow(); hills.Seed = seed; hills.Frequency = 2; ScaleBiasOutput scaleHill = new ScaleBiasOutput(hills); scaleHill.Scale = 0.04; scaleHill.Bias = 0; ScaleBiasOutput scaleMountain = new ScaleBiasOutput(mountains); scaleMountain.Scale = 1.5; Perlin selectorControl = new Perlin(); selectorControl.Seed = seed; selectorControl.Frequency = 0.10; selectorControl.Persistence = 0.25; Select selector = new Select(selectorControl, scaleMountain, scaleHill); selector.SetBounds(0, 1000); selector.EdgeFalloff = 0.5; _module = selector; }
//biased for realistic scale planets of thousands of units radius public static IModule FastPlanet(float planetRadius) { int seed = RandomHelper.GetRandomInt(1000); FastNoise fastPlanetContinents = new FastNoise(seed); fastPlanetContinents.Frequency = 0.0001f; FastBillow fastPlanetLowlands = new FastBillow(); fastPlanetLowlands.Frequency = 0.01; LibNoise.Modifiers.ScaleBiasOutput fastPlanetLowlandsScaled = new ScaleBiasOutput(fastPlanetLowlands); fastPlanetLowlandsScaled.Scale = 1; fastPlanetLowlandsScaled.Bias = 2; FastRidgedMultifractal fastPlanetMountainsBase = new FastRidgedMultifractal(seed); fastPlanetMountainsBase.Frequency = 0.008; //mountains scaled to 1000th the radius, and biased that amount upwards. ScaleBiasOutput fastPlanetMountainsScaled = new ScaleBiasOutput(fastPlanetMountainsBase); fastPlanetMountainsScaled.Scale = planetRadius / 400; fastPlanetMountainsScaled.Bias = planetRadius / 200; FastTurbulence fastPlanetMountains = new FastTurbulence(fastPlanetMountainsScaled); fastPlanetMountains.Power = 1; fastPlanetMountains.Frequency = 0.05; FastNoise fastPlanetLandFilter = new FastNoise(seed + 1); fastPlanetLandFilter.Frequency = 0.0005; Select fastPlanetLand = new Select(fastPlanetLandFilter, fastPlanetLowlandsScaled, fastPlanetMountains); fastPlanetLand.SetBounds(0, planetRadius); fastPlanetLand.EdgeFalloff = 0.1f; FastBillow fastPlanetOceanBase = new FastBillow(seed); fastPlanetOceanBase.Frequency = 0.01f; ScaleBiasOutput biasOceanOutput = new ScaleBiasOutput(fastPlanetOceanBase); biasOceanOutput.Bias = -2f; biasOceanOutput.Scale = 1f; Select fastPlanetFinal = new Select(fastPlanetContinents, biasOceanOutput, fastPlanetLand); fastPlanetFinal.SetBounds(0, planetRadius); fastPlanetFinal.EdgeFalloff = 0.01; return(fastPlanetFinal); }
public static IModule ParameterisedFastPlanet(float planetRadius, Dictionary <string, PlanetParameters> parameters, int seed = 1000) { FastNoise fastPlanetContinents = new FastNoise(seed); fastPlanetContinents.Frequency = parameters["continentFrequency"].Value; FastBillow fastPlanetLowlands = new FastBillow(); fastPlanetLowlands.Frequency = parameters["lowlandFrequency"].Value; LibNoise.Modifiers.ScaleBiasOutput fastPlanetLowlandsScaled = new ScaleBiasOutput(fastPlanetLowlands); fastPlanetLowlandsScaled.Scale = parameters["lowlandScale"].Value; fastPlanetLowlandsScaled.Bias = parameters["lowlandBias"].Value; FastRidgedMultifractal fastPlanetMountainsBase = new FastRidgedMultifractal(seed); fastPlanetMountainsBase.Frequency = parameters["mountainBaseFrequency"].Value; //mountains scaled to 1000th the radius, and biased that amount upwards. ScaleBiasOutput fastPlanetMountainsScaled = new ScaleBiasOutput(fastPlanetMountainsBase); fastPlanetMountainsScaled.Scale = parameters["mountainScale"].Value; fastPlanetMountainsScaled.Bias = parameters["mountainBias"].Value; FastTurbulence fastPlanetMountains = new FastTurbulence(fastPlanetMountainsScaled); fastPlanetMountains.Power = parameters["mountainTurbulencePower"].Value; fastPlanetMountains.Frequency = parameters["mountainTurbulenceFrequency"].Value; FastNoise fastPlanetLandFilter = new FastNoise(seed + 1); fastPlanetLandFilter.Frequency = parameters["planetlandFilterFrequency"].Value; Select fastPlanetLand = new Select(fastPlanetLandFilter, fastPlanetLowlandsScaled, fastPlanetMountains); fastPlanetLand.SetBounds(0, planetRadius); fastPlanetLand.EdgeFalloff = parameters["landEdgeFallOff"].Value; FastBillow fastPlanetOceanBase = new FastBillow(seed); fastPlanetOceanBase.Frequency = parameters["oceanFrequency"].Value; ScaleBiasOutput biasOceanOutput = new ScaleBiasOutput(fastPlanetOceanBase); biasOceanOutput.Bias = parameters["oceanBias"].Value; biasOceanOutput.Scale = parameters["oceanScale"].Value; Select fastPlanetFinal = new Select(fastPlanetContinents, biasOceanOutput, fastPlanetLand); fastPlanetFinal.SetBounds(0, planetRadius); fastPlanetFinal.EdgeFalloff = parameters["finalEdgeFallOff"].Value; return(fastPlanetFinal); }
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); }
public void Init(int seed, int width, int height) { if (LandBitmap != null && width != LandBitmap.Width) { LandBitmap.ResizeImage(width, height, false); } if (MountainBitmap != null && width != MountainBitmap.Width) { MountainBitmap.ResizeImage(width, height, false); } float delta = width / 3072.0f; delta *= ZoomMultiplier; DivNoise = delta; // Rand.SetSeed(seed); baseWaterTerrain.Frequency = 2.0; baseLandTerrain.Frequency = (2.0); ScaleBiasOutput flatTerrain = new ScaleBiasOutput(baseLandTerrain); flatTerrain.Scale = 0.005; flatTerrain.Bias = seaLevel;//SeaLevel; MinLandFreq = 0.2f; MaxLandFreq = 1f; if (LandBitmap != null) { MinLandFreq = 0.7f; } ScaleBiasOutput hillTerrain = new ScaleBiasOutput(baseLandTerrain); hillTerrain.Scale = 0.09; hillTerrain.Bias = seaLevel + 0.2;//SeaLevel; ScaleBiasOutput waterTerrain = new ScaleBiasOutput(baseWaterTerrain); waterTerrain.Bias = -0.33f;//SeaLevel; waterTerrain.Scale = 0.001; Perlin waterLandType = new Perlin(); float landFreq = Rand.Next((int)(MinLandFreq * 10000), (int)(MaxLandFreq * 10000)) / 10000.0f; waterLandType.Persistence = 0.45; waterLandType.Frequency = landFreq; //waterLandType.OctaveCount = 12; waterLandType.Seed = Rand.Next(1000000); Select waterLandSelector = new Select(waterLandType, waterTerrain, flatTerrain); if (LandBitmap != null) { waterLandSelector = new BitmapSelect(waterLandType, waterTerrain, flatTerrain, DivNoise, LandBitmap); } waterLandSelector.EdgeFalloff = (0.145); waterLandSelector.SetBounds(-0.0, 1000);; Select landHillSelector = new Select(waterLandType, waterLandSelector, hillTerrain); if (LandBitmap != null) { landHillSelector = new BitmapSelect(waterLandType, waterLandSelector, hillTerrain, DivNoise, LandBitmap); } landHillSelector.EdgeFalloff = (0.45); landHillSelector.SetBounds(0.25f, 1000);; terrainType.Persistence = 0.3; terrainType.Frequency = 0.3; terrainType.Seed = Rand.Next(10000000); var clamp = new ClampOutput(terrainType); clamp.SetBounds(0, 1); // mountainTerrain.Frequency /= 1.5f; mountainTerrain.Lacunarity = 35; mountainTerrain.Frequency = 3.2; mountainTerrain.Seed = Rand.Next(10000000); MultiplyPositive mul = new MultiplyPositive(waterLandType, waterLandType); ScaleOutput scaled = new ScaleOutput(mul, 0.00001); Add add = new Add(new BiasOutput(mountainTerrain, 0.8 + seaLevel), landHillSelector); MultiplyPositive mul2 = new MultiplyPositive(add, add); MultiplyPositive mul3 = new MultiplyPositive(clamp, mul); Select terrainSelector = new Select(mul3, landHillSelector, add); if (MountainBitmap != null) { terrainSelector = new BitmapSelect(mul3, landHillSelector, add, DivNoise, MountainBitmap); } terrainSelector.EdgeFalloff = (7.925); terrainSelector.SetBounds(0.3, 1000); Turbulence finalTerrain = new Turbulence(terrainSelector); finalTerrain.Frequency = 4; finalTerrain.Power = 0.075; Width = width; Height = height; // ResultBitmap2 = new NoiseTexture(width, height, clamp); // System.Console.Out.WriteLine("Left: " + ResultBitmap2.minRange + " - " + ResultBitmap2.maxRange); // ResultBitmap2 = new NoiseTexture(width, height, finalTerrain, DivNoise, 1.25f, -0.66f); // System.Console.Out.WriteLine("Left: " + ResultBitmap2.minRange + " - " + ResultBitmap2.maxRange); ResultBitmap = new NoiseTexture(width, height, finalTerrain, DivNoise, 1.25f, -0.66f); System.Console.Out.WriteLine("Right: " + ResultBitmap.minRange + " - " + ResultBitmap.maxRange); }
public void InitO(int seed, int width, int height) { float delta = width / 3072.0f; delta *= ZoomMultiplier; DivNoise = delta; // Rand.SetSeed(seed); baseWaterTerrain.Frequency = 2.0; baseLandTerrain.Frequency = (2.0); ScaleBiasOutput flatTerrain = new ScaleBiasOutput(baseLandTerrain); flatTerrain.Scale = 0.005; flatTerrain.Bias = seaLevel;//SeaLevel; ScaleBiasOutput hillTerrain = new ScaleBiasOutput(baseLandTerrain); hillTerrain.Scale = 0.065; hillTerrain.Bias = seaLevel + 0.2;//SeaLevel; ScaleBiasOutput waterTerrain = new ScaleBiasOutput(baseWaterTerrain); waterTerrain.Bias = -0.73f;//SeaLevel; waterTerrain.Scale = 0.05; Perlin waterLandType = new Perlin(); waterLandType.Persistence = 0.45; waterLandType.Frequency = 0.5; //waterLandType.OctaveCount = 12; waterLandType.Seed = Rand.Next(1000000); Select waterLandSelector = new Select(waterLandType, waterTerrain, flatTerrain); waterLandSelector.EdgeFalloff = (0.045); waterLandSelector.SetBounds(-0.0, 1000);; Select landHillSelector = new Select(waterLandType, waterLandSelector, hillTerrain); landHillSelector.EdgeFalloff = (0.15); landHillSelector.SetBounds(0.4, 1000);; terrainType.Persistence = 0.3; terrainType.Frequency = 0.3; terrainType.Seed = Rand.Next(10000000); var clamp = new ClampOutput(terrainType); clamp.SetBounds(0, 1); // mountainTerrain.Frequency /= 1.5f; mountainTerrain.Lacunarity = 30; mountainTerrain.Frequency = 1.3; MultiplyPositive mul = new MultiplyPositive(waterLandType, waterLandType); ScaleOutput scaled = new ScaleOutput(mul, 0.00001); Add add = new Add(new BiasOutput(mountainTerrain, 1 + seaLevel), landHillSelector); MultiplyPositive mul2 = new MultiplyPositive(mul, mul); MultiplyPositive mul3 = new MultiplyPositive(clamp, mul); Select terrainSelector = new Select(mul3, landHillSelector, add); terrainSelector.EdgeFalloff = (0.425); terrainSelector.SetBounds(0.3, 1000); Turbulence finalTerrain = new Turbulence(terrainSelector); finalTerrain.Frequency = 4; finalTerrain.Power = 0.075; Width = width; Height = height; // ResultBitmap2 = new NoiseTexture(width, height, clamp); // System.Console.Out.WriteLine("Left: " + ResultBitmap2.minRange + " - " + ResultBitmap2.maxRange); ResultBitmap = new NoiseTexture(width, height, finalTerrain, DivNoise, 1.25f, -0.66f); System.Console.Out.WriteLine("Range: " + ResultBitmap.minRange + " - " + ResultBitmap.maxRange); }
void InitializeNoise(int Seed) { //Ocean Noise Generator oceanNoise.Seed = Seed; oceanScaled = new ScaleInput(oceanNoise, 8, 8, 8); oceanScaled.SourceModule = oceanNoise; oceanOutput = new ScaleBiasOutput(oceanScaled); oceanOutput.Scale = 0.25; oceanOutput.Bias = 0.5; //Mountain Noise Generator mountainsNoise.Seed = Seed; mountainsScaled = new ScaleInput(mountainsNoise, 4, 4, 4); mountainsScaled.SourceModule = mountainsNoise; mountainsOutput = new ScaleBiasOutput(mountainsScaled); mountainsOutput.Scale = 1; mountainsOutput.Bias = 2.2; //Hills Noise Generator hillsNoise.Seed = Seed + 5; hillsNoise.Persistence = 0.25; hillsScaled = new ScaleInput(hillsNoise, 16, 16, 16); hillsScaled.SourceModule = hillsNoise; hillsOutput = new ScaleBiasOutput(hillsScaled); hillsOutput.Scale = 0.25; hillsOutput.Bias = 1.25; //Plains Noise Generator plainsNoise.Persistence = 0.5; plainsNoise.Seed = Seed; plainsScaled = new ScaleInput(plainsNoise, 2, 2, 2); plainsScaled.SourceModule = plainsNoise; plainsOutput = new ScaleBiasOutput(plainsScaled); plainsOutput.Scale = 0.17; plainsOutput.Bias = 1.2; //Desert Noise Generator desertNoise.Persistence = 0.5; desertNoise.Seed = Seed + 10; desertOutput = new ScaleBiasOutput(desertNoise); desertOutput.Scale = 0.3; desertOutput.Bias = 1.3; //Canyon Noise Generator canyonNoise.Seed = Seed + 20; canyonScaled = new ScaleBiasOutput(canyonNoise); canyonScaled.Scale = 0.4; canyonScaled.Bias = 1.75; //Island Noise Generator islandNoise.Persistence = 0.5; islandNoise.Seed = Seed - 10; islandScaled = new ScaleInput(islandNoise, 8, 8, 8); islandScaled.SourceModule = islandNoise; islandOutput = new ScaleBiasOutput(islandScaled); islandOutput.Scale = 0.2; islandOutput.Bias = 1.1; //Vegetation vegetationNoise.Seed = Seed; //Overhangs generator overhangs.Seed = Seed; overhangs.OctaveCount = 1; overhangs.Persistence = 0.3; }
void InitializeBiomes(int seed) { // New biome system noise_height.Seed = seed; noise_hum.Seed = seed * 7; noise_humidity = new ScaleBiasOutput(noise_hum); noise_humidity.Scale = 10; noise_humidity.Bias = 10; sel_bio_high0_hum0_1 = new Select(noise_humidity, id_island, id_island); sel_bio_high0_hum0_1.SetBounds(2, 6); sel_bio_high0_hum01_2 = new Select(noise_humidity, sel_bio_high0_hum0_1, id_island); sel_bio_high0_hum01_2.SetBounds(6, 13); sel_bio_high0_hum012_3 = new Select(noise_humidity, sel_bio_high0_hum01_2, id_island); sel_bio_high0_hum012_3.SetBounds(13, 18); sel_bio_high0_hum0123_4 = new Select(noise_humidity, sel_bio_high0_hum012_3, id_island); sel_bio_high0_hum0123_4.SetBounds(18, 20); sel_bio_high1_hum0_1 = new Select(noise_humidity, id_ocean, id_ocean); sel_bio_high1_hum0_1.SetBounds(2, 6); sel_bio_high1_hum01_2 = new Select(noise_humidity, sel_bio_high1_hum0_1, id_ocean); sel_bio_high1_hum01_2.SetBounds(6, 13); sel_bio_high1_hum012_3 = new Select(noise_humidity, sel_bio_high1_hum01_2, id_ocean); sel_bio_high1_hum012_3.SetBounds(13, 18); sel_bio_high1_hum0123_4 = new Select(noise_humidity, sel_bio_high1_hum012_3, id_ocean); sel_bio_high1_hum0123_4.SetBounds(18, 20); sel_bio_high2_hum0_1 = new Select(noise_humidity, id_shore, id_shore); sel_bio_high2_hum0_1.SetBounds(2, 6); sel_bio_high2_hum01_2 = new Select(noise_humidity, sel_bio_high2_hum0_1, id_shore); sel_bio_high2_hum01_2.SetBounds(6, 13); sel_bio_high2_hum012_3 = new Select(noise_humidity, sel_bio_high2_hum01_2, id_shore); sel_bio_high2_hum012_3.SetBounds(13, 18); sel_bio_high2_hum0123_4 = new Select(noise_humidity, sel_bio_high2_hum012_3, id_shore); sel_bio_high2_hum0123_4.SetBounds(18, 20); sel_bio_high3_hum0_1 = new Select(noise_humidity, id_swamp, id_plains); sel_bio_high3_hum0_1.SetBounds(2, 6); sel_bio_high3_hum01_2 = new Select(noise_humidity, sel_bio_high3_hum0_1, id_plains); sel_bio_high3_hum01_2.SetBounds(6, 13); sel_bio_high3_hum012_3 = new Select(noise_humidity, sel_bio_high3_hum01_2, id_desert); sel_bio_high3_hum012_3.SetBounds(13, 18); sel_bio_high3_hum0123_4 = new Select(noise_humidity, sel_bio_high3_hum012_3, id_desert); sel_bio_high3_hum0123_4.SetBounds(18, 20); sel_bio_high4_hum0_1 = new Select(noise_humidity, id_hills, id_hills); sel_bio_high4_hum0_1.SetBounds(2, 6); sel_bio_high4_hum01_2 = new Select(noise_humidity, sel_bio_high4_hum0_1, id_hills); sel_bio_high4_hum01_2.SetBounds(6, 13); sel_bio_high4_hum012_3 = new Select(noise_humidity, sel_bio_high4_hum01_2, id_dunes); sel_bio_high4_hum012_3.SetBounds(13, 18); sel_bio_high4_hum0123_4 = new Select(noise_humidity, sel_bio_high4_hum012_3, id_dunes); sel_bio_high4_hum0123_4.SetBounds(18, 20); sel_bio_high5_hum0_1 = new Select(noise_humidity, id_grassymountains, id_grassymountains); sel_bio_high5_hum0_1.SetBounds(2, 6); sel_bio_high5_hum01_2 = new Select(noise_humidity, sel_bio_high5_hum0_1, id_mountains); sel_bio_high5_hum01_2.SetBounds(6, 13); sel_bio_high5_hum012_3 = new Select(noise_humidity, sel_bio_high5_hum01_2, id_desertmountains); sel_bio_high5_hum012_3.SetBounds(13, 18); sel_bio_high5_hum0123_4 = new Select(noise_humidity, sel_bio_high5_hum012_3, id_desertmountains); sel_bio_high5_hum0123_4.SetBounds(18, 20); sel_bio_high0_1 = new Select(noise_height, sel_bio_high0_hum0123_4, sel_bio_high1_hum0123_4); sel_bio_high0_1.SetBounds(2, 5); sel_bio_high01_2 = new Select(noise_height, sel_bio_high0_1, sel_bio_high2_hum0123_4); sel_bio_high01_2.SetBounds(5, 6); sel_bio_high012_3 = new Select(noise_height, sel_bio_high01_2, sel_bio_high3_hum0123_4); sel_bio_high012_3.SetBounds(6, 12); sel_bio_high0123_4 = new Select(noise_height, sel_bio_high012_3, sel_bio_high4_hum0123_4); sel_bio_high0123_4.SetBounds(12, 17); sel_bio_high01234_5 = new Select(noise_height, sel_bio_high0123_4, sel_bio_high5_hum0123_4); sel_bio_high01234_5.SetBounds(17, 20); }
private void button1_Click(object sender, EventArgs e) { panel2.Enabled = false; NoiseQuality quality = NoiseQuality.Standard; if (radiolow.Checked) { quality = NoiseQuality.Low; } if (radiostandard.Checked) { quality = NoiseQuality.Standard; } if (radiohigh.Checked) { quality = NoiseQuality.High; } int seed = 0; try { seed = Convert.ToInt32(textBox1.Text); } catch { seed = 0; textBox1.Text = "0"; } int octaves = 0; try { octaves = Convert.ToInt32(textBox2.Text); } catch { octaves = 6; textBox2.Text = "6"; } if (octaves > 30) { octaves = 30; } double frequency = 0; try { frequency = Convert.ToDouble(textBox3.Text); } catch { frequency = 0.05; textBox3.Text = "0.05"; } double lacunarity = 0; try { lacunarity = Convert.ToDouble(textBox4.Text); } catch { lacunarity = 2.0; textBox4.Text = "2.0"; } double persistence = 0; try { persistence = Convert.ToDouble(textBox5.Text); } catch { persistence = 0.5; textBox5.Text = "0.5"; } bool mapToSphere = false; IModule module; switch (listBox1.SelectedItem.ToString()) { case "Slow Perlin": module = new Perlin(); ((Perlin)module).Frequency = frequency; ((Perlin)module).NoiseQuality = quality; ((Perlin)module).Seed = seed; ((Perlin)module).OctaveCount = octaves; ((Perlin)module).Lacunarity = lacunarity; ((Perlin)module).Persistence = persistence; break; case "Fast Perlin": module = new FastNoise(); ((FastNoise)module).Frequency = frequency; ((FastNoise)module).NoiseQuality = quality; ((FastNoise)module).Seed = seed; ((FastNoise)module).OctaveCount = octaves; ((FastNoise)module).Lacunarity = lacunarity; ((FastNoise)module).Persistence = persistence; break; case "Slow Billow": module = new Billow(); ((Billow)module).Frequency = frequency; ((Billow)module).NoiseQuality = quality; ((Billow)module).Seed = seed; ((Billow)module).OctaveCount = octaves; ((Billow)module).Lacunarity = lacunarity; ((Billow)module).Persistence = persistence; break; case "Fast Billow": module = new FastBillow(); ((FastBillow)module).Frequency = frequency; ((FastBillow)module).NoiseQuality = quality; ((FastBillow)module).Seed = seed; ((FastBillow)module).OctaveCount = octaves; ((FastBillow)module).Lacunarity = lacunarity; ((FastBillow)module).Persistence = persistence; break; case "Slow Ridged Multifractal": module = new RidgedMultifractal(); ((RidgedMultifractal)module).Frequency = frequency; ((RidgedMultifractal)module).NoiseQuality = quality; ((RidgedMultifractal)module).Seed = seed; ((RidgedMultifractal)module).OctaveCount = octaves; ((RidgedMultifractal)module).Lacunarity = lacunarity; break; case "Fast Ridged Multifractal": module = new FastRidgedMultifractal(); ((FastRidgedMultifractal)module).Frequency = frequency; ((FastRidgedMultifractal)module).NoiseQuality = quality; ((FastRidgedMultifractal)module).Seed = seed; ((FastRidgedMultifractal)module).OctaveCount = octaves; ((FastRidgedMultifractal)module).Lacunarity = lacunarity; break; case "Slow Combined": Billow billow = new Billow(); billow.Frequency = frequency; billow.NoiseQuality = quality; billow.Seed = seed; 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 / 2.0; ridged.NoiseQuality = quality; ridged.Seed = seed; ridged.OctaveCount = octaves; ridged.Lacunarity = lacunarity; Perlin perlin = new Perlin(); perlin.Frequency = frequency / 10.0; perlin.NoiseQuality = quality; perlin.Seed = seed; perlin.OctaveCount = octaves; perlin.Lacunarity = lacunarity; perlin.Persistence = persistence; Select selector = new Select(perlin, ridged, scaledBillow); selector.SetBounds(0, 1000); selector.EdgeFalloff = 0.5; module = selector; break; case "Fast Combined": FastBillow fastbillow = new FastBillow(); fastbillow.Frequency = frequency; fastbillow.NoiseQuality = quality; fastbillow.Seed = seed; fastbillow.OctaveCount = octaves; fastbillow.Lacunarity = lacunarity; fastbillow.Persistence = persistence; ScaleBiasOutput fastscaledBillow = new ScaleBiasOutput(fastbillow); fastscaledBillow.Bias = -0.75; fastscaledBillow.Scale = 0.125; FastRidgedMultifractal fastridged = new FastRidgedMultifractal(); fastridged.Frequency = frequency / 2.0; fastridged.NoiseQuality = quality; fastridged.Seed = seed; fastridged.OctaveCount = octaves; fastridged.Lacunarity = lacunarity; FastNoise fastperlin = new FastNoise(); fastperlin.Frequency = frequency / 10.0; fastperlin.NoiseQuality = quality; fastperlin.Seed = seed; fastperlin.OctaveCount = octaves; fastperlin.Lacunarity = lacunarity; fastperlin.Persistence = persistence; Select fastselector = new Select(fastperlin, fastridged, fastscaledBillow); fastselector.SetBounds(0, 1000); fastselector.EdgeFalloff = 0.5; module = fastselector; break; case "Voronoi": module = new Voronoi(); ((Voronoi)module).Frequency = frequency; break; case "Slow Planet": mapToSphere = true; Perlin slowPlanetContinents = new Perlin(); slowPlanetContinents.Frequency = 1.5; Billow slowPlanetLowlands = new Billow(); slowPlanetLowlands.Frequency = 4; LibNoise.Modifiers.ScaleBiasOutput slowPlanetLowlandsScaled = new ScaleBiasOutput(slowPlanetLowlands); slowPlanetLowlandsScaled.Scale = 0.2; slowPlanetLowlandsScaled.Bias = 0.5; RidgedMultifractal slowPlanetMountainsBase = new RidgedMultifractal(); slowPlanetMountainsBase.Frequency = 4; ScaleBiasOutput slowPlanetMountainsScaled = new ScaleBiasOutput(slowPlanetMountainsBase); slowPlanetMountainsScaled.Scale = 0.4; slowPlanetMountainsScaled.Bias = 0.85; FastTurbulence slowPlanetMountains = new FastTurbulence(slowPlanetMountainsScaled); slowPlanetMountains.Power = 0.1; slowPlanetMountains.Frequency = 50; Perlin slowPlanetLandFilter = new Perlin(); slowPlanetLandFilter.Frequency = 6; Select slowPlanetLand = new Select(slowPlanetLandFilter, slowPlanetLowlandsScaled, slowPlanetMountains); slowPlanetLand.SetBounds(0, 1000); slowPlanetLand.EdgeFalloff = 0.5; Billow slowPlanetOceanBase = new Billow(); slowPlanetOceanBase.Frequency = 15; ScaleOutput slowPlanetOcean = new ScaleOutput(slowPlanetOceanBase, 0.1); Select slowPlanetFinal = new Select(slowPlanetContinents, slowPlanetOcean, slowPlanetLand); slowPlanetFinal.SetBounds(0, 1000); slowPlanetFinal.EdgeFalloff = 0.5; module = slowPlanetFinal; break; case "Fast Planet": mapToSphere = true; FastNoise fastPlanetContinents = new FastNoise(seed); fastPlanetContinents.Frequency = 1.5; FastBillow fastPlanetLowlands = new FastBillow(); fastPlanetLowlands.Frequency = 4; LibNoise.Modifiers.ScaleBiasOutput fastPlanetLowlandsScaled = new ScaleBiasOutput(fastPlanetLowlands); fastPlanetLowlandsScaled.Scale = 0.2; fastPlanetLowlandsScaled.Bias = 0.5; FastRidgedMultifractal fastPlanetMountainsBase = new FastRidgedMultifractal(seed); fastPlanetMountainsBase.Frequency = 4; 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; FastNoise fastPlanetLandFilter = new FastNoise(seed + 1); fastPlanetLandFilter.Frequency = 6; Select fastPlanetLand = new Select(fastPlanetLandFilter, fastPlanetLowlandsScaled, fastPlanetMountains); fastPlanetLand.SetBounds(0, 1000); fastPlanetLand.EdgeFalloff = 0.5; FastBillow fastPlanetOceanBase = new FastBillow(seed); fastPlanetOceanBase.Frequency = 15; ScaleOutput fastPlanetOcean = new ScaleOutput(fastPlanetOceanBase, 0.1); Select fastPlanetFinal = new Select(fastPlanetContinents, fastPlanetOcean, fastPlanetLand); fastPlanetFinal.SetBounds(0, 1000); fastPlanetFinal.EdgeFalloff = 0.5; module = fastPlanetFinal; break; default: module = new Constant(1.0); break; } System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); LibNoise.Models.Sphere sphere = new LibNoise.Models.Sphere(module); for (int x = 0; x < pictureBox1.ClientSize.Width - 1; x++) { for (int y = 0; y < pictureBox1.ClientSize.Height - 1; y++) { double value; if (mapToSphere) { int offsetX = -(x - 512); int offsetY = -(y - 512); double longitude = offsetY / 5.6888888888; if (longitude > 90.0) { longitude = 90.0; } if (longitude < -90.0) { longitude = -90.0; } double latitude = offsetX / 2.844444444; if (latitude > 180.0) { latitude = 180.0; } if (latitude < -190.0) { latitude = -180.0; } value = sphere.GetValue(longitude, latitude); } else { value = (module.GetValue(x, y, 10) + 1) / 2.0; } if (mapToSphere) { if (value < 0) { value = 0; } if (value > 1.0) { value = 1.0; } int index = (int)(value * earthLookupTable.Length); if (index >= earthLookupTable.Length) { index = earthLookupTable.Length - 1; } colors[x, y] = earthLookupTable[index]; } else { if (value < 0) { value = 0; } if (value > 1.0) { value = 1.0; } byte intensity = (byte)(value * 255.0); colors[x, y] = Color.FromArgb(255, intensity, intensity, intensity); } } } stopWatch.Stop(); label2.Text = "Generation time for a 1024x1024 image, not including rendering: " + stopWatch.Elapsed.TotalMilliseconds + " ms"; for (int x = 0; x < pictureBox1.ClientSize.Width - 1; x++) { for (int y = 0; y < pictureBox1.ClientSize.Height - 1; y++) { bitmap.SetPixel(x, y, colors[x, y]); } } pictureBox1.Image = bitmap; panel2.Enabled = true; }
public void Init() { //###### TREE GEN ##### treenoise.Seed = (Seed + 2); treenoise.OctaveCount = (6); treenoise.Frequency = (1.0 / 180.0); treenoise.Lacunarity = ((treeCount / 20.0) * (treeCount / 20.0) * 2.0); //###### END TREE GEN ####### /* * cave.init(seed + 7); * seaLevel = Mineserver::get()->config()->iData("mapgen.sea.level"); * addTrees = Mineserver::get()->config()->bData("mapgen.trees.enabled"); * expandBeaches = Mineserver::get()->config()->bData("mapgen.beaches.expand"); * beachExtent = Mineserver::get()->config()->iData("mapgen.beaches.extent"); * beachHeight = Mineserver::get()->config()->iData("mapgen.beaches.height"); * * addOre = Mineserver::get()->config()->bData("mapgen.addore"); * addCaves = Mineserver::get()->config()->bData("mapgen.caves.enabled"); */ BiomeBase.Frequency = (0.2); BiomeBase.Seed = (Seed - 1); BiomeSelect = new ScaleBiasOutput(BiomeBase); //BiomeSelect.SourceModule = (BiomeBase); BiomeSelect.Scale = (2.5); BiomeSelect.Bias = (2.5); mountainTerrainBase.Seed = (Seed + 1); mountainTerrain = new ScaleBiasOutput(mountainTerrainBase); //mountainTerrain.SourceModule = (mountainTerrainBase); mountainTerrain.Scale = (0.5); mountainTerrain.Bias = (0.5); jaggieEdges = new Select(jaggieControl, terrainType, plain); //jaggieEdges.SourceModule1 = (terrainType); //jaggieEdges.SourceModule2 = (plain); plain.Value = (0.5); //jaggieEdges.ControlModule = (jaggieControl); 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.SourceModule = (baseFlatTerrain); flatTerrain.Scale = (0.125); flatTerrain.Bias = (0.07); baseWater.Seed = (Seed - 1); water = new ScaleBiasOutput(baseWater); //water.SourceModule = (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.SourceModule1 = (water); //waterTerrain.SourceModule2 = (flatTerrain); //waterTerrain.ControlModule = (terrainType2); waterTerrain.EdgeFalloff = (0.1); waterTerrain.SetBounds(-0.5, 1.0); secondTerrain = new Select(terrainType, mountainTerrain, waterTerrain); //secondTerrain.SourceModule2 = (waterTerrain); //secondTerrain.SourceModule1 = (mountainTerrain); //secondTerrain.ControlModule = (terrainType); secondTerrain.EdgeFalloff = (0.3); secondTerrain.SetBounds(-0.5, 1.0); finalTerrain = new Select(jaggieEdges, secondTerrain, waterTerrain); //finalTerrain.SourceModule1 = (secondTerrain); //finalTerrain.SourceModule2 = (waterTerrain); //finalTerrain.ControlModule = (jaggieEdges); finalTerrain.EdgeFalloff = (0.2); finalTerrain.SetBounds(-0.3, 1.0); flowers.Seed = (Seed + 10); flowers.Frequency = (3); winterEnabled = false; // Set up us the Perlin-noise module. caveNoise.Seed = (Seed + 22); caveNoise.Frequency = (1.0 / cavessize); caveNoise.OctaveCount = (4); }