Пример #1
0
        public double GetValue(double x)
        {
            double value          = 0.0;
            double signal         = 0.0;
            double curPersistence = 1.0;

            x *= _frequency;

            for (int currentOctave = 0; currentOctave < Octaves; currentOctave++)
            {
                signal          = _noise.Noise1D(x);
                value          += signal * curPersistence;
                x              *= Lacunarity;
                curPersistence *= Persistence;
            }
            return(value * Amplitude);
        }
Пример #2
0
        public double GetValue(double x)
        {
            x *= _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.Noise1D(x);

                // 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;
            }
            return(((value * 1.25) - 1.0) * _amplitude);
        }