Skip to content

Overdrivr/ZNoise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZNoise

ZNoise is a fast and easy-to-use open-source C++ noise library.

This library is a very useful framework for people who want to generate procedural images, heightmaps and textures.

Author : Rémi Bèges (twitter)

Noise algorithms

Noise algorithms are density functions. For any given point in space, they will return a density value. This value is not random, noise algorithms are always deterministic. In other words, calling the function multiple times for the same point will always return the same value. However, computing the noise for different coordinates will yield different densities.

Noises

Usage

Perlin perlin;

for(int x = 0 ; x < image.width() ; x++)
    for(int y = 0 ; y < image.height() ; y++)
    {
        // returned noise value is between -1 and 1
        // Set noise scale with the last parameter
        float value = perlin.Get({x , y},0.01f);

        // Do whatever you want with it
        // ex : generate a pixel intensity, use in a colormap ...
        // ...
    }

List of supported algorithms

The following table details the implemented noises to date :

Noise 2-D 3-D (2D slice) 4-D (2D slice)
Perlin Perlin2D Perlin3D Perlin4D
Simplex Simplex2D Simplex3D Simplex4D
Worley F1 Worley2DF1 _ _
Worley F2 _ _ _
Worley F3 _ _ _
Worley F4 _ _ _
Square _ _ _

Mixers

Usage

// Use Perlin as mixer source
Perlin perlin;
// Mixer
FBM fbm(perlin);

for(int x = 0 ; x < image.width() ; x++)
    for(int y = 0 ; y < image.height() ; y++)
    {
        float value =  fbm.Get({x , y},0.01f);
        // ...
    }

List of supported mixers

Multiple noise layers can be assembled automatically using Mixers. Three parameters are available to tune the noise output :

  • Lacunarity
  • Octave amount
  • Hurst coefficient

The amount of octaves is simply the total number of noise layers blended together. Lacunarity controls the scale ratio between two successive layers. Hurst coefficient controls relates to the weight of each layer in the final blended image.

Fractal Brownian Motion (FBM) - 5 octaves

FBM lacunarity = 2.5f lacunarity = 3.5f lacunarity = 4.5f
hurst = 0.2f FBM2D FBM2D FBM2D
hurst = 0.5f FBM2D FBM2D FBM2D
hurst = 0.8f FBM2D FBM2D FBM2D

Hybrid Multi Fractal - 5 octaves

HMF lacunarity = 2.5f lacunarity = 3.5f lacunarity = 4.5f
hurst = 0.2f HMF2D HMF2D HMF2D
hurst = 0.5f HMF2D HMF2D HMF2D
hurst = 0.8f HMF2D HMF2D HMF2D

Build the library

Znoise uses the Gradle build system. As a user, you don't need to install gradle. All you need is a gcc C++11 compiler (MinGW or TDM-GCC for instance).

On Windows, you also need to add the /bin subfolder (where you can find gcc.exe) to the PATH.

Then, run the following command in the root /Znoise folder:

gradlew build

Build the examples

gradlew installDebugMainExecutable

Run the examples

\build\install\mainExecutable\debug\main.bat

This will generate all the images in this readme. Images will be found in \build\install\examplesExecutable\debug\

Related implementation

ZNoise has at some point been developed for the https://github.com/DigitalPulseSoftware/NazaraEngine C++11 game engine.