public static class TerrainHeightmapReading and writing 16-bit raw heightmaps.
Remarks
Raw only, and PNG deliberately elsewhere. [docs/plan/31 § D1] gives this assembly one project reference and it is to the mathematics. Raw 16-bit is bytes and needs nothing; 16-bit PNG needs Vixen.Core.Imaging, so it belongs with the importer, which already depends on it. Splitting them costs a sentence of documentation and keeps the kernel something a game can carry.
Resampling is not optional. A terrain of four 128-sample tiles is 509 samples across; heightmaps come out of World Machine and Gaea at 512, 1024, 2049. They will essentially never match, so an importer that demanded they match would be an importer nobody could use. Bilinear, and the corners are pinned — see Import.
⚠ Import writes an edit layer by default, not the base. That is what makes a terrain imported from an external tool sculptable on top of without being destroyed, and re-importable without losing the sculpt — the whole return on [§ D4](../../docs/plan/31-terrain-grass-and-trees.md). Writing the base is available and is what the create dialog does.
Methods (3)
public static void Import(Terrain terrain, ReadOnlySpan<byte> bytes, in TerrainHeightmapFormat format, TerrainEditLayer? layer = null)Reads a raw heightmap into a terrain.
public static int Export(Terrain terrain, Span<byte> destination, bool bigEndian = false)Writes a terrain's composited heights as a raw heightmap.
public static long ExportByteCount(TerrainDescription description)How many bytes a terrain exports as.
Used by (1)
- TerrainHeightmapTestsVixen.Terrain.Tests