Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
docs(loop-repair): the cross-fade inside a silhouette is a reading to look at — what it reads, where its line sits, why it is no fault
Soohong Kim2e0aa7142b59
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 357e16a..3861d13 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,7 +5,9 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the## Unreleased (v2.43.0)- **Fix: no loop path delivers a ghost frame unmeasured — `video-cycle-align` takes a clean source frame beside it.** A video model filming a walk held on twos or threes sometimes leaves a frame half drawn between two drawings: a band of part coverage where a leg was and is going. The alignment took such a frame as filmed at its own time, never measured, and a frame RIFE made beside it carried the band and passed — `--between auto` judged a made frame only against its two neighbours (`dark_excess`, `outline_loss`), and a neighbour that is itself the ghost leaves nothing in excess. Now every frame delivered is read on its own coverage (`rife.ghost`: part-covered pixels, alpha 0.1–0.9, in regions at least 5 px thick, over the frame's solid pixels; a ghost over 0.3 %, `interpolation_quality.GHOST_WARN`). The source loop is screened first (`ghost_screen` per loop row and in `cycle_align`: `limit`, `thick_px`, the loop's own `level`, `reads`, and each filmed `ghosts` frame of `cycle.source/`); a loop whose median frame is over the limit is drawn part-covered (a glow, a translucent cape) and is not judged. Under `auto` and `nearest` a time on a filmed ghost takes the frame after it (or before it), a made frame that is a ghost gives way to the nearer source frame (fault `ghost`), and where that nearer frame is the ghost the other frame beside the time is taken; `rife` keeps both, named. Each such cell is listed in `ghost_at` (`at`, `source`, `ghost`, `taken`) with a warning line; a ghost with no clean frame beside it is kept and the line says to film the direction again. A loop already the set's length is screened the same way. Made frames in `smear` carry their `ghost` reading.-- **The same screen in the other loop paths.** `video-loop` records the screen of the cut it delivers for a walk or run (`ghost_screen` in its report and summary, a `warning:` line per ghost naming `cycle/frame-NNN.png`): a loop delivered as cut, never aligned, shows its ghost. The jump repair rejects a proposal that is a ghost, its rounds' `original` and `proposal` carrying `ghost`. `video-loop-compare` and `video-loop-repair` keep their versioned `rife.smear` measures and do not read it. Not seen by the screen: a made frame that blends two drawings inside one silhouette with its outline whole — no part coverage to read.+- **The same screen in the other loop paths.** `video-loop` records the screen of the cut it delivers for a walk or run (`ghost_screen` in its report and summary, a `warning:` line per ghost naming `cycle/frame-NNN.png`): a loop delivered as cut, never aligned, shows its ghost. The jump repair rejects a proposal that is a ghost, its rounds' `original` and `proposal` carrying `ghost`. `video-loop-compare` and `video-loop-repair` keep their versioned `rife.smear` measures and do not read it. Not seen by the screen: a made frame that blends two drawings inside one silhouette with its outline whole — no part coverage to read; the cross-fade reading below names it. A loop the screen does not read (`reads: false`, drawn part-covered) is now said on stderr too: `video-loop` prints a `warning:` line for its cut (and carries `ghost_screen` in its summary), and `video-cycle-align` a line in `warnings` per such loop — before, only the report said so.+- **Named, not judged: a made frame that cross-fades two drawings inside its silhouette.** Where the legs trade places across a gap wider than the flow follows, RIFE can move the coverage and cross-fade the colour — both drawings' boots at part strength inside one whole outline. That frame has no band of part coverage, nothing darker inside the body, and loses its outline only where the art outlines in near-black: the outline rule counts pixels under 70/255 as outline, so the same cross-fade outlined in grey or brown passed every fault — caught or passed by the palette's accident. `rife.crossfade(made, a, b, t)` reads it relative to the source frames' own edges: in windows 8 % of the body's height where the two source frames differ, pixels at their plain blend at the made frame's fraction (in patches 5 px thick) together with the made frame keeping under 60 % of the sources' strong edges there (local range over 7 px, wider than RIFE's blur) — the strong-edge pixels lost there, over the frame's solid pixels. Over 0.015 (`interpolation_quality.CROSSFADE_LOOK`, `looks`) a made frame is named to look at: `cycle_align.smear` rows carry `crossfade` and `look`, and a kept frame gets a `warnings` line ("may cross-fade two drawings inside its outline … kept"). It is no fault — `auto` keeps the frame and the retake rule does not count it — because checked against frames labelled by eye it does not part them: on synthetic legs over 32 palettes (outline black, brown, grey or none; boots dark, mid, light or none) the colour-blended, coverage-whole frame reads over the line in 209 of 384 (74 of 96 outlined in grey, where the fault rules catch 2; 11 of 96 drawn without outlines) and a clean drawing between two far-apart drawings in 29 of 384. The jump repair takes such a proposal and names it (its round's `look`, the proposal's `crossfade`, a `video-loop` `warning:` line). `video-loop-compare` and `video-loop-repair` keep their versioned measures.+- **`tests/video/test_crossfade.py`** draws the outlined legs with boots three times the size, the outline grey or black: a frame whose colour run cross-faded inside the drawing's own coverage reads over the line in both, the outline rule catching only the black; the drawing between reads under it, and a clean drawing between legs 13 degrees apart in grey over it (why it is no fault); the alignment keeps a cross-faded frame and names it, where the black one still gives way to its outline fault; an alignment through a stand-in whose colour run blends names each kept frame in a warning line; the jump repair takes a cross-faded proposal and names it; through the real RIFE, where installed, a short step reads no cross-fade; and a loop drawn part-covered is named on stderr by `video-loop` and in the alignment's warnings. `tests/video/test_rife.py` pins the real RIFE's whole verdict on the melted crossing (`outline` and `ghost` one way, `outline` the other, no cross-fade either way), where it pinned only the first fault.- **`tests/video/test_ghost_screen.py`** draws outlined legs with a band of 0.3 coverage between the feet: the measure reads the band and not a softened edge; the alignment takes the clean frame beside a ghost at a whole time and beside a made frame that carries one, keeps it named under `rife` or with no clean frame beside it, screens a loop already that long and leaves a loop drawn part-covered as before; `video-loop` names the ghost in its cut; the jump repair rejects a ghost proposal; and through the real RIFE, where installed, no resampled cell carries the filmed ghost.## v2.42.0 - A set's directions on one sheet, standing on one ground line; a loop whose strip as cut is missing is refused by namediff --git a/SKILL.md b/SKILL.mdindex d39fe7d..c83b9ba 100644--- a/SKILL.md+++ b/SKILL.md@@ -142,4 +142,4 @@ Scene creation consumes finished assets and remains optional. Asset metadata own## Contracts and advanced tools-[run-contract](docs/run-contract.md) owns numeric requests, run layout, atomic publication and curated exports. [architecture](docs/architecture.md) explains domain ownership. [docs index](docs/README.md) lists every specialized feature and QA procedure. `sprite-gen --help` derives the command map from the package catalog. Never replace an engine stage — extraction, the loop cut, set alignment, loop repair — with a script of your own while presenting the result as a pipeline output. Where a stage's result is wrong, use the engine's own options first (another cut with `video-loop --max-len` or `--cycle fixed`, `video-cycle-align --length`, `--between auto` (the default: a made frame that melted or carries a ghost takes the nearer source frame, and a filmed ghost frame a clean one beside it) or `--between nearest`, or `--cycles <loop>=<k>` once you have counted a suspect loop's strides, or `--foot <loop>=left|right` (`video-set --align-foot <item>=…`) once you have looked at the first strike frame of a loop the report lists under `unnamed_feet`), keep the engine's result as the comparison, report the defect against the engine, and name in the delivery each stage done by hand and why. A new clip is for what no stage can reach: the drawing, the motion itself, a clip that holds no whole cycle ([loop-review](docs/loop-review.md)) — and a clip the engine names for one: when the alignment report's `retake` lists a loop (reason `held-drawings`: the cycle cut from its clip shows each drawing for two or three frames, the set's length leaves it at under 13 drawings a second, and frames between its drawings could not be made, so the loop halts there), run the engine verbs first as above, then film that direction again and align the set anew rather than hand-painting the gap; tell the user what the reason was and that a new take usually fixes it ([loop-repair](docs/loop-repair.md) section 4). `video-loop --anchor motion-auto` already cuts a walk two steps long — one cycle — where a staff held above the head closes only there (`cycle.steps`, `strip.json` `steps: 2`; `video-cycle-align` aligns it as the one cycle it is). When its report's `cycle.step_screen` says `suspect` (a slow walk cut one step long), or `video-cycle-align` stops on a loop under `one_step`, count the steps in the loop (how often each foot lands) and cut it again with `video-loop --steps 1` if it is one step (`--steps 2` if it is two); never stretch or double it by hand. When `video-loop` warns that the top of the silhouette jumps into the loop's first frame (a staff or flag held above the head, swinging on its own beat), or that the held part does not close at the wrap below its top, that part does not close at the cut: look at the loop, and try `--cycle fixed` with another cut before filming again; a walk refused for no cycle names in its report's `cycle.candidates` the windows it measured, best first, for a cut you must deliver anyway ([loop-repair](docs/loop-repair.md) section 3, "The seam pop" and "The held side").+[run-contract](docs/run-contract.md) owns numeric requests, run layout, atomic publication and curated exports. [architecture](docs/architecture.md) explains domain ownership. [docs index](docs/README.md) lists every specialized feature and QA procedure. `sprite-gen --help` derives the command map from the package catalog. Never replace an engine stage — extraction, the loop cut, set alignment, loop repair — with a script of your own while presenting the result as a pipeline output. Where a stage's result is wrong, use the engine's own options first (another cut with `video-loop --max-len` or `--cycle fixed`, `video-cycle-align --length`, `--between auto` (the default: a made frame that melted or carries a ghost takes the nearer source frame, and a filmed ghost frame a clean one beside it; a made frame the report names as a possible cross-fade of two drawings, `look`, is kept — look at it, and where the legs show twice use `--between nearest` or film that direction again) or `--between nearest`, or `--cycles <loop>=<k>` once you have counted a suspect loop's strides, or `--foot <loop>=left|right` (`video-set --align-foot <item>=…`) once you have looked at the first strike frame of a loop the report lists under `unnamed_feet`), keep the engine's result as the comparison, report the defect against the engine, and name in the delivery each stage done by hand and why. A new clip is for what no stage can reach: the drawing, the motion itself, a clip that holds no whole cycle ([loop-review](docs/loop-review.md)) — and a clip the engine names for one: when the alignment report's `retake` lists a loop (reason `held-drawings`: the cycle cut from its clip shows each drawing for two or three frames, the set's length leaves it at under 13 drawings a second, and frames between its drawings could not be made, so the loop halts there), run the engine verbs first as above, then film that direction again and align the set anew rather than hand-painting the gap; tell the user what the reason was and that a new take usually fixes it ([loop-repair](docs/loop-repair.md) section 4). `video-loop --anchor motion-auto` already cuts a walk two steps long — one cycle — where a staff held above the head closes only there (`cycle.steps`, `strip.json` `steps: 2`; `video-cycle-align` aligns it as the one cycle it is). When its report's `cycle.step_screen` says `suspect` (a slow walk cut one step long), or `video-cycle-align` stops on a loop under `one_step`, count the steps in the loop (how often each foot lands) and cut it again with `video-loop --steps 1` if it is one step (`--steps 2` if it is two); never stretch or double it by hand. When `video-loop` warns that the top of the silhouette jumps into the loop's first frame (a staff or flag held above the head, swinging on its own beat), or that the held part does not close at the wrap below its top, that part does not close at the cut: look at the loop, and try `--cycle fixed` with another cut before filming again; a walk refused for no cycle names in its report's `cycle.candidates` the windows it measured, best first, for a cut you must deliver anyway ([loop-repair](docs/loop-repair.md) section 3, "The seam pop" and "The held side").diff --git a/docs/loop-repair.md b/docs/loop-repair.mdindex 7f77770..4a65fae 100644--- a/docs/loop-repair.md+++ b/docs/loop-repair.md@@ -181,12 +181,14 @@ adjacency rule and call budget still apply. The shared `interpolation_quality` pis the same one used by cycle alignment: `dark_excess > 0.001` or`outline_loss > 0.05` rejects a proposal, and so does a proposal that is a ghost on its owncoverage (`ghost` over 0.003, read where the loop's ghost screen reads it, section 4). An empty-proposal is also rejected.+proposal is also rejected. A proposal that cross-fades two drawings inside its silhouette+(`crossfade` over 0.015, section 4) is taken all the same and named: its round's `look` says so, and+a `warning:` line names the frame.The original middle frame is retained, not a duplicate of either neighbour.The report's `jump_repair` carries `replaced` (cycle frame indices), `attempts`,`blocked` targets, and each round's step, target, score, whole/hair parts,-`original` and `proposal` measurements (with each one's `ghost`), `faults`, and `outcome` (`accepted` or+`original` and `proposal` measurements (with each one's `ghost`, and the proposal's `crossfade`), `faults`, `look`, and `outcome` (`accepted` or`rejected`). It also records `score_max_before` / `score_max_after`, why it stopped,and which interpolator made the proposals. Rejection is not overall quality failureor success: original drawing changes and normal gait motion can remain.@@ -561,7 +563,8 @@ sprite-gen video-cycle-align --loop-dir set/front-walk/loop --loop-dir set/side-and needs it installed the same way.- **Smear and melt, per made frame**: `cycle_align.smear` lists every frame RIFE made, with its`method` — `rife` (kept) or `nearest` (a source frame beside it taken instead) — its `faults`,- its own ghost reading (`ghost`, below; `null` where the screen does not read the loop), and what+ its own ghost reading (`ghost`, below; `null` where the screen does not read the loop), its+ cross-fade reading and what to `look` at (`crossfade`, below — named, never judged), and whatit has that neither source frame beside it has (`rife.smear`):- `dark_excess`: dark pixels (luma under 70/255) inside the body beyond the darker neighbour'scount, as a fraction of its solid pixels — a black smear raises it, a dark part that only@@ -606,7 +609,9 @@ sprite-gen video-cycle-align --loop-dir set/front-walk/loop --loop-dir set/side-`cycle_align` — `limit`, `thick_px`, the loop's own `level` (its median frame's reading), `reads`,and `ghosts` (each `frame` of `cycle.source/` over the limit, with its reading). A loop whoselevel is itself over the limit is drawn part-covered — a glow, a translucent cape — and is not- judged (`reads: false`, with `why`): every made frame's `ghost` is `null`, nothing gives way.+ judged (`reads: false`, with `why`): every made frame's `ghost` is `null`, nothing gives way, and+ a line in `warnings` (on stderr, and in `video-loop`'s own output for the cut) says the screen+ does not read it, so whoever delivers it looks at `cycle/` instead.- A time on a filmed ghost takes the source frame after it, or the one before it where that oneis a ghost too, under `auto` and `nearest`; a made frame that is a ghost gives way like anyfaulty one, to the nearer source frame, or to the other beside its time where the nearer is a@@ -625,13 +630,42 @@ sprite-gen video-cycle-align --loop-dir set/front-walk/loop --loop-dir set/side-feet 2 %. It is a reference, not a measured optimum, and a frame near it is worth a look either way.- What it does not see: a frame RIFE made that blends two drawings inside one silhouette — thenear and far boots cross-faded while the outline stays whole — has no part coverage to read- and is not a ghost here.+ and is not a ghost here; the cross-fade reading below names it.- `video-loop` records the same screen of the cut it delivers, for a walk or run(`ghost_screen` in its report, and a `warning:` line per ghost naming `cycle/frame-NNN.png`):a loop delivered as cut — one direction, never aligned — shows its ghost, and the alignmentscreens `cycle.source/` again and takes a clean frame beside it. The jump repair (section 2)rejects a proposal that is a ghost. `video-loop-compare` and `video-loop-repair` keep their ownversioned measures (`rife.smear`, [loop comparison](loop-comparison.md)) and do not read it.+- **A cross-fade inside the silhouette — named, not judged** (`rife.crossfade`,+ `interpolation_quality.looks`): where two drawings differ more than the flow can follow — the legs+ trading places across a gap two or three frames wide — RIFE can move the coverage and cross-fade+ the colour: both drawings' boots at part strength inside one whole outline. No band of part+ coverage, nothing darker inside the body, and an outline the outline rule reads only where the art+ outlines in near-black (it counts pixels under 70/255 as outline): drawn in grey or brown, the same+ frame passes every fault.+ - `crossfade`: in windows 8 % of the body's height over the frame where the two source frames+ differ, two things in one window — pixels of the made frame's solid body at the plain blend of+ the two at its own fraction and well away from each (in patches 5 px thick, past an edge's soft+ rim), and the made frame keeping under 60 % of the source frames' strong edges there (local range+ over 7 px, wider than RIFE's blur, above half the sources' 95th percentile there): a blend shows+ each edge at part height, a flow that moved the part shows it whole, only softer. The strong-edge+ pixels lost in such windows, over the frame's solid pixels; 0 where it shows no blend. Relative+ to the source frames' own edges, so the palette's lightness does not decide it.+ - Over **0.015** (`interpolation_quality.CROSSFADE_LOOK`) the frame is named to look at: its+ `smear` row's `look` is `["crossfade"]`, and a kept frame (`method: rife`) gets a line in+ `warnings` ("frame 14 (made by RIFE) may cross-fade two drawings inside its outline …; kept").+ It is no fault: `auto` keeps it, it gives nothing way, and the retake rule does not count it.+ - Why a reading and not a fault: checked against frames labelled by eye, it does not part them.+ On drawn walks the frame seen cross-faded read well over the line and the frames seen clean+ under it; on synthetic legs (the walker of `tests/video/test_crossfade.py`, its palette varied+ 32 ways — the outline black, brown, grey or none, the boots dark, mid, light or none, two leg+ fills — four steps, three fractions, 1,536 frames) the colour-blended, coverage-whole frame reads over it in+ 209 of 384 — 74 of 96 outlined in grey, where the fault rules catch 2, but 11 of 96 drawn+ without outlines — and the clean drawing between, drawn, reads over it in 29 of 384, every one+ a step of 13 degrees or more between far-apart drawings, most outlined in grey. A fault would+ give way for clean frames and still pass blends; a line to look at costs neither. 0.015 is set+ by eye between the cross-faded frames and the clean ones, a reference, not a measured optimum.- **What `auto` costs**: a frame replaced shows the nearer source frame, so the motion theresteps as filmed, up to half a frame off its time, and the loop shows fewer distinct drawings asecond than `rife` — but no melted one. A clip drawn on twos has a long step between drawingsdiff --git a/docs/video-pipeline.md b/docs/video-pipeline.mdindex ab504d2..dfe7010 100644--- a/docs/video-pipeline.md+++ b/docs/video-pipeline.md@@ -382,7 +382,9 @@ is needed and RIFE is not installed; `--between nearest` makes none. A frame RIF(lost its outline where legs crossed too far) or carries a ghost (a band of part coverage) isreplaced by the nearer source frame and named, and a filmed frame left half drawn between twodrawings gives way to a clean source frame beside it (`--between auto`, the default; [loop-repair](loop-repair.md) section 4, "The ghost screen"). A loop whose view cannot+repair](loop-repair.md) section 4, "The ghost screen"); a made frame that may cross-fade two+drawings inside its outline is kept and named to look at (section 4, "A cross-fade inside the+silhouette"). A loop whose view cannottell its feet apart — or tells them apart by too small a margin (`foot_why` `low-margin`) — startson its larger strike and is listed under the report's `unnamed_feet` with its two strike frames in`cycle/`: look at the first, say which own foot lands there, and run the same alignment again with