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

473{
474 // Find the unit cube containing the point
475 uint8_t X = x>>16;
476 uint8_t Y = y>>16;
477
478 // Hash cube corner coordinates
479 uint8_t A = P(X)+Y;
480 uint8_t AA = P(A);
481 uint8_t AB = P(A+1);
482 uint8_t B = P(X+1)+Y;
483 uint8_t BA = P(B);
484 uint8_t BB = P(B+1);
485
486 // Get the relative position of the point in the cube
487 uint16_t u = x & 0xFFFF;
488 uint16_t v = y & 0xFFFF;
489
490 // Get a signed version of the above for the grad function
491 int16_t xx = (u >> 1) & 0x7FFF;
492 int16_t yy = (v >> 1) & 0x7FFF;
493 uint16_t N = 0x8000L;
494
495 u = EASE16(u); v = EASE16(v);
496
497 int16_t X1 = LERP(grad16(P(AA), xx, yy), grad16(P(BA), xx - N, yy), u);
498 int16_t X2 = LERP(grad16(P(AB), xx, yy-N), grad16(P(BB), xx - N, yy - N), u);
499
500 int16_t ans = LERP(X1,X2,v);
501
502 return ans;
503}
int y
Definition Audio.ino:72
int x
Definition Audio.ino:71
#define P(x)
Reads a single byte from the p array.
Definition noise.cpp:25
static int16_t grad16(uint8_t hash, int16_t x, int16_t y, int16_t z)
Definition noise.cpp:107

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

+ Here is the call graph for this function: