Heightmap Splatmaps
3 nodes
On this page 3
Calculate Material Id
FunctionGives each cell the index of its heaviest layer: a material ID map for engines and shaders that take one material per cell.
CalculateMaterialId -> Scalar Field
weights: Scalar Field Array
normalizeToUnitRange: TruthScalarField2D CalculateMaterialId(
ScalarField2D[] weights,
bool normalizeToUnitRange = false)Parameters
| name | type | default | description |
|---|---|---|---|
| weights | Scalar Field Array | — | Layer weights or masks, all the same size. |
| normalizeToUnitRange | Truth | False | False for the raw index (0, 1, 2, ...); true to divide by the last index so the map views as a 0..1 greyscale. |
Returns
| result | Scalar Field |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Heightmap Splatmaps
- Package
- Procedural Generation
Normalize Weights
FunctionConverts material masks into layer weights that sum to 1 at every cell.
NormalizeWeights -> Scalar Field Array
masks: Scalar Field Array
layered: Truth
includeBaseLayer: Truth
contrast: NumberScalarField2D[] NormalizeWeights(
ScalarField2D[] masks,
bool layered = true,
bool includeBaseLayer = true,
double contrast = 1)Parameters
| name | type | default | description |
|---|---|---|---|
| masks | Scalar Field Array | — | Material masks in 0..1, bottom layer first, all the same size. |
| layered | Truth | True | True to stack masks in order, false to share overlaps proportionally. |
| includeBaseLayer | Truth | True | True to add a remainder layer at index 0 of the output. |
| contrast | Number | 1 | Exponent applied to every mask first; above 1 sharpens transitions between layers, below 1 widens them. |
Returns
| result | Scalar Field Array |
Remarks
Masks are given bottom first: each later mask is a layer above the earlier ones. Layered, a layer covers the layers below it by its own weight, the way paint layers stack (a cell with rock 0.8 over grass 1 is 80 % rock, 20 % grass). Not layered, overlapping masks share the cell in proportion to their values. With a base layer, whatever no mask claims goes to an extra layer placed first in the output; without one, the bottom mask takes it (layered) or the masks are scaled up to fill the cell (not layered, split equally where every mask is 0).
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Heightmap Splatmaps
- Package
- Procedural Generation
Pack Weights
FunctionPacks layer weights four to an image, in the red, green, blue and alpha channels, the layout terrain engines read splatmaps in.
PackWeights(weights: Scalar Field Array) -> Pixel Image Array
PixelImage[] PackWeights(ScalarField2D[] weights)
Parameters
| name | type | default | description |
|---|---|---|---|
| weights | Scalar Field Array | — | Layer weights, normally from HeightmapSplatmaps.NormalizeWeights. |
Returns
| result | Pixel Image Array |
Remarks
Layer i goes to image i / 4, channel i % 4 (R, G, B, A); unused channels of the last image are 0. Bytes are rounded so that, where the weights sum to 1, the channels of all the images together sum to exactly 255 (largest-remainder rounding), so no cell loses or gains coverage to rounding.
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Heightmap Splatmaps
- Package
- Procedural Generation