Skip to content

Hybrid scenes: prepared foregrounds, surface artwork and kinetic text - #3

Open
lxf82dev wants to merge 49 commits into
mainfrom
feat/hybrid-scenes
Open

lxf82dev wants to merge 49 commits into
mainfrom
feat/hybrid-scenes

Conversation

@lxf82dev

@lxf82dev lxf82dev commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Hybrid foreground inserts could erase hands or heads, labels could be placed on the wrong object, and a generated product could change shape behind exact code geometry. This change adds reviewed source-bound preparation data, scoped foreground holdouts, original-surface artwork and deterministic moving type so those failures can be rejected or corrected.

  • Versioned analysis validates source/mask identities, decoded raster, source correspondence, review and correction revisions. Exact frame access handles lossless-mask timestamps, reverse/trim and code shutter sampling without extending missing moving masks.
  • Foreground correction/diagnostic primitives support source-space polygons, bounded interpolation, host Undo and GPU alpha/CPU luminance composition. Missing/stale/unreviewed required data fails capture.
  • Cylinder and imported UV mesh replay preserve the selected body's bounds. Seam-free artwork rasterization and neutral-body shading support original-object reskins; analytic rise/wipe/spring/orbit/extrude treatments support editable kinetic text.
  • New examples cover a selected original can and exact code geometry over an empty generated background, with optional imported GLB and authored contact/shadow controls.

Validation: 131 unit tests passed, plus real-pixel alpha/luminance foreground capture and missing-mask rejection; public-source checks passed. Complete generated-footage examples retained separately: four 121-frame foreground composites had zero opaque-interior changes above one RGB code value before encoding; an 81-frame exact-geometry scene produced byte-identical control mattes. Full details and scoped limits are in docs/prepared-plates.md.

These are model-neutral rendering/authoring primitives. Masks and body fits were reviewed and manually tuned. Automatic camera/cloth solves, arbitrary old-albedo removal, metric collision physics, fractional-hair color recovery, faithful photo reconstruction and device inference benchmarks are not implemented or claimed. The retained can shot has no hand crossing the original left can; broader static/pan/handheld stress and annotated boundary accuracy remain open. Original failed renders are preserved as failed evidence.

lxf82dev and others added 18 commits November 10, 2026 21:04
A hybrid shot mixes footage (filmed or generated) with code-rendered
elements that must agree with it: a product hidden by a passing hand, a
headline behind a presenter, a price pinned to a moving sign, a product lit
by the room it stands in.

EditableFrames runs no model. Mattes, depth maps, tracks and camera paths
are inputs from other tools; this change pins them, checks them and draws
with them.

- Derived assets: plate data records the hash of the footage it was
  computed from. A replaced take, a duplicate role or a frame-count
  mismatch is refused. asset-add gains --role/--of and depth flags, and
  JSON data assets are accepted.
- editableframes/plate: corner pins, track and camera sampling, frame-rate
  conform, depth encodings, plate measurements, seeded grain, id colours
  and shutter sampling. Pure and renderer-independent.
- editableframes/three-plate: depth occlusion, matte hold-out, lighting
  from the plate, camera replay, shadow catcher and control passes.
- Renderer contract: optional mediaInfo and derived services, declared
  passes with clock.pass, render --pass.
- Export: render --motion-blur averages sub-frame samples premultiplied.
- init --hybrid: a starter whose synthetic plate, matte, depth and track
  come from one set of formulas, so tests state where pixels must land.
- Fix transparent DOM-root exports capturing the preview page's header
  through the scene.

Runtime files changed, so existing projects need their normal rebind.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ort a trial on generated footage

Two defects found by running the hybrid helpers on plates from video models:

- createPlateEnvironment drew the mirrored half of its panorama off the
  canvas (translate width + half on a canvas `width` wide), so everything
  behind the camera was black and a mirror-like product lit from the
  footage rendered black. The panorama is now painted by an exported
  paintPlatePanorama, with a unit test for where both halves land and a
  real-pixel check that the side turned away from the light still
  reflects footage.
- A second asset-add before rebind failed with "Incompatible project",
  so the sequence shown in docs/hybrid-scenes.md did not run. importAsset
  now reads the clip definition and asset manifest, not the bound project.
  A real-pixel check runs the documented sequence.

The lit/shaded threshold in the integration test was set against the
half-empty environment (ratio 2.65); with both halves filled it is 1.32.
The clay check is split: the label must be gone under the plate's light,
and under neutral light clay must be neutral grey.

Docs: how to conform mattes and depth maps made by other tools (align by
frame number, hold a dropped tail, never stretch; depth must be grey),
the limits of the key-light estimate and of a four-corner pin on a
surface that bends, and what a trial on twelve generated plates found.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The label samples sat three rows above the label's text on macOS. The text
is laid out with the platform's font, so on Linux a sample landed on a
letter. That did not matter while the plate environment was half empty.
With both halves filled, white text on the can's shaded side is lit by the
warm wall and has the wall's colour, so "the product is visible beside the
foreground" compared the wall with itself and failed in CI.

Samples and the lit/shaded bands now use rows 112-140, plain label above
the text. Checked with the software renderer CI uses, and with a taller
label font standing in for another platform's: the previous test fails
there and this one passes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The starter's plate-lit environment intensity (1.5) was set while the
mirrored half of the panorama was empty. With both halves filled, a
plain can beside a real can in three generated plates came out, by mean
linear-light brightness over the bodies (code can / real can):

  plate                  0.8    1.0    1.2
  desk, lit from front   0.83   1.05   1.28
  kitchen, from front    0.84   1.06   1.29
  patio, sun behind      1.35   1.63   1.89

with the lids at aluminium's reflectance (#f5f6f6, about 0.91). With the
old #d9dde2 (about 0.72) the front-lit plates needed about 1.27, which is
why a higher gain looked right before. Intensity 1 means the
environment's light is the plate's own pixel values. The backlit plate
cannot be matched by a single value, because the mirrored half also puts
the sun in front of the object; the docs now give that figure.

The integration test's thresholds were not changed: lit/shaded on the
synthetic plate is 168/116 (was 183/140), still above both the 1.2 ratio
and the shaded floor of 90, and the pre-fix environment still fails the
floor (43). The two docs images showed the pre-fix black shaded side and
are regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
prepareMedia built each video's PTS list from ffprobe's
best_effort_timestamp_time, which is printed to six decimals. Frame 1 of
a 24 fps clip reads 0.041667, later than 1/24 s, so ptsIndex, which
compares with a 1e-9 tolerance, returned frame 0 for it. A third of the
frames of any 24 or 30 fps clip were drawn as their predecessor
(0, 0, 2, 3, 3, 5, ...), in preview and export, while anything sampled
on the plate's frame grid (plateFrameIndex, conformSeconds, sampleTrack)
used the right frame, so a pinned element sat one frame of motion off
the footage on those frames.

Frame times are now integer ticks scaled by the stream's time base. A
new test prepares a 24 and a 30 fps clip and looks every frame up at its
own time; before the fix it failed at frames 1, 4, 7, ... (24 fps) and
the 30 fps equivalent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… MOV

MP4 and MOV exports converted the browser's sRGB frames to the BT.709
camera transfer curve (colorspace itrc=srgb, all=bt709). Players display
BT.709 video without undoing that curve, so every export came out darker
than drawn: 32 -> 16, 128 -> 115, 224 -> 220. Footage in a hybrid shot
lost 10-13 levels against its source, found when a filmed plate's table
top went from 114 to 101. The encoder now converts RGB to BT.709 YUV in
limited range only, and tags the transfer as sRGB, which is what the
values are.

MOV (ProRes 4444) extracted alpha from the frames, and a scene with no
transparency renders frames without an alpha channel, so its MOV export
failed ("Requested planes not available"). The frames are now converted
to RGBA first.

The hybrid integration test exports the starter to MP4 and MOV and
compares the decoded frame with the PNG the browser drew: within 2
levels per channel, and opaque in the MOV. Before, the MP4 read
123,67,41 against 134,80,55 and the MOV export failed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two real-camera clips (1920 x 1080, 25 fps, motion-control dolly):

- A card pinned to the blank side panel of a box held within 2 px for 30
  frames, then the track slid onto the box's next face as the orbit
  brought it into view, while the tracking tool reported confidence of
  0.70-0.85 and no lost frames.
- estimateKeyLight chose the side the real shadow shows but placed the
  light too low, and took its colour from bright blue components. The
  shadow catcher, a plane with no depth, drew the can's shadow over a
  real object on the table.

The docs say both, add the light-colour and shadow-catcher limits where
those helpers are described, and say how MP4 and MOV now encode colour.
Occlusion was not tried on filmed footage.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
FFmpeg writes cICP, cHRM and gAMA chunks into a PNG decoded from a clip
whose primaries and transfer are tagged BT.709, which most camera footage
is. The browser then draws the frame through that curve rather than as
the values it holds: footage came out darker than its source, and a
matte or depth map tagged the same way reached the scene with changed
data. Found on filmed footage: a board pixel stored as (142, 117, 73)
drew as (136, 109, 63); without the three chunks it drew exactly.

prepareMedia now clears the primaries and transfer tags before the PNG
encoder; they do not change the decoded values. A new test decodes a
tagged clip and checks for no colour chunks and the values of a plain
decode; before the fix it found all three chunks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A tripod shot of a board with a forearm sweeping in front, with a hosted
matte and depth map:

- The headline behind the arm works, except while the arm enters fast
  (up to 460 px per frame): the matte lags it by 1-2 frames.
- The depth map as delivered was normalised per frame, so the board read
  as near until the arm came in and hid the 3D object until then.
  Rescaled per frame against static parts of the shot, the arm hid the
  object with a 3-4 px edge and nothing leaked onto the arm.

The filmed-footage section now covers all three journeys, and lists the
three export defects the trial found, all fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Separate output-frame media time from code shutter samples, retain float precision when averaging samples, and use the fixed media clock in the bundled starters. Restore hidden meshes and clear scene overrides during control passes. Add pixel and state regressions and document the media clock.
@lxf82dev lxf82dev changed the title Hybrid scenes: composite code-rendered elements inside footage Hybrid scenes: prepared foregrounds, surface artwork and kinetic text Nov 11, 2026
lxf82dev and others added 11 commits November 11, 2026 18:01
The hybrid doc's helper table gained sampleTrackFrame without its
packaged skill copy, so the CLI test that pins the copy to the doc
failed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ucts

From trials on 2026-11-12:

- Lighting: an official product photograph keeps exact branding but can
  only be colour-matched; its highlights are baked in and turn with the
  image. A 3D model responds to moving light only as well as its
  materials allow; two phone models were too flat for close-ups. Notes on
  grading a case but not its display, explicit downsampling, and
  environment strength washing out metal.
- Overlap: object-id passes at 35 crossing poses of two moving copies
  found no wrong ordering; axis-aligned boxes reported collisions a tight
  footprint ruled out.
- Presenters: a generated presenter can point at, pick up and carry a
  product, best from an explicit first frame, but the output is one
  flattened picture and the product is redrawn. Drawing the exact product
  needs separate background, presenter and hand layers, a product pose
  whose anchor moves from table to hand, a 3D or multi-view asset, and
  narration timed with the action. Proposed, not implemented.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant