Skip to main content

Module swarm

Module swarm 

Source
Expand description

Particle-swarm scene: ~10k CPU-simulated particles drifting through a flow field in a perspective volume, drawn as instanced additive sprites projected through the shared camera (ADR-0259). One of the two preset-driven systems (ADR-0002 layers 1-2).

Its behavior is a set of named parameters — force, spin, burst, hue, brightness, size — that a preset binds to expressions over the audio analysis (Plan 0003 Phase 5), plus a subset of the shared camera block. All per-particle math is CPU-side; no compute shader. Motion is deterministic; the only randomness is the seeded initial scatter (NFR 6).

§The world is a torus in frustum coordinates

A particle holds (u, v, z): z is a view depth inside the slab Z_NEAR..Z_FAR, and u, v in [-1, 1) are its place across the frustum’s cross-section at its own depth, times MARGIN. Its world position is (u * hx(z), v * hy(z)) with hx, hy the rest frustum’s half-extents at z scaled by the margin (half_extent). The torus wraps in u and v, so the seam sits the same margin outside the frame at every depth — a box of fixed world bounds would show its seam at one end of the slab or waste its population at the other (ADR-0259).

The flow is evaluated in world space and a world velocity is converted back by the half-extent at the particle’s depth, so a far particle crosses the screen more slowly than a near one under the same current: motion parallax out of the simulation itself. z rides a slow component of the same field, wraps across the slab, and a particle’s light fades to zero in a band at either slab bound, so the depth wrap never pops.

§The camera is a subset of the shared block

The eye orbits the slab’s centre at PIVOT and looks down -z. yaw and pitch are held to a sway the margin covers (sway_bound), and there is no distance: the slab is defined relative to the camera, so an orbit would show the edge of the world. zoom divides the field of view and pan_* shift after the projection (ADR-0257); neither re-maps the simulation, and a zoom below the margin shows the seam.

Structs§

SwarmScene
~10k-particle CPU flow-field swarm, driven by named preset parameters.

Constants§

PARAMS
Parameter vocabulary — see fragment_field::PARAMS. Keep in sync with set_param below.