Browse documentation ⌄
Docs/DSL reference
On this page

World syntax reference

Native world files use ashfox 1 followed by world <name> { ... } under assets/worlds/ and compile into deterministic chunked voxel GLB terrain, per-column .height.bin ground heights, .nav.bin walkability masks, a world_horizon.glb (one terrain draw, plus one water draw when the world has water), an optional world_canopy.glb, and a <name>.world.json manifest. Terrain and horizon meshes carry no vertex colour or baked lighting: albedo comes from the terrain atlas (biome tints are baked into atlas tile variants), so shadows, ambient occlusion and global illumination are left to the rendering engine. Water is exported as a <lod>_water child node with its own mesh under each terrain LOD node (so MSFT_lod swaps terrain and water together) and under the horizon node, where it sits 0.125 below its level so it never shares a plane with chunk water: no vertex colour, TEXCOORD_0 world-space UVs, TANGENT, and a world_water material with metallic 0, KHR_materials_ior 1.33, alpha blending and a ripple normal map, so engines shade depth themselves. Every chunk GLB references one shared power-of-two terrain atlas (chunks/textures/terrain_base.png, terrain_mr.png, terrain_normal.png, listed in the manifest's textureFiles) instead of embedding a copy; ship those files next to the chunks. Each block's atlas variant and orientation come from a hash of its integer world coordinates and the world seed, so they never depend on the chunk or on neighbouring blocks. At LOD0 every visible block face is its own quad showing one whole atlas tile: tops one per block, side walls one per block and per 1 m world layer (lip, then dirt, then stone with depth), so faces always meet at shared corners. LOD1 and LOD2 are 2 m and 4 m super-voxels of that same block grid: each cell takes the highest block under it, rounded up to its own height step, so a coarse level never dips below LOD0 and never shows terrain LOD0 does not have. Their tops sample a small per-chunk macro texture embedded in the chunk GLB (four texels per block, baked from the LOD0 blocks with the same variant and orientation), so each block keeps its colour across a LOD switch; their walls keep atlas tiles. A wall on a chunk border reaches down to the neighbouring chunk's LOD0 top, which is the lowest top any of its LODs can show, so neighbours at different LODs never open a gap; the outer edge of the world is closed by a wall four blocks deep. The horizon takes the lowest block under each of its cells, so it never rises above the streamed terrain. A chunk switches LOD by the camera's distance to the nearest point of its bounding sphere: the manifest's lodDistances ([0, 96, 192] for 1 m blocks, scaled with the block size) and the MSFT_screencoverage values on each chunk's LOD0 node express the same rings.

Root contract

Block / field Contract
terrain { ... } size, chunk_size, streaming, sea_level, ocean_floor, seed, edge = landlocked | ocean (defaults to landlocked when any region uses basin/alpine_valley/canyon, else ocean), erosion { hydraulic; thermal; }, hydrology { rivers; lakes; }
atmosphere { ... } preset = golden_hour | clear_day | overcast | twilight, sun_elevation, sun_azimuth, fog_color, fog_density, optional clouds { altitude; coverage; }, optional valley_mist { altitude; density; }
region <name> { ... } landform = continent | island | archipelago | basin | alpine_valley | canyon | caldera | ridged_spire, at = (x, z), radius, elevation, climate = tundra | temperate | arid | tropical | volcanic, blend, optional [0, 1] knobs: coastal_plain (0.45), coast_warp (0.30), ruggedness (0.50)
settlement <name> { ... } at, radius, safe_zone, plan = plaza_ring | crossroads | main_street | hillside, center = well | fountain | hearth | market_square | none, dressing = low | medium | high (overrideable via AshfoxSettings.world.village), flatten { blend; elevation?; }, buildings { <import> as <alias> [{ at; offset; facing; }]; ... }, place <imported structure> as <alias> { offset; facing; }
road <name> { ... } from, through = [...], to, width, max_slope, surface = cobble | dirt | stone | gravel | sand
route <name> { ... } kind = trade | patrol | ferry | trail | caravan, from, through, to, width, max_slope, surface
bridge <name> { ... } on = <road>, at = (x, z), span, width?, style = arch | timber
cave <name> { ... } entrance = (x, [y,] z), path = [...], radius, kind = cavern | mine | dungeon_gate
poi <name> { ... } asset, at = (x, [y,] z), facing, scale
landmark <name> { ... } kind = spire_ruin | citadel | ancient_tree | monolith | lighthouse, at, elevation, visibility_from = [...]
zone <name> { ... } kind, bounds = ((minX, minZ), (maxX, maxZ)) or at + radius, danger, patrol_routes, encounter { cooldown; max_active; entry <model> { weight; count; time; crowd?; } }
scatter <name> { ... } asset, biome = any | [<biome id>, ...] (default any; exact ids, see below), climate?, density, min_spacing, avoid = [settlements, roads, routes, water, cliffs], scale, seed, optional cluster { radius; count; spacing; }

Scatter biome ids are closed and matched exactly: ocean_floor, beach_sand, temperate_grass, temperate_forest, alpine_rock, snow_peak, tundra, desert_sand, savanna, tropical_rainforest, volcanic_basalt, riverbed, or any. Any other name (for example forest or grassland) fails with world.syntax and lists the valid ids.

Build budgets are closed ranges checked at parse time with world.syntax: terrain size is 64u..2048u (the horizon keeps at most 128 columns per axis), the heightfield is at most 1025 samples per axis (size / chunk_size * chunk_quads + 1), LOD0 terrain is at most 1024 columns per axis (a chunk_size of 64 or less meshes 1 m columns), and every authored height (sea_level, ocean_floor, region, world, settlement and landmark elevation) is within [-512, 512].

World import statements name relative structure sources (import "../structures/tavern.ashfox" as tavern;) and are consumed by settlement buildings or place; a non-relative, unresolved, size-less or unused import, or a building entry naming no import, fails with world.import. A placement's footprint is the imported structure's declared size (width x depth, rotated by facing); it is never authored. Overlapping placements fail with world.layout. Declarative buildings { ... } settlements automatically solve terrain-respecting per-building contour terraces with downhill stone plinths, auto-orient building frontages toward the plaza or internal lanes (unless explicitly overridden), extend external roads seamlessly into the voxel-baked plaza and door lanes, place non-clipping procedural village dressing and scatter exclusions, and verify entrance-to-road nav connectivity; every authored coordinate must lie inside the terrain square [-size/2, size/2) or the source fails with world.bounds. Zone rollEncounter helpers in every runtime SDK share one xorshift32 roll.

Streaming outputs

The <name>.world.json manifest is the contract runtimes stream from:

Field Contract
heightBin Decode contract of every chunks/c_<cx>_<cz>.height.bin: layout = "column_top_u16", samplesPerAxis, spacing, decodeMin, decodeMax. Each file holds samplesPerAxis^2 little-endian u16 values, row-major with z outer, one per LOD0 voxel column at chunkOrigin + (i + 0.5) * spacing. A value v decodes to the rendered column top decodeMin + v / 65535 * (decodeMax - decodeMin), river carving included, so ground snapping and physics stand on the visible voxel steps. Decode only with heightBin.decodeMin/decodeMax. The world and chunk heightMin/heightMax fields are elevation ranges, not decode ranges.
horizonFile world_horizon.glb, one draw call, meshed one chunk footprint at a time so no horizon triangle crosses a chunk border. A runtime drops the horizon triangles inside every streamed-in chunk footprint, so the coarse horizon never draws under loaded chunk terrain.
chunks[].lodDistances The chunk's [LOD0, LOD1, LOD2] switch distances in metres, the same values the chunk GLB declares in its LOD metadata. Measure them from the camera to the chunk bounds (boundsMin/boundsMax), not to the chunk centre, so the chunk under the camera stays at LOD0 for any chunk_size.
ashfox 1
world greenvale {
  terrain {
    size = 256u;
    chunk_size = 64u;
    streaming = true;
    sea_level = 0;
    ocean_floor = -18;
    seed = 7;
    erosion { hydraulic = 0.5; thermal = 0.35; }
    hydrology { rivers = 3; lakes = true; }
  }
  region valley {
    landform = alpine_valley;
    at = (0, 0);
    radius = 110;
    elevation = 72;
    climate = temperate;
    blend = 24;
  }
  settlement town {
    at = (-32, 24);
    radius = 18;
    safe_zone = 22;
    flatten { blend = 12; }
  }
  road king_road {
    from = town;
    through = [(-10, -10)];
    to = (42, -28);
    width = 5;
    max_slope = 0.28;
    surface = cobble;
  }
  bridge valley_arch {
    on = king_road;
    at = (14.6, 5.3);
    span = 14;
    width = 5;
    style = arch;
  }
  scatter pines {
    asset = pine_tree;
    biome = [temperate_forest, temperate_grass];
    density = 0.08;
    min_spacing = 8;
    avoid = [settlements, roads, water, cliffs];
  }
}
Ready to make something? Get agent instructions →