Vixen
02b45cc4
csharp
public sealed class HeightmapImporter

Imports a raw 16-bit heightmap.

Read the guide page for this →

As a importer

Extensions
.r16 .hmpng

Remarks

[docs/plan/31 § T1]'s split, from the other side. That phase kept raw r16 import in the kernel because it is bytes and needs no reference, and said the 16-bit PNG half "needs Vixen.Core.Imaging and belongs with the importer". This is the importer; what it does is turn a file into the samples Import already knows how to resample.

⚠ PNG is refused rather than imported at eight bits, and that is the whole point of the refusal. The decoder this build has — StbImageDecoder, which doc 01 chose over ImageSharp for licensing — reads every PNG as eight bits a channel. A 16-bit heightmap through it is a terrain quantised to 256 heights, which does not look like a broken import: it looks like a terrain with a faint terrace on every slope, and it would be attributed to the generator. So the extension is claimed and answered with the reason.

⚠ Resampling is not optional and belongs to the kernel. A terrain of four 128-sample tiles is 509 samples across and heightmaps come out of World Machine at 512, 1024 and 2049 — they essentially never match. TerrainHeightmap does it bilinearly and edge-to-edge; mapping by scale factor instead leaves a flat lip along two sides of every imported terrain.

Fields and properties (4)

  • public const string RawExtension

    What a raw 16-bit heightmap is written as.

  • public const string PngExtension

    And what a 16-bit PNG one is.

  • public const string Alias

    The [DataContract] alias a decoded heightmap is recorded under.

  • public override int Version

    Its own version. Bumping it invalidates every artefact it has ever produced, which is the whole mechanism for "I fixed the mip filter, re-import everything".

Methods (2)

  • public static int SquareSideOf(long byteCount)

    What a square file of this many bytes is, on a side.

  • protected override ValueTask<ImportResult> ImportAsync(ImportContext context, HeightmapImportSettings settings, CancellationToken cancellationToken)

    Imports one asset.

Used by (2)

  • BuiltInImportersVixen.Editor.Assets
  • TerrainAssetImporterTestsVixen.Editor.Assets.Tests