public void CreateHeightMap() { // Set up noise rigged = new RiggedMultifractal(frequency, lacunarity, octaves, seed, quality); perlin = new Perlin(frequency, lacunarity, persistence, octaves, seed, quality); billow = new Billow(frequency, lacunarity, persistence, octaves, seed, quality); //ModuleBase moduleBase = perlin; // Apply noise to the meshes foreach (Transform child in transform) { MeshFilter meshFilter = child.GetComponent <MeshFilter> (); Vector3[] vertices = meshFilter.sharedMesh.vertices; Vector3[] normals = meshFilter.sharedMesh.normals; Color[] colorMap = new Color[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { float magnitude = (float )perlin.GetValue(vertices[i].x / scale, vertices[i].y / scale, vertices[i].z / scale); //float magnitude = (float )rigged.GetValue(vertices[i].x / scale, vertices[i].y / scale, vertices[i].z / scale); vertices [i] = Vector3.MoveTowards(vertices [i], (vertices [i] + normals [i]), magnitude * heightMultiplier); colorMap [i] = gradient.Evaluate((magnitude + 1) * 0.5f); } meshFilter.sharedMesh.vertices = vertices; meshFilter.sharedMesh.colors = colorMap; meshFilter.sharedMesh.RecalculateNormals(); } }
/// <summary> /// Build the noise tree used for terrain generation /// </summary> private Module BuildModuleTree() { var mountainTerrain = new RidgedMulti() { Seed = this.Seed }; var baseFlatTerrain = new Billow() { Seed = this.Seed, Frequency = 2 }; var flatTerrain = new ScaleBias() { Source0 = baseFlatTerrain, Scale = 0.125, Bias = -0.75 }; var terrainType1 = new Perlin() { Frequency = 0.5, Persistence = 0.25, Seed = this.Seed }; var terrainType2 = new Perlin() { Frequency = 0.5, Persistence = 0.25, Seed = this.Seed + 1337 }; var terrainType = new Multiply() { Source0 = terrainType1, Source1 = terrainType2 }; var terrainSelector = new Select() { Source0 = flatTerrain, Source1 = mountainTerrain, Control = terrainType, LowerBound = 0, UpperBound = 1000, EdgeFalloff = 0.125 }; var finalTerrain = new Turbulence() { Source0 = terrainSelector, Frequency = 4, Power = 0.125, Seed = this.Seed }; return(finalTerrain); }
} // Base Height Result Module protected override void SetModules() { base.SetModules(); #region 1 ModuleBase module1 = new Const(5); #endregion #region 2 ModuleBase module2a = new RidgedMultifractal(frequency: Mathf.Pow(2, -8), lacunarity: 2.0, octaves: 6, seed: Random[IdxForRnd].Next(), quality: QualityMode.Low); ModuleBase module2b = new Turbulence(input: module2a); ((Turbulence)module2b).Seed = Random[IdxForRnd].Next(); ((Turbulence)module2b).Frequency = Mathf.Pow(2, -2); ((Turbulence)module2b).Power = 1; ModuleBase module2c = new ScaleBias(scale: 1.0, bias: 30.0, input: module2b); #endregion #region 3 ModuleBase module3a = new Billow(frequency: Mathf.Pow(2, -7) * 1.6, lacunarity: 2.0, persistence: 0.5, octaves: 8, seed: Random[IdxForRnd].Next(), quality: QualityMode.Low); ModuleBase module3b = new Turbulence(input: module3a); ((Turbulence)module3b).Seed = Random[IdxForRnd].Next(); ((Turbulence)module3b).Frequency = Mathf.Pow(2, -2); ((Turbulence)module3b).Power = 1.8; ModuleBase module3c = new ScaleBias(scale: 1.0, bias: 31.0, input: module3b); #endregion #region 4 ModuleBase module4a = new Perlin(frequency: Mathf.Pow(2, -6), lacunarity: 2.0, persistence: 0.5, octaves: 6, seed: Random[IdxForRnd].Next(), quality: QualityMode.Low); ModuleBase module4b = new Select(inputA: module2c, inputB: module3c, controller: module4a); ((Select)module4b).SetBounds(min: -.2, max: .2); ((Select)module4b).FallOff = .25; ModuleBase module4c = new Multiply(lhs: module4b, rhs: module1); #endregion MaterialSelectors[0] = (Select)module4b; Modules.Add(module4c); }
static void Tutorial4() { Console.WriteLine("Begin Tutorial 4"); RiggedMultifractal mountainTerrain = new RiggedMultifractal(); Billow baseFlatTerrain = new Billow(); baseFlatTerrain.Frequency = 2.0; ScaleBias flatTerrain = new ScaleBias(); flatTerrain[0] = baseFlatTerrain; flatTerrain.Scale = 0.125; flatTerrain.Bias = -0.75; Perlin terrainType = new Perlin(); terrainType.Frequency = 0.5; terrainType.Persistence = 0.25; Select finalTerrain = new Select(); finalTerrain[0] = flatTerrain; finalTerrain[1] = mountainTerrain; finalTerrain.Controller = terrainType; finalTerrain.SetBounds(0.0, 1000.0); finalTerrain.FallOff = 0.125; NoiseMap heightMap = new NoiseMap(); NoiseMapBuilderPlane heightMapBuilder = new NoiseMapBuilderPlane();; heightMapBuilder.SetSourceModule(finalTerrain); heightMapBuilder.SetDestNoiseMap(heightMap); heightMapBuilder.SetDestSize(256, 256); heightMapBuilder.SetBounds(6.0, 10.0, 1.0, 5.0); heightMapBuilder.Build(); RendererImage renderer = new RendererImage(); NoiseImage image = new NoiseImage(); renderer.SetSourceNoiseMap(heightMap); renderer.SetDestImage(image); renderer.ClearGradient(); renderer.AddGradientPoint(-1.00, new Color(32, 160, 0, 255)); // grass renderer.AddGradientPoint(-0.25, new Color(224, 224, 0, 255)); // dirt renderer.AddGradientPoint(0.25, new Color(128, 128, 128, 255)); // rock renderer.AddGradientPoint(1.00, new Color(255, 255, 255, 255)); // snow renderer.EnableLight(); renderer.SetLightContrast(3.0); renderer.SetLightBrightness(2.0); renderer.Render(); WriterBMP writer = new WriterBMP(); writer.SetSourceImage(image); writer.SetDestFilename("tutorial4.bmp"); writer.WriteDestFile(); Console.WriteLine("End Tutorial 4"); }
public XNoiseTurbulence() { left = 6; right = 10; top = 1; bottom = 5; var mountainTerrain = new RidgedMultifractal(); var baseFlatTerrain = new Billow(); baseFlatTerrain.Frequency = 2.0; var flatTerrain = new ScaleBias(0.125, -0.75, baseFlatTerrain); var terrainType = new Perlin(); terrainType.Frequency = 0.5; terrainType.Persistence = 0.25; var terrainSelector = new Select(flatTerrain, mountainTerrain, terrainType); terrainSelector.SetBounds(0, 1000); terrainSelector.FallOff = 0.125f; var terrainScaler = new ScaleBias(terrainSelector); terrainScaler.Scale = 375; terrainScaler.Bias = 375; finalTerrain = new Turbulence(terrainScaler); finalTerrain.Frequency = 4; finalTerrain.Power = 0.125f; }
public void Generate() { // Create the module network ModuleBase moduleBase; switch (noise) { case NoiseType.Billow: moduleBase = new Billow(); break; case NoiseType.RidgedMultifractal: moduleBase = new RidgedMultifractal(); break; case NoiseType.Voronoi: moduleBase = new Voronoi(); break; // case NoiseType.Mix: //Perlin perlin = new Perlin(); //RidgedMultifractal rigged = new RidgedMultifractal(); //moduleBase = new Add(perlin, rigged); //break; default: moduleBase = new Perlin(); break; } // Initialize the noise map this.m_noiseMap = new Noise2D(resolution, resolution, moduleBase); this.m_noiseMap.GeneratePlanar( offset + -1 * 1 / zoom, offset + offset + 1 * 1 / zoom, offset + -1 * 1 / zoom, offset + 1 * 1 / zoom); // Generate the textures this.m_textures[0] = this.m_noiseMap.GetTexture(GradientPresets.Grayscale); this.m_textures[0].Apply(); this.m_textures[1] = this.m_noiseMap.GetTexture(GradientPresets.Terrain); this.m_textures[1].Apply(); this.m_textures[2] = this.m_noiseMap.GetNormalMap(3.0f); this.m_textures[2].Apply(); //display on plane GetComponent <Renderer>().material.mainTexture = m_textures[0]; //write images to disk File.WriteAllBytes(Application.dataPath + "/../Gray.png", m_textures[0].EncodeToPNG()); File.WriteAllBytes(Application.dataPath + "/../Terrain.png", m_textures[1].EncodeToPNG()); File.WriteAllBytes(Application.dataPath + "/../Normal.png", m_textures[2].EncodeToPNG()); Debug.Log("Wrote Textures out to " + Application.dataPath + "/../"); }
void Start() { // STEP 1 // Gradient is set directly on the object var mountainTerrain = new RidgedMultifractal(); RenderAndSetImage(mountainTerrain); // Stop rendering if we're only getting as far as this tutorial // step. It saves me from doing multiple files. if (_tutorialStep <= 1) return; // STEP 2 var baseFlatTerrain = new Billow(); baseFlatTerrain.Frequency = 2.0; RenderAndSetImage(baseFlatTerrain); if (_tutorialStep <= 2) return; // STEP 3 var flatTerrain = new ScaleBias(0.125, -0.75, baseFlatTerrain); RenderAndSetImage(flatTerrain); if (_tutorialStep <= 3) return; // STEP 4 var terrainType = new Perlin(); terrainType.Frequency = 0.5; terrainType.Persistence = 0.25; var finalTerrain = new Select(flatTerrain, mountainTerrain, terrainType); finalTerrain.SetBounds(0, 1000); finalTerrain.FallOff = 0.125; RenderAndSetImage(finalTerrain); }
/// <summary> /// Initializes the base mod /// </summary> public override void OnSetup() { Billow billow = new Billow() { Seed = seed, Frequency = 2 * (1f / smoothness) }; ScaleBias scaleBia = new ScaleBias((1f / plainSmoothness), mesaVsPlainsBias, billow); RidgedMultifractal riggedMultifractal = new RidgedMultifractal { Seed = seed, OctaveCount = noisePasses, Frequency = 1 / smoothness }; Perlin perlin = new Perlin { Seed = seed, OctaveCount = noisePasses, Frequency = 1 / plainsVsMountainSmoothness, Persistence = 1 / falloff }; terrainHeightMap = new Select(0, 1, plainsVsMountainThreshold, scaleBia, riggedMultifractal) { Controller = perlin }; }
// This lets us load the modules once when the game starts and then treat them as static. private static void LoadModules(int game_seed) { seed = game_seed; // Create noise functions. mountain = new RidgedMultifractal(); mountain.Seed = seed; baseFlatTerrain = new Billow(); baseFlatTerrain.Seed = seed; baseFlatTerrain.Frequency = 0.5; //0.125 flatTerrain = new ScaleBias(0.0625, -0.75, baseFlatTerrain); //flatTerrain = new LibNoise.Unity.Generator.Const (-0.75); terrainType = new Perlin(); terrainType.Seed = seed; terrainType.Frequency = 0.5; terrainType.Persistence = 0.125; finalTerrain = new Select(flatTerrain, mountain, terrainType); finalTerrain.SetBounds(0.25, 1000.0); finalTerrain.FallOff = 0.125; modules_loaded = true; }
static bool GenBillow2D(MapGenArgs args) { Billow billow2D = new Billow(); billow2D.Seed = args.UseSeed ? args.Seed : new Random().Next(); return(Gen2D(args, billow2D)); }
private void Meh(bool random = false) { if (random) { Noise.xOrg = Random.Range(-1000, 1000); Noise.yOrg = Random.Range(-1000, 1000); } // STEP 1 // Gradient is set directly on the object var mountainTerrain = new RidgedMultifractal(); // STEP 2 var baseFlatTerrain = new Billow(); baseFlatTerrain.Frequency = Noise.Frequency; // STEP 3 var flatTerrain = new ScaleBias(Noise.Scale, Noise.Bias, baseFlatTerrain); // STEP 4 var terrainType = new Perlin(); terrainType.Frequency = Noise.TFrequency; terrainType.Persistence = Noise.Persistence; generator = new Select(flatTerrain, mountainTerrain, terrainType); generator.SetBounds(Noise.Min, Noise.Max); generator.FallOff = Noise.FallOff; RenderAndSetImage(generator); }
void Start() { var mountainTerrain = new RidgedMultifractal(); var baseFlatTerrain = new Billow(); baseFlatTerrain.Frequency = 2.0; var flatTerrain = new ScaleBias(0.125, -0.75, baseFlatTerrain); var terrainType = new Perlin(); terrainType.Frequency = 0.5; terrainType.Persistence = 0.25; // Create the selector for turbulence var terrainSelector = new Select(flatTerrain, mountainTerrain, terrainType); terrainSelector.SetBounds(0, 1000); terrainSelector.FallOff = 0.125f; var finalTerrain = new Turbulence(terrainSelector); finalTerrain.Frequency = _frequency; finalTerrain.Power = _power; RenderAndSetImage(finalTerrain); }
public TerrainGenerator(long seed) { var seededConstant = new SimplexPerlin((int)seed, NoiseQuality.Fast); TurbX = new OpenSimplex(seed); TurbY = new OpenSimplex(seed); Chaos = new RidgedMultiFractal { OctaveCount = 7, Primitive2D = seededConstant }; Hill = new OpenSimplex(seed); Alt = new HybridMultiFractal { OctaveCount = 8, Gain = 0.1f, Primitive2D = seededConstant }; Temp = new OpenSimplex(seed); Dry = new HeterogeneousMultiFractal() { Primitive2D = seededConstant }; Small = new HeterogeneousMultiFractal { OctaveCount = 2, Primitive2D = seededConstant }; Rock = new HybridMultiFractal() { Gain = 0.3f, Primitive2D = seededConstant }; Cliff = new HybridMultiFractal() { Gain = 0.3f, Primitive2D = seededConstant }; Humid = new Billow { OctaveCount = 12, Gain = 0.125f, Frequency = 1, Primitive2D = seededConstant }; }
// Use this for initialization void Start() { IModule mountainTerrain = new RidgedMulti(); IModule baseFlatTerrain = new Billow(); ((Billow)baseFlatTerrain).Frequency = 2.0; IModule flatTerrain = new ScaleBias(baseFlatTerrain, 0.125, -0.75); IModule terrainType = new Perlin(); ((Perlin)terrainType).Frequency = 0.5; ((Perlin)terrainType).Persistence = 0.25; IModule finalTerrain = new Select(flatTerrain, mountainTerrain, terrainType); ((Select)finalTerrain).SetBounds(0.0, 1000.0); ((Select)finalTerrain).SetEdgeFallOff(0.125); NoiseMapBuilderPlane heightMapBuilder = new NoiseMapBuilderPlane(256, 256); heightMapBuilder.SetBounds(6.0, 10.0, 1.0, 5.0); heightMapBuilder.Build(finalTerrain); RendererImage render = new RendererImage(); render.SourceNoiseMap = heightMapBuilder.Map; render.ClearGradient(); render.AddGradientPoint(-1.0000, new Color32(32, 160, 0, 255)); render.AddGradientPoint(-0.2500, new Color32(224, 224, 0, 255)); render.AddGradientPoint(0.2500, new Color32(128, 128, 128, 255)); render.AddGradientPoint(1.0000, new Color32(255, 255, 255, 255)); render.IsLightEnabled = true; render.LightContrast = 3.0; render.LightBrightness = 2.0; render.Render(); tex = render.GetTexture(); }
static bool GenBillow3D(Player p, Level lvl, string seed) { Billow billow3D = new Billow(); billow3D.Seed = MapGen.MakeInt(seed); return(Gen3D(lvl, billow3D)); }
private void Start() { // STEP 1 // Gradient is set directly on the object var mountainTerrain = new RidgedMultifractal(); // // STEP 2 var baseFlatTerrain = new Billow(); baseFlatTerrain.Frequency = 2.0; // STEP 3 var flatTerrain = new ScaleBias(0.125, -0.75, baseFlatTerrain); // STEP 4 var terrainType = new Perlin(); terrainType.Frequency = 0.5; terrainType.Persistence = 0.25; var finalTerrain = new Select(flatTerrain, mountainTerrain, terrainType); finalTerrain.SetBounds(0, 1000); finalTerrain.FallOff = 0.125; float start = Time.realtimeSinceStartup; RenderAndSetImage(finalTerrain); Debug.Log("BurstLibNoise runtime: " + (Time.realtimeSinceStartup - start)); }
public override void OnSetup() { finalStart = rangeStart = sphere.radius; finalEnd = rangeEnd + sphere.radius; switch (noiseType) { case NoiseType.Billow: billow = new Billow(frequency, lacunarity, persistence, Convert.ToInt32(octaves), seed, mode); modMode = 1; break; case NoiseType.HybridMultifractal: hybrid = new HybridMultifractal(frequency, Convert.ToSingle(persistence), Convert.ToInt32(octaves), seed, mode, offset); modMode = 2; break; case NoiseType.Perlin: perlin = new Perlin(frequency, lacunarity, persistence, Convert.ToInt32(octaves), seed, mode); modMode = 3; break; case NoiseType.RiggedMultifractal: rigged = new RiggedMultifractal(frequency, lacunarity, Convert.ToInt32(octaves), seed, mode); modMode = 4; break; default: throw new ArgumentNullException(nameof(noiseType)); } }
void Awake() { noiseGenerator = new NoiseGenerator(); billowModule = new Billow(n1frequency, n1lacunarity, n1persistence, n1octaves, n1seed, QualityMode.High); //(frequency, lacunarity, persistence, octaves, seed, QualityMode.High)); //billowModule = new Voronoi(n1frequency, n1lacunarity, n1seed, true); billowScaleBiasModule = new ScaleBias(n1scale, n1bias, billowModule); ridgedModule = new RidgedMultifractal(n2frequency, n2lacunarity, n2octaves, n2seed, QualityMode.High); ridgedScaleBiasModule = new ScaleBias(n2scale, n2bias, ridgedModule); perlinModule = new Perlin(n3frequency, n3lacunarity, n3persistence, n3octaves, n3seed, QualityMode.High); perlinScaleBiasModule = new ScaleBias(n3scale, n3bias, perlinModule); selectModule = new Select(billowScaleBiasModule, ridgedScaleBiasModule, perlinScaleBiasModule); selectModule.SetBounds(0.5, 1000); // parameterize? selectModule.FallOff = 0.3928571; turbulenceModule = new Turbulence(0.335, selectModule); turbulenceModule.Frequency = 4.742f; turbulenceScaleBias = new ScaleBias(n1scale, n1bias, turbulenceModule); currentModule = billowScaleBiasModule; waterGenerator = GameObject.FindObjectOfType <WaterGenerator> (); }
ModuleBase GetModule(PlanetProfile profile) { ModuleBase Generator; switch (profile.type) { case NoiseType.Perlin: Generator = new Perlin( profile.frequency, profile.lacunarity, profile.persistence, profile.octaves, Random.Range(0, int.MaxValue), QualityMode.Low); break; case NoiseType.Billow: Generator = new Billow( profile.frequency, profile.lacunarity, profile.persistence, profile.octaves, Random.Range(0, int.MaxValue), QualityMode.Low); break; case NoiseType.RiggedMultifractal: Generator = new RidgedMultifractal(profile.frequency, profile.lacunarity, profile.octaves, Random.Range(0, int.MaxValue), QualityMode.Low); break; case NoiseType.Voronoi: Generator = new Voronoi( profile.frequency, profile.displacement, Random.Range(0, int.MaxValue), true); break; default: Generator = new Perlin( profile.frequency, profile.lacunarity, profile.persistence, profile.octaves, Random.Range(0, int.MaxValue), QualityMode.Low); break; } return(Generator); }
public void DiscreteBillowTest() { Billow mbillow = new Billow(); mbillow.Frequency = 0.5; mbillow.Persistence = 0.8; DiscreteMainTestCode(mbillow, 5); }
public override Module GetModule() { int n = 2 + (int)Mathf.Log(_height, 2); var mountainTerrain = new RidgedMulti() { Frequency = 1, Lacunarity = 1.9532562354f, OctaveCount = n, Seed = _seed + 2 * _offset }; var baseFlatTerrain = new Billow() { Frequency = 2, Lacunarity = 2.031242124f, OctaveCount = n, Seed = _seed + 1 * _offset, }; var flatTerrain = new ScaleBias() { Source0 = baseFlatTerrain, Scale = 0.75, Bias = -0.25, }; var terrainType = new Perlin() { Frequency = _frequency, Lacunarity = 2.1023423f, Persistence = 0.25, OctaveCount = n, Seed = _seed }; var terrainSelector = new Select() { Source0 = flatTerrain, Source1 = mountainTerrain, Control = terrainType, LowerBound = 0, UpperBound = 1000, EdgeFalloff = 0.125, }; var finalTerrain = new Turbulence() { Source0 = terrainSelector, Frequency = 4, Roughness = 8, Power = 0.125, }; return(finalTerrain); }
private void UpdateTexture() { texture.Resize(resolution.x, resolution.y); texture.wrapModeU = wrapModeU; texture.wrapModeV = wrapModeV; texture.alphaIsTransparency = true; texture.name = "Noise_" + name; if (seed == 0) { seed = Random.Range(int.MinValue, int.MaxValue); } ModuleBase noiseGenerator; switch (noiseType) { case NoiseType.Billow: Billow billow = new Billow(frequency, lacunarity, persistence, octaves, seed, QualityMode.High); noiseGenerator = billow; break; case NoiseType.RidgedMultifractal: RidgedMultifractal ridgedMultifractal = new RidgedMultifractal(frequency, lacunarity, octaves, seed, QualityMode.High); noiseGenerator = ridgedMultifractal; break; case NoiseType.Voronoi: Voronoi voronoi = new Voronoi(frequency, displacement, seed, distance); noiseGenerator = voronoi; break; default: //Default to perlin so the compiled doesn't complain Perlin perlin = new Perlin(frequency, lacunarity, persistence, octaves, seed, QualityMode.High); noiseGenerator = perlin; break; } Noise2D noiseMap = new Noise2D(resolution.x, resolution.y, noiseGenerator); noiseMap.GeneratePlanar( offset.x + -1 * 1 / zoom.x, offset.x + offset.x + 1 * 1 / zoom.x, offset.y + -1 * 1 / zoom.y, offset.y + 1 * 1 / zoom.y, isSeamless ); Texture2D noiseTexture = noiseMap.GetTexture(colorGradient); Color32[] colorArray = noiseTexture.GetPixels32(); texture.SetPixels32(0, 0, texture.width, texture.height, colorArray); texture.Apply(); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(texture)); EditorUtility.SetDirty(this); }
protected override ModuleBase CreateAndReadyModule() { Billow billow = new Billow(); billow.Quality = quality; billow.Seed = seed; billow.Frequency = frequency; billow.OctaveCount = octaves; billow.Lacunarity = lacunarity; billow.Persistence = persistance; return billow; }
public static IModule Billow() { var module = new Billow(); module.Frequency = 0.08f; module.Lacunarity = 2; module.OctaveCount = 6; module.NoiseQuality = NoiseQuality.High; module.Seed = 0; return(module); }
public TerrainConfigurationComponent() { Width = Height = 256; TextureRepeat = 8 * 2;// * 4 IsModified = true; Correction = 20; ElevationPower = 1; Mountain = new RidgedMulti() { Seed = 0, Frequency = 1, Lacunarity = 2, OctaveCount = 6 }; Flat = new Billow() { Frequency = 2, Seed = 0, Lacunarity = 2, OctaveCount = 3 }; FlatScale = new ScaleBias() { //Scale = 0.125, //Bias = -0.75, Bias = 0.05, Scale = 0.12, }; Noise = new Perlin() { Frequency = 0.5, Persistence = 0.25, Seed = 0, OctaveCount = 6 }; Select = new Select() { LowerBound = 0, UpperBound = 1000, EdgeFalloff = 0.125, }; Turbulence = new Turbulence() { Frequency = 1.6, Power = 0.125, Roughness = 2, }; }
protected override ModuleBase CreateAndReadyModule() { Billow billow = new Billow(); billow.Quality = quality; billow.Seed = seed; billow.Frequency = frequency; billow.OctaveCount = octaves; billow.Lacunarity = lacunarity; billow.Persistence = persistance; return(billow); }
public IModule3D CreateModule() { FilterModule filterModule = null; switch (filter) { case NoiseFilter.Pipe: filterModule = new Pipe(); break; case NoiseFilter.SumFractal: filterModule = new SumFractal(); break; case NoiseFilter.SinFractal: filterModule = new SinFractal(); break; case NoiseFilter.MultiFractal: filterModule = new MultiFractal(); break; case NoiseFilter.Billow: filterModule = new Billow(); break; case NoiseFilter.HeterogeneousMultiFractal: filterModule = new HeterogeneousMultiFractal(); break; case NoiseFilter.HybridMultiFractal: filterModule = new HybridMultiFractal(); break; case NoiseFilter.RidgedMultiFractal: filterModule = new RidgedMultiFractal(); break; case NoiseFilter.Voronoi: filterModule = new Voronoi(); break; } if (filterModule != null) { filterModule.Frequency = frequency; filterModule.Lacunarity = lacunarity; filterModule.OctaveCount = (float)octaves; filterModule.Offset = offset; filterModule.Gain = gain; } return((IModule3D)filterModule); }
private ModuleBase chooseModuleBase(NoiseType moduleType) { ModuleBase moduleBase; switch (moduleType) { case NoiseType.Billow: moduleBase = new Billow(); break; case NoiseType.RiggedMultifractal: moduleBase = new RiggedMultifractal(); break; case NoiseType.Voronoi: moduleBase = new Voronoi(); break; case NoiseType.Checker: moduleBase = new Checker(); break; case NoiseType.Cylinders: moduleBase = new Cylinders(); break; case NoiseType.Spheres: moduleBase = new Spheres(); break; case NoiseType.Mix: Perlin perlin = new Perlin(); RiggedMultifractal rigged = new RiggedMultifractal(); moduleBase = new Add(perlin, rigged); break; case NoiseType.RiggedMChecker: Checker checker = new Checker(); RiggedMultifractal rigged2 = new RiggedMultifractal(); moduleBase = new Add(checker, rigged2); break; default: moduleBase = new Perlin(); break; } return(moduleBase); }
void Start() { // STEP 1 // Gradient is set directly on the object var mountainTerrain = new RidgedMultifractal(); RenderAndSetImage(mountainTerrain); // Stop rendering if we're only getting as far as this tutorial // step. It saves me from doing multiple files. if (_tutorialStep <= 1) { return; } // STEP 2 var baseFlatTerrain = new Billow(); baseFlatTerrain.Frequency = 2.0; RenderAndSetImage(baseFlatTerrain); if (_tutorialStep <= 2) { return; } // STEP 3 var flatTerrain = new ScaleBias(0.125, -0.75, baseFlatTerrain); RenderAndSetImage(flatTerrain); if (_tutorialStep <= 3) { return; } // STEP 4 var terrainType = new Perlin(); terrainType.Frequency = 0.5; terrainType.Persistence = 0.25; var finalTerrain = new Select(flatTerrain, mountainTerrain, terrainType); finalTerrain.SetBounds(0, 1000); finalTerrain.FallOff = 0.125; RenderAndSetImage(finalTerrain); }
// Use this for initialization void Start() { IModule primaryGranite = new Billow(); ((Billow)primaryGranite).Seed = 0; ((Billow)primaryGranite).Frequency = 8.0; ((Billow)primaryGranite).Persistence = 0.625; ((Billow)primaryGranite).Lacunarity = 2.18359375; ((Billow)primaryGranite).OctaveCount = 6; ((Billow)primaryGranite).NoiseQuality = NoiseQuality.Standard; IModule baseGrains = new Voronoi(); ((Voronoi)baseGrains).Seed = 1; ((Voronoi)baseGrains).Frequency = 16.0; ((Voronoi)baseGrains).EnableDistance = true; IModule scaledGrains = new ScaleBias(baseGrains); ((ScaleBias)scaledGrains).Scale = -0.5; ((ScaleBias)scaledGrains).Bias = 0.0; IModule combinedGranite = new Add(primaryGranite, scaledGrains); IModule finalGranite = new Turbulence(combinedGranite); ((Turbulence)finalGranite).Seed = 2; ((Turbulence)finalGranite).Frequency = 4.0; ((Turbulence)finalGranite).Power = 1.0 / 8.0; ((Turbulence)finalGranite).Roughness = 6; NoiseMapBuilderPlane plane = new NoiseMapBuilderPlane(256, 256); plane.SetBounds(-1.0, 1.0, -1.0, 1.0); plane.Build(finalGranite); RendererImage render = new RendererImage(); render.SourceNoiseMap = plane.Map; render.ClearGradient(); render.AddGradientPoint(-1.0000, new Color32(0, 0, 0, 255)); render.AddGradientPoint(-0.9375, new Color32(0, 0, 0, 255)); render.AddGradientPoint(-0.8750, new Color32(216, 216, 242, 255)); render.AddGradientPoint(0.0000, new Color32(191, 191, 191, 255)); render.AddGradientPoint(0.5000, new Color32(210, 116, 125, 255)); render.AddGradientPoint(0.7500, new Color32(210, 113, 98, 255)); render.AddGradientPoint(1.0000, new Color32(255, 176, 192, 255)); render.IsLightEnabled = true; render.LightAzimuth = 135.0; render.LightElev = 60.0; render.LightContrast = 2.0; render.LightColor = new Color32(255, 255, 255, 0); render.Render(); tex = render.GetTexture(); }
void Generate() { billowModule = new Billow(); offsetModule = new Translate(0, 1, 0, billowModule); myModule = new Turbulence(1, offsetModule); Noise2D heightMapBuilder = new Noise2D(terrain.Width, terrain.Height, myModule); heightMapBuilder.GenerateSpherical(-90, 90, -180, 180); weatherImage = heightMapBuilder.GetTexture(); weatherImage.Apply(); GetComponent <LODMaterial>().OurMaterial.SetTexture("_Weather", weatherImage); }
private bool sygnalize = true; //Should we mark containers for regeneration/processing? public void Initialize() { billow = new Billow(); billow.Seed = Seed; fractal = new RiggedMultifractal(); fractal.Seed = Seed; UnityEngine.Random.seed = Seed; billow.Frequency = UnityEngine.Random.value + 0.5; fractal.Frequency = UnityEngine.Random.value + 0.5; //int x,y,z; //Utils.LongToVoxelCoord(38655688717L, out x, out y, out z); //Debug.LogWarning("" + x + " " + y + " " + z); generables.Add(new GenTree()); }
void NoiseSelector() { // Requires LibNoise in your project // https://github.com/ricardojmendez/LibNoise.Unity switch (noiseType) { case NoiseMode.Billow: var billow = new Billow(); billow.Seed = seed; billow.Quality = quality; billow.OctaveCount = _octaveCount; billow.Frequency = _frecuency * 0.1; billow.Lacunarity = _lacunarity; billow.Persistence = _persistence; generate = billow; break; case NoiseMode.Perlin: var perlin = new Perlin(); perlin.Seed = seed; perlin.Quality = quality; perlin.OctaveCount = _octaveCount; perlin.Frequency = _frecuency * 0.1; perlin.Lacunarity = _lacunarity; perlin.Persistence = _persistence; generate = perlin; break; case NoiseMode.RidgedMultifractal: var multiFractal = new RidgedMultifractal(); multiFractal.Seed = seed; multiFractal.Quality = quality; multiFractal.OctaveCount = _octaveCount; multiFractal.Frequency = _frecuency * 0.1; multiFractal.Lacunarity = _lacunarity; generate = multiFractal; break; case NoiseMode.Voronoi: var voroni = new Voronoi(); voroni.Seed = seed; voroni.Frequency = _frecuency; voroni.Displacement = _displacement; generate = voroni; break; default: break; } }
void Start() { var mountainTerrain = new RidgedMultifractal(); var baseFlatTerrain = new Billow(); baseFlatTerrain.Frequency = 2.0; var flatTerrain = new ScaleBias(0.125, -0.75, baseFlatTerrain); var terrainType = new Perlin(); terrainType.Frequency = 0.5; terrainType.Persistence = 0.25; var terrainSelector = new Select(flatTerrain, mountainTerrain, terrainType); terrainSelector.SetBounds(0, 1000); terrainSelector.FallOff = 0.125f; /* * From the tutorial text: * * Next, you'll apply a bias of +375 to the output from the terrainSelector * noise module. This will cause its output to range from (-375 + 375) to * (+375 + 375), or in other words, 0 to 750. You'll apply this bias so * that most of the elevations in the resulting terrain height map are * above sea level. */ var terrainScaler = new ScaleBias(terrainSelector); terrainScaler.Scale = _scale; terrainScaler.Bias = _bias; var finalTerrain = new Turbulence(terrainScaler); finalTerrain.Frequency = _frequency; finalTerrain.Power = _power; RenderAndSetImage(finalTerrain); }
private static List<LoadedModule> GetModules(XmlNodeList moduleList) { List<LoadedModule> loadedModules = new List<LoadedModule>(); foreach (XmlNode node in moduleList) { string id = node.Attributes["guid"].Value; Point position = new Point(double.Parse(node.Attributes["position"].Value.Split(',')[0]), double.Parse(node.Attributes["position"].Value.Split(',')[1])); ModuleBase module = null; List<string> links = new List<string>(); switch (node.Attributes["type"].Value) { case "Billow": Billow billow = new Billow(); billow.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); billow.Lacunarity = double.Parse(node.SelectSingleNode("Lacunarity").InnerText); billow.OctaveCount = int.Parse(node.SelectSingleNode("OctaveCount").InnerText); billow.Persistence = double.Parse(node.SelectSingleNode("Persistence").InnerText); billow.Quality = (QualityMode)Enum.Parse(typeof(QualityMode), node.SelectSingleNode("Quality").InnerText); billow.Seed = int.Parse(node.SelectSingleNode("Seed").InnerText); module = billow; break; case "Checker": module = new Checker(); break; case "Const": Const con = new Const(); con.Value = double.Parse(node.SelectSingleNode("Value").InnerText); module = con; break; case "Cylinders": Cylinders cylinder = new Cylinders(); cylinder.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); module = cylinder; break; case "Perlin": Perlin perlin = new Perlin(); perlin.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); perlin.Lacunarity = double.Parse(node.SelectSingleNode("Lacunarity").InnerText); perlin.OctaveCount = int.Parse(node.SelectSingleNode("OctaveCount").InnerText); perlin.Persistence = double.Parse(node.SelectSingleNode("Persistence").InnerText); perlin.Quality = (QualityMode)Enum.Parse(typeof(QualityMode), node.SelectSingleNode("Quality").InnerText); perlin.Seed = int.Parse(node.SelectSingleNode("Seed").InnerText); module = perlin; break; case "RidgedMultifractal": RidgedMultifractal ridgedMF = new RidgedMultifractal(); ridgedMF.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); ridgedMF.Lacunarity = double.Parse(node.SelectSingleNode("Lacunarity").InnerText); ridgedMF.OctaveCount = int.Parse(node.SelectSingleNode("OctaveCount").InnerText); ridgedMF.Quality = (QualityMode)Enum.Parse(typeof(QualityMode), node.SelectSingleNode("Quality").InnerText); ridgedMF.Seed = int.Parse(node.SelectSingleNode("Seed").InnerText); module = ridgedMF; break; case "Spheres": Spheres spheres = new Spheres(); spheres.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); module = spheres; break; case "Voronoi": Voronoi voronoi = new Voronoi(); voronoi.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); voronoi.Displacement = double.Parse(node.SelectSingleNode("Displacement").InnerText); voronoi.UseDistance = bool.Parse(node.SelectSingleNode("UseDistance").InnerText); voronoi.Seed = int.Parse(node.SelectSingleNode("Seed").InnerText); module = voronoi; break; case "Abs": module = new Abs(); XmlNode absInputs = node.SelectSingleNode("ModuleInputs"); links.Add(absInputs.SelectSingleNode("Input").InnerText); break; case "Add": module = new Add(); XmlNode addInputs = node.SelectSingleNode("ModuleInputs"); links.Add(addInputs.SelectSingleNode("Left").InnerText); links.Add(addInputs.SelectSingleNode("Right").InnerText); break; case "Blend": module = new Blend(); XmlNode blendInputs = node.SelectSingleNode("ModuleInputs"); links.Add(blendInputs.SelectSingleNode("Left").InnerText); links.Add(blendInputs.SelectSingleNode("Right").InnerText); links.Add(blendInputs.SelectSingleNode("Operator").InnerText); break; case "Cache": module = new Cache(); XmlNode cacheInputs = node.SelectSingleNode("ModuleInputs"); links.Add(cacheInputs.SelectSingleNode("Input").InnerText); break; case "Clamp": Clamp clamp = new Clamp(); clamp.Maximum = double.Parse(node.SelectSingleNode("Maximum").InnerText); clamp.Minimum = double.Parse(node.SelectSingleNode("Minimum").InnerText); module = clamp; XmlNode clampInputs = node.SelectSingleNode("ModuleInputs"); links.Add(clampInputs.SelectSingleNode("Input").InnerText); break; case "Curve": Curve curve = new Curve(); module = curve; foreach (XmlNode cpNode in node.SelectSingleNode("ControlPoints").ChildNodes) { double x = double.Parse(cpNode.InnerText.Split(',')[0]); double y = double.Parse(cpNode.InnerText.Split(',')[1]); curve.Add(x, y); } XmlNode curveInputs = node.SelectSingleNode("ModuleInputs"); links.Add(curveInputs.SelectSingleNode("Input").InnerText); break; case "Displace": module = new Displace(); XmlNode displaceInputs = node.SelectSingleNode("ModuleInputs"); links.Add(displaceInputs.SelectSingleNode("Primary").InnerText); links.Add(displaceInputs.SelectSingleNode("X").InnerText); links.Add(displaceInputs.SelectSingleNode("Y").InnerText); links.Add(displaceInputs.SelectSingleNode("Z").InnerText); break; case "Exponent": Exponent exponent = new Exponent(); exponent.Value = double.Parse(node.SelectSingleNode("Value").InnerText); module = exponent; XmlNode exponentInputs = node.SelectSingleNode("ModuleInputs"); links.Add(exponentInputs.SelectSingleNode("Input").InnerText); break; case "Invert": module = new Invert(); XmlNode invertInputs = node.SelectSingleNode("ModuleInputs"); links.Add(invertInputs.SelectSingleNode("Input").InnerText); break; case "Max": module = new Max(); XmlNode maxInputs = node.SelectSingleNode("ModuleInputs"); links.Add(maxInputs.SelectSingleNode("Left").InnerText); links.Add(maxInputs.SelectSingleNode("Right").InnerText); break; case "Min": module = new Min(); XmlNode minInputs = node.SelectSingleNode("ModuleInputs"); links.Add(minInputs.SelectSingleNode("Left").InnerText); links.Add(minInputs.SelectSingleNode("Right").InnerText); break; case "Multiply": module = new Multiply(); XmlNode multiplyInputs = node.SelectSingleNode("ModuleInputs"); links.Add(multiplyInputs.SelectSingleNode("Left").InnerText); links.Add(multiplyInputs.SelectSingleNode("Right").InnerText); break; case "Power": module = new Power(); XmlNode powerInputs = node.SelectSingleNode("ModuleInputs"); links.Add(powerInputs.SelectSingleNode("Left").InnerText); links.Add(powerInputs.SelectSingleNode("Right").InnerText); break; case "Rotate": Rotate rotate = new Rotate(); rotate.X = double.Parse(node.SelectSingleNode("X").InnerText); rotate.Y = double.Parse(node.SelectSingleNode("Y").InnerText); rotate.Z = double.Parse(node.SelectSingleNode("Z").InnerText); module = rotate; XmlNode rotateInputs = node.SelectSingleNode("ModuleInputs"); links.Add(rotateInputs.SelectSingleNode("Input").InnerText); break; case "Scale": Scale scale = new Scale(); scale.X = double.Parse(node.SelectSingleNode("X").InnerText); scale.Y = double.Parse(node.SelectSingleNode("Y").InnerText); scale.Z = double.Parse(node.SelectSingleNode("Z").InnerText); module = scale; XmlNode scaleInputs = node.SelectSingleNode("ModuleInputs"); links.Add(scaleInputs.SelectSingleNode("Input").InnerText); break; case "ScaleBias": ScaleBias scaleBias = new ScaleBias(); scaleBias.Scale = double.Parse(node.SelectSingleNode("Scale").InnerText); scaleBias.Bias = double.Parse(node.SelectSingleNode("Bias").InnerText); module = scaleBias; XmlNode scaleBiasInputs = node.SelectSingleNode("ModuleInputs"); links.Add(scaleBiasInputs.SelectSingleNode("Input").InnerText); break; case "Select": Select select = new Select(); select.Minimum = double.Parse(node.SelectSingleNode("Minimum").InnerText); select.Maximum = double.Parse(node.SelectSingleNode("Maximum").InnerText); select.FallOff = double.Parse(node.SelectSingleNode("FallOff").InnerText); module = select; XmlNode selectInputs = node.SelectSingleNode("ModuleInputs"); links.Add(selectInputs.SelectSingleNode("Primary").InnerText); links.Add(selectInputs.SelectSingleNode("Secondary").InnerText); links.Add(selectInputs.SelectSingleNode("Controller").InnerText); break; case "Subtract": module = new Subtract(); XmlNode subtractInputs = node.SelectSingleNode("ModuleInputs"); links.Add(subtractInputs.SelectSingleNode("Left").InnerText); links.Add(subtractInputs.SelectSingleNode("Right").InnerText); break; case "Terrace": Terrace terrace = new Terrace(); module = terrace; foreach (XmlNode cpNode in node.SelectSingleNode("ControlPoints").ChildNodes) { terrace.Add(double.Parse(cpNode.InnerText)); } XmlNode terraceInputs = node.SelectSingleNode("ModuleInputs"); links.Add(terraceInputs.SelectSingleNode("Input").InnerText); break; case "Translate": Translate translate = new Translate(); translate.X = double.Parse(node.SelectSingleNode("X").InnerText); translate.Y = double.Parse(node.SelectSingleNode("Y").InnerText); translate.Z = double.Parse(node.SelectSingleNode("Z").InnerText); module = translate; XmlNode translateInputs = node.SelectSingleNode("ModuleInputs"); links.Add(translateInputs.SelectSingleNode("Input").InnerText); break; case "Turbulence": Turbulence turbulence = new Turbulence(); turbulence.Frequency = double.Parse(node.SelectSingleNode("Frequency").InnerText); turbulence.Power = double.Parse(node.SelectSingleNode("Power").InnerText); turbulence.Roughness = int.Parse(node.SelectSingleNode("Roughness").InnerText); turbulence.Seed = int.Parse(node.SelectSingleNode("Seed").InnerText); module = turbulence; XmlNode turbulenceInputs = node.SelectSingleNode("ModuleInputs"); links.Add(turbulenceInputs.SelectSingleNode("Input").InnerText); break; case "Final": module = new Final(); XmlNode finalInputs = node.SelectSingleNode("ModuleInputs"); links.Add(finalInputs.SelectSingleNode("Input").InnerText); break; default: break; } LoadedModule lm = new LoadedModule(id, module, position, links); loadedModules.Add(lm); } return loadedModules; }
public void Generate () { // Create the module network ModuleBase moduleBase; switch (noise) { case NoiseType.Billow: moduleBase = new Billow (); break; case NoiseType.RidgedMultifractal: moduleBase = new RidgedMultifractal (); break; case NoiseType.Voronoi: // moduleBase = new Voronoi(); seed = UnityEngine.Random.Range (0, 100); moduleBase = new Voronoi (frequency, displacement, seed, false); break; case NoiseType.Mix: Perlin perlin = new Perlin (); var rigged = new RidgedMultifractal (); moduleBase = new Add (perlin, rigged); break; case NoiseType.Practice: var bill = new Billow (); bill.Frequency = frequency; moduleBase = new Turbulence (turbulence / 10, bill); break; default: var defPerlin = new Perlin (); defPerlin.OctaveCount = perlinOctaves; moduleBase = defPerlin; break; } // Initialize the noise map this.m_noiseMap = new Noise2D (resolution, resolution, moduleBase); this.m_noiseMap.GeneratePlanar ( offset + -1 * 1 / zoom, offset + offset + 1 * 1 / zoom, offset + -1 * 1 / zoom, offset + 1 * 1 / zoom, true); // Generate the textures this.m_textures [0] = this.m_noiseMap.GetTexture (GradientPresets.Grayscale); this.m_textures [0].Apply (); this.m_textures [1] = this.m_noiseMap.GetTexture (GradientPresets.Terrain); this.m_textures [1].Apply (); this.m_textures [2] = this.m_noiseMap.GetNormalMap (3.0f); this.m_textures [2].Apply (); //display on plane renderer.material.mainTexture = this.m_textures [0]; //write images to disk File.WriteAllBytes (Application.dataPath + "/../Gray.png", m_textures [0].EncodeToPNG ()); File.WriteAllBytes (Application.dataPath + "/../Terrain.png", m_textures [1].EncodeToPNG ()); File.WriteAllBytes (Application.dataPath + "/../Normal.png", m_textures [2].EncodeToPNG ()); Debug.Log ("Wrote Textures out to " + Application.dataPath + "/../"); }
public static void genNoise(int channelId) { moduleBase[channelId] = new Perlin(); if (teNoiseChanTypeIndex[channelId] == 1) { int tIdx = teNoiseTypeIndex[channelId]; if (tIdx == 0) { moduleBase[channelId] = new Perlin(frequency[channelId], lacunarity[channelId], persistance[channelId], octaves[channelId], seed[channelId], QualityMode.High); } if (tIdx == 1) { moduleBase[channelId] = new Billow(frequency[channelId], lacunarity[channelId], persistance[channelId], octaves[channelId], seed[channelId], QualityMode.High); } if (tIdx == 2) { moduleBase[channelId] = new RidgedMultifractal(frequency[channelId], lacunarity[channelId], octaves[channelId], seed[channelId], QualityMode.High); } if (tIdx == 3) { moduleBase[channelId] = new Voronoi(frequency[channelId], displacement[channelId], seed[channelId], distance[channelId]); } if (tIdx == 4) { moduleBase[channelId] = new BrownianMotion(frequency[channelId], lacunarity[channelId], octaves[channelId], seed[channelId], QualityMode.High); } if (tIdx == 5) { moduleBase[channelId] = new HeterogeneousMultiFractal(frequency[channelId], lacunarity[channelId], octaves[channelId], persistance[channelId], seed[channelId], offset[channelId], QualityMode.High); } if (tIdx == 6) { moduleBase[channelId] = new HybridMulti(frequency[channelId], lacunarity[channelId], octaves[channelId], persistance[channelId], seed[channelId], offset[channelId], gain[channelId], QualityMode.High); } if (tIdx == 7) { moduleBase[channelId] = new LinearGradientNoise(frequency[channelId]); } } if (teNoiseChanTypeIndex[channelId] == 2) { int fIdx = teFunctionTypeIndex[channelId]; if (fIdx == 0) { moduleBase[channelId] = new Add(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); } if (fIdx == 1) { moduleBase[channelId] = new Subtract(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); } if (fIdx == 2) { moduleBase[channelId] = new Multiply(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); } if (fIdx == 3) { moduleBase[channelId] = new Min(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); } if (fIdx == 4) { moduleBase[channelId] = new Max(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]]); } if (fIdx == 5) { moduleBase[channelId] = new Blend(moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]], moduleBase[srcChannel3Id[channelId]]); } if (fIdx == 6) { moduleBase[channelId] = new Clamp((double)noiseFuncMin[channelId], (double)noiseFuncMax[channelId], moduleBase[srcChannel1Id[channelId]]); } if (fIdx == 7) { moduleBase[channelId] = new Power(moduleBase[srcChannel1Id[channelId]],moduleBase[srcChannel2Id[channelId]]);} if (fIdx == 8) { Curve tmpCurve = new Curve(moduleBase[srcChannel1Id[channelId]]); double adjust = double.Parse((controlpointcount[channelId]-1).ToString())*0.5; for(int i=0;i<controlpointcount[channelId];i++){ tmpCurve.Add(double.Parse(i.ToString())-adjust,(double)cpval[channelId,i]); moduleBase[channelId] = tmpCurve; } } if(fIdx==9){Terrace tmpTerrace = new Terrace(invertTerrace[channelId],moduleBase[srcChannel1Id[channelId]]); for(int i=0;i<controlpointcount[channelId];i++){ tmpTerrace.Add((double)cpval[channelId,i]-0.5); moduleBase[channelId] = tmpTerrace; } } if (fIdx == 18) { moduleBase[channelId] = new Mask(moduleBase[srcChannel1Id[channelId]], (double)noiseFuncMin[channelId], (double)noiseFuncMax[channelId]); } if (fIdx == 17) { moduleBase[channelId] = new WindexWarp(moduleBase[srcChannel1Id[channelId]]); } if (fIdx == 16) { moduleBase[channelId] = new TEWarp(moduleBase[srcChannel1Id[channelId]]); } if (fIdx == 15) { moduleBase[channelId] = new Select((double)noiseFuncMin[channelId], (double)noiseFuncMax[channelId], falloff[channelId], moduleBase[srcChannel1Id[channelId]], moduleBase[srcChannel2Id[channelId]], moduleBase[srcChannel3Id[channelId]]); } if (fIdx == 14) { moduleBase[channelId] = new Turbulence(power[channelId],moduleBase[srcChannel1Id[channelId]]); } if (fIdx == 13) { moduleBase[channelId] = new ScaleBias(scale[channelId],bias[channelId],moduleBase[srcChannel1Id[channelId]]); } if (fIdx == 12) { moduleBase[channelId] = new Invert(moduleBase[srcChannel1Id[channelId]]);} if (fIdx == 11) { moduleBase[channelId] = new Exponent(exponent[channelId],moduleBase[srcChannel1Id[channelId]]); } if (fIdx == 10) { moduleBase[channelId] = new Abs(moduleBase[srcChannel1Id[channelId]]);} } int resolution = 64; int xoffset = 0; int yoffset = 0; m_noiseMap[channelId] = new Noise2D(resolution, resolution, moduleBase[channelId]); float x1 = xoffset * zoom[channelId]; float x2 = (xoffset * zoom[channelId]) + ((zoom[channelId] / resolution) * (resolution + 1)); float y1 = -yoffset * zoom[channelId]; float y2 = (-yoffset * zoom[channelId]) + ((zoom[channelId] / resolution) * (resolution + 1)); m_noiseMap[channelId].GeneratePlanar(x1, x2, y1, y2); m_textures[channelId] = m_noiseMap[channelId].GetTexture(); m_textures[channelId].Apply(); }
public bool StartGame (double max, double min, int seed, int numberOfSites, double ParsedContinentFrequency, double ParsedBiomeFrequency, int ParsedOctaves, double ParsedLacunarity, double ParsedPersistence) { Debug.Log ("Starting the game, Max is:" + max); Max = max; Min = min; Seed = seed; NumberOfSites = numberOfSites; baseContinentNoise = new Perlin (ParsedContinentFrequency, ParsedLacunarity, ParsedPersistence, ParsedOctaves, seed, LibNoise.Unity.QualityMode.Medium); baseContinentSubtractNoise = new Scale (3, 1, 3, baseContinentNoise); Subtract sub = new Subtract (baseContinentNoise, baseContinentSubtractNoise); perturbedContinentNoise = new Turbulence (1, sub); mountainNoise = new RiggedMultifractal (ParsedBiomeFrequency, ParsedLacunarity, ParsedOctaves, seed, LibNoise.Unity.QualityMode.Medium); baseFlatTerrainNoise = new Billow (ParsedBiomeFrequency, ParsedLacunarity, ParsedPersistence, ParsedOctaves, seed, LibNoise.Unity.QualityMode.Medium); flatTerrainNoise = new ScaleBias (0.25, -0.75, baseFlatTerrainNoise); terrainTypeNoise = new Perlin (ParsedBiomeFrequency, ParsedLacunarity, ParsedPersistence, ParsedOctaves, seed, LibNoise.Unity.QualityMode.Low); finalTerrainNoise = new Select (flatTerrainNoise, mountainNoise, terrainTypeNoise); finalTerrainNoise.SetBounds (0, 1000); finalTerrainNoise.FallOff = .5; finalTerrainNoiseMinusContinentNoise = new Subtract(finalTerrainNoise,perturbedContinentNoise); heatNoise = new Perlin (ParsedBiomeFrequency, ParsedLacunarity, ParsedPersistence, ParsedOctaves, seed, LibNoise.Unity.QualityMode.Medium); moistureNoise = new Perlin (ParsedBiomeFrequency, ParsedLacunarity, ParsedPersistence, ParsedOctaves, -seed, LibNoise.Unity.QualityMode.Medium); return BuildGraph (); }