Terrain · function
terrainMaterialWeights
The normalised weights at a point in the field's own 0..1 extent.
Explained in Terrain.
function terrainMaterialWeights(map: TerrainMaterials, u: number, v: number, out: Float32Array): Float32Arrayimport { terrainMaterialWeights } from '@driftengine/terrain';Parameters
| Parameter | Type | Description |
|---|---|---|
map | TerrainMaterials | |
u | number | |
v | number | |
out | Float32Array |
In depth
Normalised, and a sample that weighs nothing falls back to the first material. An unpainted corner of a map sums to zero, and dividing by that gives a NaN or a black patch depending on where it lands — both of which read as a rendering fault rather than as an unpainted map. Black is not a colour terrain should ever be by accident.
out must hold one number per material; it is returned for convenience and is the caller's.