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

◆ inoise16_raw() [1/4]

fl::i16 inoise16_raw ( fl::u32 x)
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)

Definition at line 505 of file noise.cpp.hpp.

506{
507 // Find the unit cube containing the point
508 fl::u8 X = x>>16;
509
510 // Hash cube corner coordinates
511 fl::u8 A = NOISE_P(X);
512 fl::u8 AA = NOISE_P(A);
513 fl::u8 B = NOISE_P(X+1);
514 fl::u8 BA = NOISE_P(B);
515
516 // Get the relative position of the point in the cube
517 fl::u16 u = x & 0xFFFF;
518
519 // Get a signed version of the above for the grad function
520 fl::i16 xx = (u >> 1) & 0x7FFF;
521 fl::u16 N = 0x8000L;
522
523 u = EASE16(u);
524
525 fl::i16 ans = LERP(grad16(NOISE_P(AA), xx), grad16(NOISE_P(BA), xx - N), u);
526
527 return ans;
528}
int x
Definition simple.h:92
unsigned char u8
Definition stdint.h:131
FL_DISABLE_WARNING_PUSH unsigned char * B
static fl::i16 grad16(fl::u8 hash, fl::i16 x, fl::i16 y, fl::i16 z)
#define NOISE_P(x)
Reads a single byte from the p array.
Definition noise.cpp.hpp:32

References grad16(), NOISE_P, and x.

+ Here is the call graph for this function: