spine-parts 2.35.0 → 2.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/AUTHORING.md +27 -2
- package/docs/STABILITY.md +2 -2
- package/package.json +2 -2
- package/src/assemble.ts +147 -52
- package/src/config.ts +11 -4
- package/src/layers.ts +2 -0
- package/src/occluders.ts +2 -0
- package/src/occluderstage.ts +5 -3
- package/src/parts.ts +49 -2
- package/src/takelayers.ts +11 -1
package/docs/AUTHORING.md
CHANGED
|
@@ -161,7 +161,7 @@ read by no CPU stage).
|
|
|
161
161
|
| `assemble.yield_refused` | assemble | **authored**, optional boolean, default `false` (issue #819; other types: `CONFIG_FIELD_TYPE`). With `true`, an original front projection-core pixel refused at max-channel drift > `DRIFT_LIMIT` (90) can yield when its original source pixel is still opaque. Non-core rim pixels (0 < alpha < `CORE_ALPHA`, 250) on the same 8-connected part body can then yield too (issue #832). Connectivity reads the part support before clearing: the opaque border outside the eroded projection core connects the body to its rim but is not itself newly cleared. A separate rim island without a yielded core seed is unchanged. At every cleared pixel, the actual top-most opaque holder below it (alpha >= 250), after earlier yields, must have colour within 90 of the painting. A deeper matching part cannot bypass an intervening opaque mismatch. This setting also applies to alternate sets. A yielded pixel's alpha becomes 0 and its RGB is not repainted. Accepted own-core pixels in the same connected support within the original yielded core's Gaussian footprint (radius 4 rig pixels), with a matching opaque behind holder, finish to painting RGB while retaining alpha and ownership (issue #841); original refusals, protected samples and replacements are excluded. Away from that footprint projection is unchanged. Merge/ring replacements, samples explicitly kept by `keep_under_occluders`, and pixels outside a derived piece cannot connect a rim or be newly yielded. Front is relative to the matching part behind, so original refusals in another run are eligible even when a different part is the global top holder. The reading proceeds back to front against the current behind pixels; alpha changes do not repaint or create a new matching colour. `yieldReadings` optionally records `finishedProjection` (accepted samples whose RGB changed), and records `yieldedRim` as the rim subset of total `yielded`, skipped core merge/ring/nonopaque/no-match counts and original/final global holders; a yielded pixel also taken by projection closing is omitted from the written `source_px_taken` count. Existing cuts/patches and thresholds are unchanged. The `drift:` line reports `yielded N px` per affected part, even below the drift-body size bar; with the setting off it names `assemble.yield_refused: true` as the conditional remedy. Rebuild and inspect the newly exposed layer in motion before considering any cut; a mismatching or absent behind holder cannot be repaired by this setting. |
|
|
162
162
|
| `assemble.keep_under_occluders` | assemble | **authored**, optional array of unique source part names from `assemble.plan`, default `[]` (issue #825). For each named part, keep its own See-through RGBA where the front-most covering part in the final draw stack has alpha greater than 0 and below `CORE_ALPHA` (250), including a cover in the other run. Covers at raw alpha <= 8 are ghosts and are not kept under; a ghost-cleaned sample with final alpha 0 is absent cover and does not trigger restoration. Only original opaque own-layer samples are restored after source projection/closing and protected from later seam re-take; merged/rim, cap, under-fill and authored replacement pixels are excluded. This keeps their existing provenance and makes no holes; fully opaque cover and absent cover keep the old path. Cuts and limb pieces inherit the source part's protection. Unknown names: `CONFIG_NAME_RESOLVES`; duplicates: `CONFIG_PART_UNIQUE`; invalid shape: `CONFIG_FIELD_TYPE`. Inspect the part's own amodal layer first: this handle preserves its existing content and cannot complete a missing pixel — in particular, it does not close a motion opening inside the figure (`figure_openings` / [Openings inside the figure on undeclared layer pairs](#openings-inside-the-figure-on-undeclared-layer-pairs-issue-933)) where the lower layer has no opaque core under an opaque upper layer (measured with every `assemble.plan` part named in `keep_under_occluders`: `0` of `1` pair-animation warnings across `demo`'s eight animations closed, with `hair_back\|handwear_r` on `hop` frame `5` staying at `40` cells over `28` allowed in `38x70` world units at `2.517` world units/cell, while `scarf` reads `CLEAR` (`0` warnings) both with and without `keep_under_occluders`; use `assemble.extend_painting` when the lower part lacks opaque source material under an opaque upper cover). Example: `"keep_under_occluders": ["shin_r"]`. |
|
|
163
163
|
| `assemble.require_hidden_extent` | assemble, build | **authored**, optional array of unique `{part, occluder}` source-name pairs from `assemble.plan` (issue #1047). The distinct occluder must draw after the part. Before cleanup, projection, underfill, cuts or limb splitting, the original selected source is normalized to the rig grid. Own support is alpha >8. Its enclosed holes are `fillHoles(support) \ support`, using four-connected exterior background. Any hole cell under the resolved front-most named occluder (alpha >8) refuses `ASSEMBLE_HIDDEN_EXTENT_ABSENT`. Zero holes with measurable filled-support overlap passes. No overlap or unavailable original ancestry refuses `ASSEMBLE_HIDDEN_EXTENT_UNMEASURED`. A region take's output (`assemble.take`) counts as the selected source. Cover resolves over `assemble.plan` source families only; cut slots are not resolved as cover, which is a stated limit. Omitted or `[]` adds no reading or output. This is a source-support bar reached by build at assemble. See [Original hidden extent required](#original-hidden-extent-required). |
|
|
164
|
-
| `assemble.occluders` | assemble, build | **authored**, optional (issues #1230, #1237, #1241, #1246, #1251): `[{image, sha256, under, over?, plate?, part?, grow?, rgb_within}]` — an RGBA PNG of what stands in front of the character on the painting's grid (`image`, relative to the config's directory; another size refuses `ASSEMBLE_OCCLUDER_GRID`), its bytes' sha256 (`CONFIG_OCCLUDER_SHA256`), the plan parts it stands over (`under`, `CONFIG_NAME_RESOLVES`), optional distinct plan parts that draw this occluder (`over`, `CONFIG_NAME_RESOLVES`, `CONFIG_PART_UNIQUE`), optional receipted plate directory (`plate`, `ASSEMBLE_OCCLUDER_PLATE_*`), optional part name (`part`, `CONFIG_FIELD_TYPE`, `CONFIG_PART_NAME`, `CONFIG_PART_UNIQUE`, `CONFIG_PART_ATTACHED`), optional non-negative integer rig-px dilation radius (`grow`, `CONFIG_FIELD_TYPE`; absent means `0`), and an integer 0–255 (`rgb_within`). After any take and before projection, a pixel of an `under` part's selected layer at alpha above 128, where the occluder's alpha is above 0, within `rgb_within` (max channel) of the painting there, is the occluder's colour copied into the layer: `assemble` prints `WARN ASSEMBLE_OCCLUDER_COLOUR_COPIED` with the part, the rig px count and the first pixel. On the rig grid, occluder membership is the boolean core where the occluder image's alpha is strictly above `128` (`COPIED_ALPHA_ABOVE`), dilated by `growMask`'s `(2 * grow + 1)^2` square when `grow > 0` (`parts.json` records top-level `occluder_grow` with `{occluder, image, grow, covered_px_before, covered_px_after}` for each entry with `grow > 0`; the occluder-split take and `occluders[i].plate` do not read `grow`); holding is a front part's alpha at or above `250` (`CORE_ALPHA`). Under `--project visible`, an `under` part's pixels (and every cut piece or limb segment derived from it) inside
|
|
164
|
+
| `assemble.occluders` | assemble, build | **authored**, optional (issues #1230, #1237, #1241, #1246, #1251, #1259): `[{image, sha256, under, over?, plate?, part?, grow?, guard?, rgb_within}]` — an RGBA PNG of what stands in front of the character on the painting's grid (`image`, relative to the config's directory; another size refuses `ASSEMBLE_OCCLUDER_GRID`), its bytes' sha256 (`CONFIG_OCCLUDER_SHA256`), the plan parts it stands over (`under`, `CONFIG_NAME_RESOLVES`), optional distinct plan parts that draw this occluder (`over`, `CONFIG_NAME_RESOLVES`, `CONFIG_PART_UNIQUE`), optional receipted plate directory (`plate`, `ASSEMBLE_OCCLUDER_PLATE_*`), optional part name (`part`, `CONFIG_FIELD_TYPE`, `CONFIG_PART_NAME`, `CONFIG_PART_UNIQUE`, `CONFIG_PART_ATTACHED`), optional non-negative integer rig-px dilation radius (`grow`, `CONFIG_FIELD_TYPE`; absent means `0`), optional non-negative integer rig-px under-keep dilation radius (`guard`, `CONFIG_FIELD_TYPE`; absent means `0`), and an integer 0–255 (`rgb_within`). After any take and before projection, a pixel of an `under` part's selected layer at alpha above 128, where the occluder's alpha is above 0, within `rgb_within` (max channel) of the painting there, is the occluder's colour copied into the layer: `assemble` prints `WARN ASSEMBLE_OCCLUDER_COLOUR_COPIED` with the part, the rig px count and the first pixel. On the rig grid, occluder membership is the boolean core where the occluder image's alpha is strictly above `128` (`COPIED_ALPHA_ABOVE`), dilated by `growMask`'s `(2 * grow + 1)^2` square when `grow > 0` (`parts.json` records top-level `occluder_grow` with `{occluder, image, grow, covered_px_before, covered_px_after}` for each entry with `grow > 0`; the occluder-split take and `occluders[i].plate` do not read `grow`); holding is a front part's alpha at or above `250` (`CORE_ALPHA`). Under `--project visible`, an `under` part's pixels (and every cut piece or limb segment derived from it) inside the under-keep mask — the `alpha > 128` core dilated by `max(grow, guard)` via `growMask`'s `(2 * r + 1)^2` square (`parts.json` records top-level `occluder_guard` with `{occluder, image, guard, guarded_px_before, guarded_px_after}` for each entry with `guard > 0`; `guard` paints nothing, changes neither `occluders[i].part` nor `ASSEMBLE_OCCLUDER_UNHELD`, has no effect when `guard <= grow` though the record is still written, and is not read by the occluder-split take or `occluders[i].plate`) — keep the base run's surface rather than projecting `--source`. When `over` is declared, each `(over, under)` pair in an entry draws `over` in front of `under` regardless of mixed-run depth or two-run role band (`ASSEMBLE_OCCLUDER_DRAW_ORDER` if `assemble.plan` draws `over` behind `under`, `ASSEMBLE_OCCLUDER_DRAW_CYCLE` on contradictory `over`/`under` cycles, `ASSEMBLE_OCCLUDER_OVER_TAKEN` if an `over` part's layer is not taken by `assemble.take`). When `part` is declared, `assemble` emits a `painting:<part>` part (`parts/<part>.png`, placed immediately before the first slot of any `over` part of that entry across `full` and `head`, counting pieces cut from an `over` part — "before the first `over` part" wins when a piece derived from `under` sits after `over`, and when `over` is omitted the part is placed after the last slot derived from `under`) holding `--source` at alpha `255` over the occluder membership (`alpha > 128`, after `grow`) minus the pixels held at `alpha >= 250` (`CORE_ALPHA`) by every part drawn in front of it (`ASSEMBLE_OCCLUDER_EMPTY` if `0` rig px remain); when `part` is omitted and any occluder pixel (`alpha > 128`, after `grow`) is not held at `alpha >= 250` (`CORE_ALPHA`) by a part drawn in front of it, `assemble` prints `WARN ASSEMBLE_OCCLUDER_UNHELD` with the count and first pixel. |
|
|
165
165
|
| `assemble.editor_receipts` | assemble, build | **authored**, optional (issue #946): `{receipts: [{file, sha256, from_sha256, editor}], required?, trace_parts?}`. Each receipt records an image edited in an image editor; `file` (relative to the config's directory) must exist and hash to `sha256`, verified at assemble; `from_sha256` and `editor` are the author's declaration, held only to form. With `required: true`, every author-made layer, hidden-art layer, cut `under` and limb `cap` the build reads, alternate sets' runs included, needs a receipt whose `sha256` is its file's. With `trace_parts: true` (issue #947), every part's pixels must trace to a layer of the split or to a receipted image: the receipts are demanded as under `required`, and every shape the config draws through a part — a cut's `polygon`, `seethrough.arm_split`, a limb's `split.line`, a patch's `box`, a painting extension's `band` — is refused (`ASSEMBLE_PART_SOURCE`). Absent, no file is read and no byte moves. See [Editor receipts](#editor-receipts-assembleeditor_receipts-issue-946) and [Part sources](#part-sources-assembleeditor_receiptstrace_parts-issue-947). |
|
|
166
166
|
| `limbs` | assemble (the cut and the caps), rig (through `regions`), check (`LIMB_ONE_BONE`) | **proposed** by `propose --keypoints` (issue #349), then checked: `{<limb>: {segments: [{part, from, bone}, {part, from, bone, joint, range?, cap?, edge?, cap_shape?, cut_band?, hybrid?}, …], split?, layout?, front?}}`, the upper segment first. The rule is *Limbs: cut at their joints* below the table. `part` is a new part (`CONFIG_PART_NAME`, `CONFIG_PART_UNIQUE` against the plan, patches, cuts and every other limb part); `from` a plan part or a cut's piece (`CONFIG_NAME_RESOLVES`) — the layer the segment's pixels come from, which is cut into the limb parts and is not itself made: a `meshes` or `regions` entry for it is `CONFIG_NAME_RESOLVES`, and the segments of one limb that take one part are consecutive (`CONFIG_LIMB_FROM_RUN`); `bone` a declared bone, each segment's the child of the one before (`CONFIG_LIMB_BONES_CHAIN`); the upper segment names no `joint`, `range`, `cap`, `edge`, `cap_shape` or `cut_band` (`CONFIG_KEY_KNOWN`), every other names its `joint` (`CONFIG_FIELD_PRESENT`) — the joint is its bone's origin; `range` is `[min, max]` degrees from rest with `min <= 0 <= max` (`CONFIG_LIMB_RANGE`), which `assemble` writes into the lower part's `parts.json` record and `check` poses the joint at — its two ends and its middle — reading the seam there (`SEAM_OVER_RANGE`, issue #360; rig-c needs no rotation limit); `cap` a PNG path relative to the config's directory (`CONFIG_FIELD_TYPE`); `edge` `"feather"` (issue #360), the one value it takes, and `cap_shape` `"disc"` (issue #360) or `"ball"` (issue #579) (`CONFIG_FIELD_TYPE` on any other) — the cut's geometry at that joint, *Limbs: cut at their joints* below; absent, the cut is hard and the cap the layer's half-disc of half the limb's width; `cut_band` a whole number of px, 1 or more (`CONFIG_FIELD_TYPE`), on a segment that takes the segment above's part — between two layers nothing is cut, so a band there is `CONFIG_KEY_KNOWN` — places the cut within that many px of the joint line (issue #360, *Limbs: cut at their joints*); absent, the cut is the joint line. Each limb part is attached like any part — `regions.<part>`, which must be the segment's `bone` (`CONFIG_LIMB_BONE`), or a mesh, which `check` holds to that bone alone (`LIMB_ONE_BONE`). With `limbs`, `assemble` reads `bones` too (`CONFIG_FIELD_PRESENT` without it). Absent, nothing is cut at a joint and no byte of any output moves. Optional `front` (issue #664), `{parts: [<own segment part>, …], after: "<produced part>"}`, gives each named segment a second slot `<part>_front`, empty at setup, placed after `after`'s slot family, for a gesture set to draw on (`CONFIG_FRONT_SCOPE`, `CONFIG_FRONT_NAME`, `CONFIG_FRONT_LAYOUT`; *Front slots (issue #664)* below) |
|
|
167
167
|
| `bones` | rig; `propose --from-config` | **proposed** by `propose`, then corrected. A single bone `{name, parent, at, tip?}` or a chain `{chain, parent, points, tip, link_inherit?}` whose links are named `<chain>0 … <chain>n`. Parents come before children. In `rig.json` each link is **turned along its chain** — `rotation` is the direction from its origin to the next link's (the last link's to `tip`) and `length` that distance (issue #73), so a physics constraint added downstream finds a lever; under `--idle-keys ctl` the link's `<link>_ctl` carries the turn and the length and the link sits at local rotation 0 beneath it. A single bone with a `tip` is turned the same way, towards its tip, with that distance as its length (issue #239); a tip on the bone's own origin is refused (`RIG_TIP_DISTINCT`). The five face bones `eye_r`, `eye_l`, `brow_r`, `brow_l` and `mouth` (by name, when one has no tip of its own) are turned to the eye line — the line through the origins of `eye_r` and `eye_l` as `bones` writes them, read image-left to image-right, drawn when parts.json holds both an `eyewhite-r` and an `eyewhite-l` part — so the blink's `scaley` squashes across the eye line on a tilted head; move an eye bone and the line moves with it. With one eyewhite or none, or an eye bone missing, the rig stage's `face axis:` line says so and they keep the page's axes. A bone under a face bone keeps the face's axis. With the line, `rig.json` also declares `invariants.axes` — one entry, `"face"`, through `eye_r` and `eye_l`, holding the turned face bones (and their controls) — so rig-c's gate holds the build to the line; the line is the one rigc draws through the same two bones, so the tolerance is only the float floor — the largest gap the emitted (float32) bones have to it, rounded up to 6 places plus one 6-place unit — and the `face axis:` line prints it. With the line the rig stage also adds `head_up` (issue #250): a slotless bone under `head`, at head's origin, turned to the eye line + 90 degrees and as long as the eye midpoint lies from head's origin along that axis — the head's frame, which a rule that needs it reads; `head` keeps its own frame, so no key on it or under it changes meaning, and a config bone of that name is refused (`RIG_HEAD_UP_NAME_FREE`). A face bone with its own `tip` is held too (issue #258), in a second entry, `"face_tips"`, when its tip lies along the line within whole-pixel rounding — a tip written in whole pixels sits at most sqrt(2)/2 px off the point of the line it stands for, so its direction may sit up to asin((sqrt(2)/2) / length) degrees off — with its tolerance measured the same way; a tip further off is the bone's own axis, and the `face axis:` line names it with its gap and that bound. A failure is rig-c's `A51_BONES_LIE_ALONG_THEIR_DECLARED_AXIS` line, which names the bone and the fix (rig-c's `docs/AUTHORING.md` §3.7 and §5.2); with no line no entry is written and A51 reports SKIP. Every region on a turned bone is turned back, so the setup pose does not move. Any other single bone keeps world rotation 0; one whose parent is a link is turned back upright. A single bone may declare `inherit` (issue #348): what it takes from its parent's transform, one of rig-c's own mode names exactly as rig-c's table spells them — `normal`, `onlyTranslation`, `noRotationOrReflection`, `noScale`, `noScaleOrReflection` (rig-c's `RigBone.inherit`) — written to that bone in `rig.json` as declared; any other spelling, `"NoScale"` included (the runtime would fold its first letter; nothing here folds or maps), is refused (`CONFIG_BONE_INHERIT`), and a chain takes no `inherit` (`CONFIG_KEY_KNOWN`). A chain may instead declare `link_inherit` (issue #369), an object mapping its own expanded link names to those same modes, for example `"link_inherit": {"leg_r1": "noScale"}`. Only the named link changes; omitted links inherit normally. A key outside this chain is `CONFIG_NAME_RESOLVES`, with this chain's valid link names in the detail; a non-object or non-string mode is `CONFIG_FIELD_TYPE`, and another mode spelling is `CONFIG_BONE_INHERIT`. The mode is forwarded to the expanded link, or to its control under `--idle-keys ctl`, by the same rule as a single bone. This is an authored opt-in: `propose` does not add it. Its setup rotation is the turn from where rig-c's own poser puts the bone with no rotation of its own under that mode, so it still stands upright (or along its tip) at the setup pose. Where the idle gives the bone a `<bone>_ctl`, the mode goes on the control: the control is the bone the parent's rotation reaches, and the bone under it inherits normally, so the idle's keys moved onto the control still turn it. A foot that does not take its shin's rotation (`noRotationOrReflection` or `onlyTranslation`) keeps its shoe level while the leg is posed (`FEET_STAY_LEVEL`, §7); which mode is the author's. `noScale` keeps a shin or shoe's shape under a scaled parent but still takes the parent's rotation: a shoe that must also stay level needs a separate rotation constraint, for example a transform constraint from an unrotated bone. This does not change the proposed feet's existing inheritance or `FEET_STAY_LEVEL` default. An automatic mesh weighted through a bone with a mode other than `normal` gets no derived amplitude (its row names the bone) and no residual envelope (rig-c's `SKINNING_RANGE_UNSUPPORTED`). Absent, `rig.json` carries no `inherit` and no byte moves |
|
|
@@ -5434,7 +5434,11 @@ or a joint.
|
|
|
5434
5434
|
pixels at or below `128` take the donor run's pixel (transparent included,
|
|
5435
5435
|
overwriting base pixels outside the occluder), and donor `st_input` identity is
|
|
5436
5436
|
checked on the donor's visible support only (`ASSEMBLE_TAKE_SPLIT_EMPTY` if
|
|
5437
|
-
either `covered_px` or `visible_px` at `alpha > 8` is `0`).
|
|
5437
|
+
either `covered_px` or `visible_px` at `alpha > 8` is `0`). During assembly,
|
|
5438
|
+
the base and donor layers are warped to the rig grid separately and the split
|
|
5439
|
+
is chosen on the rig grid from the un-grown occluder mask (`alpha > 128`)
|
|
5440
|
+
before projection, so resampling never blends across the occluder edge (issue
|
|
5441
|
+
#1251). `parts.json` records
|
|
5438
5442
|
`split: {occluder, image, sha256, covered_px, visible_px}` on that part's
|
|
5439
5443
|
`taken_layers` entry. `assemble --propose-plan` accepts occluder-split takes,
|
|
5440
5444
|
drafting the row from the split's `tag` on the merged layer while still
|
|
@@ -5476,6 +5480,27 @@ or a joint.
|
|
|
5476
5480
|
`grow > 0`). The occluder-split take (#1242) and `occluders[i].plate` (#1240)
|
|
5477
5481
|
do **not** read `grow`.
|
|
5478
5482
|
|
|
5483
|
+
An optional `guard` integer `>= 0` on `config.assemble.occluders[i]` (issue
|
|
5484
|
+
#1259; `CONFIG_FIELD_TYPE` on a negative number, non-integer or non-number;
|
|
5485
|
+
absent means `0` and is never defaulted or inferred) widens only the
|
|
5486
|
+
`--project visible` under-keep mask around the `alpha > 128`
|
|
5487
|
+
(`COPIED_ALPHA_ABOVE`) boolean core on the rig grid, so an anti-aliased or
|
|
5488
|
+
soft outer ring of the occluder (`alpha <= 128`) is not projected from
|
|
5489
|
+
`--source` into `under` parts. `guard` paints nothing: it changes neither
|
|
5490
|
+
`occluders[i].part` nor `ASSEMBLE_OCCLUDER_UNHELD`, and no part gains alpha
|
|
5491
|
+
from it. When both `grow` and `guard` are declared, the under-keep mask is the
|
|
5492
|
+
`alpha > 128` core dilated by `max(grow, guard)` with `growMask`'s
|
|
5493
|
+
`(2 * r + 1)^2` square while `occluders[i].part` and
|
|
5494
|
+
`ASSEMBLE_OCCLUDER_UNHELD` read the core dilated by `grow` only. When any
|
|
5495
|
+
entry has `guard > 0`, `parts.json` writes top-level `occluder_guard` with one
|
|
5496
|
+
`{occluder, image, guard, guarded_px_before, guarded_px_after}` record per
|
|
5497
|
+
such entry, counting the `alpha > 128` core (`guarded_px_before`) and the
|
|
5498
|
+
entry's under-keep mask (`guarded_px_after`) on the rig grid; when
|
|
5499
|
+
`guard <= grow`, `guard` has no effect (`guarded_px_after` equals the
|
|
5500
|
+
grow-only under-keep count), and the record is still written so the no-op is
|
|
5501
|
+
visible. The occluder-split take (#1242) and `occluders[i].plate` (#1240) do
|
|
5502
|
+
**not** read `guard`.
|
|
5503
|
+
|
|
5479
5504
|
`<out>` holds `plate.png`, `mask.png` (the mask actually used: opaque white
|
|
5480
5505
|
inside, opaque black outside) and `receipt.json`, spec
|
|
5481
5506
|
`rig-parts-plate-receipt/1` ([STABILITY](STABILITY.md#plate-receipt)). A receipted
|
package/docs/STABILITY.md
CHANGED
|
@@ -317,7 +317,7 @@ part name, `[i]` an entry of a list):
|
|
|
317
317
|
- **assemble** — required: `rig_scale`, `plan` (from plain `assemble` on); optional: `seam`, `project`, `ground`, `extend_below_crop`, `patches`, `cuts`, `alternates`, `head_face_underfill`, `yield_refused`, `stage_map`, `keep_under_occluders`, `require_hidden_extent`, `extend_painting`, `edge_splits`, `take`, `editor_receipts`, `occluders`
|
|
318
318
|
- **assemble.edge_splits[i]** — required: `over`, `under`, `band`
|
|
319
319
|
- **assemble.require_hidden_extent[i]** — required: `part`, `occluder`
|
|
320
|
-
- **assemble.occluders[i]** — required: `image`, `sha256`, `under`, `rgb_within`; optional: `over`, `plate`, `part`, `grow` (issues #1230, #1237, #1241, #1246, #1251)
|
|
320
|
+
- **assemble.occluders[i]** — required: `image`, `sha256`, `under`, `rgb_within`; optional: `over`, `plate`, `part`, `grow`, `guard` (issues #1230, #1237, #1241, #1246, #1251, #1259)
|
|
321
321
|
- **assemble.alternates[i]** — required: `name`; optional: `source`, `full`, `head`, `parts`, `hides`, `head_box`, `cuts`, `skeleton`, `anchor`, `base_anchor`, `drawn`, `tips`, `front`, `layers`, `focus` (issues #454, #465, #543, #652, #664, #666, #719, #780). `focus` is an authored finite `[x, y]` in painting pixels, within its canvas (edges included), refused as CONFIG_SET_FOCUS before assemble output when invalid; only when present, `parts.json` records it with focus_source_size and `sets.json` emits it in setup-world coordinates through the actual rig resize and `src/coords.ts`. Absent focus emits no field or inferred value; changing/removing it requires reassembly
|
|
322
322
|
- **assemble.extend_below_crop[i]** — required: `part`, `run`, `tag`; optional: `edges` (left, right, top, bottom; explicit edges require a head-run part and the full-run layer of the same tag)
|
|
323
323
|
- **assemble.extend_painting[i]** — required: `part`, `band`, `max_distance`; optional: `min_held_alpha`, `order` (issues #848, #854, #855; explicit final layer-derived part, half-open rig band and positive four-neighbour path bound; base painting only). The optional integer floor 1–255 admits exact original alpha-over coverage strictly below it; absent or 1 blocks every nonzero holder. Only selected target samples below the floor may take painting RGBA; target samples at/above the floor and every non-target holder remain exact. By default overlapping reachable claims refuse. With `order` on every entry (unique nonnegative safe integers), lower values claim first and their gains block later candidates and paths; array order never breaks ties or supplies missing precedence
|
|
@@ -550,7 +550,7 @@ resolution before resizing; it can differ for non-opaque paintings.
|
|
|
550
550
|
| file | written by | what is stable |
|
|
551
551
|
| --- | --- | --- |
|
|
552
552
|
| `stage-map.json` | `assemble`, `build`, under `assemble.stage_map: true` | `rig-parts-stage-map/1`, cropped last-writer and pre-seam RLE maps with writer dictionaries and excluded counts. See [Per-pixel stage map](AUTHORING.md#per-pixel-stage-map). |
|
|
553
|
-
| `parts.json`, `parts/<name>.png` | `assemble`, `build` | one record per part: `from` (`<run>:<tag>` with a See-through v3 tag, `<run>:author:<label>` for a layer the author made — issue #256, read by no role rule — or `painting:<name>` for a patch), `cut_from` on a cut's piece only (the plan part it was cut from, issue #230), `limb` on a limb segment's part only (issue #349: `name`, `segment`, `of`, `bone`, and below a joint `joint`, `range` when the config segment declares one (issue #360), and `cap` — `at`, `width`, `radius`, `box`, `layer_px`, `image_px` with a cap image, `image_layer` after it when that image was a hidden-art layer — issue #359, `<run>:<layer>:hidden` — `missing_px`, `short_px` (`left`, `right`) after it only when `missing_px` is above 0 (issue #557, additive), `excluded_px` after them only on a subset set's limb part whose cap the set exclusion took a pixel of (issue #603, additive: each pixel taken out of the count it was in, so the cap's counts are the written PNG's), then `shape` and `upper_px` under the segment's `cap_shape` — `upper_px` without the shape only when the upper segment gave a pixel (issue #557, additive) — and after them `lower_px`, `lower_kept_px` and `lower_missing_px` under `cap_shape: "ball"` (issue #579, additive), and `edge`, `feather_radius` and `feathered_px` under its `edge`, and `cut_band`, `cut_offset`, `cut_at`, `cut_crossed`, `joint_crossed`, `band_px` and `stroke_luma_max` (when the band has a split) under its `cut_band`, issue #360), the box `x`, `y`, `w`, `h` (rig px), the pixel counts `src/parts.ts` documents (`opaque_px`, `visible_px`, `occluded_px`, `projected_core_px`, `source_px_taken`, `visible_not_projected_px`, `refused_drift_px`, `merged_px` — on a subset set's limb part counted after the set exclusion, issue #603 — `seam_override_px`, and `fringe_pushed_back` when not empty); per-part `taken_layers` (with optional `transport`, issue #973, and optional `split` — `occluder`, `image`, `sha256`, `covered_px`, `visible_px` — on a split take, additive, issue #1242) and `provenance` (`unchanged_layer_px`, `hand_px`, `automatic_px`, `edits`, `automatic`, additive, issue #823); optional top-level `motion_seams`, `occluder_plates` (one record per `assemble.occluders` entry declaring `plate` — `receipt`, `receipt_sha256`, `occluder_sha256`, `painting_sha256`, `output_sha256`, `mask_sha256`, additive, issue #1237), `occluder_grow` (one record per `assemble.occluders` entry with `grow > 0` — `occluder`, `image`, `grow`, `covered_px_before`, `covered_px_after`, additive, issue #1251), `alternates` and `cut_ownership` (one row per cut, independent of RGBA equality, issue #823, with optional `under_plate` — `receipt`, `receipt_sha256`, `occluder_sha256`, `painting_sha256`, `output_sha256`, `mask_sha256` — on a `{plate}` under, additive, issue #1230); `rig_size`, `scale_rig_per_source`, `ghost_px`, `recomposite`, and `scene` (`figure_alpha_above`, `figure_px`, `figure_mask`) under `config.scene` only, with the figure's mask `figure_rig.png` beside the recomposite (issue #242), and the same bytes beside `parts.json` when the two directories differ (issue #1177); `single_run_pad` (`file_size`, `side`, `left`, `top`) last, only for one run whose file is not the `seethrough.resolution` square (issue #366) |
|
|
553
|
+
| `parts.json`, `parts/<name>.png` | `assemble`, `build` | one record per part: `from` (`<run>:<tag>` with a See-through v3 tag, `<run>:author:<label>` for a layer the author made — issue #256, read by no role rule — or `painting:<name>` for a patch), `cut_from` on a cut's piece only (the plan part it was cut from, issue #230), `limb` on a limb segment's part only (issue #349: `name`, `segment`, `of`, `bone`, and below a joint `joint`, `range` when the config segment declares one (issue #360), and `cap` — `at`, `width`, `radius`, `box`, `layer_px`, `image_px` with a cap image, `image_layer` after it when that image was a hidden-art layer — issue #359, `<run>:<layer>:hidden` — `missing_px`, `short_px` (`left`, `right`) after it only when `missing_px` is above 0 (issue #557, additive), `excluded_px` after them only on a subset set's limb part whose cap the set exclusion took a pixel of (issue #603, additive: each pixel taken out of the count it was in, so the cap's counts are the written PNG's), then `shape` and `upper_px` under the segment's `cap_shape` — `upper_px` without the shape only when the upper segment gave a pixel (issue #557, additive) — and after them `lower_px`, `lower_kept_px` and `lower_missing_px` under `cap_shape: "ball"` (issue #579, additive), and `edge`, `feather_radius` and `feathered_px` under its `edge`, and `cut_band`, `cut_offset`, `cut_at`, `cut_crossed`, `joint_crossed`, `band_px` and `stroke_luma_max` (when the band has a split) under its `cut_band`, issue #360), the box `x`, `y`, `w`, `h` (rig px), the pixel counts `src/parts.ts` documents (`opaque_px`, `visible_px`, `occluded_px`, `projected_core_px`, `source_px_taken`, `visible_not_projected_px`, `refused_drift_px`, `merged_px` — on a subset set's limb part counted after the set exclusion, issue #603 — `seam_override_px`, and `fringe_pushed_back` when not empty); per-part `taken_layers` (with optional `transport`, issue #973, and optional `split` — `occluder`, `image`, `sha256`, `covered_px`, `visible_px` — on a split take, additive, issue #1242) and `provenance` (`unchanged_layer_px`, `hand_px`, `automatic_px`, `edits`, `automatic`, additive, issue #823); optional top-level `motion_seams`, `occluder_plates` (one record per `assemble.occluders` entry declaring `plate` — `receipt`, `receipt_sha256`, `occluder_sha256`, `painting_sha256`, `output_sha256`, `mask_sha256`, additive, issue #1237), `occluder_grow` (one record per `assemble.occluders` entry with `grow > 0` — `occluder`, `image`, `grow`, `covered_px_before`, `covered_px_after`, additive, issue #1251), `occluder_guard` (one record per `assemble.occluders` entry with `guard > 0` — `occluder`, `image`, `guard`, `guarded_px_before`, `guarded_px_after`, additive, issue #1259), `alternates` and `cut_ownership` (one row per cut, independent of RGBA equality, issue #823, with optional `under_plate` — `receipt`, `receipt_sha256`, `occluder_sha256`, `painting_sha256`, `output_sha256`, `mask_sha256` — on a `{plate}` under, additive, issue #1230); `rig_size`, `scale_rig_per_source`, `ghost_px`, `recomposite`, and `scene` (`figure_alpha_above`, `figure_px`, `figure_mask`) under `config.scene` only, with the figure's mask `figure_rig.png` beside the recomposite (issue #242), and the same bytes beside `parts.json` when the two directories differ (issue #1177); `single_run_pad` (`file_size`, `side`, `left`, `top`) last, only for one run whose file is not the `seethrough.resolution` square (issue #366) |
|
|
554
554
|
| `rig/rig.json`, `rig/motion.json`, `rig/images/` | `rig`, `build`, `compose` | rig-c's rig spec and motion spec, `spec` `rigc-rig/1` and `rigc-motion/1`: the format is rig-c's, and this package writes only what rig-c's parser accepts; a bone carries `inherit` only where config.bones declares one, rig-c's mode name as written (issue #348) |
|
|
555
555
|
| `rig/mesh_report.json` | `rig`, `build` | one row per mesh: `part`, `vertices`, `triangles`, `hull`, `bones` (the sorted names the attachment's weights bind in the written `rig.json`, in every mode — since 1.49.1 (issue #536) a rig with `turn` or `stops` names the twins and `<link>_d` bones there, where the row named the segment bones they replace: a fix of a wrong name, not a format change; a rig with neither writes the bytes it wrote), `max_influences`, `mean_influences`, `art_coverage`, then `grid` (a lattice); or `mode` "explicit" with `image_sha256` and `region_sha256` (the verified guards; counts and coverage are measured from the supplied mesh, no legacy generator report is adopted); `mode` "contour" with `params`, `contour`, `regions` (`params.maxEdge` and `contour.outlineCut` only when the mesh declares `contour.maxEdge`; `params.bridges` and `contour.bridges` — `islands`, `units`, `joins`, and `faint` only when an island was left out as faint — only when it declares `contour.bridges`); or `mode` "influence" with `influence` (as declared), `reach` (`farthest`, `at`, `nearest`, `capped`, `widest`) and `lattice` (rig-c's `SegmentsLatticeReport`: `cols`, `rows`, `artCells`, `keptCells`, `passes`, `islands`) (issue #378); or `mode` "auto" with `settings`, `source`, `result`, `residuals`, `worst_residual`, `worst_region`, `motion_amplitude`, `termination`, `weights`, `regions`, `deformation`, `quality_report` (rig-c's `mesh-quality-report/1` document whole), `motion_report`, and, only when they apply, `stray_cleared` (after `source`, when `source.stray` is declared), `skinning_residual` and `replay` (`AutoMeshReport` in `src/rig.ts`); in every mode, `exponent` when the mesh declares one (after `grid`, or after `mode`); `influences`, as declared, when a lattice or contour mesh declares it (after `exponent`, or where `exponent` would be); `stray` and `stray_cleared` when a lattice mesh declares `stray` (after `influences`, or where `influences` would be); `ribs` when a contour or auto mesh declares them (after `exponent`, or after `mode`), and then `contour.ribs` (`source.contour.ribs` in the automatic mode) |
|
|
556
556
|
| `check/check.json` and the rest of `check/` | `check`, `build`, `compose` | the reference's fields in its order (`gate_spine_html_green`, `rigc_entry`, `pack_mode`, `environment` after it under `--environment` only (issue #538, additive: `path` as given, `sha256`, `steps`), `loop_max_diff`, the seam figures — `seam_mean`, `seam_px_over_40`, `seam_px_over_80` and, from issue #216, `seam_frame_scale`, the frame scale the bar divides the count by), `loop_physics` after `loop_max_diff` when the rig declares a physics constraint, `seam_border` after the seam figures when `parts.json` declares a scene (issue #242), `seam_pairs` after the seam figures when the seam bar fails or `--seam-pairs` asks (each row's picture under `check/seam/`; `--keep-stills` leaves the setup-pose still and its `frames.json` under `check/setup_still/`), then the judgement lines (`BREATH_VISIBLE`, `BLINK_NO_HOLE`, `CHAIN_LAG`, `TIP_OVER_ROOT`, `STILL_REGIONS_DARK`, `TEXTURE_STRETCH`), `ANIMATIONS_DO_NOT_FOLD` after them when `motion.json` holds an animation, the idle included — on every rig with an idle since issue #333 (issues #320, #363: `status`, `animations`, `fps`, `physics_left_out`, `folding` — each `animation`, `slot`, `attachment`, `frames`, `worst_frame`, `worst_triangles`, `triangles`, `physics_on`, `physics_off`, `physics_constraints`, `declared`, `line` — `folding_undeclared`, `declared_not_folding`, `bar`), `FEET_STAY_LEVEL` after it when a `footwear` part rides a bone that hangs from another and `motion.json` holds an animation (issue #348: `status`, `reason` on a SKIP only, `animations`, `fps`, `physics_left_out`, `bar_degrees`, `bar`, `feet` — each `part`, `bone`, `hangs_from`, `status`, `frames_posed`, `worst`), `LIMB_ONE_BONE` after it (and after `STRESS_OFF_CHAIN` where that is written) when `parts.json` holds a limb segment's part (issue #349: `status`, `parts` — each `part`, `limb`, `bone`, `status`, `others`), `SEAM_OVER_RANGE` after it when a limb record carries a `range` (issue #360: `status`, `frame_scale`, `physics_left_out`, `bar` — `mean`, `rig_px_over_40`, `level` — and `joints`, each `part`, `limb`, `segment`, `joint`, `bone`, `range`, `at`, `radius`, `under_px`, `status`, `poses` — each `degrees`, `status`, `mean`, `px_over_40`, `px_over_80`, `rig_px_over_40`, and `step_px` (`left`, `right`) only on a joint whose cap record carries `short_px` (issue #557, additive) — and `unread` on a joint not read), `SEAM_OVER_MOTION` after it when `parts.json` holds a limb segment or `--requirements` a `seam` (issue #493 retains existing pair warnings; issue #686 gates GAP on proven body-root pairs only (gap-only; mixed ghost remains INFO until rig-c/core#1555 supplies owners): `status` — `WARN`, `CLEAR`, `SKIP` or `FAIL` — `reason` on a SKIP only, `fps`, `floor`, `pairs` — each `pair`, `a`, `b`, `declared`, optional `root` (`limb`, `bone`, `parent`) on a proven body-root pair, and `unread` on a pair not read — `animations`, `warnings`, `rows` — each `pair`, `animation`, `status`, `drawn`, `banded`, `opens`, `px`, `max_px`, `under_floor`, and only on new-root rows stock `gapOpen` plus UNDER-owned `ghostA`/`ghostB` cells selected by resolved per-frame draw order gate their summed count against the unchanged strict one-cell floor on the original raw kind boxes (their union when both kinds contribute), never narrowed partition boxes, while `gapCovered` and OVER-owned ghost cells are excluded (issue #711); `cells` retains partition counts, UNDER owner and counted total, `worst` retains frame/count/cell/box, and `roots` retains status, mode `gap-open+under-ghost`, ghost_owner `resolved-draw-order`, pairs, failed, reason and optional unmeasured bindings; eligible candidates whose valid setup bands are all zero retain a named unmeasured root and SKIP bar, including when no pair is selected; measured root FAIL wins over SKIP, while measured PASS plus an unmeasured root remains SKIP; every eligible body drawing with stock setup `banded > 0` is selected, including both when a parent is shared; issue #708 resolves a body slot on its exact generated turn child to the same named carrier only after unique identity-bone/control/per-part-transform proof, without changing pair identity, setup selection or the direct-carrier path; setup-only observation preserves the authored motion and default drawing, root-free inputs add no setup compile/render, and no animation remains SKIP rather than a measured zero; existing internal pair warnings and their exits are unchanged; issue #941 adds optional `required` only under the requirements file's `seam_over_motion.required: true` — `status` (`PASS` or `FAIL`), `mode` `gap-open`, `bar_px` 0, `pairs` (each `pair`, `class` — `body-root`, `internal-joint` or `explicit` — `frames`, `background_frames`, `max_px`) and `failed` — and with it the key is written even when no pair is declared; issue #591 adds optional `worlds` on physics rigs with readable declared pairs and animations: `default` and `still`, each `wind`, `gravity`, `status` (`REPORTED` or `SKIP`), `reason` on SKIP, `dir` only when rendered (relative to check.json: `seam_motion/default` or `seam_motion/still`, the complete retained render with frames.json and each animation's raw seam.json), and `rows` — pair, animation, status, drawn, banded, `gap` and `ghost`, each `max_px` and `worst` only; worst carries `index`, `px`, `cell`, `box`. Per-frame hits stay in the raw sidecars. These raw reference readings add no bar or warning and leave the custom environment reading unchanged), `CLOTH_SETTLES` after it when the rig declares a physics constraint and has an idle (issue #501, a warning and not a bar: `status` — `WARN` or `CLEAR` — `fps`, `frames`, `duration`, `floor_rig_px_per_s`, `floor`, `levers`, `warnings`, `rows` — each `tip`, `root`, `links`, `point`, `settles_at`, `max_rig_px_per_s`, `min_rig_px_per_s`), `RECOMPOSITE_HOLES` (its first figure `declared_scene` when `parts.json` declares a scene), `SETUP_POSE_VS_SOURCE`, `WIND_BAND` after it under `--wind-band` only (issue #590, additive: `status` `"REPORTED"`, `spec` `"rig-parts-wind-band/1"`, `path` as given, `sha256`, `steady_wind_only` `true`, `gravity` `[0, 1]`, `min`, `max`, `step`, `steps`, `fps`, `animations`, `max_gap`, `max_ghost`, `holds_from`, `holds_to`, `pairs_holding_all`, and `pairs` — each `pair`, `a`, `b`, `holds_all`, `holds_from`, `holds_to`, `first_break_below`, `first_break_above`, `worst_gap`, `worst_ghost`, `steps`), `skipped`, `config` under `build` only (issue #607, additive: `path` as `--config` was typed, `sha256` of the bytes the build read; `check` and `compose` read no config and write none), a `requirements` block under `--requirements` (or `build`'s `config.requirements`) — `file` first from issue #556, additive: `path` as typed or declared, `sha256`, `keys` — and `PASS`; `check/build/skeleton.json`, `.atlas` and `.png` are the packed artifact rig-c writes. Missing stock partitions or resolved owner are named refusals, never zero. No whole-box exemption or consumer compositor remains; internal warnings and reference raw readings are unchanged. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spine-parts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.37.0",
|
|
4
4
|
"description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"ag-psd": "^31.0.2",
|
|
71
|
-
"@rig-c/core": "3.
|
|
71
|
+
"@rig-c/core": "3.7.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@esotericsoftware/spine-core": "4.3.13",
|
package/src/assemble.ts
CHANGED
|
@@ -123,7 +123,7 @@ import { foldName, PartsError, type Problem, refuseIfAny } from './errors.ts';
|
|
|
123
123
|
import { CORE_ALPHA, figuresPhrase, implausibleRules, type Layer, type LayerFigures, layerFigures, type LayerSet, NEAR_WHITE_MIN, OPAQUE_ALPHA_ABOVE, ruleSummary } from './layers.ts';
|
|
124
124
|
import { padToSquare, squarePad } from './inputs.ts';
|
|
125
125
|
import type { MotionSeamDeclaration } from './motionseams.ts';
|
|
126
|
-
import { type CapRecord, type LimbRecord, FIGURE_MASK_FILE, type OccluderGrowRecord, PAINTING_RUN, type PartRecord, type PartsFile, type RecompositeRecord, type SceneRecord, type SingleRunPad } from './parts.ts';
|
|
126
|
+
import { type CapRecord, type LimbRecord, FIGURE_MASK_FILE, type OccluderGrowRecord, type OccluderGuardRecord, PAINTING_RUN, type PartRecord, type PartsFile, type RecompositeRecord, type SceneRecord, type SingleRunPad } from './parts.ts';
|
|
127
127
|
import { growMask } from './plate.ts';
|
|
128
128
|
import { assignCrossedLimbs, assignOverlappingHands, type BonePlace, bonePlaces, capBox, coveredRadius, type CutPlacement, featherWeight, halfWidthAbout, inDisc, jointLine, type JointLine, jointOffsets, limbPolyline, limbRun, luma601, nearestLimb, nearestOnLine, offLineFigure, pastJoint, placeCut, polylineDist2, segmentOf } from './limbs.ts';
|
|
129
129
|
import {
|
|
@@ -294,10 +294,20 @@ export function padSingleRun(set: LayerSet, frame: Pick<Frame, 'fullPad' | 'full
|
|
|
294
294
|
const dx = frame.fullPad;
|
|
295
295
|
const dy = frame.fullPadTop;
|
|
296
296
|
if (dx === 0 && dy === 0 && set.canvas.w === resolution && set.canvas.h === resolution) return set;
|
|
297
|
+
const shiftLayer = (l: Layer): Layer => ({
|
|
298
|
+
...l,
|
|
299
|
+
left: l.left + dx,
|
|
300
|
+
top: l.top + dy,
|
|
301
|
+
right: l.right + dx,
|
|
302
|
+
bottom: l.bottom + dy,
|
|
303
|
+
...(l.occluderSplit === undefined
|
|
304
|
+
? {}
|
|
305
|
+
: { occluderSplit: { occluder: l.occluderSplit.occluder, base: shiftLayer(l.occluderSplit.base), donor: shiftLayer(l.occluderSplit.donor), merged: l.occluderSplit.merged } }),
|
|
306
|
+
});
|
|
297
307
|
return {
|
|
298
308
|
...set,
|
|
299
309
|
canvas: { w: resolution, h: resolution },
|
|
300
|
-
layers: set.layers.map(
|
|
310
|
+
layers: set.layers.map(shiftLayer),
|
|
301
311
|
hidden: set.hidden.map((l) => ({ ...l, left: l.left + dx, top: l.top + dy, right: l.right + dx, bottom: l.bottom + dy })),
|
|
302
312
|
};
|
|
303
313
|
}
|
|
@@ -1954,6 +1964,68 @@ export function layerToRig(canvas: Raster, frame: Frame, run: Run): Raster {
|
|
|
1954
1964
|
return out;
|
|
1955
1965
|
}
|
|
1956
1966
|
|
|
1967
|
+
/**
|
|
1968
|
+
* Resample an occluder image (on the painting's grid) onto the `W x H` rig grid
|
|
1969
|
+
* by nearest centre (`alpha > COPIED_ALPHA_ABOVE`), before any `grow`.
|
|
1970
|
+
*/
|
|
1971
|
+
export function occluderCoreMask(image: Raster, W: number, H: number): { coreBefore: Mask; coveredBefore: number } {
|
|
1972
|
+
const occSx = (x: number): number => Math.min(image.width - 1, Math.floor((x + 0.5) * image.width / W));
|
|
1973
|
+
const occSy = (y: number): number => Math.min(image.height - 1, Math.floor((y + 0.5) * image.height / H));
|
|
1974
|
+
const coreBefore = newMask(W, H);
|
|
1975
|
+
let coveredBefore = 0;
|
|
1976
|
+
for (let y = 0; y < H; y++) {
|
|
1977
|
+
const srcY = occSy(y);
|
|
1978
|
+
for (let x = 0; x < W; x++) {
|
|
1979
|
+
const a = image.data[(srcY * image.width + occSx(x)) * 4 + 3];
|
|
1980
|
+
const p = y * W + x;
|
|
1981
|
+
if (a > COPIED_ALPHA_ABOVE) {
|
|
1982
|
+
coreBefore.data[p] = 1;
|
|
1983
|
+
coveredBefore++;
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
return { coreBefore, coveredBefore };
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
/**
|
|
1991
|
+
* Issue #1251: place a layer on the rig grid, warping an occluder-split layer's
|
|
1992
|
+
* base and donor runs through {@link layerToRig} separately and picking between
|
|
1993
|
+
* them on the rig grid using the occluder's boolean core (`alpha > 128`, before
|
|
1994
|
+
* any `grow`) so resampling never blends base and donor across the occluder edge.
|
|
1995
|
+
*/
|
|
1996
|
+
export function layerToRigSplit(
|
|
1997
|
+
layer: Layer,
|
|
1998
|
+
resolution: number,
|
|
1999
|
+
frame: Frame,
|
|
2000
|
+
run: Run,
|
|
2001
|
+
occluderCoreMasks: readonly Mask[],
|
|
2002
|
+
cleaned = false,
|
|
2003
|
+
): Raster {
|
|
2004
|
+
const toRig = (l: Layer): Raster => {
|
|
2005
|
+
const placed = placeLayer(l, resolution);
|
|
2006
|
+
return layerToRig(cleaned ? cleanGhosts(placed).canvas : placed, frame, run);
|
|
2007
|
+
};
|
|
2008
|
+
const split = layer.occluderSplit;
|
|
2009
|
+
const mask = split === undefined ? undefined : occluderCoreMasks[split.occluder];
|
|
2010
|
+
if (split === undefined || layer.pixels !== split.merged || mask === undefined) return toRig(layer);
|
|
2011
|
+
// Ghost clean-up reads the merged layer, as before the split moved to the rig grid: a donor fragment joined to the
|
|
2012
|
+
// base across the occluder edge is one component there. What the merged clean-up drops is dropped from both sides.
|
|
2013
|
+
const kept = cleaned ? cleanGhosts(placeLayer(layer, resolution)).canvas : null;
|
|
2014
|
+
const sideToRig = (l: Layer): Raster => {
|
|
2015
|
+
const placed = placeLayer(l, resolution);
|
|
2016
|
+
if (kept !== null) for (let p = 0; p < resolution * resolution; p++) if (kept.data[p * 4 + 3] === 0) placed.data[p * 4 + 3] = 0;
|
|
2017
|
+
return layerToRig(placed, frame, run);
|
|
2018
|
+
};
|
|
2019
|
+
const baseRig = sideToRig(split.base);
|
|
2020
|
+
const donorRig = sideToRig(split.donor);
|
|
2021
|
+
const out = newRaster(frame.W, frame.H);
|
|
2022
|
+
for (let p = 0; p < frame.W * frame.H; p++) {
|
|
2023
|
+
const src = mask.data[p] === 1 ? baseRig.data : donorRig.data;
|
|
2024
|
+
out.data.set(src.subarray(p * 4, p * 4 + 4), p * 4);
|
|
2025
|
+
}
|
|
2026
|
+
return out;
|
|
2027
|
+
}
|
|
2028
|
+
|
|
1957
2029
|
/**
|
|
1958
2030
|
* Issue #492: warp a full-run layer (`resolution x resolution`) onto the head
|
|
1959
2031
|
* run's `resolution x resolution` canvas using the same premultiplied float32
|
|
@@ -5056,12 +5128,54 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
5056
5128
|
refuseIfAny(depthInputProblems);
|
|
5057
5129
|
// Issue #366: one run's file, padded to the resolution square; read as both runs, as before.
|
|
5058
5130
|
const fullPadded = single ? padSingleRun(depthFullInput, frame, input.resolution) : depthFullInput;
|
|
5131
|
+
const { W, H } = frame;
|
|
5132
|
+
const occluderGrowRecords: OccluderGrowRecord[] = [];
|
|
5133
|
+
const occluderGuardRecords: OccluderGuardRecord[] = [];
|
|
5134
|
+
const occluderEntries = (input.occluders ?? []).map(({ declaration, image }, index) => {
|
|
5135
|
+
const { coreBefore, coveredBefore } = occluderCoreMask(image, W, H);
|
|
5136
|
+
const grow = declaration.grow ?? 0;
|
|
5137
|
+
const guard = declaration.guard ?? 0;
|
|
5138
|
+
let copiedMask = coreBefore;
|
|
5139
|
+
if (grow > 0) {
|
|
5140
|
+
const grown = growMask({ width: W, height: H, inside: coreBefore.data }, grow);
|
|
5141
|
+
copiedMask = newMask(W, H);
|
|
5142
|
+
copiedMask.data.set(grown.inside);
|
|
5143
|
+
let coveredAfter = 0;
|
|
5144
|
+
for (let p = 0; p < W * H; p++) if (copiedMask.data[p] === 1) coveredAfter++;
|
|
5145
|
+
occluderGrowRecords.push({
|
|
5146
|
+
occluder: index,
|
|
5147
|
+
image: declaration.image,
|
|
5148
|
+
grow,
|
|
5149
|
+
covered_px_before: coveredBefore,
|
|
5150
|
+
covered_px_after: coveredAfter,
|
|
5151
|
+
});
|
|
5152
|
+
}
|
|
5153
|
+
let guardMask = copiedMask;
|
|
5154
|
+
if (guard > 0) {
|
|
5155
|
+
if (guard > grow) {
|
|
5156
|
+
const guarded = growMask({ width: W, height: H, inside: coreBefore.data }, guard);
|
|
5157
|
+
guardMask = newMask(W, H);
|
|
5158
|
+
guardMask.data.set(guarded.inside);
|
|
5159
|
+
}
|
|
5160
|
+
let guardedAfter = 0;
|
|
5161
|
+
for (let p = 0; p < W * H; p++) if (guardMask.data[p] === 1) guardedAfter++;
|
|
5162
|
+
occluderGuardRecords.push({
|
|
5163
|
+
occluder: index,
|
|
5164
|
+
image: declaration.image,
|
|
5165
|
+
guard,
|
|
5166
|
+
guarded_px_before: coveredBefore,
|
|
5167
|
+
guarded_px_after: guardedAfter,
|
|
5168
|
+
});
|
|
5169
|
+
}
|
|
5170
|
+
return { index, declaration, coreBefore, copiedMask, guardMask };
|
|
5171
|
+
});
|
|
5172
|
+
const occluderCoreMasks = occluderEntries.map((e) => e.coreBefore);
|
|
5059
5173
|
if ((input.requireHiddenExtent?.length ?? 0) > 0) {
|
|
5060
5174
|
// Read the selected original layers, before split/underfill/cleanup can replace their material.
|
|
5061
5175
|
const originals = input.plan.map(([name, run, tag]): HiddenExtentSource => {
|
|
5062
5176
|
const set = run === 'full' ? fullPadded : depthHeadInput;
|
|
5063
5177
|
const layer = set.layers.find(candidate => candidate.name === tag);
|
|
5064
|
-
return { name, from: `${run}:${tag}`, image: layer === undefined ? null :
|
|
5178
|
+
return { name, from: `${run}:${tag}`, image: layer === undefined ? null : layerToRigSplit(layer, input.resolution, frame, run, occluderCoreMasks) };
|
|
5065
5179
|
});
|
|
5066
5180
|
const painting = patches.length === 0 ? null : sourceInRig(source, frame.W, frame.H);
|
|
5067
5181
|
const silhouette = painting === null ? null : figureSilhouette(painting);
|
|
@@ -5103,55 +5217,19 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
5103
5217
|
const registeredDepth = new Map([...depthFull, ...depthHead]);
|
|
5104
5218
|
if (single) checkSingleRun(full, plan, extend);
|
|
5105
5219
|
checkPlanAgainstRuns(sourcePlan, extend, full, head);
|
|
5106
|
-
const { W, H } = frame;
|
|
5107
5220
|
const srcr = sourceInRig(source, W, H);
|
|
5108
5221
|
const supportPainted = paintedFigure(srcr);
|
|
5109
5222
|
const groundShare = groundRingShare(srcr, supportPainted);
|
|
5110
|
-
const occSx = (x: number): number => Math.min(source.width - 1, Math.floor((x + 0.5) * source.width / W));
|
|
5111
|
-
const occSy = (y: number): number => Math.min(source.height - 1, Math.floor((y + 0.5) * source.height / H));
|
|
5112
|
-
const occluderGrowRecords: OccluderGrowRecord[] = [];
|
|
5113
|
-
const occluderEntries = (input.occluders ?? []).map(({ declaration, image }, index) => {
|
|
5114
|
-
const coreBefore = newMask(W, H);
|
|
5115
|
-
let coveredBefore = 0;
|
|
5116
|
-
for (let y = 0; y < H; y++) {
|
|
5117
|
-
const srcY = occSy(y);
|
|
5118
|
-
for (let x = 0; x < W; x++) {
|
|
5119
|
-
const a = image.data[(srcY * source.width + occSx(x)) * 4 + 3];
|
|
5120
|
-
const p = y * W + x;
|
|
5121
|
-
if (a > COPIED_ALPHA_ABOVE) {
|
|
5122
|
-
coreBefore.data[p] = 1;
|
|
5123
|
-
coveredBefore++;
|
|
5124
|
-
}
|
|
5125
|
-
}
|
|
5126
|
-
}
|
|
5127
|
-
const grow = declaration.grow ?? 0;
|
|
5128
|
-
let copiedMask = coreBefore;
|
|
5129
|
-
if (grow > 0) {
|
|
5130
|
-
const grown = growMask({ width: W, height: H, inside: coreBefore.data }, grow);
|
|
5131
|
-
copiedMask = newMask(W, H);
|
|
5132
|
-
copiedMask.data.set(grown.inside);
|
|
5133
|
-
let coveredAfter = 0;
|
|
5134
|
-
for (let p = 0; p < W * H; p++) if (copiedMask.data[p] === 1) coveredAfter++;
|
|
5135
|
-
occluderGrowRecords.push({
|
|
5136
|
-
occluder: index,
|
|
5137
|
-
image: declaration.image,
|
|
5138
|
-
grow,
|
|
5139
|
-
covered_px_before: coveredBefore,
|
|
5140
|
-
covered_px_after: coveredAfter,
|
|
5141
|
-
});
|
|
5142
|
-
}
|
|
5143
|
-
return { index, declaration, copiedMask };
|
|
5144
|
-
});
|
|
5145
5223
|
const occluderUnderKeepByPlanPart = new Map<string, Mask>();
|
|
5146
5224
|
if (projectRule === 'visible') {
|
|
5147
|
-
for (const { declaration,
|
|
5225
|
+
for (const { declaration, guardMask } of occluderEntries) {
|
|
5148
5226
|
for (const u of declaration.under) {
|
|
5149
5227
|
let m = occluderUnderKeepByPlanPart.get(u);
|
|
5150
5228
|
if (m === undefined) {
|
|
5151
5229
|
m = newMask(W, H);
|
|
5152
5230
|
occluderUnderKeepByPlanPart.set(u, m);
|
|
5153
5231
|
}
|
|
5154
|
-
for (let p = 0; p < W * H; p++) if (
|
|
5232
|
+
for (let p = 0; p < W * H; p++) if (guardMask.data[p] === 1) m.data[p] = 1;
|
|
5155
5233
|
}
|
|
5156
5234
|
}
|
|
5157
5235
|
}
|
|
@@ -5227,7 +5305,14 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
5227
5305
|
}
|
|
5228
5306
|
}
|
|
5229
5307
|
if (run === 'full') fullTags.push(...layers.filter((l) => l.opaqueRunPx > 0).map((l) => l.tag));
|
|
5230
|
-
const rigLayers = layers.map((l) =>
|
|
5308
|
+
const rigLayers = layers.map((l) => {
|
|
5309
|
+
const srcLayer = set.layers.find((q) => q.name === l.tag);
|
|
5310
|
+
return srcLayer?.occluderSplit !== undefined &&
|
|
5311
|
+
srcLayer.pixels === srcLayer.occluderSplit.merged &&
|
|
5312
|
+
srcLayer.regionSelection === undefined
|
|
5313
|
+
? layerToRigSplit(srcLayer, input.resolution, frame, run, occluderCoreMasks, true)
|
|
5314
|
+
: layerToRig(l.canvas, frame, run);
|
|
5315
|
+
});
|
|
5231
5316
|
const rank = planRanks(layers.map((l) => l.tag), run, sourcePlan);
|
|
5232
5317
|
const keep = layers.map((l, i): Mask | null => {
|
|
5233
5318
|
let mask: Mask | null = null;
|
|
@@ -5283,19 +5368,28 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
5283
5368
|
: original === undefined ? [] : [original];
|
|
5284
5369
|
let raw: Raster | null = null;
|
|
5285
5370
|
if (author === 0 && sourceLayers.length > 0) {
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5371
|
+
if (
|
|
5372
|
+
sourceLayers.length === 1 &&
|
|
5373
|
+
sourceLayers[0].occluderSplit !== undefined &&
|
|
5374
|
+
sourceLayers[0].pixels === sourceLayers[0].occluderSplit.merged
|
|
5375
|
+
) {
|
|
5376
|
+
raw = layerToRigSplit(sourceLayers[0], input.resolution, frame, run, occluderCoreMasks);
|
|
5377
|
+
} else {
|
|
5378
|
+
// A sole layer needs no composite copy: layerToRig premultiplies,
|
|
5379
|
+
// so discarded RGB at alpha 0 has exactly the same float32 input.
|
|
5380
|
+
const canvas = sourceLayers.length === 1 ? placeLayer(sourceLayers[0], input.resolution) : newRaster(input.resolution, input.resolution);
|
|
5381
|
+
if (sourceLayers.length > 1) for (const originalLayer of sourceLayers) {
|
|
5382
|
+
const sourceCanvas = placeLayer(originalLayer, input.resolution);
|
|
5383
|
+
for (let p = 0; p < input.resolution * input.resolution; p++) if (sourceCanvas.data[p * 4 + 3] > 0) canvas.data.set(sourceCanvas.data.subarray(p * 4, p * 4 + 4), p * 4);
|
|
5384
|
+
}
|
|
5385
|
+
raw = layerToRig(canvas, frame, run);
|
|
5292
5386
|
}
|
|
5293
|
-
raw = layerToRig(canvas, frame, run);
|
|
5294
5387
|
}
|
|
5295
5388
|
// Reuse only a proved identical placed input, never wrapper identity.
|
|
5296
5389
|
const samePlacedSource = raw !== null && sourceLayers.length === 1 && prepared !== undefined &&
|
|
5297
|
-
sourceLayers[0].pixels === prepared.pixels && sourceLayers[0].left === prepared.left && sourceLayers[0].top === prepared.top
|
|
5298
|
-
|
|
5390
|
+
sourceLayers[0].pixels === prepared.pixels && sourceLayers[0].left === prepared.left && sourceLayers[0].top === prepared.top &&
|
|
5391
|
+
sourceLayers[0].occluderSplit === prepared.occluderSplit;
|
|
5392
|
+
const preparedRig = samePlacedSource ? raw : prepared === undefined ? null : layerToRigSplit(prepared, input.resolution, frame, run, occluderCoreMasks);
|
|
5299
5393
|
for (let p = 0; p < W * H; p++) {
|
|
5300
5394
|
if (rigLayers[i].data[p * 4 + 3] === 0) continue;
|
|
5301
5395
|
ids[p] = author;
|
|
@@ -6055,7 +6149,7 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
6055
6149
|
const canvases = stack.map(onRig);
|
|
6056
6150
|
const rawPlan = input.plan.map(([name, run, tag]) => {
|
|
6057
6151
|
const layer = input[run].layers.find(l => l.name === tag)!;
|
|
6058
|
-
return { name, raster:
|
|
6152
|
+
return { name, raster: layerToRigSplit(layer, input.resolution, frame, run, occluderCoreMasks), keep: occluderUnderKeepByPlanPart.get(name) ?? null };
|
|
6059
6153
|
});
|
|
6060
6154
|
if ((input.edgeSplits?.length ?? 0) > 0) applyEdgeSplits(input.edgeSplits!, new Map(rawPlan.map(p => [p.name, p.raster])), srcr);
|
|
6061
6155
|
const owner = rawPaintingOwner(rawPlan, W * H);
|
|
@@ -6472,6 +6566,7 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
6472
6566
|
recomposite: recompositeRecord(figures),
|
|
6473
6567
|
...(sceneRecord === null ? {} : { scene: sceneRecord }),
|
|
6474
6568
|
...(occluderGrowRecords.length === 0 ? {} : { occluder_grow: occluderGrowRecords }),
|
|
6569
|
+
...(occluderGuardRecords.length === 0 ? {} : { occluder_guard: occluderGuardRecords }),
|
|
6475
6570
|
...(padRecord === null ? {} : { single_run_pad: padRecord }),
|
|
6476
6571
|
},
|
|
6477
6572
|
images: placed,
|
package/src/config.ts
CHANGED
|
@@ -2581,7 +2581,7 @@ function checkRequiredHiddenExtent(c: Check, a: Record<string, Json>, names: rea
|
|
|
2581
2581
|
}
|
|
2582
2582
|
|
|
2583
2583
|
/**
|
|
2584
|
-
* Issue #1230 / #1241 / #1246 / #1251: `config.assemble.occluders`, `[{image, sha256, under, over?, rgb_within, plate?, part?, grow?}]`.
|
|
2584
|
+
* Issue #1230 / #1241 / #1246 / #1251 / #1259: `config.assemble.occluders`, `[{image, sha256, under, over?, rgb_within, plate?, part?, grow?, guard?}]`.
|
|
2585
2585
|
* Shape at every door; `under`, `over` and `part` resolved against the plan where the door reads it; the file and its
|
|
2586
2586
|
* sha256 where the door knows the config's directory (`checkOccluderFiles`). Returns the declared `part` names, in order.
|
|
2587
2587
|
*/
|
|
@@ -2593,7 +2593,7 @@ function checkOccluders(c: Check, a: Record<string, Json>, names: readonly strin
|
|
|
2593
2593
|
const partNames: string[] = [];
|
|
2594
2594
|
(a.occluders as Json[]).forEach((value, i) => {
|
|
2595
2595
|
const p = `${at}[${i}]`;
|
|
2596
|
-
const row = c.object(p, value, ['image', 'sha256', 'under', 'rgb_within'], ['over', 'plate', 'part', 'grow']);
|
|
2596
|
+
const row = c.object(p, value, ['image', 'sha256', 'under', 'rgb_within'], ['over', 'plate', 'part', 'grow', 'guard']);
|
|
2597
2597
|
if (row === null) return;
|
|
2598
2598
|
const imageOk = c.string(`${p}.image`, row.image);
|
|
2599
2599
|
const shaOk = typeof row.sha256 === 'string' && SHA256_PATTERN.test(row.sha256);
|
|
@@ -2629,8 +2629,15 @@ function checkOccluders(c: Check, a: Record<string, Json>, names: readonly strin
|
|
|
2629
2629
|
if (!growOk) c.fail('CONFIG_FIELD_TYPE', `${p}.grow`, `is ${show(row.grow)}; a non-negative integer is required`);
|
|
2630
2630
|
else growVal = row.grow as number;
|
|
2631
2631
|
}
|
|
2632
|
-
|
|
2633
|
-
|
|
2632
|
+
let guardOk = true;
|
|
2633
|
+
let guardVal: number | undefined;
|
|
2634
|
+
if ('guard' in row) {
|
|
2635
|
+
guardOk = typeof row.guard === 'number' && Number.isInteger(row.guard) && row.guard >= 0;
|
|
2636
|
+
if (!guardOk) c.fail('CONFIG_FIELD_TYPE', `${p}.guard`, `is ${show(row.guard)}; a non-negative integer is required`);
|
|
2637
|
+
else guardVal = row.guard as number;
|
|
2638
|
+
}
|
|
2639
|
+
if (imageOk && shaOk && underOk && overOk && rgbOk && plateOk && partOk && growOk && guardOk) {
|
|
2640
|
+
declarations.push({ image: row.image as string, sha256: row.sha256 as string, under: row.under as string[], ...('over' in row ? { over: row.over as string[] } : {}), rgb_within: row.rgb_within as number, ...('plate' in row ? { plate: row.plate as string } : {}), ...(partName !== undefined ? { part: partName } : {}), ...(growVal !== undefined ? { grow: growVal } : {}), ...(guardVal !== undefined ? { guard: guardVal } : {}) });
|
|
2634
2641
|
}
|
|
2635
2642
|
});
|
|
2636
2643
|
c.problems.push(...occluderNameProblems(declarations, names));
|
package/src/layers.ts
CHANGED
|
@@ -56,6 +56,8 @@ export const NEAR_WHITE_MIN = 235;
|
|
|
56
56
|
export interface Layer {
|
|
57
57
|
/** Exact seeded component in the original run canvas; internal, never serialized. */
|
|
58
58
|
regionSelection?: Mask;
|
|
59
|
+
/** Unmerged base and donor layers for an occluder-split take, placed separately on the rig grid; internal, never serialized. */
|
|
60
|
+
occluderSplit?: { occluder: number; base: Layer; donor: Layer; merged: Raster };
|
|
59
61
|
/** Verified donor identities retained through generated splits. */
|
|
60
62
|
takenLayers?: TakenLayerSource[];
|
|
61
63
|
/** As the input names it: a v3 tag, possibly with a `-r`/`-l` side, or an author-made layer's `author:<label>`. */
|
package/src/occluders.ts
CHANGED
|
@@ -38,6 +38,8 @@ export interface OccluderDeclaration {
|
|
|
38
38
|
part?: string;
|
|
39
39
|
/** An optional non-negative integer rig-px radius by which the occluder's > 128 core is dilated on the rig grid before the under guard, the occluder part and UNHELD read it (issue #1251). */
|
|
40
40
|
grow?: number;
|
|
41
|
+
/** An optional non-negative integer rig-px radius by which the occluder's > 128 core is dilated on the rig grid for the under guard only, without painting a part or changing UNHELD (issue #1259). */
|
|
42
|
+
guard?: number;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
export const OCCLUDER_COLOUR_COPIED = 'ASSEMBLE_OCCLUDER_COLOUR_COPIED';
|
package/src/occluderstage.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { createHash } from 'node:crypto';
|
|
11
11
|
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
12
12
|
import { dirname, join, resolve } from 'node:path';
|
|
13
|
-
import { checkGeometry,
|
|
13
|
+
import { checkGeometry, layerToRigSplit, occluderCoreMask, padSingleRun, sourceInRig } from './assemble.ts';
|
|
14
14
|
import type { PlanEntry } from './config.ts';
|
|
15
15
|
import { SHA256_PATTERN } from './editreceipt.ts';
|
|
16
16
|
import { PartsError } from './errors.ts';
|
|
@@ -76,7 +76,9 @@ export function occluderStageWarnings(input: OccluderStageInput): string[] {
|
|
|
76
76
|
const full = runs.single ? padSingleRun(runs.full, frame, input.resolution) : runs.full;
|
|
77
77
|
const painting = sourceInRig(source, frame.W, frame.H);
|
|
78
78
|
const lines: string[] = [];
|
|
79
|
-
readOccluderInputs(input.occluders, input.configPath, source)
|
|
79
|
+
const occluderInputs = readOccluderInputs(input.occluders, input.configPath, source);
|
|
80
|
+
const occluderCoreMasks = occluderInputs.map(({ image }) => occluderCoreMask(image, frame.W, frame.H).coreBefore);
|
|
81
|
+
occluderInputs.forEach(({ declaration: d, image }, i) => {
|
|
80
82
|
// A rig pixel reads the occluder at the source pixel its centre falls in.
|
|
81
83
|
const sx = (x: number): number => Math.min(source.width - 1, Math.floor((x + 0.5) * source.width / frame.W));
|
|
82
84
|
const sy = (y: number): number => Math.min(source.height - 1, Math.floor((y + 0.5) * source.height / frame.H));
|
|
@@ -85,7 +87,7 @@ export function occluderStageWarnings(input: OccluderStageInput): string[] {
|
|
|
85
87
|
const row = input.plan.find(([part]) => part === name);
|
|
86
88
|
if (row === undefined) return [];
|
|
87
89
|
const layer = (row[1] === 'full' ? full : runs.head).layers.find((l) => l.name === row[2]);
|
|
88
|
-
return layer === undefined ? [] : [{ name, image:
|
|
90
|
+
return layer === undefined ? [] : [{ name, image: layerToRigSplit(layer, input.resolution, frame, row[1], occluderCoreMasks) }];
|
|
89
91
|
});
|
|
90
92
|
for (const copy of occluderColourCopies(parts, painting, alpha, d.rgb_within)) lines.push(occluderColourWarning(i, copy, d.rgb_within));
|
|
91
93
|
});
|
package/src/parts.ts
CHANGED
|
@@ -405,6 +405,19 @@ export interface OccluderGrowRecord {
|
|
|
405
405
|
covered_px_after: number;
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
+
export interface OccluderGuardRecord {
|
|
409
|
+
/** Zero-based index into `config.assemble.occluders`. */
|
|
410
|
+
occluder: number;
|
|
411
|
+
/** The declared `config.assemble.occluders[occluder].image` path. */
|
|
412
|
+
image: string;
|
|
413
|
+
/** The declared positive integer `config.assemble.occluders[occluder].guard` radius in rig px. */
|
|
414
|
+
guard: number;
|
|
415
|
+
/** Rig pixels of the occluder core (`alpha > 128`) before the dilation. */
|
|
416
|
+
guarded_px_before: number;
|
|
417
|
+
/** Rig pixels of the under keep mask (`alpha > 128` dilated by `max(grow, guard)`) for this entry. */
|
|
418
|
+
guarded_px_after: number;
|
|
419
|
+
}
|
|
420
|
+
|
|
408
421
|
export interface PartsFile {
|
|
409
422
|
/** Optional on legacy packages; binds the opaque RGB raster assemble actually read. */
|
|
410
423
|
painting_in_rig?: PaintingInRig;
|
|
@@ -426,6 +439,8 @@ export interface PartsFile {
|
|
|
426
439
|
occluder_plates?: OccluderPlateRecord[];
|
|
427
440
|
/** Written only when an `assemble.occluders` entry declares `grow > 0` (issue #1251); absent otherwise. */
|
|
428
441
|
occluder_grow?: OccluderGrowRecord[];
|
|
442
|
+
/** Written only when an `assemble.occluders` entry declares `guard > 0` (issue #1259); absent otherwise. */
|
|
443
|
+
occluder_guard?: OccluderGuardRecord[];
|
|
429
444
|
/** Written only when alternate painting sets were assembled (issue #454); absent otherwise. */
|
|
430
445
|
alternates?: AlternatePartsRecord[];
|
|
431
446
|
}
|
|
@@ -462,10 +477,11 @@ export interface SceneRecord {
|
|
|
462
477
|
figure_mask: string;
|
|
463
478
|
}
|
|
464
479
|
|
|
465
|
-
const TOP_KEYS = ['painting_in_rig', 'rig_size', 'scale_rig_per_source', 'parts', 'ghost_px', 'recomposite', 'scene', 'occluder_plates', 'occluder_grow', 'single_run_pad', 'alternates', 'motion_seams', 'cut_ownership'] as const;
|
|
466
|
-
const REQUIRED_TOP_KEYS = TOP_KEYS.filter((k) => k !== 'painting_in_rig' && k !== 'recomposite' && k !== 'scene' && k !== 'single_run_pad' && k !== 'occluder_plates' && k !== 'occluder_grow' && k !== 'alternates' && k !== 'motion_seams' && k !== 'cut_ownership');
|
|
480
|
+
const TOP_KEYS = ['painting_in_rig', 'rig_size', 'scale_rig_per_source', 'parts', 'ghost_px', 'recomposite', 'scene', 'occluder_plates', 'occluder_grow', 'occluder_guard', 'single_run_pad', 'alternates', 'motion_seams', 'cut_ownership'] as const;
|
|
481
|
+
const REQUIRED_TOP_KEYS = TOP_KEYS.filter((k) => k !== 'painting_in_rig' && k !== 'recomposite' && k !== 'scene' && k !== 'single_run_pad' && k !== 'occluder_plates' && k !== 'occluder_grow' && k !== 'occluder_guard' && k !== 'alternates' && k !== 'motion_seams' && k !== 'cut_ownership');
|
|
467
482
|
export const OCCLUDER_PLATE_KEYS = ['receipt', 'receipt_sha256', 'occluder_sha256', 'painting_sha256', 'output_sha256', 'mask_sha256'] as const;
|
|
468
483
|
export const OCCLUDER_GROW_KEYS = ['occluder', 'image', 'grow', 'covered_px_before', 'covered_px_after'] as const;
|
|
484
|
+
export const OCCLUDER_GUARD_KEYS = ['occluder', 'image', 'guard', 'guarded_px_before', 'guarded_px_after'] as const;
|
|
469
485
|
export const SINGLE_RUN_PAD_KEYS = ['file_size', 'side', 'left', 'top'] as const;
|
|
470
486
|
export const SCENE_KEYS = ['figure_alpha_above', 'figure_px', 'figure_mask'] as const;
|
|
471
487
|
export const RECOMPOSITE_KEYS = ['mean_abs', 'within_limit', 'within_share', 'error_limit', 'error_px', 'covered_alpha', 'uncovered_error_px', 'hole_count', 'holes_listed', 'holes'] as const;
|
|
@@ -629,6 +645,7 @@ export function serializeParts(file: PartsFile): string {
|
|
|
629
645
|
...(file.scene === undefined ? {} : { scene: Object.fromEntries(SCENE_KEYS.map((k) => [k, (file.scene as SceneRecord)[k]])) }),
|
|
630
646
|
...(file.occluder_plates === undefined ? {} : { occluder_plates: file.occluder_plates.map((p) => Object.fromEntries(OCCLUDER_PLATE_KEYS.map((k) => [k, p[k]]))) }),
|
|
631
647
|
...(file.occluder_grow === undefined ? {} : { occluder_grow: file.occluder_grow.map((g) => Object.fromEntries(OCCLUDER_GROW_KEYS.map((k) => [k, g[k]]))) }),
|
|
648
|
+
...(file.occluder_guard === undefined ? {} : { occluder_guard: file.occluder_guard.map((g) => Object.fromEntries(OCCLUDER_GUARD_KEYS.map((k) => [k, g[k]]))) }),
|
|
632
649
|
...(file.single_run_pad === undefined ? {} : { single_run_pad: Object.fromEntries(SINGLE_RUN_PAD_KEYS.map((k) => [k, (file.single_run_pad as SingleRunPad)[k]])) }),
|
|
633
650
|
...(file.alternates === undefined
|
|
634
651
|
? {}
|
|
@@ -1005,6 +1022,36 @@ function checkParts(raw: unknown, path: string): PartsFile {
|
|
|
1005
1022
|
});
|
|
1006
1023
|
}
|
|
1007
1024
|
}
|
|
1025
|
+
if ('occluder_guard' in o) {
|
|
1026
|
+
if (!Array.isArray(o.occluder_guard) || o.occluder_guard.length === 0) {
|
|
1027
|
+
fail('PARTS_FIELD_TYPE', `${path} field "occluder_guard"`, `is ${show(o.occluder_guard)}; a non-empty array of occluder guard records is required`);
|
|
1028
|
+
} else {
|
|
1029
|
+
o.occluder_guard.forEach((entry, i) => {
|
|
1030
|
+
const at = `${path} occluder_guard[${i}]`;
|
|
1031
|
+
if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {
|
|
1032
|
+
fail('PARTS_FIELD_TYPE', at, `is ${show(entry)}; an object is required`);
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
const r = entry as Record<string, unknown>;
|
|
1036
|
+
for (const k of Object.keys(r)) if (!(OCCLUDER_GUARD_KEYS as readonly string[]).includes(k)) fail('PARTS_KEY_KNOWN', `${at} key "${k}"`, `is not an occluder_guard field; known: ${OCCLUDER_GUARD_KEYS.join(', ')}`);
|
|
1037
|
+
for (const k of OCCLUDER_GUARD_KEYS) if (!(k in r)) fail('PARTS_FIELD_PRESENT', `${at} field "${k}"`, 'is absent and required');
|
|
1038
|
+
if ('occluder' in r && !(typeof r.occluder === 'number' && Number.isInteger(r.occluder) && r.occluder >= 0)) {
|
|
1039
|
+
fail('PARTS_FIELD_TYPE', `${at} field "occluder"`, `is ${show(r.occluder)}; a non-negative integer index is required`);
|
|
1040
|
+
}
|
|
1041
|
+
if ('image' in r && (typeof r.image !== 'string' || r.image.length === 0)) {
|
|
1042
|
+
fail('PARTS_FIELD_TYPE', `${at} field "image"`, `is ${show(r.image)}; a non-empty string path is required`);
|
|
1043
|
+
}
|
|
1044
|
+
if ('guard' in r && !(typeof r.guard === 'number' && Number.isInteger(r.guard) && r.guard > 0)) {
|
|
1045
|
+
fail('PARTS_FIELD_TYPE', `${at} field "guard"`, `is ${show(r.guard)}; a positive integer is required`);
|
|
1046
|
+
}
|
|
1047
|
+
for (const k of ['guarded_px_before', 'guarded_px_after'] as const) {
|
|
1048
|
+
if (k in r && !(typeof r[k] === 'number' && Number.isInteger(r[k]) && (r[k] as number) >= 0)) {
|
|
1049
|
+
fail('PARTS_FIELD_TYPE', `${at} field "${k}"`, `is ${show(r[k])}; a non-negative integer is required`);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1008
1055
|
if ('recomposite' in o && sizeOk) {
|
|
1009
1056
|
const names = Array.isArray(o.parts) ? new Set(o.parts.map((p) => (typeof p === 'object' && p !== null ? (p as Record<string, unknown>).name : undefined)).filter((n): n is string => typeof n === 'string')) : new Set<string>();
|
|
1010
1057
|
checkRecomposite(o.recomposite, path, size as [number, number], names, fail);
|
package/src/takelayers.ts
CHANGED
|
@@ -289,7 +289,17 @@ export function applyTakenLayers(runs: { full: LayerSet; head: LayerSet; single:
|
|
|
289
289
|
...(transported === undefined ? {} : { transport: transported.transport }),
|
|
290
290
|
split: { occluder: d.occluder, image: occEntry.image, sha256: occEntry.sha256, covered_px: coveredPx, visible_px: visiblePx },
|
|
291
291
|
};
|
|
292
|
-
const replacement: Layer = {
|
|
292
|
+
const replacement: Layer = {
|
|
293
|
+
...baseLayer,
|
|
294
|
+
left: 0,
|
|
295
|
+
top: 0,
|
|
296
|
+
right: set.canvas.w,
|
|
297
|
+
bottom: set.canvas.h,
|
|
298
|
+
pixels: merged,
|
|
299
|
+
opaquePx,
|
|
300
|
+
takenLayers: [source],
|
|
301
|
+
occluderSplit: { occluder: d.occluder, base: baseLayer, donor: donorOnSet, merged },
|
|
302
|
+
};
|
|
293
303
|
lists[d.run] = [...lists[d.run].filter(l => l.name !== d.tag), replacement];
|
|
294
304
|
origins.set(replacement, resolve(base, d.run_dir));
|
|
295
305
|
notes.push(takeLayerNote(source));
|