MyNixOS website logo
Description

Performant, modern noise generation for Haskell with minimal dependencies. Based on FastNoiseLite.

Please see the README on GitHub at https://github.com/jtnuttall/pure-noise#readme

pure-noise

Performant, modern noise generation for Haskell with a minimal dependency footprint.

The algorithms used in this library are ported from FastNoiseLite. The library structure has been retuned to fit better with Haskell semantics.

The public interface for this library is unlikely to change much, although the implementations (noiseBaseN functions and anything in Numeric.Noise.Internal) are subject to change and may change between minor versions.

Usage

The library exports newtypes for N-dimensional noise. Currently, these are just functions that accept a seed and a point in N-dimensional space. They can be arbitrarily unwrapped by with the noiseNAt family of functions. Since they abstract over the given seed and parameters, they can be composed with Num or Fractional methods at will with little-to-no performance cost.

Noise values are generally clamped to [-1, 1], although some noise functions may occasionally produce values slightly outside this range.

import Numeric.Noise qualified as Noise

myNoise2 :: (RealFrac a) => Seed -> a -> a -> a
myNoise2 =
  let fractalConfig = Noise.defaultFractalConfig
  in Noise.noise2At $
      Noise.fractal2 fractalConfig ((perlin2 + superSimplex2) / 2)

More examples can be found in bench and demo.

Performance notes

  • This library benefits considerably from compilation with the LLVM backend (-fllvm). Benchmarks suggest a ~50-80% difference depending on the kind of noise.

Benchmarks

Results

Measured by values / second generated by the noise functions. These results come from a benchmark with -fllvm enabled.

All results are for Floats.

There's inevitably some noise in the measurements because all of the results are forced into an unboxed vector.

2D

namevalues / second
value2157_347_680
perlin2129_541_747
openSimplex264_758_006
superSimplex264_072_639
valueCubic252_110_819
cellular215_743_434

3D

namevalues / second
value385_438_023
perlin356_830_482
valueCubic315_559_523

Examples

There's an interactive demo app in the demo directory.

OpenSimplex2

Perlin

Cellular.

Metadata

Version

0.1.0.1

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows