FastLED 3.10.8
Loading...
Searching...
No Matches

◆ inoise8_raw() [2/3]

fl::i8 inoise8_raw ( fl::u16 x,
fl::u16 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 621 of file noise.cpp.hpp.

622 {
623 // Find the unit cube containing the point
624 fl::u8 X = x>>8;
625 fl::u8 Y = y>>8;
626
627 // Hash cube corner coordinates
628 fl::u8 A = NOISE_P(X)+Y;
629 fl::u8 AA = NOISE_P(A);
630 fl::u8 AB = NOISE_P(A+1);
631 fl::u8 B = NOISE_P(X+1)+Y;
632 fl::u8 BA = NOISE_P(B);
633 fl::u8 BB = NOISE_P(B+1);
634
635 // Get the relative position of the point in the cube
636 fl::u8 u = x;
637 fl::u8 v = y;
638
639 // Get a signed version of the above for the grad function
640 fl::i8 xx = ((fl::u8)(x)>>1) & 0x7F;
641 fl::i8 yy = ((fl::u8)(y)>>1) & 0x7F;
642 fl::u8 N = 0x80;
643
644 u = EASE8(u); v = EASE8(v);
645
646 fl::i8 X1 = lerp7by8(grad8(NOISE_P(AA), xx, yy), grad8(NOISE_P(BA), xx - N, yy), u);
647 fl::i8 X2 = lerp7by8(grad8(NOISE_P(AB), xx, yy-N), grad8(NOISE_P(BB), xx - N, yy - N), u);
648
649 fl::i8 ans = lerp7by8(X1,X2,v);
650
651 return ans;
652 // return scale8((70+(ans)),234)<<1;
653}
int y
Definition simple.h:93
int x
Definition simple.h:92
unsigned char u8
Definition stdint.h:131
signed char i8
Definition stdint.h:130
static fl::i8 lerp7by8(fl::i8 a, fl::i8 b, fract8 frac) FL_NO_EXCEPT
static fl::i8 grad8(fl::u8 hash, fl::i8 x, fl::i8 y, fl::i8 z) FL_NO_EXCEPT
#define NOISE_P(x)
Reads a single byte from the p array.
Definition noise.cpp.hpp:33

References FL_NO_EXCEPT, grad8(), lerp7by8(), NOISE_P, x, and y.

+ Here is the call graph for this function: