Ejemplo n.º 1
0
        public double GetValue(double x, double y)
        {
            double value          = 0.0;
            double signal         = 0.0;
            double curPersistence = 1.0;

            x *= _frequency; y *= _frequency;

            for (int currentOctave = 0; currentOctave < Octaves; currentOctave++)
            {
                signal          = _noise.Noise2D(x, y);
                value          += signal * curPersistence;
                x              *= Lacunarity; y *= Lacunarity;
                curPersistence *= Persistence;
            }
            return(value * Amplitude);
        }
Ejemplo n.º 2
0
        public double GetValue(double x, double y)
        {
            x *= _frequency; y *= _frequency;

            double signal = 0.0;
            double value  = 0.0;
            double weight = 1.0;

            double offset = 1.0;
            double gain   = 2.0;

            for (int currentOctave = 0; currentOctave < Octaves; currentOctave++)
            {
                signal = _noise.Noise2D(x, y);

                // Make the ridges.
                signal = Math.Abs(signal);
                signal = offset - signal;

                // Square the signal to increase the sharpness of the ridges.
                signal *= signal; signal *= weight;
                // Weight successive contributions by the previous signal.
                weight = signal * gain;
                if (weight > 1.0)
                {
                    weight = 1.0;
                }
                if (weight < 0.0)
                {
                    weight = 0.0;
                }

                // Add the signal to the output value.
                value += (signal * _spectralWeight[currentOctave]);
                // Go to the next octave.
                x *= _lacunarity; y *= _lacunarity;
            }
            return(((value * 1.25) - 1.0) * _amplitude);
        }