Пример #1
0
        public static float Generate(float x)
        {
            int    num1 = Noise.FastFloor(x);
            int    num2 = num1 + 1;
            float  x1   = x - (float)num1;
            float  x2   = x1 - 1f;
            double num3 = 1.0 - (double)x1 * (double)x1;
            double num4 = num3 * num3;
            float  num5 = (float)(num4 * num4) * Noise.grad((int)Noise.perm[num1 & (int)byte.MaxValue], x1);
            double num6 = 1.0 - (double)x2 * (double)x2;
            double num7 = num6 * num6;
            float  num8 = (float)(num7 * num7) * Noise.grad((int)Noise.perm[num2 & (int)byte.MaxValue], x2);

            return((float)(0.395000010728836 * ((double)num5 + (double)num8)));
        }
Пример #2
0
        public static float Generate(float x, float y)
        {
            float  num1 = (float)(((double)x + (double)y) * 0.366025388240814);
            double num2 = (double)x + (double)num1;
            float  x1   = y + num1;
            int    num3 = Noise.FastFloor((float)num2);
            int    num4 = Noise.FastFloor(x1);
            int    num5 = num4;
            float  num6 = (float)(num3 + num5) * 0.2113249f;
            float  num7 = (float)num3 - num6;
            float  num8 = (float)num4 - num6;
            float  x2   = x - num7;
            float  y1   = y - num8;
            int    num9;
            int    num10;

            if ((double)x2 > (double)y1)
            {
                num9  = 1;
                num10 = 0;
            }
            else
            {
                num9  = 0;
                num10 = 1;
            }
            float x3    = (float)((double)x2 - (double)num9 + 0.211324870586395);
            float y2    = (float)((double)y1 - (double)num10 + 0.211324870586395);
            float x4    = (float)((double)x2 - 1.0 + 0.422649741172791);
            float y3    = (float)((double)y1 - 1.0 + 0.422649741172791);
            int   num11 = 256;
            int   num12 = num3 % num11;
            int   index = num4 % 256;
            float num13 = (float)(0.5 - (double)x2 * (double)x2 - (double)y1 * (double)y1);
            float num14;

            if ((double)num13 < 0.0)
            {
                num14 = 0.0f;
            }
            else
            {
                float num15 = num13 * num13;
                num14 = num15 * num15 * Noise.grad((int)Noise.perm[num12 + (int)Noise.perm[index]], x2, y1);
            }
            float num16 = (float)(0.5 - (double)x3 * (double)x3 - (double)y2 * (double)y2);
            float num17;

            if ((double)num16 < 0.0)
            {
                num17 = 0.0f;
            }
            else
            {
                float num15 = num16 * num16;
                num17 = num15 * num15 * Noise.grad((int)Noise.perm[num12 + num9 + (int)Noise.perm[index + num10]], x3, y2);
            }
            float num18 = (float)(0.5 - (double)x4 * (double)x4 - (double)y3 * (double)y3);
            float num19;

            if ((double)num18 < 0.0)
            {
                num19 = 0.0f;
            }
            else
            {
                float num15 = num18 * num18;
                num19 = num15 * num15 * Noise.grad((int)Noise.perm[num12 + 1 + (int)Noise.perm[index + 1]], x4, y3);
            }
            return((float)(40.0 * ((double)num14 + (double)num17 + (double)num19)));
        }