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

◆ grad8() [3/3]

static int8_t grad8 ( uint8_t hash,
int8_t x,
int8_t y,
int8_t z )
inlinestatic

Definition at line 209 of file noise.cpp.

209 {
210#if 0
211 switch(hash & 0xF) {
212 case 0: return (( x) + ( y))>>1;
213 case 1: return ((-x) + ( y))>>1;
214 case 2: return (( x) + (-y))>>1;
215 case 3: return ((-x) + (-y))>>1;
216 case 4: return (( x) + ( z))>>1;
217 case 5: return ((-x) + ( z))>>1;
218 case 6: return (( x) + (-z))>>1;
219 case 7: return ((-x) + (-z))>>1;
220 case 8: return (( y) + ( z))>>1;
221 case 9: return ((-y) + ( z))>>1;
222 case 10: return (( y) + (-z))>>1;
223 case 11: return ((-y) + (-z))>>1;
224 case 12: return (( y) + ( x))>>1;
225 case 13: return ((-y) + ( z))>>1;
226 case 14: return (( y) + (-x))>>1;
227 case 15: return ((-y) + (-z))>>1;
228 }
229#else
230
231 hash &= 0xF;
232
233 int8_t u, v;
234 //u = (hash&8)?y:x;
235 u = selectBasedOnHashBit( hash, 3, y, x);
236
237#if 1
238 v = hash<4?y:hash==12||hash==14?x:z;
239#else
240 // Verbose version for analysis; generates idenitical code.
241 if( hash < 4) { // 00 01 02 03
242 v = y;
243 } else {
244 if( hash==12 || hash==14) { // 0C 0E
245 v = x;
246 } else {
247 v = z; // 04 05 06 07 08 09 0A 0B 0D 0F
248 }
249 }
250#endif
251
252 if(hash&1) { u = -u; }
253 if(hash&2) { v = -v; }
254
255 return avg7(u,v);
256#endif
257}
uint32_t z[NUM_LAYERS]
Definition Fire2023.ino:82
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
LIB8STATIC_ALWAYS_INLINE int8_t avg7(int8_t i, int8_t j)
Calculate an integer average of two signed 7-bit integers (int8_t).
Definition math8.h:306
static int8_t selectBasedOnHashBit(uint8_t hash, uint8_t bitnumber, int8_t a, int8_t b)
Definition noise.cpp:190

References avg7(), selectBasedOnHashBit(), x, y, and z.

Referenced by inoise8_raw(), inoise8_raw(), and inoise8_raw().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: