Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Add brightness to colour correction

Bitti33450bba9585
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 924f87f..d5120ef 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -27,6 +27,7 @@ This alpha update adds DMAD LoRA support, resumable model downloads, and improve
## Fixes and improvements
+- Colour correction includes a Brightness control for preview and export.
- Continue preserves the full joined video and audio from Slopfab. Adjacent source and continuation scenes use that shared decode in preview and export, preserving context across the cut. Regenerate older Continue scenes to apply the fix.
- The timeline playhead follows playback without waiting for editor updates.
- Copy and paste effect settings between matching effects from their **…** menus, including bypass state and LUT data.
diff --git a/src-tauri/src/project/timeline.rs b/src-tauri/src/project/timeline.rs
index 7d4afa0..5275e42 100644
--- a/src-tauri/src/project/timeline.rs
+++ b/src-tauri/src/project/timeline.rs
@@ -101,6 +101,8 @@ pub(crate) struct ClipBlur {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub(crate) struct ClipColorCorrection {
pub(crate) exposure: f64,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) brightness: Option<f64>,
pub(crate) contrast: f64,
pub(crate) saturation: f64,
/// Effect bypass: `Some(false)` keeps the settings but renders without
diff --git a/src-tauri/src/project/validation/timeline.rs b/src-tauri/src/project/validation/timeline.rs
index e7f9a1a..a2beddd 100644
--- a/src-tauri/src/project/validation/timeline.rs
+++ b/src-tauri/src/project/validation/timeline.rs
@@ -77,6 +77,7 @@ pub(super) fn validate(config: &mut ProjectConfig) -> Result<(), String> {
.is_some_and(|v| !within(v.amount, 0.0, 100.0))
|| clip.color_correction.as_ref().is_some_and(|v| {
!within(v.exposure, -4.0, 4.0)
+ || v.brightness.is_some_and(|value| !within(value, -100.0, 100.0))
|| !within(v.contrast, -100.0, 100.0)
|| !within(v.saturation, 0.0, 200.0)
})
diff --git a/src-tauri/src/tests/persistence.rs b/src-tauri/src/tests/persistence.rs
index 6b6d8cf..b8e4d90 100644
--- a/src-tauri/src/tests/persistence.rs
+++ b/src-tauri/src/tests/persistence.rs
@@ -204,7 +204,7 @@ fn video_effects_survive_save_and_reopen() {
let clip = &mut json["timeline"]["tracks"][0]["clips"][0];
clip["sharpen"] = serde_json::json!({"amount": 60});
clip["blur"] = serde_json::json!({"radius": 4});
- clip["colorCorrection"] = serde_json::json!({"exposure": 1, "contrast": 20, "saturation": 80});
+ clip["colorCorrection"] = serde_json::json!({"exposure": 1, "brightness": -25, "contrast": 20, "saturation": 80});
clip["vignette"] = serde_json::json!({"amount": 30});
clip["lut"] = serde_json::json!({"intensity": 70, "table": {
"name": "Identity", "size": 2, "domainMin": [0, 0, 0], "domainMax": [1, 1, 1],
@@ -218,6 +218,16 @@ fn video_effects_survive_save_and_reopen() {
let folder = PathBuf::from(&created.folder_path);
write_project(&folder, &config).unwrap();
assert_eq!(read_project(&folder).unwrap().config, config);
+ assert_eq!(config.timeline.tracks[0].clips[0].color_correction.as_ref().unwrap().brightness, Some(-25.0));
+ for brightness in [-101.0, 101.0, f64::NAN, f64::INFINITY] {
+ let mut invalid = config.clone();
+ invalid.timeline.tracks[0].clips[0].color_correction.as_mut().unwrap().brightness = Some(brightness);
+ assert!(validate_and_normalize_config(invalid).unwrap_err().contains("video effects"));
+ }
+ let mut legacy = serde_json::to_value(&config).unwrap();
+ legacy["timeline"]["tracks"][0]["clips"][0]["colorCorrection"].as_object_mut().unwrap().remove("brightness");
+ let legacy = validate_and_normalize_config(serde_json::from_value(legacy).unwrap()).unwrap();
+ assert_eq!(legacy.timeline.tracks[0].clips[0].color_correction.as_ref().unwrap().brightness, None);
let mut invalid = config.clone();
invalid.timeline.tracks[0].clips[0]
.lut
diff --git a/src/components/workspace/ClipEffects.test.tsx b/src/components/workspace/ClipEffects.test.tsx
index 5d78cb3..6bdd923 100644
--- a/src/components/workspace/ClipEffects.test.tsx
+++ b/src/components/workspace/ClipEffects.test.tsx
@@ -54,7 +54,7 @@ describe("clip effects", () => {
{ name: "Chroma key", patch: { chromaKey: { color: "#123456", tolerance: 43 } } },
{ name: "Sharpen", patch: { sharpen: { amount: 125 } } },
{ name: "Gaussian blur", patch: { blur: { radius: 8.5 } } },
- { name: "Colour correction", patch: { colorCorrection: { exposure: -1.2, contrast: 20, saturation: 75 } } },
+ { name: "Colour correction", patch: { colorCorrection: { exposure: -1.2, brightness: 35, contrast: 20, saturation: 75 } } },
{ name: "Vignette", patch: { vignette: { amount: 75 } } },
{ name: "3D LUT", patch: { lut: { intensity: 45, table: parseCube(CUBE, "identity.cube") } } },
] satisfies { name: string; patch: Partial<TimelineClip> }[])("copies $name settings to another clip as one independent edit", ({ name, patch }) => {
@@ -152,11 +152,15 @@ describe("clip effects", () => {
fireEvent.change(screen.getByLabelText("Sharpen amount"), { target: { value: "120" } });
fireEvent.change(screen.getByLabelText("Blur radius"), { target: { value: "6.5" } });
fireEvent.change(screen.getByLabelText("Exposure"), { target: { value: "-1.2" } });
+ expect((screen.getByLabelText("Brightness") as HTMLInputElement).value).toBe("0");
+ fireEvent.change(screen.getByLabelText("Brightness"), { target: { value: "-25" } });
fireEvent.change(screen.getByLabelText("Saturation"), { target: { value: "0" } });
fireEvent.change(screen.getByLabelText("Vignette amount"), { target: { value: "75" } });
expect(saved()).toMatchObject({
- sharpen: { amount: 120 }, blur: { radius: 6.5 }, colorCorrection: { exposure: -1.2, saturation: 0 }, vignette: { amount: 75 },
+ sharpen: { amount: 120 }, blur: { radius: 6.5 }, colorCorrection: { exposure: -1.2, brightness: -25, saturation: 0 }, vignette: { amount: 75 },
});
+ fireEvent.click(screen.getByRole("button", { name: "Reset brightness" }));
+ expect(saved().colorCorrection).toEqual({ exposure: -1.2, brightness: 0, contrast: 0, saturation: 0 });
remove("Gaussian blur");
expect(saved().blur).toBeUndefined();
expect(screen.getByLabelText("Sharpen amount")).toBeTruthy();
diff --git a/src/components/workspace/ClipEffects.tsx b/src/components/workspace/ClipEffects.tsx
index 3d00287..2861705 100644
--- a/src/components/workspace/ClipEffects.tsx
+++ b/src/components/workspace/ClipEffects.tsx
@@ -153,12 +153,13 @@ const EFFECTS: readonly EffectDefinition[] = [
editor: ({ clip, update, disabled }) => <Param label="Radius" ariaLabel="Blur radius" value={clip.blur!.radius} max={24} step={0.5} suffix=" px" defaultValue={4} disabled={disabled} onChange={(radius) => update({ blur: { ...clip.blur!, radius } })} />,
},
{
- id: "colorCorrection", name: "Colour correction", description: "Adjust exposure, contrast and saturation",
- defaults: { colorCorrection: { exposure: 0, contrast: 0, saturation: 100 } },
+ id: "colorCorrection", name: "Colour correction", description: "Adjust exposure, brightness, contrast and saturation",
+ defaults: { colorCorrection: { exposure: 0, brightness: 0, contrast: 0, saturation: 100 } },
editor: ({ clip, update, disabled }) => {
const color = clip.colorCorrection!;
return <>
<Param label="Exposure" value={color.exposure} min={-4} max={4} step={0.1} suffix=" stops" defaultValue={0} disabled={disabled} onChange={(exposure) => update({ colorCorrection: { ...color, exposure } })} />
+ <Param label="Brightness" value={color.brightness ?? 0} min={-100} defaultValue={0} disabled={disabled} onChange={(brightness) => update({ colorCorrection: { ...color, brightness } })} />
<Param label="Contrast" value={color.contrast} min={-100} defaultValue={0} disabled={disabled} onChange={(contrast) => update({ colorCorrection: { ...color, contrast } })} />
<Param label="Saturation" value={color.saturation} max={200} defaultValue={100} disabled={disabled} onChange={(saturation) => update({ colorCorrection: { ...color, saturation } })} />
</>;
diff --git a/src/lib/effectSettings.test.ts b/src/lib/effectSettings.test.ts
index 930b1a0..77e4dfa 100644
--- a/src/lib/effectSettings.test.ts
+++ b/src/lib/effectSettings.test.ts
@@ -44,7 +44,7 @@ it("retains effects through project parsing and export frame planning", () => {
const clip = timelineClipSchema.parse({
id: "clip", assetId: "asset", trackId: "track", label: "Test", startMs: 0, durationMs: 1000,
sharpen: { amount: 60 }, blur: { radius: 4 }, vignette: { amount: 30 },
- colorCorrection: { exposure: 1, contrast: 20, saturation: 80 },
+ colorCorrection: { exposure: 1, brightness: -25, contrast: 20, saturation: 80 },
lut: { intensity: 70, table: parseCube(identityCube, "identity.cube") },
});
const reopened = timelineClipSchema.parse(JSON.parse(JSON.stringify(clip)));
@@ -52,6 +52,11 @@ it("retains effects through project parsing and export frame planning", () => {
sharpen: clip.sharpen, blur: clip.blur, vignette: clip.vignette, colorCorrection: clip.colorCorrection, lut: clip.lut,
});
expect(timelineClipSchema.safeParse({ ...clip, blur: { radius: 25 } }).success).toBe(false);
+ for (const brightness of [-101, 101, NaN, Infinity]) {
+ expect(timelineClipSchema.safeParse({ ...clip, colorCorrection: { ...clip.colorCorrection, brightness } }).success).toBe(false);
+ }
+ const legacyGrade = { exposure: 1, contrast: 20, saturation: 80 };
+ expect(timelineClipSchema.parse({ ...clip, colorCorrection: legacyGrade }).colorCorrection).toEqual(legacyGrade);
expect(timelineClipSchema.safeParse({ ...clip, lut: { ...clip.lut, table: { ...clip.lut!.table, values: [] } } }).success).toBe(false);
});
@@ -95,7 +100,7 @@ describe("effect bypass", () => {
transition: { type: "fade", durationMs: 500, enabled: false },
sharpen: { amount: 40, enabled: false },
blur: { radius: 3, enabled: false },
- colorCorrection: { exposure: 1, contrast: 0, saturation: 100, enabled: false },
+ colorCorrection: { exposure: 1, brightness: 40, contrast: 0, saturation: 100, enabled: false },
vignette: { amount: 30, enabled: false },
lut: { intensity: 50, enabled: false },
});
diff --git a/src/lib/effectSettings.ts b/src/lib/effectSettings.ts
index 9aedb90..5ce8c9b 100644
--- a/src/lib/effectSettings.ts
+++ b/src/lib/effectSettings.ts
@@ -29,6 +29,7 @@ export const effectSchemas = {
blur: z.object({ radius: z.number().finite().min(0).max(24), enabled: effectEnabledSchema }).nullish(),
colorCorrection: z.object({
exposure: z.number().finite().min(-4).max(4),
+ brightness: z.number().finite().min(-100).max(100).nullish(),
contrast: z.number().finite().min(-100).max(100),
saturation: z.number().finite().min(0).max(200),
enabled: effectEnabledSchema,
diff --git a/src/lib/videoEffectsGpu.ts b/src/lib/videoEffectsGpu.ts
index a7fcc01..4f86c17 100644
--- a/src/lib/videoEffectsGpu.ts
+++ b/src/lib/videoEffectsGpu.ts
@@ -88,6 +88,7 @@ fn straight(color: vec4f) -> vec3f { return color.rgb / max(color.a, .00001); }
rgb += (rgb - straight(neighbors)) * params.detail.x;
}
rgb *= exp2(params.grade.x);
+ rgb += vec3f(params.domainMax.w);
rgb = (rgb - vec3f(.5)) * params.grade.y + vec3f(.5);
let luma = dot(rgb, vec3f(.2126, .7152, .0722));
rgb = mix(vec3f(luma), rgb, params.grade.z);
@@ -153,7 +154,8 @@ export function createVideoEffectsProcessor(device: GPUDevice) {
...(effects.chromaKey ? keyColor(effects.chromaKey.color) : [0, 0, 0]), (effects.chromaKey?.tolerance ?? 0) / 100,
grade?.exposure ?? 0, 1 + (grade?.contrast ?? 0) / 100, (grade?.saturation ?? 100) / 100, (effects.vignette?.amount ?? 0) / 100,
(effects.sharpen?.amount ?? 0) / 100, table?.size ?? 0, (effects.lut?.intensity ?? 0) / 100, effects.chromaKey ? 1 : 0,
- ...(table?.domainMin ?? [0, 0, 0]), (effects.look?.temperature ?? 0) / 100, ...(table?.domainMax ?? [1, 1, 1]), 0,
+ // Pack temperature and brightness into the unused domain vector lanes.
+ ...(table?.domainMin ?? [0, 0, 0]), (effects.look?.temperature ?? 0) / 100, ...(table?.domainMax ?? [1, 1, 1]), (grade?.brightness ?? 0) / 100,
effects.blur?.radius ?? 0, 0, 0, 0,
]);
device.queue.writeBuffer(uniforms[0], 0, data);