FastLED 3.10.8
Loading...
Searching...
No Matches

◆ inoise16_raw() [3/4]

fl::i16 inoise16_raw ( fl::u32 x,
fl::u32 y,
fl::u32 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 341 of file noise.cpp.hpp.

342 {
343 // Find the unit cube containing the point
344 fl::u8 X = (x>>16)&0xFF;
345 fl::u8 Y = (y>>16)&0xFF;
346 fl::u8 Z = (z>>16)&0xFF;
347
348 // Hash cube corner coordinates
349 fl::u8 A = NOISE_P(X)+Y;
350 fl::u8 AA = NOISE_P(A)+Z;
351 fl::u8 AB = NOISE_P(A+1)+Z;
352 fl::u8 B = NOISE_P(X+1)+Y;
353 fl::u8 BA = NOISE_P(B) + Z;
354 fl::u8 BB = NOISE_P(B+1)+Z;
355
356 // Get the relative position of the point in the cube
357 fl::u16 u = x & 0xFFFF;
358 fl::u16 v = y & 0xFFFF;
359 fl::u16 w = z & 0xFFFF;
360
361 // Get a signed version of the above for the grad function
362 fl::i16 xx = (u >> 1) & 0x7FFF;
363 fl::i16 yy = (v >> 1) & 0x7FFF;
364 fl::i16 zz = (w >> 1) & 0x7FFF;
365 fl::u16 N = 0x8000L;
366
367 u = EASE16(u); v = EASE16(v); w = EASE16(w);
368
369 // skip the log fade adjustment for the moment, otherwise here we would
370 // adjust fade values for u,v,w
371 fl::i16 X1 = LERP(grad16(NOISE_P(AA), xx, yy, zz), grad16(NOISE_P(BA), xx - N, yy, zz), u);
372 fl::i16 X2 = LERP(grad16(NOISE_P(AB), xx, yy-N, zz), grad16(NOISE_P(BB), xx - N, yy - N, zz), u);
373 fl::i16 X3 = LERP(grad16(NOISE_P(AA+1), xx, yy, zz-N), grad16(NOISE_P(BA+1), xx - N, yy, zz-N), u);
374 fl::i16 X4 = LERP(grad16(NOISE_P(AB+1), xx, yy-N, zz-N), grad16(NOISE_P(BB+1), xx - N, yy - N, zz - N), u);
375
376 fl::i16 Y1 = LERP(X1,X2,v);
377 fl::i16 Y2 = LERP(X3,X4,v);
378
379 fl::i16 ans = LERP(Y1,Y2,w);
380
381 return ans;
382}
int y
Definition simple.h:93
int x
Definition simple.h:92
uint32_t z[NUM_LAYERS]
Definition Fire2023.h:93
unsigned char u8
Definition stdint.h:131
static fl::i16 grad16(fl::u8 hash, fl::i16 x, fl::i16 y, fl::i16 z) FL_NO_EXCEPT
#define NOISE_P(x)
Reads a single byte from the p array.
Definition noise.cpp.hpp:33

References FL_NO_EXCEPT, grad16(), NOISE_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: