MCPcopy Create free account
hub / github.com/FastLED/FastLED / snoise16

Function snoise16

src/simplex.cpp.hpp:106–126  ·  view source on GitHub ↗

1D simplex noise.

Source from the content-addressed store, hash-verified

104
105// 1D simplex noise.
106fl::u16 snoise16(fl::u32 x) {
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}
127
128// 2D simplex noise.
129fl::u16 snoise16(fl::u32 x, fl::u32 y) {

Callers

nothing calls this directly

Calls 1

gradFunction · 0.70

Tested by

no test coverage detected