FastLED 3.9.15
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 106 of file simplex.cpp.hpp.

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

References grad(), SIMPLEX_P, and x.

+ Here is the call graph for this function: