Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

docs: foot strike off the legs, start foot per view, RIFE bleed and smear, --between nearest; changelog

Soohong Kim2d4c0b3e2930
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e9d600..5c42f4f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,15 @@
All notable public changes to `sprite-gen` are recorded here. Versions track the `version:` field in `SKILL.md` and `pyproject.toml`.
+## Unreleased - Every view of an aligned walk starts as the same foot lands, read off the legs, and RIFE leaves no black between crossing legs
+
+- **Output change: every frame RIFE makes, and where every aligned loop starts.** Frames made by RIFE (`video-cycle-align`, `video-set --align-cycles auto`, `video-loop` jump repair) are drawn differently wherever the legs cross or the flow is unsure; frames taken as filmed are untouched. Every loop `video-cycle-align` turns may start on a different frame: on its legs instead of its top edge, and, with views, on one foot for the whole set. A loop already aligned starts where the new rule says the next time it is aligned (it is read from `cycle.source/`).
+- **Fix: a black smear between crossing legs in a frame RIFE made.** RIFE runs its flow twice, once for the colour and once for the coverage, and where two legs pass each other the runs disagree: the coverage says body where the colour still carries what lay around the body. 2.24 premultiplied the colour over black, so the disagreement came out black. The colour image now carries the body's own colour around the body (`rife.bleed`: the colour from 0.8 % of the body's height inside its solid edge, past a drawn outline, pushed out over the transparent area), so a disagreement reads as the body's fill; inside the body the colour is the frame's own, outline included. On two outlined legs walking through each other the made frame at t = 0.5 had 6 % of its body dark beyond either neighbour; now none (`tests/video/test_rife.py`). A limb RIFE cannot follow is still soft and pale, never black. [docs/loop-repair.md](docs/loop-repair.md#1-rife--what-runs-where-and-what-it-costs).
+- **A smear is measured on every made frame, never passed over quietly.** `cycle_align.smear` lists per made frame `dark_excess` (dark pixels inside the body beyond the darker neighbour's count — a moved hat or watch keeps its count) and `partial_excess` (part-covered pixels beyond the more ragged neighbour's); over 0.1 % dark, the frame is named in the alignment report's `warnings`, on stderr and in `video-set`'s `warnings` (`rife.smear`, `align.SMEAR_WARN`).
+- **New `video-cycle-align --between nearest`** (`video-set --align-between nearest`): a time between two source frames takes the nearer source frame, so nothing is made and no RIFE is needed; the motion keeps the filmed frames up to half a frame off their time. `rife` stays the default. A loop stretched this way shows a frame twice; its GIF and WebP are checked for one frame per run of identical cells, since both hold a repeated frame as one of twice the delay.
+- **Fix: the loop started where an ear tip was lowest.** The turn took the frame whose alpha box top was lowest, and a long ear, a hat's point or an antenna owns that edge and flops on its own rhythm, so each view started at another point of its step. The start is now read off the legs (`align.foot_strike`, `turned_on` in the loop row): the widest stride where the foot band (the lowest 8 %) swings by 15 % of the body's height or more (side and diagonal views, a heel landing in front); otherwise the lowest solid row, where it swings by 1.5 % or more (front and back views, the foot nearer the viewer drawn lowest); and only for a body with no legs to read, the body's top line, the first row at least half as wide as the frame's widest, so a narrow ear is passed over. A body that hardly bobs turns on its legs as one that bobs does (`tests/video/test_cycle_align.py`: a drawn walker whose ears are lowest half a step off its heel strike, with and without a bob).
+- **New: every view starts as the same own foot lands** (`video-cycle-align --view front --view side@right …`, one per `--loop-dir`, `--start-foot right|left`, default right; `video-set` passes each item's view and facing). A walk lands twice a cycle, half a cycle apart, and until now the turn took either. The foot is told by how the view draws it (`align.strike_foot`, with `handedness.placement` for which own side is where): front and back by which foot is drawn lower (nearer the viewer), side and diagonal by which leg is shaded (the far one). Where the cue does not follow the step (its once-a-cycle swing under a quarter of its spread) or the two strikes do not differ enough, the foot is not named rather than guessed: the loop starts on its larger strike with `start_foot: null` and `foot_why`, and the report's `warnings` say so; without `--view` the report says once that no foot was chosen. Each loop row carries `view`, `start_foot` and `foot` (the cue, its values and margin). [docs/loop-repair.md](docs/loop-repair.md#4-one-cycle-for-a-direction-set--video-cycle-align-video-set---align-cycles-auto).
+
## v2.24.0 - A walk filmed from its first frame loops at one size, a frame scaled up keeps its crown, and a soft part can follow the body
- **Output change: a walk or run loop whose clip changes size by 1 % or more is cut differently.** `video-loop --anchor motion-auto` now holds the clip at its first frame's size before the cycle search (`--size-hold auto`, the default; `size_hold` in the report): the subject's fitted height over the clip is measured (`gait_fallback.scale_drift`) and, at 1 % or more (`SIZE_HOLD_MIN`), every frame is scaled back to the first frame's height about its fitted foot point (`undo_scale`). Until now that ran only in the gait fallback, after the search had failed and at 3 % or more, so a clip that grew 1–3 % and still looped was cut on frames of changing size: the frame one cycle on was larger than the first, and the loop popped at the wrap. A clip under 1 % is cut exactly as before; `--size-hold off` gives the old cut. A clip that grows 2.5 % now loops at its size where it found no cycle before (`tests/video/test_gait_fallback.py`); a front catwalk filmed from its first frame (+2.0 %) went from a seam ratio of 1.44 to 1.19. [docs/video-pipeline.md](docs/video-pipeline.md#4-loop--period-first-seam-second-then-the-gait-floor).
diff --git a/docs/loop-repair.md b/docs/loop-repair.md
index 15beb50..059a06a 100644
--- a/docs/loop-repair.md
+++ b/docs/loop-repair.md
@@ -75,9 +75,20 @@ whose repair could not run (section 3) reads the loop as filmed, and its failure
repair did not run.
RIFE reads three colour channels and no alpha. A frame is therefore interpolated as two
-images — its colour premultiplied over black, and its coverage as a grey image — and put back
-together unpremultiplied (`sprite_gen/video/rife.py`). Coverage below 2/255 is dropped, so no
-faint halo is invented around the body.
+images — its colour, and its coverage as a grey image — and put back together
+(`sprite_gen/video/rife.py`). Coverage below 2/255 is dropped, so no faint halo is invented
+around the body.
+
+The two images are two runs of the flow, and where the picture is hard to follow — two legs
+passing each other — they do not agree: the coverage says body where the colour run still
+carries what lay around the body. Until 2.24 the colour was premultiplied over black, so that
+disagreement came out as a black smear between the legs. The colour image now holds the
+body's own colour around the body (`rife.bleed`): the colour from 0.8 % of the body's height
+inside its solid edge — past a drawn outline — pushed out over the transparent area, coarse to
+fine. A disagreement then reads as the body's fill. Where the frame has coverage its colour is
+its own, outline included, and it is taken from the colour run as it comes out (no division by
+the coverage). A limb RIFE cannot follow at all still comes out pale and soft, never black;
+`rife.smear` measures both (section 4).
### Where — measured 2026-10-03
@@ -246,7 +257,8 @@ same number of frames, starting on the same step.
```bash
sprite-gen video-cycle-align --loop-dir set/front-walk/loop --loop-dir set/side-walk/loop \
- --loop-dir set/back-walk/loop [--length N] [--report set/walk.cycle-align.json]
+ --loop-dir set/back-walk/loop [--view front --view side@right --view back] [--start-foot right] \
+ [--between rife|nearest] [--length N] [--report set/walk.cycle-align.json]
```
- **Length**: the median of the set's own lengths (`--length` overrides). The median is the
@@ -256,14 +268,63 @@ sprite-gen video-cycle-align --loop-dir set/front-walk/loop --loop-dir set/side-
k·L/L*, cyclic. A time within 0.03 of a source frame takes that frame as filmed; only a time
between two frames is made, by RIFE at that fraction (section 1). An offset of half a frame,
which would remake every frame, is not offered (section 2).
-- **Foot strike**: each loop is then turned to start where the body is lowest (its solid top
- line lowest, smoothed 1-2-1) — both feet down just after a heel lands. A walk has two such
- moments; the first is taken.
+- **Between two source frames** (`--between`): `rife` (default) makes the frame; `nearest` takes
+ the nearer source frame, so nothing is made and no RIFE is needed, and the motion keeps the
+ filmed frames at up to half a frame off their time (a loop stretched longer shows a frame
+ twice, which the GIF and WebP hold as one frame of twice the delay). `video-set` passes
+ `--align-between`.
+- **Smear, per made frame**: `cycle_align.smear` lists, for every frame RIFE made, what it has
+ that neither source frame beside it has, as fractions of its solid pixels: `dark_excess`, dark
+ pixels (luma under 70/255) inside the body beyond the darker neighbour's count — a black smear
+ raises it, a dark part that only moved (a hat, a watch) does not — and `partial_excess`,
+ part-covered pixels beyond the more ragged neighbour's (a pale, soft limb). A frame whose
+ `dark_excess` is over 0.1 % is named in the report's `warnings` (and on stderr, and in
+ `video-set`'s `warnings`); look at it in `cycle/`, or align with `--between nearest`.
+- **Foot strike**: each loop is then turned to start as a heel lands (`align.foot_strike`), read
+ off one signal smoothed 1-2-1 — never off the frame's top edge, which a long ear, a hat's
+ point or an antenna owns and which flops on its own rhythm:
+ - `stride`, where the width of the foot band (the lowest 8 % of the frame) swings by 15 % of
+ the body's height or more — a side or diagonal walk. The feet are widest apart as the front
+ heel lands.
+ - `reach`, where instead the lowest solid row swings by 1.5 % or more — a front or back walk,
+ whose feet pass one behind the other: the foot nearer the viewer is drawn lowest, and lowest
+ when the feet are furthest apart.
+ - `body_low`, where neither moves — a body with no legs to read: its top line lowest, the top
+ line being the first row whose longest solid run is at least half the frame's widest, so a
+ narrow ear or antenna is passed over.
+
+ A body that hardly bobs still turns on its legs; the body's bob is read only where there are
+ no legs. The loop row says which (`turned_on`) and the two swings (`stride_swing`,
+ `reach_swing`).
+- **The same foot in every view** (`--view`, one per `--loop-dir` in order: `front`, `back`, or
+ `side|front_diagonal|back_diagonal@right|left` for the way it faces; `video-set` passes each
+ item's own): a walk lands twice a cycle, half a cycle apart. Each loop starts as the same own
+ foot lands (`--start-foot`, default right), told apart by how the view draws the feet
+ (`align.strike_foot`; which own side is where is `handedness.placement`):
+ - front or back (`depth`): the feet are side by side in the picture, the one nearer the viewer
+ drawn lower. From the front the landing foot is the one stepping toward the viewer, the
+ lower; from the back it is the one stepping away, the higher.
+ - side or diagonal (`shade`): the feet are one in front of the other, so the picture cannot
+ place them, but the far leg is drawn in shade. At the strike where the front foot is the
+ lighter against the back one, the near leg is in front.
+
+ The cue must follow the step — its once-a-cycle swing (first harmonic) at least a quarter of
+ its spread over the cycle, or it is the drawing's own flicker — and, averaged over each strike
+ frame and its two neighbours, the two strikes must differ by 0.015 in luma (shade) or 1 % of
+ the body's height (depth); otherwise the foot is not named. A view seen from behind a diagonal
+ can shade its legs too evenly for this, and is then left unnamed rather than guessed. A loop row carries `view`, `start_foot` and `foot` (the cue, the strikes, their values,
+ the margin, the feet); a loop whose foot is not named starts on its larger strike with
+ `start_foot: null` and `foot_why`, and the report's `warnings` say so — a set whose loops do
+ not all name their foot may not start on one foot. Without `--view` no foot is named and the
+ report says that once. A character drawn without shading on the far leg leaves its side and
+ diagonal views unnamed; mirroring a loop afterwards (a left view made from a right one) swaps
+ its own feet.
- **Rebuilt in place**: `cycle/`, `<name>.strip.png` / `.strip.json`, `.gif`, `.webp` are
rewritten at the loop's own cell rules (`cell_height_cap`, body-height target, anchor), at the
loop's frame rate, so the aligned cycle lasts L*/fps seconds. `strip.json` gains
- `cycle_align` (`from`, `to`, `taken`, `made_by_rife`, `made_at`, `turned_by`, the seam ratio of
- the rebuilt cells, and the re-verified GIF/WebP).
+ `cycle_align` (`from`, `to`, `between`, `taken`, `made_by_rife`, `made_at`, `smear` or
+ `nearest_at`, `turned_by`, `turned_on`, `view`, `start_foot`, the seam ratio of the rebuilt
+ cells, and the re-verified GIF/WebP).
- **The cut as filmed is kept** in `cycle.source/` on the first alignment, and every later
alignment reads from there: running it again, or at another length, never resamples a
resampled loop. Every loop of the set is resampled before any is rewritten, so a loop that
diff --git a/docs/video-pipeline.md b/docs/video-pipeline.md
index 1fd25df..d9d4f56 100644
--- a/docs/video-pipeline.md
+++ b/docs/video-pipeline.md
@@ -791,10 +791,14 @@ A front or back walk films from its base redrawn mid-step (`--walk-start redraw`
image generation each, `--still-provider` picks the provider; see §2). After the loops are cut,
every walk or run filmed in two or more directions is given one cycle
length: each loop is resampled to the set's median length (only the frames that fall between two
-source frames are made, by RIFE) and turned to start on a foot strike (`--align-cycles auto`, the
-default; `off` keeps each loop's own length). The same step stands alone as
-`sprite-gen video-cycle-align --loop-dir … --loop-dir …`. `set.report.json` carries `cycle_align`
-per state, and a failed alignment is listed as `cycle-align:<state>`. Without RIFE the alignment
+source frames are made, by RIFE; `--align-between nearest` takes the nearer source frame instead)
+and turned to start as the same own foot lands in every view — read off the legs, never off an
+ear or a hat's point, and the foot told apart by the item's own view and facing (`--align-cycles
+auto`, the default; `off` keeps each loop's own length). The same step stands alone as
+`sprite-gen video-cycle-align --loop-dir … --view …`. `set.report.json` carries `cycle_align`
+per state (with `start_foot` per item), a failed alignment is listed as `cycle-align:<state>`,
+and a made frame with a smear or a loop whose foot could not be named is a line under
+`warnings`. Without RIFE the alignment
is skipped with a warning (`applied: false`, and a line under the report's `warnings`), not failed. See
[loop repair](loop-repair.md) section 4.