Landscapes
Skill ferret-terrain · download all skills · SKILL.md
When to use#
A level needs ground that is generated, not modelled: a valley, a dune sea, a swamp, a field of icebergs, a lunar plain; or a game needs to ask what the ground is at a point.
The model#
A TerrainSpec ({ version: 1, seed, relief: [...] }) lists operations (noise, shape, terrace, river, erode, lake, pond, paint, import). The height is a pure function of (seed, x, z), so tiles at any size, collision, view and queries agree. Ground adds climate, 25 biomes, layers, soil, surface, water.
Steps#
- Write the spec; check it with
validateSpec(issues have a path). new Ground({ spec, climate });ground.sample(x, z)answers height, normal, slope, biome weights, layer, soil, surface, wetness, water.- Draw:
new TerrainView(scene, { ground, cell, levels, radius, shadows: true })and callupdate([x, y, z])each frame;ScatterViewfor rocks and plants (ROCKS,PLANT_SPECIES, generated in code). A game's look:paint(colour per vertex, a 4th value is data in the alpha) andmaterial(its own standard/PBR material: world uv, geomorph plugin, opaque);water: 'inland'with a sea of its own (OceanView),setWaterReflection(skyProbe). - Physics:
registerSurfaces(host.materials),CollisionChunks(kernel, ground)+track(body)+update(),toTerrain(ground, region)for digging and sinking. - Water and hazards:
relief.waterAt,riverProfile,waterfalls;avalancheHazard,slide,rockfall; ice:makeIceberg,floatation,settle.
Check afterwards#
Render from eye height with a low sun and compare with a photograph of the same kind of place; hollows must read as hollows. Run on the RTX and check the renderer string. Tiles must agree at shared edges; the validator must pass.
What usually goes wrong#
- Everything is one biome: the test ground sits at 0 m, which is coast. Add a base height or a
zonesbiome map. erodeis slow at a finestep: use 48 m for flight scale and keep fine steps for small areas. A wide eroded band stalls the first flight over it (a block is ~0.2 s): mask it, or use ridged noise withwarp.- A lake kilometres wide:
pond, notlake(which sees only pits smaller than its block). - Grey slabs or walls at chunk edges on the loading screen: the build budget is one chunk a frame; raise
o.buildsPerUpdate/o.buildMswhile the splash is up. - The page shows through the ground: vertex alpha used as coverage; a game material must be opaque (
TerrainViewsets it). - A hole while moving: never build chunks yourself;
TerrainView.updatekeeps old chunks until new ones exist. - Light from below or no cast shadows turns craters and dunes inside out.
- Farmland and volcanic fields are
manualbiomes: they come only fromzones. - Havok has no height field: use
CollisionChunks(mesh tiles), not a heightmap.
Files#
reference/terrain.mdis the guide for this module;reference/api-terrain.mdlists every export.- The terrain package's
GrassViewtakes an optionalflowMapso local air (a rotor's wash) bends the blades; seeferret-physics-response.