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

◆ inoise8_raw() [3/3]

fl::i8 inoise8_raw ( fl::u16 x,
fl::u16 y,
fl::u16 z )
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)
zz-axis coordinate on noise map (3D)

Definition at line 572 of file noise.cpp.hpp.

573 {
574 // Find the unit cube containing the point
575 fl::u8 X = x>>8;
576 fl::u8 Y = y>>8;
577 fl::u8 Z = z>>8;
578
579 // Hash cube corner coordinates
580 fl::u8 A = NOISE_P(X)+Y;
581 fl::u8 AA = NOISE_P(A)+Z;
582 fl::u8 AB = NOISE_P(A+1)+Z;
583 fl::u8 B = NOISE_P(X+1)+Y;
584 fl::u8 BA = NOISE_P(B) + Z;
585 fl::u8 BB = NOISE_P(B+1)+Z;
586
587 // Get the relative position of the point in the cube
588 fl::u8 u = x;
589 fl::u8 v = y;
590 fl::u8 w = z;
591
592 // Get a signed version of the above for the grad function
593 fl::i8 xx = ((fl::u8)(x)>>1) & 0x7F;
594 fl::i8 yy = ((fl::u8)(y)>>1) & 0x7F;
595 fl::i8 zz = ((fl::u8)(z)>>1) & 0x7F;
596 fl::u8 N = 0x80;
597
598 u = EASE8(u); v = EASE8(v); w = EASE8(w);
599
600 fl::i8 X1 = lerp7by8(grad8(NOISE_P(AA), xx, yy, zz), grad8(NOISE_P(BA), xx - N, yy, zz), u);
601 fl::i8 X2 = lerp7by8(grad8(NOISE_P(AB), xx, yy-N, zz), grad8(NOISE_P(BB), xx - N, yy - N, zz), u);
602 fl::i8 X3 = lerp7by8(grad8(NOISE_P(AA+1), xx, yy, zz-N), grad8(NOISE_P(BA+1), xx - N, yy, zz-N), u);
603 fl::i8 X4 = lerp7by8(grad8(NOISE_P(AB+1), xx, yy-N, zz-N), grad8(NOISE_P(BB+1), xx - N, yy - N, zz - N), u);
604
605 fl::i8 Y1 = lerp7by8(X1,X2,v);
606 fl::i8 Y2 = lerp7by8(X3,X4,v);
607
608 fl::i8 ans = lerp7by8(Y1,Y2,w);
609
610 return ans;
611}
int y
Definition simple.h:93
int x
Definition simple.h:92
uint32_t z[NUM_LAYERS]
Definition Fire2023.h:93
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, y, and z.

Referenced by inoise8(), inoise8(), and inoise8().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: