Divooka Reference

Heightmap Amplification

8 nodes

On this page 8

Heightmap Data Usage Token Detail Amplitude

Function

Usage of a detail amplitude map, in metres of RMS height at the reference scale.

Signature
HeightmapDataUsageTokenDetailAmplitude() -> Text
string HeightmapDataUsageTokenDetailAmplitude()

Returns

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

Add Fractal Detail

Function

Adds fractal detail below the resolution of the data a heightmap was made from, scaled by the terrain's own roughness and slope.

Signature
AddFractalDetail -> Scalar Field
    heightmap: Scalar Field
    sourceCellMetres: Number
    strength: Number
    hurst: Number
    style: Heightmap Detail Style
    warp: Number
    steepSlopeDegrees: Number
    flatSlopeDegrees: Number
    flatAmount: Number
    stillWaterSlopeDegrees: Number
    finestFeatureMetres: Number
    mask: Scalar Field
    seed: Integer
ScalarField2D AddFractalDetail(
    ScalarField2D heightmap,
    double sourceCellMetres = 0,
    double strength = 0.6,
    double hurst = 0.8,
    HeightmapDetailStyle style = HeightmapDetailStyle.Eroded,
    double warp = 0.1,
    double steepSlopeDegrees = 35,
    double flatSlopeDegrees = 3,
    double flatAmount = 0.3,
    double stillWaterSlopeDegrees = 0.5,
    double finestFeatureMetres = 0,
    ScalarField2D mask,
    int seed = 1337)

Parameters

nametypedefaultdescription
heightmapScalar Field—Heights in metres; PhysicalScale in metres per cell.
sourceCellMetresNumber0Cell size in metres of the data the heightmap came from (10 for a 1/3 arc-second survey); 0 uses the heightmap's own cell size.
strengthNumber0.6Multiplier of the detail: 1 restores the relief lidar shows and a 10 m survey lacks, 0 adds nothing; 0.6 reads best in renders.
hurstNumber0.8Hurst exponent, 0..1: how fast the roughness falls with feature size. 0.8 suits most landscapes; lower is rougher at small scales, higher smoother.
styleHeightmap Detail StyleErodedFbm (rounded), Ridged (rock ribs) or Eroded (clean faces, rough tops and hollows).
warpNumber0.1Domain warp as a fraction of the coarsest feature size; 0 disables it.
steepSlopeDegreesNumber35Slope at and above which the detail is at full strength.
flatSlopeDegreesNumber3Slope at and below which the detail is reduced to Flat Amount.
flatAmountNumber0.3Fraction of the detail kept on flat ground, 0..1.
stillWaterSlopeDegreesNumber0.5Below this slope (a hydro-flattened lake or river surface) the detail fades to nothing; 0 disables the cut.
finestFeatureMetresNumber0Smallest feature size to add, in metres; 0 uses three output cells.
maskScalar Field—Optional 0..1 mask the same size as the heightmap that scales the detail (e.g. 0 on water, roads or buildings).
seedInteger1337Noise seed; the same seed gives the same detail.

Returns

resultScalar Field

Remarks

Octave feature sizes run from four times Source Cell Metres down to Finest Feature Metres (three output cells when 0), each about half the last. The amplitude of each octave is the local envelope (see HeightmapAmplification.CalculateDetailAmplitude) times a calibration constant times (feature size / coarsest size)^Hurst times Strength; at strength 1 the result matches the RMS relief that 1 m lidar has and a 10 m resampling of it lacks. The octaves are evaluated at gently domain-warped world positions and each is rotated, so the detail has no grid direction.
Give the source's true cell size when the heightmap has already been upsampled, otherwise the detail starts at the heightmap's own cell and adds nothing the source lacked.

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

Add Strata

Function

Adds sedimentary bedding: steep ground breaks into ledges and short cliff bands that follow the contours, the way layered rock weathers, while flat ground keeps its shape.

Signature
AddStrata -> Scalar Field
    heightmap: Scalar Field
    layerThicknessMetres: Number
    strength: Number
    thinBedFraction: Number
    dipDegrees: Number
    dipAzimuthDegrees: Number
    warpMetres: Number
    anchorHeight: Number
    mask: Scalar Field
    seed: Integer
ScalarField2D AddStrata(
    ScalarField2D heightmap,
    double layerThicknessMetres = 8,
    double strength = 0.6,
    double thinBedFraction = 0.2,
    double dipDegrees = 0,
    double dipAzimuthDegrees = 0,
    double warpMetres = 2,
    double anchorHeight = double.NaN,
    ScalarField2D mask,
    int seed = 1337)

Parameters

nametypedefaultdescription
heightmapScalar Field—Heights in metres.
layerThicknessMetresNumber8Mean thickness of a bed in metres.
strengthNumber0.6How strongly beds terrace, 0..1: 0 leaves the surface unchanged; above about 0.75 the sharpest beds may fold a contour back on itself.
thinBedFractionNumber0.2Share of the strength given to the thin beds, 0..1.
dipDegreesNumber0Dip of the bedding planes in degrees.
dipAzimuthDegreesNumber0Compass direction the beds dip toward, clockwise from north (up the map).
warpMetresNumber2Vertical waviness of the beds in metres, over a few hundred metres.
anchorHeightNumberNaNElevation in metres that the bedding leaves exactly in place (a river or lake level); NaN uses the lowest height on the map, which in a canyon is its river.
maskScalar Field—Optional 0..1 mask the same size as the heightmap that scales the effect; keep its edges soft, since a hard edge becomes a step of up to the largest movement.
seedInteger1337Seed of the bed sequence.

Returns

resultScalar Field

Remarks

Heights are remapped through a monotone function of elevation: within each bed, height changes slowly above and below a band where it changes quickly, so a slope breaks into benches and a cliff band per bed. Because only elevation is remapped, the ledges follow the contours exactly and the effect grows with slope by itself: a flat plateau or a lake is one elevation and moves as a whole, keeping its shape. Up to a strength of about 0.75 the remap never reverses the order of two heights, so it creates no pits or spikes. Bed thickness varies along a slow fractal of elevation and each bed has its own hardness (how strongly it terraces) and position of its cliff band; a second set of thin beds about a quarter as thick adds finer banding. The beds are warped and may dip, so they are not perfectly level. A cell moves by at most about a third of the bed thickness times the strength (about 1.5 m for 8 m beds at strength 0.6); on a 60° wall that sets ledges back by about a metre.
The remap is shifted so that ground at Anchor Height does not move at all: give the water level there, so a river or lake stays where the water surface expects it. Gating the bedding off on flat ground instead would turn the offset at the water's edge into a step along every bank.
Apply it to a smooth surface (after HeightmapAmplification.Upsample, before HeightmapAmplification.AddFractalDetail); applied after noise, the noise jitters which bed a cell falls in.

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

Calculate Detail Amplitude

Function

The local amplitude HeightmapAmplification.AddFractalDetail uses, as a map: the RMS height in metres of detail at the reference size (twice the source cell), before strength is applied.

Signature
CalculateDetailAmplitude -> Scalar Field
    heightmap: Scalar Field
    sourceCellMetres: Number
    steepSlopeDegrees: Number
    flatSlopeDegrees: Number
    flatAmount: Number
    stillWaterSlopeDegrees: Number
ScalarField2D CalculateDetailAmplitude(
    ScalarField2D heightmap,
    double sourceCellMetres = 0,
    double steepSlopeDegrees = 35,
    double flatSlopeDegrees = 3,
    double flatAmount = 0.3,
    double stillWaterSlopeDegrees = 0.5)

Parameters

nametypedefaultdescription
heightmapScalar Field—Heights in metres.
sourceCellMetresNumber0Cell size in metres of the data the heightmap came from; 0 uses the heightmap's own.
steepSlopeDegreesNumber35Slope at and above which the amplitude is not reduced.
flatSlopeDegreesNumber3Slope at and below which the amplitude is reduced to Flat Amount.
flatAmountNumber0.3Fraction kept on flat ground.
stillWaterSlopeDegreesNumber0.5Below this slope the amplitude fades to zero; 0 disables the cut.

Returns

resultScalar Field

Remarks

It combines two measures in quadrature: the roughness the source shows at its finest scale (the RMS of the source minus a one-cell blur, averaged over two cells), and a slope term, a twentieth of the height a plane of the local slope gains over the reference size, so that a smooth but steep face still roughens a little. On lidar the envelope correlates with the relief a 10 m resampling loses at 0.91 to 0.94. The result is weighted by the slope ramp and still-water cut and capped at half the reference size. Useful as a mask of where the terrain will change, or to tune the slope parameters before running the detail.

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

Refine

Function

Refines a coarse heightmap for rendering: a smooth upsample to Target Cell Metres and fractal detail below the source's resolution.

Signature
Refine -> Scalar Field
    source: Scalar Field
    targetCellMetres: Number
    detailStrength: Number
    seed: Integer
    hurst: Number
    style: Heightmap Detail Style
    kernel: Heightmap Upsampling Kernel
    mask: Scalar Field
    strataThicknessMetres: Number
    strataStrength: Number
ScalarField2D Refine(
    ScalarField2D source,
    double targetCellMetres = 1,
    double detailStrength = 0.6,
    int seed = 1337,
    double hurst = 0.8,
    HeightmapDetailStyle style = HeightmapDetailStyle.Eroded,
    HeightmapUpsamplingKernel kernel = HeightmapUpsamplingKernel.MonotoneCubic,
    ScalarField2D mask,
    double strataThicknessMetres = 0,
    double strataStrength = 0.6)

Parameters

nametypedefaultdescription
sourceScalar Field—Heightmap as surveyed, heights and PhysicalScale in metres.
targetCellMetresNumber1Cell size of the result in metres.
detailStrengthNumber0.6Multiplier of the added detail: 1 restores the relief lidar shows and a 10 m survey lacks, 0 adds none; 0.6 reads best in renders.
seedInteger1337Noise seed.
hurstNumber0.8Hurst exponent of the detail, 0..1; 0.8 suits most landscapes.
styleHeightmap Detail StyleErodedFbm, Ridged or Eroded detail.
kernelHeightmap Upsampling KernelMonotone cubicUpsampling kernel; MonotoneCubic does not overshoot at cliffs.
maskScalar Field—Optional 0..1 detail mask at the source's resolution (e.g. 0 on water); it is upsampled bilinearly.
strataThicknessMetresNumber0Mean bed thickness for HeightmapAmplification.AddStrata, applied between the upsample and the detail; 0 (the default) adds no bedding. Use it for layered sedimentary rock: canyons, mesas, badlands.
strataStrengthNumber0.6Strength of the bedding, 0..1.

Returns

resultScalar Field

Remarks

The source's cell size is taken as the resolution of its information, so give the heightmap as surveyed (a 10 m model at 10 m cells), not one already upsampled. With Detail Strength 0 this is just HeightmapAmplification.Upsample. For layered rock give a bed thickness (8 to 12 m, with detail strength nearer 0.4); for downslope streaks follow with a short erosion, see the class remarks.

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

Resample

Function

Resamples a heightmap to an exact number of columns and rows over the same ground.

Signature
Resample -> Scalar Field
    source: Scalar Field
    columns: Integer
    rows: Integer
    kernel: Heightmap Upsampling Kernel
ScalarField2D Resample(
    ScalarField2D source,
    int columns,
    int rows,
    HeightmapUpsamplingKernel kernel = HeightmapUpsamplingKernel.MonotoneCubic)

Parameters

nametypedefaultdescription
sourceScalar Field—Heightmap to resample.
columnsInteger—Columns of the result.
rowsInteger—Rows of the result.
kernelHeightmap Upsampling KernelMonotone cubicInterpolation; see HeightmapAmplification.Upsample.

Returns

resultScalar Field

Remarks

PhysicalScale becomes the source width in metres divided by Columns; when the aspect ratio changes, the rows are stretched to the same extent and the cells are no longer square, which PhysicalScale cannot describe, so keep the aspect ratio for heightmaps.

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

Upsample

Function

Resamples a heightmap to a finer cell size in metres, keeping its ground extent.

Signature
Upsample -> Scalar Field
    source: Scalar Field
    targetCellMetres: Number
    kernel: Heightmap Upsampling Kernel
ScalarField2D Upsample(
    ScalarField2D source,
    double targetCellMetres = 1,
    HeightmapUpsamplingKernel kernel = HeightmapUpsamplingKernel.MonotoneCubic)

Parameters

nametypedefaultdescription
sourceScalar Field—Heightmap to resample; its PhysicalScale must be metres per cell.
targetCellMetresNumber1Cell size of the result in metres.
kernelHeightmap Upsampling KernelMonotone cubicInterpolation: MonotoneCubic (smooth, no overshoot; recommended), CatmullRom (smooth, rings at cliffs) or Bilinear (faceted).

Returns

resultScalar Field

Remarks

The output covers the same ground: its width in cells is the source's width in metres divided by Target Cell Metres, rounded, and its PhysicalScale is adjusted so the extent is exact. Samples sit at cell centres, as ScalarField2D.SampleWorldBilinearClamped assumes. Within half a source cell of the border the cubic kernels continue the edge slope rather than flattening. A coarser target is allowed; the source is then blurred first so it does not alias.

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

Upsample By Factor

Function

Resamples a heightmap by a factor (2 doubles the cells along each side), keeping its ground extent.

Signature
UpsampleByFactor -> Scalar Field
    source: Scalar Field
    factor: Number
    kernel: Heightmap Upsampling Kernel
ScalarField2D UpsampleByFactor(
    ScalarField2D source,
    double factor = 4,
    HeightmapUpsamplingKernel kernel = HeightmapUpsamplingKernel.MonotoneCubic)

Parameters

nametypedefaultdescription
sourceScalar Field—Heightmap to resample.
factorNumber4Ratio of the source cell size to the result's; need not be a whole number.
kernelHeightmap Upsampling KernelMonotone cubicInterpolation; see HeightmapAmplification.Upsample.

Returns

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