Mod-texture assignment convention
(File was originally "externalized mod texture util" — that framing was investigated and rejected. See "Rejected branches" below. Kept at this path so the original idea remains findable.)
Status: discussed to a conclusion 2026-07-29, not yet specced. No code written. Some claims verified directly against f_masonry and src/ during that discussion (marked verified); the rest is inference and still needs checking. SUPERSEDED AS THE LEADING PLAN, 2026-09-17 — see banner below.
Conclusion
⚠️ 2026-09-17 update: the trigger condition below has been met.
named_mod_textures.mdT1 (round-trip), T2 (two tagged streams sharing one inlet), and T3 (no staleness) all passed live in Max. Per this file's own 2026-07-29 note, that makes most of the conclusion below obsolete as the leading plan — not deleted, since the tagged-texture approach still needs its own T4 (live, against a realvs_inState- wrapped module)/T5 (inlet ceiling)/T6 (routepassinteraction) closed, plus an unexplained failure mode (a bare pass-throughjit.gl.pixdidn't render in the scratch test; routing straight into the display did) root-caused before anything gets built on it either.What actually falls away if named textures holds: the assignment matrix mechanism itself,
f_util_matrix_grid.jsas something worth continuing to invest in (nothing left to display), and the_mod_amt_a/_mod_amt_b/_mod_amt_cper-param×channel Param explosion — named tags give each target its own dedicated stream, so that collapses toward one mod-depth Param per target.What survives untouched, because it's orthogonal to the routing mechanism: the scalar/depth/texture triple (see "Scalar modulation vs. texture modulation" below), the unipolar/bipolar divergence (still fully open, still blocking), "masonry isn't convention authority," and masonry's real insight that mod sources are different coordinate spaces, not interchangeable channels (see "Why
f_masonryis the wrong template" below) — a named target still needs to be sampled at its own correct space, that part doesn't go away.One real tradeoff, not a strict loss: the matrix model let one upstream texture drive several params at once, at different live- adjustable depths, from a UI grid. Named textures doesn't give that for free — fanning one source to two params becomes an upstream patching decision (cable it out twice under two tags), not a runtime-adjustable blend. Worth checking whether that multicast was ever actually used before treating its loss as a real cost.
Original 2026-07-29 banner, for the record: "a possible alternative to this whole approach was raised — see
ideas/named_mod_textures.md... unverified — nothing scratch-tested — so the conclusion below stands for now... do not build on this file until T1/T2 have been run, because passing tests there would make most of what follows obsolete."
A module exposes a small fixed number of mod texture inlets (2 as the working default), and what those textures drive is set in the UI at runtime rather than fixed by which inlet you patched into. Assignment lives inside the module, not in an external routing util.
The mechanism is per-param weighted accumulation in the codebox:
param_eff = clamp(param + a_sample * param_mod_amt_a
+ b_sample * param_mod_amt_b, lo, hi);Every modulatable param carries one amount Param per mod inlet. Unused ones sit at zero — a multiply-add against zero is free on GPU.
Caveat added 2026-07-29: the formula above is written in f_masonry's unipolar form (black = neutral). Kevin's canonical Vsynth modules use a bipolar form (0.5 gray = neutral, via scale 0. 1. -1. 1. before the depth multiply). That conflict is unresolved and must be settled before this becomes a convention — see "Scalar modulation vs. texture modulation" below. Also note this shared-inlet + assignment model is a deliberate break from Kevin's 1-inlet-per-param convention, not an extension of it.
This is not new machinery — it is what f_masonry already does (verified, src/f_masonry/definition.py):
mortar_eff = clamp(mortar + a_sample * mortar_mod_amt_a
+ b_sample * mortar_mod_amt_b
+ c_sample * mortar_mod_amt_c, 0.0, 1.0);The convention generalizes that pattern; it does not invent it.
What is durable vs. what is UI
The contract is the durable part and should be settled first:
definition.pydeclares the mod inlets (themod_inletskey already exists and does this — see below).definition.pydeclares, per texture-modulatable param, a triple: the base scalar param, a paired mod-depth scalar (_m/_mod_amt_), and the binding to a mod texture inlet. Modulatability is not a boolean property of a param — see "Scalar modulation vs. texture modulation" below, this distinction was originally conflated here.- Codegen emits the
_mod_amt_<inlet>Params and the accumulation line per modulatable param. - Amount
Params are addressable by name.
Get that right and the UI is entirely downstream — grid, (+)-row list, context strip, or something not yet imagined, swappable without touching a single module. Get it wrong and every UI built on it inherits the mistake.
Explicit decision from the discussion: do not bank on any existing UI. All of it is up for revision. Build the contract, ship it on one module with whatever minimal UI is fastest, then design the real UI once it has been used and the interaction is understood.
Scalar modulation vs. texture modulation — NOT the same thing
Clarified 2026-07-29 after this file originally conflated them. Reference implementation: Kevin's vs_displacement (Vsynth/patchers/vs_displacement.maxpat, gen patcher inside jit.gl.pix) — verified by reading it directly.
Sending [param zoom 1.2] sets a scalar. Texture-modulating zoom is a different mechanism requiring three things, not one flag:
| piece | Kevin's naming | role |
|---|---|---|
| base scalar param | param zoom 1. | the value being modulated |
| mod-depth scalar | param zoom_m 0. | how much the texture moves it |
| bound texture inlet | in 5 | the modulating texture itself |
The depth is itself an ordinary scalar param, so it is [param $1]-controllable like any other. vs_displacement's route list — angle zoom x y xm ym rotm zm kmode mmode — exposes base scalars and mod depths side by side.
Bipolar remap (important). Every mod texture in vs_displacement passes through scale 0. 1. -1. 1. before being multiplied by its depth. So 0.5 gray is neutral and the texture is a signed deviation — consistent with the f_vf_ family's 0.5-is-zero-vector convention.
Divergence, unresolved: f_masonry does not remap. a_sample = sample(in2, brick_uv).r is used raw, so black is neutral and modulation is unipolar-additive. The library currently carries two incompatible mod-texture conventions. This must be decided before any library-wide convention lands — and note the conclusion at the top of this file was drafted from the masonry (unipolar) form without noticing the divergence.
Kevin's model is 1 texture inlet : 1 param. Canonical Vsynth, but it does not scale — masonry's 13 modulatable params would need 13 inlets, which is precisely why it went to shared inlets plus an assignment matrix. So "2 inlets + assignment" is a deliberate break from Vsynth convention, not a refinement of it. That should be an explicit argued decision, not something that happens by default, especially given Kevin's modules are the canonical reference for conventions in this library.
Why break Kevin's convention at all — the motivating problem
Stated by Matt 2026-07-29, and the reason this whole line of thinking exists:
f_ modules tend to have substantially more params than Kevin's do. Kevin's 1-texture-inlet-per-modulatable-param convention works fine at his scale — vs_displacement modulates four things and has four mod inlets. It degrades badly as param count grows: f_masonry has 13 modulatable params and would need 13 mod inlets under that convention, which is unpatchable in practice.
So the break is deliberate and motivated, not an oversight. This file is an experiment in what can replace 1:1 inlet binding once param count makes it untenable. That reframes the open question below from "should we break convention?" (answered: yes, we have to) to "what is the right replacement, and how far does it diverge?"
Related, and a caution: f_masonry's mod inlets were developed in isolation, without reference to Kevin's conventions — Matt's own assessment. That is how the unipolar/bipolar divergence got in. So masonry should be treated as evidence about scaling pressure (it demonstrates the real problem) but not as a source of convention authority. Where masonry and Kevin disagree on a detail that isn't about param count, Kevin is the reference.
Discovery: already solved, was never the problem
Much of the original discussion theorized about how a util could "discover" a module's modulatable inlets. Verified: the metadata already exists in definition.py as the mod_inlets key, with human-readable labels. From f_masonry:
"mod_inlets": [
{"label": "slot mod", "vs_instate": False},
{"label": "brick mod", "vs_instate": False},
{"label": "pixel mod", "vs_instate": False},
],Self-declaration in definition.py was the fallback plan in the original version of this file. It turns out to be the existing state of affairs, not a fallback. What may still need adding is a modulatable params declaration (which params get _mod_amt_ pairs emitted) — probably explicit rather than inferred from the full param list, since not every param wants texture modulation.
Caution (verified): f_masonry's mod_inlets key was once missing from definition.py while three inlets were live in production, hand-wired into the .maxpat and never captured back. Rebuilding silently dropped them. Declarations drifting from reality is a demonstrated failure mode here, not a hypothetical one.
Why f_masonry is the wrong template
f_masonry has three mod inlets, but they are not three interchangeable sources — they are three different coordinate spaces (verified, src/f_masonry/definition.py):
| inlet | label | sampled at | meaning |
|---|---|---|---|
in2 | slot mod | brick_uv | winner's slot identity |
in3 | brick mod | (along_frac, across_phase) | position within brick |
in4 | pixel mod | norm | screen space |
Masonry affords three spaces because it is built around slot/course geometry. That is unusual. Most modules afford one (screen space only — f_droste, f_lens, f_tone_curve have no per-item identity to sample). Discrete-item generators (f_grain, f_stipple, f_vf_seeds) plausibly afford two: item identity and pixel.
Therefore the inlet count is not a number to standardize on — it falls out of each module's geometry. Masonry is the maximal case and generalizing from it would over-engineer everything else. Two is a sensible default ceiling for ordinary modules, not a law.
Also verified: masonry's matrix is asymmetric. Only six params (mortar, softness, width, roundness, course_color, brick_color) get all three sources; drift, offset, speed_var, regularity, phase, skip have _a only. At least offset is structurally forced — it samples in2 before the winner search runs, so it cannot use winner-keyed sampling.
Existing UI, for reference only
Verified: package/javascript/f_util_matrix_grid.js (436 lines) is already generic and data-driven — params <name1> <name2> … rebuilds its rows, and it has scroll state, a scrollbar, and a strip mode (strip, focus <param>) for a single-row context strip. f_masonry instantiates it twice: full grid at 211×289, context strip at 211×22.
So the grid is further along than "unwieldy flat table" suggested — it is scrollable. The likely real complaint is scroll quality: 13 rows at 20px ≈ 260px against a 289px box, so it barely scrolls and the scrollbar is near-vestigial. Worth confirming which before assuming a rewrite is the fix.
Two concrete defects if it is ever reused as-is:
NUM_SOURCES = 3andSOURCE_LABELS = ["A","B","C"]are hardcoded.- Masonry feeds it 13 param names × 3 columns = 39 cells, but only ~25 are wired in the codebox. Roughly a third of the grid does nothing.
But per the decision above, none of this should be built on. It is recorded so the next UI attempt knows what exists and what went wrong, not as a starting point.
Note on the (+)-row idea (Ableton-mapping-style growable list, one row per live assignment): at two sources with sparse usage a grid is mostly whitespace, so a row list is the natural presentation — a one-column matrix degenerates into exactly that. The (+)-row and the grid may not be rival designs so much as the same widget at different source counts. Unverified: whether Max can add rows without dynamic object creation, or whether it must be N pre-built hidden rows.
Rollout sequencing
Verified: f_sirds, f_vf_advect, and f_vf_seeds each have a dedicated build script alongside definition.py (build_sirds.py, build_advect.py, build_seeds_multistage.py) — all multi-stage modules. They are regenerable, just through their own path, so the rollout cost is teaching four builders one pattern rather than hand-editing four patchers.
f_masonry has definition.py only, no build script — it is the genuine manual case. It also already has a working version of this mechanism, so it is arguably the last module to touch, not the first.
Proposed order:
- Settle the
definition.pydeclaration format (mod inlets + modulatable params + ranges). - Implement codegen in
build_patcher.py. - Prove it on one simple single-stage module with minimal UI.
- Propagate to the three custom builders.
- Design the real UI, informed by actual use.
- Consider migrating
f_masonry— or leave it alone.
Rejected branches
Recorded so they are not re-litigated.
- External routing util (the original premise). Rejected. It cannot remove the in-module accumulation, only shadow it — the params live in the shader and their use sites are hardcoded, so assignment cannot leave the module. A util would create two sources of truth for the weights and fragment preset recall across two objects.
- External util justified by fan-out (one texture to many modules). Rejected: Max cables already fan out natively. One outlet drives many inlets; each texture inlet takes 0 or 1 cable. No util needed.
- External util justified by keeping module UI clean. Rejected: the module needs the inlets and the accumulation regardless, so the only thing externalized is the UI — at the cost of the sync and preset problems above.
- Channel muxing (pack 4 mod sources into RGBA, unpack in the codebox). Rejected: it only compresses fan-in. The matrix, the mapping UI, and the param list all still exist, and it adds a slot-index abstraction the performer must track plus pack/unpack machinery in every codebox. Capacity nobody was short on, in exchange for a concept everybody must learn.
- Dynamic outlet/inlet counts. Rejected as almost certainly impossible — Max bpatcher I/O is fixed at patch-load by the physical
in/outobjects. Fixed small counts instead. - Standardizing on masonry's three-space model. Rejected — see "Why
f_masonryis the wrong template" above.
Open questions
Unipolar or bipolar mod textures?
f_masonryis unipolar (black = neutral), Kevin'svs_displacementis bipolar (0.5 = neutral). Blocking — decide before anything else, since it changes every accumulation line and every module's neutral state. Leaning bipolar: it matches both canonical Vsynth and thef_vf_family, and masonry's unipolar form came from isolated development rather than a considered choice (see above), so it carries little weight as precedent. Cost if bipolar wins: masonry's existing accumulation lines and any saved presets change meaning.What replaces 1:1 inlet binding, and how far to diverge? The break itself is settled (param count forces it — see "Why break Kevin's convention"). Open: whether shared-inlets-plus-assignment is the best replacement, and whether anything else of Kevin's convention (naming, depth-param shape, bipolar remap) should be preserved even while the binding model changes. Default assumption: preserve everything except the 1:1 binding.
(+)-row feasibility in Max: can rows be created on demand, or must it be N pre-built rows hidden until used?Is the existing grid's problem scroll quality or scroll absence? Confirm against the running patch before deciding a rewrite is warranted.
Modulatable-param declaration format: how to express the base/depth/inlet-binding triple in
definition.py(a flag per param is insufficient — see the scalar-vs-texture section). Needs the effective-result clamp range too, which is not necessarily the base param's own range.Paramnamespace cost: a 12-param module at 2 inlets carries 24_mod_amt_Params, mostly zero. Cheap on GPU, but 24 entries in preset state per module. Probably fine — worth confirming before it becomes a library-wide convention.Does the two-inlet default hold for discrete-item generators? They plausibly want item-identity space and pixel space, which is exactly two — but that should be checked against
f_grain/f_stipple/f_vf_seedsrather than assumed.Does the base/depth/texture triple need a fourth element — an optional confidence-gate source? Raised 2026-10-11 via the tensor-field thread (
ideas/f_tensorfield.mdopen question 15): a structure tensor's anisotropy output is a per-pixel "how much does the field data mean here" signal, distinct from the depth scalar's performer-intent meaning ("how much do I want this param to respond"). The proposed shape keeps both —effective_depth = depth_dial * confidence_sample— rather than letting one replace the other, which would lose the performer's ability to mute/ride the effect independent of content. If this becomes a real pattern, the declaration format (whichever open question above settles it) should probably have a slot for an optional fourth binding, not just base/depth/texture.