HOME

TheInfoList



OR:

Perlin noise is a type of
gradient noise Gradient noise is a type of noise commonly used as a procedural texture primitive in computer graphics. It is conceptually different, and often confused with value noise. This method consists of a creation of a lattice of random (or typically pseu ...
developed by
Ken Perlin Kenneth H. Perlin is a professor in the Department of Computer Science at New York University, founding director of the Media Research Lab at NYU, director of the Future Reality Lab at NYU, and the Director of the Games for Learning Institute. He ...
.


History

Ken Perlin Kenneth H. Perlin is a professor in the Department of Computer Science at New York University, founding director of the Media Research Lab at NYU, director of the Future Reality Lab at NYU, and the Director of the Games for Learning Institute. He ...
developed Perlin noise in 1983 as a result of his frustration with the "machine-like" look of
computer-generated imagery Computer-generated imagery (CGI) is the use of computer graphics to create or contribute to images in art, printed media, video games, simulators, and visual effects in films, television programs, shorts, commercials, and videos. The images may ...
(CGI) at the time. He formally described his findings in a
SIGGRAPH SIGGRAPH (Special Interest Group on Computer Graphics and Interactive Techniques) is an annual conference on computer graphics (CG) organized by the ACM SIGGRAPH, starting in 1974. The main conference is held in North America; SIGGRAPH Asia ...
paper in 1985 called ''An Image Synthesizer''. He developed it after working on
Disney The Walt Disney Company, commonly known as Disney (), is an American multinational mass media and entertainment conglomerate headquartered at the Walt Disney Studios complex in Burbank, California. Disney was originally founded on October ...
's
computer animated Computer animation is the process used for digitally generating animations. The more general term computer-generated imagery (CGI) encompasses both static scenes (still images) and dynamic images (moving images), while computer animation refer ...
sci-fi Science fiction (sometimes shortened to Sci-Fi or SF) is a genre of speculative fiction which typically deals with imaginative and futuristic concepts such as advanced science and technology, space exploration, time travel, parallel universe ...
motion picture ''
Tron ''Tron'' (stylized as ''TRON'') is a 1982 American science fiction action-adventure film written and directed by Steven Lisberger from a story by Lisberger and Bonnie MacBird. The film stars Jeff Bridges as Kevin Flynn, a computer programmer a ...
'' (1982) for the animation company Mathematical Applications Group (MAGI). In 1997, Perlin was awarded an
Academy Award for Technical Achievement The Technical Achievement Award is one of three Scientific and Technical Awards given from time to time by the Academy of Motion Picture Arts and Sciences. (The other two awards are the Scientific and Engineering Award and the Academy Award of Me ...
for creating the algorithm, the citation for which read:Original source code
/ref> Perlin did not apply for any patents on the algorithm, but in 2001 he was granted a patent for the use of 3D+ implementations of
simplex noise Simplex noise is the result of an ''n''-dimensional noise function comparable to Perlin noise ("classic" noise) but with fewer directional artifacts and, in higher dimensions, a lower computational overhead. Ken Perlin designed the algorithm in ...
for
texture synthesis Texture synthesis is the process of algorithmically constructing a large digital image from a small digital sample image by taking advantage of its structural content. It is an object of research in computer graphics and is used in many fields, amo ...
. Simplex noise has the same purpose, but uses a simpler space-filling grid. Simplex noise alleviates some of the problems with Perlin's "classic noise", among them computational complexity and visually-significant directional artifacts.


Uses

Perlin noise is a
procedural texture In computer graphics, a procedural texture is a texture created using a mathematical description (i.e. an algorithm) rather than directly stored data. The advantage of this approach is low storage cost, unlimited texture resolution and easy textur ...
primitive, a type of
gradient noise Gradient noise is a type of noise commonly used as a procedural texture primitive in computer graphics. It is conceptually different, and often confused with value noise. This method consists of a creation of a lattice of random (or typically pseu ...
used by visual effects artists to increase the appearance of realism in
computer graphics Computer graphics deals with generating images with the aid of computers. Today, computer graphics is a core technology in digital photography, film, video games, cell phone and computer displays, and many specialized applications. A great de ...
. The function has a
pseudo-random A pseudorandom sequence of numbers is one that appears to be statistically random, despite having been produced by a completely deterministic and repeatable process. Background The generation of random numbers has many uses, such as for random ...
appearance, yet all of its visual details are the same size. This property allows it to be readily controllable; multiple scaled copies of Perlin noise can be inserted into mathematical expressions to create a great variety of procedural textures. Synthetic textures using Perlin noise are often used in CGI to make computer-generated visual elementssuch as object surfaces, fire, smoke, or cloudsappear more natural, by imitating the controlled random appearance of textures in nature. It is also frequently used to generate textures when memory is extremely limited, such as in
demos Demos may refer to: Computing * DEMOS, a Soviet Unix-like operating system * DEMOS (ISP), the first internet service provider in the USSR * Demos Commander, an Orthodox File Manager for Unix-like systems * plural for Demo (computer programming) ...
. Its successors, such as
fractal noise Pink noise or noise is a signal or process with a frequency spectrum such that the power spectral density (power per frequency interval) is inversely proportional to the frequency of the signal. In pink noise, each octave interval (halving or ...
and
simplex noise Simplex noise is the result of an ''n''-dimensional noise function comparable to Perlin noise ("classic" noise) but with fewer directional artifacts and, in higher dimensions, a lower computational overhead. Ken Perlin designed the algorithm in ...
, have become nearly ubiquitous in
graphics processing unit A graphics processing unit (GPU) is a specialized electronic circuit designed to manipulate and alter memory to accelerate the creation of images in a frame buffer intended for output to a display device. GPUs are used in embedded systems, mobi ...
s both for real-time graphics and for non-real-time procedural textures in all kinds of computer graphics. It is frequently used in video games to make
procedurally generated terrain A scenery generator is software used to create landscape images, 3D models, and animations. These programs often use procedural generation to generate the landscapes. If not using procedural generation to create the landscapes, then normally ...
that looks natural.


Algorithm detail

Perlin noise is most commonly implemented as a two-, three- or four-dimensional
function Function or functionality may refer to: Computing * Function key, a type of key on computer keyboards * Function model, a structured representation of processes in a system * Function object or functor or functionoid, a concept of object-oriente ...
, but can be defined for any number of dimensions. An implementation typically involves three steps: defining a grid of random gradient vectors, computing the
dot product In mathematics, the dot product or scalar productThe term ''scalar product'' means literally "product with a scalar as a result". It is also used sometimes for other symmetric bilinear forms, for example in a pseudo-Euclidean space. is an algebra ...
between the gradient vectors and their offsets, and interpolation between these values.


Grid definition

Define an ''n''-dimensional grid where each grid intersection has associated with it a fixed random ''n''-dimensional unit-length gradient vector, except in the one dimensional case where the gradients are random scalars between -1 and 1.


Dot product

For working out the value of any candidate point, first find the unique grid cell in which the point lies. Then, identify the 2^n corners of that cell and their associated gradient vectors. Next, for each corner, calculate an offset vector. An offset vector is a displacement vector from that corner to the candidate point. For each corner, we take the
dot product In mathematics, the dot product or scalar productThe term ''scalar product'' means literally "product with a scalar as a result". It is also used sometimes for other symmetric bilinear forms, for example in a pseudo-Euclidean space. is an algebra ...
between its gradient vector and the offset vector to the candidate point. This dot product will be zero if the candidate point is exactly at the grid corner. Note that a gradient vector's influence grows with distance, which can be avoided by normalizing the offset vector to a length of 1 first. This would introduce noticeable sharp changes, except the distance is taken into account in the following interpolation step. Normalizing the offset vector is however not a common practice. For a point in a two-dimensional grid, this will require the computation of 4 offset vectors and dot products, while in three dimensions it will require 8 offset vectors and 8 dot products. In general, the algorithm has O(2^n)
complexity Complexity characterises the behaviour of a system or model whose components interaction, interact in multiple ways and follow local rules, leading to nonlinearity, randomness, collective dynamics, hierarchy, and emergence. The term is generall ...
, where n is the number of dimensions.


Interpolation

The final step is interpolation between the 2^n dot products. Interpolation is performed using a function that has zero first
derivative In mathematics, the derivative of a function of a real variable measures the sensitivity to change of the function value (output value) with respect to a change in its argument (input value). Derivatives are a fundamental tool of calculus. F ...
(and possibly also second derivative) at the 2^n grid nodes. Therefore, at points close to the grid nodes, the output will approximate the dot product of the gradient vector of the node and the offset vector to the node. This means that the noise function will pass through zero at every node, giving Perlin noise its characteristic look. If n=1, an example of a function that interpolates between value a_0 at grid node 0 and value a_1 at grid node 1 is :f(x) = a_0 + \operatorname(x)\cdot(a_1-a_0) \ \ \text0\leq x\leq 1 where the
smoothstep Smoothstep is a family of sigmoid-like interpolation and clamping functions commonly used in computer graphics, video game engines, and machine learning. The function depends on three parameters, the input ''x'', the "left edge" and the "right e ...
function was used. Noise functions for use in computer graphics typically produce values in the range 1.0,1.0and can be scaled accordingly.


Implementation

The following is a two-dimensional implementation of Classical Perlin Noise, written in C. The original reference implementation by Perlin had major differences: * it is using a three-dimensional approach by interpolating between 8 corners of a cube instead of the 4 corners of a square below. * the random gradient direction shuffles bits of the integer coordinates of corners, which is much faster than shuffling using the interference at high frequency of rotations of the integer coordinates of corners, merged and rotated again at high frequency by a product: the rotations are not uniformly distributed. * Perlin's method split the integer space into 256x256x256 cubes and then uses a random permutation of these cubes to shuffle them, and then each cube position corners is assigned one of twelve directions to the neighboring non-permuted cubes in a 4x4x4 paving space: this requires only integer operations but maintains a uniform distribution of directions. * the interpolation function is the smoother 4-degree Smootherstep (with the first three derivatives equal to zero on the clamping boundaries) and not the basic linear step. This avoids visible artefacts, notably along vertices or diagonals joining the sampling corners, where the result would visibly be anisotropic (tainting the desired
white noise In signal processing, white noise is a random signal having equal intensity at different frequencies, giving it a constant power spectral density. The term is used, with this or similar meanings, in many scientific and technical disciplines, ...
into
pink noise Pink noise or noise is a signal or process with a frequency spectrum such that the power spectral density (power per frequency interval) is inversely proportional to the frequency of the signal. In pink noise, each octave interval (halving ...
; if the noise was used to generate a solid crystal, it would not be entirely black and opaque to the light, but partly transparent and colored in some discrete directions of observation). #include /* Function to linearly interpolate between a0 and a1 * Weight w should be in the range .0, 1.0 */ float interpolate(float a0, float a1, float w) typedef struct vector2; /* Create pseudorandom direction vector */ vector2 randomGradient(int ix, int iy) // Computes the dot product of the distance and gradient vectors. float dotGridGradient(int ix, int iy, float x, float y) // Compute Perlin noise at coordinates x, y float perlin(float x, float y)


Permutation

Many implementations of Perlin noise use the same permutation set that Ken Perlin used in his original implementation. That implementation is as follows: int permutation[] = ; This specific permutation is not absolutely required, though it does require a randomized array of the values [0–255] (inclusive). If creating a new permutation table, care should be taken to ensure uniform distribution of the values.


Complexity

For each evaluation of the noise function, the dot product of the position and gradient vectors must be evaluated at each node of the containing grid cell. Perlin noise therefore scales with complexity O(2^n) for n dimensions. Alternatives to Perlin noise producing similar results with improved complexity scaling include
simplex noise Simplex noise is the result of an ''n''-dimensional noise function comparable to Perlin noise ("classic" noise) but with fewer directional artifacts and, in higher dimensions, a lower computational overhead. Ken Perlin designed the algorithm in ...
and
OpenSimplex noise OpenSimplex noise is an n-dimensional (up to 4D) gradient noise function that was developed in order to overcome the patent-related issues surrounding simplex noise, while likewise avoiding the visually-significant directional artifacts characte ...
.


See also

* Value noise *
Simulation noise Simulation noise is a function that creates a divergence-free vector field. This signal can be used in artistic simulations for the purposes of increasing the perception of extra detail. The function can be calculated in three dimensions by divi ...
*
Simplex noise Simplex noise is the result of an ''n''-dimensional noise function comparable to Perlin noise ("classic" noise) but with fewer directional artifacts and, in higher dimensions, a lower computational overhead. Ken Perlin designed the algorithm in ...


References


External links


Matt Zucker's Perlin noise math FAQ

Rob Farber's tutorial demonstrating Perlin noise generation and visualization on CUDA-enabled graphics processors

Jason Bevins's extensive C++ library for generating complex, coherent noise values

PHP Implementation
(GitHub)
Perlin Noise Explained in Depth (with C++ source code)

The Book of Shaders by Patricio Gonzalez Vivo & Jen LowePerlin noise online generator
{{Noise Noise (graphics) Special effects Fractals Computer graphics Articles with example C code