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

◆ inoise16_raw() [3/4]

int16_t inoise16_raw ( uint32_t x,
uint32_t y,
uint32_t z )
extern

16-bit, fixed point implementation of Perlin's noise without scaling.

Coordinates are 16.16 fixed point values, 32 bit integers with integral coordinates in the high 16-bits and fractional in the low 16-bits.

Returns
unscaled noise value as a signed integer, roughly -18k to 18k
Parameters
xx-axis coordinate on noise map (1D)
yy-axis coordinate on noise map (2D)
zz-axis coordinate on noise map (3D)

Definition at line 318 of file noise.cpp.

319{
320 // Find the unit cube containing the point
321 uint8_t X = (x>>16)&0xFF;
322 uint8_t Y = (y>>16)&0xFF;
323 uint8_t Z = (z>>16)&0xFF;
324
325 // Hash cube corner coordinates
326 uint8_t A = P(X)+Y;
327 uint8_t AA = P(A)+Z;
328 uint8_t AB = P(A+1)+Z;
329 uint8_t B = P(X+1)+Y;
330 uint8_t BA = P(B) + Z;
331 uint8_t BB = P(B+1)+Z;
332
333 // Get the relative position of the point in the cube
334 uint16_t u = x & 0xFFFF;
335 uint16_t v = y & 0xFFFF;
336 uint16_t w = z & 0xFFFF;
337
338 // Get a signed version of the above for the grad function
339 int16_t xx = (u >> 1) & 0x7FFF;
340 int16_t yy = (v >> 1) & 0x7FFF;
341 int16_t zz = (w >> 1) & 0x7FFF;
342 uint16_t N = 0x8000L;
343
344 u = EASE16(u); v = EASE16(v); w = EASE16(w);
345
346 // skip the log fade adjustment for the moment, otherwise here we would
347 // adjust fade values for u,v,w
348 int16_t X1 = LERP(grad16(P(AA), xx, yy, zz), grad16(P(BA), xx - N, yy, zz), u);
349 int16_t X2 = LERP(grad16(P(AB), xx, yy-N, zz), grad16(P(BB), xx - N, yy - N, zz), u);
350 int16_t X3 = LERP(grad16(P(AA+1), xx, yy, zz-N), grad16(P(BA+1), xx - N, yy, zz-N), u);
351 int16_t X4 = LERP(grad16(P(AB+1), xx, yy-N, zz-N), grad16(P(BB+1), xx - N, yy - N, zz - N), u);
352
353 int16_t Y1 = LERP(X1,X2,v);
354 int16_t Y2 = LERP(X3,X4,v);
355
356 int16_t ans = LERP(Y1,Y2,w);
357
358 return ans;
359}
int y
Definition Audio.ino:72
int x
Definition Audio.ino:71
uint32_t z[NUM_LAYERS]
Definition Fire2023.ino:84
#define P(x)
Reads a single byte from the p array.
Definition noise.cpp:25
static int16_t grad16(uint8_t hash, int16_t x, int16_t y, int16_t z)
Definition noise.cpp:107

References grad16(), P, x, y, and z.

Referenced by inoise16(), inoise16(), inoise16(), and inoise16().

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