perlin-noise-1d
v1.0.0
Published
Seeded 1D Perlin noise in [-1, 1], continuous and zero at integers, with no period.
Maintainers
Readme
perlin-noise-1d
Seeded 1D Perlin noise in [-1, 1], continuous and zero at integers, with no period.
Installation
npm install perlin-noise-1dFeatures
- Gradient noise: a random slope at each integer, blended with Perlin's quintic fade (smootherstep). Zero at integers, smooth everywhere.
- Seed per call:
perlinNoise1D(x, seed). Independent channels are seeds, not instances. - No period: gradients are hashed, not looked up in a 256 permutation table.
- Continuous gradients in [-1, 1], not just ±1, which looks regular in 1D.
- Normalized to [-1, 1]: 1D gradient noise otherwise peaks at ±0.5.
Usage
import perlinNoise1D from "perlin-noise-1d";
// One independent channel per seed, e.g. a camera shake's pitch, yaw and roll.
const pitch = maxPitch * perlinNoise1D(time * frequency, seed);
const yaw = maxYaw * perlinNoise1D(time * frequency, seed + 1);
const roll = maxRoll * perlinNoise1D(time * frequency, seed + 2);API
perlinNoise1D
perlinNoise1D(x, [seed]) ⇒ number ⏏
Seeded 1D Perlin noise in [-1, 1], continuous and zero at integers.
Kind: Exported function See: Perlin, K. (2002). Improving noise. ACM TOG 21(3).
| Param | Type | Default | Description | | ------ | ------------------- | -------------- | ------------------------------ | | x | number | | | | [seed] | number | 0 | Truncated to a 32-bit integer. |
References
- Perlin, K. (1985). An image synthesizer. SIGGRAPH. doi:10.1145/325165.325247
- Gradient noise with random gradients.
- Perlin, K. (2002). Improving noise. ACM TOG 21(3). doi:10.1145/566654.566636 · paper · reference implementation
- The quintic fade 6t⁵ - 15t⁴ + 10t³, i.e. smootherstep.
- Wang, T. (1997, updated 2007). Integer hash function. web.archive.org
- The
0x27d4eb2dmultiplier ofhash32shiftmult, used to spread the seed.
- The
- Appleby, A. SMHasher: MurmurHash3. github.com
- The
fmix32finalizer hashing the lattice index.
- The
License
MIT. See license file.

