@rig-c/parts 2.30.3 → 2.32.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/cli.ts +17 -10
- package/docs/AUTHORING.md +19 -1
- package/docs/STABILITY.md +9 -6
- package/package.json +1 -1
- package/src/assemble.ts +53 -2
- package/src/build.ts +8 -1
- package/src/comfy/plate.ts +22 -4
- package/src/config.ts +66 -3
- package/src/edgesplit.ts +185 -0
- package/src/occluders.ts +102 -0
- package/src/occluderstage.ts +64 -0
- package/src/plate.ts +63 -10
package/cli.ts
CHANGED
|
@@ -877,9 +877,9 @@ usage:
|
|
|
877
877
|
non-square inputs use the recorded square transform, square uploads stay
|
|
878
878
|
unchanged. A selector alone is not installation: model files are checked.
|
|
879
879
|
|
|
880
|
-
rig-parts comfy plate --mode background|foreground --painting <png>
|
|
881
|
-
--mask-from seethrough:<dir>|figure-mask:<dir>|matte:<dir> --
|
|
882
|
-
[--graph lama|core] [--model <name>] [--checkpoint-sha256 <hex>]
|
|
880
|
+
rig-parts comfy plate --mode background|foreground|occluder --painting <png>
|
|
881
|
+
--mask-from seethrough:<dir>|figure-mask:<dir>|matte:<dir> | --occluder <rgba png> [--holes]
|
|
882
|
+
--out <dir> [--graph lama|core] [--model <name>] [--checkpoint-sha256 <hex>]
|
|
883
883
|
[--seed 0] [--grow 8] [--steps 30] [--cfg 6] [--prompt <text>] [--negative <text>]
|
|
884
884
|
[--host <url>] [--wait 1800] [--timeout 3600] [--poll 3]
|
|
885
885
|
A step-4 plate with a receipt: <out>/plate.png, mask.png and receipt.json
|
|
@@ -895,7 +895,10 @@ usage:
|
|
|
895
895
|
place), and pastes the result into the painting inside the mask only.
|
|
896
896
|
--checkpoint-sha256 is required for background and is recorded as declared.
|
|
897
897
|
foreground runs no box: the painting's pixels inside the mask, transparent
|
|
898
|
-
outside.
|
|
898
|
+
outside. occluder runs the background route over the mask an RGBA image of
|
|
899
|
+
what stands in front of the character gives (alpha above 0, on the
|
|
900
|
+
painting's grid, enclosed holes filled with --holes, grown --grow px): the
|
|
901
|
+
painting with the occluder inpainted away, its receipt binding the occluder.
|
|
899
902
|
|
|
900
903
|
rig-parts build --config <config.json> --source <painting.png> --full <dir|psd>
|
|
901
904
|
[--head <dir|psd>] --out <dir> [--seam near-white|silhouette]
|
|
@@ -1181,7 +1184,7 @@ const TAKES = {
|
|
|
1181
1184
|
'comfy seethrough': { valued: ['--image', '--out', '--resolution', '--steps', '--seed', '--prefix', '--host', '--wait', '--timeout', '--poll', '--config', '--depth-run'], switches: ['--offload', '--no-offload', '--lama', '--nf4'] },
|
|
1182
1185
|
'comfy paint': { valued: ['--config', '--out', '--seeds', '--seed0', '--host', '--wait', '--timeout', '--poll'], switches: [] },
|
|
1183
1186
|
'comfy matte': { valued: ['--painting', '--out', '--node', '--model', '--checkpoint-sha256', '--resolution', '--threshold', '--host', '--wait', '--timeout', '--poll'], switches: [] },
|
|
1184
|
-
'comfy plate': { valued: ['--mode', '--painting', '--mask-from', '--out', '--graph', '--model', '--checkpoint-sha256', '--seed', '--grow', '--steps', '--cfg', '--prompt', '--negative', '--host', '--wait', '--timeout', '--poll'], switches: [] },
|
|
1187
|
+
'comfy plate': { valued: ['--mode', '--painting', '--mask-from', '--occluder', '--out', '--graph', '--model', '--checkpoint-sha256', '--seed', '--grow', '--steps', '--cfg', '--prompt', '--negative', '--host', '--wait', '--timeout', '--poll'], switches: ['--holes'] },
|
|
1185
1188
|
inputs: { valued: ['--source', '--config', '--out'], switches: [] },
|
|
1186
1189
|
build: { valued: ['--config', '--source', '--full', '--head', '--out', '--seam', '--project', '--page-edges', '--pack-shape', '--requirements', '--idle-keys', '--lead-in', '--alt', '--set', '--environment', '--wind-band'], switches: ['--loop', '--seam-pairs', '--keep-stills', '--all-sets', '--no-extremes'] },
|
|
1187
1190
|
compose: { valued: ['--scene', '--out', '--requirements', '--accept'], switches: [] },
|
|
@@ -1989,9 +1992,13 @@ function secondsFlag(v: Map<string, string>, flag: string, fallback: number): nu
|
|
|
1989
1992
|
/** Flags `comfy plate --mode foreground` does not take: it runs no box and no model. */
|
|
1990
1993
|
const PLATE_BOX_FLAGS = ['--graph', '--model', '--checkpoint-sha256', '--seed', '--grow', '--steps', '--cfg', '--prompt', '--negative', '--host', '--wait', '--timeout', '--poll'];
|
|
1991
1994
|
|
|
1992
|
-
async function cmdComfyPlate(v: Map<string, string>): Promise<number> {
|
|
1995
|
+
async function cmdComfyPlate(v: Map<string, string>, on: Set<string> = new Set()): Promise<number> {
|
|
1993
1996
|
const mode = v.get('--mode');
|
|
1994
|
-
if (mode !== 'background' && mode !== 'foreground') return usage(`comfy plate needs --mode background or
|
|
1997
|
+
if (mode !== 'background' && mode !== 'foreground' && mode !== 'occluder') return usage(`comfy plate needs --mode background, foreground or occluder${mode === undefined ? '' : `; got "${mode}"`}`);
|
|
1998
|
+
// Issue #1230: the occluder mode reads its mask from --occluder and nothing else; the other modes never read one.
|
|
1999
|
+
if (mode === 'occluder' && v.has('--mask-from')) return usage('comfy plate --mode occluder reads its mask from --occluder; --mask-from is for --mode background or foreground');
|
|
2000
|
+
if (mode === 'occluder' && !v.has('--occluder')) return usage('comfy plate --mode occluder needs --occluder <rgba png>');
|
|
2001
|
+
if (mode !== 'occluder') for (const x of ['--occluder', '--holes']) if (v.has(x) || on.has(x)) return usage(`${x} is for --mode occluder`);
|
|
1995
2002
|
const painting = v.get('--painting');
|
|
1996
2003
|
if (painting === undefined) return usage('comfy plate needs --painting <png>');
|
|
1997
2004
|
const out = v.get('--out');
|
|
@@ -2018,11 +2025,11 @@ async function cmdComfyPlate(v: Map<string, string>): Promise<number> {
|
|
|
2018
2025
|
for (const x of [seed, grow, steps]) if (typeof x === 'string') return usage(x);
|
|
2019
2026
|
if (graph === 'lama') for (const x of ['--steps', '--prompt', '--negative']) if (v.has(x)) return usage(`${x} is for --graph core; the lama graph takes no prompt and no steps`);
|
|
2020
2027
|
const cfg = coreCfg(v.get('--cfg'), graph);
|
|
2021
|
-
console.log(`rig-parts comfy plate:
|
|
2028
|
+
console.log(`rig-parts comfy plate: ${mode} (${graph}) ${painting} -> ${out}`);
|
|
2022
2029
|
// Every local refusal (no source mask, the checksum, the grid) comes before the host is resolved.
|
|
2023
2030
|
const r = await runBackground(
|
|
2024
2031
|
() => new ComfyClient(resolveHost(v.get('--host'), process.env.COMFY_HOST), { poll: poll as number, request: 30, wait: wait as number }),
|
|
2025
|
-
{ painting, maskFrom: v.get('--mask-from'), out, graph, model: v.get('--model'), checkpointSha256: v.get('--checkpoint-sha256'), seed: seed as number, growPx: grow as number, steps: steps as number, ...(v.has('--cfg') ? { cfg } : {}), prompt: v.get('--prompt'), negative: v.get('--negative'), wait: wait as number, timeout: timeout as number },
|
|
2032
|
+
{ mode, painting, maskFrom: v.get('--mask-from'), ...(mode === 'occluder' ? { occluder: v.get('--occluder'), holes: on.has('--holes') } : {}), out, graph, model: v.get('--model'), checkpointSha256: v.get('--checkpoint-sha256'), seed: seed as number, growPx: grow as number, steps: steps as number, ...(v.has('--cfg') ? { cfg } : {}), prompt: v.get('--prompt'), negative: v.get('--negative'), wait: wait as number, timeout: timeout as number },
|
|
2026
2033
|
(l) => console.log(l),
|
|
2027
2034
|
);
|
|
2028
2035
|
console.log(` wrote ${join(out, r.output.path)} (sha256 ${r.output.sha256}), ${r.mask.path} and receipt.json; model ${r.model?.name} (checkpoint sha256 declared), GPU ${r.gpu}`);
|
|
@@ -2058,7 +2065,7 @@ async function cmdComfy(args: string[]): Promise<number> {
|
|
|
2058
2065
|
if (sub !== 'seethrough' && sub !== 'paint' && sub !== 'plate' && sub !== 'matte') return usage(`comfy takes seethrough, paint, plate or matte; got ${sub === undefined ? 'nothing' : `"${sub}"`}`);
|
|
2059
2066
|
const f = comfyFlags(rest, `comfy ${sub}`);
|
|
2060
2067
|
if (typeof f === 'string') return usage(f);
|
|
2061
|
-
if (sub === 'plate') return cmdComfyPlate(f.v);
|
|
2068
|
+
if (sub === 'plate') return cmdComfyPlate(f.v, f.on);
|
|
2062
2069
|
if (sub === 'matte') return cmdComfyMatte(f.v);
|
|
2063
2070
|
const { v, on } = f;
|
|
2064
2071
|
if (on.has('--offload') && on.has('--no-offload')) return usage('--offload and --no-offload cannot be combined');
|
package/docs/AUTHORING.md
CHANGED
|
@@ -161,6 +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 (issue #1230): `[{image, sha256, under, 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`) 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. No output byte moves. |
|
|
164
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). |
|
|
165
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) |
|
|
166
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 |
|
|
@@ -5343,7 +5344,8 @@ those settings. Changing a config seed alone cannot change a no-config run.
|
|
|
5343
5344
|
`rig-parts comfy plate --mode background|foreground --painting <png>
|
|
5344
5345
|
--mask-from seethrough:<dir>|figure-mask:<dir> --out <dir>` makes the two plates
|
|
5345
5346
|
a full-screen scene needs: the background with the figure removed, and a
|
|
5346
|
-
foreground matte with alpha.
|
|
5347
|
+
foreground matte with alpha. `--mode occluder` (below) makes a third: the
|
|
5348
|
+
painting with a declared occluder removed. It never makes a character part
|
|
5347
5349
|
or a joint.
|
|
5348
5350
|
|
|
5349
5351
|
- **The mask comes from a source.** `seethrough:<dir>` is a See-through run in
|
|
@@ -5375,6 +5377,19 @@ or a joint.
|
|
|
5375
5377
|
measured**.
|
|
5376
5378
|
- **foreground** runs no box and no model. The plate is the painting's pixels
|
|
5377
5379
|
inside the mask, transparent zero outside.
|
|
5380
|
+
- **occluder** (issue #1230) takes `--occluder <png>` in place of
|
|
5381
|
+
`--mask-from`: an RGBA image of what stands in front of the character, on
|
|
5382
|
+
the painting's own grid (another size is refused, `PLATE_OCCLUDER_GRID`,
|
|
5383
|
+
before anything is uploaded). The mask is the occluder's alpha above 0; with
|
|
5384
|
+
`--holes`, every pocket the occluder encloses (4-connected) is filled; then it
|
|
5385
|
+
is grown by `--grow` and inpainted exactly as **background** is. The plate is
|
|
5386
|
+
the painting with the occluder removed, and `receipt.json` binds the
|
|
5387
|
+
occluder's path and sha256 beside the painting's. A See-through run on that
|
|
5388
|
+
plate paints the surface behind the occluder that no run on the painting
|
|
5389
|
+
paints. To assemble from it, give that run as `--full` with the real painting
|
|
5390
|
+
as `--source`, and take the occluder's own layers from the run on the painting
|
|
5391
|
+
through `config.assemble.take` (their `st_input` is the painting, so the take's
|
|
5392
|
+
input identity holds).
|
|
5378
5393
|
|
|
5379
5394
|
`<out>` holds `plate.png`, `mask.png` (the mask actually used: opaque white
|
|
5380
5395
|
inside, opaque black outside) and `receipt.json`, spec
|
|
@@ -5405,6 +5420,7 @@ recorded transform. The record fields and sampling formula are specified in
|
|
|
5405
5420
|
| <a id="PLATE_MASK_SOURCE"></a><a id="PLATE_MASK_GRID"></a><a id="PLATE_MASK_VALUES"></a><a id="PLATE_MASK_EMPTY"></a>`PLATE_MASK_SOURCE`, `PLATE_MASK_GRID`, `PLATE_MASK_VALUES`, `PLATE_MASK_EMPTY` | no `--mask-from`, or a source directory holding no See-through run or no scene figure mask; a source on another grid without a valid recorded `input_transform`; a `figure_rig.png` holding other than opaque white and black; a mask with no figure pixel | run `comfy seethrough` on the original painting to record its input transform, or `assemble` with `config.scene` at the painting grid |
|
|
5406
5421
|
| <a id="PLATE_MASK_RUN"></a>`PLATE_MASK_RUN` | the figure source has no readable `rig-run/1` assemble `run.json`, or its `figure_rig.png`, `parts.json` or declared `painting_in_rig.png` lacks exactly one matching output hash; or the See-through source has no readable `meta.json` with `image_sha256` and `layers` hashes, or a layer PNG on disk lacks a matching `layers` entry | re-run `assemble` with the source config to regenerate `run.json` and its `rig/` files together, or re-run `comfy seethrough` on the painting to regenerate `meta.json` and `parts/` together |
|
|
5407
5422
|
| <a id="PLATE_MASK_PAINTING"></a>`PLATE_MASK_PAINTING` | `parts.json` has an invalid `painting_in_rig` declaration, its recorded painting is missing, undecodable or differs from its declared hash, or the supplied painting differs from the recorded opaque RGB; or the supplied painting's SHA-256 differs from a See-through source's `meta.json` `image_sha256` | use the original `--painting` file for this source, or re-run `assemble` or `comfy seethrough` on this painting |
|
|
5423
|
+
| <a id="PLATE_OCCLUDER_PRESENT"></a><a id="PLATE_OCCLUDER_GRID"></a><a id="PLATE_OCCLUDER_ALPHA"></a>`PLATE_OCCLUDER_PRESENT`, `PLATE_OCCLUDER_GRID`, `PLATE_OCCLUDER_ALPHA` | `--mode occluder` with no readable `--occluder` file; an occluder whose size is not the painting's; an occluder with no transparent pixel (it would mask the whole painting) | export the occluder as an RGBA PNG on the painting's grid, transparent outside it |
|
|
5408
5424
|
| <a id="PLATE_CHECKPOINT_SHA256"></a><a id="PLATE_MODEL_GIVEN"></a>`PLATE_CHECKPOINT_SHA256`, `PLATE_MODEL_GIVEN` | `--checkpoint-sha256` absent or not 64 hex characters; `--graph core` without `--model` | the flag |
|
|
5409
5425
|
| <a id="PLATE_CORE_CFG"></a>`PLATE_CORE_CFG` | `--cfg` given with `--graph lama`, or not a finite number above 0 | `--cfg`, `--graph` |
|
|
5410
5426
|
| <a id="PLATE_CORE_GRID"></a>PLATE_CORE_GRID *(retired)* | retired in 2.x: off-grid `core` now pads to the next multiple of 8 and records `grid_transform`; see [STABILITY](STABILITY.md#plate-receipt) | none |
|
|
@@ -5474,6 +5490,8 @@ recorded transform. The record fields and sampling formula are specified in
|
|
|
5474
5490
|
| <a id="ASSEMBLE_PART_OPAQUE"></a>`ASSEMBLE_PART_OPAQUE` | a part ended with no opaque pixel | drop the entry, or take the tag from the other run |
|
|
5475
5491
|
| <a id="ASSEMBLE_HIDDEN_EXTENT_ABSENT"></a>`ASSEMBLE_HIDDEN_EXTENT_ABSENT` | a declared `assemble.require_hidden_extent` pair has an enclosed own-source hole beneath its resolved front-most occluder, before cleanup or any writer. The refusal names both source parts, original run:tag, absent/overlap rig-cell counts, soft/opaque cover counts and the first cell | supply a source that already carries the extent, such as a second decomposition run. That source-production route is separate from this change. [Original hidden extent required](#original-hidden-extent-required) states the domain and open-cuff boundary |
|
|
5476
5492
|
| <a id="ASSEMBLE_HIDDEN_EXTENT_UNMEASURED"></a>`ASSEMBLE_HIDDEN_EXTENT_UNMEASURED` | a declared pair has no filled own-support overlap under the resolved occluder, empty own support, unavailable original selected-layer ancestry or a partial alternate replacing only one declared source family | resolve the original sources and their declared overlap. An empty hole set with measurable overlap is a valid zero reading. See [Original hidden extent required](#original-hidden-extent-required) |
|
|
5493
|
+
| <a id="ASSEMBLE_OCCLUDER_COLOUR_COPIED"></a>`ASSEMBLE_OCCLUDER_COLOUR_COPIED` (WARN) | a selected layer of an `assemble.occluders` `under` part holds pixels (alpha above 128) under the occluder (alpha above 0) within `rgb_within` of the painting: the decomposition painted the thing in front into the surface behind it | take the part from a See-through run on the painting with the occluder removed (`comfy plate --mode occluder`), as `--full`, with the occluder's own layers taken from the painting's run through `assemble.take` |
|
|
5494
|
+
| <a id="CONFIG_OCCLUDER_SHA256"></a><a id="ASSEMBLE_OCCLUDER_GRID"></a>`CONFIG_OCCLUDER_SHA256`, `ASSEMBLE_OCCLUDER_GRID` | an `assemble.occluders` image whose bytes do not hash to its declared `sha256`; an occluder image whose size is not the painting's | declare the bytes the image holds; export the occluder on the painting's grid |
|
|
5477
5495
|
| <a id="CONFIG_HIDDEN_EXTENT_ORDER"></a>`CONFIG_HIDDEN_EXTENT_ORDER` | `assemble.require_hidden_extent` names the same source as part and occluder, or names an occluder drawn before the part | declare distinct source parts with the occluder after the part in `assemble.plan` |
|
|
5478
5496
|
| <a id="DIFF_COMPONENTS_INPUT"></a>`DIFF_COMPONENTS_INPUT` | `diff-components` needs readable PNG stack/painting/part images, a writable `--out` target when writing, explicit parts, positive integer floor, a finite threshold in [0,255], matching native dimensions and valid coverage/domain inputs; flags must be unique and known, with nonempty values | Supply the named missing or invalid input; no resampling or inferred figure is performed |
|
|
5479
5497
|
| <a id="DIFF_COMPONENTS_BINDING"></a>`DIFF_COMPONENTS_BINDING` | The shipped report reader found a stack or painting SHA-256 different from the supplied bytes; found and required digests are printed | Regenerate against the bytes being reviewed |
|
package/docs/STABILITY.md
CHANGED
|
@@ -214,7 +214,7 @@ defaults are the help's too, and none is guessed from the art.
|
|
|
214
214
|
| `inputs` | `--source`, `--config`, `--out` |
|
|
215
215
|
| `comfy` | `paint`: `--config`, `--out`; optional `--seeds`, `--seed0`, `--host`, `--wait`, `--timeout`, `--poll` |
|
|
216
216
|
| `comfy` | `matte`: `--painting`, `--out`, `--node` (`BiRefNetRMBG`), `--model` (`BiRefNet-HR-matting`), `--checkpoint-sha256` (declared, required); optional `--resolution`, `--threshold`, `--host`, `--wait`, `--timeout`, `--poll` (issue #1204) |
|
|
217
|
-
| `comfy` | `plate`: `--mode` (`background` or `
|
|
217
|
+
| `comfy` | `plate`: `--mode` (`background`, `foreground` or `occluder`), `--painting`, `--mask-from` (`seethrough:<dir>`, `figure-mask:<dir>` or `matte:<dir>`; not with `occluder`), `--out`; with `--mode occluder`, `--occluder` (an RGBA PNG on the painting's grid, required) and optional `--holes` (issue #1230), and the background flags below; with `--mode background` also `--checkpoint-sha256` (required) and optional `--graph` (`lama` or `core`), `--model` (required with `core`), `--seed`, `--grow`, `--steps`, `--cfg`, `--prompt`, `--negative` (the last four with `core` only), `--host`, `--wait`, `--timeout`, `--poll` (issue #1183, additive) |
|
|
218
218
|
| `comfy` | `seethrough`: `--image`, `--out`; optional `--resolution`, `--steps`, `--seed`, `--prefix`, `--offload`, `--no-offload`, `--lama`, `--nf4`, `--host`, `--wait`, `--timeout`, `--poll`, `--config` (See-through settings and optional depth block), `--depth-run` (`full` or `head`, required with the block) |
|
|
219
219
|
| `assemble` | `--propose-plan` with `--source`, `--full`, `--config`, optional `--head`, `--write-config` (must name `--config` itself, issue #356); or `--source`, `--full`, `--config`, `--out`, optional `--head` (without it, one run: issue #359), `--seam` (near-white, silhouette), `--project` (core, visible), `--alt` (repeatable `<name>=<source>:<full>[:<head>]`, issue #454), `--requirements` (source-bound cut-material evidence only when the file declares `cut_material`, issue #888) |
|
|
220
220
|
| `head-crop-preflight` | `--full`, `--canvas`, `--head-box` (JSON coordinate array); read-only advice before the head run, original alpha > 8 samples (issue #1082) |
|
|
@@ -314,8 +314,10 @@ part name, `[i]` an entry of a list):
|
|
|
314
314
|
- **generation.control.skeleton**, the pose file it names when it is no built-in — required: `width`, `height`, `points`
|
|
315
315
|
- **seethrough** — required: `resolution`, `steps`, `seed`, `offload`; optional: `head_box`, `arm_split`
|
|
316
316
|
- **seethrough.arm_split** — required: `order`, and one of `x` or `line` (issue #439)
|
|
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`, `take`, `editor_receipts`
|
|
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
|
+
- **assemble.edge_splits[i]** — required: `over`, `under`, `band`
|
|
318
319
|
- **assemble.require_hidden_extent[i]** — required: `part`, `occluder`
|
|
320
|
+
- **assemble.occluders[i]** — required: `image`, `sha256`, `under`, `rgb_within` (issue #1230)
|
|
319
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
|
|
320
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)
|
|
321
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
|
|
@@ -444,14 +446,15 @@ new spec version. Every path in it is relative to the receipt's directory.
|
|
|
444
446
|
| key | meaning |
|
|
445
447
|
| --- | --- |
|
|
446
448
|
| `spec` | `"rig-parts-plate-receipt/1"` |
|
|
447
|
-
| `mode` | `"background"` or `"
|
|
449
|
+
| `mode` | `"background"`, `"foreground"` or `"occluder"` (issue #1230, additive) |
|
|
448
450
|
| `painting` | `{ path, sha256 }` of the painting read |
|
|
449
|
-
| `
|
|
451
|
+
| `occluder` | present only when `mode` is `"occluder"` (issue #1230, additive), right after `painting`: `{ path, sha256 }` of the `--occluder` RGBA image the mask was read from |
|
|
452
|
+
| `mask` | `{ source, from, path, sha256 }`: `source` is `"seethrough"`, `"figure-mask"`, `"matte"` or `"occluder"`, `from` the source directory (the occluder image for `"occluder"`), `path` the mask actually used (`mask.png`, opaque white inside) |
|
|
450
453
|
| `model` | `{ name, checkpoint_sha256, checkpoint_sha256_from }`, or null for `foreground`. `checkpoint_sha256` is the `--checkpoint-sha256` value, lower-cased; `checkpoint_sha256_from` is `"declared"`: the box reports no hash, so this field is **declared, not measured** |
|
|
451
|
-
| `params` | every parameter of the run, the seed included, in a fixed order per graph: `lama` — `seed`, `grow_px`, `mask_alpha_above`; `core` — `seed`, `grow_px`, `steps`, `cfg` (`--cfg`, default `6`), `sampler`, `scheduler`, `denoise`, `prompt`, `negative`, `mask_alpha_above`; `foreground` — `mask_alpha_above` |
|
|
454
|
+
| `params` | every parameter of the run, the seed included, in a fixed order per graph: `lama` — `seed`, `grow_px`, `mask_alpha_above`; `core` — `seed`, `grow_px`, `steps`, `cfg` (`--cfg`, default `6`), `sampler`, `scheduler`, `denoise`, `prompt`, `negative`, `mask_alpha_above`; `foreground` — `mask_alpha_above`; `occluder` — the `lama` or `core` list with `holes` (`--holes`) before `mask_alpha_above`, which is `0` |
|
|
452
455
|
| `graph` | `"rig-parts/plate-background-lama/1"`, `"rig-parts/plate-background-core/1"`, or the fixed local id `"rig-parts/plate-foreground/1"` |
|
|
453
456
|
| `gpu` | the device `/system_stats` names (the same seed gives other pixels on another GPU), or null for `foreground` |
|
|
454
|
-
| `grid_transform` | present only when `mode` is `"background"`, `graph` is `"rig-parts/plate-background-core/1"`, and the painting's width or height is not a multiple of 8 (issue #1209, additive): `{ source: [width, height], padded: [ceil(width/8)*8, ceil(height/8)*8], pad: [0, 0], pad_fill: "edge-replicate", mask_pad_fill: "zero", inverse: "crop" }` in that key order. Omitted for on-grid `core`, `lama`, and `foreground` |
|
|
457
|
+
| `grid_transform` | present only when `mode` is `"background"` or `"occluder"`, `graph` is `"rig-parts/plate-background-core/1"`, and the painting's width or height is not a multiple of 8 (issue #1209, additive): `{ source: [width, height], padded: [ceil(width/8)*8, ceil(height/8)*8], pad: [0, 0], pad_fill: "edge-replicate", mask_pad_fill: "zero", inverse: "crop" }` in that key order. Omitted for on-grid `core`, `lama`, and `foreground` |
|
|
455
458
|
| `output` | `{ path, sha256 }` of `plate.png` |
|
|
456
459
|
|
|
457
460
|
The receipt is read back against the bytes on disk before `<out>` is published;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rig-c/parts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.32.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": {
|
package/src/assemble.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { materialSource, type MaterialSource, materialRows, polygonMaterialEdges
|
|
|
12
12
|
import { unionTakenSources } from './takesource.ts';
|
|
13
13
|
import { authoredUnitDepths, type AuthoredUnitDepth } from './authoredunit.ts';
|
|
14
14
|
import { paintingExtensionMasks, paintingExtensionProblems, type PaintingExtension } from './paintingextension.ts';
|
|
15
|
+
import { applyEdgeSplits, edgeSplitLines, edgeSplitProblems, type EdgeSplit, type EdgeSplitReading } from './edgesplit.ts';
|
|
15
16
|
import { AUTOMATIC_WRITERS as AW, compactValueBaseline, pixelProvenance, rgbaEqual, type ValueBaseline, type StageMap } from './provenance.ts';
|
|
16
17
|
import { bindDepthRun, copyDepthMaterial, registerDepthRun, transportPartDepth, type DepthConfig, type RegisteredDepth } from './depthsheets.ts';
|
|
17
18
|
/**
|
|
@@ -376,6 +377,8 @@ export interface AssembleInput {
|
|
|
376
377
|
requireHiddenExtent?: readonly HiddenExtentDeclaration[];
|
|
377
378
|
/** Base painting only; named final parts, explicit band and path bound (#848). */
|
|
378
379
|
paintingExtension?: readonly PaintingExtension[];
|
|
380
|
+
/** Painting-edge splits between plan parts before projection (#1231). */
|
|
381
|
+
edgeSplits?: readonly EdgeSplit[];
|
|
379
382
|
/**
|
|
380
383
|
* Issue #587: rig pixels taken out of named parts once the cuts and the limbs are made, before the fringe pass and
|
|
381
384
|
* every figure a part's record holds — each entry clears `part`'s pixels (alpha, colour and region) where `mask` is
|
|
@@ -4788,6 +4791,8 @@ export interface AssembleResult {
|
|
|
4788
4791
|
splits: SplitCount[];
|
|
4789
4792
|
/** Issue #637: source-transparent cap pixels assigned before preservation, in either source-art door. */
|
|
4790
4793
|
capSplits: SplitCount[];
|
|
4794
|
+
/** Issue #1231: what each `edge_splits` entry moved before projection; empty without one. */
|
|
4795
|
+
edgeSplits: EdgeSplitReading[];
|
|
4791
4796
|
}
|
|
4792
4797
|
|
|
4793
4798
|
/** Issue #953: the edge pixels `paintingEdges` resolved, the part pixels it changed, and the edge pixels it left, by reason. */
|
|
@@ -4991,6 +4996,7 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
4991
4996
|
const { source, extend, patches, seamRule, projectRule } = input;
|
|
4992
4997
|
const authoredDepths = input.depth === undefined ? new Map<string, AuthoredUnitDepth>() : authoredUnitDepths(input);
|
|
4993
4998
|
if (input.paintingExtension !== undefined) refuseIfAny(paintingExtensionProblems(input.paintingExtension));
|
|
4999
|
+
if (input.edgeSplits !== undefined) refuseIfAny(edgeSplitProblems(input.edgeSplits, new Set(input.plan.map(([name]) => name))));
|
|
4994
5000
|
const single = input.single === true;
|
|
4995
5001
|
const frame = checkGeometry(
|
|
4996
5002
|
{ sourceW: source.width, sourceH: source.height, resolution: input.resolution, headBox: input.headBox, rigScale: input.rigScale, ...(single ? { single: true } : {}) },
|
|
@@ -5107,6 +5113,7 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
5107
5113
|
const ghost: Record<string, number> = {};
|
|
5108
5114
|
/** The full run's layers with an opaque pixel, in draw order: the candidates `uncoveredErrorLayers` reads. */
|
|
5109
5115
|
const fullTags: string[] = [];
|
|
5116
|
+
const preparedRuns: Array<{ run: Run; set: LayerSet; layers: ReturnType<typeof runLayers>; rigLayers: Raster[]; rank: number[]; keep: Array<Mask | null>; writes: Array<Int32Array | null> }> = [];
|
|
5110
5117
|
// A single run (issue #359) is read once: there is no head run to place, project or count ghosts for.
|
|
5111
5118
|
for (const [run, set] of single ? ([['full', full]] as const) : ([['full', full], ['head', head]] as const)) {
|
|
5112
5119
|
const layers = runLayers(set, input.resolution);
|
|
@@ -5193,6 +5200,42 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
5193
5200
|
valueBaselines.set(key, raw === null ? null : compactValueBaseline(raw));
|
|
5194
5201
|
return ids;
|
|
5195
5202
|
});
|
|
5203
|
+
preparedRuns.push({ run, set, layers, rigLayers, rank, keep, writes });
|
|
5204
|
+
}
|
|
5205
|
+
const edgeSplitNewSampleParts = new Set<string>();
|
|
5206
|
+
const edgeSplits = (input.edgeSplits?.length ?? 0) === 0 ? [] : applyEdgeSplits(
|
|
5207
|
+
input.edgeSplits!,
|
|
5208
|
+
new Map(sourcePlan.flatMap(([name, r, tag]) => {
|
|
5209
|
+
const prep = preparedRuns.find(p => p.run === r);
|
|
5210
|
+
const idx = prep?.layers.findIndex(l => l.tag === tag) ?? -1;
|
|
5211
|
+
return prep !== undefined && idx >= 0 ? [[name, prep.rigLayers[idx]] as [string, Raster]] : [];
|
|
5212
|
+
})),
|
|
5213
|
+
srcr,
|
|
5214
|
+
(part, pixel, cleared, priorAlpha) => {
|
|
5215
|
+
if (!cleared && priorAlpha <= OPAQUE_ALPHA_ABOVE) edgeSplitNewSampleParts.add(part);
|
|
5216
|
+
const row = sourcePlan.find(([name]) => name === part);
|
|
5217
|
+
if (row === undefined) return;
|
|
5218
|
+
const prep = preparedRuns.find(p => p.run === row[1]);
|
|
5219
|
+
const idx = prep?.layers.findIndex(l => l.tag === row[2]) ?? -1;
|
|
5220
|
+
const w = prep !== undefined && idx >= 0 ? prep.writes[idx] : null;
|
|
5221
|
+
if (w !== null && w !== undefined) w[pixel] = cleared ? 0 : AW.sourceProjection;
|
|
5222
|
+
},
|
|
5223
|
+
);
|
|
5224
|
+
const edgeSplitDepthProblems: Problem[] = [];
|
|
5225
|
+
for (const part of edgeSplitNewSampleParts) {
|
|
5226
|
+
const row = sourcePlan.find(([name]) => name === part);
|
|
5227
|
+
if (row === undefined) continue;
|
|
5228
|
+
const keys = [`${row[1]}:${row[2]}`, ...extend.filter(e => e.part === part).map(e => `${e.run}:${e.tag}`)];
|
|
5229
|
+
if (keys.some(k => registeredDepth.has(k))) {
|
|
5230
|
+
edgeSplitDepthProblems.push({
|
|
5231
|
+
code: 'DEPTH_PART_SUPPORT',
|
|
5232
|
+
object: `part "${part}"`,
|
|
5233
|
+
detail: 'edge split (config.assemble.edge_splits) gives new painting samples to a part with a layer depth sheet; remove the split or the target layer depth, never extrapolate a layer sheet onto new painting samples',
|
|
5234
|
+
});
|
|
5235
|
+
}
|
|
5236
|
+
}
|
|
5237
|
+
refuseIfAny(edgeSplitDepthProblems);
|
|
5238
|
+
for (const { run, set, layers, rigLayers, rank, keep, writes } of preparedRuns) {
|
|
5196
5239
|
const st = projectSource(rigLayers, srcr, frame, run, projectRule, rank, keep, (i, p) => { if (writes[i] !== null) (writes[i] as Int32Array)[p] = AW.sourceProjection; }, owners => {
|
|
5197
5240
|
if (targets !== undefined && beforeTake === null) return;
|
|
5198
5241
|
const reading = sourceCoverRun(run, set, run === 'full' ? fullPadded : depthHeadInput,
|
|
@@ -5875,10 +5918,12 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
5875
5918
|
return whole;
|
|
5876
5919
|
};
|
|
5877
5920
|
const canvases = stack.map(onRig);
|
|
5878
|
-
const
|
|
5921
|
+
const rawPlan = input.plan.map(([name, run, tag]) => {
|
|
5879
5922
|
const layer = input[run].layers.find(l => l.name === tag)!;
|
|
5880
5923
|
return { name, raster: layerToRig(placeLayer(layer, input.resolution), frame, run) };
|
|
5881
|
-
})
|
|
5924
|
+
});
|
|
5925
|
+
if ((input.edgeSplits?.length ?? 0) > 0) applyEdgeSplits(input.edgeSplits!, new Map(rawPlan.map(p => [p.name, p.raster])), srcr);
|
|
5926
|
+
const owner = rawPaintingOwner(rawPlan, W * H);
|
|
5882
5927
|
const lineage: Array<[string, string]> = [
|
|
5883
5928
|
...input.cuts.map(c => [c.from, c.into] as [string, string]),
|
|
5884
5929
|
...Object.values(input.limbs ?? {}).flatMap(l => l.segments.flatMap(segment => [
|
|
@@ -6182,9 +6227,12 @@ function assembleParts(input: AssembleInput, targets?: ReadonlySet<string>, befo
|
|
|
6182
6227
|
islands: islandKept.counts,
|
|
6183
6228
|
splits: islandKept.splits,
|
|
6184
6229
|
capSplits: capAssigned.counts,
|
|
6230
|
+
edgeSplits,
|
|
6185
6231
|
};
|
|
6186
6232
|
}
|
|
6187
6233
|
|
|
6234
|
+
export { edgeSplitLines };
|
|
6235
|
+
|
|
6188
6236
|
// ---------------------------------------------------------------------------
|
|
6189
6237
|
// refused bodies: a part whose layer is not what the painting shows (issue #255)
|
|
6190
6238
|
// ---------------------------------------------------------------------------
|
|
@@ -7087,6 +7135,8 @@ export function stageFields(
|
|
|
7087
7135
|
requireHiddenExtent?: readonly HiddenExtentDeclaration[];
|
|
7088
7136
|
/** Base painting only; named final parts, explicit band and path bound (#848). */
|
|
7089
7137
|
paintingExtension?: readonly PaintingExtension[];
|
|
7138
|
+
/** Painting-edge splits between plan parts before projection (#1231). */
|
|
7139
|
+
edgeSplits?: readonly EdgeSplit[];
|
|
7090
7140
|
turnMovingPair?: (a: string, b: string) => boolean;
|
|
7091
7141
|
turn?: TurnSpec;
|
|
7092
7142
|
regions?: Record<string, RegionSpec>;
|
|
@@ -7119,6 +7169,7 @@ export function stageFields(
|
|
|
7119
7169
|
...(cfg.assemble.require_hidden_extent === undefined ? {} : { requireHiddenExtent: cfg.assemble.require_hidden_extent }),
|
|
7120
7170
|
...(cfg.assemble.ground === undefined ? {} : { ground: cfg.assemble.ground }),
|
|
7121
7171
|
...(cfg.assemble.extend_painting === undefined ? {} : { paintingExtension: cfg.assemble.extend_painting }),
|
|
7172
|
+
...(cfg.assemble.edge_splits === undefined ? {} : { edgeSplits: cfg.assemble.edge_splits }),
|
|
7122
7173
|
...(turnMovingPair === null ? {} : { turnMovingPair }),
|
|
7123
7174
|
...(cfg.turn === undefined ? {} : { turn: cfg.turn, regions: cfg.regions, meshes: cfg.meshes, motion: cfg.motion }),
|
|
7124
7175
|
rigScale: cfg.assemble.rig_scale,
|
package/src/build.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { CUT_MATERIAL_LINE, CUT_MATERIAL_SOURCES, materialLines } from './cutmat
|
|
|
15
15
|
import { ART_JOINT_LINE, artJointLines } from './artjoints.ts';
|
|
16
16
|
import { applyTakenLayers } from './takelayers.ts';
|
|
17
17
|
import { applyTakenRegions } from './takeregion.ts';
|
|
18
|
+
import { occluderStageWarnings } from './occluderstage.ts';
|
|
18
19
|
import { ownershipLines, provenanceLines } from './provenance.ts';
|
|
19
20
|
import { readSourceDepth } from './depthsheets.ts';
|
|
20
21
|
import { orderedBaseAnchor } from './baseanchor.ts';
|
|
@@ -66,7 +67,7 @@ import { createHash } from 'node:crypto';
|
|
|
66
67
|
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
67
68
|
import { basename, dirname, join, relative, resolve, sep } from 'node:path';
|
|
68
69
|
import { type AnimFrame, EncodeError, encodeApng, encodeIndexedApng, INDEXED_DEFAULTS } from './apng.ts';
|
|
69
|
-
import { assemble, type AssembleResult, cutLines, type ExcludedCount, excludedLines, setExclusions, islandLines, setIslandSources, type IslandCount, hiddenLines, SINGLE_RUN_FACE_TAGS, singleRunHeadBox, softOcclusionLine, driftLine, limbLines, FIGURE_MASK_FILE, figuresLine, groundWarning, holeKindsLine, holeLines, measurePinholes, measureRecomposite, pinholeProblems, pinholesLine, type ProjectRule, recomposite, recompositeRecord, scenePhrase, type SeamRule, sourceInRig, stageFields, uncoveredLine } from './assemble.ts';
|
|
70
|
+
import { assemble, type AssembleResult, cutLines, edgeSplitLines, type ExcludedCount, excludedLines, setExclusions, islandLines, setIslandSources, type IslandCount, hiddenLines, SINGLE_RUN_FACE_TAGS, singleRunHeadBox, softOcclusionLine, driftLine, limbLines, FIGURE_MASK_FILE, figuresLine, groundWarning, holeKindsLine, holeLines, measurePinholes, measureRecomposite, pinholeProblems, pinholesLine, type ProjectRule, recomposite, recompositeRecord, scenePhrase, type SeamRule, sourceInRig, stageFields, uncoveredLine } from './assemble.ts';
|
|
70
71
|
import { allocationClause, type Reducer, stageBClause, unboundedClause } from './automesh.ts';
|
|
71
72
|
import { residualClause } from './autoenvelope.ts';
|
|
72
73
|
import { type AutoMotionCase, failingRows, idleSchedule, localRow, motionClause, motionDeformation, motionDocument, motionInput, motionRowText, motionStimulus, motionVerdict, noStimulusProblem, prepareComparison, type ReplayCandidate, runComparison, runPreparedComparison, sourceSelfFailure, stimulusMotion, withStimulus } from './automotion.ts';
|
|
@@ -389,6 +390,11 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
389
390
|
const result = assemble({ allocationEvent: input.allocationEvent === undefined ? undefined : event => input.allocationEvent!(event, null), source: src, full: runs.full, head: runs.head, depth: cfg.depth, depthBase: dirname(resolve(input.config)), ...fields, under, ...(declaredFigure === undefined ? {} : { declaredFigure }),
|
|
390
391
|
...((cfg.assemble.take ?? []).some(t => 'part' in t) ? { regionTake: { full: takenRuns.full, head: takenRuns.head, targets: (cfg.assemble.take ?? []).flatMap(t => 'part' in t ? [t.part] : []) } } : {}), ...(caps === undefined ? {} : { caps }), seamRule: seam, projectRule: project });
|
|
391
392
|
|
|
393
|
+
// Issue #1230: copied occluder colour in a declared occluder's under parts is named, never kept silent; no byte moves.
|
|
394
|
+
if (cfg.assemble.occluders !== undefined) {
|
|
395
|
+
for (const line of occluderStageWarnings({ occluders: cfg.assemble.occluders, configPath: input.config, source: src, runs, plan: fields.plan, resolution: fields.resolution, headBox: fields.headBox, rigScale: fields.rigScale })) log(line);
|
|
396
|
+
}
|
|
397
|
+
|
|
392
398
|
const sourceCoverSets = [sourceCoverSet(result, null, input.source, read)];
|
|
393
399
|
|
|
394
400
|
// Issue #454: alternate painting sets, assembled before any file is written.
|
|
@@ -1018,6 +1024,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
|
|
|
1018
1024
|
for (const alt of altBuilt) for (const line of [...provenanceLines(alt.record.records), ...ownershipLines(alt.record.cut_ownership ?? [])]) log(` set "${alt.record.name}" ${line.trimStart()}`);
|
|
1019
1025
|
// Issue #256: one line per part from an author-made layer, so it never reads as See-through's. None without one.
|
|
1020
1026
|
for (const l of authorPartLines(result.parts.parts)) log(l);
|
|
1027
|
+
for (const l of edgeSplitLines(result.edgeSplits)) log(l);
|
|
1021
1028
|
// One line per plan part an assemble.cuts entry cut, before the fringe lines: the cut is made first. None without cuts.
|
|
1022
1029
|
for (const l of cutLines(result.cuts)) log(l);
|
|
1023
1030
|
if (materialAsked) for (const line of materialLines({ status: 'SKIP', rows: result.cutMaterial, reason: 'assemble source readings only; check --requirements judges declared joint material' })) log(` ${line}`);
|
package/src/comfy/plate.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `comfy plate --mode background`: the figure-removed background plate of a
|
|
3
3
|
* painting, inpainted on a ComfyUI box over a source mask (issue #1183).
|
|
4
|
+
* `--mode occluder` (issue #1230) runs the same route over the mask a declared
|
|
5
|
+
* occluder image gives (`occluderMask`): the painting with what stands in
|
|
6
|
+
* front of the character inpainted away, for a See-through run to read the
|
|
7
|
+
* surface behind it from. Its receipt binds the occluder too.
|
|
4
8
|
*
|
|
5
9
|
* The route, in order, each step refusing by name:
|
|
6
10
|
*
|
|
@@ -39,6 +43,9 @@ import {
|
|
|
39
43
|
LAMA_MODEL,
|
|
40
44
|
lamaPlateGraph,
|
|
41
45
|
maskImage,
|
|
46
|
+
type MaskSource,
|
|
47
|
+
OCCLUDER_ALPHA_ABOVE,
|
|
48
|
+
occluderMask,
|
|
42
49
|
parseMaskFrom,
|
|
43
50
|
pasteInside,
|
|
44
51
|
PLATE_GRAPH_IDS,
|
|
@@ -46,6 +53,7 @@ import {
|
|
|
46
53
|
type PlateReceipt,
|
|
47
54
|
prepareCoreGrid,
|
|
48
55
|
publishPlate,
|
|
56
|
+
readOccluder,
|
|
49
57
|
readPlatePainting,
|
|
50
58
|
readSourceMask,
|
|
51
59
|
} from '../plate.ts';
|
|
@@ -54,8 +62,14 @@ import { decodePngBytes, encodePngBytes } from '../raster/png.ts';
|
|
|
54
62
|
import { ComfyClient, historyImages, refuse } from './client.ts';
|
|
55
63
|
|
|
56
64
|
export interface BackgroundRun {
|
|
65
|
+
/** Absent: `background`. */
|
|
66
|
+
mode?: 'background' | 'occluder';
|
|
57
67
|
painting: string;
|
|
58
68
|
maskFrom: string | undefined;
|
|
69
|
+
/** `--mode occluder`: the RGBA occluder image on the painting's grid. */
|
|
70
|
+
occluder?: string;
|
|
71
|
+
/** `--mode occluder --holes`: fill the pockets the occluder encloses before growing. */
|
|
72
|
+
holes?: boolean;
|
|
59
73
|
out: string;
|
|
60
74
|
graph: PlateGraph;
|
|
61
75
|
/** The model file the graph loads: the LaMa model for `lama`, the checkpoint for `core`. */
|
|
@@ -85,10 +99,13 @@ export function gpuName(stats: Record<string, unknown>, host: string): string {
|
|
|
85
99
|
export async function runBackground(connect: () => ComfyClient, run: BackgroundRun, say: (line: string) => void): Promise<PlateReceipt> {
|
|
86
100
|
// Local first: no source mask, a bad checksum or a missing checkpoint is refused before the box is reached.
|
|
87
101
|
const cfg = coreCfg(run.cfg, run.graph);
|
|
88
|
-
const
|
|
102
|
+
const occluderMode = run.mode === 'occluder';
|
|
103
|
+
if (occluderMode && run.occluder === undefined) refuse('PLATE_OCCLUDER_PRESENT', '--occluder', 'is absent; --mode occluder reads its mask from an RGBA occluder image on the painting\'s grid');
|
|
104
|
+
const from: { source: MaskSource; dir: string } = occluderMode ? { source: 'occluder', dir: run.occluder! } : parseMaskFrom(run.maskFrom);
|
|
89
105
|
const painting = readPlatePainting(run.painting);
|
|
90
106
|
const { width: W, height: H } = painting.raster;
|
|
91
|
-
const
|
|
107
|
+
const occluder = occluderMode ? readOccluder(run.occluder!) : undefined;
|
|
108
|
+
const source: FigureMask = occluder !== undefined ? occluderMask(occluder.raster, run.occluder!, W, H, run.holes === true) : readSourceMask(from.source, from.dir, W, H, painting.raster, painting.bytes);
|
|
92
109
|
const checkpoint = declaredChecksum(run.checkpointSha256);
|
|
93
110
|
if (run.graph === 'core' && run.model === undefined) {
|
|
94
111
|
refuse('PLATE_MODEL_GIVEN', '--model', 'is absent; the core graph needs the checkpoint the box loads, by its name on the box — there is no default checkpoint');
|
|
@@ -133,7 +150,7 @@ export async function runBackground(connect: () => ComfyClient, run: BackgroundR
|
|
|
133
150
|
return publishPlate({
|
|
134
151
|
out: run.out,
|
|
135
152
|
stageTag: prefix,
|
|
136
|
-
mode: 'background',
|
|
153
|
+
mode: occluderMode ? 'occluder' : 'background',
|
|
137
154
|
paintingPath: run.painting,
|
|
138
155
|
paintingBytes: painting.bytes,
|
|
139
156
|
source: from.source,
|
|
@@ -141,9 +158,10 @@ export async function runBackground(connect: () => ComfyClient, run: BackgroundR
|
|
|
141
158
|
mask,
|
|
142
159
|
plate: pasteInside(painting.raster, inpainted, mask),
|
|
143
160
|
model: { name: model, checkpoint_sha256: checkpoint, checkpoint_sha256_from: 'declared' },
|
|
144
|
-
params: run.graph === 'lama' ? {
|
|
161
|
+
params: { ...(run.graph === 'lama' ? lama : core), ...(occluderMode ? { holes: run.holes === true, mask_alpha_above: OCCLUDER_ALPHA_ABOVE } : { mask_alpha_above: OPAQUE_ALPHA_ABOVE }) },
|
|
145
162
|
graph: PLATE_GRAPH_IDS[run.graph],
|
|
146
163
|
gpu,
|
|
147
164
|
gridTransform: prepared.transform,
|
|
165
|
+
...(occluder === undefined ? {} : { occluder: { path: run.occluder!, bytes: occluder.bytes } }),
|
|
148
166
|
});
|
|
149
167
|
}
|
package/src/config.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { hiddenExtentNameProblems, type HiddenExtentDeclaration } from './hiddenextent.ts';
|
|
2
|
+
import { occluderFileProblems, occluderNameProblems, type OccluderDeclaration } from './occluders.ts';
|
|
2
3
|
import { SEAM_RULES, type SeamRule } from './seamrule.ts';
|
|
3
4
|
import { DEFAULT_PROJECT_RULE, GROUNDS, type Ground, PROJECT_RULES, type ProjectRule } from './projectrule.ts';
|
|
4
5
|
import type { TakeDeclaration } from './takeregion.ts';
|
|
5
6
|
import { paintingExtensionProblems, type PaintingExtension } from './paintingextension.ts';
|
|
7
|
+
import { edgeSplitProblems, type EdgeSplit } from './edgesplit.ts';
|
|
6
8
|
import { baseAnchorProblems, type BaseAnchor } from './baseanchor.ts';
|
|
7
9
|
import type { DepthConfig } from './depthsheets.ts';
|
|
8
10
|
/**
|
|
@@ -326,6 +328,8 @@ export interface Assemble {
|
|
|
326
328
|
extend_below_crop?: Extend[];
|
|
327
329
|
/** Bounded base-painting samples assigned to named final output parts (#848). */
|
|
328
330
|
extend_painting?: PaintingExtension[];
|
|
331
|
+
/** Painting-edge splits between plan parts before projection (#1231). */
|
|
332
|
+
edge_splits?: EdgeSplit[];
|
|
329
333
|
patches?: Patch[];
|
|
330
334
|
cuts?: Cut[];
|
|
331
335
|
alternates?: AlternateSetConfig[];
|
|
@@ -339,6 +343,8 @@ export interface Assemble {
|
|
|
339
343
|
keep_under_occluders?: string[];
|
|
340
344
|
/** Require original material in enclosed source holes beneath a named moving cover. */
|
|
341
345
|
require_hidden_extent?: HiddenExtentDeclaration[];
|
|
346
|
+
/** Issue #1230: declared RGBA occluders on the painting's grid and the plan parts they stand over. */
|
|
347
|
+
occluders?: OccluderDeclaration[];
|
|
342
348
|
}
|
|
343
349
|
|
|
344
350
|
export interface SingleBone {
|
|
@@ -1476,6 +1482,13 @@ export function configFileReferences(raw: unknown): ConfigFileReference[] {
|
|
|
1476
1482
|
const target = parent;
|
|
1477
1483
|
out.push({ at: field.path.join('.'), value, set: (next) => { target[key] = next; } });
|
|
1478
1484
|
}
|
|
1485
|
+
// Issue #1230: each declared occluder's image, an array field the single-path table above cannot name.
|
|
1486
|
+
const assemble = isPlainObject(raw) ? raw.assemble : undefined;
|
|
1487
|
+
const occluders = isPlainObject(assemble) && Array.isArray(assemble.occluders) ? assemble.occluders : [];
|
|
1488
|
+
occluders.forEach((entry: unknown, i: number) => {
|
|
1489
|
+
if (!isPlainObject(entry) || typeof entry.image !== 'string' || entry.image === '') return;
|
|
1490
|
+
out.push({ at: `assemble.occluders[${i}].image`, value: entry.image, set: (next) => { entry.image = next; } });
|
|
1491
|
+
});
|
|
1479
1492
|
return out;
|
|
1480
1493
|
}
|
|
1481
1494
|
|
|
@@ -1702,7 +1715,7 @@ export interface EarlyConfig {
|
|
|
1702
1715
|
depth?: DepthConfig;
|
|
1703
1716
|
key: string;
|
|
1704
1717
|
seethrough: SeeThrough;
|
|
1705
|
-
assemble: { rig_scale: number; seam?: SeamRule; project?: ProjectRule; ground?: Ground; take?: TakeDeclaration[]; editor_receipts?: EditorReceipts; head_face_underfill?: boolean; yield_refused?: boolean; stage_map?: boolean; keep_under_occluders?: string[]; require_hidden_extent?: HiddenExtentDeclaration[]; extend_painting?: PaintingExtension[] };
|
|
1718
|
+
assemble: { rig_scale: number; seam?: SeamRule; project?: ProjectRule; ground?: Ground; take?: TakeDeclaration[]; editor_receipts?: EditorReceipts; head_face_underfill?: boolean; yield_refused?: boolean; stage_map?: boolean; keep_under_occluders?: string[]; require_hidden_extent?: HiddenExtentDeclaration[]; extend_painting?: PaintingExtension[]; occluders?: OccluderDeclaration[]; edge_splits?: EdgeSplit[] };
|
|
1706
1719
|
}
|
|
1707
1720
|
|
|
1708
1721
|
/** What plain `assemble` reads: the early config plus the plan `--propose-plan` printed. */
|
|
@@ -1780,7 +1793,7 @@ function parseEarlyConfigFrom(raw: Json, door: EarlyDoor, base: string | null, p
|
|
|
1780
1793
|
if (door === 'layers') {
|
|
1781
1794
|
if ('seethrough' in t) checkSeeThrough(c, t.seethrough);
|
|
1782
1795
|
if ('assemble' in t) {
|
|
1783
|
-
const a = c.object('config.assemble', t.assemble, sectionRequired(door, 'assemble'), ['plan', 'extend_below_crop', 'patches', 'cuts', 'alternates', 'head_face_underfill', 'yield_refused', 'stage_map', 'keep_under_occluders', 'require_hidden_extent', 'extend_painting', 'take', 'seam', 'project', 'ground', 'editor_receipts']);
|
|
1796
|
+
const a = c.object('config.assemble', t.assemble, sectionRequired(door, 'assemble'), ['plan', 'extend_below_crop', 'patches', 'cuts', 'alternates', 'head_face_underfill', 'yield_refused', 'stage_map', 'keep_under_occluders', 'require_hidden_extent', 'extend_painting', 'edge_splits', 'take', 'seam', 'project', 'ground', 'editor_receipts', 'occluders']);
|
|
1784
1797
|
if (a !== null) {
|
|
1785
1798
|
checkAssembleRules(c, a);
|
|
1786
1799
|
if ('rig_scale' in a) c.number('config.assemble.rig_scale', a.rig_scale, 'positive');
|
|
@@ -1792,7 +1805,9 @@ function parseEarlyConfigFrom(raw: Json, door: EarlyDoor, base: string | null, p
|
|
|
1792
1805
|
}
|
|
1793
1806
|
checkKeepUnderOccluders(c, a, null);
|
|
1794
1807
|
checkRequiredHiddenExtent(c, a, null);
|
|
1808
|
+
checkOccluders(c, a, null, base);
|
|
1795
1809
|
if ('extend_painting' in a) checkPaintingExtensions(c, a.extend_painting);
|
|
1810
|
+
if ('edge_splits' in a) checkEdgeSplits(c, a.edge_splits, Array.isArray(a.plan) ? new Set(a.plan.filter((r): r is Json[] => Array.isArray(r) && typeof r[0] === 'string').map(r => r[0] as string)) : null);
|
|
1796
1811
|
if ('take' in a) checkTakeLayers(c, a.take);
|
|
1797
1812
|
if ('editor_receipts' in a) checkEditorReceipts(c, a.editor_receipts);
|
|
1798
1813
|
if ('yield_refused' in a && typeof a.yield_refused !== 'boolean') {
|
|
@@ -1807,6 +1822,7 @@ function parseEarlyConfigFrom(raw: Json, door: EarlyDoor, base: string | null, p
|
|
|
1807
1822
|
if (busyVisible && 'requirements' in t && c.string('config.requirements', t.requirements) && base !== null) checkRequirementsFile(c, configFilePath('requirements', base, t.requirements) as string);
|
|
1808
1823
|
if ('seethrough' in t) checkSeeThrough(c, t.seethrough);
|
|
1809
1824
|
const made = 'assemble' in t ? checkAssemble(c, t.assemble, door) : { parts: [], patches: [], cuts: [] };
|
|
1825
|
+
if ('assemble' in t) checkOccluderFiles(c, t.assemble, base);
|
|
1810
1826
|
checkProposedRigScale(c, t);
|
|
1811
1827
|
if ('scene' in t) checkScene(c, t.scene);
|
|
1812
1828
|
// Issue #349: the limbs' joints are their bones' origins, so the bones are read with them, and only then.
|
|
@@ -2038,6 +2054,7 @@ function parseConfigFrom(raw: Json, base: string | null): { config: CharacterCon
|
|
|
2038
2054
|
if ('generation' in t) checkGeneration(c, t.generation);
|
|
2039
2055
|
if ('seethrough' in t) checkSeeThrough(c, t.seethrough);
|
|
2040
2056
|
const { parts, patches, cuts } = 'assemble' in t ? checkAssemble(c, t.assemble, 'full') : { parts: [], patches: [], cuts: [] };
|
|
2057
|
+
if ('assemble' in t) checkOccluderFiles(c, t.assemble, base);
|
|
2041
2058
|
checkProposedRigScale(c, t);
|
|
2042
2059
|
const names = 'bones' in t ? checkBones(c, t.bones) : { bones: new Set<string>([ROOT_BONE]), chains: new Map<string, number>(), parents: new Map<string, string>() };
|
|
2043
2060
|
const limbs = 'limbs' in t ? checkLimbs(c, t.limbs, { parts, patches, cuts }, 'bones' in t ? names : null) : null;
|
|
@@ -2524,6 +2541,16 @@ function checkPaintingExtensions(c: Check, value: Json, names: ReadonlySet<strin
|
|
|
2524
2541
|
}
|
|
2525
2542
|
}
|
|
2526
2543
|
|
|
2544
|
+
function checkEdgeSplits(c: Check, value: Json, names: ReadonlySet<string> | null = null): void {
|
|
2545
|
+
const at = 'config.assemble.edge_splits';
|
|
2546
|
+
if (c.array(at, value, false)) (value as Json[]).forEach((entry, i) => {
|
|
2547
|
+
c.object(`${at}[${i}]`, entry, ['over', 'under', 'band'], []);
|
|
2548
|
+
});
|
|
2549
|
+
for (const p of edgeSplitProblems(value, names)) {
|
|
2550
|
+
if (!c.problems.some(old => old.code === p.code && old.object === p.object)) c.problems.push(p);
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2527
2554
|
function checkRequiredHiddenExtent(c: Check, a: Record<string, Json>, names: readonly string[] | null): void {
|
|
2528
2555
|
if (!('require_hidden_extent' in a)) return;
|
|
2529
2556
|
const at = 'config.assemble.require_hidden_extent';
|
|
@@ -2539,6 +2566,40 @@ function checkRequiredHiddenExtent(c: Check, a: Record<string, Json>, names: rea
|
|
|
2539
2566
|
c.problems.push(...hiddenExtentNameProblems(declarations, names));
|
|
2540
2567
|
}
|
|
2541
2568
|
|
|
2569
|
+
/**
|
|
2570
|
+
* Issue #1230: `config.assemble.occluders`, `[{image, sha256, under, rgb_within}]`. Shape at every door; `under`
|
|
2571
|
+
* resolved against the plan where the door reads it; the file and its sha256 where the door knows the config's
|
|
2572
|
+
* directory (`checkOccluderFiles`).
|
|
2573
|
+
*/
|
|
2574
|
+
function checkOccluders(c: Check, a: Record<string, Json>, names: readonly string[] | null, base: string | null): void {
|
|
2575
|
+
if (!('occluders' in a)) return;
|
|
2576
|
+
const at = 'config.assemble.occluders';
|
|
2577
|
+
if (!c.array(at, a.occluders, false)) return;
|
|
2578
|
+
const declarations: OccluderDeclaration[] = [];
|
|
2579
|
+
(a.occluders as Json[]).forEach((value, i) => {
|
|
2580
|
+
const p = `${at}[${i}]`;
|
|
2581
|
+
const row = c.object(p, value, ['image', 'sha256', 'under', 'rgb_within'], []);
|
|
2582
|
+
if (row === null) return;
|
|
2583
|
+
const imageOk = c.string(`${p}.image`, row.image);
|
|
2584
|
+
const shaOk = typeof row.sha256 === 'string' && SHA256_PATTERN.test(row.sha256);
|
|
2585
|
+
if (!shaOk) c.fail('CONFIG_FIELD_TYPE', `${p}.sha256`, `is ${show(row.sha256)}; ${SHA256_RULE} is required`);
|
|
2586
|
+
let underOk = c.array(`${p}.under`, row.under, true);
|
|
2587
|
+
if (underOk) (row.under as Json[]).forEach((name, j) => { if (!c.string(`${p}.under[${j}]`, name)) underOk = false; });
|
|
2588
|
+
const rgbOk = typeof row.rgb_within === 'number' && Number.isInteger(row.rgb_within) && row.rgb_within >= 0 && row.rgb_within <= 255;
|
|
2589
|
+
if (!rgbOk) c.fail('CONFIG_FIELD_TYPE', `${p}.rgb_within`, `is ${show(row.rgb_within)}; an integer from 0 to 255 is required`);
|
|
2590
|
+
if (imageOk && shaOk && underOk && rgbOk) declarations.push({ image: row.image as string, sha256: row.sha256 as string, under: row.under as string[], rgb_within: row.rgb_within as number });
|
|
2591
|
+
});
|
|
2592
|
+
c.problems.push(...occluderNameProblems(declarations, names));
|
|
2593
|
+
if (base !== null) c.problems.push(...occluderFileProblems(declarations, base));
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
/** The occluder files, at the doors that know the config's directory but read the plan elsewhere. */
|
|
2597
|
+
function checkOccluderFiles(c: Check, assemble: Json, base: string | null): void {
|
|
2598
|
+
if (base === null || !isPlainObject(assemble) || !Array.isArray(assemble.occluders)) return;
|
|
2599
|
+
const declarations = (assemble.occluders as Json[]).filter((d): d is OccluderDeclaration => isPlainObject(d) && typeof d.image === 'string' && d.image !== '' && typeof d.sha256 === 'string' && SHA256_PATTERN.test(d.sha256));
|
|
2600
|
+
c.problems.push(...occluderFileProblems(declarations, base));
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2542
2603
|
function checkKeepUnderOccluders(c: Check, a: Record<string, Json>, plan: readonly string[] | null): void {
|
|
2543
2604
|
if (!('keep_under_occluders' in a)) return;
|
|
2544
2605
|
const at = 'config.assemble.keep_under_occluders';
|
|
@@ -2658,7 +2719,7 @@ function checkAssembleRules(c: Check, a: Record<string, Json>): void {
|
|
|
2658
2719
|
|
|
2659
2720
|
function checkAssemble(c: Check, v: Json, door: 'assemble' | 'full'): { parts: string[]; patches: string[]; cuts: string[] } {
|
|
2660
2721
|
const required = sectionRequired(door, 'assemble');
|
|
2661
|
-
const a = c.object('config.assemble', v, required.filter((k) => k !== 'plan'), ['plan', 'extend_below_crop', 'patches', 'cuts', 'alternates', 'head_face_underfill', 'yield_refused', 'stage_map', 'keep_under_occluders', 'require_hidden_extent', 'extend_painting', 'take', 'seam', 'project', 'ground', 'editor_receipts']);
|
|
2722
|
+
const a = c.object('config.assemble', v, required.filter((k) => k !== 'plan'), ['plan', 'extend_below_crop', 'patches', 'cuts', 'alternates', 'head_face_underfill', 'yield_refused', 'stage_map', 'keep_under_occluders', 'require_hidden_extent', 'extend_painting', 'edge_splits', 'take', 'seam', 'project', 'ground', 'editor_receipts', 'occluders']);
|
|
2662
2723
|
if (a === null) return { parts: [], patches: [], cuts: [] };
|
|
2663
2724
|
checkAssembleRules(c, a);
|
|
2664
2725
|
if (required.includes('plan') && !('plan' in a)) {
|
|
@@ -2698,7 +2759,9 @@ function checkAssemble(c: Check, v: Json, door: 'assemble' | 'full'): { parts: s
|
|
|
2698
2759
|
}
|
|
2699
2760
|
checkKeepUnderOccluders(c, a, parts);
|
|
2700
2761
|
checkRequiredHiddenExtent(c, a, parts);
|
|
2762
|
+
checkOccluders(c, a, parts, null);
|
|
2701
2763
|
if ('extend_painting' in a) checkPaintingExtensions(c, a.extend_painting);
|
|
2764
|
+
if ('edge_splits' in a) checkEdgeSplits(c, a.edge_splits, new Set(parts));
|
|
2702
2765
|
if ('take' in a) checkTakeLayers(c, a.take, parts);
|
|
2703
2766
|
if ('editor_receipts' in a) checkEditorReceipts(c, a.editor_receipts);
|
|
2704
2767
|
if ('extend_below_crop' in a && c.array(`${p}.extend_below_crop`, a.extend_below_crop, false)) {
|
package/src/edgesplit.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/** Painting-edge part split on pre-projection plan rasters (#1231). */
|
|
2
|
+
import type { Problem } from './errors.ts';
|
|
3
|
+
import { refuseIfAny } from './errors.ts';
|
|
4
|
+
import type { Raster } from './raster/types.ts';
|
|
5
|
+
import { pyRound } from './round.ts';
|
|
6
|
+
|
|
7
|
+
const EDGE_SPLIT_ALPHA = 128;
|
|
8
|
+
const EDGE_SPLIT_STEP = 40;
|
|
9
|
+
|
|
10
|
+
export interface EdgeSplit {
|
|
11
|
+
over: string;
|
|
12
|
+
under: string;
|
|
13
|
+
/** Half-open rectangle in rig pixels [x0, y0, x1, y1]; scopes the search. */
|
|
14
|
+
band: [number, number, number, number];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface EdgeSplitReading {
|
|
18
|
+
over: string;
|
|
19
|
+
under: string;
|
|
20
|
+
band: [number, number, number, number];
|
|
21
|
+
columns: number;
|
|
22
|
+
edge_share: number;
|
|
23
|
+
moved_px: number;
|
|
24
|
+
y_star_min: number;
|
|
25
|
+
y_star_max: number;
|
|
26
|
+
over_below_edge_px: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Shared by every config door and the callable assemble API. */
|
|
30
|
+
export function edgeSplitProblems(value: unknown, names: ReadonlySet<string> | null = null): Problem[] {
|
|
31
|
+
const at = 'config.assemble.edge_splits', out: Problem[] = [];
|
|
32
|
+
const fail = (code: string, object: string, detail: string): void => { out.push({ code, object, detail }); };
|
|
33
|
+
if (!Array.isArray(value)) {
|
|
34
|
+
fail('CONFIG_FIELD_TYPE', at, 'requires an array of {over, under, band}; omit it for no split');
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
value.forEach((entry: unknown, i) => {
|
|
38
|
+
const path = `${at}[${i}]`;
|
|
39
|
+
if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {
|
|
40
|
+
fail('CONFIG_FIELD_TYPE', path, 'requires {over, under, band}');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const e = entry as Record<string, unknown>;
|
|
44
|
+
for (const key of Object.keys(e)) {
|
|
45
|
+
if (!['over', 'under', 'band'].includes(key)) {
|
|
46
|
+
fail('CONFIG_KEY_KNOWN', `${path}.${key}`, 'is unknown; only over, under and band are read');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
for (const key of ['over', 'under', 'band']) {
|
|
50
|
+
if (!(key in e)) {
|
|
51
|
+
fail('CONFIG_FIELD_PRESENT', `${path}.${key}`, 'is absent and required; no part or band is inferred');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
for (const key of ['over', 'under'] as const) {
|
|
55
|
+
if (key in e) {
|
|
56
|
+
if (typeof e[key] !== 'string' || e[key] === '') {
|
|
57
|
+
fail('CONFIG_FIELD_TYPE', `${path}.${key}`, `is ${JSON.stringify(e[key])}; a nonempty plan part name is required`);
|
|
58
|
+
} else if (names !== null && !names.has(e[key] as string)) {
|
|
59
|
+
fail('CONFIG_NAME_RESOLVES', `${path}.${key}`, `names "${e[key]}"; a part named in assemble.plan is required — known: ${[...names].join(', ')}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (typeof e.over === 'string' && e.over !== '' && e.over === e.under) {
|
|
64
|
+
fail('CONFIG_PART_UNIQUE', `${path}.under`, `names "${e.under}", the same part as over; two distinct plan parts are required`);
|
|
65
|
+
}
|
|
66
|
+
if ('band' in e && !(Array.isArray(e.band) && e.band.length === 4 && e.band.every(n => Number.isSafeInteger(n) && n >= 0) && e.band[0] < e.band[2] && e.band[1] < e.band[3])) {
|
|
67
|
+
fail('CONFIG_FIELD_TYPE', `${path}.band`, `is ${JSON.stringify(e.band)}; [x0,y0,x1,y1] as nonnegative safe integers with x0 < x1 and y0 < y1 is required, rig pixels, upper bounds exclusive`);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Splits `over` and `under` plan rasters in place along the strongest painting
|
|
75
|
+
* vertical RGB step in `band`, before source projection.
|
|
76
|
+
*/
|
|
77
|
+
export function applyEdgeSplits(
|
|
78
|
+
declarations: readonly EdgeSplit[],
|
|
79
|
+
parts: ReadonlyMap<string, Raster>,
|
|
80
|
+
painting: Raster,
|
|
81
|
+
written?: (part: string, pixel: number, cleared: boolean, priorAlpha: number) => void,
|
|
82
|
+
): EdgeSplitReading[] {
|
|
83
|
+
refuseIfAny(edgeSplitProblems(declarations, new Set(parts.keys())));
|
|
84
|
+
const { width: W, height: H } = painting;
|
|
85
|
+
const problems: Problem[] = [];
|
|
86
|
+
declarations.forEach((e, i) => {
|
|
87
|
+
if (e.band[2] > W || e.band[3] > H) {
|
|
88
|
+
problems.push({
|
|
89
|
+
code: 'ASSEMBLE_PAINTING_BAND_INSIDE',
|
|
90
|
+
object: `config.assemble.edge_splits[${i}] ("${e.over}" -> "${e.under}")`,
|
|
91
|
+
detail: `band is [${e.band.join(', ')}]; rig is ${W}x${H}, so x1 <= ${W} and y1 <= ${H} are required; no clipping is applied`,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
refuseIfAny(problems);
|
|
96
|
+
|
|
97
|
+
const initialAlpha = new Map<string, Uint8Array>();
|
|
98
|
+
for (const e of declarations) {
|
|
99
|
+
if (!initialAlpha.has(e.under)) {
|
|
100
|
+
const r = parts.get(e.under)!;
|
|
101
|
+
const a = new Uint8Array(W * H);
|
|
102
|
+
for (let i = 0; i < W * H; i++) a[i] = r.data[i * 4 + 3];
|
|
103
|
+
initialAlpha.set(e.under, a);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const readings: EdgeSplitReading[] = [];
|
|
108
|
+
for (const e of declarations) {
|
|
109
|
+
const overRaster = parts.get(e.over)!;
|
|
110
|
+
const underRaster = parts.get(e.under)!;
|
|
111
|
+
const underInitialAlpha = initialAlpha.get(e.under)!;
|
|
112
|
+
const [x0, y0, x1, y1] = e.band;
|
|
113
|
+
let columns = 0;
|
|
114
|
+
let strongEdgeColumns = 0;
|
|
115
|
+
let movedPx = 0;
|
|
116
|
+
let yStarMin = Infinity;
|
|
117
|
+
let yStarMax = -1;
|
|
118
|
+
let overBelowEdgePx = 0;
|
|
119
|
+
|
|
120
|
+
for (let x = x0; x < x1; x++) {
|
|
121
|
+
let yStar = -1;
|
|
122
|
+
let bestStep = -1;
|
|
123
|
+
for (let y = y0; y < y1 && y + 1 < H; y++) {
|
|
124
|
+
const p = (y * W + x) * 4;
|
|
125
|
+
if (overRaster.data[p + 3] < EDGE_SPLIT_ALPHA) continue;
|
|
126
|
+
const q = ((y + 1) * W + x) * 4;
|
|
127
|
+
const step = Math.max(
|
|
128
|
+
Math.abs(painting.data[p] - painting.data[q]),
|
|
129
|
+
Math.abs(painting.data[p + 1] - painting.data[q + 1]),
|
|
130
|
+
Math.abs(painting.data[p + 2] - painting.data[q + 2]),
|
|
131
|
+
);
|
|
132
|
+
if (step > bestStep) {
|
|
133
|
+
bestStep = step;
|
|
134
|
+
yStar = y;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (yStar < 0) continue;
|
|
138
|
+
columns++;
|
|
139
|
+
if (bestStep > EDGE_SPLIT_STEP) strongEdgeColumns++;
|
|
140
|
+
if (yStar < yStarMin) yStarMin = yStar;
|
|
141
|
+
if (yStar > yStarMax) yStarMax = yStar;
|
|
142
|
+
|
|
143
|
+
for (let y = yStar + 1; y < y1; y++) {
|
|
144
|
+
const idx = y * W + x;
|
|
145
|
+
const p = idx * 4;
|
|
146
|
+
const oa = overRaster.data[p + 3];
|
|
147
|
+
if (oa >= EDGE_SPLIT_ALPHA) {
|
|
148
|
+
const priorUnderAlpha = underInitialAlpha[idx];
|
|
149
|
+
overRaster.data.fill(0, p, p + 4);
|
|
150
|
+
written?.(e.over, idx, true, oa);
|
|
151
|
+
underRaster.data[p] = painting.data[p];
|
|
152
|
+
underRaster.data[p + 1] = painting.data[p + 1];
|
|
153
|
+
underRaster.data[p + 2] = painting.data[p + 2];
|
|
154
|
+
underRaster.data[p + 3] = 255;
|
|
155
|
+
written?.(e.under, idx, false, priorUnderAlpha);
|
|
156
|
+
movedPx++;
|
|
157
|
+
} else if (oa > 0) {
|
|
158
|
+
overRaster.data.fill(0, p, p + 4);
|
|
159
|
+
written?.(e.over, idx, true, oa);
|
|
160
|
+
}
|
|
161
|
+
if (overRaster.data[p + 3] >= EDGE_SPLIT_ALPHA) overBelowEdgePx++;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
readings.push({
|
|
166
|
+
over: e.over,
|
|
167
|
+
under: e.under,
|
|
168
|
+
band: [x0, y0, x1, y1],
|
|
169
|
+
columns,
|
|
170
|
+
edge_share: columns === 0 ? 0 : pyRound(strongEdgeColumns / columns, 3),
|
|
171
|
+
moved_px: movedPx,
|
|
172
|
+
y_star_min: columns === 0 ? 0 : yStarMin,
|
|
173
|
+
y_star_max: columns === 0 ? 0 : yStarMax,
|
|
174
|
+
over_below_edge_px: overBelowEdgePx,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return readings;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function edgeSplitLines(readings: readonly EdgeSplitReading[]): string[] {
|
|
181
|
+
return readings.map(
|
|
182
|
+
(r) =>
|
|
183
|
+
` edge split: "${r.over}" -> "${r.under}" band [${r.band.join(', ')}] columns=${r.columns} edge_share=${r.edge_share} moved=${r.moved_px} px y*=${r.y_star_min}..${r.y_star_max} over_below_edge_px=${r.over_below_edge_px}`,
|
|
184
|
+
);
|
|
185
|
+
}
|
package/src/occluders.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declared occluders (issue #1230): `config.assemble.occluders`, an opt-in
|
|
3
|
+
* list of RGBA images of what stands in front of the character, each on the
|
|
4
|
+
* painting's grid, bound by sha256, with the plan parts it stands over.
|
|
5
|
+
*
|
|
6
|
+
* Today one reading uses it: a pixel of an `under` part's selected source
|
|
7
|
+
* layer (after any take, before projection or cleanup) with alpha above
|
|
8
|
+
* {@link COPIED_ALPHA_ABOVE}, where the occluder's alpha is above 0, whose RGB
|
|
9
|
+
* lies within `rgb_within` (max absolute channel difference) of the painting
|
|
10
|
+
* at that pixel, is the occluder's own colour copied into the layer: the run
|
|
11
|
+
* painted the thing in front into the surface behind it. It is reported as a
|
|
12
|
+
* WARN with {@link OCCLUDER_COLOUR_COPIED}, never silently kept and never
|
|
13
|
+
* repaired.
|
|
14
|
+
*
|
|
15
|
+
* Nothing here reads a stage or an assembly, so the config doors can share
|
|
16
|
+
* the name and file checks without an import cycle.
|
|
17
|
+
*/
|
|
18
|
+
import { existsSync, statSync } from 'node:fs';
|
|
19
|
+
import { resolve } from 'node:path';
|
|
20
|
+
import { fileSha256, SHA256_PATTERN } from './editreceipt.ts';
|
|
21
|
+
import type { Problem } from './errors.ts';
|
|
22
|
+
import type { Raster } from './raster/types.ts';
|
|
23
|
+
|
|
24
|
+
export interface OccluderDeclaration {
|
|
25
|
+
/** An RGBA PNG on the painting's grid, relative to the config's directory. */
|
|
26
|
+
image: string;
|
|
27
|
+
/** The image file's sha256, 64 lowercase hex digits. */
|
|
28
|
+
sha256: string;
|
|
29
|
+
/** Plan parts the occluder stands in front of. */
|
|
30
|
+
under: string[];
|
|
31
|
+
/** Max absolute channel difference from the painting at which an `under` pixel reads as the occluder's colour. */
|
|
32
|
+
rgb_within: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const OCCLUDER_COLOUR_COPIED = 'ASSEMBLE_OCCLUDER_COLOUR_COPIED';
|
|
36
|
+
/** An `under` layer pixel counts at alpha above this: the half-opaque floor `deriveTakenRegion` reads. */
|
|
37
|
+
export const COPIED_ALPHA_ABOVE = 128;
|
|
38
|
+
|
|
39
|
+
const AT = 'config.assemble.occluders';
|
|
40
|
+
|
|
41
|
+
/** Every `under` entry names a plan part (`CONFIG_NAME_RESOLVES`); `names` null skips the check (a door without the plan). */
|
|
42
|
+
export function occluderNameProblems(declarations: readonly OccluderDeclaration[], names: readonly string[] | null): Problem[] {
|
|
43
|
+
if (names === null) return [];
|
|
44
|
+
const problems: Problem[] = [];
|
|
45
|
+
declarations.forEach((d, i) => d.under.forEach((name, j) => {
|
|
46
|
+
if (!names.includes(name)) problems.push({ code: 'CONFIG_NAME_RESOLVES', object: `${AT}[${i}].under[${j}]`, detail: `names "${name}"; a part in config.assemble.plan is required` });
|
|
47
|
+
}));
|
|
48
|
+
return problems;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The image is a file beside the config (`CONFIG_FILE_PRESENT`) whose bytes hash to `sha256` (`CONFIG_OCCLUDER_SHA256`). */
|
|
52
|
+
export function occluderFileProblems(declarations: readonly OccluderDeclaration[], base: string): Problem[] {
|
|
53
|
+
const problems: Problem[] = [];
|
|
54
|
+
declarations.forEach((d, i) => {
|
|
55
|
+
const path = resolve(base, d.image);
|
|
56
|
+
if (!existsSync(path) || !statSync(path).isFile()) {
|
|
57
|
+
problems.push({ code: 'CONFIG_FILE_PRESENT', object: `${AT}[${i}].image`, detail: `names ${d.image}, which is no such file; an RGBA PNG of the occluder on the painting's grid, relative to the config's directory, is required` });
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const found = fileSha256(path);
|
|
61
|
+
if (SHA256_PATTERN.test(d.sha256) && found !== d.sha256) {
|
|
62
|
+
problems.push({ code: 'CONFIG_OCCLUDER_SHA256', object: `${AT}[${i}].sha256`, detail: `is ${d.sha256}; ${d.image} has sha256 ${found} — declare the bytes the occluder image holds` });
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return problems;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface OccluderCopy {
|
|
69
|
+
part: string;
|
|
70
|
+
px: number;
|
|
71
|
+
/** Rig px, x right and y down: the first copied pixel in row order. */
|
|
72
|
+
first: [number, number];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Copied occluder colour per `under` part, on the rig grid: `parts` are the
|
|
77
|
+
* selected source layers placed on the rig canvas (`width`x`height`), `painting`
|
|
78
|
+
* the painting on the same grid, `alpha(x, y)` the occluder's alpha at a rig
|
|
79
|
+
* pixel. A part with no copied pixel is left out.
|
|
80
|
+
*/
|
|
81
|
+
export function occluderColourCopies(parts: ReadonlyArray<{ name: string; image: Raster }>, painting: Raster, alpha: (x: number, y: number) => number, rgbWithin: number): OccluderCopy[] {
|
|
82
|
+
const out: OccluderCopy[] = [];
|
|
83
|
+
const { width, height } = painting;
|
|
84
|
+
for (const { name, image } of parts) {
|
|
85
|
+
let px = 0, first = -1;
|
|
86
|
+
for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
|
|
87
|
+
const p = y * width + x;
|
|
88
|
+
if (image.data[p * 4 + 3] <= COPIED_ALPHA_ABOVE || alpha(x, y) <= 0) continue;
|
|
89
|
+
let delta = 0;
|
|
90
|
+
for (let c = 0; c < 3; c++) delta = Math.max(delta, Math.abs(image.data[p * 4 + c] - painting.data[p * 4 + c]));
|
|
91
|
+
if (delta > rgbWithin) continue;
|
|
92
|
+
if (first < 0) first = p;
|
|
93
|
+
px++;
|
|
94
|
+
}
|
|
95
|
+
if (px > 0) out.push({ part: name, px, first: [first % width, Math.floor(first / width)] });
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function occluderColourWarning(index: number, copy: OccluderCopy, rgbWithin: number): string {
|
|
101
|
+
return `WARN ${OCCLUDER_COLOUR_COPIED}: ${AT}[${index}] part "${copy.part}" — ${copy.px} rig px of its selected layer at alpha > ${COPIED_ALPHA_ABOVE} under the occluder (alpha > 0) lie within ${rgbWithin} of the painting (max channel); first at ${copy.first[0]},${copy.first[1]}; the layer holds the occluder's own colour — take this part from a See-through run on the painting with the occluder removed (comfy plate --mode occluder)`;
|
|
102
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The assemble stage's reading of `config.assemble.occluders` (issue #1230):
|
|
3
|
+
* each declaration's image read and held to its sha256 and to the painting's
|
|
4
|
+
* size, each `under` part's selected source layer placed on the rig grid the
|
|
5
|
+
* way the hidden-extent reading places it (after any take, before projection
|
|
6
|
+
* or cleanup), and every copied-colour pixel counted ({@link occluderColourCopies}).
|
|
7
|
+
* It returns WARN lines and changes no output byte.
|
|
8
|
+
*/
|
|
9
|
+
import { createHash } from 'node:crypto';
|
|
10
|
+
import { readFileSync } from 'node:fs';
|
|
11
|
+
import { dirname, resolve } from 'node:path';
|
|
12
|
+
import { checkGeometry, layerToRig, padSingleRun, placeLayer, sourceInRig } from './assemble.ts';
|
|
13
|
+
import type { PlanEntry } from './config.ts';
|
|
14
|
+
import { PartsError } from './errors.ts';
|
|
15
|
+
import type { LayerSet } from './layers.ts';
|
|
16
|
+
import { type OccluderDeclaration, occluderColourCopies, occluderColourWarning } from './occluders.ts';
|
|
17
|
+
import { decodePngBytes } from './raster/png.ts';
|
|
18
|
+
import type { Raster } from './raster/types.ts';
|
|
19
|
+
|
|
20
|
+
function refuse(code: string, object: string, detail: string): never {
|
|
21
|
+
throw new PartsError([{ code, object, detail }]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface OccluderStageInput {
|
|
25
|
+
occluders: readonly OccluderDeclaration[];
|
|
26
|
+
configPath: string;
|
|
27
|
+
source: Raster;
|
|
28
|
+
runs: { full: LayerSet; head: LayerSet; single: boolean };
|
|
29
|
+
plan: readonly PlanEntry[];
|
|
30
|
+
resolution: number;
|
|
31
|
+
headBox: [number, number, number, number];
|
|
32
|
+
rigScale: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function occluderStageWarnings(input: OccluderStageInput): string[] {
|
|
36
|
+
const { source, runs } = input;
|
|
37
|
+
const frame = checkGeometry({ sourceW: source.width, sourceH: source.height, resolution: input.resolution, headBox: input.headBox, rigScale: input.rigScale, ...(runs.single ? { single: true } : {}) }, { full: runs.full, head: runs.head });
|
|
38
|
+
const full = runs.single ? padSingleRun(runs.full, frame, input.resolution) : runs.full;
|
|
39
|
+
const painting = sourceInRig(source, frame.W, frame.H);
|
|
40
|
+
const lines: string[] = [];
|
|
41
|
+
input.occluders.forEach((d, i) => {
|
|
42
|
+
const at = `config.assemble.occluders[${i}]`;
|
|
43
|
+
const path = resolve(dirname(resolve(input.configPath)), d.image);
|
|
44
|
+
const bytes = new Uint8Array(readFileSync(path));
|
|
45
|
+
const found = createHash('sha256').update(bytes).digest('hex');
|
|
46
|
+
if (found !== d.sha256) refuse('CONFIG_OCCLUDER_SHA256', `${at}.sha256`, `is ${d.sha256}; ${d.image} has sha256 ${found} — declare the bytes the occluder image holds`);
|
|
47
|
+
const image = decodePngBytes(bytes, path);
|
|
48
|
+
if (image.width !== source.width || image.height !== source.height) {
|
|
49
|
+
refuse('ASSEMBLE_OCCLUDER_GRID', `${at}.image`, `is ${image.width}x${image.height}; the painting's ${source.width}x${source.height} is required — the occluder is read on the painting's grid and never fitted`);
|
|
50
|
+
}
|
|
51
|
+
// A rig pixel reads the occluder at the source pixel its centre falls in.
|
|
52
|
+
const sx = (x: number): number => Math.min(source.width - 1, Math.floor((x + 0.5) * source.width / frame.W));
|
|
53
|
+
const sy = (y: number): number => Math.min(source.height - 1, Math.floor((y + 0.5) * source.height / frame.H));
|
|
54
|
+
const alpha = (x: number, y: number): number => image.data[(sy(y) * source.width + sx(x)) * 4 + 3];
|
|
55
|
+
const parts = d.under.flatMap((name) => {
|
|
56
|
+
const row = input.plan.find(([part]) => part === name);
|
|
57
|
+
if (row === undefined) return [];
|
|
58
|
+
const layer = (row[1] === 'full' ? full : runs.head).layers.find((l) => l.name === row[2]);
|
|
59
|
+
return layer === undefined ? [] : [{ name, image: layerToRig(placeLayer(layer, input.resolution), frame, row[1]) }];
|
|
60
|
+
});
|
|
61
|
+
for (const copy of occluderColourCopies(parts, painting, alpha, d.rgb_within)) lines.push(occluderColourWarning(i, copy, d.rgb_within));
|
|
62
|
+
});
|
|
63
|
+
return lines;
|
|
64
|
+
}
|
package/src/plate.ts
CHANGED
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
* `scene`, the figure being the `figure_rig.png` assemble wrote beside it
|
|
18
18
|
* (opaque white inside the figure, opaque black outside);
|
|
19
19
|
* - `matte:<dir>`: a model mask whose receipt binds both raw and final masks
|
|
20
|
-
* to the exact painting bytes and the recorded threshold/transform
|
|
20
|
+
* to the exact painting bytes and the recorded threshold/transform;
|
|
21
|
+
* - `--occluder <png>` (`--mode occluder`, issue #1230): a declared RGBA
|
|
22
|
+
* image of what stands in front of the character, on the painting's grid,
|
|
23
|
+
* the mask being its alpha above 0 (enclosed holes filled under `--holes`).
|
|
21
24
|
*
|
|
22
25
|
* The mask is taken on its own grid and never fitted: a source whose grid is
|
|
23
26
|
* not the painting's size is refused by name. With no source the command
|
|
@@ -39,7 +42,8 @@ import type { Graph } from './graphs.ts';
|
|
|
39
42
|
import { type LayerSet, OPAQUE_ALPHA_ABOVE, readWrapperLayers } from './layers.ts';
|
|
40
43
|
import { FIGURE_MASK_FILE, PAINTING_IN_RIG_FILE } from './parts.ts';
|
|
41
44
|
import { decodePngBytes, encodePngBytes } from './raster/png.ts';
|
|
42
|
-
import {
|
|
45
|
+
import { fillHoles } from './raster/morph.ts';
|
|
46
|
+
import { newMask, newRaster, type Raster } from './raster/types.ts';
|
|
43
47
|
|
|
44
48
|
export const PLATE_RECEIPT_SPEC = 'rig-parts-plate-receipt/1';
|
|
45
49
|
export const PLATE_RECEIPT_FILE = 'receipt.json';
|
|
@@ -50,12 +54,16 @@ export const PLATE_OUTPUT_FILE = 'plate.png';
|
|
|
50
54
|
export const PLATE_RECEIPT_KEYS = ['spec', 'mode', 'painting', 'mask', 'model', 'params', 'graph', 'gpu', 'output'] as const;
|
|
51
55
|
/** The receipt's top-level keys when `grid_transform` is present (off-grid `core`), in the order they are written. */
|
|
52
56
|
export const PLATE_RECEIPT_GRID_TRANSFORM_KEYS = ['spec', 'mode', 'painting', 'mask', 'model', 'params', 'graph', 'gpu', 'grid_transform', 'output'] as const;
|
|
57
|
+
/** `--mode occluder` (issue #1230): the keys above with the declared occluder image bound after the painting. */
|
|
58
|
+
export const PLATE_RECEIPT_OCCLUDER_KEYS = ['spec', 'mode', 'painting', 'occluder', 'mask', 'model', 'params', 'graph', 'gpu', 'output'] as const;
|
|
59
|
+
/** `--mode occluder` with `grid_transform` (off-grid `core`). */
|
|
60
|
+
export const PLATE_RECEIPT_OCCLUDER_GRID_TRANSFORM_KEYS = ['spec', 'mode', 'painting', 'occluder', 'mask', 'model', 'params', 'graph', 'gpu', 'grid_transform', 'output'] as const;
|
|
53
61
|
/** The `grid_transform` object's keys, in the order they are written. */
|
|
54
62
|
export const CORE_GRID_TRANSFORM_KEYS = ['source', 'padded', 'pad', 'pad_fill', 'mask_pad_fill', 'inverse'] as const;
|
|
55
63
|
|
|
56
|
-
export type PlateMode = 'background' | 'foreground';
|
|
64
|
+
export type PlateMode = 'background' | 'foreground' | 'occluder';
|
|
57
65
|
export type PlateGraph = 'lama' | 'core';
|
|
58
|
-
export type MaskSource = 'seethrough' | 'figure-mask' | 'matte';
|
|
66
|
+
export type MaskSource = 'seethrough' | 'figure-mask' | 'matte' | 'occluder';
|
|
59
67
|
|
|
60
68
|
export interface CoreGridTransform {
|
|
61
69
|
source: [number, number];
|
|
@@ -82,6 +90,8 @@ export interface PlateReceipt {
|
|
|
82
90
|
spec: typeof PLATE_RECEIPT_SPEC;
|
|
83
91
|
mode: PlateMode;
|
|
84
92
|
painting: { path: string; sha256: string };
|
|
93
|
+
/** `--mode occluder` only: the declared occluder image the mask is read from. */
|
|
94
|
+
occluder?: { path: string; sha256: string };
|
|
85
95
|
mask: { source: MaskSource; from: string; path: string; sha256: string };
|
|
86
96
|
model: { name: string; checkpoint_sha256: string; checkpoint_sha256_from: 'declared' } | null;
|
|
87
97
|
params: Record<string, string | number | boolean>;
|
|
@@ -315,6 +325,40 @@ export function readSourceMask(source: MaskSource, dir: string, width: number, h
|
|
|
315
325
|
return { width, height, inside };
|
|
316
326
|
}
|
|
317
327
|
|
|
328
|
+
/** `--occluder <png>`: its bytes as on disk (hashed into the receipt) and its pixels; a missing file is refused by name. */
|
|
329
|
+
export function readOccluder(path: string): { bytes: Uint8Array; raster: Raster } {
|
|
330
|
+
if (!existsSync(path) || !statSync(path).isFile()) fail('PLATE_OCCLUDER_PRESENT', path, 'no such file; an RGBA PNG of what stands in front of the character, on the painting\'s grid, is required');
|
|
331
|
+
const bytes = new Uint8Array(readFileSync(path));
|
|
332
|
+
return { bytes, raster: decodePngBytes(bytes, path) };
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** The occluder's alpha above this is inside the mask: every pixel the occluder touches, soft edge included. */
|
|
336
|
+
export const OCCLUDER_ALPHA_ABOVE = 0;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* The `--mode occluder` mask (issue #1230): the occluder's alpha above
|
|
340
|
+
* {@link OCCLUDER_ALPHA_ABOVE}, on the painting's own grid, never fitted; with
|
|
341
|
+
* `holes`, every pocket the occluder encloses (4-connected, as `fillHoles`
|
|
342
|
+
* reads it) is filled. Refused by name: an occluder whose size is not the
|
|
343
|
+
* painting's, one with no pixel above the floor, and one with no pixel at or
|
|
344
|
+
* below it (an image with no transparency would mask the whole painting).
|
|
345
|
+
*/
|
|
346
|
+
export function occluderMask(occluder: Raster, path: string, width: number, height: number, holes: boolean): FigureMask {
|
|
347
|
+
if (occluder.width !== width || occluder.height !== height) {
|
|
348
|
+
fail('PLATE_OCCLUDER_GRID', path, `is ${occluder.width}x${occluder.height}; the painting's ${width}x${height} is required — the occluder is read on the painting's own grid and never fitted`);
|
|
349
|
+
}
|
|
350
|
+
const support = newMask(width, height);
|
|
351
|
+
let clear = 0;
|
|
352
|
+
for (let p = 0; p < width * height; p++) {
|
|
353
|
+
if (occluder.data[p * 4 + 3] > OCCLUDER_ALPHA_ABOVE) support.data[p] = 1;
|
|
354
|
+
else clear++;
|
|
355
|
+
}
|
|
356
|
+
if (clear === width * height) fail('PLATE_MASK_EMPTY', path, `holds no pixel with alpha above ${OCCLUDER_ALPHA_ABOVE}; an occluder to remove is required`);
|
|
357
|
+
if (clear === 0) fail('PLATE_OCCLUDER_ALPHA', path, `holds no pixel with alpha ${OCCLUDER_ALPHA_ABOVE}; an RGBA image transparent outside the occluder is required — an opaque one would mask the whole painting`);
|
|
358
|
+
const inside = holes ? fillHoles(support).data : support.data;
|
|
359
|
+
return { width, height, inside: Uint8Array.from(inside) };
|
|
360
|
+
}
|
|
361
|
+
|
|
318
362
|
/** The mask grown by a square of side `2r+1` (two separable passes): a halo of the figure's outline is inpainted too. */
|
|
319
363
|
export function growMask(mask: FigureMask, r: number): FigureMask {
|
|
320
364
|
if (r === 0) return { ...mask, inside: mask.inside.slice() };
|
|
@@ -521,11 +565,16 @@ export function cropCoreGrid(padded: Raster, transform: CoreGridTransform): Rast
|
|
|
521
565
|
// the receipt
|
|
522
566
|
// ---------------------------------------------------------------------------
|
|
523
567
|
|
|
568
|
+
/** The receipt's key order: occluder mode binds the occluder, an off-grid `core` run its `grid_transform`. */
|
|
569
|
+
export function receiptKeys(occluder: boolean, gridTransform: boolean): readonly string[] {
|
|
570
|
+
if (occluder) return gridTransform ? PLATE_RECEIPT_OCCLUDER_GRID_TRANSFORM_KEYS : PLATE_RECEIPT_OCCLUDER_KEYS;
|
|
571
|
+
return gridTransform ? PLATE_RECEIPT_GRID_TRANSFORM_KEYS : PLATE_RECEIPT_KEYS;
|
|
572
|
+
}
|
|
573
|
+
|
|
524
574
|
/** The receipt's JSON text, its keys in `PLATE_RECEIPT_KEYS` (or `PLATE_RECEIPT_GRID_TRANSFORM_KEYS` when `grid_transform` is present) order. */
|
|
525
575
|
export function receiptText(r: PlateReceipt): string {
|
|
526
576
|
const ordered: Record<string, unknown> = {};
|
|
527
|
-
const
|
|
528
|
-
for (const k of keys) ordered[k] = r[k];
|
|
577
|
+
for (const k of receiptKeys(r.mode === 'occluder', r.grid_transform !== undefined)) ordered[k] = (r as unknown as Record<string, unknown>)[k];
|
|
529
578
|
return `${JSON.stringify(ordered, null, 2)}\n`;
|
|
530
579
|
}
|
|
531
580
|
|
|
@@ -554,11 +603,11 @@ export function verifyPlateReceipt(receiptFile: string): Problem[] {
|
|
|
554
603
|
}
|
|
555
604
|
if (r.spec !== PLATE_RECEIPT_SPEC) problems.push({ code: 'PLATE_RECEIPT_SPEC', object: receiptFile, detail: `has spec ${JSON.stringify(r.spec)}; "${PLATE_RECEIPT_SPEC}" is required` });
|
|
556
605
|
const keys = Object.keys(r).join(',');
|
|
557
|
-
const expectedKeys = 'grid_transform' in r
|
|
606
|
+
const expectedKeys = receiptKeys(r.mode === 'occluder', 'grid_transform' in r);
|
|
558
607
|
if (keys !== expectedKeys.join(',')) problems.push({ code: 'PLATE_RECEIPT_KEYS', object: receiptFile, detail: `has keys ${keys}; ${expectedKeys.join(',')} in that order is required` });
|
|
559
608
|
const base = dirname(receiptFile);
|
|
560
609
|
let paintingRaster: Raster | undefined;
|
|
561
|
-
for (const field of ['painting', 'mask', 'output'] as const) {
|
|
610
|
+
for (const field of r.mode === 'occluder' ? ['painting', 'occluder', 'mask', 'output'] as const : ['painting', 'mask', 'output'] as const) {
|
|
562
611
|
const f = r[field] as { path?: unknown; sha256?: unknown } | undefined;
|
|
563
612
|
if (typeof f?.path !== 'string' || typeof f.sha256 !== 'string') {
|
|
564
613
|
problems.push({ code: 'PLATE_RECEIPT_KEYS', object: `${receiptFile} ${field}`, detail: 'lacks a path and a sha256' });
|
|
@@ -577,7 +626,8 @@ export function verifyPlateReceipt(receiptFile: string): Problem[] {
|
|
|
577
626
|
}
|
|
578
627
|
}
|
|
579
628
|
if (paintingRaster !== undefined) {
|
|
580
|
-
const
|
|
629
|
+
const inpainted = r.mode === 'background' || r.mode === 'occluder';
|
|
630
|
+
const expectedTransform = inpainted && r.graph === PLATE_GRAPH_IDS.core ? coreGridTransform(paintingRaster.width, paintingRaster.height) : undefined;
|
|
581
631
|
if (expectedTransform !== undefined) {
|
|
582
632
|
if (!('grid_transform' in r) || r.grid_transform === undefined) {
|
|
583
633
|
problems.push({
|
|
@@ -596,7 +646,7 @@ export function verifyPlateReceipt(receiptFile: string): Problem[] {
|
|
|
596
646
|
problems.push({
|
|
597
647
|
code: 'PLATE_RECEIPT_GRID_TRANSFORM',
|
|
598
648
|
object: `${receiptFile} grid_transform`,
|
|
599
|
-
detail: `is ${JSON.stringify(r.grid_transform)}; no grid_transform is permitted for ${
|
|
649
|
+
detail: `is ${JSON.stringify(r.grid_transform)}; no grid_transform is permitted for ${inpainted && r.graph === PLATE_GRAPH_IDS.core ? `on-grid painting ${paintingRaster.width}x${paintingRaster.height}` : `mode ${JSON.stringify(r.mode)} graph ${JSON.stringify(r.graph)}`}`,
|
|
600
650
|
});
|
|
601
651
|
}
|
|
602
652
|
} else if ('grid_transform' in r && (typeof r.grid_transform !== 'object' || r.grid_transform === null || Array.isArray(r.grid_transform) || Object.keys(r.grid_transform as object).join(',') !== CORE_GRID_TRANSFORM_KEYS.join(','))) {
|
|
@@ -643,6 +693,8 @@ export interface PlateWrite {
|
|
|
643
693
|
graph: string;
|
|
644
694
|
gpu: string | null;
|
|
645
695
|
gridTransform?: CoreGridTransform;
|
|
696
|
+
/** `--mode occluder` only: the occluder file, bound into the receipt by path and sha256. */
|
|
697
|
+
occluder?: { path: string; bytes: Uint8Array };
|
|
646
698
|
}
|
|
647
699
|
|
|
648
700
|
let foregroundStageSeq = 0;
|
|
@@ -666,6 +718,7 @@ export function publishPlate(w: PlateWrite): PlateReceipt {
|
|
|
666
718
|
spec: PLATE_RECEIPT_SPEC,
|
|
667
719
|
mode: w.mode,
|
|
668
720
|
painting: { path: receiptPath(w.out, w.paintingPath), sha256: sha256(w.paintingBytes) },
|
|
721
|
+
...(w.occluder === undefined ? {} : { occluder: { path: receiptPath(w.out, w.occluder.path), sha256: sha256(w.occluder.bytes) } }),
|
|
669
722
|
mask: { source: w.source, from: receiptPath(w.out, w.sourceDir), path: PLATE_MASK_FILE, sha256: mask.sha256 },
|
|
670
723
|
model: w.model,
|
|
671
724
|
params: w.params,
|