Esempio n. 1
0
        public override double GetValue(double x, double y)
        {
            double value          = 0.0;
            double signal         = 0.0;
            double curPersistence = 1.0;
            //double nx, ny, nz;
            long seed;

            double lacunarity  = Lacunarity.GetValue(x, y);
            double persistence = Persistence.GetValue(x, y);
            double frequency   = Frequency.GetValue(x, y);

            x *= frequency;
            y *= frequency;

            int mOctaveCount = (int)OctaveCount.GetValue(x, y);

            for (int currentOctave = 0; currentOctave < mOctaveCount; currentOctave++)
            {
                seed = (Seed + currentOctave) & 0xffffffff;

                signal = GradientNoise.GradientCoherentNoise(x, y, (int)seed, NoiseQuality);

                value += signal * curPersistence;

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

            return(value);
        }
Esempio n. 2
0
        public override double GetValue(double x, double y, double z)
        {
            double lacunarity = Lacunarity.GetValue(x, y, z);
            double gain       = Gain.GetValue(x, y, z);
            double offset     = Offset.GetValue(x, y, z);
            double frequency  = Frequency.GetValue(x, y, z);

            x *= frequency;
            y *= frequency;
            z *= frequency;

            int mOctaveCount = (int)OctaveCount.GetValue(x, y, z);

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

            for (int currentOctave = 0; currentOctave < mOctaveCount; currentOctave++)
            {
                long seed = (Seed + currentOctave) & 0x7fffffff;
                signal = GradientNoise.GradientCoherentNoise(x, y, z,
                                                             (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;
                }
                else 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;
                z *= lacunarity;
            }

            return((value * 1.25) - 1.0);
        }
Esempio n. 3
0
        public override double GetValue(double x, double y, double z)
        {
            double value          = 0.0;
            double signal         = 0.0;
            double curPersistence = 1.0;
            //double nx, ny, nz;
            long seed;

            double lacunarity = Lacunarity.GetValue(x, y, z);
            double persist    = Persistence.GetValue(x, y, z);
            double frequency  = Frequency.GetValue(x, y, z);

            x *= frequency;
            y *= frequency;
            z *= frequency;

            int mOctaveCount = (int)OctaveCount.GetValue(x, y, z);

            for (int currentOctave = 0; currentOctave < mOctaveCount; currentOctave++)
            {
                /*nx = Math.MakeInt32Range(x);
                *  ny = Math.MakeInt32Range(y);
                *  nz = Math.MakeInt32Range(z);*/

                seed   = (Seed + currentOctave) & 0xffffffff;
                signal = GradientNoise.GradientCoherentNoise(x, y, z, (int)seed, NoiseQuality);
                signal = 2.0 * System.Math.Abs(signal) - 1.0;
                value += signal * curPersistence;

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

            value += 0.5;

            return(value);
        }