public void RidgedMultifractal()
 {
     LibNoise.Generator.RidgedMultifractal _noise = new LibNoise.Generator.RidgedMultifractal();
     _noise.Seed        = Seed;
     _noise.OctaveCount = OctaveCount;
     _noise.Frequency   = Frequency;
     _noise.Lacunarity  = Lacunarity;
     Heights(terr, _noise);
 }
    void GenerateLeafNoise()
    {
        float modifier,
              lacu = 1.5f;

        int octaves = 1;

        float newFrequency     = Random.Range(frequency.x, frequency.y);
        float newAmplification = Random.Range(amplification.x, amplification.y);

        var noise = new LibNoise.Generator.RidgedMultifractal(newFrequency, lacu, octaves, Random.Range(0, 0xffffff), QualityMode.High);

        for (int i = 0; i < vertices.Length; i++)
        {
            modifier    = (float)noise.GetValue(vertices[i].x, vertices[i].y, vertices[i].z);
            modifier    = ((modifier - 0.5f) / newAmplification) + 0.99f;
            vertices[i] = Vector3.Scale(vertices[i], (Vector3.one * modifier));
        }
    }
Beispiel #3
0
    //Copied
    public Vector2 PerlinNoise3D(Transform tr, float radius, float scaler, int octaves = 2, float lucanarity = 2f, float gain = 0.1f, float warp = 0.1f, float testing = 10)
    {
        LibNoise.Generator.Perlin             planes    = GameObject.FindGameObjectWithTag("Setting").GetComponent <TestongThings>().planes;
        LibNoise.Generator.RidgedMultifractal mountains = GameObject.FindGameObjectWithTag("Setting").GetComponent <TestongThings>().mountains;
        float highest = 0;
        float lowest  = 0;

        for (var i = 0; i < vertices.Length; i++)
        {
            Vector3 point = tr.TransformPoint(vertices[i]);
            //Vector3 point = vertices[i];
            float sum = 0.0f, freq = 1.0f, amp = 1.0f;

            for (int j = 0; j < octaves; j++)
            {
                sum  += amp * (float)planes.GetValue(point);
                freq *= lucanarity;
                amp  *= gain;
            }

            sum *= (float)mountains.GetValue(point * freq) * octaves * testing;
            sum  = Mathf.Max(-1, sum / 2);


            vertices[i] = vertices[i].normalized * (radius * scaler + sum);


            if (sum > highest)
            {
                highest = sum;
            }
            if (sum < lowest && sum > 0)
            {
                lowest = sum;
            }
        }
        return(new Vector2(lowest, highest));
    }