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])

Function Summary
float cellNoise(xyz)
Returns cellnoise.
3-float list cellNoiseV(xyz)
Returns cellnoise vector/point/color.
float fBm(xyz, H, lacunarity, octaves, basis)
Returns Fractal Brownian Motion noise value (fBm).
float heteroTerrain(xyz, H, lacunarity, octaves, offset, basis)
Returns Heterogeneous Terrain value.
float hybridMFractal(xyz, H, lacunarity, octaves, offset, gain, basis)
Returns Hybrid Multifractal value.
float multiFractal(xyz, H, lacunarity, octaves, basis)
Returns Multifractal noise value.
float noise(xyz, type)
Returns general noise of the optional specified type.
float random()
Returns a random floating point number."
3-float list randuvec()
Returns a random unit vector.
float ridgedMFractal(xyz, H, lacunarity, octaves, offset, gain, basis)
Returns Ridged Multifractal value.
  setRandomSeed(seed)
Initializes the random number generator.
float turbulence(xyz, octaves, hard, basis, ampscale, freqscale)
Returns general turbulence value using the optional specified noise 'basis' function.
float vlNoise(xyz, distortion, type1, type2)
Returns Variable Lacunarity Noise value, a distorted variety of noise.
3-float list vNoise(xyz, type)
Returns noise vector of the optional specified type.
list voronoi(xyz, distance_metric, exponent)
Returns Voronoi diagrams-related data.
3-float list vTurbulence(xyz, octaves, hard, basis, ampscale, freqscale)
Returns general turbulence vector using the optional specified noise basis function.

Variable Summary
readonly dictionary DistanceMetrics: The available distance metrics values for Voronoi.
readonly dictionary NoiseTypes: The available noise types.

Function Details

cellNoise(xyz)

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

cellNoiseV(xyz)

Returns cellnoise vector/point/color.
Parameters:
xyz - (x,y,z) float values.
           (type=3-float tuple)
Returns:
the generated vector.
           (type=3-float list)

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

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

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

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

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

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

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

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

noise(xyz, type=1)

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

random()

Returns a random floating point number."
Returns:
a random number in [0, 1).
           (type=float)

randuvec()

Returns a random unit vector.
Returns:
a list of three floats.
           (type=3-float list)

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

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

setRandomSeed(seed)

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

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

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

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

vNoise(xyz, type=1)

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

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

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

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

Variable Details

DistanceMetrics

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

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:
{'STDPERLIN': 1, 'BLENDER': 0}                                         

Generated by Epydoc 2.1 on Thu Dec 22 22:38:14 2005 http://epydoc.sf.net