Module Noise
[frames] | no frames]

Module Noise

The Blender.Noise submodule.

Noise and Turbulence

This module can be used to generate noise of various types. This can be used for terrain generation, to create textures, make animations more 'animated', object deformation, etc. As an example, this code segment when scriptlinked to a framechanged event, will make the camera sway randomly about, by changing parameters this can look like anything from an earthquake to a very nervous or maybe even drunk cameraman... (the camera needs an ipo with at least one Loc & Rot key for this to work!):

Example:

 from Blender import Get, Scene, Noise
 ####################################################
 # This controls jitter speed
 sl = 0.025
 # This controls the amount of position jitter
 sp = 0.1
 # This controls the amount of rotation jitter
 sr = 0.25
 ####################################################

 time = Get('curtime')
 ob = Scene.GetCurrent().getCurrentCamera()
 ps = (sl*time, sl*time, sl*time)
 # To add jitter only when the camera moves, use this next line instead
 #ps = (sl*ob.LocX, sl*ob.LocY, sl*ob.LocZ)
 rv = Noise.vTurbulence(ps, 3, 0, Noise.NoiseTypes.NEWPERLIN)
 ob.dloc = (sp*rv[0], sp*rv[1], sp*rv[2])
 ob.drot = (sr*rv[0], sr*rv[1], sr*rv[2])
Functions
float
random()
Returns a random floating point number."
3-float list
randuvec()
Returns a random unit vector.
 
setRandomSeed(seed)
Initializes the random number generator.
float
noise(xyz, type=1)
Returns general noise of the optional specified type.
3-float list
vNoise(xyz, type=1)
Returns noise vector of the optional specified type.
float
turbulence(xyz, octaves, hard, basis=1, ampscale=0.5, freqscale=2.0)
Returns general turbulence value using the optional specified noise 'basis' function.
3-float list
vTurbulence(xyz, octaves, hard, basis=1, ampscale=0.5, freqscale=2.0)
Returns general turbulence vector using the optional specified noise basis function.
float
fBm(xyz, H, lacunarity, octaves, basis=1)
Returns Fractal Brownian Motion noise value (fBm).
float
multiFractal(xyz, H, lacunarity, octaves, basis=1)
Returns Multifractal noise value.
float
vlNoise(xyz, distortion, type1=1, type2=1)
Returns Variable Lacunarity Noise value, a distorted variety of noise.
float
heteroTerrain(xyz, H, lacunarity, octaves, offset, basis=1)
Returns Heterogeneous Terrain value.
float
hybridMFractal(xyz, H, lacunarity, octaves, offset, gain, basis=1)
Returns Hybrid Multifractal value.
float
ridgedMFractal(xyz, H, lacunarity, octaves, offset, gain, basis=1)
Returns Ridged Multifractal value.
list
voronoi(xyz, distance_metric=0, exponent=2.5)
Returns Voronoi diagrams-related data.
float
cellNoise(xyz)
Returns cellnoise.
3-float list
cellNoiseV(xyz)
Returns cellnoise vector/point/color.
Variables
readonly dictionary NoiseTypes = {'BLENDER': 0, 'STDPERLIN': 1}
The available noise types.
readonly dictionary DistanceMetrics = {'DISTANCE': 0}
The available distance metrics values for Voronoi.
  __package__ = None
Function Details

random()

 

Returns a random floating point number."

Returns: float
a random number in [0, 1).

randuvec()

 

Returns a random unit vector.

Returns: 3-float list
a list of three floats.

setRandomSeed(seed)

 

Initializes the random number generator.

Parameters:
  • seed (int) - the seed for the random number generator. If seed = 0, the current time will be used as seed, instead.

noise(xyz, type=1)

 

Returns general noise of the optional specified type.

Parameters:
  • xyz (tuple of 3 floats) - (x,y,z) float values.
  • type (int) - the type of noise to return. See NoiseTypes.
Returns: float
the generated noise value.

vNoise(xyz, type=1)

 

Returns noise vector of the optional specified type.

Parameters:
  • xyz (tuple of 3 floats) - (x,y,z) float values.
  • type (int) - the type of noise to return. See NoiseTypes.
Returns: 3-float list
the generated noise vector.

turbulence(xyz, octaves, hard, basis=1, ampscale=0.5, freqscale=2.0)

 

Returns general turbulence value using the optional specified noise 'basis' function.

Parameters:
  • xyz (3-float tuple) - (x,y,z) float values.
  • octaves (int) - number of noise values added.
  • hard (bool) - noise hardness: 0 - soft noise; 1 - hard noise. (Returned value is always positive.)
  • basis (int) - type of noise used for turbulence, see NoiseTypes.
  • ampscale (float) - amplitude scale value of the noise frequencies added.
  • freqscale (float) - frequency scale factor.
Returns: float
the generated turbulence value.

vTurbulence(xyz, octaves, hard, basis=1, ampscale=0.5, freqscale=2.0)

 

Returns general turbulence vector using the optional specified noise basis function.

Parameters:
  • xyz (3-float tuple) - (x,y,z) float values.
  • octaves (int) - number of noise values added.
  • hard (bool) - noise hardness: 0 - soft noise; 1 - hard noise. (Returned vector is always positive.)
  • basis (int) - type of noise used for turbulence, see NoiseTypes.
  • ampscale (float) - amplitude scale value of the noise frequencies added.
  • freqscale (float) - frequency scale factor.
Returns: 3-float list
the generated turbulence vector.

fBm(xyz, H, lacunarity, octaves, basis=1)

 

Returns Fractal Brownian Motion noise value (fBm).

Parameters:
  • xyz (3-float tuple) - (x,y,z) float values.
  • H (float) - the fractal increment parameter.
  • lacunarity (float) - the gap between successive frequencies.
  • octaves (float) - the number of frequencies in the fBm.
  • basis (int) - type of noise used for the turbulence, see NoiseTypes.
Returns: float
the generated noise value.

multiFractal(xyz, H, lacunarity, octaves, basis=1)

 

Returns Multifractal noise value.

Parameters:
  • xyz (3-float tuple) - (x,y,z) float values.
  • H (float) - the highest fractal dimension.
  • lacunarity (float) - the gap between successive frequencies.
  • octaves (float) - the number of frequencies in the fBm.
  • basis (int) - type of noise used for the turbulence, see NoiseTypes.
Returns: float
the generated noise value.

vlNoise(xyz, distortion, type1=1, type2=1)

 

Returns Variable Lacunarity Noise value, a distorted variety of noise.

Parameters:
  • xyz (3-float tuple) - (x,y,z) float values.
  • distortion (float) - the amount of distortion.
  • type1 (int) - sets the noise type to distort.
  • type2 (int) - sets the noise type used for the distortion.
Returns: float
the generated noise value.

heteroTerrain(xyz, H, lacunarity, octaves, offset, basis=1)

 

Returns Heterogeneous Terrain value.

Parameters:
  • xyz (3-float tuple) - (x,y,z) float values.
  • H (float) - fractal dimension of the roughest areas.
  • lacunarity (float) - gap between successive frequencies.
  • octaves (float) - number of frequencies in the fBm.
  • offset (float) - it raises the terrain from 'sea level'.
  • basis (int) - noise basis determines the type of noise used for the turbulence, see NoiseTypes.
Returns: float
the generated value.

hybridMFractal(xyz, H, lacunarity, octaves, offset, gain, basis=1)

 

Returns Hybrid Multifractal value.

Parameters:
  • xyz (3-float tuple) - (x,y,z) float values.
  • H (float) - fractal dimension of the roughest areas.
  • lacunarity (float) - gap between successive frequencies.
  • octaves (float) - number of frequencies in the fBm.
  • offset (float) - it raises the terrain from 'sea level'.
  • gain (float) - scale factor.
  • basis (int) - noise basis determines the type of noise used for the turbulence, see NoiseTypes.
Returns: float
the generated value.

ridgedMFractal(xyz, H, lacunarity, octaves, offset, gain, basis=1)

 

Returns Ridged Multifractal value.

Parameters:
  • xyz (3-float tuple) - (x,y,z) float values.
  • H (float) - fractal dimension of the roughest areas.
  • lacunarity (float) - gap between successive frequencies.
  • octaves (float) - number of frequencies in the fBm.
  • offset (float) - it raises the terrain from 'sea level'.
  • gain (float) - scale factor.
  • basis (int) - noise basis determines the type of noise used for the turbulence, see NoiseTypes.
Returns: float
the generated value.

voronoi(xyz, distance_metric=0, exponent=2.5)

 

Returns Voronoi diagrams-related data.

Parameters:
  • xyz (3-float tuple) - (x,y,z) float values.
  • distance_metric (int) - see DistanceMetrics
  • exponent (float) - only used with MINKOVSKY, default is 2.5.
Returns: list
a list containing a list of distances in order of closest feature, and a list containing the positions of the four closest features.

cellNoise(xyz)

 

Returns cellnoise.

Parameters:
  • xyz (3-float tuple) - (x,y,z) float values.
Returns: float
the generated value.

cellNoiseV(xyz)

 

Returns cellnoise vector/point/color.

Parameters:
  • xyz (3-float tuple) - (x,y,z) float values.
Returns: 3-float list
the generated vector.

Variables Details

NoiseTypes

The available noise types.
  • BLENDER
  • STDPERLIN
  • NEWPERLIN
  • VORONOI_F1
  • VORONOI_F2
  • VORONOI_F3
  • VORONOI_F4
  • VORONOI_F2F1
  • VORONOI_CRACKLE
  • CELLNOISE
Type:
readonly dictionary
Value:
{'BLENDER': 0, 'STDPERLIN': 1}

DistanceMetrics

The available distance metrics values for Voronoi.
  • DISTANCE
  • DISTANCE_SQUARED
  • MANHATTAN
  • CHEBYCHEV
  • MINKOVSKY_HALF
  • MINKOVSKY_FOUR
  • MINKOVISKY
Type:
readonly dictionary
Value:
{'DISTANCE': 0}