Skip to content

Fast implementation of simplex noise 3D algorithm with octaves, amplitude, scale and distribution

License

Notifications You must be signed in to change notification settings

tmptrash/simplex-noise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simplex-noise

Fast implementation of simplex noise using ES6. Based on source of Jonas Wagner. Added octaves, amplitude, scale, and distribution. Good explanation of these parameters may be found here. Only 3D version + time is implemented. By default all configs === 1. Simplex noise may be used for generationg terrains, clouds, fog and different visualisations. It's used in game development and computer graphics. The idea behind is very simple. You just need to create an instance of Simplex class and call noise() function. It returns height (or z coordinate), which may be used to create 3D or 2D terrain. Playing with colors and parameters, which are described below you may generate different realistic worlds.

Configuration:

  • scale [0..1] - zoom coefficient. 0 - max zoom, 1 - min zoom
  • amplitude [0..1] - similar to amplitude in waves. Means a range of returning function values
  • distrib [0..X] - 0..1 - noise function will return top values, 1..X noise function will return buttom values
  • octaves [1..X] - amount of details of a 3D map. Less value, means less details.
  • random - reference to random function, which return values between 0..1. Math.random() - by default

Example

let simplex = new Simplex({distrib: 2, scale: .009, octaves: 8, amplitude: .005});
let t = 0;
/**
 * Call this function many times to obtain dynamic noise
 */
function drawNoise(width, height) {
  for (let x = 0; x < width; x++) {
    for (let y = 0; y < height; y++) {
      const z = simplex.noise(x, y, t);
      // draw x,y,z point
    }
  }
  t += .001;
}

drawNoise(128, 128);

How to run

Just put any html file into Chrome browser

Screenshots

simplex noise

About

Fast implementation of simplex noise 3D algorithm with octaves, amplitude, scale and distribution

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages