Perlin Noise and turbulence

Source: Internet
Author: User
Tags scalar scale image

Perlin Noise and turbulence

Written by Paul Bourke
January 2000


Introduction

It is not uncommon in computer graphics and modelling to want to use a random function to make imagery or geometry appear more natural looking. the real world is not perfectly smooth nor does it move or change in regular ways. the random function found in the maths libraries of most programming versions aren't always suitable, the main reason is because they result in a discontinuous function. the problem then is to dream up a random/noisy function that changes "smoothly ". it turns out that there are other desirable characteristics such as it being defined everywhere (both at large scales and at very small scales) and for it to be band limited, at least in a controllable way.

The most famous practical solution to this problem came from Ken Perlin back in the 1980's. his techniques have found their way in one form or another into your rendering packages both free and other cial, it has also found its way into hardware such as the MMX chip set. at the bottom of this document I 've ve got Ded the original (almost) version of the C code as released by Ken Perlin and on which most of the examples in the document are based.

The basic idea is to create a seeded random number series and smoothly interpolate between the terms in the series, filling-in the gaps if you like. there are a number of ways of doing this and the details of the particle method used by Perlin need not be discussed here. perlin Noise can be defined in any dimension, most common dimensions are 1 to 4. the first 3 of these will be strated and discussed below.

1 dimencript

A common technique is to create 1/FN noise which is known to occur often in natural processes. an approximation to this is to add suitably scaled harmonics of this basic noise function. for the rest of this discussion the Perlin Noise functions will be referred to as noise (X) Of a VariableXWhich may a vector in 1, 2, 3 or higher dimension. This function will return a real (scalar) value. A harmonic will be noise (BX) Where "B" is some positive number greater than 1, most commonly it will be powers of 2. while the noise () functions can be used by themselves, a more common approach is to create a weighted sum of a number of harmonics of these functions. these will be refered to as noise (X) And can be defined


Where N is typically between 6 and 10. the parameter "A" controls how rough the final noise () function will be. small values of "A", eg: 1, give very rough functions, larger values give smoother functions. while this is the standard form in practice it isn't uncommon for the terms I and BI to be replaced by arbitrary values for each I.

The following shows increasing harmonics of 1 dimen=perlin noise along with the sum of the first 8 harmonics at the bottom. in this case a and B are both equal to 2. note that since in practice we only ever add a limited number of harmonics, if we zoom into this function sufficiently it will become smooth.

2 dimensional

The following show the same progression but in two dimensions. this is also a good example of why one doesn't have to sum to large values of N, after the 4th harmonic the values are less than the resolution of a gray scale image both in terms of spatial resolution and the resolution of 8 bit gray scale.



0 (1)

1 (2)

2 (4)

3 (8)

4 (16)

Sum

As earlier, A and B are both set to 2 but note that there are an infinite number of ways these harmonics cocould be added together to create different effects. for example, if in the above case one wanted more of the second harmonic then the scaling of that can be increased. while the design of a particle image/texture isn't difficult it does take some practice to become proficient.

3 dimencript

Perlin Noise can be created in 3D and higher dimensions, unfortunately it is harder to visualise the result in the same way as the earlier dimensions. one isosurface of the first two harmonics are shown below but it hardly tells the whole story since each point in space has a value assigned to it.



0 (1)

1 (2)

Perhaps the most common use of 3D Perlin Noise is generating volumetric textures, that is, textures that can be evaluated at any point in space instead of just on the surface. there are a number of reasons why this is desirable.

  • It means that the texture need not be created beforehand but can be computed on the fly.

  • There are a number of ways the texture can be animated. one way to translate the 3 dimenvelpoint passed to the noise () function, alternatively one can rotate the points. since the 3D texture is defined everywhere in 3D space, this is equivalent to translating or rotating the texture volume.

  • The exact appearance of the texture can be controlled by either varying the relative scaling of the harmonics or by adjusting how the scalar from the Perlin functions is mapped to color and/or transparency.

  • It gets around the problem of mapping rectangular texture images onto topologically different surfaces. for example, the following texture for a sun was created using 3D noise and evaluating the points using the same mapping as will be used when the texture is mapped onto a sphere. the result is that the texture will map without pinching at the poles and there will not be any seams on the left and right.


Source code

The original C code by Ken Perlin is given here: Perlin. h and Perlin. C.

Applications

The above describes a way of creating a noisy but continuous function. in normal operation one passes a vector in some dimension and the function returns a scalar. how this scalar is used is the creative part of the process. often it is can be used directly, for example, to move the limbs of virtual character so they aren't rigid looking. or it might be used directly as the transparency function for clouds. another fairly common application is to use the 1D noise to perturb lines so they look more natural, or to use the 2D noise as the height for terrain models. 2D and 3D Perlin Noise are often used to create clouds, a hint of this can be seen in the sum of the 2D noise () functions abve.

When the aim is to create a texture the scalar is used as an index into a color map, this may either be a continuous function or a lookup table. creating the color map to achieve the result being sought is a matter of skill and experience. another approach is to use noise () functions as arguments to other mathematical funical, for example, marble effects are often made using cos (x + noise (x, y, z )) and mapping that to the desired marble colours.

In order to adjust tively map the values returned from the noise functions one needs to know the range of values and the distribution of values returned. the original functions and therefore the ones presented here both have Gaussian like distributions centered on the origin. noise () returns values between about-0.7 and 0.7 while noise () returns values potentially between-1 and 1. the two distributions are shown below.

The possibilities are endless, enjoy experimenting.

References

Ken Perlin
An image Synthesizer
Computer Graphics, 1985, 19 (3), pp 287-296.

Donald Hearn and M. Pauline Baker
Fractal-geometry Methods
Computer Graphics, C-version, 1997, pp 362-378.

Perlin, K
Live paint: painting with procedural multiscale textures
Computer Graphics, volume 28, number 3.

David Ebert, et al (chapter by Ken Perlin)
Texturing and modeling, a procedural approach
AP professional, Cambridge, 1994.

Perlin, K., Hoffert, E.
Hypertexture
Computer Graphics (Proceedings of ACM Siggraph Conference), 1989, vol. 22, No. 3.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.