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