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

579{
580 // Find the unit cube containing the point
581 uint8_t X = x>>8;
582 uint8_t Y = y>>8;
583
584 // Hash cube corner coordinates
585 uint8_t A = NOISE_P(X)+Y;
586 uint8_t AA = NOISE_P(A);
587 uint8_t AB = NOISE_P(A+1);
588 uint8_t B = NOISE_P(X+1)+Y;
589 uint8_t BA = NOISE_P(B);
590 uint8_t BB = NOISE_P(B+1);
591
592 // Get the relative position of the point in the cube
593 uint8_t u = x;
594 uint8_t v = y;
595
596 // Get a signed version of the above for the grad function
597 int8_t xx = ((uint8_t)(x)>>1) & 0x7F;
598 int8_t yy = ((uint8_t)(y)>>1) & 0x7F;
599 uint8_t N = 0x80;
600
601 u = EASE8(u); v = EASE8(v);
602
603 int8_t X1 = lerp7by8(grad8(NOISE_P(AA), xx, yy), grad8(NOISE_P(BA), xx - N, yy), u);
604 int8_t X2 = lerp7by8(grad8(NOISE_P(AB), xx, yy-N), grad8(NOISE_P(BB), xx - N, yy - N), u);
605
606 int8_t ans = lerp7by8(X1,X2,v);
607
608 return ans;
609 // return scale8((70+(ans)),234)<<1;
610}
int y
Definition simple.h:93
int x
Definition simple.h:92
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, and y.

+ Here is the call graph for this function: