Divooka Reference

Heightmap Filters

7 nodes

On this page 7

Distort

Function

Warps a field by two displacement fields, one for each axis, with a maximum displacement in metres.

Signature
Distort -> Scalar Field
    source: Scalar Field
    displacementX: Scalar Field
    displacementY: Scalar Field
    amplitudeMetres: Number
    centredAtHalf: Truth
ScalarField2D Distort(
    ScalarField2D source,
    ScalarField2D displacementX,
    ScalarField2D displacementY,
    double amplitudeMetres = 20,
    bool centredAtHalf = true)

Parameters

nametypedefaultdescription
sourceScalar Field—Field to warp.
displacementXScalar Field—Displacement along X (columns), the same size as the source.
displacementYScalar Field—Displacement along Y (rows), the same size as the source.
amplitudeMetresNumber20Distance in metres a displacement value of 1 moves the sample.
centredAtHalfTruthTrueTrue for displacement fields in 0..1 (masks, normalised noise), where 0.5 means no movement and 0 and 1 move by minus and plus the amplitude; false when the fields are already signed, centred on zero.

Returns

resultScalar Field

Remarks

Each output cell reads the source at its own position plus (dx, dy) × amplitude, bilinearly, clamped at the border. Distorting a selector mask by a noise or by the terrain itself removes the grid-straight edges thresholds leave behind; use HeightmapFilters.DistortByNoise when no displacement fields are at hand.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Heightmap Filters
Package
Procedural Generation

Distort By Noise

Function

Warps a field by a smooth fractal noise, with the noise's feature size and the warp's reach in metres.

Signature
DistortByNoise -> Scalar Field
    source: Scalar Field
    amplitudeMetres: Number
    featureSizeMetres: Number
    seed: Integer
    octaves: Integer
ScalarField2D DistortByNoise(
    ScalarField2D source,
    double amplitudeMetres = 20,
    double featureSizeMetres = 200,
    int seed = 1337,
    int octaves = 3)

Parameters

nametypedefaultdescription
sourceScalar Field—Field to warp.
amplitudeMetresNumber20Largest distance in metres a sample moves.
featureSizeMetresNumber200Size in metres of the noise's largest features; small values fray edges, large values bend them.
seedInteger1337Noise seed.
octavesInteger3Fractal octaves; more adds finer fraying.

Returns

resultScalar Field

Remarks

The noise is evaluated in world metres, so a 2k and a 1k copy of the same terrain are warped alike. The X and Y displacements use independent seeds.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Heightmap Filters
Package
Procedural Generation

Expand

Function

Grows or shrinks the bright parts of a mask (or the high parts of a heightmap) by a radius in metres, with a round footprint.

Signature
Expand -> Scalar Field
    source: Scalar Field
    radiusMetres: Number
    mode: Heightmap Expander Mode
    softnessMetres: Number
ScalarField2D Expand(
    ScalarField2D source,
    double radiusMetres = 10,
    HeightmapExpanderMode mode = HeightmapExpanderMode.Grow,
    double softnessMetres = 0)

Parameters

nametypedefaultdescription
sourceScalar Field—Mask or field to expand.
radiusMetresNumber10Radius of the disc in metres. Below half a cell the source is returned unchanged.
modeHeightmap Expander ModeGrowGrow (maximum) or Shrink (minimum).
softnessMetresNumber0Optional Gaussian blur in metres applied afterwards, so the new edge fades instead of stepping; 0 keeps the edge hard.

Returns

resultScalar Field

Remarks

Grow takes the maximum within a disc around each cell (morphological dilation), Shrink the minimum (erosion); grey values are kept, so a soft mask stays soft. Typical uses: spread a rock mask a few metres onto the scree below it, pull grass back from cliff edges, close small holes (grow then shrink) or remove specks (shrink then grow).

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Heightmap Filters
Package
Procedural Generation

Flip

Function

Mirrors a field left-right, top-bottom, or both.

Signature
Flip -> Scalar Field
    source: Scalar Field
    horizontal: Truth
    vertical: Truth
ScalarField2D Flip(
    ScalarField2D source,
    bool horizontal = true,
    bool vertical = false)

Parameters

nametypedefaultdescription
sourceScalar Field—Field to mirror.
horizontalTruthTrueMirror left-right (reverse each row).
verticalTruthFalseMirror top-bottom (reverse the order of rows).

Returns

resultScalar Field
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Heightmap Filters
Package
Procedural Generation

Gaussian Blur

Function

Smooths a field with a Gaussian whose standard deviation is given in metres.

Signature
GaussianBlur -> Scalar Field
    source: Scalar Field
    sigmaMetres: Number
ScalarField2D GaussianBlur(
    ScalarField2D source,
    double sigmaMetres = 10)

Parameters

nametypedefaultdescription
sourceScalar Field—Field to blur.
sigmaMetresNumber10Standard deviation of the Gaussian in metres. Features much smaller than this disappear; zero returns a copy.

Returns

resultScalar Field

Remarks

Unlike HeightmapOperations.Smooth (a box of a radius in cells) this is round, has no blocky ringing, and keeps its size in metres when the resolution changes. The kernel reaches three standard deviations.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Heightmap Filters
Package
Procedural Generation

High Pass

Function

Keeps only the detail smaller than a size in metres: the field minus its Gaussian blur.

Signature
HighPass -> Scalar Field
    source: Scalar Field
    sigmaMetres: Number
ScalarField2D HighPass(
    ScalarField2D source,
    double sigmaMetres = 20)

Parameters

nametypedefaultdescription
sourceScalar Field—Field to filter.
sigmaMetresNumber20Standard deviation in metres of the blur that is subtracted; larger keeps broader features.

Returns

resultScalar Field

Remarks

The result is centred on zero and in the source's units (metres for a heightmap): positive on bumps and crests narrower than about the given size, negative in dips. Feed it to HeightmapOperations.Normalize or a selector to make a mask.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Heightmap Filters
Package
Procedural Generation

Sharpen

Function

Exaggerates detail smaller than a size in metres (unsharp masking): source + amount × high-pass.

Signature
Sharpen -> Scalar Field
    source: Scalar Field
    sigmaMetres: Number
    amount: Number
ScalarField2D Sharpen(
    ScalarField2D source,
    double sigmaMetres = 20,
    double amount = 1)

Parameters

nametypedefaultdescription
sourceScalar Field—Field to sharpen.
sigmaMetresNumber20Standard deviation in metres separating detail from form.
amountNumber1How much of the detail to add again; 0 returns the source, 1 doubles the detail, negative values soften.

Returns

resultScalar Field
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Heightmap Filters
Package
Procedural Generation