예제 #1
0
        public override double GetValue(double x, double y, double z)
        {
            double value          = 0.0;
            double curPersistence = 1.0;

            //double nx, ny, nz;

            x *= Frequency;
            y *= Frequency;
            z *= Frequency;

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

                /*nx = Math.MakeInt32Range(x);
                *  ny = Math.MakeInt32Range(y);
                *  nz = Math.MakeInt32Range(z);*/
                double signal = GeneratorBase.GradientCoherentNoise(x, y, z, (int)seed, Quality);
                //signal = cachedNoise3(x, y, z);

                value += signal * curPersistence;

                x *= Lacunarity;
                y *= Lacunarity;
                z *= Lacunarity;
                curPersistence *= Persistence;
            }
            return(value);
        }
예제 #2
0
        public override double GetValue(double x, double y, double z)
        {
            double value          = 0.0;
            double curPersistence = 1.0;

            //double nx, ny, nz;

            x *= Frequency;
            y *= Frequency;
            z *= Frequency;

            for (int currentOctave = 0; currentOctave < OctaveCount; currentOctave++)
            {
                long   seed   = (Seed + currentOctave) & 0xffffffff;
                double signal = GeneratorBase.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 *= Persistence;
            }

            value += 0.5;

            return(value);
        }
예제 #3
0
        public override double GetValue(double x, double y, double z)
        {
            x *= Frequency;
            y *= Frequency;
            z *= Frequency;

            double value  = 0.0;
            double weight = 1.0;

            const double offset = 1.0;
            const double gain   = 2.0;

            for (int currentOctave = 0; currentOctave < OctaveCount; currentOctave++)
            {
                //double nx, ny, nz;

                /* nx = Math.MakeInt32Range(x);
                 * ny = Math.MakeInt32Range(y);
                 * nz = Math.MakeInt32Range(z);*/

                long   seed   = (Seed + currentOctave) & 0x7fffffff;
                double signal = GeneratorBase.GradientCoherentNoise(x, y, z,
                                                                    (int)seed, NoiseQuality);

                // Make the ridges.
                signal = 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;
                z *= Lacunarity;
            }

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