← f_ notebook · docs/f-reference/f_masonry.md

f_masonry — Bpatcher Spec ​

Last updated: 2026-07-05Status: WorkingRenamed from f_weave (2026-05-30). Note: a separate, later f_weave module now exists in the library under a new name/concept — do not conflate the two.

Concept ​

A parametric masonry texture generator — courses (horizontal bands), bond (bricks per course), mortar (gap width), offset (stagger between courses), and per-course drift/animation. Ranges from crisp mechanical regularity (running bond brick, ashlar stone) to organic broken-course structure. Complex spatial deformation (fisheye, spiral, lens) is downstream's job (f_droste, f_mobius, f_lens) — f_masonry produces the clean course structure those processors work on.

Taxonomy note (carried from HANDOFF): despite being labeled archetype: "processor" in definition.py, f_masonry is self-sufficient — it has no real content dependency on its texture inlet (routepass-only render trigger) — the only generator-like tell left after bypass became passthrough, which is why its processor flag remains defensible. Flagged for correction whenever build_modules.py's CATEGORIES get refined; not yet acted on.

Parameters ​

NameTypeRangeDefaultDescription
coursesfloat0.0–100.08.0Number of horizontal bands (rows of bricks)
bondfloat0.0–100.08.0Number of bricks per course (columns)
offsetfloat0.0–1.00.0Per-course stagger — 0.5 = half-brick running bond
anglefloat-360–3600.0Field rotation in degrees
skipfloat0.0–1.01.0Fraction of courses that are visible (course presence gate)
regularityfloat0.0–1.01.01=nearest-wins even grid, 0=priority bias letting candidates win contested territory (uneven spacing, density not preserved)
driftfloat0.0–4.00.0Per-course along-axis drift amount
phasefloat0.0–1.00.0Per-course phase offset — primary animation target (drive with vs_lfo)
speed_varfloat0.0–10.00.0Per-course speed variation when animated; 0 = all courses move together
mortarfloat0.0–1.00.5Gap width between bricks
softnessfloat0.0–1.00.0Edge feathering — 0=hard, >0=smooth
widthfloat-2.0–2.00.5Brick aspect ratio scale in across-axis
roundnessfloat-2.0–2.00.00=rectangular, 1=circular/oval bricks
course_colorfloat0.0–1.00.0Per-course color randomization amount
brick_colorfloat0.0–1.00.0Per-brick color randomization amount
course_seedfloat0.0–999.00.0Course hash seed — changes color/speed/skip pattern
brick_seedfloat0.0–999.00.0Brick hash seed — changes presence/drift pattern
src_modeinternal0/1—Driven by vs_inState; not user-facing
bypassbypass0/10Passthrough — both outlets mix to the source texture from in1 (drives bypass_gate)

Three modulation inlets (A/B/C, texture in) drive per-param _mod_amt_ deltas on many of the above params (offset, drift, speed_var, regularity, phase, skip, mortar, softness, width, roundness, course_color, brick_color) — these modulation-amount params are codebox-internal, set via the mod-inlet system rather than the named route, and are not independently addressable messages. See codebox in .specify/f_masonry/definition.py for the full _eff accumulation per param.

  • A (slot mod) — sampled at brick identity coordinates (in2); one value per brick, constant within a brick footprint.
  • B (brick mod) — sampled at intra-brick coordinates (in3); tiles per brick face.
  • C (pixel mod) — sampled at screen-space coordinates (in4); continuous, articulated into structural variation by the brick mask.

Signal Chain ​

in0 (texture + ctrl) → routepass jit_gl_texture jit_matrix

routepass out0 (texture or vs_black) → masonry_pix in0   [render trigger]
routepass unmatched → route <params> → live.dials → prepend param <name> → masonry_pix in0

in1 (slot mod texture, A)  → masonry_pix in2
in2 (brick mod texture, B) → masonry_pix in3
in3 (pixel mod texture, C) → masonry_pix in4

masonry_pix out0 (composite) → out0
masonry_pix out1 (mask)       → out1

Algorithm ​

Coordinate frame rotates by angle into along/across axes (with aspect correction). across is quantized into course bands (band_idx); along is quantized into brick slots (slot), staggered per-course by offset. Per-course hashes (seeded by course_seed) drive skip (course presence), speed_var (per-course animation rate), and course_color. Per-brick hashes (seeded by brick_seed) drive regularity (regular vs. randomized spacing) and drift (positional jitter, via the ADR 7 candidate-search (.specify/f_masonry/plan.md, ADR 7)), and brick_color. Brick footprint is a mix between a rectangular and rounded (superellipse-like) distance field, gated by roundness, sized by mortar/width, and anti-aliased by a per-pixel-derivative-aware softness floor (aa_width, computed from screen-space partials of along/across). skip-gated courses are dropped entirely (cont gate) before compositing.

Loose Threads ​

  • quantize removal from the live .maxpat — completed 2026-09-23 (E001p). quantize was removed from the codebox algorithm in the 2026-07-05 ADR 7 candidate-search redesign. The dead live.dial, its route entry, the prepend quantize wiring and the parameter entries were removed by hand on 2026-09-23 and the controls panel reflowed. Nothing outstanding.
  • Known bug (per HANDOFF): square-output artifact at non-square render resolutions — untouched.
  • Target-list partitioning for the three modulation inlets is a working hypothesis (structural params → slot space, appearance params → brick/pixel space), not finalized — see .specify/f_masonry/spec.md's Open Questions.
  • Angle compensation for slot-mod sampling when angle≠0 is deferred (sample coordinate doesn't currently correct for rotation).

References ​

Brick-wall bond patterns (running bond, Flemish bond, etc.) are classical masonry; the per-course offset arithmetic is elementary. The implementation is an original construction: the ADR-7 candidate-search algorithm (hash-seeded per-course candidates with bond constraints), the three modulation-inlet contract, and the continuous distance-field line placement (never grid-quantized) were all derived during development.

This module predates the build system and carries hand-built UI: src/f_masonry/definition.py reproduces the shipped patch but regeneration destroyed the UI once -- it is on the never-regenerate list (tests/build/drift_baseline.json documents the deliberate drift). Known loose threads are in Loose Threads above (the dead quantize control flagged there has since been removed from the shipped .maxpat).

See docs/f-reference/f_masonry.md (this file) for the full ADR-7 algorithm and the modulation contract.

Source File ​

package/patchers/f_masonry.maxpat