Skip to content

Modular node graph based noise generation library using SIMD, C++17 and templates

License

Notifications You must be signed in to change notification settings

Auburn/FastNoise2

Repository files navigation

GitHub Actions CI Discord MIT License

FastNoise2

Modular node based noise generation library using SIMD, focused on performance, modern C++17 and designed with ease of use in mind.

Noise node graphs can be created in code or with the help of the included visual "Node Editor" tool. Or if you just want basic coherent noise you can easily generate it from a single Simplex/Perlin node

Why Nodes?

The node-based approach keeps all noise generation and operations (add, multiply, blend, etc.) within the SIMD pipeline. This means when combining multiple noise types or applying modifiers, the intermediate values stay in SIMD registers rather than being written to memory.

The traditional approach of generating noise types separately and combining them with scalar operations doesn't make sense if you want to benefit from SIMD. With just SIMD noise generation each noise type is generated into its own array, then the arrays would need to be combined afterwards in separate passes. With FastNoise2's node graph, the entire computation is fused and executed in SIMD, maximizing throughput and minimizing both memory allocation and bandwidth.

Features

Coherent Noise

  • Perlin, Simplex, SuperSimplex (OpenSimplex2S), Value
  • Cellular Value, Cellular Distance, Cellular Lookup

Fractals

  • FBm, Ridged

Blends & Operators

  • Add, Subtract, Multiply, Divide, (Smooth)Min, (Smooth)Max, Fade, and more

Modifiers

  • Remap, Terrace, Domain Scale/Offset/Rotate, and more

Domain Warping

  • Gradient, Simplex, SuperSimplex
  • Fractal Progressive, Fractal Independent

Dimensions

  • 2D, 3D, 4D noise generation + 2D tiling support

Thread Safety

  • Fully thread-safe: generate noise in parallel across multiple threads with the same node tree

Serialization

  • Node trees can be encoded to compact strings and decoded at runtime for quick iteration
  • Create complex noise setups in the Node Editor and load them directly into your application
  • Connect your application directly to the node editor and see live node tree update in your engine

Extendable

  • Create custom nodes using the SIMD-agnostic interface provided by FastSIMD
  • Write code once and it automatically compiles for all supported SIMD architectures
  • Custom nodes work in the Node Editor, serialisation and other language bindings with minimal effort thanks to node metadata

Node Editor

The FastNoise2 Node Editor tool provides a node graph editor to create trees of FastNoise2 nodes. Node trees can be exported as serialised strings and loaded into the FastNoise2 library in your own code. Node Editor has 2D texture/heightmap and 3D mesh previews for the node graph output, generation is infinite in all dimensions. See screenshots below for examples.

Web WASM Node Editor

Check the Releases for compiled Node Editor binaries for desktop platforms

Node Editor Mountain Terrain

Node Editor Crazy Terrain

FastNoise2 vs FastNoise Lite

FastNoise Lite is a simpler, portable library best suited for basic noise needs in many languages. Choose FastNoise2 when you need:

  • Maximum performance through SIMD optimization
  • Better tools to create interesting noise generation
  • Runtime-configurable node graphs

Platform Support

Uses FastSIMD to compile code with multiple SIMD architectures and selects the fastest supported SIMD level at runtime

  • Scalar (non-SIMD)
  • SSE2
  • SSE4.1
  • AVX2
  • AVX512
  • NEON
  • WASM SIMD

Supports:

  • 32/64 bit
  • Windows
  • Linux
  • Android
  • MacOS x86/ARM
  • iOS
  • MSVC
  • Clang(CL)
  • GCC
  • Emscripten (WASM)

On Windows using ClangCL is recommended as MSVC has SIMD compiler bugs, which cause incorrect generation. ClangCL also complies much faster and has measurable runtime performance increases. Remember ClangCL binaries/libraries are fully compatible with MSVC!

Bindings:

Roadmap:

Performance

FastNoise2 has continuous benchmarking to track of performance for each node type across commits

Results can be found here: https://auburn.github.io/fastnoise2benchmarking/

Library Comparisons

Benchmarked using NoiseBenchmarking

  • CPU: Intel 7820X @ 4.9Ghz
  • OS: Win10 x64
  • Compiler: clang-cl 10.0.0 -m64 /O2

Million points of noise generated per second (higher = better)

3D Value Perlin (*Open)Simplex Cellular
FastNoise Lite 64.13 47.93 36.83* 12.49
FastNoise (Legacy) 49.34 37.75 44.74 13.27
FastNoise2 (AVX2) 494.49 261.10 268.44 52.43
libnoise 27.35 0.65
stb perlin 34.32
2D Value Perlin Simplex Cellular
FastNoise Lite 114.01 92.83 71.30 39.15
FastNoise (Legacy) 102.12 87.99 65.29 36.84
FastNoise2 (AVX2) 776.33 624.27 466.03 194.30

Getting Started

See Wiki