18 "title" :
"VuoGradientNoiseCommon",
32 static unsigned char perm[] =
35 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103,
36 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120,
37 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57,
38 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68,
39 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83,
40 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245,
41 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76,
42 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86,
43 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123,
44 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47,
45 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2,
46 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39,
47 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218,
48 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162,
49 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181,
50 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150,
51 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128,
52 195, 78, 66, 215, 61, 156, 180,
54 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103,
55 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120,
56 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57,
57 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68,
58 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83,
59 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245,
60 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76,
61 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86,
62 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123,
63 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47,
64 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2,
65 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39,
66 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218,
67 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162,
68 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181,
69 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150,
70 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128,
71 195, 78, 66, 215, 61, 156, 180
79 {0,1,2,3},{0,1,3,2},{0,0,0,0},{0,2,3,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,2,3,0},
80 {0,2,1,3},{0,0,0,0},{0,3,1,2},{0,3,2,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,3,2,0},
81 {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},
82 {1,2,0,3},{0,0,0,0},{1,3,0,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,3,0,1},{2,3,1,0},
83 {1,0,2,3},{1,0,3,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,0,3,1},{0,0,0,0},{2,1,3,0},
84 {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},
85 {2,0,1,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,0,1,2},{3,0,2,1},{0,0,0,0},{3,1,2,0},
86 {2,1,0,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,1,0,2},{0,0,0,0},{3,2,0,1},{3,2,1,0}
95 static inline float grad4dSimplex(
int hash,
float x,
float y,
float z,
float t);
110 X = (int)floor(x) & 255;
117 return 0.25 *
lerp(u,
164 X = (int)floor(x) & 255;
165 Y = (int)floor(y) & 255;
232 X = (int)floor(x) & 255;
233 Y = (int)floor(y) & 255;
234 Z = (int)floor(z) & 255;
314 X = (int)floor(x) & 255;
315 Y = (int)floor(y) & 255;
316 Z = (int)floor(z) & 255;
317 W = (int)floor(w) & 255;
419 float t0 = 1.0f - x0 * x0;
423 float t1 = 1.0f - x1 * x1;
426 return 0.395f * (n0 + n1);
511 VuoReal x2 = x0 - 1.0f + 2.0f * g2;
512 VuoReal y2 = y0 - 1.0f + 2.0f * g2;
519 VuoReal t0 = 0.5f - x0 * x0 - y0 * y0;
528 VuoReal t1 = 0.5f - x1 * x1 - y1 * y1;
537 VuoReal t2 = 0.5f - x2 * x2 - y2 * y2;
548 return 46.0f * (n0 + n1 + n2);
686 VuoReal x2 = x0 - i2 + 2.0f * G3;
687 VuoReal y2 = y0 - j2 + 2.0f * G3;
688 VuoReal z2 = z0 - k2 + 2.0f * G3;
689 VuoReal x3 = x0 - 1.0f + 3.0f * G3;
690 VuoReal y3 = y0 - 1.0f + 3.0f * G3;
691 VuoReal z3 = z0 - 1.0f + 3.0f * G3;
699 VuoReal t0 = 0.6f - x0 * x0 - y0 * y0 - z0 * z0;
708 VuoReal t1 = 0.6f - x1 * x1 - y1 * y1 - z1 * z1;
717 VuoReal t2 = 0.6f - x2 * x2 - y2 * y2 - z2 * z2;
726 VuoReal t3 = 0.6f - x3 * x3 - y3 * y3 - z3 * z3;
737 return 32.0f * (n0 + n1 + n2 + n3);
781 float F4 = 0.309016994f;
782 float G4 = 0.138196601f;
784 float n0, n1, n2, n3, n4;
787 float s = (x + y + z + w) * F4;
792 int i = (int)floorf(xs);
793 int j = (int)floorf(ys);
794 int k = (int)floorf(zs);
795 int l = (int)floorf(ws);
797 float t = (i + j + k + l) * G4;
816 int c1 = (x0 > y0) ? 32 : 0;
817 int c2 = (x0 > z0) ? 16 : 0;
818 int c3 = (y0 > z0) ? 8 : 0;
819 int c4 = (x0 > w0) ? 4 : 0;
820 int c5 = (y0 > w0) ? 2 : 0;
821 int c6 = (z0 > w0) ? 1 : 0;
822 int c = c1 + c2 + c3 + c4 + c5 + c6;
833 i1 =
simplex[c][0] >= 3 ? 1 : 0;
834 j1 =
simplex[c][1] >= 3 ? 1 : 0;
835 k1 =
simplex[c][2] >= 3 ? 1 : 0;
836 l1 =
simplex[c][3] >= 3 ? 1 : 0;
838 i2 =
simplex[c][0] >= 2 ? 1 : 0;
839 j2 =
simplex[c][1] >= 2 ? 1 : 0;
840 k2 =
simplex[c][2] >= 2 ? 1 : 0;
841 l2 =
simplex[c][3] >= 2 ? 1 : 0;
849 float x1 = x0 - i1 + G4;
850 float y1 = y0 - j1 + G4;
851 float z1 = z0 - k1 + G4;
852 float w1 = w0 - l1 + G4;
853 float x2 = x0 - i2 + 2.0f*G4;
854 float y2 = y0 - j2 + 2.0f*G4;
855 float z2 = z0 - k2 + 2.0f*G4;
856 float w2 = w0 - l2 + 2.0f*G4;
857 float x3 = x0 - i3 + 3.0f*G4;
858 float y3 = y0 - j3 + 3.0f*G4;
859 float z3 = z0 - k3 + 3.0f*G4;
860 float w3 = w0 - l3 + 3.0f*G4;
861 float x4 = x0 - 1.0f + 4.0f*G4;
862 float y4 = y0 - 1.0f + 4.0f*G4;
863 float z4 = z0 - 1.0f + 4.0f*G4;
864 float w4 = w0 - 1.0f + 4.0f*G4;
873 float t0 = 0.6f - x0*x0 - y0*y0 - z0*z0 - w0*w0;
882 float t1 = 0.6f - x1*x1 - y1*y1 - z1*z1 - w1*w1;
891 float t2 = 0.6f - x2*x2 - y2*y2 - z2*z2 - w2*w2;
900 float t3 = 0.6f - x3*x3 - y3*y3 - z3*z3 - w3*w3;
909 float t4 = 0.6f - x4*x4 - y4*y4 - z4*z4 - w4*w4;
919 return 27.0f * (n0 + n1 + n2 + n3 + n4);
963 float grad = 1.0 + (h & 7);
980 VuoReal v = h < 4 ? y : h==12 || h==14 ? x : 0;
981 return ((h&1) == 0 ? u : -u) + ((h&2) == 0 ? v : -v);
992 return ((h&1) ? -u : u) + ((h&2) ? -2.0f*v : 2.0f*v);
1002 VuoReal v = h<4 ? y : h==12||h==14 ? x : z;
1003 return ((h&1) == 0 ? u : - u) + ((h&2) == 0 ? v : -v);
1031 return ((h&4)==0 ? -a:a) + ((h&2)==0 ? -b:b) + ((h&1)==0 ? -c:c);
1040 float u = h < 24 ? x : y;
1041 float v = h < 16 ? y : z;
1042 float w = h < 8 ? z : t;
1043 return ((h&1) ? -u : u) + ((h&2) ? -v : v) + ((h&4) ? -w : w);
1051 return (t * t * t * (t * (t * 6 - 15) + 10));
1059 return (a + t * (b - a));