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
-
x | x-axis coordinate on noise map (1D) |
y | y-axis coordinate on noise map (2D) |
Definition at line 498 of file noise.cpp.
499{
500
503
504
508 uint8_t B =
P(X+1)+Y;
511
512
513 uint16_t u =
x & 0xFFFF;
514 uint16_t v =
y & 0xFFFF;
515
516
517 int16_t xx = (u >> 1) & 0x7FFF;
518 int16_t yy = (v >> 1) & 0x7FFF;
519 uint16_t N = 0x8000L;
520
521 u = EASE16(u); v = EASE16(v);
522
523 int16_t X1 = LERP(
grad16(
P(AA), xx, yy),
grad16(
P(BA), xx - N, yy), u);
524 int16_t X2 = LERP(
grad16(
P(AB), xx, yy-N),
grad16(
P(BB), xx - N, yy - N), u);
525
526 int16_t ans = LERP(X1,X2,v);
527
528 return ans;
529}
#define P(x)
Reads a single byte from the p array.
static int16_t grad16(uint8_t hash, int16_t x, int16_t y, int16_t z)
References grad16(), P, x, and y.