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

◆ inoise16_raw() [2/4]

int16_t inoise16_raw ( uint32_t x,
uint32_t y )
extern

16-bit, fixed point implementation of Perlin's noise without scaling.

Coordinates are 16.16 fixed point values, 32 bit integers with integral coordinates in the high 16-bits and fractional in the low 16-bits.

Returns
unscaled noise value as a signed integer, roughly -18k to 18k
Parameters
xx-axis coordinate on noise map (1D)
yy-axis coordinate on noise map (2D)

Definition at line 498 of file noise.cpp.

499{
500 // Find the unit cube containing the point
501 uint8_t X = x>>16;
502 uint8_t Y = y>>16;
503
504 // Hash cube corner coordinates
505 uint8_t A = P(X)+Y;
506 uint8_t AA = P(A);
507 uint8_t AB = P(A+1);
508 uint8_t B = P(X+1)+Y;
509 uint8_t BA = P(B);
510 uint8_t BB = P(B+1);
511
512 // Get the relative position of the point in the cube
513 uint16_t u = x & 0xFFFF;
514 uint16_t v = y & 0xFFFF;
515
516 // Get a signed version of the above for the grad function
517 int16_t xx = (u >> 1) & 0x7FFF;
518 int16_t yy = (v >> 1) & 0x7FFF;
519 uint16_t N = 0x8000L;
520
521 u = EASE16(u); v = EASE16(v);
522
523 int16_t X1 = LERP(grad16(P(AA), xx, yy), grad16(P(BA), xx - N, yy), u);
524 int16_t X2 = LERP(grad16(P(AB), xx, yy-N), grad16(P(BB), xx - N, yy - N), u);
525
526 int16_t ans = LERP(X1,X2,v);
527
528 return ans;
529}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
#define P(x)
Reads a single byte from the p array.
Definition noise.cpp:51
static int16_t grad16(uint8_t hash, int16_t x, int16_t y, int16_t z)
Definition noise.cpp:133

References grad16(), P, x, and y.

+ Here is the call graph for this function: