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

530{
531 // Find the unit cube containing the point
532 uint8_t X = x>>8;
533 uint8_t Y = y>>8;
534 uint8_t Z = z>>8;
535
536 // Hash cube corner coordinates
537 uint8_t A = NOISE_P(X)+Y;
538 uint8_t AA = NOISE_P(A)+Z;
539 uint8_t AB = NOISE_P(A+1)+Z;
540 uint8_t B = NOISE_P(X+1)+Y;
541 uint8_t BA = NOISE_P(B) + Z;
542 uint8_t BB = NOISE_P(B+1)+Z;
543
544 // Get the relative position of the point in the cube
545 uint8_t u = x;
546 uint8_t v = y;
547 uint8_t w = z;
548
549 // Get a signed version of the above for the grad function
550 int8_t xx = ((uint8_t)(x)>>1) & 0x7F;
551 int8_t yy = ((uint8_t)(y)>>1) & 0x7F;
552 int8_t zz = ((uint8_t)(z)>>1) & 0x7F;
553 uint8_t N = 0x80;
554
555 u = EASE8(u); v = EASE8(v); w = EASE8(w);
556
557 int8_t X1 = lerp7by8(grad8(NOISE_P(AA), xx, yy, zz), grad8(NOISE_P(BA), xx - N, yy, zz), u);
558 int8_t X2 = lerp7by8(grad8(NOISE_P(AB), xx, yy-N, zz), grad8(NOISE_P(BB), xx - N, yy - N, zz), u);
559 int8_t X3 = lerp7by8(grad8(NOISE_P(AA+1), xx, yy, zz-N), grad8(NOISE_P(BA+1), xx - N, yy, zz-N), u);
560 int8_t X4 = lerp7by8(grad8(NOISE_P(AB+1), xx, yy-N, zz-N), grad8(NOISE_P(BB+1), xx - N, yy - N, zz - N), u);
561
562 int8_t Y1 = lerp7by8(X1,X2,v);
563 int8_t Y2 = lerp7by8(X3,X4,v);
564
565 int8_t ans = lerp7by8(Y1,Y2,w);
566
567 return ans;
568}
int y
Definition simple.h:93
int x
Definition simple.h:92
uint32_t z[NUM_LAYERS]
Definition Fire2023.h:94
static int8_t grad8(uint8_t hash, int8_t x, int8_t y, int8_t z)
Definition noise.cpp:187
static int8_t lerp7by8(int8_t a, int8_t b, fract8 frac)
Definition noise.cpp:278
#define NOISE_P(x)
Reads a single byte from the p array.
Definition noise.cpp:26

References 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: