Skip to content
Jordan Peck edited this page May 28, 2016 · 12 revisions

Usage

Copy FastNoise.h and FastNoise.cpp into your project

#include "FastNoise.h"

Getting Started

Using FastNoise to create a 2D heightmap

FastNoise myNoise; // Create a FastNoise object
myNoise.SetNoiseType(FastNoise::SimplexFractal); // Set the desired noise type

float heightMap[32][32]; // 2D heightmap to create terrain

for (int x = 0; x < 32; x++)
{
    for (int y = 0; y < 32; y++)
    {
        heightMap[x][y] = myNoise.GetNoise(x,y);
    }
}

Notes

  • All outputs are approximately bounded from -1.0 to 1.0, except for distance functions on cellular noise
  • All noise settings are initialised to sensible values so all noise types will function correctly without any setup

Noise Generation

float GetNoise(float x, float y{, float z})

Returns the noise type as set by SetNoiseType()


float GetValue(float x, float y{, float z})

float GetValueFractal(float x, float y{, float z})

float GetGradient(float x, float y{, float z})

float GetGradientFractal(float x, float y{, float z})

float GetSimplex(float x, float y{, float z}{, float w})

float GetSimplexFractal(float x, float y{, float z})

float GetCellular(float x, float y{, float z})

float GetCellularHQ(float x, float y{, float z})

float GetWhiteNoise(float x, float y{, float z}{, float w})

float GetWhiteNoiseInt(int x, int y{, int z}{, int w})

Clone this wiki locally