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

453{
454 // Find the unit cube containing the point
455 uint8_t X = x>>16;
456 uint8_t Y = y>>16;
457
458 // Hash cube corner coordinates
459 uint8_t A = NOISE_P(X)+Y;
460 uint8_t AA = NOISE_P(A);
461 uint8_t AB = NOISE_P(A+1);
462 uint8_t B = NOISE_P(X+1)+Y;
463 uint8_t BA = NOISE_P(B);
464 uint8_t BB = NOISE_P(B+1);
465
466 // Get the relative position of the point in the cube
467 uint16_t u = x & 0xFFFF;
468 uint16_t v = y & 0xFFFF;
469
470 // Get a signed version of the above for the grad function
471 int16_t xx = (u >> 1) & 0x7FFF;
472 int16_t yy = (v >> 1) & 0x7FFF;
473 uint16_t N = 0x8000L;
474
475 u = EASE16(u); v = EASE16(v);
476
477 int16_t X1 = LERP(grad16(NOISE_P(AA), xx, yy), grad16(NOISE_P(BA), xx - N, yy), u);
478 int16_t X2 = LERP(grad16(NOISE_P(AB), xx, yy-N), grad16(NOISE_P(BB), xx - N, yy - N), u);
479
480 int16_t ans = LERP(X1,X2,v);
481
482 return ans;
483}
int y
Definition simple.h:93
int x
Definition simple.h:92
static int16_t grad16(uint8_t hash, int16_t x, int16_t y, int16_t z)
Definition noise.cpp:111
#define NOISE_P(x)
Reads a single byte from the p array.
Definition noise.cpp:26

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

+ Here is the call graph for this function: