Expand description
§fastnoise2
fastnoise2 provides an easy-to-use and mostly safe interface for the FastNoise2 C++ library, which provides modular node graph-based noise generation using SIMD.

This crate acts as a wrapper around fastnoise2-sys, the unsafe bindings for FastNoise2.
§Examples
Here is an example of a encoded node tree, exported by FastNoise2’s Node Editor.
use fastnoise2::SafeNode;
let (x_count, y_count) = (1000, 1000);
let step_size = 3.0;
let encoded_node_tree = "E@BBZEG@BD8JFgIECArXIzwECiQIw/UoPwkuAAE@BJDQAH@BC@AIEAJBw@ABZEED0KV78YZmZmPwQDmpkZPwsAAIA/HAMAAHBCBA==";
let node = SafeNode::from_encoded_node_tree(encoded_node_tree).unwrap();
// Allocate a buffer of enough size to hold all output data.
let mut noise_out = vec![0.0; (x_count * y_count) as usize];
let min_max = node.gen_uniform_grid_2d(
&mut noise_out,
-x_count as f32 / 2.0 * step_size, // x_offset
-y_count as f32 / 2.0 * step_size, // y_offset
x_count, // x_count
y_count, // y_count
step_size, // x_step_size
step_size, // y_step_size
1337, // seed
);
// use `noise_out`!You can also manually code a node tree using FastNoise2’s metadata system, either with Node, or by combining generators, see SafeNode.
Take a look at examples to find out more.
§Setup
fastnoise2-sys, the underlying bindings for fastnoise2, uses a build script that follows a specific order of preference for compiling and/or linking the FastNoise2 library:
- Building from source, if the
build-from-sourcefeature is enabled. - If the
FASTNOISE2_LIB_DIRenvironment variable is set to/path/to/lib/, that path will be searched for staticFastNoiselibrary. - If not set, it falls back to building from source.
§Building from Source
To build FastNoise2 from source using fastnoise2-sys, ensure you have:
- CMake
- a C++17 compiler
§Notes
- If you prefer not to build from source, precompiled binaries are available for download from the FastNoise2 Releases.
- For a web-based Node Editor experience, check out the official Web WASM Node Editor.
- For desktop platforms, you can download compiled Node Editor binaries from the FastNoise2 Releases.
- The
FASTNOISE2_SOURCE_DIRenvironment variable is generally not needed as fastnoise2-sys includes the FastNoise2 source code as a Git submodule. If you need to use a different source directory, setFASTNOISE2_SOURCE_DIRto point to the root of the FastNoise2 source code.
Modules§
- generator
- FastNoise2 generators as types. Ensures safety at compile time.
Structs§
- Node
- Represents a node in the FastNoise2 C++ library.
- Output
MinMax - Holds the minimum and maximum values from noise generation.
- Safe
Node - Unlike
Node, this structure is safe to use because it is built from typed nodes that implement theGeneratortrait, or built by an encoded node tree produced by the Node Editor.
Enums§
- Fast
Noise Error - Errors that can occur when interacting with
Node. - Member
Type - Defines the type of value or reference a node can handle.