FastLED 3.10.8
Loading...
Searching...
No Matches

◆ inoise16_raw() [2/4]

fl::i16 inoise16_raw ( fl::u32 x,
fl::u32 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 495 of file noise.cpp.hpp.

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

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

+ Here is the call graph for this function: