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 187 of file noise.cpp.

187 {
188 // Industry-standard 3D Perlin noise gradient implementation
189 // Uses proper 12 edge vectors of a cube for maximum range coverage
190
191 switch(hash & 0xF) {
192 case 0: return avg7( x, y); // (1,1,0)
193 case 1: return avg7(-x, y); // (-1,1,0)
194 case 2: return avg7( x, -y); // (1,-1,0)
195 case 3: return avg7(-x, -y); // (-1,-1,0)
196 case 4: return avg7( x, z); // (1,0,1)
197 case 5: return avg7(-x, z); // (-1,0,1)
198 case 6: return avg7( x, -z); // (1,0,-1)
199 case 7: return avg7(-x, -z); // (-1,0,-1)
200 case 8: return avg7( y, z); // (0,1,1)
201 case 9: return avg7(-y, z); // (0,-1,1)
202 case 10: return avg7( y, -z); // (0,1,-1)
203 case 11: return avg7(-y, -z); // (0,-1,-1)
204 // Repeat first 4 for hash values 12-15 (proper wrap-around)
205 case 12: return avg7( x, y); // (1,1,0)
206 case 13: return avg7(-x, y); // (-1,1,0)
207 case 14: return avg7( x, -y); // (1,-1,0)
208 case 15: return avg7(-x, -y); // (-1,-1,0)
209 }
210 return 0; // Should never reach here
211}
int y
Definition simple.h:93
int x
Definition simple.h:92
uint32_t z[NUM_LAYERS]
Definition Fire2023.h:94
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:322

References avg7(), 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: