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

◆ inoise8_raw() [3/3]

int8_t inoise8_raw ( uint16_t x,
uint16_t y,
uint16_t 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 575 of file noise.cpp.

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