Crate libnoise

Source
Expand description

A simple, performant, and customizable procedural noise generation library.

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.

§Quickstart

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. 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

Visualizer allows us to get such a visual representation of a given generator when using the image feature.

Modules§

devtools
prelude
Re-exports of useful members.

Structs§

Abs
A generator returning the absolute value of the results of the underlying generator.
Add
A generator adding offset to results of the underlying generator.
Billow
Create a generator applying an fbm()-like effect on the underlying generator.
Blend
A generator blending the underlying generator with a given other generator based on the value supplied by a control-generator.
Checkerboard
A generator which produces an n-dimensional checkerboard pattern.
Clamp
A generator clamping results of the underlying generator to a given interval.
Constant
A generator which produces the supplied value for every input point.
Custom
A generator which produces n-dimensional values based on the provided closure.
Displace
A generator producing the maximum of results of the underlying generator and results of a given other generator.
Exp
A generator applying the exponential function on results of the underlying generator.
Fbm
A generator applying fractal brownian motion on the underlying generator.
ImprovedPerlin
A generator which produces n-dimensional improved perlin noise.
Lambda
A generator applying the supplied closure to results of the underlying generator.
Max
A generator producing the maximum of results of the underlying generator and results of a given other generator.
Min
A generator producing the minimum of results of the underlying generator and results of a given other generator.
Mul
A generator multiplying scale to results of the underlying generator.
NaturalCubicSpline
Implementation of natural cubic splines used in the Spline adapter.
Neg
A generator which negates the results of the underlying generator.
NoiseBuffer
A struct for generating an n-dimensional array and efficiently filling it with noise values.
Perlin
A generator which produces n-dimensional perlin noise.
Pow
A generator raising results of the underlying generator to the power of exponent.
Power
A generator raising results of the underlying generator to the power of results of a given other generator.
Product
A generator multiplying results of the underlying generator to results of a given other generator.
RidgedMulti
Create a generator applying an fbm()-like effect on the underlying generator.
Rotate
A generator which rotates input points before passing them to the underlying generator.
Scale
A generator which scales input points before passing them to the underlying generator.
Select
Create a generator selecting the result of either the underlying generator or that of a given other generator based on whether the value supplied by a control-generator lies within the provided interval.
Simplex
A generator which produces n-dimensional simplex noise.
Source
A struct serving as entry point for building generators.
Spline
A generator returning the absolute value of the results of the underlying generator.
Sum
A generator adding results of the underlying generator to results of a given other generator.
Translate
A generator which translates input points before passing them to the underlying generator.
Value
A generator which produces n-dimensional value noise.
Visualizer
A struct for visualizing the output of a generator.
Worley
A generator which produces n-dimensional worley noise.

Traits§

Generator
A trait for building a coherent noise generation pipeline.
Generator1D
A trait representing the specialization of Generator<D> for 1-dimensional input spaces.
Generator2D
A trait representing the specialization of Generator<D> for 2-dimensional input spaces.
Generator3D
A trait representing the specialization of Generator<D> for 3-dimensional input spaces.
Generator4D
A trait representing the specialization of Generator<D> for 4-dimensional input spaces.
Seed
A trait attached to valid seed types for noise sources.
SplineImpl
A trait for implementing splines used in the Spline adapter.