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 624 of file noise.cpp.

625{
626 // Find the unit cube containing the point
627 uint8_t X = x>>8;
628 uint8_t Y = y>>8;
629
630 // Hash cube corner coordinates
631 uint8_t A = P(X)+Y;
632 uint8_t AA = P(A);
633 uint8_t AB = P(A+1);
634 uint8_t B = P(X+1)+Y;
635 uint8_t BA = P(B);
636 uint8_t BB = P(B+1);
637
638 // Get the relative position of the point in the cube
639 uint8_t u = x;
640 uint8_t v = y;
641
642 // Get a signed version of the above for the grad function
643 int8_t xx = ((uint8_t)(x)>>1) & 0x7F;
644 int8_t yy = ((uint8_t)(y)>>1) & 0x7F;
645 uint8_t N = 0x80;
646
647 u = EASE8(u); v = EASE8(v);
648
649 int8_t X1 = lerp7by8(grad8(P(AA), xx, yy), grad8(P(BA), xx - N, yy), u);
650 int8_t X2 = lerp7by8(grad8(P(AB), xx, yy-N), grad8(P(BB), xx - N, yy - N), u);
651
652 int8_t ans = lerp7by8(X1,X2,v);
653
654 return ans;
655 // return scale8((70+(ans)),234)<<1;
656}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
static int8_t grad8(uint8_t hash, int8_t x, int8_t y, int8_t z)
Definition noise.cpp:209
#define P(x)
Reads a single byte from the p array.
Definition noise.cpp:51
static int8_t lerp7by8(int8_t a, int8_t b, fract8 frac)
Definition noise.cpp:324

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

+ Here is the call graph for this function: