c4d.utils.noise.C4DNoise

An important technique for generating procedural textures is the use of fractal noise.

class c4d.utils.noise.C4DNoise

Members

C4DNoise.__init__([seed=0])
Parameters: seed (int) – Noise seed.
Return type: C4DNoise
Returns: A new noise object.
C4DNoise.CreateMenuContainer([bIncludeNone=False])

Creates a menu container with the different noise options available:

bc = noise.C4DNoise.CreateMenuContainer(False)
for index, name in bc:
    print index, name
Parameters: bIncludeNone (bool) – Include the none option.
Return type: BaseContainer
Returns: Generated noise menu.
C4DNoise.InitFbm(lMaxOctaves, rLacunarity, h)

Initializes fractal brownian motion.

Parameters:
  • lMaxOctaves (int) – Ther maximum octave.
  • rLacunarity (float) – This parameter controls the scale of each successive fractal overlay.
  • h (float) – H-Parameter
Return type:

bool

Returns:

Initializes fractal brownian motion

C4DNoise.Noise(t, two_d, p[, time=0.0][, octaves=4.0][, absolute=False][, sampleRad=0.25][, detailAtt=0.25][, t_repeat=0])

Samples a 2D or 3D noise.

Parameters:
  • t (int) –

    The noise Type: Noise Types

    Note

    Please use InitFbm() before you use one of the following noise types: NOISE_ZADA, NOISE_DISPL_VORONOI, NOISE_OBER, NOISE_FBM, NOISE_BUYA.

  • two_d (bool) – True for 2D Sampling, False for 3D Sampling
  • p (Vector) – Noise coordinate.
  • time (float) – Time.
  • octaves (float) – Octaves, if supported. See HasOctaves()
  • absolute (bool) – Absolute value, if supported. See HasAbsolute()
  • sampleRad (float) – Sample radius.
  • detailAtt (float) – Detail attenuation.
  • t_repeat (int) – Must be 2^x - 1, where x = [1..10], i.e. one of 1, 3, 7, 15, 31, 63, 127, 255, 511, and 1023. A noise repeats itself in time every 1024 units. Using a smaller repeat the noise will repeat at an earlier time.
Return type:

float

Returns:

Noise sample.

C4DNoise.SNoise(p, lRepeat[, t=0.0])

Generate a periodic signed noise value.

Parameters:
  • p (Vector) – Noise coordinate.
  • lRepeat (int) – Must be 2^x - 1, where x = [1..10], i.e. one of 1, 3, 7, 15, 31, 63, 127, 255, 511, and 1023. A noise repeats itself in time every 1024 units. Using a smaller lRepeat the noise will repeat at an earlier time.
  • t (float) – The time.
Return type:

float

Returns:

Signed noise value, this is between -1.0 and 1.0.

C4DNoise.Turbulence(p, rOctaves, bAsolute[, t=0.0])

Generate a turbulence value, this is a sum of multiple noises with different frequency.

Parameters:
  • p (Vector) – Turbulence coordinate
  • rOctaves (float) – The number of octaves.
  • bAbsolute (bool) – True for absolute values.
  • t (float) – The time.
Return type:

float

Returns:

Noise sample.

C4DNoise.Fbm(p, rOctaves, lRepeat[, t=0.0])

Generate a periodic Fractional Brownian Motion value.

Note

Needs the call InitFbm() before.

Warning

The rOctaves value must not exceed the value passed to InitFbm() but can be lower.

Parameters:
  • p (Vector) – The evaluation point.
  • rOctaves (float) – The octaves
  • lRepeat (int) – Must be 2^x - 1, where x = [1..10], i.e. one of 1, 3, 7, 15, 31, 63, 127, 255, 511, and 1023. A noise repeats itself in time every 1024 units. Using a smaller repeat the noise will repeat at an earlier time.
  • t (float) – The time
Return type:

float

Returns:

The fbm value.

C4DNoise.RidgedMultifractal(p, rOctaves, rOffset, rGain, lRepeat[, t=0])

Generate a periodic fractal function used for such things as landscapes or mountain ranges.

Note

Needs the call InitFbm() before.

Warning

The rOctaves value must not exceed the value passed to InitFbm() but can be lower.

Parameters:
  • p (Vector) – The evaluation point.
  • rOctaves (float) – The octave.
  • rOffset (float) – The zero offset, this controls the multifractality.
  • rGain (float) – The amplification of the fractal value.
  • lRepeat (float) – Must be 2^x - 1, where x = [1..10], i.e. one of 1, 3, 7, 15, 31, 63, 127, 255, 511, and 1023. A noise repeats itself in time every 1024 units. Using a smaller lrepeat the noise will repeat at an earlier time.
  • t (float) – The time.
Return type:

float

Returns:

The fractal value.

static C4DNoise.HasOctaves(t)

Checks if a certain noise type supports the octaves parameter.

Parameters: t (int) – Noise type.
Return type: bool
Returns: True if octaves is supported, otherwise False.
static C4DNoise.HasAbsolute(t)

Checks if a certain noise type supports the absolute parameter.

Parameters: t (int) – Noise type.
Return type: bool
Returns: True if absolute is supported, otherwise False.
static C4DNoise.HasCycles(t)

Checks if a certain noise type supports the cycles parameter.

Parameters: t (int) – Noise type.
Return type: bool
Returns: True if cycles is supported, otherwise False.

Example

Creates a noise and save it in a bitmap:

import c4d
from c4d.utils.noise import C4DNoise
from c4d import bitmaps

width = 300
height = 300
noisetype = c4d.NOISE_DISPL_TURB
bmp =  bitmaps.BaseBitmap()
bmp.Init(width, height, 24)

# Create and initialize the noise instance
p = C4DNoise(1234)
p.InitFbm(21, 2.1, 0.5)

rw = float(width-1)
rh = float(height-1)

# Iterate through the bitmap and set the noise value per pixel
for x in xrange(width):
    for y in xrange(height):
        r = p.Noise(noisetype, False, c4d.Vector(x/rw, y/rh, 0) * 7.0, octaves=5)
        o = int(255.0*r)
        if o < 0: o = 0
        elif o > 255: o = 255

        bmp[x, y] = (o, o, o)

bitmaps.ShowBitmap(bmp)

Noise Types

BoxNoise

Type: NOISE_BOX_NOISE

Blistered Turbulence

Type: NOISE_BLIST_TURB

Buya

Type: NOISE_BUYA

Cell Noise

Type: NOISE_CELL_NOISE

Cell Voronoi

Type: NOISE_CELL_VORONOI

Cranal

Type: NOISE_CRANAL

Dents

Type: NOISE_DENTS

Displaced Turbulence

Type: NOISE_DISPL_TURB

Electric

Type: NOISE_ELECTRIC

FBM

Type: NOISE_FBM

Fire

Type: NOISE_FIRE

Gas

Type: NOISE_GASEOUS

Hama

Type: NOISE_HAMA

Luka

Type: NOISE_LUKA

Mod Noise

Type: NOISE_MOD_NOISE

Naki

Type: NOISE_NAKI

Noise

Type: NOISE_NOISE

None

Type: NOISE_NONE

Nutous

Type: NOISE_NUTOUS

Ober

Type: NOISE_OBER

Pezo

Type: NOISE_PEZO

Poxo

Type: NOISE_POXO

Sema

Type: NOISE_SEMA

Sparse Convolution

Type: NOISE_SPARSE_CONV

Stupl

Type: NOISE_STUPL

Turbulence

Type: NOISE_TURBULENCE

VLNoise

Type: NOISE_VL_NOISE

Voronoi 1

Type: NOISE_VORONOI_1

Voronoi 2

Type: NOISE_VORONOI_2

Voronoi 3

Type: NOISE_VORONOI_3

Wavy Turbulence

Type: NOISE_WAVY_TURB

Zada

Type: NOISE_ZADA