Simple and customizable procedural noise generation library written in Rust.

Overview

libnoise

format lint test codecov docs.rs Crates.io

A simple, performant, and customizable procedural noise generation library inspired by libnoise for C++ featuring:

  • Easy coherent noise generation through sources provided via Source
  • Modular generator creation by chaining adapters to modify and combine generator inputs and outputs, and the ability to flexibly create custom generators and adapters, all through the Generator trait
  • Efficient and cache friendly sampling of generators through NoiseBuffer and much of the generator complexity resolving at compile time
  • Easy visualization of generator outputs for debugging through Visualizer

Libnoise provides utilities to generate coherent noise and customize them by applying a variety of operations which modify and combine generators. With a focus on customizability, the library allows users to create custom generators and modifiers.

Most immediately relevant documentation can be found in Source and Generator docs.

Usage

To get started easily, create a source generator using one of the many sources found in Source, and apply adapters documented in Generator.

use libnoise::prelude::*;

// build a simplex noise generator seeded with 42
let generator = Source::simplex(42);

// sample the generator for input point [0.2, 0.5]
let value = generator.sample([0.2, 0.5]);

Note how the dimensionality, which is internally represented as a constant generic argument, is automatically inferred by sampling the generator with a 2-dimensional input point.

Naturally, we can create more interesting complex generators:

use libnoise::prelude::*;

// build a generator
let generator = Source::simplex(42)                 // start with simplex noise
    .fbm(5, 0.013, 2.0, 0.5)                        // apply fractal brownian motion
    .blend(                                         // apply blending...
        Source::worley(43).scale([0.05, 0.05]),     // ...with scaled worley noise
        Source::worley(44).scale([0.02, 0.02]))     // ...controlled by other worley noise
    .lambda(|f| (f * 2.0).sin() * 0.3 + f * 0.7 );  // apply a closure to the noise

// sample the generator for input point [0.2, 0.5]
let value = generator.sample([0.2, 0.5]);

We can also use NoiseBuffer for efficiently filling n-dimensional arrays with noise, and Visualizer to get a visual representation of a given generator. The above generator produces the following image, when sampled for every pixel position:

image

It is common to interpret the 3rd or 4th dimension as time, allowing us to produce space-time noise such as:

image

Contributing

Contributors and feature suggestions are welcome!

License

Libnoise is distributed under the terms of the MIT license.

See LICENSE-MIT for details.

You might also like...
Simple autoclicker written in Rust, to learn the Rust language.

RClicker is an autoclicker written in Rust, written to learn more about the Rust programming language. RClicker was was written by me to learn more ab

Rust 核心库和标准库的源码级中文翻译,可作为 IDE 工具的智能提示 (Rust core library and standard library translation. can be used as IntelliSense for IDE tools)

Rust 标准库中文版 这是翻译 Rust 库 的地方, 相关源代码来自于 https://github.com/rust-lang/rust。 如果您不会说英语,那么拥有使用中文的文档至关重要,即使您会说英语,使用母语也仍然能让您感到愉快。Rust 标准库是高质量的,不管是新手还是老手,都可以从中

A simple /proc/pid/{mem,maps} library for Rust

Summary A very simple library that wraps around /proc/pid/mem and /proc/pid/maps to read memory out of a running process on Linux. Usage Basic usage l

A simple endian-handling library for Rust

endi Yet another endian handling library for Rust. The approach is very similar to that of byteordered crate with its Endianness enum, except that end

A simple local storage media library manager.
A simple local storage media library manager.

OFFFLIX A simple application to auto manage series on your local storage. Features Resume watching Play next episode Auto increment season Play random

Library for abstract mathematics written by Rust. It is aiming to replace SageMath.

ankolib Roadmap Mathematical Structures Sets Monoids Groups Semirings Rings Algebras Basic Rings and Fields Integers and Rational Numbers Integer Rati

RTL-SDR library written in Rust

RTL-SDR An RTL-SDR library written in Rust! What is RTL-SDR? RTL-SDR is a family of low-cost (~$30) USB software-defined radio (SDR) receivers that ca

An open source WCH-Link library/command line tool written in Rust.

wlink - WCH-Link command line tool NOTE: This tool is still in development and not ready for production use. Known Issue: Only support binary firmware

Hypercraft - a VMM library written in Rust

hypercraft is a VMM library written in Rust. If you are interested in Design & Implement about this project, please see this disc

Comments
  • Simplification of `src/core/adapters/rotate.rs` -> `Generator<3> for Rotate<3, 3, G>` and `Generator<4> for Rotate<4, 6, G>`

    Simplification of `src/core/adapters/rotate.rs` -> `Generator<3> for Rotate<3, 3, G>` and `Generator<4> for Rotate<4, 6, G>`

    Mathematical expressions have been simplified, namely: the number of number multiplication operations has been reduced.

    The speed of 4D rendering has increased by only ≈2.5%

    opened by MayorDi 1
  • compile faster

    compile faster

    crate:image pulls in absurdly many image formats by default. cargo build now takes 11 packages and 4.5s; before it took 82 packages and 1m16s. cargo test is still pretty heavy.

    Using crate:rand::StdRng could break reproducibility as they are allowed to change the algorithm. Chacha12 is what they are using now.

    opened by purpleposeidon 0
  • Replacing `multi_cartesian_product` to`iproduct!`

    Replacing `multi_cartesian_product` to`iproduct!`

    During the test of this code:

    fn example_billow_simplex_noise3d() {
        let generator = Source::simplex(0).billow(3, 0.013, 2.0, 0.5);
        Visualizer::<3>::new([15, 15, 15], &generator).write_to_file("billow_simplex_3d.png");
    }
    
    fn example_billow_simplex_noise4d() {
        let generator = Source::simplex(0).billow(3, 0.013, 2.0, 0.5);
        Visualizer::<4>::new([15, 15, 15, 15], &generator).write_to_file("billow_simplex_4d.gif");
    }
    

    iproduct!() showed execution speed ≈16.1%_ faster for example_billow_simplex_noise3d and ≈7.3% faster for example_billow_simplex_noise4d compared to multi_cartesian_product().

    Therefore, multi_cartesian_product() was replaced with iproduct!().

    opened by MayorDi 0
  • major CI improvements (optional secrets, caching)

    major CI improvements (optional secrets, caching)

    Previously, running the testing CI in a fork failed due to the coveralls secret token not being available for tarpaulin coverage testing. Now, the coverage testing runs conditionally with or without the token.

    Furthermore, the CI has been accelerated significantly due to usage of caching actions.

    opened by cookiephone 0
Owner
SpoogieOogie
Just a cookie...
SpoogieOogie
Learn to write Rust procedural macros [Rust Latam conference, Montevideo Uruguay, March 2019]

Rust Latam: procedural macros workshop This repo contains a selection of projects designed to learn to write Rust procedural macros — Rust code that g

David Tolnay 2.5k Dec 29, 2022
A procedural macro for configuring constant values across crates

toml-cfg Rough ideas: Crates can declare variables that can be overridden Anything const, e.g. usize, strings, etc. (Only) The "root crate" can overri

James Munns 43 Dec 24, 2022
Procedural macro to derive Serde serializer-deserializer for Prost

prost-serde-derive prost-serde-derive is a procedural macro to generate Serde serializers and deserializers for Prost-generated structs. Rationale Cur

Park Joon-Kyu 4 Dec 15, 2022
A procedural macro to generate a new function implementation for your struct.

Impl New ?? A procedural macro to generate a new function implementation for your struct. ?? Add to your project Add this to your Cargo.toml: [depende

Mohammed Alotaibi 4 Sep 8, 2023
Repository to learn fractal generation algorithms.

Fractalrs Created this project so I can study Rust while programming fractals! I have always wanted to learn fractal generation. Fractals Fractals are

Luke Dias 4 Jun 10, 2023
A relatively simple puzzle generator application written in Rust and used via Javascript

Puzzlip Basic Overview This is a relatively simple puzzle generator application written in Rust and used via Javascript in https://puzzlip.com. If you

Nenad 5 Dec 7, 2022
🚀simple server that returns error codes with their respective messages and debug information, written in rust 🦀

ErrorServer ?? A simple & lightweight server that returns a HTML page of the error code with its respective message and debug information, written in

Jakob 2 Dec 15, 2022
A simple thread schedule and priority library for rust

thread-priority A simple library to control thread schedule policies and thread priority. If your operating system isn't yet supported, please, create

Victor Polevoy 62 Dec 5, 2022
A typesafe, flexible, simple, and user-friendly unit system library for Rust that has good error messages.

uy A typesafe, flexible, simple, and user-friendly unit system library for Rust that has good error messages. Usage uy not only stores the unit of a v

Lachlan Sneff 19 Aug 8, 2023
A simple library to get all pairs from any Dex and sync reserves.

pair_sync A simple library to get all pairs from any supported Dex and sync reserves. Crates.io Documentation in progress Filename: examples/sync-pair

null 116 Dec 30, 2022