Taos API Reference
    Preparing search index...

    Module terrain

    The TerrainSystem CDLOD heightmap renderer: procedural or image-driven heights, virtual-texture page streaming, PBR layer splatting, quality presets, and the render-graph feature wiring.

    Enumerations

    TerrainQuality

    Classes - Passes

    TerrainGeometryPass
    TerrainLodPass
    TerrainPointSpotShadowPass
    TerrainShadowPass

    Classes - Components

    Terrain

    A CDLOD heightmap terrain. By default a fully-resident finite slab that's easy to frame in the editor; set bounded to false with a large worldExtent for an "infinite" world that streams pages around the camera.

    WaterBody

    A finite water body on a terrain. Defaults are calm freshwater (greener scatter, visible shallow beds, foam off).

    Classes - Terrain

    TerrainProbeRenderer

    Draws the terrain into reflection-probe cube faces. Create once per (context, system) and register draw via ReflectionProbeCapturePass.addExternalDraw. Owns one small uniform per (probe slot, face) — the capture pass encodes all faces before the queue submits, so a shared buffer would be overwritten by the last face.

    TerrainRegionEditSession

    Classes - Features

    WaterFeature

    Classes - Other

    HeightField

    A normalized [0, 1] height field over a world-space rect, sampled bilinearly. Row-major width × height samples; texel (0, 0) sits at (originX, originZ) and texel (width-1, height-1) at (originX + extentX, originZ + extentZ) — the same mapping the page-gen shader uses when it samples the heightmap texture with a clamping sampler.

    TerrainEditSession
    TerrainLodFeature

    Reconciles the TerrainSystem against the authored Terrain each frame, drives its per-frame update, runs the LOD compute, and publishes the patch + indirect-args handles for the terrain shadow + G-Buffer features. Owns the shared system's lifetime (destroys it on engine teardown).

    TerrainShadowFeature

    Appends terrain depth to every cascade of the directional shadow map produced by the engine's ShadowFeature. shadow:cascades is set during ShadowFeature's update() but the engine wipes frame.extras between update and addPasses, so it is cached in our own update(). Skips quietly when there is no shadow map, no cascades, or no terrain.

    TerrainGeometryFeature

    Loads the terrain into the deferred G-Buffer. When a prior geometry feature has already written it (mesh renderers, skinned models), this loads on top so terrain and meshes share one G-Buffer; otherwise it clears a fresh one. Inert when there is no terrain.

    TerrainGrassFeature

    Grows the grass detail layer over the authored terrain: a deterministic scatterer seats blades on the CPU height mirror with density from the masked splat weights, and the engine's GrassPass draws + shadow-casts them. Inert until the Terrain enables grass and its height data is loaded.

    TerrainTreeFeature

    Scatters trees over the authored terrain (jittered spacing grid, density from the masked splat weights, slope-culled) and contributes them as instanced batches to the engine's GeometryFeature (G-Buffer) and ShadowFeature (all cascades) via their additive provider APIs.

    TerrainGrassField
    TerrainRegionSource
    TerrainSystem
    TerrainTreeField

    Interfaces

    HeightFieldOptions

    Maps the height field's texel grid onto world space (XZ plane).

    HeightmapLoadOptions
    LoadedHeightmap
    TexelRect

    Inclusive texel rect (x0/y0..x1/y1) touched by an edit.

    BrushStamp

    One brush application (a pointer-move step of a stroke).

    EditableHeights

    An editable height field bound to its GPU texture.

    EditableSplat

    An editable RGBA splat weight map bound to its GPU texture.

    EditableHoleMask

    An editable hole mask (one byte per texel, ≥128 = hole) bound to its r8unorm GPU texture.

    EditableColorMap

    An editable painted color/tint map (RGBA; rgb = overlay multiplier centered at 0.5, a = paint opacity) bound to its GPU texture.

    TerrainEditSessionOptions
    TerrainGrassSettings

    Authored grass settings (mirrors the Terrain component's grass fields).

    TerrainRaycastHit
    RegionTexelRect

    One region's texel rect (tile texels, 0..regionTexels inclusive).

    RegionEdit

    One region's undo payload: the rect plus before/after sample blocks.

    RegionWindow
    TerrainRegionSourceOptions
    SplineCarveSpline
    SplineGridMapping

    Maps a row-major grid onto world space (min corner + span).

    SplineTexelRect
    CarveHeightsOptions
    PaintSplineOptions
    TerrainSystemOptions
    TerrainLayerStyle

    Per-layer style knobs mirrored into the shader's LayerStyle UBO.

    SplatmapOptions

    Maps authored splat weight textures onto world space.

    HoleMaskData

    CPU copy of the hole mask (one byte per texel, row-major; ≥128 = hole).

    HoleMaskOptions

    Maps the hole mask texture onto world space.

    ControlMapOptions

    Maps a control map (see packControlTexel) onto world space.

    ColorMapData

    CPU copy of the color/tint map (RGBA bytes, row-major).

    ColorMapOptions

    Maps the color/tint map texture onto world space.

    HeightmapOptions

    Maps the heightmap texture passed to TerrainSystem.setHeightmap onto world space.

    TerrainTreeSettings

    Authored tree settings (mirrors the Terrain component's tree fields).

    TreeRecordSet

    One packed record set: instance data + count.

    Type Aliases

    TerrainQualityName

    Quality preset choices exposed by Terrain.

    TerrainLayerDef

    One authored PBR layer: texture asset refs + style knobs. Refs are opaque keys resolved by Terrain.resolveAssetBytes (asset guids in the editor, URLs elsewhere).

    HeightBrushOp

    Height-changing brush operations.

    HeightQuery

    World-space height query: world Y at (x, z), or null off the field.

    SplineCarveMode

    How the carve moves ground toward the spline profile.

    Variables

    GRASS_TILE_SIZE

    World size of one scatter tile.

    REGION_INVALID_LAYER

    Invalid layer marker in the region table (mirrors the VT page table).

    WORLD_EXTENT
    DEFAULT_HEIGHT_SCALE
    LOD_GRID
    MAX_PATCHES
    MAX_LAYERS

    Maximum PBR layers the shader supports (fixed-size uniform array + two RGBA splat weight textures = 8 channels).

    INDIRECT_ARGS_BYTES
    TREE_TILE_SIZE

    World size of one scatter tile (holds many spacing cells).

    Functions

    loadHeightmapTexture

    Fetch and decode a grayscale heightmap image into an r16float texture. The R channel of the decoded image is read as height. Throws if the fetch or decode fails (so callers can fall back to procedural generation).

    heightmapFromImageBytes

    Decode a grayscale heightmap image from raw bytes (see loadHeightmapTexture for the denoising it applies). Used by hosts whose asset bytes don't come from a fetchable URL (the editor's Content/ pipeline).

    loadHeightmapRaw16

    Fetch a raw little-endian uint16 height field (e.g. the terrain stitcher's .r16 output) into an r16float texture + normalized CPU field. No denoising is applied — 16-bit sources don't have the 8-bit/JPG noise the image loader blurs away. Square fields can omit resolution (inferred from the byte length).

    heightmapFromRaw16Bytes

    Decode a raw little-endian uint16 height field from bytes (the fetch-free core of loadHeightmapRaw16).

    heightmapDataToTexture

    Upload a normalized [0, 1] Float32 height field as an r16float texture. data must be res * res row-major samples.

    loadSplatmapTexture

    Fetch and decode a splat weight image (PNG/WebP) into an rgba8unorm texture. Channels are read verbatim — author the image with linear channel values, not color-managed ones.

    splatmapFromImageBytes

    Decode a splat weight image from raw bytes (the fetch-free core of loadSplatmapTexture).

    splatmapDataToTexture

    Upload raw RGBA weight bytes (row-major width × height × 4) as an rgba8unorm splat texture.

    registerTerrainComponents

    Register the terrain component factory (idempotent; called on module import).

    unionRects

    Union of two texel rects (for accumulating a stroke's total dirty area).

    registerTerrainFeatures

    Register the three discovery-driven terrain features on an engine, ordered correctly against the standard deferred features. Call this once per engine that should be able to render an authored Terrain — after the engine's shadow / geometry / lighting features exist, so the anchors resolve (the editor calls it at the end of its preset for both the Scene and Game engines). The features stay inert until the scene contains an enabled Terrain.

    raycastHeightField

    March a ray against a height query. step is the coarse march step in world units — use about one heightmap texel; the hit is refined by bisection to ~1/64 step. Points where the query returns null are treated as "no ground" (the ray passes over the void beyond the field).

    regionKey

    Pack a (possibly negative) region grid coordinate into a map key.

    desiredRegionWindow

    The square window of regions a camera position wants resident.

    carveSplineIntoHeights

    Carve (or flatten) the spline profile into a normalized height grid, in place. Returns the touched texel rect (undo snapshots + flush), or null when the spline misses the grid.

    paintSplineIntoSplat

    Paint a splat layer along the spline footprint (channel + banks) with the coverage as the blend weight, renormalizing the other layers down — the "dress the banks" half of a carve. Mutates the arrays in place; returns the touched SPLAT texel rect or null.

    packControlTexel

    Pack one control-map texel (splat mode 3). Two layer ids + blend give two texture taps per texel regardless of palette size; rotation/scale detile the planar sampling frame per texel; autoshader hands the texel to the procedural height/slope rule.

    decodeControlTexel

    Decode packControlTexel's word (CPU mirrors + tests).

    mul16

    out = a × b (column-major 4×4). Allocates when out is omitted.

    composeTrs

    Compose a column-major TRS matrix from glTF node components.

    createPineMesh

    Build the shared low-poly pine mesh (call once per device; ~60 verts).

    createPineImpostorMesh

    Far-LOD stand-in: a single canopy cone + trunk stub (~14 verts). Used for distant trees regardless of the near mesh, so the far field stays a few triangles per tree until baked impostors arrive.

    registerWaterComponents

    Register the water-body component factory (idempotent; called on module import).