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

◆ snoise16() [1/4]

fl::u16 snoise16 ( fl::u32 x)

32 bit, fixed point implementation of simplex noise functions.

The inputs are 20.12 fixed-point value. The result covers the full range of a uint16_t averaging around 32768.

Definition at line 107 of file simplex.cpp.hpp.

107 {
108 fl::u32 i0 = x >> 12;
109 fl::u32 i1 = i0 + 1;
110 fl::i32 x0 = x & 0xfff; // .12
111 fl::i32 x1 = x0 - 0x1000; // .12
112
113 fl::i32 t0 = 0x8000 - ((x0*x0)>>9); // .15
114 t0 = (t0 * t0) >> 15; // .15
115 t0 = (t0 * t0) >> 15; // .15
116 fl::i32 n0 = (t0 * grad(SIMPLEX_P(i0&0xff), x0)) >> 12; // .15 * .12 = .15
117
118 fl::i32 t1 = 0x8000 - ((x1*x1)>>9); // .15
119 t1 = (t1 * t1) >> 15; // .15
120 t1 = (t1 * t1) >> 15; // .15
121 fl::i32 n1 = (t1 * grad(SIMPLEX_P(i1&0xff), x1)) >> 12; // .15 * .12 = .15
122
123 fl::i32 n = n0 + n1; // .15
124 n += 2503; // .15: fix offset, adjust to +0.03
125 n = (n * 26694) >> 16; // .15: fix scale to fit in [-1,1]
126 return fl::u16(n) + 0x8000;
127}
int x
Definition simple.h:92
#define SIMPLEX_P(x)
static fl::i32 grad(fl::u8 hash, fl::i32 x) FL_NO_EXCEPT

References FL_NO_EXCEPT, grad(), SIMPLEX_P, and x.

+ Here is the call graph for this function: