Spot lights for mods (render.set-spot-lights, API level 16): surfaces lit in the cone, a volumetric beam stopped by depth (#60); film capture (render.capture-*, set-film-quality, API level 17): fixed-step clock, frames piped to ffmpeg or PNGs, offline audio, no chat in the frames (#58); the client builds without the mods feature again

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 09:28:05 +03:00
committed by airdef
parent 9c33fdae2c
commit 251bb6777f
20 changed files with 1917 additions and 48 deletions
+65 -1
View File
@@ -588,7 +588,7 @@ A camera the game renders the world from besides the player's eye (AirDef fork):
| `yaw` | `f32` | Degrees, as the player's: yaw 0 looks south (+z), pitch 90 down. |
| `pitch` | `f32` | |
| `fov` | `f32` | Vertical field of view, degrees (1 to 110). |
| `width` | `u32` | The picture's size in pixels (16 to 1920 × 16 to 1080). |
| `width` | `u32` | The picture's size in pixels (16 to 3840 × 16 to 2160). |
| `height` | `u32` | |
### record `point-light`
@@ -638,6 +638,65 @@ A piece of smoke or exhaust trail (AirDef fork): a tube from `a` to `b` (equal e
| `rise` | `f32` | Blocks per second it floats up (negative sinks). |
| `clear` | `f32` | Radius in blocks of the clear tunnel it leaves in fog and cloud, filling back in over `life` (0 none). |
### record `spot-light`
A directional light with a visible beam (AirDef fork): a searchlight, a headlight. The HD lighting lights the surfaces and flying things inside its cone (smoothly from the inner to the outer angle, down to nothing at `range`) and draws the beam as a translucent volume lit from inside: it scatters in the air (more in fog and smoke, a faint artistic one in clear air), the world hides it where it is in front, and the camera may stand inside it. The light does not look for walls: send `range` as far as the beam is free (a cast along the axis) so it stops where the land stops it.
| Field | Type | |
| --- | --- | --- |
| `id` | `u32` | Stays the same while the light lives: the game moves it smoothly. |
| `x` | `f64` | The apex, in the lens. |
| `y` | `f64` | |
| `z` | `f64` | |
| `dx` | `f32` | Where it points (any length but zero; it is normalised). |
| `dy` | `f32` | |
| `dz` | `f32` | |
| `color` | `tuple<f32, f32, f32>` | Linear RGB, 0 to 1. |
| `intensity` | `f32` | Brightness: about what it lights one block away (0 to 100000). |
| `range` | `f32` | Nothing past this many blocks (1 to 1024). |
| `inner-angle` | `f32` | Half angle in radians where the light is at full strength (0.005 to 1.2). |
| `outer-angle` | `f32` | Half angle in radians where it has faded to nothing (past the inner one, to 1.4). |
| `beam` | `f32` | How visible the beam is in the air, 0 (the light only lights things) to 1. |
### record `capture-options`
What `capture-start` records (AirDef fork, API level 17).
| Field | Type | |
| --- | --- | --- |
| `folder` | `string` | A folder under the game's home (letters, digits, `-`, `_` and `/`; no `..`); made if missing. The result lands in it. |
| `name` | `string` | The file name without its extension (letters, digits, `-`, `_`, `.`). |
| `fps` | `u32` | Frames a second of the picture (1 to 120). |
| `width` | `u32` | The picture's size in pixels; 0 keeps the window's. An offscreen game is resized to it, a window asked to be (what it gets is in the state). |
| `height` | `u32` | |
| `crf` | `u32` | x264 quality, 0 (lossless) to 51; 14 is visually clean. |
| `audio` | `bool` | Mix the sounds the mod plays (`play-sound`) into the file's audio track, heard from the main view's camera at the capture's own time. |
| `warmup` | `u32` | Frames drawn and thrown away after a cut (a new `set-main-view` id) so the anti-aliasing and the volumes settle in the new shot (0 to 32). |
### enum `capture-phase`
Where a capture is.
| Case | |
| --- | --- |
| `idle` | Nothing running (or never started). |
| `arming` | Asked; waiting for the picture to reach the size. |
| `recording` | Frames are being rendered and written. |
| `encoding` | The frames are written; the encoder is closing the file. |
| `done` | Finished: `file` is the result. |
| `failed` | Stopped by an error or cancelled: `message` says why. |
### record `capture-state`
| Field | Type | |
| --- | --- | --- |
| `phase` | `capture-phase` | |
| `frames` | `u32` | Frames written so far. |
| `width` | `u32` | The size of the frames, once known. |
| `height` | `u32` | |
| `file` | `string` | The result: the MP4, or the folder of the PNG sequence when no `ffmpeg` was found. Empty until `done`. |
| `message` | `string` | An error, or a note about the result (no encoder, no audio). |
| Function | Signature | What it does |
| --- | --- | --- |
| `set-hud` | `func(shapes: list<shape>)` | Replaces the mod's HUD shapes: up to 1024, drawn every frame in order over the HUD (after the hotbar, under chat and screens), hidden with the HUD (F1). An empty list removes them. |
@@ -672,6 +731,11 @@ A piece of smoke or exhaust trail (AirDef fork): a tube from `a` to `b` (equal e
| `set-lighting` | `func(lighting: lighting)` | Switches the HD lighting on or off for this mod's world, with its exposure and bloom; off, the world is drawn as the game draws it. |
| `set-time-override` | `func(day-time: option<u64>)` | Shows the world at this time of day (AirDef fork): the sky, the sun and moon, the sky light and the fog, as `day-time` ticks (24000 a day, as `clock`). Only what the player sees changes: the world's own clock, its saves and its rules do not. None shows the world's own time. |
| `set-smoke` | `func(clock: f64, segments: list<smoke-segment>) -> bool` | Replaces the mod's smoke: up to 4096 segments, `clock` being now in ticks (the game shows the age between the last two calls). Returns whether the HD renderer draws them; when it does not (the effects preset, HD smoke off), the mod draws its own smoke. |
| `set-spot-lights` | `func(lights: list<spot-light>) -> bool` | Replaces the mod's spot lights: up to 32 (the nearest 16 are drawn), interpolated per id between the last two calls. Returns whether the HD renderer draws them with their beams; when it does not (the effects preset, HD off), the mod draws its own beam if it wants one. |
| `capture-start` | `func(options: capture-options) -> result<_, string>` | Records the screen frame by frame (AirDef fork), at a fixed time step whatever the speed of the machine: while it records, the game clock advances exactly `1 / fps` seconds a frame (ticks, interpolation, the mod's `tick`s and the sounds with it), so a slow frame is a longer wait and not a skipped one. The frames are read back from the GPU and encoded to H.264 MP4 by `ffmpeg` (found on the `PATH`, or named by `HORIZON_FFMPEG`) through a bounded queue, never held in memory; with no `ffmpeg` they are written as a PNG sequence. Returns an error for a capture already running, a bad name, or an invalid size. Only the game's own files are written, under its home. |
| `capture-stop` | `func(cancel: bool)` | Ends the capture: finishes the file, or (`cancel`) throws it away. |
| `capture-status` | `func() -> capture-state` | The capture's state; `done` and `failed` stay until the next start. |
| `set-film-quality` | `func(on: bool)` | Asks for the best picture the renderer can give (AirDef fork, level 17): the HD world at the full size of the window (no resolution scale, so no upscaling), and the volumetric clouds and fog marched with more steps. Meant for replays and films; false restores the player's settings. A capture turns it on for its duration. |
## `events`