noise library

Deterministic noise, matched between CPU and GPU.

FastNoiseLite evaluates OpenSimplex2/OpenSimplex2S, Perlin, Value, and Cellular noise (with fBm, ridged, and ping-pong fractal layering, plus domain warp) in pure Dart. The engine ships a GLSL counterpart (#include <noise.glsl> inside a .fmat block) implementing the same algorithms with the same tables and seeds, so a field sampled on the CPU and evaluated in a shader agree.

The agreement contract has two tiers. noiseHash2 and noiseHash3 (and the GLSL NoiseHash2/NoiseHash3) are pure 32-bit integer math and match bit for bit on every backend, use them for decisions that must never disagree (world generation, placement). The float noise functions match within a small tolerance (float32 rounding differs per GPU), which is imperceptible visually; avoid re-deriving a hard threshold from float noise on both sides, make the decision once and share it.

Web caveat: the GLSL noise is correct on every backend, including the web (WebGL2). The Dart FastNoiseLite, however, relies on 32-bit integer arithmetic that overflows on the web, where Dart int is a JavaScript double (exact only to 53 bits), so the hash loses its low bits and 3D noise can overflow. Prefer the GLSL side, or a bakeNoiseTexture built at build time or in a native isolate, when targeting the web. A web-safe integer multiply for the Dart side is a planned follow-up.

Classes

FastNoiseLite Noise
A web-safe port of FastNoiseLite covering the OpenSimplex2, OpenSimplex2S, Perlin, Value, and Cellular noise types with None/FBm/Ridged/PingPong fractal layering, plus domain warp (domainWarp2/domainWarp3).

Enums

CellularDistanceFunction Noise
How distance to a cell point is measured by NoiseType.cellular.
CellularReturnType Noise
What value NoiseType.cellular computes for a query point.
DomainWarpFractalType Noise
How successive domain warp octaves are combined.
DomainWarpType Noise
The warp algorithm applied by FastNoiseLite.domainWarp2 and FastNoiseLite.domainWarp3.
FractalType Noise
How successive noise octaves are combined.
NoiseType Noise
The base noise algorithm used by FastNoiseLite.

Functions

bakeNoisePixels(FastNoiseLite noise, {required int width, required int height, double originX = 0.0, double originY = 0.0, double cellSize = 1.0}) Uint8List Noise
Evaluates noise over a width x height grid into grayscale RGBA8888 pixels (straight alpha 255).
bakeNoiseTexture(FastNoiseLite noise, {required int width, required int height, double originX = 0.0, double originY = 0.0, double cellSize = 1.0, TextureSampling sampling = const TextureSampling()}) Texture2D Noise
Bakes noise into a grayscale Texture2D, ready to bind as a material sampler.
noiseCurl3(double x, double y, double z, {int seed = 1337, double epsilon = 0.25}) → ({double x, double y, double z}) Noise
The curl of a seeded vector noise field at the pre-scaled position (x, y, z).
noiseHash2(int seed, int x, int y) int Noise
Bit-exact hashed value for the integer lattice cell (x, y).
noiseHash3(int seed, int x, int y, int z) int Noise
Bit-exact hashed value for the integer lattice cell (x, y, z).