8000 feat: global color grade + opinionated filters (VHS · Super-8 · Decay · Noir · Sepia · Instant) by johannboehme · Pull Request #60 · johannboehme/tk-1 · GitHub
[go: up one dir, main page]

Skip to content

feat: global color grade + opinionated filters (VHS · Super-8 · Decay · Noir · Sepia · Instant) - #60

Merged
johannboehme merged 8 commits into
mainfrom
worktree-global-grade
Jun 20, 2026
Merged

johannboehme merged 8 commits into
mainfrom
worktree-global-grade

Conversation

@johannboehme
Copy link
Copy Markdown
Owner

What

Adds two new, distinct surfaces to the Overlays tab for shaping the whole video's look — separate from the momentary punch-in accents:

1. Color grade (a real grading surface)

One persistent grade per project (colorGrade), edited via grouped controls in pipeline order:

  • Tone — Exposure · Contrast · Black · Fade
  • Color — Saturation · Temp · Tint
  • Wheels — Shadows (lift) · Midtones (gamma) · Highlights (gain)

Backed by a shared grade engine (WebGL2 / WebGPU / Canvas2D) with byte-aligned GPU parity. Emits one grade FrameFx, skipped entirely when it's the identity.

2. Filters (opinionated, recognizable looks)

A stack of distinct effects — each its own shader with its own controls (no shared macro block):

Filter What it does Controls
VHS rolling tracking band, chroma bleed, scanlines, snow — animated Track / Bleed / Snow / Wobble
Super-8 organic grain, gate weave, exposure flicker, halation — animated Grain / Weave / Flicker / Warmth
Decay dancing dust + hair, flickering scratches, gate-judder, light-leaks — animated Dust / Scratch / Flicker / Leak
Noir B&W with a coloured-filter response, contrast curve, grain, vignette Filter / Contrast / Grain / Vign
Sepia true luma→duotone remap, paper fade, grain, oval vignette Tone / Contrast / Fade / Grain
Instant warm-cool split, centre bloom, vignette, off-white paper frame Fade / Bloom / Cast / Vign / Frame

Filters stack (order = serial compose order, reorder changes the result), each seeded with a tasteful non-zero default so a fresh filter is immediately visible.

Architecture

  • New FilterSlot { id, kind, params } + colorGrade: GradeParams on the store; descriptor emits grade → filters → punch-ins (all replace-blend, re-snapshotted per FX, so they compose serially). Shared colorGradeFrameFx + filterFrameFx used by both the live preview AND the export compositor → preview == render.
  • Each filter is a normal source-FX FxDefinition built from one makeFilterDef factory; the per-card UI is driven by a new filterParams?: FxParamDef[] schema (variable length, distinct from the 2-knob hardware-encoder params), so each card renders its kind's own controls.
  • Persisted per job (ColorGradeRecord + FilterSlotRecord in jobs-db); partial grades fill defaults on load.

Verification

  • GPU-verified end to end: a browser test compiles every filter's frag and wgsl on a live WebGL2 + WebGPU, asserts the default look changes the image and amount=0 is a clean identity pass (caught + fixed two reserved-word ship-blockers in the generated shaders: cast, dot). The grade engine has a WebGL2 ≡ WebGPU ±6 LSB pixel-parity test.
  • 1141 unit tests + 23 GPU browser tests green; tsc clean.

Notes

  • This replaces an earlier look-preset approach (every "look" was a preset of one engine sharing 4 macros) — rebuilt into distinct effects + a separate grade after review feedback that the presets all looked alike.
  • The Canvas2D path is a documented reduced fallback (live no-GPU only); export runs on WebGPU = full shaders.
  • VITE_DB_NAME env override added so an isolated dev instance can avoid clashing with the real IndexedDB (prod unchanged).

🤖 Generated with Claude Code

johannboehme and others added 8 commits June 20, 2026 16:04
…gine/shaders/descriptor)

Adds a global "film stock" color-grade layer that sits UNDER the punch-in
accents. This is the engine half — UI lands next.

- fx/looks.ts: GradeParams vector (16 params), 10 TE-named looks (CLEAR,
  FROST, EMBER, HAZE, BLUSH, DUSK, VOLT, MONO, GOLD, SUPER-8) + RAW, a
  GradeSlot (look + strength BLEND + 4 macros), mergeGradeParams, and the
  canonical CPU reference gradeColor() mirroring the shaders.
- fx/webgl2/grade.frag.ts + fx/webgpu/grade.wgsl.ts: one shared grade
  pipeline, byte-aligned for GPU parity; mix(source, graded, strength) so
  strength=0 is a literal identity pass. Registered in program-cache +
  webgpu registry.
- catalog.ts: GRADE FxDefinition (replace-blend source sampler; reduced
  Canvas2D fallback). No 2-knob tuple — its surface is the Overlays panel.
- build-descriptor.ts: prepend one grade FrameFx per active slot AHEAD of
  the punch-ins, so the frame is graded first and accents composite on top;
  slots stack serially A->B->C.
- types.ts / jobs-db.ts: mirror the new `grade` FxKind.

Tests: looks (engine + catalog + gradeColor), grade (registration +
backend param-parity + strength-0 skip), build-descriptor (prepend / skip
raw+zero / stacking order / global-at-any-t). 81 unit tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- store.ts: gradeSlots[] state + addGradeSlot / updateGradeSlot /
  removeGradeSlot / moveGradeSlot actions; init in default/reset/loadJob.
- preview-runtime: feed gradeSlots into the descriptor snapshot.
- useAutoPersist + jobs-db (GradeSlotRecord) + Editor.tsx loadJob: persist
  the grade stack per job, hydrate on load, clean default-[] migration for
  pre-feature jobs.
- export: thread grades through jobs.ts -> edit.worker -> edit ->
  compositor and prepend via the shared gradeFrameFxFor() helper, so the
  exported file is graded identically to the live preview (preview == render).

Tests: grade-actions (add/update/remove/move/load/reset), persist round-trip.
131 unit tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds the global-filter UI as a stacked card list in the OVERLAYS tab,
matching the panel's existing conventions (no new visual paradigm):

- FilterStack.tsx: ADD appends a filter card; each card = a look <select>
  (RAW/CLEAR/FROST/EMBER/HAZE/BLUSH/DUSK/VOLT/MONO/GOLD/SUPER-8), an Amount
  slider, and four macro sliders (Warmth/Fade/Punch/Grain), plus a swatch
  chip, REMOVE, and up/down reorder nudges. Card order = serial compose
  order. Reuses ChunkyButton, the panel <select> idiom, and the
  QualitySlider-style range markup.
- OverlaysPanel: render <FilterStack/> between the visualizer and text
  overlays; subtitle now reads "Filters · text overlays · audio visualizer".

Tests: FilterStack render + ADD/REMOVE/reorder + look/Amount/macro -> store
mapping. Full unit suite green (1137 tests).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Browser test that compiles the real grade.frag/grade.wgsl on a live GPU and
checks the graded pixels: strength-0 identity, warm-temp red lift, sat-0
greyscale, and WebGL2 vs WebGPU agree on an EMBER grade to within ±6 LSB.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replaces the "every look is a preset of one engine with the same 4 macros"
approach with genuinely distinct effects, each its own shader + own controls:

- VHS (rolling tracking band, chroma bleed, scanlines, snow — temporal)
- Super-8 (organic grain, gate weave, exposure flicker, halation — temporal)
- Decay (dancing dust/hair, flickering scratches, gate-judder, light-leaks — temporal)
- Noir (B&W with a coloured-filter response, contrast curve, grain, vignette)
- Sepia (real luma->duotone remap, paper fade, grain, oval vignette)
- Instant/Polaroid (warm-cool split, center bloom, vignette, paper border)

Each is a source-sampling REPLACE FX with a variable-length `filterParams`
schema (its OWN controls) on FxDefinition, built via one shared makeFilterDef
factory; tasteful non-zero defaults so a fresh filter immediately looks like
the thing; amount = master dry/wet (folds ADSR wetness). Registered across
catalog + program-cache (WebGL2) + webgpu registry; jobs-db kind mirror.

Color-grade engine extended with shadowsLift + highlightsGain (the Shadows /
Highlights wheels of a lift/gamma/gain grade; gamma already = midtones),
mirrored across gradeColor + grade.frag + grade.wgsl, no-op at 0.

Verified on real GPU: a browser test compiles every filter's frag AND wgsl on
WebGL2 + WebGPU, asserts the default look changes the image and amount=0 is
identity (caught + fixed two reserved-word ship-blockers: GLSL `cast`, `dot`).
1147 unit + 18 GPU filter tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…filter stack

Replaces the "look-preset slot" model (every look = a preset of one engine
with the same 4 macros — the user's complaint) with two distinct surfaces:

- COLOR GRADE: a single persistent `colorGrade: GradeParams` on the store,
  edited via a dedicated ColorGradePanel (Tone: Exposure/Contrast/Black/Fade ·
  Color: Saturation/Temp/Tint · Wheels: Shadows/Midtones/Highlights). Emits
  one grade FrameFx, skipped when identity.
- FILTERS: `filterSlots: FilterSlot[]` — each slot picks a filter KIND and
  carries that kind's OWN params (FxDefinition.filterParams). FilterStack
  renders the selected kind's controls per card (VHS → TRACK/BLEED/SNOW,
  Sepia → TONE/CONTRAST/FADE) — no shared macro block.

Deletes GradeSlot / GRADE_LOOKS / GradeLookId / mergeGradeParams /
defaultGradeSlot machinery from looks.ts (now engine-only). build-descriptor
emits grade → filters → punch-ins via colorGradeFrameFx + filterFrameFx,
shared by preview AND export (compositor/edit/worker/jobs threaded with
colorGrade + filterSlots). Persistence: ColorGradeRecord + FilterSlotRecord
in jobs-db; useAutoPersist + Editor.tsx loadJob updated; partial grades fill
defaults on load. Shared ParamSlider extracted.

Tests rewritten for the new model (looks / grade / grade-actions /
build-descriptor / FilterStack / useAutoPersist / grade-backend). 1141 unit +
23 GPU tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Lets an isolated dev instance (e.g. a worktree under review) use its own
IndexedDB instead of sharing — and clashing on schema version with — the real
'videoaudiosync' DB. Production sets nothing → canonical name.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Resolves the jobs-db.ts conflict: keeps the new ColorGradeRecord /
FilterSlotRecord + VITE_DB_NAME override AND adopts main's DB_VERSION 11
(waveform-pyramid store from #59). Other files auto-merged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@johannboehme
johannboehme merged commit 814450f into main Jun 20, 2026
1 check passed
@johannboehme
johannboehme deleted the worktree-global-grade branch June 20, 2026 15:46
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

0