# GliderCamera
Sunfall Ridge's chase camera for a pilot under a glider: a camera behaviour (tagged
`cameraBehavior`) set as the `behavior` of the `Camera` on the player prototype's camera rig,
with `Camera.follow` bound to the pilot's body as every follow camera is. The body needs
glideKit's `Glider` and airMotor's controller (the CharacterController the player prototype
already carries).
## What it does
- **In the air** it rides 8 m behind and 2.2 m above the pilot's hips along the flight path
(the body's velocity), framed so the pilot sits in the lower-middle third and the horizon,
the low sun and the ridge stay in the picture.
- Every part of the framing (heading, distance, height, roll, field of view) moves on
critically damped springs: no jitter, no snap in a turn, a dive or a landing.
- **Turns:** the turn rate is fed forward so the camera holds station behind the wing in a
steady turn; it swings a little to the inside of the turn while its aim leads into it
(`turnSwing`, `maxSwing`), and it rolls with `bankShare` (40%) of the glider's bank.
- **Speed:** it pulls back (`speedPullBack`) and widens its field of view from `fovSlow` (58°
at 12 m/s) to `fovFast` (68° at 30 m/s). **Dive:** it rises (`diveRise`) and tips its aim
down (`diveTilt`) so the ground ahead shows.
- **Clearance:** it stays `groundClearance` above the terrain (the `Terrain` of the entity
named `terrainName`, `ridge` by default, through `heightAt`; a downward ray where there is
none), and a ray from the pilot pulls it in ahead of any collider; it never comes closer
than a style's minimum distance, so it stays outside the wing.
- **Look around:** the look control of the Controllers library's `cameraRig` map (right-button
drag, right stick, right-side touch drag) turns it round the pilot within `lookYawLimit`
(±70°) in the air, and it eases back after `lookReturnDelay` (1 s) without input.
- **On the ground** (landed or walking) it settles into a calm third-person orbit
(`groundDistance`, `groundHeight`), behind a walking pilot and drifting slowly round one who
stands (`groundDrift`); the look control orbits it freely.
- **Styles:** each glider style has a framing profile. A canopy (paraglider, umbrella, leaf)
is framed from lower and further back so the canopy reads as a shape overhead.
## Setup
```luau
local rig = entity.spawn("CameraRig", { parent = prototype })
rig:setNetworkScope("OwnerOnly")
rig.component.add("Camera", { behavior = asset.resolve("sunfall.GliderCamera", "component"), fov = 60 })
body.component.add("Glider", { style = "hangGlider", cameraFollow = false, cameraFx = false })
```
It owns the camera's transform and field of view, so the Glider's `cameraFollow` and
`cameraFx` must be off (glideKit's FOV kick and its orbital easing would fight it).
`framingState()` reads the framing it holds now (heading, turn rate, roll, field of view,
distance, height, look offsets, how far it reads the pilot as flying).
# Run
One flight of Sunfall Ridge for the player on this peer. Placed once on the scene's `run` entity, it moves the
game through `title`, `cinematic`, `flight` and `result` (in `sunfall.game`), plays the films of `sunfall.intro`,
puts the pilot in the air off the launch with the `sunfall` flight feel and the glider and trail the player
picked (`sunfall.progress`), sinks the `sun` entity's light along `sunfall.course`'s path, races and calms the
`cloud_sea`'s wind, writes the instruments every frame, counts thermals climbed, and ends the flight on a
landing (scored in the meadow), a crash, the cloud sea or nightfall. `:fly()` starts a flight at once and
`:forceEnd(outcome)` ends one, for tests. Needs glideKit (with airMotor) and a player body carrying `Glider`.
# SunfallAudio
The whole soundscape of Sunfall Ridge as one component. Put it on any one entity of the scene and it does the rest: it reads the run's shared state (`sunfall.game`, written every frame by the `Run` component) and the course (`sunfall.course`) and plays everything the player hears, from the clips in `sunfall.package/sounds/`. It needs no sibling component and no other setup.
```luau
local audioEntity = entity.spawn("audio")
audioEntity.component.add("SunfallAudio", {})
```
## What it plays
| Layer | When | How |
|---|---|---|
| Score: `music_title` | title, cinematic | warm pads and felt piano, 72 s seamless loop; lifts while the cinematic's title card is up |
| Title-card swell: `sting_swell` | 4.6 s into the cinematic | one-shot over the bed |
| Score: `music_flight` | flight | lighter flowing guitar and strings, 126 s loop; thins out as `light` falls below 0.25 |
| Score: `music_dusk` | flight, `light` < 0.22 | low drone and slow pulse, 74 s loop; full by `light` 0.12 |
| High mountain wind: `wind_mountain` | title, cinematic, result | soft breeze bed |
| Evening ambience: `ambience_evening` + rare distant bird | title, cinematic, result | very sparse |
| Wind over the wing: `wind_body` + `wind_air_l`/`wind_air_r` | flight | quiet hiss at 10 m/s to a full roar at 30 m/s; the bright layer rises and brightens with `speed` (gain and pitch), slow gusting, leans left/right with `bank` |
| Variometer: `vario_beep` | flight, climb from +0.2 m/s | 500 Hz at 2 beeps/s (+0.3 m/s) up to 1200 Hz at 7 beeps/s (+5 m/s); silent between -2.5 and +0.2 |
| Sink tone: `vario_sink` | flight, sink below -3 m/s | soft low hum, held until the sink eases past -2.5 |
| Thermal: `thermal_swell` | `inThermal` turns true | one-shot |
| Raptors: `bird_eagle_1`, `bird_hawk_2`, `bird_buzzard_3` | flight, within ~520 m of a thermal | spatial, from an emitter circling each thermal at about the pilot's height; calls every 7-15 s, every 3-7 s while circling in that thermal |
| Endings | `state.result` changes | landed: touchdown + `sting_landed` (`sting_landed_best` for 3 feathers); outlanding: touchdown + `sting_outlanding`; crash: `crash`; dark: `sting_dark` |
| UI click: `ui_click` | every `request` event | soft one-shot |
Every bed fades toward its target over 1-2 s, starts from its head when it rises out of silence and stops once faded out, so beds nobody hears cost nothing.
## Fields
- `master`, `music`, `wind`, `vario`, `ambience`, `effects`: levels, 0..1. They multiply each layer's own mix level, and they are read every frame, so a settings slider is heard as it moves. `effects` covers the touchdown, crash and UI click.
- `listener` (default true): when no `AudioListener` is active, it puts one on the play camera (`layers.active.camera.entity`) so the birds are placed, and takes it off again when the component goes. A scene that places its own listener keeps it.
## Methods
- `report()` returns what it is doing now: each bed's gain, target, volume, pitch and the mixer's own report of its voice, the vario's smoothed reading and last beep, and the one-shots played most recently. Tests read it.
- `simulate(state)` drives it from a table shaped like `Game.state` instead of the run's state, and `simulate(nil)` hands it back. The test bench `scenes/audio_test.scene` uses it to walk every phase while a real run plays beside it.
## The clips
They live in `sunfall.package/sounds/`, and `scenes/audio_test.scene/bake_sounds.luau` documents how each was made. The music, stings, wind textures, ambience, birds, thermal swell, touchdown, crash and click were generated with `@builtin::services.audio_gen` (ElevenLabs), then trimmed, levelled and, for the loops, made seamless with an equal-power tail-into-head crossfade. The vario beep, the sink tone and the crash's low thud were synthesized. Loops are Opus at 160 kbps, the click and vario clips are PCM, and every loop reads seamless on `clip:loopSeam()`.
Glide kit's `Glider` plays a wind loop of its own. Turn it off (`sound = false`) where this component is used, so only one wind is heard.
# SunfallUi
Every on-screen interface of Sunfall Ridge, in one component. Put it on one entity of a scene
that runs the game (it needs no sibling components and no mesh); it reads the shared run state
in `sunfall.game` and shows the screen for the current `Game.state.phase`:
- **title**: SUNFALL RIDGE over the ridge beauty shot with only a soft gradient scrim, the
tagline, a FLY button (`Game.request("fly")`, also Enter / pad A), the player's best score,
best flight and feather total, and glider and trail pickers from `sunfall.progress` showing
each option's lock state and feathers needed (a click selects through `Progress.select`; a
locked card shakes).
- **cinematic**: letterbox bars easing in and out, the title card fading in and out a few seconds
in, and a skip hint; any key, click, tap or pad button calls `Game.request("skip")`.
- **flight**: a minimal HUD at the screen edges: the sun dial (the sun sinking to the horizon as
`light` falls) with time left as m:ss turning ember and pulsing in the last 30 s; height above
the meadow, a climb/sink vario bar and number, airspeed (km/h); the meadow compass with
distance and a "behind, turn left/right" cue; the course line with the thermal count; a soft
THERMAL cue when `inThermal` turns true; first-flight hints worded for keyboard, pad or touch.
- **result**: a card reading `Game.state.result`: headline and detail, three feathers landing one
by one, the score counting up with its breakdown rows, New best and every unlocked label, and
FLY AGAIN (`"retry"`) / TITLE (`"title"`). Success is gold and warm; outlanding, crash and
nightfall are ember and cooler, nightfall under a darker scrim.
Beside them it always draws `Game.state.fade` as a full-screen `fadeColor` overlay below its own
screens, and `Game.state.message` as a centre-top caption that fades in and out.
Screens fade and slide between phases, honour reduced motion, lay out for a phone (a compact
layout below 560 points tall or 900 wide) as well as 1920x1080, and only the title and result
hold the pointer, so the flight keeps its mouse and the HUD takes no clicks.
## Placing it
```luau
local ui = entity.spawn("SunfallUi")
ui.component.add("sunfall.SunfallUi", {})
```
Fields: `layer` (UI layer of the phase screens, default 40; the fade draws 20 below, the caption
2 above), `hints` (first-flight hints, default on), `hudRate` (most HUD rebuilds per second,
default 24; it only rebuilds when a reading changed).
It runs while the gameplay clock runs (play). The look lives in `sunfall.ui.style`.
# ThermalAir
A column of rising or sinking air for gliders. Put it on an entity standing on a thermal's axis: at play it
finds the ground under itself (the scene's `ridge` terrain) and stands three nested engine `Wind` volumes from
there up to `top`, so lift grows toward the core, and registers the column with glideKit as a `thermal` zone
(`sink` when `strength` is negative) so gliders fire `updraftEnter` / `updraftExit` for it. Fields: `label`,
`radius`, `top`, `strength`, `gust`; `ground` reads back the height it stands on. It draws nothing:
`ThermalMarker` shows where the air is. Needs glideKit installed.
# ThermalMarker
Draws the signs a pilot spots a thermal by, and nothing else: large raptors (griffon vultures / eagles, 3.2 m span) circling in its core, and a dust devil swirling up off the ground under it. It applies no lift and no wind; the `Thermal` (or any other lift) component does that beside it.
Put it on an entity standing at the thermal's axis: the entity's x and z are the axis, its y is roughly the ground. At start it finds the ground under the axis (the `ridge` entity's `Terrain:heightAt`, else a physics ray down, else the entity's own y) and stands the dust there. It needs no sibling component.
## Fields
| Field | Default | Meaning |
|---|---|---|
| `radius` | 60 | Metres of lifting air round the axis; each bird circles at 25-75% of it. |
| `top` | 1400 | World height the thermal ends at; birds circle in bands between 60 m above the ground and this. |
| `birds` | 7 | How many raptors circle in it (0 for none). |
| `strength` | 5 | Lift in m/s: how fast the birds climb and how fast and thick the dust spins and rises. |
| `seed` | 1 | Which flock and which dust devil (paths, phases, wander, turn direction). |
| `dust` | true | Draw the dust devil. |
All fields are `Sync`; changing one rebuilds the marker. `groundHeight()` answers the ground found under the axis and `birdPositions()` the birds' world positions this frame.
## What it draws
- **Birds**: one instanced draw of the shared raptor mesh (`sunfall.markers.raptorFlock`, about 2.8k triangles, built once per session and shared by every marker) with the `raptor` shader, which poses each copy in its vertex hook from four lanes this component writes: shoulder and wrist angles (a shallow V, slow occasional flap bursts), primary-feather spread, tail spread, hand sweep and tip curl. Each bird flies its own circle (radius 25-75% of `radius`, 10-14 m/s, about 30% turning the other way), banked 20-35 degrees into the turn, climbing in its own height band; at the top of its band it glides out in a wide arc, faster, wings flexed, and comes back into the core lower. Birds farther than 900 m from the on-screen camera keep moving but stop animating their wings.
- **Dust**: a second instanced draw, about 790 stateless GPU particles on one shared card mesh (`sunfall.markers.raptorFlock.dustCard`) with the `dust_puff` shader. Its vertex hook works out every particle from the clock and lanes written once at build, so the dust costs no CPU per frame and writes no buffer after the draw is made. It draws a rotating, wandering, tapering funnel about 10-18 m wide at the ground and 70-140 m tall (from `radius` and `strength`). The funnel is dense in its lowest 30 m and thins into wisps above, with two twisted dust bands winding up the core. It also draws a skirt of dust thrown out along the ground, dry grass and leaves whirled up in it, and a faint scatter of motes and seed fluff rising toward the birds. The cards are soft and lit by sky and sun with a forward-scattering glow when backlit, and fade into the ground they meet. The dust moves on the gameplay clock, so it stands still while the editor is paused.
It runs in edit (while paused) and in play, on every peer locally; nothing it draws is replicated or saved.
## Placing it
```luau
local Course = require("sunfall.course")
for i, t in Course.THERMALS do
local marker = entity.spawn("thermal_marker_" .. i, { parent = group })
marker.localPosition = { t.x, 0, t.z } -- y is found from the terrain at start
marker.component.add("ThermalMarker", {
radius = t.radius, top = t.top, birds = t.birds, strength = t.strength, seed = i,
})
end
```
# course
The layout of Sunfall Ridge as data: the crest of the ridge, the launch ledge and the airborne start, the
meadow's landing zone and bullseye, the thermals and sink along the west face, the cloud sea's heights and the
sun's path over a flight (`sunAt(t)`, `sunDirection(azimuth, elevation)`). Helpers answer the crest at a z
(`crestAt`), the progress along the course (`progress`) and whether a point is in the meadow (`inMeadow`,
`meadowDistance`). The terrain graph, the scene build, the run, the HUD and the cinematic all require it, so
they agree on where everything is.
# Fence (scene module)
A short run of weathered split-rail fence for the edge of Sunfall Ridge's landing meadow: turned round posts with pointed tops, each leaning a little its own way, two split rails between each pair of posts in three tones of grey-brown timber, and a rail missing here and there where it has long since fallen.
The origin is the first post's foot; the run goes along +X. Inputs: `posts` (count), `spacing` (m), `drops` (comma-separated metres each post's foot stands below the origin, so the run follows the slope), `seed`. `sunfall.dressing.build` runs one along the meadow's uphill edge by the hut, reading the ground under each post.
# Forest (component)
The conifer forest on Sunfall Ridge's lower slopes, drawn instanced with distance levels of detail; put it on one entity at the world origin (the build's `dressing/forest`). It needs no sibling component and writes nothing to disk.
At start it walks a jittered 5.5 m lattice over the west face, the crest and the near east side and plants a tree wherever the baked landscape lays its `forest` surface (read from the terrain's own control textures through `sunfall.dressing.ground`, so trees and forest floor agree texel for texel), thinned by a two-scale clumping noise into stands and gaps. Toward the treeline the trees shrink and turn from spruce and fir to larch and stone pine; past it a few single stone pines, larches and mountain pines stand on the dry grass; dead snags stand in the dense forest. None grow on rock walls, on steep scree, below 420 m, above 1095 m, round the launch or in the meadow's landing circle. About 38,000 trees, built in ~0.3 s.
Each species and variant is one group, sorted into 128 m cells; as the camera moves (every 25 m) the cells are re-sorted, six groups a frame, into three instanced draws per part: near needle cards within 70 m, middle cards within 480 m, far canopy tiers out to `range`. Only the near level casts shadows, through the middle level's lighter mesh (`renderer.setShadowProxy`). Draws are registered only once their meshes are resident.
Fields: `seed`, `spacing` (m), `range` (m), `farShadows` (let the middle level cast too). Methods: `stats()`, `refresh()` (re-sort now round the camera or `ground.setFocus`), `suspend()` / `resume()` (drop and rebuild every draw, to measure the frame without the forest).
# GroundTable
Hands the ridge's ground material the landscape's layer textures. It sits on the `ridge` entity beside the `Terrain` (added by `land()` in `scenes/main.scene/build.luau`).
The Terrain wears a copy of `sunfall.dressing.ridgeGround`, and a material named on a Terrain is given the terrain surface contract but nothing of the landscape's table of surfaces. The material's file carries the table's numbers (tints, tilings, rules, which slice each layer reads); this component binds the three texture arrays (`layer_albedo`, `layer_normal`, `layer_mask`) from the slices the landscape wrote, and binds them again whenever the Terrain makes its copy again: a load, a cook, an edit of the shader.
The arrays are bound here rather than stated in the material's file because the world's validation reads an `array:` texture reference in a material's source as one asset reference that does not resolve, and refuses the push.
- `every`: frames between two looks at which material the ground wears (12).
- `:bound()`: true once the arrays are on the material the Terrain wears now.
Until the arrays are bound (a few frames after a load) the ground draws with the layers' tints alone.
# Hut (scene module)
A small weathered alpine herders' hut, for the uphill edge of Sunfall Ridge's landing meadow. Everything is modelled part by part with the quick geometry nouns so it reads at standing height: a dry-stone footing laid course by course from rough blocks (its lowest courses sunk so it meets a sloping meadow), log walls of round logs with overlapping, notched corners and sawn end grain, a plank door in a framed opening with iron strap hinges, ledges and a ring latch on a stone doorstep, a shuttered four-pane window, plank gables, a shingle roof laid shingle by shingle in staggered rows over roof boarding with a ridge cap, bargeboards and deep eaves, a dry-stone chimney with its cap slab, a plank bench on log legs along the front wall, and a stack of split firewood (pale split faces outward) under a small lean-to roof against the side wall.
The placement's origin is the middle of the floor at ground level; the door faces +Z. Inputs: `width` (m along the front), `depth` (m front to back), `seed` (which stones, logs and shingles). `sunfall.dressing.build` stands it outside the landing circle on the meadow's uphill (east) edge, the door turned toward the meadow.
# LaunchRamp (scene module)
The timber take-off ramp at Sunfall Ridge's launch ledge: a sloping deck of boards in three weathered tones over five joists and three bearers, edge boards along both sides and a rounded leading edge, standing on squared posts with cross bracing that reach down to ground falling away past the ledge (`posts` metres; buried where the ground stands higher). A box collider under the boards makes the deck walkable. At its back corner a stick carries a red-and-white wind streamer, a ribbon of eight strips that flies downwind and whips and twists, every pose a formula of `Time`.
The origin is the middle of the deck's back edge at ground level; the deck runs out along -Z, falling `slope` degrees. Inputs: `width`, `length`, `slope`, `posts`, `heading` (compass bearing the wind blows toward). `sunfall.dressing.build` places it at the north lip of `Course.LAUNCH`'s ledge, clear of the player spawn behind it.
# Meadow (component)
The landing meadow's grass and wildflowers: a GPU grass field drawn round the camera. Put it on one entity (the build's `dressing/meadow_grass`); it needs nothing else.
The shelf round `Course.MEADOW` is cut into 8 m tiles wherever the baked landscape lays meadow or dry grass on gentle ground. A tile's tufts and flowers are planted the first time the camera comes near it (deterministic per tile, so every peer plants the same field; up to ten tiles a frame) and kept as ready-made instance buffers. As the camera moves, the tiles in reach are joined into a handful of instanced draws: fine tufts within 22 m, coarser and sparser tufts out to 80 m, flowers within 45 m; past that the meadow turf texture carries the field. Inside the landing circle the sward is short and grazed; beyond it the grass stands knee-high and flowers gather in drifts (arnica and globeflower, gentian and campanula, edelweiss and saxifrage, cotton grass, alpine aster, and alpenrose patches toward the edges). Nothing casts shadows. The blades sway in gusts that roll across the field (`grass` shader).
Fields: `seed`, `density` (tufts per m² near the camera), `reach` (m from the meadow's centre). Methods: `stats()`, `refresh()`, `suspend()` / `resume()`.
# Rocks (component)
Sunfall Ridge's boulders, outcrops, scree, erratics and the meadow's landing target, drawn instanced with distance levels of detail; put it on one entity at the world origin (the build's `dressing/rocks`).
At start it places, from the baked landscape and `sunfall.course`: boulders and stones over the scree fans; outcrops along the edges of the rock bands, sunk well in; a scatter of boulders round the launch ledge (none in the take-off lane to its north); boulders on the meadow's rim, a few flat stones in its grass and five big erratics on the shoulder; and the landing target, a ring of limed stones `Course.MEADOW.target` metres in radius with a cross of stones at its centre, the mark real landing fields lay out. Every rock leans part-way into its slope and is sunk into it. About 6,000 rocks.
Each kind and variant draws three levels (about 1280, 320 and 80 triangles) chosen per rock by distance over size, re-sorted every 20 m of camera travel; only the near level casts shadows. Fields: `seed`, `range`. Methods: `stats()`, `refresh()`, `suspend()` / `resume()`.
# Windsock (scene module)
The meadow's wind indicator, built the way real landing fields mount one: a galvanised 6 m mast on a concrete footing with its base plate, bolts, collar and climbing steps, a swivel at its head, an arm and a steel hoop holding the mouth open, and a tapering fabric sock in five orange and white bands.
The sock is a chain of bands, each hung from the end of the one before, so it bends along its length. It streams toward `heading` (the compass bearing the wind blows toward, degrees clockwise from north, -Z), droops a little under its weight, swings a few degrees round the swivel and flutters, more toward the tail. Every pose is a formula of `Time`, so it moves in edit and play with no script.
Inputs: `height` (mast, m), `heading` (deg), `length` (sock, m), `mouth` (radius, m), `gust` (0 still .. 1 fresh breeze). The placement's origin is the foot of the mast on the ground. `sunfall.dressing.build` places it at `Course.WINDSOCK` with the evening breeze from the west-north-west.
# build (module)
Stands Sunfall Ridge's dressing in a scene. `scenes/main.scene/build.luau` calls it from its `dressing(world)` function (one call, right after `land(world)`), passing the world root; it spawns one `dressing` entity under that root (attribute `role = dressing`) and everything under it, so a rebuild replaces it whole and nothing else in the scene is touched.
Under `dressing`: `forest` (`Forest`), `meadow_grass` (`Meadow`), `rocks` (`Rocks`, the landing target included), and the placed scene modules `windsock` (at `Course.WINDSOCK`, streaming toward the east-south-east), `hut` (on the meadow's uphill edge, on the gentlest ground found outside the landing circle, door to the meadow), `fence` (a run beside the hut following the ground) and `launch_ramp` (on the launch ledge's north lip). Heights come from `sunfall.dressing.ground`, which reads the baked terrain in edit mode, so the build is fast (a fraction of a second) and re-runnable.
# canopy (shader)
The far level of Sunfall Ridge's conifers: every tree past a few hundred metres is a stack of jagged needle tiers and a trunk, a few dozen triangles built by `sunfall.dressing.conifers`, drawn instanced by `sunfall.dressing.Forest`. This shader colours them from the mesh's vertex colour (the species' needle green, darker under each tier, the trunk brown; alpha 1 on foliage, 0 on wood), breaks the tier faces into needle clumps with a world-space noise (`clumps`), and lights the crown's rim warm when the low sun stands behind the tree (`translucency`, `translucency_color`), so the far forest holds the tone and silhouette of the near needle cards.
Properties: `base_color`, `roughness`, `translucency`, `translucency_color`, `clumps`, `vertexBoundsDilation`.
# conifers (module)
Grows Sunfall Ridge's conifers as meshes, deterministically from a species, a variant (1-3) and a level of detail: Norway spruce, silver fir, European larch, Swiss stone pine, mountain (mugo) pine and a dead spruce snag. Each tree is a trunk with a flared foot and dead stubs on the bare bole, carrying whorls of branches whose length follows the species' crown profile (narrow cone, fuller cone, rounded column, dome); each branch is a run of alpha-cut needle-spray cards set in a V along it, drooping and turning up at the tip by species. Every card vertex carries a crown normal (out of the crown and up), the crown's self-shading in its colour and its freedom in the wind in its alpha.
Level 0 (near, ~1.3-3.2k triangles) has every whorl and two cards per segment; level 1 (middle, ~0.4-1k) every other whorl with longer, wider cards; level 2 (far, 24-160) is a stack of jagged needle tiers and a trunk drawn with the `canopy` shader. Needle and bark textures are alpineMaterials' (the copy the Tidewater library carries).
```luau
local C = require("sunfall.dressing.conifers")
local parts = C.parts("spruce", 2, 0) -- { { mesh, material } }: bark and needles, or the far canopy
print(C.triangles("fir", 1)) -- { near, middle, far }
```
`parts` makes each mesh once per session with `renderer.mesh.create` and holds it; a fresh mesh is kept for 5 s before it can be judged released. `material(key)` answers `needles:<species>`, `bark:<species>` or `canopy`. Called by `sunfall.dressing.Forest`.
# foliage (shader)
The needle sprays of Sunfall Ridge's conifers: alpha-cut spray cards (alpineMaterials' needle textures) drawn on the near and middle levels of the forest `sunfall.dressing.Forest` draws, and on the dwarf pines at the treeline.
The mesh (`sunfall.dressing.conifers`) gives every card a crown normal pointing out of the crown and up, so a tree shades as one volume; its vertex colour rgb is the crown's self-shading (darker inside and low down) and its alpha how freely a vertex moves in the wind (0 at the trunk, 1 at a tip). The card's own normal map bends that crown normal by `normal_detail`. When the low sun stands behind a crown the needles glow at the rim (`translucency`, `translucency_color`), which is what makes a conifer silhouette against an evening sun read.
The wind sways every copy in `vertex_clip`: a slow lean along `wind_dir` (the world x, z the breeze blows toward) and a quicker flutter across it, phased by where each tree stands so a gust crosses the forest. `wind_amount` is the metres a free tip moves, `wind_speed` the pace.
Properties: `base_color`, `roughness`, `alpha_cutoff`, `translucency`, `translucency_color`, `normal_detail`, `wind_dir`, `wind_amount`, `wind_speed`, `base_color_texture`, `normal_texture`, `vertexBoundsDilation`.
# grass (shader)
The meadow's grass and wildflowers on Sunfall Ridge's landing shelf: tufts of curved blades and flower stems drawn instanced round the camera by `sunfall.dressing.Meadow` (meshes from `sunfall.dressing.meadowMeshes`).
The mesh carries each blade's colour in its vertex colour, `uv.y` the share of the way from root (0) to tip (1), and `uv.x` 2 on flower petals. Gusts roll across the field along `wind_dir` as a travelling wave (`wind_amount` metres of lean at a tip, `wind_speed` the pace), every blade leaning with it and fluttering across it, more toward its tip. Roots sit in the sward's shade and tips catch the light; a slow world-space noise swings patches between lush green and sun-cured gold (`patchiness`, `dry_color`); blades seen against the low sun glow through (`translucency`, `translucency_color`).
Properties: `base_color`, `roughness`, `translucency`, `translucency_color`, `patchiness`, `dry_color`, `wind_dir`, `wind_amount`, `wind_speed`, `vertexBoundsDilation`.
# ground (module)
Reads Sunfall Ridge's baked landscape straight from `terrain/ridge.terrainData`, so the dressing can be placed in edit mode, at build time and at start without a live `Terrain`: the height texture (rgba32f, R metres) and the two control textures that say which surface covers each 5 m texel, in the graph's layer order (fields, forest, grass, meadow; rock, scree, gravel, snow). Trees, rocks and grass therefore stand exactly where the ground draws their surfaces.
- `height(x, z)` bilinear metres; `slope(x, z)` degrees; `normal(x, z)` three numbers
- `weight(layer, x, z)` and `weights(x, z)` the surfaces' 0..1 coverage (renormalise by their sum)
- `reload()` decodes the textures again after a re-cook (about 0.2 s; done lazily once per session)
- `setFocus(x, y, z)` / `focus()` the point the forest, rocks and grass sort their detail round instead of the active camera (set it before a capture from a fixed position, clear it with no arguments)
- `meshReady(handle)` whether a runtime mesh has been resident long enough to be named in an instanced draw
Used by `sunfall.dressing.build`, `Forest`, `Rocks` and `Meadow`.
# meadowMeshes (module)
The meshes and materials `sunfall.dressing.Meadow` draws the landing meadow's grass field with. `tuft(0)` is a tuft of eighteen curved, twisted blades of three segments (blade colour in the vertex colour, root-to-tip in `uv.y`), `tuft(1)` a coarser nine-blade tuft for the far ring; both are built 0.5 m tall and scaled per instance. `flower(name)` draws a wildflower from alpineMaterials' flower atlas on crossed cards (gentian, edelweiss, arnica, alpenrose, saxifrage, cottonGrass, campanula, globeflower, alpineAster) or the alpenrose shrub from the shrub atlas (`alpenroseShrub`). `material("grass")` is the `grass` blade shader; `material("flowers")` / `material("shrubs")` the `foliage` card shader on the atlases. Everything is made once per session and held.
# ridgeGround (material)
The material Sunfall Ridge's `Terrain` (`ridge`, placed by `land()` in `scenes/main.scene/build.luau`) wears: the `ridgeGround` shader with the landscape's own layer table and the wall, turf and outcrop settings.
A material named on a `Terrain` is bound the terrain surface contract (field rect, ground normal, control weights, ground masks, macro colour) and nothing of the landscape's layer table, so this material carries the table itself: `layerN_tint`, `_size`, `_rule`, `_slices`, `_mean`, `_maskmean`, `_tilt` The three `layer_albedo` / `layer_normal` / `layer_mask` texture arrays are not in this file: `sunfall.dressing.GroundTable`, on the same entity, binds them from the landscape's slices each time the Terrain makes its copy of this material. The numbers are copied from the stock surface the engine builds for the landscape. When the graph's `surfaces` change (a texture, a tint, a tiling, a layer added or reordered), copy them again: clear `material` in `land()`, let the scene rebuild, read `renderer.material.describe(entity.find("ridge").component.get("Model").material)` and write its `layer*` properties here, then set `material` back. The Terrain logs that this material "replaces the landscape's table": that is expected, the table is here.
# ridgeGround (shader)
Sunfall Ridge's ground surface: the engine's eight-layer terrain splat surface (`terrainSplat`, copied whole, so the landscape's layer table, hex tiling, far reads, settle, biplanar steep faces and baked ground masks all still work) with what the ridge needs on top, in the landscape's layer order (0 fields, 1 forest, 2 grass, 3 meadow, 4 rock, 5 scree, 6 gravel, 7 snow):
- **The rock.** The rock layer is a photographed cliff face (Poly Haven's marble_cliff_05, CC0: colour, normal and the light its cracks hold) read at the size of the cliff, not of the scan: one repeat covers `cliff_macro_size` metres, so the scan's cracks, blocks and stained seams become fracture systems and buttress faces seen from the air. A second read, turned and at another size, takes over in patches and both are bent by a slow noise, so no repeat lines up along a wall; close to the rock a third read at `cliff_near_size` gives it its grain. The scan turns the normal the engine lights (`cliff_relief`), darkens its cracks (`cliff_cavity`) and is read through the planes the broad shape of the ground faces, on walls and on rock that lies down alike. Its three maps ride as the last slice of the layer arrays (`cliff_slice`, set by `GroundTable`).
- **The wall.** On steep ground the rock takes the tones of bedded dolomite in the face's own frame: beds of irregular thickness (`bed_spacing`) in packets of cream and grey (`rock_cream`, `rock_grey`) whose edges ease into each other, a lip and an undercut on the beds that stand out, grey-black weathering in broad ragged fields (`streak_amount`, `streak_dark`), paler fresh rock, ochre scars (`ochre_amount`) and grass on the bed tops where the face is not sheer. Nothing on the wall is a drawn line running its height: the joints, fractures, chimneys and water curtains an earlier version drew were what read as streaks pulled down the face.
- **The turf.** Fields, grass and meadow carry sweeps of lighter and darker grass, sun-cured patches, flower drifts, worn paths and cattle terracettes. Grass on a slope is thinner and browner than the pasture's, nearer the rock's own tone.
- **Who holds a slope.** The landscape draws its surfaces in smooth-edged patches tens of metres across, which lay on the hillsides like a camouflage print. Here its weights are read a few metres to one side by a noise (`edge_fray`), and turf, rock and scree share a slope by the lie of the ground: where the landscape leans toward turf the grass takes the gentle ground and leaves the steep to the stone, with ragged edges a few metres across. Scree is the wall's own stone (`scree_tone`), and the forest floor's red-brown litter is held to brown-olive (`floor_tone`) so it does not turn mauve in shadow where no tree stands on it. The landing field (`landing_clear`) and the launch (`launch_clear`) keep the landscape's own edges. Limestone outcrops still break the turf, and the forest floor on slopes past `forest_steep` gives way to grass and speckles of rock; the trees still read the baked forest weight.
Steep ground is read through the side planes from `triplanar_slope` (38 on the material). Worn by the `Terrain` of the main scene through `sunfall.dressing.ridgeGround` (material).
# rock (shader)
The boulders, outcrops, scree stones and erratics of Sunfall Ridge, and the limed stones of the meadow's landing target. alpineMaterials' lichen granite (albedo and normal) is projected from the three world axes (`tile` metres a repeat), so a rock mesh needs no UVs and no seam shows however a copy is turned; the three reads are blended by the normal and their normal maps folded onto the surface (`normal_scale`). Up-facing parts carry moss and lichen in noisy patches (`moss`, `moss_color`); the mesh's vertex colour red is each rock's cavity shading (crevices and the underside where it meets the ground darker); `whitewash` limes a stone white with its grain showing through, for the landing target.
Drawn by `sunfall.dressing.Rocks` on meshes from `sunfall.dressing.rocks`. Properties: `base_color`, `tile`, `normal_scale`, `roughness`, `moss`, `moss_color`, `whitewash`, `contact`, `base_color_texture`, `normal_texture`, `vertexBoundsDilation`.
# rocks (module)
Boulder meshes for Sunfall Ridge, grown from a seed at three levels of detail (about 1280, 320 and 80 triangles) with the same shape at each: an icosphere squashed to the kind's proportions, roughened with layered noise, then cut by a handful of random planes so its faces break flat and angular the way split granite does, its foot flattened to sit into the ground. Each vertex's colour carries its cavity shading. Kinds: `boulder`, `slab` (flat: ledges, the meadow's flat stones), `outcrop` (tall, blocky, many cuts), `stone` (small: scree and the landing target). Four variants each.
`mesh(kind, variant, lod)` answers a held runtime mesh; `material("granite")` the `rock` shader on alpineMaterials' lichen granite, `material("limed")` the same whitewashed for the landing target. Called by `sunfall.dressing.Rocks`.
# game
Sunfall Ridge's run as shared state. `Game.state` holds the phase (`title`, `cinematic`, `flight`, `result`),
the pilot's instruments (time and light left, altitude, climb rate, airspeed, bank, thermal state, distance and
bearing to the meadow), the full-screen fade and the last flight's `Result`. The `Run` component writes it every
frame; the UI, the sound and anything else read it and listen with `Game.on("phase" | "result" | "thermal" |
"skip" | "request", fn)`. Screens ask the run for a flight, a retry, the title or a skip with
`Game.request(what)`; the run drains them with `takeRequests()`. It owns no entities, so any script may require it.
# intro
Sunfall Ridge's two films as cutscene definitions for `cutscene.play`: `title()`, the slow drift along the
west face the title screen sits over, and `opening()`, the 19 second opening cinematic (the cloud sea and its
racing shadows, a pass over the cloud tops, the climb to the launch summit, the pilot on the ledge).
`OPENING_SECONDS` and `TITLE_CARD` tell the UI when the title card stands. The `Run` component plays them.
# look
Sunfall Ridge's picture, as a scene setup: the light the sky gives back to what the sun does not reach
(`skyLight`), ambient occlusion and contact shadows, exposure that follows the sun down to dusk (its
`maxEV` of 3.5 lets it open up enough that the blue-hour ending stays readable), a soft `bloom` round the
low sun and the brightest cloud rims, the film `grade` (`sunfall.look.grade`: saturation the AgX display
curve takes out of a sunset put back, a filmic S-curve on luminance, cool shadows and warm highlights, a
floor under black, a light vignette), temporal anti-aliasing, and debanding for the sunset's gradients.
The scene places it beside its own sun, physical atmosphere, valley haze (a height-pooled
`VolumetricLighting` medium that also throws the sun's shafts), cloud sea and lens (`LensFx`: a restrained
flare and a fine grain), all in `scenes/main.scene/build.luau`'s `sky()`. The `Run` component drives the
sun through the flight from its `SUN_LOOK` table and, in `writeSun`, keeps the sky's own sun constant
through sunset so the twilight and the afterglow appear on their own.
# SunGlow
Draws the sun a player looks at in Sunfall Ridge's sunset. The atmosphere's own solar disc is held to a few times the sky's brightness, which after exposure and the display curve reads as a small pale grey disc; SunGlow draws the real thing over it: a small, very bright core (white-yellow high up, gold, orange and finally a dim red ball at the horizon), a tight aureole, a wide warm halo bleeding into the sky, and faint diffraction rays, bright enough that bloom and the lens flare fire on it. It sinks behind the cloud deck's far edge and goes out by -1 degree.
Put it on the entity carrying the sun's directional `Light` (the scene's `sun`); it reads that Light's direction and `enabled` and needs nothing else. It runs in play and in edit.
## Fields
| Field | Default | Meaning |
|---|---|---|
| `strength` | 1 | Overall brightness of the drawn sun and its glow (0 hides it). |
| `distance` | 9500 | Metres from the camera the card is placed; the shader puts its depth at the far plane, so every surface any camera draws (terrain, wing, pilot) hides it, whatever that camera's far distance. |
| `deckReach` | 30000 | Metres to the cloud deck's far edge (the deck's top is `sunfall.course`'s `CLOUDS.top`). |
## How it draws
One instanced draw of one card with `look/sun_glow.shader`, additive, writing no depth, queue 2950 (under the other blended surfaces). The shader stands the card along the sun's direction from the camera every frame, so no entity moves and nothing is recorded into the scene. The component writes the draw's four lanes (direction, strength, deck top, reach, distance) only when the Light has turned, into a table made once: nothing is allocated per frame. Buffers are registered a few frames after they are made and freed a few frames after the draw is dropped.
# bloom
The glow round the low sun and the brightest cloud rims in Sunfall Ridge: the engine's bloom shader
(`@builtin::shaders.post.bloom`) on the scene layer, run on the scene's light before the display curve so
only light well above white (the sun, its glare on the cloud tops) spreads. A high threshold and a low
intensity keep it a soft halo rather than a haze over the frame. Applied by the `look` scene setup.
# filmGrade
Sunfall Ridge's colour grade, a post-process shader in display space (it reads the code values the
AgX display curve wrote). It puts back the saturation AgX bleaches from a bright sunset sky (`saturation`,
with `vibrance` lifting muted colours more than vivid ones), applies an S-curve to luminance alone about
`pivot` (`contrast`) so hues hold, cools the shadows toward `shadowTint` and warms the highlights toward
`highlightTint` by `splitAmount`, keeps a `blackFloor` under black so the shaded face never crushes, and
darkens the corners by `vignette`. Used by `sunfall.look.grade`, the post effect the look setup applies.
# grade
Sunfall Ridge's film grade, applied by the `look` scene setup: the `sunfall.look.filmGrade` shader on the
scene layer (so the HUD and menus keep their own colours), after the scene and its bloom and before the UI.
It restores the colour the AgX tone curve takes out of a sunset sky, adds a filmic S-curve on luminance,
cools the shadows and warms the highlights, keeps a floor under black and adds a soft vignette. The values
it runs with are stated by the setup's `grade` member.
# Sail cloth
The cloth of Sunfall Ridge's hang glider: a sail that moves in the air and is drawn as a sewn sail.
**How it looks.** Off-white Dacron (or whatever `base_color` says) cut into panels, one between each pair of battens and three along the chord, each a shade apart from its neighbours; a doubled row of stitching where panels meet; a fine ripstop grid up close. With the sun behind the sail the cloth glows (`emissive`, `emissive_intensity`) and the seams and battens stand dark in the glow.
**How it moves.** The leading edge is held on its tube and does not move. Toward the trailing edge the cloth ripples, most between two battens and little on one, in waves that run back along the chord five and nine times a second at cruising speed. Between battens the panels fill and ease, deeper as `load` rises (a steep bank, strong lift). `phase` is the clock: whoever owns the wing advances it with the airspeed, so a faster wing flutters faster and a paused world holds the cloth still.
**What a mesh must carry.** Its place on the sail in its UV: `uv.x` along the span (0 at the keel, 1 at the tip) and `uv.y` along the chord (0 leading edge, 1 trailing edge), the same for every part of one sail, so the top cloth, batten pockets and trailing tape that lie on each other move as one. The mesh is laid out with the span along X (either way from the keel at x = 0), the chord back along -Z and the wing's up along +Y.
**Where it is used.** `sunfall.wing` builds the sail's meshes and wears this on the top cloth, tips, leading panel, pinstripe, batten pockets, trailing tape and undersurface, and drives `phase`, `load` and `emissive_intensity` from the nearest wing.
Properties are listed with their units in `properties.yaml`.
# sun_flare (shader)
The lens flare the low sun of Sunfall Ridge throws: a post-process pass over the scene's light, in the frame's optics stage before the grade and before the interface is drawn, so the HUD is never flared. `SunGlow` registers it and writes `sunDir` whenever the sun moves.
It draws, scaled by how much of the sun the camera sees:
- six soft ghosts of different sizes and tints along the line from the sun through the frame's centre (`ghosts`);
- a faint ring round the sun with its edges split in colour (`halo`, `haloRadius`);
- an anamorphic streak through the sun across the frame, cooler than the sun (`streak`).
The cover test reads thirteen taps over the sun's disc on screen: a tap counts where the scene's depth is empty sky (the mountain, the wing and the pilot all hide it) and the light that reached the frame there clears `gate` (a cloud in front, or the deck the sun sinks into, leaves it dim). The share of taps that count is the flare's strength and their colour its tint, so the flare reddens with the sun, fades as the mountain or the wing slides over it and goes out when the sun is under the cloud. `nominal` is the sun's light the flare is tuned on: a dimmer sun throws a weaker flare. Off screen or behind the camera it draws nothing.
Cost: one full-screen pass at output size, 26 texture reads a pixel (13 depth, 13 colour, all at the same few texels) plus the arithmetic for six ghosts, a ring and a streak.
# sun_glow (shader)
The low sun of Sunfall Ridge as a player sees it: a small, limb-darkened disc many times brighter than the sky (bright enough that bloom and the lens flare fire on it), a tight aureole hugging it, a wide warm halo that bleeds into the sky around it, and faint six-point diffraction rays. It is one camera-facing card drawn additively (`SunGlow` makes the draw), which the vertex hook stands far along the sun's direction from the camera, so no entity moves and the mountain, the wing and the pilot hide it by the depth test.
The colour follows the sun's air mass (Kasten-Young): white-yellow high up, gold and orange lower, a dim red ball at the horizon. It goes out between -0.35 and -1 degrees. The cloud deck's far edge, seen from the camera, cuts the disc and swallows the glow as the sun sinks into it.
Lanes: 0 = the direction toward the sun (xyz) and overall strength (w); 1 = the cloud deck's top (x), its reach (y) and the card's distance (z). Properties: `core`, `disc_radius`, `aureole`, `halo`, `rays`, `extent` (the card's angular half-size) and `vertexBoundsDilation` (20 km, because the hook places the card far from its draw's own bounds).
# dust_puff (shader)
The dust devil a `ThermalMarker` draws, as stateless GPU particles on soft camera-facing cards. The vertex hook places every particle from the clock and its own lanes: each particle loops a life and is re-seeded every cycle, and each cycle's wrap is anchored to the frame clock so motion vectors stay true. There are five layers:
- a skirt of dust thrown out along the ground;
- a dense foot drawn in and spun up the core;
- a column that rises, widens and thins out with height, its particles riding two twisted bands so the rotation reads from far off;
- dry grass and leaves whirled up and flung out;
- motes and seed fluff rising high toward the birds.
The funnel's foot wanders a few metres and the column follows it late, so it snakes.
The fragment lights warm dust by the sky and by the low sun with a forward-scattering phase, so the column glows when backlit. Thick cores shade themselves. Puffs fade into the ground they meet (soft particles), near the camera, over their life and with height.
Lanes: 0 = (particle seed, layer), 1 = (marker seed, strength, column height, foot width), 2 = the ground point. Properties: `tint`, `mote_tint`, `opacity`, `glow`, `vertexBoundsDilation` (320 m, because the hook places particles far from the card's own bounds).
# raptor (shader)
The surface of the soaring raptors a `ThermalMarker` draws: engine-lit dark-brown plumage with paler underwing coverts, a pale head and ruff, the thin flight feathers glowing warm when the low sun is behind them. Its vertex hook poses every copy of the shared rest-pose bird mesh (`sunfall.markers.raptorFlock`) from that copy's instance lanes, so one instanced draw holds a whole flock with every bird flapping, gliding and banking on its own.
Lanes: 0 = (shoulder angle, wrist angle, primary spread, tail spread), 1 = (hand sweep, tip curl). The mesh carries its part in `uv.x`, a primary's place in the fan (or the tail's lateral share) in `uv.y`, and how far along a primary a vertex stands in colour alpha. Properties: `roughness`, `transmission` (sun through the feathers), `albedo_scale`, `vertexBoundsDilation`.
# raptorFlock (module)
The shared drawing assets every `ThermalMarker` uses. Each is built once per session and held, so every marker shares them:
- `mesh()`: a rest-pose griffon-vulture-like bird with a 2.6 m span. It has a lofted body with a pale head, a ruff and a hooked beak, a fanned tail, broad airfoil wings with a serrated trailing edge, and seven fingered primaries. The plumage is in vertex colours. About 1.8k vertices and 2.8k triangles.
- `material()`: the `raptor` shader's material, which poses each instance.
- `dustCard()` and `dustMaterial()`: the unit card and the `dust_puff` material the dust devil's particles are drawn with.
`counts()` reports the bird mesh's vertices and triangles. `reset()` drops the cache after an edit.
# pilotProne
A static full-body pose for the Sunfall pilot under a hang glider: prone, head to the nose and
lifted about 10° to look ahead, legs straight back and together with the toes pointed, both
arms reaching forward and down to the base bar with soft elbows. Built from the library idle's
first frame on the humanoid rig (the `Hips` turned a half turn about the body's up-forward
diagonal), so it plays on any body with that rig.
The `sunfall.pilot` avatar plays it from its `Glide` animator layer while the synced `Gliding`
parameter is on (set by `sunfall.wing` on the owner while the wing is open).
# pilotLook
Dresses every player in Sunfall Ridge as a hang-glider pilot: the `sunfall.pilot` avatar (the
library humanoid's rig, so the CharacterController, the locomotion and glideKit's poses all
still work) wearing a full-face helmet with a smoked visor and an orange crown stripe (parts of
the avatar), a charcoal base layer, a dark-teal soft-shell jacket, charcoal trousers, black
leather gloves and brown leather boots (garments in `sunfall.package/pilotKit`).
A person's own account look would otherwise be composed onto their body when they join, so the
pilot is laid on as the game's override rules on the body's `Appearance` component (see
`avatarAppearance.override`): every peer composes the same pilot, whatever the person wears
elsewhere. Rules compose over a document, so the body also starts from a bare pilot document,
which a person's account look replaces and the rules then dress again.
## Use
In a player prototype's build, on the body:
```luau
local Look = require("sunfall.pilotLook")
body.component.add("Asset", { source = asset.resolve("sunfall.pilot", "avatar") })
body.component.add("Appearance", { document = Look.documentJson(), rules = Look.rulesJson() })
```
At runtime, on a live avatar root: `Look.apply(body)`. `Look.rules()` returns the rules table;
`Look.AVATAR` and `Look.GARMENTS` name what it wears.
# progress
Sunfall Ridge's player progression: the feathers each flight earns (0 to 3), the bests, and the
gliders and trails they unlock. `require("sunfall.progress")`.
## Where it saves
Each player's profile is one record at `sunfall/profile` in that player's own `runtime_data`
store (`runtime_data.player(runtime_data.localId())`). The engine keeps that store on ZeroMind,
so a player's feathers, bests and choices are there again when they leave and come back, on any
device, and no other player can write them. A signed-out session (`localId()` nil) has no store;
it plays with a profile held for the session only, and `Progress.persistent()` reads false.
## API
- `Progress.profile()` -> `{ bestScore, bestFeathers, totalFeathers, flights, landings, glider, trail }`
- `Progress.gliders()` / `Progress.trails()` -> ordered `{ id, label, description, need, unlocked, selected }`.
Gliders (glideKit styles): `hangGlider` 0, `paraglider` 3, `birdWings` 7, `wingsuit` 12 feathers.
Trails (glideKit trails): `none` 0, `wingtips` 1, `feathers` 4, `streaks` 8, `rainbow` 14.
- `Progress.select(kind, id)` -> boolean: `kind` is `"glider"` or `"trail"`; a locked or unknown id is refused.
- `Progress.award(result)` -> `{ newBest, unlocked = { label } }`: counts the flight, adds the
result's feathers (and a landing when `outcome == "landed"`), raises the bests, saves, and names
every glider or trail the new feather total unlocked.
- `Progress.onChanged(fn)` -> unsubscribe: `fn(profile)` after an award, a selection, a reset, or a
save from another session of the same player.
- `Progress.reset()`: back to a first flight.
- `Progress.persistent()`: whether a per-player store backs the profile.
## Who calls it
The `Run` component awards a finished flight and reads the selected glider and trail; the
`SunfallUi` title screen lists the pickers and selects; the result screen shows what was unlocked.
# ambience_evening
Evening air on the mountain: a quiet bed of distant birds and insects. `SunfallAudio` loops it under the title and the flight. Generated with the engine's audio service, then trimmed and levelled.
# bird_buzzard_3
A buzzard's call, mono so it can be placed in 3D. `SunfallAudio` plays it from the birds circling a thermal, and sparsely on the title. Generated with the engine's audio service.
# bird_eagle_1
An eagle's call, mono so it can be placed in 3D. `SunfallAudio` plays it from the birds circling a thermal, and sparsely on the title. Generated with the engine's audio service.
# bird_hawk_2
A hawk's call, mono so it can be placed in 3D. `SunfallAudio` plays it from the birds circling a thermal, and sparsely on the title. Generated with the engine's audio service.
# crash
The impact of a crash on the ridge, with a synthesized low thud under it. `SunfallAudio` plays it when a flight ends in a crash.
# music_dusk
The dusk drone: a 74 second loop with a slow pulse. `SunfallAudio` brings it up as the light runs out and the flight music thins. Generated with the engine's audio service and made seamless with a crossfade.
# music_flight
The flight's music: a 126 second loop. `SunfallAudio` plays it through a flight and fades it toward the dusk drone as the sun sinks. Generated with the engine's audio service and made seamless with a crossfade.
# music_title
The title's music: a 72 second loop. `SunfallAudio` plays it on the title screen and through the opening cinematic. Generated with the engine's audio service and made seamless with a crossfade.
# sting_dark
The sting for a flight that ran out of light. `SunfallAudio` plays it once when the result is `dark`. Generated with the engine's audio service.
# sting_landed
The sting for a landing in the meadow. `SunfallAudio` plays it once when the result is `landed`. Generated with the engine's audio service.
# sting_landed_best
The sting for a three-feather landing. `SunfallAudio` plays it in place of `sting_landed` when the flight earns all three feathers. Generated with the engine's audio service.
# sting_outlanding
The sting for landing out, short of the meadow. `SunfallAudio` plays it once when the result is `outlanding`. Generated with the engine's audio service.
# sting_swell
A rising swell for the opening cinematic's title card. `SunfallAudio` plays it as the card comes up. Generated with the engine's audio service.
# thermal_swell
A soft swell of rising air. `SunfallAudio` plays it once as the pilot enters a thermal. Generated with the engine's audio service.
# touchdown
Feet and harness meeting grass. `SunfallAudio` plays it on a landing, in the meadow or out of it. Generated with the engine's audio service.
# ui_click
A short click for the screens' buttons. `SunfallAudio` plays it on every request a screen sends (fly, retry, title, skip). Generated with the engine's audio service.
# vario_beep
The variometer's climb beep: a synthesized 800 Hz tone. `SunfallAudio` plays it faster and higher (about 500 to 1200 Hz) the faster the glider climbs, and not at all in sink.
# vario_sink
The variometer's sink tone: a synthesized low tone. `SunfallAudio` brings it in when the glider sinks faster than its normal glide.
# wind_air_l
The bright layer of the airspeed wind for the left ear (the right side is kept 18 dB down). `SunfallAudio` raises it with airspeed and leans it left and right with the glider's bank. Made from two generated wind takes.
# wind_air_r
The bright layer of the airspeed wind for the right ear (the left side is kept 18 dB down). `SunfallAudio` raises it with airspeed and leans it left and right with the glider's bank. Made from two generated wind takes.
# wind_body
The dark body of the airspeed wind. `SunfallAudio` loops it through a flight and raises its level and pitch with airspeed. Made from two generated wind takes.
# wind_mountain
Wind over the ridge, heard from the ground. `SunfallAudio` loops it on the title and in the cinematic. Generated with the engine's audio service, then trimmed and levelled.
# style
Sunfall Ridge's UI look, shared by every screen the `SunfallUi` component builds:
`require("sunfall.ui.style")`.
- **Palette**: warm gold `#ffc56b`, ember `#f0703a`, deep dusk blue `#141a2e`, off-white text,
a green-gold climb and a cool sink colour, plus the translucent dusk glass the HUD plates use.
- **Type**: `serif` (EB Garamond, fetched from ZeroMind's Optional Fonts on first use, falling back
to Georgia/serif) for titles and headlines, `sans` (Arimo) in wide-tracked capitals for captions.
`shadow` / `shadowSoft` are the text halos that keep type legible over a bright sky and a dark
valley alike.
- **Node helpers**: `text`, `caps`, `serifText`, `svg` return widget nodes; `enter`, `leave`,
`pulse` return `animation` tables; `still()` is the reduced-motion override.
- **Glyphs** (inline SVG strings): `featherSvg`, `quillSvg`, `lockSvg`, `chevronSvg`,
`sunDialSvg(light, …)` (the sun sinking along its arc to the horizon) and
`compassSvg(bearing, …)` (the meadow mark on a ±90° tick arc).
- **Formatting**: `clock` (m:ss), `thousands`, `distance` (m / km).
It registers nothing; it only returns data and nodes.
# wing
Sunfall Ridge's hang glider for glideKit: a modern kingposted delta, about 10 m span with a
128° nose angle.
- **Sail:** a cambered, washed-out top surface in off-white Dacron, an orange leading-edge
panel and a red pinstripe, red tip panels, eight raised batten pockets a side, a trailing edge
that pulls in between the battens, a dark trailing-edge tape, and an orange double
undersurface over the front 62% of the chord. The cloth takes subsurface light, so it warms
and glows when the low sun is behind it.
- **Airframe:** sleeved leading edges, an aluminium keel with nose plate and cone, a crossbar
inside the double surface, a kingpost with upper wires (nose, tail, crossbar junctions,
outboard), a control frame (A-frame) of two downtubes and a base bar with black grips, lower
flying wires (nose, tail, sides), dive sticks near the tips and tip fairings.
- **Pilot:** a charcoal harness pod with a teal back panel, orange piping and a reserve
container, laid prone around the pilot's body, and a hang strap from the pod to the carabiner
on the keel's hang point. The prone body itself is the `sunfall.pilot` avatar's `Glide`
animator layer (the `pilotKit/pilotProne` clip), switched on by its synced `Gliding`
parameter, which this module sets on the peer that owns the body while the wing is open.
- **Motion:** the wing banks and pitches with the flight as glideKit's own did (glideKit's
flight mount), unfolds along its span as it opens, and each half flexes slowly about the keel
so the sail breathes. One per-frame step serves every wing in the world; it also keeps the
hang strap between the pod and the keel and tidies the pod away when glideKit folds the wing.
- Meshes and materials are built once per engine and shared by every glider.
## Use
```luau
require("sunfall.wing").install() -- once, on every peer, before a glider opens
```
`install()` registers the model with glideKit under the existing style id `hangGlider`
(glideKit's `models.register` replaces a built-in), so `Glider { style = "hangGlider" }`,
`Glide.setStyle("hangGlider")` and saved progression keep working, and gives that style the
pose `sunfallProne` (glideKit's attitude only; the body pose comes from the avatar). It is safe
to call more than once. Call it from a scene entrypoint or from a component's `start`, so it
runs in every client.
The pilot reads right only on a body wearing the `sunfall.pilot` avatar (see
`sunfall.pilotLook`); another body keeps its own animation under the wing.
`gripPoints()` gives where the base bar's grips are in the flight frame (metres from the hips:
+X the left wing, +Y up, +Z the nose); `PRONE` is the prone turn in the body's own space.