f_particles
Name: f_particles (final, Matt 2026-11-29; the menu entry is still provisional, G-menu).
Type: Dual-mode processor with a stateful layer. Two texture inlets (source; field), two texture outlets (composite; density layer). Three jit.gl.pix stages (update, pass, comp), a points mesh drawing into a float32 jit.gl.node capture, a seed loader and a reset network (the raw layer). Status: Built 2026-11-29. Update stage bench 14/14, functional module bench 6/6, composite bench 10/10 (three rows rerun alone), scatter record 8/8, contract bench 2/2 (the last run after the panel and inlet changes: tests/logs/20261129-222948-bench.log). Matt looked live: "much better" (round dots, Inertia), then the panel and both inlets passed (2026-11-29); defaults confirmed ("Defaults are fine"). Not looked at live: two instances in one patch (demo_particles built offline 2026-11-29, not opened in Max). Not done: the helpfile and demo looks in Max, preflight Part 2b.
Reference written 2026-11-29 from src/f_particles/ (definition, codebox_update.gen, codebox_composite.gen, particles_scene.py), .specify/f_particles/{spec,tasks}.md and the logs cited below.
What it does
It scatters a fixed crowd of 262,144 dots (particles) over the frame and moves each one a little every frame, pushed by a field you patch in. The dots keep their positions from frame to frame, so they gather where the field leads them and stay there. The result is drawn as a density picture and added to a source.
Sand on a Chladni figure. Patch
f_chladni's outlet 2 (its third) into inlet 1 with Push = Descend (its Gain at 0.5 or lower): the dots slide off the moving parts and pile up on the still lines, like sand on a vibrating plate. Matt's look confirmed the lines fill and the sand follows a note change.Tracers in a flow. Patch a vecfield (
f_vf_fluidout) into inlet 1 with Push = Field: the dots ride the flow and keep fine structure that a texture advection smears (tier 1 contrast 0.95 against 0.48 at frame 200).Inlet 0: the source texture. Optional: unplugged, the layer is drawn over black (
vs_inState, flagsrc_mode; Matt, 2026-11-29: an unplugged cable must stop drawing the old texture).Inlet 1: the field. Push = Field: a vecfield (R, G = 0.5 + 0.5 x, y). Descend and Ascend: a scalar in R. Unplugged, it reads as black and the layer is silent (also
vs_inState); control messages arrive on inlet 0.Outlet 0, composite: source plus the density through the exposure curve, crossfaded by Mix.
Outlet 1, density: the tone-mapped layer alone, white where dots pile up.
The particle state is kept in a one-frame feedback loop (position in R, G; velocity in B, A). Reset returns every particle to its seed position; Respawn re-places a share of them each frame.
Signal Flow
inlet 1 (field) -> vs_inState -> update, comp(field guard)
update -> pass -> update inlet 1 (state feedback, one frame)
update -> scatter (points mesh, one vertex per texel of the state) -> float32 capture -> comp inlet 1
inlet 0 -> vs_inState -> comp inlet 0
comp -> outlet 0 (composite), outlet 1 (density)| Stage | Reads | Writes |
|---|---|---|
update (512 x 512, float32) | field, previous state, seed texture | new state: R, G = position, B, A = velocity in field texels per frame |
pass | update | the same state held one frame (the feedback) |
| scatter | update | float32 capture at the RENDER size and aspect: R = particle count (times weight) per pixel |
comp | source, capture, field | outlet 0 and outlet 1 at the render size |
The update reads the field with four hand-blended nearest() taps (never sample(): a particle position is a jumpy coordinate). Push = Descend or Ascend takes a central-difference gradient at each of the four texels around the particle, normalized there, then blends. Respawn picks particles by fract(u + rphase) < respawn_pct / 100 and sends them to the seed position at an index offset. No hash is used anywhere; positions come from the shipped seed texture package/media/f_particles_seed512.jxf (a shuffled jittered grid).
Parameters
Panel: dials Speed, Respawn, Inertia and the Reset button on the top row; the Push menu in the title bar; numboxes Ease, Gain, Expo, Mix and Size, Hard, Thresh below.
| Name | Type | Range | Default | Description |
|---|---|---|---|---|
speed_pct (Speed) | dial | 0 to 2 | 0.15 | Step per frame as a percent of the frame height. Field: the vecfield's strength times this. Descend and Ascend: always this far. |
respawn_pct (Respawn) | dial | 0 to 20 | 0 | Percent of particles moved to a random position each frame. 0 is as sharp as the field allows; 1 percent leaves about two thirds of the sand on the lines (tier 1). |
inertia (Inertia) | dial | 0 to 0.99 | 0.85 | Each particle's velocity relaxes toward the push: v = inertia * v + (1 - inertia) * target. Time constant 1 / (1 - Inertia) frames. Soft starts and turns; values above about 0.95 overshoot a line and take longer to settle. |
ease (Ease) | numbox | 0 to 1 | 0.1 | Descend and Ascend: the push shrinks to zero as the scalar nears the attractor level (0 for Descend, 1 for Ascend), within this distance in scalar units. Lowers the residual speed by 2 to 5 times; delays arrival. Field ignores it. |
gain (Gain) | numbox | 0 to 4 | 1 | Density brightness, the same at any render size (normalized to 1024 x 1024). |
expo (Expo) | numbox | 0.3 to 1.5 | 0.7 | Exposure curve (v / (1 + v)) ^ expo. |
mix_pct (Mix) | numbox | 0 to 100 | 100 | Source alone (0) to source plus density (100). |
size (Size) | int numbox | 0 to 4 | 1 | Dot size: the density is grown by a max filter over a disk of this many output pixels. 0 is the plain dot. Costs output pixels, not particles. |
hardness (Hard) | numbox | 0 to 1 | 1 | Edge of the grown dots: 1 a crisp disk, 0 a soft round dot. Needs Size above 0. |
thresh (Thresh) | numbox | 0 to 0.95 | 0 | A black point on the tone-mapped layer: faint sprinkle and halos drop out. |
push_mode (Push) | menu | Field / Descend / Ascend | Field | Field: ride a vecfield. Descend: slide toward the darker, down the gradient of a scalar. Ascend: toward the brighter. A flat or clamped scalar has no gradient, so the particles do not move there. |
| Reset | button | Returns every particle to its seed position (reset_gate stays 1 for three draws, as in f_cgl). Also runs at load. | ||
bypass | toggle | 0/1 | 0 | Both outlets go to the source (black if inlet 0 is unplugged). The state keeps running underneath. The native bypass 1 message has no effect. |
Internal, never set by hand: fw, fh (render size), rphase, roff, reset_gate, and on the composite capw, caph, src_mode.
Notes and limits
- Descend needs an unclamped scalar.
f_chladni's first outlet is black almost everywhere at its default sharpness (no gradient, so no motion); use its third outlet with Gain 0.5 or lower. At Gain 1 note 60 reaches only 0.88 on the lines because of the clamp (tier 1). - Brightness is normalized to the render size (Matt, 2026-11-29): the density is scaled by the capture's area over 1024 x 1024, so the same particles read the same at any render size. Anything tuned before this change at another size reads differently: about 2 times brighter at 1920 x 1080, and 0.4 times at 640 x 640 (inferred from the area ratio, not measured live). Gain still sets the level. Composite bench 9/9 after the change (
tests/logs/20261129-233545-bench.log); Matt looked live: "right at my size". - Dilation at small renders. At a render below 1024 the first build read a 1024 capture by minification and sparse dots flickered at Size 0; the capture now equals the render size, which ended that (tasks T037, observed in the composite bench).
- A black field is not neutral. Plugged-in black reads as a full -1 vecfield in Field mode; the layer is silenced by the guard, but the hidden state still drifts.
- Capture memory. A render-size float32 capture is about 133 MB at 3840 x 2160 (inferred from size, not measured).
- Two instances in one patch: not checked.
- Seed loader: it uses the builder's
staticmechanism (a texture read from a shipped file at load); it worked in the benches and live, and Matt called it verified (2026-11-29). - No identity or events: no per-particle color or age, no collisions, no count outlet (that is
f_cores), positions wrap. - Cost, 1920 x 1080, 262,144 particles, converged, Descend (ms per frame; amplified method, upper bounds where marked): update 0.19 (Field 0.04; 0.75 at 1,048,576), scatter at most 1.67 (1024 capture 1.68, uniform at most 1.12), composite 0.04 / 0.33 / 0.91 / 1.75 at Size 0 / 1 / 2 / 3; Size 4 was not measured (the job times out; Matt: ignore it, 2026-11-29). Sum about 2.2 at Size 1 and 3.6 at Size 3 (SC-004 budget 4 ms). Logs in tasks.md "Cost at a render-size capture".
Verification
- Tier 1:
tests/modules/particles/test_particles.py22/22 (the NumPy mirror: Field, Descend, Ascend, inertia relaxation, ease, respawn, reset, mutations) andtest_particles_build.py(structure: route order, raw-layer ids, capture node source). - Tier 2:
bench_particles_update.py14/14 (tests/logs/20261129-212333-bench.log);bench_particles_composite.pyagainst the mirror, including non-square (20261129-212546-bench.log,20261129-214347-bench.log);bench_particles_module.py6/6 (20261129-214520-bench.log: sand on the nodal lines, ratio about 17,700; respawn blurs it; a black field is silent; Ascend gathers on a bright line); the scatter recordtests/records/bench_particles_scatter.py8/8 (20261129-215105-bench.log); contract bench 2/2 (20261129-222948-bench.log). - Live (Matt): see Status.
Related
f_chladni (outlet 2, its third, into inlet 1, Descend), f_vf_fluid (a flow for Field), f_caustic (the scatter and composite contract this follows), f_cores (marks the swirl centers a flow produces), f_vf_stamp. ideas/f_particles_spike.md (the evidence), ideas/field_object_bridge.md (why).
References
The scatter and exposure curve follow f_caustic (docs/f-reference/f_caustic.md). Inertia is an exponential moving average of the target velocity, a standard smoothing, not a spring. The seed is a shuffled jittered grid made for this module. No outside source was consulted.