示例#1
0
        public override double GetWrapped(double x, double y, int wrap)
        {
            double value          = 0.0;
            double signal         = 0.0;
            double curPersistence = 1.0;
            long   seed;

            double lacunarity = Lacunarity.GetWrapped(x, y, wrap);
            double persist    = Persistence.GetWrapped(x, y, wrap);
            double frequency  = Frequency.GetWrapped(x, y, wrap);

            x *= frequency;
            y *= frequency;

            int mOctaveCount = (int)OctaveCount.GetWrapped(x, y, wrap);

            for (int currentOctave = 0; currentOctave < mOctaveCount; currentOctave++)
            {
                seed   = (Seed + currentOctave) & 0xffffffff;
                signal = GradientCoherentNoiseWrap(x, y, wrap, (int)seed, NoiseQuality);
                signal = 2.0 * System.Math.Abs(signal) - 1.0;
                value += signal * curPersistence;

                x *= lacunarity;
                y *= lacunarity;
                curPersistence *= persist;
            }

            value += 0.5;

            return(value);
        }
示例#2
0
        public override double GetWrapped(double x, double y, int wrap)
        {
            double lacunarity = Lacunarity.GetWrapped(x, y, wrap);
            double frequency  = Frequency.GetWrapped(x, y, wrap);

            x *= frequency;
            y *= frequency;

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

            // These parameters should be user-defined; they may be exposed in a
            // future version of libnoise.
            double offset = 1.0;
            double gain   = 2.0;

            int mOctaveCount = (int)OctaveCount.GetWrapped(x, y, wrap);

            for (int currentOctave = 0; currentOctave < mOctaveCount; currentOctave++)
            {
                long seed = (Seed + currentOctave) & 0x7fffffff;
                signal = GradientCoherentNoiseWrap(x, y, wrap, (int)seed, NoiseQuality);

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

                // Square the signal to increase the sharpness of the ridges.
                signal *= signal;

                // The weighting from the previous octave is applied to the signal.
                // Larger values have higher weights, producing sharp points along the
                // ridges.
                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 * SpectralWeights[currentOctave]);

                // Go to the next octave.
                x *= lacunarity;
                y *= lacunarity;
            }

            return((value * 1.25) - 1.0);
        }