What it does
Noise is how a game gets values that are random but smooth: a height that rises and falls across a map, a cloud's
density, a current that swirls. The pack gives the standard set as plain functions on game.procgen, and exports every
one from the package for code that imports rather than composes. You make a permutation table from a seed with
noisePerm, keep it, and sample Perlin noise, fractal sums and curl from it at whatever frequency you scale your
coordinates by.
Fractal sums stack octaves of Perlin noise: fBm for rolling terrain and clouds, ridged noise for sharp crests such as
mountain ridges, lightning and veins, turbulence for billows. Worley noise gives the distance to the nearest of one
random point per cell, for cells, scales and cracked earth. curl2 turns a field into a divergence-free flow, so
particles or smoke that follow it swirl rather than collecting in one place. Hashes give a repeatable random value per
cell with no table at all.
When you want a picture rather than numbers, noiseData samples a whole field into a square grid of values from 0 to
1, noiseCanvas paints it, and noiseFrame puts it straight into the atlas under a key. Textures tile by default, and
can be greyscale or white with the field as alpha, with an optional radial mask that fades it to a soft puff for smoke
and steam.
Features
- Perlin noise in 2D and 3D —
perlin2andperlin3, about -1 to 1, with aperiodin whole cells that makes it tile; the third axis can be time, to animate a 2D field. - Value and Worley noise —
value2, cheaper and blockier, andworley2, the distance to the nearest cell point. - Fractal sums —
fbm2,fbm3,ridged2andturbulence2, shaped byoctaves,lacunarity,gainandperiod. - Curl flow —
curl2, a divergence-free 2D flow from fBm, for particles, smoke and water. - Hashes —
hash2,hash3andhashIntsfor a repeatable value per cell or a seed per slot. - Fields as data —
noiseDatareturns a square grid of floats for any of five kinds: fbm, ridged, turbulence, worley or value. - Textures in the atlas —
noiseFramepaints a tileable field under a key, greyscale or white with alpha, optionally masked to a radial puff. - Deterministic — every function takes its seed or table, and
noiseFrameuses the game's seed unless given one.
Good for
- Terrain heightfields in 2D or 3D: fBm for hills, ridged noise for mountain ranges.
- Smoke, steam and cloud sprites made at load time with no image files, faded to a puff by the radial mask.
- Swirling particle motion: embers, snow or foam drifting along a curl field.
- Dissolve and displacement masks that need a field which tiles.
- Cell patterns: cracked earth, scales or stone from Worley noise.
- Per-tile variation in a tile map or a block world, with a hash per cell so the same cell always gets the same answer.
Make it yours
The pack has no options; every choice is in the call. Frequency is how far you scale your coordinates, octaves,
lacunarity and gain shape the detail, period makes a field tile, and a texture's kind, size, cell,
octaves and seed pick the field and its scale.
Two different uses: a 3D terrain that samples fbm2 with five octaves at a low frequency for its rolling ground and
ridged2 for its peaks, from one table made once; and a 2D game that paints a 256-pixel smoke puff at load with
noiseFrame('smoke', { alpha: true, mask: 'radial' }) and draws its particles with that frame, then sends them along
curl2 so the smoke curls as it rises.
A quick look
A table, a few fields sampled at a point, and a texture into the atlas:
const p = game.procgen;
const perm = p.noisePerm(7); // one table per field, kept
const h = p.fbm2(x * 0.01, y * 0.01, perm, { octaves: 5 }); // about -1..1
const [vx, vy] = p.curl2(x * 0.01, y * 0.01, perm); // a divergence-free flow
const cells = p.worley2(x * 0.05, y * 0.05, 3); // 0 at a cell's point, about 1 between
const frame = p.noiseFrame('smoke', { size: 256, cell: 56, octaves: 3, alpha: true, mask: 'radial' });
Works with
particles-2d— a curl field to drift particles along, and a noise puff to draw them with.rpg-world— its generated overworld uses this pack's noise.levelgen— mazes, roguelike dungeons and caves, when you want structure rather than smooth noise.
Good to know
- It is Perlin, not simplex: fine for textures and fields, a little grid-aligned at high octaves.
- A texture tiles cleanly only when
periodis a whole number of cells. noiseDataruns on the CPU in time that grows with size squared times octaves, so a 1024-pixel, five-octave field takes a moment: make it once.- Worley noise gives the nearest cell point only, with no second-nearest distance.
- Headless,
noiseCanvasreturns null andnoiseFramemakes a blank frame.






