示例#1
0
        private double GroundFunction(float s, float t)
        {
            // varying amplitude and frequency
            float amplitude = 0.5f; // +a;
            float frequency = 0.5f; // +f;

            // define constants
            int   n     = 7;    // number of octaves
            float alpha = 2.0f; // weight when sum is formed, approching 1 is noisier
            float beta  = 2.0f; // harmonic scaling/spacing
            float scale = 5.0f * frequency;

            double toReturn = Perlin.PerlinNoise2D(scale * s, scale * t, alpha, beta, n);

            toReturn = amplitude * toReturn + amplitude * amplitude * toReturn + amplitude * amplitude * amplitude * toReturn + amplitude * amplitude * amplitude * amplitude * toReturn;
            toReturn = Math.Sin(20 * 1 + s * toReturn) + Math.Sin(20 * 2 + s * toReturn) + Math.Sin(20 * 3 + s * toReturn) + Math.Sin(20 * 4 + s * toReturn);

            // scale between 0 and 1
            return(toReturn % 1.0f);
        }
示例#2
0
        private double woodFunction(float s, float t, float r)
        {
            // variable amplitude and frequency
            float amplitude = 6.0f; // +a;
            float frequency = 2.0f; // +f;

            // define toReturn variable
            double toReturn = s * s + t * t; // f(s,t,r) = s^2 + t^2; // fixed r

            // define perlin noise constants
            int   n     = 2;    // number of octaves
            float alpha = 2.0f; // "division factor" (how much to damp subsequent octaves)
            float beta  = 2.0f; // factor that multiplies "jump" into noise

            // perlin noise!!!
            double perlin = Perlin.PerlinNoise2D(frequency * s, frequency * s, alpha, beta, n);

            toReturn = toReturn + amplitude * perlin;

            return(toReturn % 1.0f);
            //double integerPart; // don't care about
            //return modf(toReturn, &integerPart);
        }