Provides a noise module that outputs a three-dimensional billowy noise. [GENERATOR]
Inheritance: ModuleBase
Example #1
0
    public void Generate()
    {
        // Create the module network
            ModuleBase moduleBase;
            switch(noise) {
                case NoiseType.Billow:
                moduleBase = new Billow();
                break;

                case NoiseType.RiggedMultifractal:
                moduleBase = new RiggedMultifractal();
                break;

                case NoiseType.Voronoi:
                moduleBase = new Voronoi();
                break;

              	case NoiseType.Mix:
                Perlin perlin = new Perlin();
                RiggedMultifractal rigged = new RiggedMultifractal();
                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);

        Debug.Log (moduleBase.GetValue (0, 0, UnityEngine.Random.value));

            // Generate the textures
            this.m_textures[0] = this.m_noiseMap.GetTexture(LibNoise.Unity.Gradient.Grayscale);
            this.m_textures[0].Apply();

            this.m_textures[1] = this.m_noiseMap.GetTexture(LibNoise.Unity.Gradient.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 + "/../");
    }
Example #2
0
 public Noise(float s, float p, float o, Calculate c, Generator g) {
     scale = s; power = p; offset = o; calc = c;
     if (g == Generator.Vonoroi)
         vonoroi = Generators.Vonoroi(0.1, offset);
     else if (g == Generator.Perlin)
         perlin = Generators.Perlin(0.1, offset);
     else if (g == Generator.Billow)
         billow = Generators.Billow(0.1, offset);
     generator = g;
 }
	public override void GenerateNoise ()
	{
		noiseModule = new Billow (noiseSettings.frequency, noiseSettings.lacunarity, noiseSettings.persistence, noiseSettings.octaves, seed, noiseSettings.quality);
	}
Example #4
0
    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());
    }
 public void PostApply(ConfigNode node)
 {
     switch (type)
     {
     case NoiseType.Perlin:
         var perlin = new Perlin ();
         perlin.Quality = QualityMode.High;
         perlin.Seed = seed;
         perlin.OctaveCount = octaves;
         perlin.Frequency = frequency;
         perlin.Lacunarity = lacunarity;
         perlin.Persistence = persistence;
         Module = perlin;
         break;
     case NoiseType.ExDistPerlin:
         var exDistPerlin = new ExDistPerlin ();
         exDistPerlin.Quality = QualityMode.High;
         exDistPerlin.Seed = seed;
         exDistPerlin.OctaveCount = octaves;
         exDistPerlin.Frequency = frequency;
         exDistPerlin.Lacunarity = lacunarity;
         exDistPerlin.Persistence = persistence;
         exDistPerlin.Mu = mu;
         Module = exDistPerlin;
         break;
     case NoiseType.Billow:
         var billow = new Billow ();
         billow.Quality = QualityMode.High;
         billow.Seed = seed;
         billow.OctaveCount = octaves;
         billow.Frequency = frequency;
         billow.Lacunarity = lacunarity;
         billow.Persistence = persistence;
         Module = billow;
         break;
     case NoiseType.RidgedMultiFractal:
         var ridgedMultiFractal = new RiggedMultifractal ();
         ridgedMultiFractal.Quality = QualityMode.High;
         ridgedMultiFractal.Seed = seed;
         ridgedMultiFractal.OctaveCount = octaves;
         ridgedMultiFractal.Frequency = frequency;
         ridgedMultiFractal.Lacunarity = lacunarity;
         Module = ridgedMultiFractal;
         break;
     case NoiseType.Voronoi:
         var voronoi = new Voronoi ();
         voronoi.Seed = seed;
         voronoi.UseDistance = voronoiUseDistance;
         voronoi.Displacement = displacement;
         voronoi.Frequency = frequency;
         Module = voronoi;
         break;
     case NoiseType.Const:
         var constant = new Const ();
         constant.Value = constantValue;
         Module = constant;
         break;
     }
 }