Terrain · function
decodeTerrainSplat
Sample the four weights at a field coordinate, renormalised so they sum to one.
Explained in Terrain.
function decodeTerrainSplat(layer: TerrainSplatLayer, u: number, v: number, out: Float32Array): voidimport { decodeTerrainSplat } from '@driftengine/terrain';Parameters
| Parameter | Type | Description |
|---|---|---|
layer | TerrainSplatLayer | |
u | number | |
v | number | |
out | Float32Array |
In depth
The renormalisation is not tidiness. Four weights each rounded to eight bits sum to anywhere between 0.994 and 1.006, and a shader that trusts the sum draws a hillside slightly too bright or slightly too dark — smoothly, so it reads as lighting rather than as a texture bug. The alternative, storing three weights and deriving the fourth, puts the entire error on one material and is worse for the same total.