Example #1
0
    /// <summary>
    /// get noise of position (x,y,z) from noise generator
    /// by frequency, dimension and apply fractal if desired
    /// </summary>
    /// <param name="noise">noise generator</param>
    /// <param name="frequency"></param>
    /// <param name="dimension"></param>
    /// <param name="fractal"></param>
    /// <param name="x"></param>
    /// <param name="y"></param>
    /// <param name="z"></param>
    /// <returns></returns>
    protected virtual Color GetNoise(NoiseTools.NoiseGeneratorBase noise, float frequency, int dimension, int fractal, int x, int y, int z = 0)
    {
        var   scale = 1.0f / this._resolution;
        var   sx    = x * scale;
        var   sy    = y * scale;
        var   sz    = z * scale;
        float c     = 0;

        if (frequency == 1)
        {
            if (dimension == 2)
            {
                c = noise.GetAt(sx, sy);
            }
            else
            {
                c = noise.GetAt(sx, sy, sz);
            }
        }
        else
        if (dimension == 2)
        {
            c = noise.GetFractal(sx, sy, fractal);
        }
        else
        {
            c = noise.GetFractal(sx, sy, sz, fractal);
        }

        return(new Color(c, c, c, 1));
    }
Example #2
0
    protected override Color GetNoise(NoiseTools.NoiseGeneratorBase noise, float frequency, int dimension, int fractal, int x, int y, int z = 0)
    {
        if (this._perlinNoise == null || this._worleyNoise0 == null || this._worleyNoise1 == null || this._worleyNoise2 == null)
        {
            return(Color.black);
        }
        float perlin = this._perlinNoise.GetNoiseData(x, y, z);
        //inverted worley noise
        //with higher frequency

        float worley_sub = this._worleySubNoise.GetNoiseData(x, y, z);
        float worley0    = this._worleyNoise0.GetNoiseData(x, y, z);
        float worley1    = this._worleyNoise1.GetNoiseData(x, y, z);
        float worley2    = this._worleyNoise2.GetNoiseData(x, y, z);

        //float worleyFBM = worley0 * 0.625f + worley1 * 0.25f + worley2 * 0.125f;

        float perlinWorley = 0;

        //from TileableVolumeNoise
        //perlinWorley = Remap(perlin, 0, 1, worleyFBM, 1);

        //this from Nubis course
        perlinWorley = Remap(perlin, 1.0f - worley_sub, 1, 0, 1);
        //perlinWorley = Remap(perlin, worley_sub, 1, 0, 1);

        return(new Color(perlinWorley, worley0, worley1, worley2));
    }
Example #3
0
    void Regenerate()
    {
        this._currentProgress = 0;

        _fileName = this._type.ToString();
        switch (this._type)
        {
        case NoiseType.Perlin:
            _noise = new NoiseTools.PerlinNoise(this._frequency, 1);
            break;

        case NoiseType.Worley:
            _noise = new NoiseTools.WorleyNoise(this._frequency, 1);
            break;

        case NoiseType.NewWorley:
            _noise = new NoiseTools.NewWorleyNoise(this._frequency, 1);
            break;

        default:
            Debug.LogWarning("Can not found noise generator");
            break;
        }

        var scale = 1.0f / _resolution;
        var z_dim = this._dimensions == 2 ? 1 : _resolution;
        var index = 0;

        for (var iz = 0; iz < z_dim; iz++)
        {
            for (var iy = 0; iy < _resolution; iy++)
            {
                for (var ix = 0; ix < _resolution; ix++)
                {
                    var c = GetNoise(this._noise, this._frequency, this._dimensions, this._fractal, ix, iy, iz);

                    if (this._revert)
                    {
                        c = Invert(c);
                    }

                    this._data[index++] = c;
                }
            }
            this._currentProgress = iz * scale;
        }

        this._currentProgress = 1;
        this._pendingReset    = true;
    }
    protected override Color GetNoise(NoiseTools.NoiseGeneratorBase noise, float frequency, int dimension, int fractal, int x, int y, int z = 0)
    {
        if (this._worleyNoise0 == null || this._worleyNoise1 == null || this._worleyNoise2 == null)
        {
            return(Color.black);
        }
        //inverted worley noise
        //with higher frequency
        float worley0 = this._worleyNoise0.GetNoiseData(x, y, z);
        float worley1 = this._worleyNoise1.GetNoiseData(x, y, z);
        float worley2 = this._worleyNoise2.GetNoiseData(x, y, z);

        return(new Color(worley0, worley1, worley2, 1));
    }