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;
110 int32_t x1 = x0 - 0x1000;
111
112 int32_t t0 = 0x8000 - ((x0*x0)>>9);
113 t0 = (t0 * t0) >> 15;
114 t0 = (t0 * t0) >> 15;
116
117 int32_t t1 = 0x8000 - ((x1*x1)>>9);
118 t1 = (t1 * t1) >> 15;
119 t1 = (t1 * t1) >> 15;
121
122 int32_t n = n0 + n1;
123 n += 2503;
124 n = (n * 26694) >> 16;
125 return uint16_t(n) + 0x8000;
126}
static int32_t grad(uint8_t hash, int32_t x)
References grad(), SIMPLEX_P, and x.