FastLED 3.9.15
Loading...
Searching...
No Matches

◆ inoise8_raw() [2/3]

int8_t inoise8_raw ( uint16_t x,
uint16_t y )
extern

8-bit, fixed point implementation of Perlin's noise without scaling.

Coordinates are 8.8 fixed point values, 16-bit integers with integral coordinates in the high 8-bits and fractional in the low 8-bits.

Returns
unscaled noise value as a signed integer, roughly -70 to 70
Parameters
xx-axis coordinate on noise map (1D)
yy-axis coordinate on noise map (2D)

Definition at line 598 of file noise.cpp.

599{
600 // Find the unit cube containing the point
601 uint8_t X = x>>8;
602 uint8_t Y = y>>8;
603
604 // Hash cube corner coordinates
605 uint8_t A = P(X)+Y;
606 uint8_t AA = P(A);
607 uint8_t AB = P(A+1);
608 uint8_t B = P(X+1)+Y;
609 uint8_t BA = P(B);
610 uint8_t BB = P(B+1);
611
612 // Get the relative position of the point in the cube
613 uint8_t u = x;
614 uint8_t v = y;
615
616 // Get a signed version of the above for the grad function
617 int8_t xx = ((uint8_t)(x)>>1) & 0x7F;
618 int8_t yy = ((uint8_t)(y)>>1) & 0x7F;
619 uint8_t N = 0x80;
620
621 u = EASE8(u); v = EASE8(v);
622
623 int8_t X1 = lerp7by8(grad8(P(AA), xx, yy), grad8(P(BA), xx - N, yy), u);
624 int8_t X2 = lerp7by8(grad8(P(AB), xx, yy-N), grad8(P(BB), xx - N, yy - N), u);
625
626 int8_t ans = lerp7by8(X1,X2,v);
627
628 return ans;
629 // return scale8((70+(ans)),234)<<1;
630}
int y
Definition Audio.ino:72
int x
Definition Audio.ino:71
static int8_t grad8(uint8_t hash, int8_t x, int8_t y, int8_t z)
Definition noise.cpp:183
#define P(x)
Reads a single byte from the p array.
Definition noise.cpp:25
static int8_t lerp7by8(int8_t a, int8_t b, fract8 frac)
Definition noise.cpp:298

References grad8(), lerp7by8(), P, x, and y.

+ Here is the call graph for this function: