FastLED 3.9.15
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages

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

345{
346 // Find the unit cube containing the point
347 uint8_t X = (x>>16)&0xFF;
348 uint8_t Y = (y>>16)&0xFF;
349 uint8_t Z = (z>>16)&0xFF;
350
351 // Hash cube corner coordinates
352 uint8_t A = P(X)+Y;
353 uint8_t AA = P(A)+Z;
354 uint8_t AB = P(A+1)+Z;
355 uint8_t B = P(X+1)+Y;
356 uint8_t BA = P(B) + Z;
357 uint8_t BB = P(B+1)+Z;
358
359 // Get the relative position of the point in the cube
360 uint16_t u = x & 0xFFFF;
361 uint16_t v = y & 0xFFFF;
362 uint16_t w = z & 0xFFFF;
363
364 // Get a signed version of the above for the grad function
365 int16_t xx = (u >> 1) & 0x7FFF;
366 int16_t yy = (v >> 1) & 0x7FFF;
367 int16_t zz = (w >> 1) & 0x7FFF;
368 uint16_t N = 0x8000L;
369
370 u = EASE16(u); v = EASE16(v); w = EASE16(w);
371
372 // skip the log fade adjustment for the moment, otherwise here we would
373 // adjust fade values for u,v,w
374 int16_t X1 = LERP(grad16(P(AA), xx, yy, zz), grad16(P(BA), xx - N, yy, zz), u);
375 int16_t X2 = LERP(grad16(P(AB), xx, yy-N, zz), grad16(P(BB), xx - N, yy - N, zz), u);
376 int16_t X3 = LERP(grad16(P(AA+1), xx, yy, zz-N), grad16(P(BA+1), xx - N, yy, zz-N), u);
377 int16_t X4 = LERP(grad16(P(AB+1), xx, yy-N, zz-N), grad16(P(BB+1), xx - N, yy - N, zz - N), u);
378
379 int16_t Y1 = LERP(X1,X2,v);
380 int16_t Y2 = LERP(X3,X4,v);
381
382 int16_t ans = LERP(Y1,Y2,w);
383
384 return ans;
385}
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
#define P(x)
Reads a single byte from the p array.
Definition noise.cpp:51
static int16_t grad16(uint8_t hash, int16_t x, int16_t y, int16_t z)
Definition noise.cpp:133

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: