示例#1
0
        public override double GetValue(double x, double y, double z)
        {
            double a = SourceModule1.GetValue(x, y, z);
            double b = SourceModule2.GetValue(x, y, z);

            return(a + ((b - a) * 0.5f));
        }
示例#2
0
文件: Max.cs 项目: Earthmark/Libnoise
        public override double GetValue(double x, double y, double z)
        {
            double v0 = SourceModule1.GetValue(x, y, z);
            double v1 = SourceModule2.GetValue(x, y, z);

            return(Math.Max(v0, v1));
        }
示例#3
0
        public override double GetValue(double t)
        {
            double a = SourceModule1.GetValue(t);
            double b = SourceModule2.GetValue(t);

            return(a + ((b - a) * 0.5f));
        }
示例#4
0
        public override double GetValue(double t)
        {
            // Read the values:
            double min = LowerBound.GetValue(t);
            double max = UpperBound.GetValue(t);
            double value;

            if (min > max)
            {
                // Flip, using value as temp storage:
                value = min;
                min   = max;
                max   = value;
            }

            // Source:
            value = SourceModule1.GetValue(t);

            if (value > max)
            {
                return(max);
            }
            else if (value < min)
            {
                return(min);
            }

            return(value);
        }
        public override double GetValue(double x, double y)
        {
            // pStr:
            double str = SourceModule2.GetValue(x, y);

            double mapX = MapX;
            double mapY = MapY;

            // Read the surrounding heights:
            double tl = SourceModule1.GetValue(x - mapX, y + mapY);
            double t  = SourceModule1.GetValue(x, y + mapY);
            double tr = SourceModule1.GetValue(x + mapX, y + mapY);
            double r  = SourceModule1.GetValue(x + mapX, y);
            double br = SourceModule1.GetValue(x + mapX, y - mapY);
            double b  = SourceModule1.GetValue(x, y - mapY);
            double bl = SourceModule1.GetValue(x - mapX, y - mapY);
            double l  = SourceModule1.GetValue(x - mapX, y);

            // sobel filter
            double dX = ((tr + 2.0 * r + br) - (tl + 2.0 * l + bl));
            double dY = ((bl + 2.0 * b + br) - (tl + 2.0 * t + tr));
            double dZ = 1.0 / str;

            // Normalise:
            double length = System.Math.Sqrt(dX * dX + dY * dY + dZ * dZ);

            return(dZ / length);
        }
        public override UnityEngine.Color GetColour(double x, double y)
        {
            // 1/pStr:
            float str = (float)SourceModule2.GetValue(x, y);

            double mapX = MapX;
            double mapY = MapY;

            // Read the surrounding heights:
            double tl = SourceModule1.GetValue(x - mapX, y + mapY);
            double t  = SourceModule1.GetValue(x, y + mapY);
            double tr = SourceModule1.GetValue(x + mapX, y + mapY);
            double r  = SourceModule1.GetValue(x + mapX, y);
            double br = SourceModule1.GetValue(x + mapX, y - mapY);
            double b  = SourceModule1.GetValue(x, y - mapY);
            double bl = SourceModule1.GetValue(x - mapX, y - mapY);
            double l  = SourceModule1.GetValue(x - mapX, y);

            // sobel filter
            float dX = (float)((tr + 2.0 * r + br) - (tl + 2.0 * l + bl));
            float dY = (float)((bl + 2.0 * b + br) - (tl + 2.0 * t + tr));
            float dZ = str;

            // Normalise:
            float length = (float)System.Math.Sqrt(dX * dX + dY * dY + dZ * dZ);

            dX /= length;
            dY /= length;
            dZ /= length;

            return(new Color(dX, dY, dZ, 1f));
        }
示例#7
0
        public double GetValue(double x, double y, double z)
        {
            if (SourceModule1 == null || SourceModule2 == null)
            {
                throw new NullReferenceException("Source modules must be provided.");
            }

            return(Math.GetSmaller(SourceModule1.GetValue(x, y, z), SourceModule2.GetValue(x, y, z)));
        }
示例#8
0
        public override double GetValue(double x, double y, double z)
        {
            // Stretch out t by times to repeat:
            double rep    = SourceModule2.GetValue(x, y, z);
            bool   mirror = (SourceModule3.GetValue(x, y, z) > 0.5);

            x *= rep;
            y *= rep;
            z *= rep;

            // Get the current repetition:
            int baseRepetition = (int)x;

            // Shift:
            x -= baseRepetition;

            // X is now in the 0-1 range.

            if (mirror && (baseRepetition & 1) == 1)
            {
                // "odd" repetition - flip t:
                x = 1.0 - x;
            }

            // Get the current repetition:
            baseRepetition = (int)y;

            // Shift:
            y -= baseRepetition;

            // Y is now in the 0-1 range.

            if (mirror && (baseRepetition & 1) == 1)
            {
                // "odd" repetition - flip t:
                y = 1.0 - y;
            }

            // Get the current repetition:
            baseRepetition = (int)z;

            // Shift:
            z -= baseRepetition;

            // Z is now in the 0-1 range.

            if (mirror && (baseRepetition & 1) == 1)
            {
                // "odd" repetition - flip t:
                z = 1.0 - z;
            }

            // Read source:
            return(SourceModule1.GetValue(x, y, z));
        }
        public override double GetValue(double t)
        {
            // Read amplitude:
            double amp = Contrast.GetValue(t);

            // Origin:
            double origin = Origin.GetValue(t);

            // Sample at that point:
            return(((SourceModule1.GetValue(t) - origin) * amp) + origin);
        }
        public override double GetValue(double x, double y)
        {
            double a = SourceModule1.GetValue(x, y);
            double b = SourceModule2.GetValue(x, y);

            if (a > b)
            {
                return(a);
            }
            return(b);
        }
示例#11
0
        public override double GetValue(double x)
        {
            // Read params:
            double mu     = SourceModule1.GetValue(x);
            double sigma2 = SourceModule2.GetValue(x);

            double tMu = x - mu;

            // Amplitude of 1.
            return(System.Math.Exp((-tMu * tMu) / (2.0 * sigma2)));
        }
示例#12
0
        /// <summary>
        /// Returns the result of blending the output of the two source modules using the
        /// output of the weight module as the blending weight.
        /// </summary>
        public double GetValue(double x, double y, double z)
        {
            if (SourceModule1 == null || SourceModule2 == null || WeightModule == null)
            {
                throw new NullReferenceException();
            }

            return(LinearInterpolate(SourceModule1.GetValue(x, y, z),
                                     SourceModule2.GetValue(x, y, z),
                                     (WeightModule.GetValue(x, y, z) + 1.0) / 2.0));
        }
示例#13
0
        public override double GetValue(double t)
        {
            // Read the values:
            double a = SourceModule1.GetValue(t);
            double b = SourceModule2.GetValue(t);

            // Blend factor:
            double blend = WeightModule.GetValue(t);

            // Blend now!
            return(a + ((b - a) * blend));
        }
示例#14
0
        public override double GetValue(double x, double y)
        {
            double a = SourceModule1.GetValue(x, y);
            double b = SourceModule2.GetValue(x, y);

            if (a != b)
            {
                return(IfTrue.GetValue(x, y));
            }

            return(IfFalse.GetValue(x, y));
        }
示例#15
0
        public override double GetValue(double t)
        {
            double a = SourceModule1.GetValue(t);
            double b = SourceModule2.GetValue(t);

            if (a < b)
            {
                return(a);
            }

            return(b);
        }
示例#16
0
        public override double GetValue(double x, double y, double z)
        {
            double controlValue = ControlModule.GetValue(x, y, z);

            if (EdgeFalloff > 0.0)
            {
                if (controlValue < (LowerBound - EdgeFalloff))
                {
                    // The output value from the control module is below the selector
                    // threshold; return the output value from the first source module.
                    return(SourceModule1.GetValue(x, y, z));
                }
                if (controlValue < (LowerBound + EdgeFalloff))
                {
                    // The output value from the control module is near the lower end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (LowerBound - EdgeFalloff);
                    double upperCurve = (LowerBound + EdgeFalloff);
                    double alpha      = Interp.SCurve3((controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(Interp.LinearInterp(SourceModule1.GetValue(x, y, z), SourceModule2.GetValue(x, y, z), alpha));
                }
                if (controlValue < (UpperBound - EdgeFalloff))
                {
                    // The output value from the control module is within the selector
                    // threshold; return the output value from the second source module.
                    return(SourceModule2.GetValue(x, y, z));
                }
                if (controlValue < (UpperBound + EdgeFalloff))
                {
                    // The output value from the control module is near the upper end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (UpperBound - EdgeFalloff);
                    double upperCurve = (UpperBound + EdgeFalloff);
                    double alpha      = Interp.SCurve3((controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(Interp.LinearInterp(SourceModule2.GetValue(x, y, z), SourceModule1.GetValue(x, y, z), alpha));
                }
                // Output value from the control module is above the selector threshold;
                // return the output value from the first source module.
                return(SourceModule1.GetValue(x, y, z));
            }
            if (controlValue < LowerBound || controlValue > UpperBound)
            {
                return(SourceModule1.GetValue(x, y, z));
            }
            return(SourceModule2.GetValue(x, y, z));
        }
示例#17
0
        public override double GetValue(double x)
        {
            // How many stairs?
            double count = SourceModule2.GetValue(x);

            // Map x into our current step:
            x *= count;

            // Get the base step:
            int baseStep = (int)x;

            // Read the curve at x-baseStep (0-1 inside the current step):
            double curve = SourceModule1.GetValue(x - baseStep);

            // Gotta now offset and compress it back:
            return(((double)baseStep + curve) / count);
        }
示例#18
0
        public double GetValue(double x, double y, double z)
        {
            if (SourceModule1 == null || SourceModule2 == null)
            {
                throw new NullReferenceException("Source modules must be provided.");
            }

            double a = SourceModule1.GetValue(x, y, z);
            double b = SourceModule2.GetValue(x, y, z);

            if (b < 0)
            {
                return(a * 0);
            }


            return(a * b);
        }
示例#19
0
        public override double GetValue(double t)
        {
            // Stretch out t by times to repeat:
            t *= SourceModule2.GetValue(t);

            // Get the current repetition:
            int baseRepetition = (int)t;

            // Shift t:
            t -= baseRepetition;

            // T is now in the 0-1 range.
            bool mirror = (SourceModule3.GetValue(t) > 0.5);

            if (mirror && (baseRepetition & 1) == 1)
            {
                // "odd" repetition - flip t:
                t = 1.0 - t;
            }

            // Read source:
            return(SourceModule1.GetValue(t));
        }
示例#20
0
 /// <summary>
 /// Returns the result of blending the output of the two source modules using the
 /// output of the weight module as the blending weight.
 /// </summary>
 public override double GetValue(double x, double y)
 {
     return(Loonim.Math.LinearInterpolate(SourceModule1.GetValue(x, y),
                                          SourceModule2.GetValue(x, y),
                                          (WeightModule.GetValue(x, y) + 1.0) / 2.0));
 }
示例#21
0
 public override double GetValue(double x, double y, double z)
 {
     return(SourceModule1.GetValue(x, y, z) * SourceModule2.GetValue(x, y, z));
 }
示例#22
0
 public override double GetValue(double x, double y)
 {
     return(SourceModule1.GetValue(x, y) - SourceModule2.GetValue(x, y));
 }
示例#23
0
        public virtual double GetValue(double x, double y, double z)
        {
            if (ControlModule == null || SourceModule1 == null || SourceModule2 == null)
            {
                throw new NullReferenceException("Control and source modules must be provided.");
            }

            double controlValue = ControlModule.GetValue(x, y, z);
            double alpha;

            if (EdgeFalloff > 0.0)
            {
                if (controlValue < (LowerBound - EdgeFalloff))
                {
                    // The output value from the control module is below the selector
                    // threshold; return the output value from the first source module.
                    return(SourceModule1.GetValue(x, y, z));
                }
                else if (controlValue < (LowerBound + EdgeFalloff))
                {
                    // The output value from the control module is near the lower end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (LowerBound - EdgeFalloff);
                    double upperCurve = (LowerBound + EdgeFalloff);
                    alpha = SCurve3((controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(LinearInterpolate(SourceModule1.GetValue(x, y, z),
                                             SourceModule2.GetValue(x, y, z), alpha));
                }
                else if (controlValue < (UpperBound - EdgeFalloff))
                {
                    // The output value from the control module is within the selector
                    // threshold; return the output value from the second source module.
                    return(SourceModule2.GetValue(x, y, z));
                }
                else if (controlValue < (UpperBound + EdgeFalloff))
                {
                    // The output value from the control module is near the upper end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (UpperBound - EdgeFalloff);
                    double upperCurve = (UpperBound + EdgeFalloff);
                    alpha = SCurve3(
                        (controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(LinearInterpolate(SourceModule2.GetValue(x, y, z),
                                             SourceModule1.GetValue(x, y, z),
                                             alpha));
                }
                else
                {
                    // Output value from the control module is above the selector threshold;
                    // return the output value from the first source module.
                    return(SourceModule1.GetValue(x, y, z));
                }
            }
            else
            {
                if (controlValue < LowerBound || controlValue > UpperBound)
                {
                    return(SourceModule1.GetValue(x, y, z));
                }
                else
                {
                    return(SourceModule2.GetValue(x, y, z));
                }
            }
        }
示例#24
0
 public override double GetValue(double t)
 {
     return(SourceModule1.GetValue(t) * SourceModule2.GetValue(t));
 }
示例#25
0
 public override double GetValue(double x, double y)
 {
     return(System.Math.Atan2(SourceModule1.GetValue(x, y), SourceModule2.GetValue(x, y)));
 }
        public override double GetValue(double x, double y)
        {
            double controlValue = ControlModule.GetValue(x, y);
            double alpha;

            double lowerBound  = LowerBound.GetValue(x, y);
            double upperBound  = UpperBound.GetValue(x, y);
            double edgeFalloff = EdgeFalloff.GetValue(x, y);

            if (edgeFalloff > 0.0)
            {
                if (controlValue < (lowerBound - edgeFalloff))
                {
                    // The output value from the control module is below the selector
                    // threshold; return the output value from the first source module.
                    return(SourceModule1.GetValue(x, y));
                }
                else if (controlValue < (lowerBound + edgeFalloff))
                {
                    // The output value from the control module is near the lower end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (lowerBound - edgeFalloff);
                    double upperCurve = (lowerBound + edgeFalloff);
                    alpha = Loonim.Math.SCurve3((controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(Loonim.Math.LinearInterpolate(SourceModule1.GetValue(x, y),
                                                         SourceModule2.GetValue(x, y), alpha));
                }
                else if (controlValue < (upperBound - edgeFalloff))
                {
                    // The output value from the control module is within the selector
                    // threshold; return the output value from the second source module.
                    return(SourceModule2.GetValue(x, y));
                }
                else if (controlValue < (upperBound + edgeFalloff))
                {
                    // The output value from the control module is near the upper end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (upperBound - edgeFalloff);
                    double upperCurve = (upperBound + edgeFalloff);
                    alpha = Loonim.Math.SCurve3(
                        (controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(Loonim.Math.LinearInterpolate(SourceModule2.GetValue(x, y),
                                                         SourceModule1.GetValue(x, y),
                                                         alpha));
                }
                else
                {
                    // Output value from the control module is above the selector threshold;
                    // return the output value from the first source module.
                    return(SourceModule1.GetValue(x, y));
                }
            }
            else
            {
                if (controlValue < lowerBound || controlValue > upperBound)
                {
                    return(SourceModule1.GetValue(x, y));
                }
                else
                {
                    return(SourceModule2.GetValue(x, y));
                }
            }
        }
示例#27
0
 public double GetValue(double x, double y, double z)
 {
     return(Mathf.Lerp((float)SourceModule1.GetValue(x, y, z), (float)SourceModule2.GetValue(x, y, z), (float)T));
 }
示例#28
0
        public override double GetValue(double x, double y, double z)
        {
            //   var result = base.GetValue(x, y, z);


            double del = Div * 150.0f;
            double xx  = (x * del);
            double yy  = (z * del);
            var    col = Bitmap.GetPixel((int)xx, (int)(yy));

            float height = col.R / 255.0f;

            if (col.A == 0)
            {
                return(0);
            }
            if (height > 0.7f)
            {
            }
            height -= 0.5f;
            height *= 2.0f;

            double controlValue = ControlModule.GetValue(x, y, z);
            double alpha;

            controlValue = height + (controlValue * 1.2f * Randomness);

            if (EdgeFalloff > 0.0)
            {
                if (controlValue < (LowerBound - EdgeFalloff))
                {
                    // The output value from the control module is below the selector
                    // threshold; return the output value from the first source module.
                    return(SourceModule1.GetValue(x, y, z));
                }
                else if (controlValue < (LowerBound + EdgeFalloff))
                {
                    // The output value from the control module is near the lower end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (LowerBound - EdgeFalloff);
                    double upperCurve = (LowerBound + EdgeFalloff);
                    alpha = SCurve3((controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(LinearInterpolate(SourceModule1.GetValue(x, y, z),
                                             SourceModule2.GetValue(x, y, z), alpha));
                }
                else if (controlValue < (UpperBound - EdgeFalloff))
                {
                    // The output value from the control module is within the selector
                    // threshold; return the output value from the second source module.
                    return(SourceModule2.GetValue(x, y, z));
                }
                else if (controlValue < (UpperBound + EdgeFalloff))
                {
                    // The output value from the control module is near the upper end of the
                    // selector threshold and within the smooth curve. Interpolate between
                    // the output values from the first and second source modules.
                    double lowerCurve = (UpperBound - EdgeFalloff);
                    double upperCurve = (UpperBound + EdgeFalloff);
                    alpha = SCurve3(
                        (controlValue - lowerCurve) / (upperCurve - lowerCurve));
                    return(LinearInterpolate(SourceModule2.GetValue(x, y, z),
                                             SourceModule1.GetValue(x, y, z),
                                             alpha));
                }
                else
                {
                    // Output value from the control module is above the selector threshold;
                    // return the output value from the first source module.
                    return(SourceModule1.GetValue(x, y, z));
                }
            }
            else
            {
                if (controlValue < LowerBound || controlValue > UpperBound)
                {
                    return(SourceModule1.GetValue(x, y, z));
                }
                else
                {
                    return(SourceModule2.GetValue(x, y, z));
                }
            }
        }