public GraniteTextureTest() { module = new Turbulence { Seed = 2, Frequency = 4, Power = 1.0 / 8.0, Roughness = 6, Source0 = new Add { Source0 = new Billow { Seed = 1, Frequency = 8, Persistence = 0.625, Lacunarity = 2.18359375, OctaveCount = 6, }, Source1 = new ScaleBias { Scale = -0.5, Bias = 0, Source0 = new Voronoi { Seed = 1, Frequency = 16, EnableDistance = true, } } } }; noiseMap = new NoiseMap(); textureImage = new Image(); renderer = new ImageRenderer { EnableLight = true, LightAzimuth = 135, LightElevation = 60, LightContrast = 2, LightColor = new Color(255, 255, 255, 0), }; renderer.AddGradientPoint(-1.0000, new Color(0, 0, 0, 255)); renderer.AddGradientPoint(-0.9375, new Color(0, 0, 0, 255)); renderer.AddGradientPoint(-0.8750, new Color(216, 216, 242, 255)); renderer.AddGradientPoint(0.0000, new Color(191, 191, 191, 255)); renderer.AddGradientPoint(0.5000, new Color(210, 116, 125, 255)); renderer.AddGradientPoint(0.7500, new Color(210, 113, 98, 255)); renderer.AddGradientPoint(1.0000, new Color(255, 176, 192, 255)); }
private async void startButton_Click(object sender, EventArgs e) { timeLabel.Text = string.Empty; var cts = new CancellationTokenSource(); var dialog = new ProgressDialog(); dialog.Owner = this; dialog.cancelButton.Click += (s, ea) => cts.Cancel(); dialog.Show(); var stopwatch = new Stopwatch(); stopwatch.Start(); var generatorModule = new PlanetGenerator(GeneratorSettings).CreatePlanetModule(); var planetBuilder = new SphereNoiseMapBuilder(); var planetElevationMap = new NoiseMap(); planetBuilder.SetBounds(GeneratorSettings.SouthCoord, GeneratorSettings.NorthCoord, GeneratorSettings.WestCoord, GeneratorSettings.EastCoord); planetBuilder.SetDestSize(GeneratorSettings.GridWidth, GeneratorSettings.GridHeight); planetBuilder.SourceModule = generatorModule; planetBuilder.DestNoiseMap = planetElevationMap; bool cancelled = false; try { await planetBuilder.BuildAsync(cts.Token); } catch (OperationCanceledException) { cancelled = true; } stopwatch.Stop(); dialog.Close(); if (cancelled) return; timeLabel.Text = String.Format("Planet generated in {0}", stopwatch.Elapsed.ToString()); var degExtent = GeneratorSettings.EastCoord - GeneratorSettings.WestCoord; var gridExtent = (double)GeneratorSettings.GridWidth; var metersPerDegree = (GeneratorSettings.PlanetCircumference / 360.0); var resInMeters = (degExtent / gridExtent) * metersPerDegree; var seaLevelInMeters = (((GeneratorSettings.SeaLevel + 1) / 2.0) * (GeneratorSettings.MaxElev - GeneratorSettings.MinElev)) + GeneratorSettings.MinElev; var planetImage = new Image(); var planetRenderer = new ImageRenderer(); planetRenderer.SourceNoiseMap = planetElevationMap; planetRenderer.DestinationImage = planetImage; planetRenderer.AddGradientPoint (-16384.0 + seaLevelInMeters, new Color ( 0, 0, 0, 255)); planetRenderer.AddGradientPoint ( -256 + seaLevelInMeters, new Color ( 6, 58, 127, 255)); planetRenderer.AddGradientPoint ( -1.0 + seaLevelInMeters, new Color ( 14, 112, 192, 255)); planetRenderer.AddGradientPoint ( 0.0 + seaLevelInMeters, new Color ( 70, 120, 60, 255)); planetRenderer.AddGradientPoint ( 1024.0 + seaLevelInMeters, new Color (110, 140, 75, 255)); planetRenderer.AddGradientPoint ( 2048.0 + seaLevelInMeters, new Color (160, 140, 111, 255)); planetRenderer.AddGradientPoint ( 3072.0 + seaLevelInMeters, new Color (184, 163, 141, 255)); planetRenderer.AddGradientPoint ( 4096.0 + seaLevelInMeters, new Color (255, 255, 255, 255)); planetRenderer.AddGradientPoint ( 6144.0 + seaLevelInMeters, new Color (128, 255, 255, 255)); planetRenderer.AddGradientPoint ( 16384.0 + seaLevelInMeters, new Color ( 0, 0, 255, 255)); planetRenderer.EnableLight = true; planetRenderer.LightContrast = 1.0 / resInMeters; planetRenderer.LightIntensity = 2; planetRenderer.LightElevation = 45; planetRenderer.LightAzimuth = 135; planetRenderer.Render(); string filename; using(var sfd = new SaveFileDialog()) { sfd.Filter = "PNG Image (*.png)|*.png"; DialogResult result; do { result = sfd.ShowDialog(); } while (result != DialogResult.OK); filename = sfd.FileName; } planetImage.SaveGdiBitmap(filename, System.Drawing.Imaging.ImageFormat.Png); }
public WoodTextureTest() { module = new Turbulence { Seed = 2, Frequency = 2, Power = 1.0 / 64.0, Roughness = 4, Source0 = new RotatePoint { XAngle = 84, Source0 = new TranslatePoint { ZTranslation = 1.48, Source0 = new Turbulence { Seed = 1, Frequency = 4, Power = 1.0 / 256.0, Roughness = 4, Source0 = new Add { Source0 = new Cylinders { Frequency = 16, }, Source1 = new ScaleBias { Scale = 0.25, Bias = 0.125, Source0 = new ScalePoint { YScale = 0.25, Source0 = new Perlin { Seed = 2135, Frequency = 48, Persistence = 0.5, Lacunarity = 2.20703125, OctaveCount = 3, } } } } } } } }; noiseMap = new NoiseMap(); textureImage = new Image(); renderer = new ImageRenderer { EnableLight = false, }; renderer.AddGradientPoint(-1.00, new Color(189, 94, 4, 255)); renderer.AddGradientPoint(0.50, new Color(144, 48, 6, 255)); renderer.AddGradientPoint(1.00, new Color(60, 10, 8, 255)); }