F32 LLPerlinNoise::noise3(F32 x, F32 y, F32 z) { U8 bx0, bx1, by0, by1, bz0, bz1; S32 b00, b10, b01, b11; F32 rx0, rx1, ry0, ry1, rz0, rz1, *q, sy, sz, a, b, c, d, t, u, v; S32 i, j; if (!sInitialized) init(); fast_setup(x, bx0,bx1, rx0,rx1); fast_setup(y, by0,by1, ry0,ry1); fast_setup(z, bz0,bz1, rz0,rz1); i = p[ bx0 ]; j = p[ bx1 ]; b00 = p[ i + by0 ]; b10 = p[ j + by0 ]; b01 = p[ i + by1 ]; b11 = p[ j + by1 ]; t = s_curve(rx0); sy = s_curve(ry0); sz = s_curve(rz0); q = g3[ b00 + bz0 ]; u = fast_at3(rx0,ry0,rz0,q); q = g3[ b10 + bz0 ]; v = fast_at3(rx1,ry0,rz0,q); a = lerp_m(t, u, v); q = g3[ b01 + bz0 ]; u = fast_at3(rx0,ry1,rz0,q); q = g3[ b11 + bz0 ]; v = fast_at3(rx1,ry1,rz0,q); b = lerp_m(t, u, v); c = lerp_m(sy, a, b); q = g3[ b00 + bz1 ]; u = fast_at3(rx0,ry0,rz1,q); q = g3[ b10 + bz1 ]; v = fast_at3(rx1,ry0,rz1,q); a = lerp_m(t, u, v); q = g3[ b01 + bz1 ]; u = fast_at3(rx0,ry1,rz1,q); q = g3[ b11 + bz1 ]; v = fast_at3(rx1,ry1,rz1,q); b = lerp_m(t, u, v); d = lerp_m(sy, a, b); return lerp_m(sz, c, d); }
F32 noise2(F32 *vec) { U8 bx0, bx1, by0, by1; U32 b00, b10, b01, b11; F32 rx0, rx1, ry0, ry1, *q, sx, sy, a, b, u, v; S32 i, j; if (gNoiseStart) { gNoiseStart = 0; init(); } fast_setup(*vec, bx0, bx1, rx0, rx1); fast_setup(*(vec + 1), by0, by1, ry0, ry1); i = *(p + bx0); j = *(p + bx1); b00 = *(p + i + by0); b10 = *(p + j + by0); b01 = *(p + i + by1); b11 = *(p + j + by1); sx = s_curve(rx0); sy = s_curve(ry0); q = *(g2 + b00); u = fast_at2(rx0, ry0, q); q = *(g2 + b10); v = fast_at2(rx1, ry0, q); a = lerp_m(sx, u, v); q = *(g2 + b01); u = fast_at2(rx0,ry1,q); q = *(g2 + b11); v = fast_at2(rx1,ry1,q); b = lerp_m(sx, u, v); return lerp_m(sy, a, b); }
F32 LLPerlinNoise::noise2(F32 x, F32 y) { U8 bx0, bx1, by0, by1; U32 b00, b10, b01, b11; F32 rx0, rx1, ry0, ry1, *q, sx, sy, a, b, u, v; S32 i, j; if (!sInitialized) init(); fast_setup(x, bx0, bx1, rx0, rx1); fast_setup(y, by0, by1, ry0, ry1); i = *(p + bx0); j = *(p + bx1); b00 = *(p + i + by0); b10 = *(p + j + by0); b01 = *(p + i + by1); b11 = *(p + j + by1); sx = s_curve(rx0); sy = s_curve(ry0); q = *(g2 + b00); u = fast_at2(rx0, ry0, q); q = *(g2 + b10); v = fast_at2(rx1, ry0, q); a = lerp_m(sx, u, v); q = *(g2 + b01); u = fast_at2(rx0,ry1,q); q = *(g2 + b11); v = fast_at2(rx1,ry1,q); b = lerp_m(sx, u, v); return lerp_m(sy, a, b); }