Module Noise
[hide private]
[frames] | no frames]

Module Noise

source code

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 [hide private]
float
random()
Returns a random floating point number."
source code
3-float list
randuvec()
Returns a random unit vector.
source code
 
setRandomSeed(seed)
Initializes the random number generator.
source code
float
noise(xyz, type=1)
Returns general noise of the optional specified type.
source code
3-float list
vNoise(xyz, type=1)
Returns noise vector of the optional specified type.
source code
float
turbulence(xyz, octaves, hard, basis=1, ampscale=0.5, freqscale=2.0)
Returns general turbulence value using the optional specified noise 'basis' function.
source code
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.
source code
float
fBm(xyz, H, lacunarity, octaves, basis=1)
Returns Fractal Brownian Motion noise value (fBm).
source code
float
multiFractal(xyz, H, lacunarity, octaves, basis=1)
Returns Multifractal noise value.
source code
float
vlNoise(xyz, distortion, type1=1, type2=1)
Returns Variable Lacunarity Noise value, a distorted variety of noise.
source code
float
heteroTerrain(xyz, H, lacunarity, octaves, offset, basis=1)
Returns Heterogeneous Terrain value.
source code
float
hybridMFractal(xyz, H, lacunarity, octaves, offset, gain, basis=1)
Returns Hybrid Multifractal value.
source code
float
ridgedMFractal(xyz, H, lacunarity, octaves, offset, gain, basis=1)
Returns Ridged Multifractal value.
source code
list
voronoi(xyz, distance_metric=0, exponent=2.5)
Returns Voronoi diagrams-related data.
source code
float
cellNoise(xyz)
Returns cellnoise.
source code
3-float list
cellNoiseV(xyz)
Returns cellnoise vector/point/color.
source code
Variables [hide private]
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 [hide private]

random()

source code 

Returns a random floating point number."

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

randuvec()

source code 

Returns a random unit vector.

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

setRandomSeed(seed)

source code 

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)

source code 

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)

source code 

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)

source code 

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)

source code 

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)

source code 

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)

source code 

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)

source code 

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)

source code 

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)

source code 

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)

source code 

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)

source code 

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)

source code 

Returns cellnoise.

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

cellNoiseV(xyz)

source code 

Returns cellnoise vector/point/color.

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

Variables Details [hide private]

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}