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

◆ snoise16() [1/4]

uint16_t snoise16 ( uint32_t 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.

106 {
107 uint32_t i0 = x >> 12;
108 uint32_t i1 = i0 + 1;
109 int32_t x0 = x & 0xfff; // .12
110 int32_t x1 = x0 - 0x1000; // .12
111
112 int32_t t0 = 0x8000 - ((x0*x0)>>9); // .15
113 t0 = (t0 * t0) >> 15; // .15
114 t0 = (t0 * t0) >> 15; // .15
115 int32_t n0 = (t0 * grad(SIMPLEX_P(i0&0xff), x0)) >> 12; // .15 * .12 = .15
116
117 int32_t t1 = 0x8000 - ((x1*x1)>>9); // .15
118 t1 = (t1 * t1) >> 15; // .15
119 t1 = (t1 * t1) >> 15; // .15
120 int32_t n1 = (t1 * grad(SIMPLEX_P(i1&0xff), x1)) >> 12; // .15 * .12 = .15
121
122 int32_t 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 uint16_t(n) + 0x8000;
126}
int x
Definition simple.h:92
static int32_t grad(uint8_t hash, int32_t x)
Definition simplex.cpp:74
#define SIMPLEX_P(x)
Definition simplex.cpp:35

References grad(), SIMPLEX_P, and x.

+ Here is the call graph for this function: