Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

feat(color): Adjust drawn in light, Contrast, Saturation and White Balance, tables read in their own space

Jareer981fbd44caa7
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index 9cd228d0..cebff359 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -183,6 +183,18 @@ in one submission into pictures claimed from the pool and handed on from
one package to the next of a layer's stack, and only the last pass mixes by
intensity.
+A format 2 shader works in light (`space = "linear"`, the default), in the
+display encoding (`"display"`, the colour looks), or in log (`"log"`,
+ACEScct), and every result is held to what half floats store. The colour
+tools share the scene-linear library: exposure in stops, `contrast` in
+stops about middle grey, `white_balance` as a Bradford adaptation along the
+Planckian locus. A `.cube` imported as a look (`concat_effects::looks`) is a
+format 2 filter reading its table through `look()`, which carries a level
+past the table's ends, in the display encoding or, for a table made for
+ACEScct, in log; tables are kept in floats and uploaded as half floats.
+Looks an earlier build imported as format 1 are rewritten onto this when
+the window loads its packages.
+
## 4. Decoding, caching and scheduling
Export decodes every frame once, in order, with one decoder per clip. Everything
diff --git a/src/crates/concat-core/src/shader.rs b/src/crates/concat-core/src/shader.rs
index 3e022767..8fde8ad3 100644
--- a/src/crates/concat-core/src/shader.rs
+++ b/src/crates/concat-core/src/shader.rs
@@ -131,36 +131,40 @@ pub struct TransitionPass {
pub xfade: Option<String>,
}
-/// A 3D look-up table: `size` texels a side, RGBA8, red fastest, then
+/// A 3D look-up table: `size` texels a side, RGBA floats, red fastest, then
/// green, then blue - the order a `.cube` file lists its rows in and the
/// layout a `texture_3d` is uploaded from. A colour is looked up by its
/// own components: the table maps every input colour to an output one.
+/// Floats, not bytes: a table read in log spreads seventeen stops over its
+/// range, and eight bits of that would be steps a fifteenth of a stop
+/// apart - bands in any sky.
#[derive(Clone, Debug, PartialEq)]
pub struct Lut {
/// A hash of the contents, so a renderer can cache the upload.
pub id: u64,
/// Texels a side, at least 2.
pub size: u32,
- /// `size³ × 4` bytes.
- pub rgba: Arc<[u8]>,
+ /// `size³ × 4` floats, alpha 1.
+ pub rgba: Arc<[f32]>,
}
impl Lut {
- /// A table from `size³` RGB triples in 0..=1, red fastest. Values
- /// outside the range are clamped; a table of the wrong length is None.
+ /// A table from `size³` RGB triples, red fastest, as the table gives
+ /// them - usually 0..=1, though a table made for log or for HDR may
+ /// reach past either end. A table of the wrong length, or with a value
+ /// that is not a number, is None.
pub fn from_rgb(size: u32, rgb: &[f32]) -> Option<Lut> {
let texels = (size as usize).checked_pow(3)?;
- if size < 2 || rgb.len() != texels * 3 {
+ if size < 2 || rgb.len() != texels * 3 || !rgb.iter().all(|value| value.is_finite()) {
return None;
}
let mut rgba = Vec::with_capacity(texels * 4);
for triple in rgb.chunks_exact(3) {
- for channel in triple {
- rgba.push((channel.clamp(0.0, 1.0) * 255.0).round() as u8);
- }
- rgba.push(255);
+ rgba.extend_from_slice(triple);
+ rgba.push(1.0);
}
- let id = fnv64(&rgba) ^ u64::from(size);
+ let bytes: Vec<u8> = rgba.iter().flat_map(|value| value.to_le_bytes()).collect();
+ let id = fnv64(&bytes) ^ u64::from(size);
Some(Lut {
id,
size,
@@ -198,11 +202,7 @@ impl Lut {
let (bi, bf) = at(rgb[2]);
let texel = |r: usize, g: usize, b: usize| {
let o = ((b * n + g) * n + r) * 4;
- [
- f32::from(self.rgba[o]) / 255.0,
- f32::from(self.rgba[o + 1]) / 255.0,
- f32::from(self.rgba[o + 2]) / 255.0,
- ]
+ [self.rgba[o], self.rgba[o + 1], self.rgba[o + 2]]
};
let lerp = |a: [f32; 3], b: [f32; 3], t: f32| {
[
@@ -314,6 +314,23 @@ mod tests {
fn a_table_of_the_wrong_length_is_refused() {
assert!(Lut::from_rgb(3, &[0.0; 26 * 3]).is_none());
assert!(Lut::from_rgb(1, &[0.0; 3]).is_none());
+ let mut broken = [0.5; 8 * 3];
+ broken[4] = f32::NAN;
+ assert!(Lut::from_rgb(2, &broken).is_none(), "not a number");
+ }
+
+ /// A table keeps its values as the file gave them, past either end and
+ /// finer than eight bits.
+ #[test]
+ fn a_table_keeps_its_values_as_given() {
+ let lut = Lut::from_rgb(2, &[0.1234567, -0.25, 1.75].repeat(8)).expect("a table");
+ assert_eq!(lut.sample([0.3, 0.6, 0.9]), [0.1234567, -0.25, 1.75]);
+ assert_ne!(
+ lut.id,
+ Lut::from_rgb(2, &[0.1234568, -0.25, 1.75].repeat(8))
+ .expect("a table")
+ .id
+ );
}
#[test]
diff --git a/src/crates/concat-effects/packages/concat.adjust/effect.toml b/src/crates/concat-effects/packages/concat.adjust/effect.toml
index 3b392781..df0c6069 100644
--- a/src/crates/concat-effects/packages/concat.adjust/effect.toml
+++ b/src/crates/concat-effects/packages/concat.adjust/effect.toml
@@ -11,11 +11,16 @@ description = "The manual colour panel every picture clip carries: exposure, ton
# Three groups, in the order the panel lists them. Colour: temperature in
# kelvin with 6500 the picture as shot, tint green to magenta, saturation
-# as a signed percent. Lightness: exposure in stops, then brightness,
-# contrast, highlights, shadows, whites and blacks as signed percents; the
-# last four lift or crush their end of the curve, highlights and shadows
-# the broad upper and lower halves, whites and blacks the narrow extremes.
-# Effects: sharpen, fade and vignette add from zero.
+# as a signed percent. Lightness: exposure in stops of light, then
+# brightness, contrast, highlights, shadows, whites and blacks as signed
+# percents; the last four lift or crush their end of the curve, highlights
+# and shadows the broad upper and lower halves, whites and blacks the
+# narrow extremes. Effects: sharpen, fade and vignette add from zero.
+#
+# 2: drawn in light. Exposure is in true stops of light, where it scaled
+# the display encoding, some 2.4 stops an EV; the rest reads as it did at
+# a moderate setting, without clipping.
+version = 2
[[param]]
key = "temperature"
@@ -149,7 +154,6 @@ unit = "%"
[wgsl]
entry = "effect.wgsl"
-space = "display"
# At its defaults the panel changes nothing; the card shows it at work.
[card]
diff --git a/src/crates/concat-effects/packages/concat.adjust/effect.wgsl b/src/crates/concat-effects/packages/concat.adjust/effect.wgsl
index 90a63bf5..2551ba40 100644
--- a/src/crates/concat-effects/packages/concat.adjust/effect.wgsl
+++ b/src/crates/concat-effects/packages/concat.adjust/effect.wgsl
@@ -15,52 +15,73 @@ struct Params {
}
// The manual colour panel, in the order a colourist works: exposure and
-// balance, then tone, then the edge and the frame.
+// balance, then tone, then the edge and the frame. What a lens or a lamp
+// does is done in light - exposure in stops, the white balance, the
+// vignette - and contrast in stops about middle grey; what an eye judges
+// on the picture - brightness, saturation, the four tonal bands, the fade,
+// sharpness - in the display encoding its sliders were drawn in, which
+// here is never clipped: a highlight past white is carried on past it.
+// Every knob at its default is the picture as it came.
+
+/// `by` added to a display-encoded colour, as far down as black and no
+/// further: a channel that is lit is not taken below nothing.
+fn lifted(encoded: vec3<f32>, by: f32) -> vec3<f32> {
+ let moved = encoded + vec3<f32>(by);
+ return select(moved, max(moved, vec3<f32>(0.0)), encoded >= vec3<f32>(0.0));
+}
+
fn effect(uv: vec2<f32>) -> vec4<f32> {
let t = texel();
let src = sample(uv);
- var c = src.rgb;
- // Exposure in stops, then brightness as an offset.
- c = c * exp2(params.exposure) + vec3<f32>(params.brightness / 100.0 * 0.5);
+ // Exposure in stops, then brightness as a lift of the display level.
+ var c = exposure(src.rgb, params.exposure);
+ c = from_display(lifted(to_display(c), params.brightness / 100.0 * 0.5));
// White balance about daylight, and green to magenta.
- c = white_balance(c, params.temperature);
- c.g = c.g - params.tint / 100.0 * 0.25;
+ c = white_balance(c, params.temperature, params.tint);
+
+ // Contrast in stops about middle grey.
+ c = contrast(c, 1.0 + params.contrast / 100.0);
- // Contrast about middle grey, saturation about luminance.
- c = (c - vec3<f32>(0.5)) * (1.0 + params.contrast / 100.0) + vec3<f32>(0.5);
- c = mix(vec3<f32>(luma(c)), c, 1.0 + params.saturation / 100.0 * 2.0);
+ // Saturation about luminance, by the display level: a push richer by
+ // up to three times, a pull greyer to none at all.
+ var d = to_display(c);
+ let s = params.saturation / 100.0;
+ d = saturation(d, select((1.0 + s) * (1.0 + s), 1.0 + 2.0 * s, s > 0.0));
// Shadows and highlights lift or crush their half of the range, blacks
- // and whites the extreme quarter of each; fade lifts the black.
- let l = luma(clamp(c, vec3<f32>(0.0), vec3<f32>(1.0)));
+ // and whites the extreme quarter of each, by the display level; fade
+ // lifts the black and carries a level past white on past it.
+ let l = luma(clamp(d, vec3<f32>(0.0), vec3<f32>(1.0)));
let low = (1.0 - smoothstep(0.0, 0.5, l)) * params.shadows / 100.0 * 0.18;
let high = smoothstep(0.5, 1.0, l) * params.highlights / 100.0 * 0.18;
let black = (1.0 - smoothstep(0.0, 0.25, l)) * params.blacks / 100.0 * 0.1;
let white = smoothstep(0.75, 1.0, l) * params.whites / 100.0 * 0.1;
- c = c + vec3<f32>(low + high + black + white);
+ d = lifted(d, low + high + black + white);
let lift = params.fade / 100.0 * 0.25;
- c = c * (1.0 - lift) + vec3<f32>(lift);
+ let below = min(d, vec3<f32>(1.0));
+ d = below * (1.0 - lift) + vec3<f32>(lift) + (d - below);
- // Sharpen: the difference from a small blur, scaled.
+ // Sharpen: the picture's difference from a small blur of it, scaled.
if (params.sharpen > 0.0) {
var blur = vec3<f32>(0.0);
for (var y: i32 = -1; y <= 1; y++) {
for (var x: i32 = -1; x <= 1; x++) {
- blur += sample(uv + vec2<f32>(f32(x), f32(y)) * t).rgb;
+ blur += to_display(sample(uv + vec2<f32>(f32(x), f32(y)) * t).rgb);
}
}
blur /= 9.0;
- c = c + (src.rgb - blur) * params.sharpen / 100.0 * 2.0;
+ d = d + (to_display(src.rgb) - blur) * params.sharpen / 100.0 * 2.0;
}
+ c = from_display(d);
- // Vignette: darker towards the corners.
+ // Vignette: the light falling off towards the corners, as a lens's does.
if (params.vignette > 0.0) {
- let d = length((uv - vec2<f32>(0.5)) * vec2<f32>(2.0));
+ let r = length((uv - vec2<f32>(0.5)) * vec2<f32>(2.0));
let v = params.vignette / 100.0;
- let fall = smoothstep(1.4 - v * 0.9, 1.6 - v * 0.3, d);
- c = c * (1.0 - fall * (0.4 + 0.6 * v));
+ let fall = smoothstep(1.4 - v * 0.9, 1.6 - v * 0.3, r);
+ c = c * pow(1.0 - fall * (0.4 + 0.6 * v), 2.4);
}
return vec4<f32>(c, src.a);
diff --git a/src/crates/concat-effects/packages/concat.adjust/fixtures.toml b/src/crates/concat-effects/packages/concat.adjust/fixtures.toml
index 43705e6e..12173217 100644
--- a/src/crates/concat-effects/packages/concat.adjust/fixtures.toml
+++ b/src/crates/concat-effects/packages/concat.adjust/fixtures.toml
@@ -1,22 +1,45 @@
# Colours in the working space: linear light, 1.0 the white of an SDR
-# picture. Pinned from the format 1 shader, so the look is what it was.
+# picture. Exposure, white balance and contrast are in light and in stops;
+# brightness, saturation, the four tonal bands, fade and sharpness by the
+# display level, unclipped. Every knob at its default is the picture as it
+# came.
[[probe]]
name = "default"
input = [0.3, 0.2, 0.12, 1]
-expect = [0.30005, 0.19995, 0.12, 1]
+expect = [0.3, 0.2, 0.12, 1]
+# Three stops down, the black lifted away and the contrast flat: a grey.
[[probe]]
name = "minimum"
at = "min"
-input = [0.45, 0.4, 0.35, 1]
-expect = [0.18945, 0.18945, 0.18945, 1]
+input = [6.0, 5.0, 4.0, 1]
+expect = [0.130138, 0.130138, 0.130138, 1]
-# Every knob up is far past white, where format 1 clipped it: the panel's
-# exposure scales the display encoding, +3 EV eight times over, until its
-# maths moves into light with the colour sliders (phase 2, step 5).
+# Every knob up: three true stops, brightness, contrast twice the stops,
+# three times the saturation. Far past white, as light asked for it is.
[[probe]]
name = "maximum"
at = "max"
input = [0.08, 0.07, 0.06, 1]
-expect = [40.8125, 31.71875, 122.25, 1]
+expect = [447.66, 0.00821351, 310.039, 1]
+
+# A moderate grade: a stop up, a little contrast and colour, a warm light.
+[[probe]]
+name = "a grade"
+params = { exposure = 1, contrast = 30, saturation = 30, temperature = 5000, tint = 10 }
+input = [0.18, 0.12, 0.08, 1]
+expect = [0.775977, 0.217197, 0.0563556, 1]
+
+[[probe]]
+name = "a grade, past white"
+params = { exposure = 1, contrast = 30, saturation = 30, temperature = 5000, tint = 10 }
+input = [4.0, 3.0, 2.0, 1]
+expect = [42.5604, 14.6572, 3.87784, 1]
+
+# Fade lifts the black and leaves a level past white where it was.
+[[probe]]
+name = "fade, past white"
+params = { fade = 50 }
+input = [4.0, 4.0, 4.0, 1]
+expect = [4.0, 4.0, 4.0, 1]
diff --git a/src/crates/concat-effects/packages/concat.contrast/effect.toml b/src/crates/concat-effects/packages/concat.contrast/effect.toml
new file mode 100644
index 00000000..67a86068
--- /dev/null
+++ b/src/crates/concat-effects/packages/concat.contrast/effect.toml
@@ -0,0 +1,27 @@
+format = 2
+
+[effect]
+id = "concat.contrast"
+name = "Contrast"
+kind = "effect"
+category = "Color"
+order = 11
+intensity = "amount"
+description = "More or less contrast in stops about middle grey, highlights past white kept and black never crushed."
+
+[[param]]
+key = "amount"
+label = "Contrast"
+min = -100
+max = 100
+default = 0
+step = 1
+unit = "%"
+animate = true
+
+[wgsl]
+entry = "effect.wgsl"
+
+# At its default the picture is as shot; the card shows a push.
+[card]
+params = { amount = 40 }
diff --git a/src/crates/concat-effects/packages/concat.contrast/effect.wgsl b/src/crates/concat-effects/packages/concat.contrast/effect.wgsl
new file mode 100644
index 00000000..848635e2
--- /dev/null
+++ b/src/crates/concat-effects/packages/concat.contrast/effect.wgsl
@@ -0,0 +1,10 @@
+struct Params { amount: f32 }
+
+// Contrast in stops about middle grey (see `contrast`): a push takes every
+// level further from grey by the same share of its distance in stops, a
+// pull draws them together, and at -100 the picture is flat grey. What the
+// Adjust panel's contrast does, alone: the slider's percent is the share.
+fn effect(uv: vec2<f32>) -> vec4<f32> {
+ let c = sample(uv);
+ return vec4<f32>(contrast(c.rgb, 1.0 + params.amount / 100.0), c.a);
+}
diff --git a/src/crates/concat-effects/packages/concat.contrast/fixtures.toml b/src/crates/concat-effects/packages/concat.contrast/fixtures.toml
new file mode 100644
index 00000000..b3d1407e
--- /dev/null
+++ b/src/crates/concat-effects/packages/concat.contrast/fixtures.toml
@@ -0,0 +1,31 @@
+# Every level moves in stops about middle grey, 0.18: at +100 twice as far,
+# at -100 onto grey itself. A channel with no light in it stays as it was.
+
+[[probe]]
+name = "default"
+input = [0.36, 0.09, 0.18, 1]
+expect = [0.36, 0.09, 0.18, 1]
+
+[[probe]]
+name = "minimum, flat grey"
+at = "min"
+input = [0.36, 0.09, 0.18, 1]
+expect = [0.18, 0.18, 0.18, 1]
+
+[[probe]]
+name = "maximum, twice the stops"
+at = "max"
+input = [0.36, 0.09, 0.18, 1]
+expect = [0.72, 0.045, 0.18, 1]
+
+[[probe]]
+name = "maximum, a highlight past white and a channel below black"
+at = "max"
+input = [4.0, 0.5, -0.02, 1]
+expect = [88.8889, 1.38889, -0.02, 1]
+
+[[probe]]
+name = "half again the stops"
+params = { amount = 50 }
+input = [0.36, 0.09, 0.18, 1]
+expect = [0.509117, 0.0636396, 0.18, 1]
diff --git a/src/crates/concat-effects/packages/concat.saturation/effect.toml b/src/crates/concat-effects/packages/concat.saturation/effect.toml
new file mode 100644
index 00000000..265ba2fb
--- /dev/null
+++ b/src/crates/concat-effects/packages/concat.saturation/effect.toml
@@ -0,0 +1,28 @@
+format = 2
+
+[effect]
+id = "concat.saturation"
+name = "Saturation"
+kind = "effect"
+category = "Color"
+order = 12
+intensity = "amount"
+description = "Richer or greyer colour, about each pixel's own brightness."
+
+[[param]]
+key = "amount"
+label = "Saturation"
+min = -100
+max = 100
+default = 0
+step = 1
+unit = "%"
+animate = true
+
+[wgsl]
+entry = "effect.wgsl"
+space = "display"
+
+# At its default the picture is as shot; the card shows a push.
+[card]
+params = { amount = 50 }
diff --git a/src/crates/concat-effects/packages/concat.saturation/effect.wgsl b/src/crates/concat-effects/packages/concat.saturation/effect.wgsl
new file mode 100644
index 00000000..4fc4180f
--- /dev/null
+++ b/src/crates/concat-effects/packages/concat.saturation/effect.wgsl
@@ -0,0 +1,10 @@
+struct Params { amount: f32 }
+
+// Saturation about luminance, by the display level, as the Adjust panel's
+// slider makes it: a push up to three times richer at +100, a pull to grey
+// at -100, easing in so the first steps either way are gentle.
+fn effect(uv: vec2<f32>) -> vec4<f32> {
+ let c = sample(uv);
+ let s = params.amount / 100.0;
+ return vec4<f32>(saturation(c.rgb, select((1.0 + s) * (1.0 + s), 1.0 + 2.0 * s, s > 0.0)), c.a);
+}
diff --git a/src/crates/concat-effects/packages/concat.saturation/fixtures.toml b/src/crates/concat-effects/packages/concat.saturation/fixtures.toml
new file mode 100644
index 00000000..e3a69acd
--- /dev/null
+++ b/src/crates/concat-effects/packages/concat.saturation/fixtures.toml
@@ -0,0 +1,32 @@
+# Saturation about luminance in the display encoding: at -100 every channel
+# is the display level's luminance, at +100 three times as far from it. A
+# highlight past white is spread like any other level.
+
+[[probe]]
+name = "default"
+input = [0.6, 0.3, 0.1, 1]
+expect = [0.6, 0.3, 0.1, 1]
+
+[[probe]]
+name = "minimum, grey"
+at = "min"
+input = [0.6, 0.3, 0.1, 1]
+expect = [0.333173, 0.333173, 0.333173, 1]
+
+[[probe]]
+name = "maximum"
+at = "max"
+input = [0.6, 0.3, 0.1, 1]
+expect = [1.42701, 0.239652, -0.00566044, 1]
+
+[[probe]]
+name = "maximum, past white"
+at = "max"
+input = [4.0, 2.0, 1.0, 1]
+expect = [9.31414, 1.52779, 0.0182573, 1]
+
+[[probe]]
+name = "a gentle pull"
+params = { amount = -30 }
+input = [0.6, 0.3, 0.1, 1]
+expect = [0.452557, 0.316664, 0.199006, 1]
diff --git a/src/crates/concat-effects/packages/concat.white-balance/effect.toml b/src/crates/concat-effects/packages/concat.white-balance/effect.toml
new file mode 100644
index 00000000..266f410a
--- /dev/null
+++ b/src/crates/concat-effects/packages/concat.white-balance/effect.toml
@@ -0,0 +1,37 @@
+format = 2
+
+[effect]
+id = "concat.white-balance"
+name = "White Balance"
+kind = "effect"
+category = "Color"
+order = 13
+intensity = "temperature"
+description = "The picture as if lit warmer or cooler, and turned towards magenta or green, as the eye adapts to the light."
+
+[[param]]
+key = "temperature"
+label = "Temperature"
+min = 2000
+max = 11000
+default = 6500
+step = 50
+unit = "K"
+animate = true
+
+[[param]]
+key = "tint"
+label = "Tint"
+min = -100
+max = 100
+default = 0
+step = 1
+unit = "%"
+animate = true
+
+[wgsl]
+entry = "effect.wgsl"
+
+# At its defaults the picture is as shot; the card shows a warm light.
+[card]
+params = { temperature = 4500 }
diff --git a/src/crates/concat-effects/packages/concat.white-balance/effect.wgsl b/src/crates/concat-effects/packages/concat.white-balance/effect.wgsl
new file mode 100644
index 00000000..64188726
--- /dev/null
+++ b/src/crates/concat-effects/packages/concat.white-balance/effect.wgsl
@@ -0,0 +1,11 @@
+struct Params { temperature: f32, tint: f32 }
+
+// The picture as if lit at `temperature` kelvin rather than the daylight it
+// was shot in - lower warmer, 6500 as shot - and turned towards magenta by
+// `tint`, minus towards green: the eye's own adaptation, in light (see
+// `white_balance`), a grey keeping its brightness. What the Adjust panel's
+// temperature and tint do, alone.
+fn effect(uv: vec2<f32>) -> vec4<f32> {
+ let c = sample(uv);
+ return vec4<f32>(white_balance(c.rgb, params.temperature, params.tint), c.a);
+}
diff --git a/src/crates/concat-effects/packages/concat.white-balance/fixtures.toml b/src/crates/concat-effects/packages/concat.white-balance/fixtures.toml
new file mode 100644
index 00000000..e45cac28
--- /dev/null
+++ b/src/crates/concat-effects/packages/concat.white-balance/fixtures.toml
@@ -0,0 +1,39 @@
+# A von Kries scaling of Bradford's cone responses from the light at 6500 K
+# to the light asked for, a grey keeping its brightness: warmer below 6500,
+# cooler above, magenta for a positive tint. Past white it scales the light
+# like any other level.
+
+[[probe]]
+name = "default"
+input = [0.3, 0.2, 0.12, 1]
+expect = [0.3, 0.2, 0.12, 1]
+
+[[probe]]
+name = "minimum, candlelight and green"
+at = "min"
+input = [0.18, 0.18, 0.18, 1]
+expect = [0.385013, 0.152618, -0.152439, 1]
+
+[[probe]]
+name = "maximum, blue sky and magenta"
+at = "max"
+input = [0.18, 0.18, 0.18, 1]
+expect = [0.36901, 0.103865, 0.377625, 1]
+
+[[probe]]
+name = "tungsten"
+params = { temperature = 3200 }
+input = [0.18, 0.18, 0.18, 1]
+expect = [0.29346, 0.158766, 0.0562451, 1]
+
+[[probe]]
+name = "tungsten, a highlight past white"
+params = { temperature = 3200 }
+input = [4.0, 4.0, 4.0, 1]
+expect = [6.52133, 3.52814, 1.24989, 1]
+
+[[probe]]
+name = "a magenta tint"
+params = { tint = 30 }
+input = [0.3, 0.2, 0.12, 1]
+expect = [0.368792, 0.177089, 0.150857, 1]
diff --git a/src/crates/concat-effects/src/lib.rs b/src/crates/concat-effects/src/lib.rs
index 9fff1ec4..b1c0bfe6 100644
--- a/src/crates/concat-effects/src/lib.rs
+++ b/src/crates/concat-effects/src/lib.rs
@@ -28,6 +28,7 @@ pub mod catalogue;
pub mod cube;
pub mod expr;
pub mod filters;
+pub mod looks;
pub mod manifest;
pub mod shader;
pub mod template;
diff --git a/src/crates/concat-effects/src/looks.rs b/src/crates/concat-effects/src/looks.rs
new file mode 100644
index 00000000..b5ec7f0c
--- /dev/null
+++ b/src/crates/concat-effects/src/looks.rs
@@ -0,0 +1,285 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! Looks made from `.cube` tables.
+//!
+//! A table from a grading tool becomes a package folder of its own: a
+//! manifest, a shader that reads the table and nothing else, and the table
+//! beside them. The package is a look - a filter, mixed by intensity - drawn
+//! on the GPU in the space its table was made for: the display encoding, for
+//! nearly every table there is (a creative look, or a camera's log to Rec.
+//! 709 over footage read as it was recorded), or log for a table made for
+//! ACEScct. Either way a level past the table's ends is carried on past
+//! them (`look()` in the shader prelude), so a highlight keeps its place
+//! above the table's white.
+//!
+//! Earlier builds made a format 1 package of a table, run through the
+//! wrapper that hands it the gamma-encoded picture; [`upgrade`] rewrites
+//! those onto the format 2 look, the same table read the same way on SDR.
+
+use std::path::Path;
+
+use crate::manifest::{Kind, Manifest, Space};
+
+/// What a look's table is called in its folder.
+pub const TABLE: &str = "look.cube";
+
+/// The shader every look made from a table runs.
+pub const SHADER: &str = "// The table, carried past its ends, and nothing else; the host mixes it\n\
+ // by intensity.\n\
+ fn effect(uv: vec2<f32>) -> vec4<f32> {\n let c = sample(uv);\n return vec4<f32>(look(c.rgb), c.a);\n}\n";
+
+/// The shader earlier builds wrote for a table, as it reads with its
+/// comments and spacing taken out.
+const FORMAT_1_SHADER: &str =
+ "fneffect(uv:vec2<f32>)->vec4<f32>{letc=sample(uv);returnvec4<f32>(lut(c.rgb),c.a);}";
+
+/// The space a table is read in: log for one made for ACEScct, which its
+/// file's name or its title says, and the display encoding for the rest.
+pub fn space_of(path: &Path, table: &str) -> Space {
+ let title = table
+ .lines()
+ .find_map(|line| line.trim().strip_prefix("TITLE"))
+ .unwrap_or("");
+ let name = path
+ .file_stem()
+ .map(|stem| stem.to_string_lossy().into_owned())
+ .unwrap_or_default();
+ let said = |text: &str| text.to_ascii_lowercase().contains("acescct");
+ if said(&name) || said(title) {
+ Space::Log
+ } else {
+ Space::Display
+ }
+}
+
+/// The manifest of the look `id`, called `name`, reading the table `file`
+/// in `space`.
+pub fn manifest(id: &str, name: &str, file: &str, space: Space) -> String {
+ let space = match space {
+ Space::Log => "log",
+ Space::Linear | Space::Display => "display",
+ };
+ format!(
+ "format = 2\n\n[effect]\nid = \"{id}\"\nname = {name:?}\nkind = \"filter\"\ncategory = \"Imported\"\n\
+ description = \"A look imported from a .cube table.\"\n\n[lut]\nfile = {file:?}\n\n\
+ [wgsl]\nentry = \"effect.wgsl\"\nspace = \"{space}\"\n"
+ )
+}
+
+/// Makes a package folder under `dir` from the table at `path`, and
+/// returns the package's id: `user.` and the file's name, slugged. A second
+/// import of the same name replaces the first.
+pub fn import(dir: &Path, path: &Path) -> Result<String, String> {
+ let stem = path
+ .file_stem()
+ .map(|stem| stem.to_string_lossy().into_owned())
+ .unwrap_or_default();
+ let mut slug: String = stem
+ .to_lowercase()
+ .chars()
+ .map(|c| if c.is_ascii_alphanumeric() { c } else { '-' })
+ .collect::<String>()
+ .split('-')
+ .filter(|part| !part.is_empty())
+ .collect::<Vec<_>>()
+ .join("-");
+ if slug.is_empty() {
+ slug = "look".to_owned();
+ }
+ let id = format!("user.{slug}");
+ let text = std::fs::read_to_string(path).map_err(|error| error.to_string())?;
+ crate::cube::parse(&text)?;
+ let folder = dir.join(&id);
+ std::fs::create_dir_all(&folder).map_err(|error| error.to_string())?;
+ let written = manifest(&id, stem.trim(), TABLE, space_of(path, &text));
+ std::fs::write(folder.join("effect.toml"), written).map_err(|error| error.to_string())?;
+ std::fs::write(folder.join("effect.wgsl"), SHADER).map_err(|error| error.to_string())?;
+ std::fs::write(folder.join(TABLE), &text).map_err(|error| error.to_string())?;
+ // A still an earlier import drew for this name: the card drawn from the
+ // package's own shader replaces it.
+ let _ = std::fs::remove_file(folder.join("preview.png"));
+ Ok(id)
+}
+
+/// Rewrites every look an earlier build made from a table in `dir` onto
+/// the format 2 look, in the display encoding it was read in, and returns
+/// their ids. A look is known by its shape - a filter of the user's with a
+/// table, no knobs, and the one-line shader the import wrote - so a package
+/// someone wrote by hand is left alone, and a look already rewritten is not
+/// touched again. One whose folder cannot be written keeps loading as it
+/// was.
+pub fn upgrade(dir: &Path) -> Vec<String> {
+ let Ok(folders) = crate::catalogue::package_folders(dir) else {
+ return Vec::new();
+ };
+ let mut upgraded = Vec::new();
+ for folder in folders {
+ let read = |name: &str| std::fs::read_to_string(folder.join(name)).ok();
+ let (Some(text), Some(shader)) = (read("effect.toml"), read("effect.wgsl")) else {
+ continue;
+ };
+ let Ok(old) = Manifest::parse(&text) else {
+ continue;
+ };
+ let chained = old
+ .ffmpeg
+ .as_ref()
+ .is_none_or(|ffmpeg| ffmpeg.chain == "lut3d=file={lut}" && ffmpeg.lets.is_empty());
+ let Some(table) = &old.lut else {
+ continue;
+ };
+ let imported = !old.scene_linear()
+ && old.effect.kind == Kind::Filter
+ && old.effect.id.starts_with("user.")
+ && old.params.is_empty()
+ && old.wgsl.is_some()
+ && chained
+ && bare(&shader) == FORMAT_1_SHADER;
+ if !imported {
+ continue;
+ }
+ let written = manifest(
+ &old.effect.id,
+ &old.effect.name,
+ &table.file,
+ Space::Display,
+ );
+ let wrote = std::fs::write(folder.join("effect.wgsl"), SHADER)
+ .and_then(|()| std::fs::write(folder.join("effect.toml"), written));
+ if wrote.is_ok() {
+ let _ = std::fs::remove_file(folder.join("preview.png"));
+ upgraded.push(old.effect.id.clone());
+ }
+ }
+ upgraded
+}
+
+/// A shader's text with its comments and whitespace taken out: what two
+/// spellings of one shader have in common.
+fn bare(shader: &str) -> String {
+ shader
+ .lines()
+ .map(|line| line.split("//").next().unwrap_or(""))
+ .flat_map(str::chars)
+ .filter(|c| !c.is_whitespace())
+ .collect()
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::catalogue::{Catalogue, Package};
+
+ fn scratch(name: &str) -> std::path::PathBuf {
+ let dir = std::env::temp_dir().join(format!("concat-looks-{}-{name}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&dir);
+ std::fs::create_dir_all(&dir).expect("a scratch folder");
+ dir
+ }
+
+ fn table(title: &str) -> String {
+ let mut text = format!("TITLE \"{title}\"\nLUT_3D_SIZE 2\n");
+ for b in 0..2 {
+ for g in 0..2 {
+ for r in 0..2 {
+ text.push_str(&format!("{r} {} {b}\n", g as f32 * 0.5));
+ }
+ }
+ }
+ text
+ }
+
+ /// An imported table is a format 2 look that loads, reads its table in
+ /// the display encoding or, for one made for ACEScct, in log, and
+ /// carries a level past the table's ends.
+ #[test]
+ fn a_table_imports_as_a_format_2_look() {
+ let dir = scratch("import");
+ let source = dir.join("Teal & Orange v2.cube");
+ std::fs::write(&source, table("Teal")).expect("a table");
+ let looks = dir.join("looks");
+ let id = import(&looks, &source).expect("imports");
+ assert_eq!(id, "user.teal-orange-v2");
+ let package = Package::from_folder(&looks.join(&id)).expect("loads");
+ assert!(package.manifest.scene_linear());
+ assert_eq!(package.manifest.effect.name, "Teal & Orange v2");
+ assert_eq!(
+ package.manifest.wgsl.as_ref().map(|wgsl| wgsl.space),
+ Some(Space::Display)
+ );
+ assert!(
+ package
+ .shader()
+ .is_some_and(|shader| shader.source().contains("look(c.rgb)"))
+ );
+ assert_eq!(package.lut().map(|lut| lut.size), Some(2));
+
+ let log = dir.join("Film.cube");
+ std::fs::write(&log, table("Film emulation ACEScct")).expect("a table");
+ let id = import(&looks, &log).expect("imports");
+ let package = Package::from_folder(&looks.join(&id)).expect("loads");
+ assert_eq!(
+ package.manifest.wgsl.as_ref().map(|wgsl| wgsl.space),
+ Some(Space::Log)
+ );
+ assert!(import(&looks, &dir.join("missing.cube")).is_err());
+ let _ = std::fs::remove_dir_all(&dir);
+ }
+
+ /// A look an earlier build imported is rewritten onto the format 2 look,
+ /// once; a package of the same shape written by hand with anything
+ /// more in it is left as it was.
+ #[test]
+ fn an_earlier_import_is_rewritten_once() {
+ let dir = scratch("upgrade");
+ let write = |id: &str, shader: &str, chain: bool| {
+ let folder = dir.join(id);
+ std::fs::create_dir_all(&folder).expect("a folder");
+ let chain = if chain {
+ "[ffmpeg]\nchain = \"lut3d=file={lut}\"\n\n"
+ } else {
+ ""
+ };
+ std::fs::write(
+ folder.join("effect.toml"),
+ format!(
+ "format = 1\n\n[effect]\nid = \"{id}\"\nname = \"Old\"\nkind = \"filter\"\n\
+ category = \"Imported\"\ndescription = \"A look imported from a .cube table.\"\n\n\
+ [lut]\nfile = \"look.cube\"\n\n{chain}[wgsl]\nentry = \"effect.wgsl\"\n"
+ ),
+ )
+ .expect("a manifest");
+ std::fs::write(folder.join("effect.wgsl"), shader).expect("a shader");
+ std::fs::write(folder.join(TABLE), table("Old")).expect("a table");
+ std::fs::write(folder.join("preview.png"), b"old").expect("a still");
+ };
+ let imported = "// The table, and nothing else; the host mixes it by intensity.\n\
+ fn effect(uv: vec2<f32>) -> vec4<f32> {\n let c = sample(uv);\n return vec4<f32>(lut(c.rgb), c.a);\n}\n";
+ write("user.old", imported, true);
+ write(
+ "user.older",
+ "fn effect(uv: vec2<f32>) -> vec4<f32> { let c = sample(uv); return vec4<f32>(lut(c.rgb), c.a); }",
+ false,
+ );
+ write(
+ "user.mine",
+ "fn effect(uv: vec2<f32>) -> vec4<f32> { let c = sample(uv); return vec4<f32>(lut(c.rgb) * 0.9, c.a); }",
+ true,
+ );
+ let mut upgraded = upgrade(&dir);
+ upgraded.sort();
+ assert_eq!(upgraded, ["user.old", "user.older"]);
+ assert!(upgrade(&dir).is_empty(), "once");
+ let package = Package::from_folder(&dir.join("user.old")).expect("loads");
+ assert!(package.manifest.scene_linear());
+ assert_eq!(package.manifest.effect.name, "Old");
+ assert!(package.manifest.ffmpeg.is_none());
+ assert!(!dir.join("user.old").join("preview.png").exists());
+ let mine = Package::from_folder(&dir.join("user.mine")).expect("loads");
+ assert!(!mine.manifest.scene_linear(), "a package of someone's own");
+ let mut catalogue = Catalogue::new();
+ assert!(catalogue.load_dir(&dir).is_empty());
+ let _ = std::fs::remove_dir_all(&dir);
+ }
+}
diff --git a/src/crates/concat-effects/src/manifest.rs b/src/crates/concat-effects/src/manifest.rs
index 0656095b..056f8062 100644
--- a/src/crates/concat-effects/src/manifest.rs
+++ b/src/crates/concat-effects/src/manifest.rs
@@ -282,6 +282,11 @@ pub enum Space {
/// clipped. Where a colour look drawn by eye on an SDR picture reads as
/// it was drawn; its result is taken back into light and mixed there.
Display,
+ /// Log: ACEScct's curve over the working space, every level of light
+ /// from black to far past white between 0 and 1. Where a table made
+ /// for ACEScct is read; its result is taken back into light and mixed
+ /// there.
+ Log,
}
/// The `[transition]` table: a two-input shader that combines the outgoing
@@ -852,8 +857,15 @@ mod tests {
let manifest = Manifest::parse(&format!("format = 2\n{display}")).expect("parses");
assert_eq!(manifest.wgsl.map(|wgsl| wgsl.space), Some(Space::Display));
rejects(&display, "format 2 setting");
+ let log = display.replace("\"display\"", "\"log\"");
+ let manifest = Manifest::parse(&format!("format = 2\n{log}")).expect("parses");
+ assert_eq!(manifest.wgsl.map(|wgsl| wgsl.space), Some(Space::Log));
+ rejects(&log, "format 2 setting");
rejects(
- &format!("format = 2\n{}", display.replace("\"display\"", "\"log\"")),
+ &format!(
+ "format = 2\n{}",
+ display.replace("\"display\"", "\"gamma\"")
+ ),
"unknown variant",
);
}
diff --git a/src/crates/concat-effects/src/shader.rs b/src/crates/concat-effects/src/shader.rs
index db4727f1..fbeddd4d 100644
--- a/src/crates/concat-effects/src/shader.rs
+++ b/src/crates/concat-effects/src/shader.rs
@@ -122,6 +122,17 @@ fn sample(uv: vec2<f32>) -> vec4<f32> {
}
"#;
+/// An effect's `sample` under the scene-linear contract in log.
+const EFFECT_SAMPLE_LOG: &str = r#"
+/// The layer's colour at `uv`, straight alpha, in log (see `to_log`): the
+/// space a table made for ACEScct reads, and where every level of light,
+/// far past white, has a place between 0 and 1.
+fn sample(uv: vec2<f32>) -> vec4<f32> {
+ let c = textureSample(source, source_sampler, uv);
+ return vec4<f32>(to_log(c.rgb), c.a);
+}
+"#;
+
/// What a transition's shader binds: the outgoing picture and the incoming
/// one at group 0, the frame block - its spare slot the progress - and the
/// parameters at group 1, the table at group 2, and no reveal map.
@@ -793,6 +804,23 @@ fn to_display(rgb: vec3<f32>) -> vec3<f32> {
fn from_display(encoded: vec3<f32>) -> vec3<f32> {
return sign(encoded) * pow(abs(encoded), vec3<f32>(2.4));
}
+
+/// A colour held to what the working space's half floats store: a knob
+/// pushed to its end makes the brightest light there is, never infinity,
+/// which every pass after it would carry on as no number at all.
+fn held(colour: vec4<f32>) -> vec4<f32> {
+ return clamp(colour, vec4<f32>(-65504.0), vec4<f32>(65504.0));
+}
+
+/// The package's look-up table over a colour of the space its shader works
+/// in - the display encoding, or log - whose table spans 0 to 1: a level
+/// past either end is carried on past it by as much, where `lut` holds it
+/// at the end, so a highlight past white keeps its place above the table's
+/// white. The colour as it was when the package ships no table.
+fn look(rgb: vec3<f32>) -> vec3<f32> {
+ let inside = clamp(rgb, vec3<f32>(0.0), vec3<f32>(1.0));
+ return lut(inside) + (rgb - inside);
+}
"#;
/// The format 2 library: helpers that hold for any level of light.
@@ -832,12 +860,14 @@ fn from_log(log: vec3<f32>) -> vec3<f32> {
return select(curve, toe, log <= vec3<f32>(0.155251141552511));
}
-/// Contrast about middle grey, in log: 1 as shot, 0 flat grey, 2 every
-/// level twice as many stops from grey. Grey stays where it is, and a
-/// highlight above white is pushed or pulled like any other level.
+/// Contrast about middle grey, in stops: 1 as shot, 0 flat grey, 2 every
+/// level twice as many stops from grey. Grey stays where it is, a highlight
+/// above white is pushed or pulled like any other level, and however hard
+/// the push, a level of light never goes below black: a channel with none
+/// is left as it was.
fn contrast(rgb: vec3<f32>, amount: f32) -> vec3<f32> {
- let grey = to_log(vec3<f32>(MID_GREY));
- return from_log((to_log(rgb) - grey) * amount + grey);
+ let pushed = MID_GREY * pow(max(rgb, vec3<f32>(1e-10)) / MID_GREY, vec3<f32>(amount));
+ return select(rgb, min(pushed, vec3<f32>(65504.0)), rgb > vec3<f32>(0.0));
}
/// Saturation about luminance, in light: 1 as shot, 0 grey, above 1
@@ -846,6 +876,75 @@ fn contrast(rgb: vec3<f32>, amount: f32) -> vec3<f32> {
fn saturation(rgb: vec3<f32>, amount: f32) -> vec3<f32> {
return mix(vec3<f32>(luma(rgb)), rgb, amount);
}
+
+/// CIE XYZ into cone responses, by Bradford's matrix: where a white balance
+/// is worked out, as the eye adapts to the light.
+const BRADFORD: mat3x3<f32> = mat3x3<f32>(
+ vec3<f32>(0.8951, -0.7502, 0.0389),
+ vec3<f32>(0.2664, 1.7135, -0.0685),
+ vec3<f32>(-0.1614, 0.0367, 1.0296),
+);
+
+/// Light on Rec. 709's primaries into Bradford's cone responses, and back.
+const CONES: mat3x3<f32> = mat3x3<f32>(
+ vec3<f32>(0.4227252927, 0.0556997770, 0.0213826437),
+ vec3<f32>(0.4913453244, 0.9615340509, 0.0876418678),
+ vec3<f32>(0.0273579445, 0.0231838105, 0.9805081326),
+);
+const FROM_CONES: mat3x3<f32> = mat3x3<f32>(
+ vec3<f32>(2.5380445168, -0.1460040576, -0.0422985104),
+ vec3<f32>(-1.2932769979, 1.1166483055, -0.0716072203),
+ vec3<f32>(-0.0402368843, -0.0223290262, 1.0227526883),
+);
+
+/// Where a black body at `kelvin` sits in CIE 1960's (u, v): Kim et al.'s
+/// cubic fit to the Planckian locus, 1667 K to 25000 K.
+fn planckian(kelvin: f32) -> vec2<f32> {
+ let t = clamp(kelvin, 1667.0, 25000.0);
+ let k = 1000.0 / t;
+ var x: f32;
+ if (t <= 4000.0) {
+ x = ((-0.2661239 * k - 0.2343589) * k + 0.8776956) * k + 0.179910;
+ } else {
+ x = ((-3.0258469 * k + 2.1070379) * k + 0.2226347) * k + 0.240390;
+ }
+ var y: f32;
+ if (t <= 2222.0) {
+ y = ((-1.1063814 * x - 1.34811020) * x + 2.18555832) * x - 0.20219683;
+ } else if (t <= 4000.0) {
+ y = ((-0.9549476 * x - 1.37418593) * x + 2.09137015) * x - 0.16748867;
+ } else {
+ y = ((3.0817580 * x - 5.87338670) * x + 3.75112997) * x - 0.37001483;
+ }
+ return vec2<f32>(4.0 * x, 6.0 * y) / (-2.0 * x + 12.0 * y + 3.0);
+}
+
+/// The white of light at `kelvin`, moved `tint` across the locus towards
+/// magenta - 100 is 0.07 in (u, v), minus towards green - as cone
+/// responses.
+fn white_cones(kelvin: f32, tint: f32) -> vec3<f32> {
+ let here = planckian(kelvin);
+ let along = normalize(planckian(kelvin * 1.01) - here);
+ let across = vec2<f32>(along.y, -along.x);
+ let magenta = select(across, -across, across.y > 0.0);
+ let uv = here + magenta * (tint * 0.0007);
+ let d = 2.0 * uv.x - 8.0 * uv.y + 4.0;
+ let x = 3.0 * uv.x / d;
+ let y = 2.0 * uv.y / d;
+ return BRADFORD * vec3<f32>(x / y, 1.0, (1.0 - x - y) / y);
+}
+
+/// White balance: the picture as if lit at `kelvin` - lower warmer, 6500
+/// as shot - and `tint` towards magenta, minus towards green, 0 as shot.
+/// The eye's own adaptation, a von Kries scaling of Bradford's cone
+/// responses from the light at 6500 K to the light asked for, in light,
+/// so a highlight is balanced like any other level; a grey keeps its
+/// brightness.
+fn white_balance(rgb: vec3<f32>, kelvin: f32, tint: f32) -> vec3<f32> {
+ let gains = white_cones(kelvin, tint) / white_cones(6500.0, 0.0);
+ let adapt = FROM_CONES * mat3x3<f32>(CONES[0] * gains, CONES[1] * gains, CONES[2] * gains);
+ return adapt * rgb / luma(adapt * vec3<f32>(1.0));
+}
"#;
/// The vertex stage every shader draws with: one triangle over the whole
@@ -879,13 +978,14 @@ fn fs_main(in: VsOut) -> @location(0) vec4<f32> {
"#;
/// An effect's fragment under the scene-linear contract: the package's
-/// colour mixed over the untouched layer by intensity, in light.
+/// colour mixed over the untouched layer by intensity, in light, and held
+/// to what the working space's half floats store (see `held`).
const EFFECT_FRAGMENT_LINEAR: &str = r#"
@fragment
fn fs_main(in: VsOut) -> @location(0) vec4<f32> {
let base = sample(in.uv);
let treated = effect(in.uv);
- return mix(base, treated, clamp(frame.intensity, 0.0, 1.0));
+ return held(mix(base, treated, clamp(frame.intensity, 0.0, 1.0)));
}
"#;
@@ -897,7 +997,19 @@ fn fs_main(in: VsOut) -> @location(0) vec4<f32> {
let base = textureSample(source, source_sampler, in.uv);
let treated = effect(in.uv);
let light = vec4<f32>(from_display(treated.rgb), treated.a);
- return mix(base, light, clamp(frame.intensity, 0.0, 1.0));
+ return held(mix(base, light, clamp(frame.intensity, 0.0, 1.0)));
+}
+"#;
+
+/// An effect's fragment in log: the package's colour taken back into light,
+/// then mixed over the untouched layer by intensity there.
+const EFFECT_FRAGMENT_LOG: &str = r#"
+@fragment
+fn fs_main(in: VsOut) -> @location(0) vec4<f32> {
+ let base = textureSample(source, source_sampler, in.uv);
+ let treated = effect(in.uv);
+ let light = vec4<f32>(from_log(treated.rgb), treated.a);
+ return held(mix(base, light, clamp(frame.intensity, 0.0, 1.0)));
}
"#;
@@ -932,19 +1044,24 @@ pub enum Contract {
/// encoding, unclipped, the display-space library, and the result
/// taken back into light and mixed there.
Display,
+ /// Format 2 on, `space = "log"`: the picture in log (ACEScct), the
+ /// scene-linear library, and the result taken back into light and mixed
+ /// there - where a table made for ACEScct is read.
+ Log,
}
impl Contract {
/// The edition `manifest` asks for.
pub fn of(manifest: &Manifest) -> Contract {
- let display = manifest
+ let space = manifest
.wgsl
.as_ref()
- .is_some_and(|wgsl| wgsl.space == Space::Display);
- match (manifest.scene_linear(), display) {
+ .map_or(Space::Linear, |wgsl| wgsl.space);
+ match (manifest.scene_linear(), space) {
(false, _) => Contract::Legacy,
- (true, false) => Contract::Linear,
- (true, true) => Contract::Display,
+ (true, Space::Linear) => Contract::Linear,
+ (true, Space::Display) => Contract::Display,
+ (true, Space::Log) => Contract::Log,
}
}
@@ -961,13 +1078,14 @@ impl Contract {
(Entry::Effect, Contract::Display) => {
(EFFECT_HEAD, EFFECT_SAMPLE_DISPLAY, EFFECT_FRAGMENT_DISPLAY)
}
+ (Entry::Effect, Contract::Log) => (EFFECT_HEAD, EFFECT_SAMPLE_LOG, EFFECT_FRAGMENT_LOG),
(Entry::Transition, Contract::Legacy) => (
TRANSITION_HEAD,
TRANSITION_SAMPLE_LEGACY,
TRANSITION_FRAGMENT_LEGACY,
),
// A transition has no [wgsl] table to ask for another space.
- (Entry::Transition, Contract::Linear | Contract::Display) => (
+ (Entry::Transition, Contract::Linear | Contract::Display | Contract::Log) => (
TRANSITION_HEAD,
TRANSITION_SAMPLE_LINEAR,
TRANSITION_FRAGMENT_LINEAR,
@@ -1833,8 +1951,8 @@ fn effect(uv: vec2<f32>) -> vec4<f32> {
assert!(
linear
.source()
- .contains("return mix(base, treated, clamp(frame.intensity, 0.0, 1.0));"),
- "mixed in light"
+ .contains("return held(mix(base, treated, clamp(frame.intensity, 0.0, 1.0)));"),
+ "mixed in light, and held to what half floats store"
);
let clipping = Shader::compile(
&linear_manifest("effect", "wgsl"),
@@ -1855,6 +1973,25 @@ fn effect(uv: vec2<f32>) -> vec4<f32> {
);
assert!(legacy.source().contains("return legacy_out(mix("));
+ let log = Manifest::parse(
+ "format = 2\n[effect]\nid = \"test.log\"\nname = \"Log\"\nkind = \"filter\"\n\
+ [wgsl]\nentry = \"effect.wgsl\"\nspace = \"log\"\n",
+ )
+ .expect("a valid manifest");
+ assert_eq!(Contract::of(&log), Contract::Log);
+ let table = Shader::compile(
+ &log,
+ "fn effect(uv: vec2<f32>) -> vec4<f32> { let c = sample(uv); return vec4<f32>(look(c.rgb), c.a); }",
+ )
+ .expect("a table read in log");
+ assert!(
+ table
+ .source()
+ .contains("return vec4<f32>(to_log(c.rgb), c.a);")
+ && table.source().contains("from_log(treated.rgb)"),
+ "sampled in log and taken back into light"
+ );
+
let transition = TransitionShader::compile(
&linear_manifest("transition", "transition"),
"fn transition(uv: vec2<f32>, progress: f32) -> vec4<f32> {
diff --git a/src/crates/concat-render/src/gpu.rs b/src/crates/concat-render/src/gpu.rs
index 887c27bc..841f758b 100644
--- a/src/crates/concat-render/src/gpu.rs
+++ b/src/crates/concat-render/src/gpu.rs
@@ -2476,10 +2476,17 @@ impl WgpuCompositor {
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D3,
- format: wgpu::TextureFormat::Rgba8Unorm,
+ // Half floats, filterable everywhere: see `Lut` for why not
+ // bytes.
+ format: wgpu::TextureFormat::Rgba16Float,
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
view_formats: &[],
});
+ let halves: Vec<u8> = lut
+ .rgba
+ .iter()
+ .flat_map(|value| half::f16::from_f32(*value).to_le_bytes())
+ .collect();
self.queue.write_texture(
wgpu::TexelCopyTextureInfo {
texture: &texture,
@@ -2487,10 +2494,10 @@ impl WgpuCompositor {
origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All,
},
- &lut.rgba,
+ &halves,
wgpu::TexelCopyBufferLayout {
offset: 0,
- bytes_per_row: Some(size * 4),
+ bytes_per_row: Some(size * WORK_BYTES as u32),
rows_per_image: Some(size),
},
wgpu::Extent3d {
diff --git a/src/crates/concat-render/src/gpu/tests.rs b/src/crates/concat-render/src/gpu/tests.rs
index d8c05f36..37f63d99 100644
--- a/src/crates/concat-render/src/gpu/tests.rs
+++ b/src/crates/concat-render/src/gpu/tests.rs
@@ -1355,3 +1355,45 @@ fn a_stack_of_blurs_shares_its_pictures() {
// half of both.
assert!(gpu.pool.contains_key(&(32, 64)) && gpu.pool.contains_key(&(32, 32)));
}
+
+/// A look made from a table reads it in the space it was made for and
+/// carries a level past the table's ends on past them: through the
+/// identity, a highlight four times white comes out as it went in, read in
+/// the display encoding or in log. And a table's values come through finer
+/// than eight bits.
+#[test]
+fn a_table_is_read_in_its_space_and_carried_past_its_ends() {
+ let Some(mut gpu) = gpu() else { return };
+ let look = |space: &str, lut: Lut| {
+ let manifest = concat_effects::Manifest::parse(&format!(
+ "format = 2\n[effect]\nid = \"test.look\"\nname = \"Look\"\nkind = \"filter\"\n\
+ [wgsl]\nentry = \"effect.wgsl\"\nspace = \"{space}\"\n"
+ ))
+ .expect("a manifest");
+ concat_effects::Shader::compile(&manifest, concat_effects::looks::SHADER)
+ .expect("compiles")
+ .pass(&BTreeMap::new(), &[], 1.0, Some(Arc::new(lut)), None)
+ };
+ for space in ["display", "log"] {
+ let identity = look(space, Lut::identity(33));
+ for colour in [[4.0, 0.5, 0.02, 1.0], [0.18, 0.18, 0.18, 1.0]] {
+ let got = gpu
+ .probe(std::slice::from_ref(&identity), colour, 8, 0.0)
+ .expect("reads back");
+ assert!(
+ near(got, colour, 0.01),
+ "{space}: {colour:?} came out {got:?}"
+ );
+ }
+ }
+ // One colour everywhere, a value eight bits would round to 31/255.
+ let flat = Lut::from_rgb(2, &[0.123_456, 0.5, 0.25].repeat(8)).expect("a table");
+ let got = gpu
+ .probe(&[look("display", flat)], [0.3, 0.3, 0.3, 1.0], 8, 0.0)
+ .expect("reads back");
+ let want = [0.123_456f32, 0.5, 0.25].map(|level| level.powf(2.4));
+ assert!(
+ near(got, [want[0], want[1], want[2], 1.0], 0.004),
+ "{got:?} against {want:?}"
+ );
+}
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index f50c41f3..49f5ec56 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "Cloudless Sky",
"effects.colorCycle.description": "Sanfte Farbtondrehung über das gesamte Spektrum im Zeitverlauf.",
"effects.colorCycle.name": "Farbzyklus",
+ "effects.contrast.description": "Mehr oder weniger Kontrast in Blendenstufen um das mittlere Grau; Lichter über Weiß bleiben erhalten, Schwarz läuft nie zu.",
+ "effects.contrast.name": "Kontrast",
"effects.contrastPop.description": "Tiefere Schatten, hellere Lichter.",
"effects.contrastPop.name": "Kontrast-Pop",
"effects.cool.description": "Verschiebt das Bild in Richtung Tageslichtschatten.",
@@ -576,6 +578,8 @@
"effects.rosy.name": "Rosig",
"effects.sage.description": "Muted and green-teal through the midtones, a gentle film curve, warmth only where a face is. The quiet grade of an indie film.",
"effects.sage.name": "Sage",
+ "effects.saturation.description": "Kräftigere oder grauere Farbe, bezogen auf die eigene Helligkeit jedes Pixels.",
+ "effects.saturation.name": "Sättigung",
"effects.scanlines.description": "Dark lines across the picture every few pixels, the way a tube television drew it.",
"effects.scanlines.name": "Scanlines",
"effects.sciFi.description": "Ein kühles, steriles Grading in Stahl und Petrol, die Sättigung zurückgenommen.",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "Reißschwenk",
"effects.whisper.description": "Luftiger, hauchiger Klang mit gedämpften Tiefen und mehr Präsenz.",
"effects.whisper.name": "Flüstern",
+ "effects.whiteBalance.description": "Das Bild, als wäre es wärmer oder kühler beleuchtet, und zu Magenta oder Grün gedreht – so, wie sich das Auge an das Licht anpasst.",
+ "effects.whiteBalance.name": "Weißabgleich",
"effects.winterCool.description": "Entsättigt und blau, die Schwarztöne zu einem matten, winterlichen Dunst angehoben.",
"effects.winterCool.name": "Winterkühle",
"effects.wordReveal.description": "Die Wörter eines Titels erscheinen nacheinander, während der Clip läuft, in Lesereihenfolge.",
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index 7a95adb7..2b7cbf16 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "Cloudless Sky",
"effects.colorCycle.description": "Smooth temporal hue rotation across the entire spectrum.",
"effects.colorCycle.name": "Color Cycle",
+ "effects.contrast.description": "More or less contrast in stops about middle grey, highlights past white kept and black never crushed.",
+ "effects.contrast.name": "Contrast",
"effects.contrastPop.description": "Deeper shadows, brighter highlights.",
"effects.contrastPop.name": "Contrast Pop",
"effects.cool.description": "Shifts the picture towards daylight shade.",
@@ -576,6 +578,8 @@
"effects.rosy.name": "Rosy",
"effects.sage.description": "Muted and green-teal through the midtones, a gentle film curve, warmth only where a face is. The quiet grade of an indie film.",
"effects.sage.name": "Sage",
+ "effects.saturation.description": "Richer or greyer colour, about each pixel's own brightness.",
+ "effects.saturation.name": "Saturation",
"effects.scanlines.description": "Dark lines across the picture every few pixels, the way a tube television drew it.",
"effects.scanlines.name": "Scanlines",
"effects.sciFi.description": "A cool, sterile steel-and-teal grade, saturation held back.",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "Whip Pan",
"effects.whisper.description": "Airy, breathy tone with attenuated low end and enhanced presence.",
"effects.whisper.name": "Whisper",
+ "effects.whiteBalance.description": "The picture as if lit warmer or cooler, and turned towards magenta or green, as the eye adapts to the light.",
+ "effects.whiteBalance.name": "White Balance",
"effects.winterCool.description": "Desaturated and blue, the blacks lifted to a matte wintry haze.",
"effects.winterCool.name": "Winter Cool",
"effects.wordReveal.description": "A title's words appear one at a time as the clip plays, in reading order.",
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index 29908d65..0b74a6a5 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "Cloudless Sky",
"effects.colorCycle.description": "Rotación suave del matiz en el tiempo por todo el espectro.",
"effects.colorCycle.name": "Ciclo de color",
+ "effects.contrast.description": "Más o menos contraste en pasos de luz en torno al gris medio, sin perder las luces por encima del blanco ni empastar nunca el negro.",
+ "effects.contrast.name": "Contraste",
"effects.contrastPop.description": "Sombras más profundas, luces más brillantes.",
"effects.contrastPop.name": "Contraste vivo",
"effects.cool.description": "Lleva la imagen hacia la sombra de la luz del día.",
@@ -576,6 +578,8 @@
"effects.rosy.name": "Rosado",
"effects.sage.description": "Muted and green-teal through the midtones, a gentle film curve, warmth only where a face is. The quiet grade of an indie film.",
"effects.sage.name": "Sage",
+ "effects.saturation.description": "Color más intenso o más gris, en torno al propio brillo de cada píxel.",
+ "effects.saturation.name": "Saturación",
"effects.scanlines.description": "Dark lines across the picture every few pixels, the way a tube television drew it.",
"effects.scanlines.name": "Scanlines",
"effects.sciFi.description": "Un etalonaje frío y aséptico en acero y verde azulado, con la saturación contenida.",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "Barrido latigazo",
"effects.whisper.description": "Un tono aireado y susurrante, con los graves atenuados y la presencia realzada.",
"effects.whisper.name": "Susurro",
+ "effects.whiteBalance.description": "La imagen como si la iluminara una luz más cálida o más fría, y llevada hacia el magenta o el verde, como el ojo se adapta a la luz.",
+ "effects.whiteBalance.name": "Balance de blancos",
"effects.winterCool.description": "Desaturado y azul, con los negros levantados hasta una bruma invernal mate.",
"effects.winterCool.name": "Frío invernal",
"effects.wordReveal.description": "Las palabras de un título aparecen una a una mientras se reproduce el clip, en orden de lectura.",
diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.json
index 58567635..38b2213d 100644
--- a/src/crates/concat/locales/fa.json
+++ b/src/crates/concat/locales/fa.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "آسمان صاف",
"effects.colorCycle.description": "چرخش نرم و زمانی Hue در سراسر طیف رنگ.",
"effects.colorCycle.name": "چرخش رنگ",
+ "effects.contrast.description": "کنتراست بیشتر یا کمتر به اندازهٔ Stopها حول خاکستری میانی؛ هایلایت‌های فراتر از سفید حفظ می‌شوند و سیاه هرگز له نمی‌شود.",
+ "effects.contrast.name": "کنتراست",
"effects.contrastPop.description": "سایه‌های عمیق‌تر و هایلایت‌های روشن‌تر.",
"effects.contrastPop.name": "افزایش کنتراست",
"effects.cool.description": "تصویر را به سمت سایه نور روز سردتر می‌کند.",
@@ -576,6 +578,8 @@
"effects.rosy.name": "گلگون",
"effects.sage.description": "رنگهای Muted با سبز-Teal در Midtoneها، منحنی فیلم ملایم و گرمی فقط روی چهره؛ درجه‌بندی رنگ آرام یک فیلم مستقل.",
"effects.sage.name": "سبز مریم‌گلی",
+ "effects.saturation.description": "رنگ پرمایه‌تر یا خاکستری‌تر، حول روشنایی خود هر پیکسل.",
+ "effects.saturation.name": "اشباع",
"effects.scanlines.description": "خطوط تیره در سراسر تصویر با فاصله چند پیکسل، شبیه نحوه نمایش تلویزیون‌های Tube.",
"effects.scanlines.name": "خطوط اسکن",
"effects.sciFi.description": "درجه‌بندی رنگ سرد و بی‌روح فولادی-Teal با Saturation مهارشده.",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "پن سریع (Whip Pan)",
"effects.whisper.description": "صدایی سبک و نفس‌دار با فرکانس‌های پایین کم‌شده و Presence تقویت‌شده.",
"effects.whisper.name": "زمزمه",
+ "effects.whiteBalance.description": "تصویر گویی با نوری گرم‌تر یا سردتر روشن شده و به سوی ارغوانی یا سبز چرخیده است، همان‌گونه که چشم با نور سازگار می‌شود.",
+ "effects.whiteBalance.name": "تراز سفیدی (White Balance)",
"effects.winterCool.description": "کم‌رنگ و آبی، با سیاهی‌های بالا آمده تا یک مه زمستانی Matte.",
"effects.winterCool.name": "سرمای زمستانی",
"effects.wordReveal.description": "کلمات عنوان همراه با پخش کلیپ یکی‌یکی و به ترتیب خواندن ظاهر می‌شوند.",
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index bb584762..ffb02b2f 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "Cloudless Sky",
"effects.colorCycle.description": "Une rotation fluide de la teinte dans le temps, sur tout le spectre.",
"effects.colorCycle.name": "Cycle de couleurs",
+ "effects.contrast.description": "Plus ou moins de contraste, par diaphs autour du gris moyen : hautes lumières au-delà du blanc préservées, noir jamais bouché.",
+ "effects.contrast.name": "Contraste",
"effects.contrastPop.description": "Des ombres plus profondes, des hautes lumières plus vives.",
"effects.contrastPop.name": "Contraste vif",
"effects.cool.description": "Tire l'image vers l'ombre du jour.",
@@ -576,6 +578,8 @@
"effects.rosy.name": "Rosé",
"effects.sage.description": "Muted and green-teal through the midtones, a gentle film curve, warmth only where a face is. The quiet grade of an indie film.",
"effects.sage.name": "Sage",
+ "effects.saturation.description": "Des couleurs plus riches ou plus grises, autour de la luminosité propre à chaque pixel.",
+ "effects.saturation.name": "Saturation",
"effects.scanlines.description": "Dark lines across the picture every few pixels, the way a tube television drew it.",
"effects.scanlines.name": "Scanlines",
"effects.sciFi.description": "Un étalonnage froid et clinique, acier et sarcelle, la saturation contenue.",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "Panoramique fouetté",
"effects.whisper.description": "Un timbre aérien et soufflé, les graves atténués et la présence renforcée.",
"effects.whisper.name": "Chuchotement",
+ "effects.whiteBalance.description": "L'image comme éclairée plus chaud ou plus froid, et tirée vers le magenta ou le vert, comme l'œil s'adapte à la lumière.",
+ "effects.whiteBalance.name": "Balance des blancs",
"effects.winterCool.description": "Désaturé et bleu, les noirs relevés en une brume hivernale et mate.",
"effects.winterCool.name": "Froid hivernal",
"effects.wordReveal.description": "Les mots d'un titre apparaissent un à un pendant la lecture du clip, dans l'ordre de lecture.",
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index b700acb7..7c256962 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "Nebo bez oblaka",
"effects.colorCycle.description": "Glatka vremenska rotacija nijanse kroz cijeli spektar.",
"effects.colorCycle.name": "Ciklus boja",
+ "effects.contrast.description": "Više ili manje kontrasta u stupnjevima svjetla oko srednje sive; svjetla iznad bijele ostaju očuvana, a crna se nikad ne guši.",
+ "effects.contrast.name": "Kontrast",
"effects.contrastPop.description": "Dublje sjene, svjetlija svjetla.",
"effects.contrastPop.name": "Kontrastni pop",
"effects.cool.description": "Miče sliku prema sjeni dnevnog svjetla.",
@@ -576,6 +578,8 @@
"effects.rosy.name": "Ružičasto",
"effects.sage.description": "Prigušeno i zeleno-tirkizno kroz srednje tonove, nježna filmska krivulja, toplina samo gdje je lice. Tihi grade indie filma.",
"effects.sage.name": "Kadulja",
+ "effects.saturation.description": "Bogatija ili sivlja boja, u odnosu na vlastitu svjetlinu svakog piksela.",
+ "effects.saturation.name": "Zasićenje",
"effects.scanlines.description": "Tamne linije preko slike svakih nekoliko piksela, kao što ih je crtala cijevna televizija.",
"effects.scanlines.name": "Linije skeniranja",
"effects.sciFi.description": "Hladan, sterilan čelično-tirkizni grade, zasićenost suzdržana.",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "Brzo panoramiranje",
"effects.whisper.description": "Zračan, dahtav ton s prigušenim niskim tonovima i pojačanom prisutnošću.",
"effects.whisper.name": "Šapat",
+ "effects.whiteBalance.description": "Slika kao da je osvijetljena toplije ili hladnije te zakrenuta prema magenti ili zelenoj, kako se oko prilagođava svjetlu.",
+ "effects.whiteBalance.name": "Balans bijele",
"effects.winterCool.description": "Odzasićeno i plavo, crne podignute u mat zimsku izmaglicu.",
"effects.winterCool.name": "Zimska hladnoća",
"effects.wordReveal.description": "Riječi naslova pojavljuju se jedna po jedna dok klip svira, redom čitanja.",
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index 34f3788c..932fe3e8 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "Cloudless Sky",
"effects.colorCycle.description": "Una rotazione fluida della tonalità nel tempo, lungo tutto lo spettro.",
"effects.colorCycle.name": "Ciclo di colore",
+ "effects.contrast.description": "Più o meno contrasto in stop attorno al grigio medio, con le luci oltre il bianco preservate e il nero mai chiuso.",
+ "effects.contrast.name": "Contrasto",
"effects.contrastPop.description": "Ombre più profonde, luci più brillanti.",
"effects.contrastPop.name": "Contrasto vivo",
"effects.cool.description": "Sposta l'immagine verso l'ombra della luce diurna.",
@@ -576,6 +578,8 @@
"effects.rosy.name": "Roseo",
"effects.sage.description": "Muted and green-teal through the midtones, a gentle film curve, warmth only where a face is. The quiet grade of an indie film.",
"effects.sage.name": "Sage",
+ "effects.saturation.description": "Colore più ricco o più grigio, attorno alla luminosità propria di ogni pixel.",
+ "effects.saturation.name": "Saturazione",
"effects.scanlines.description": "Dark lines across the picture every few pixels, the way a tube television drew it.",
"effects.scanlines.name": "Scanlines",
"effects.sciFi.description": "Una gradazione fredda e asettica, acciaio e verde petrolio, con la saturazione trattenuta.",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "Panoramica a frusta",
"effects.whisper.description": "Un timbro arioso e soffiato, con i bassi attenuati e la presenza rafforzata.",
"effects.whisper.name": "Sussurro",
+ "effects.whiteBalance.description": "L'immagine come se fosse illuminata da una luce più calda o più fredda, e spostata verso il magenta o il verde, come l'occhio si adatta alla luce.",
+ "effects.whiteBalance.name": "Bilanciamento del bianco",
"effects.winterCool.description": "Desaturato e blu, con i neri sollevati in una foschia invernale opaca.",
"effects.winterCool.name": "Freddo invernale",
"effects.wordReveal.description": "Le parole di un titolo compaiono una alla volta mentre la clip scorre, in ordine di lettura.",
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index 17386c46..3cd06740 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "Cloudless Sky",
"effects.colorCycle.description": "全スペクトルにわたる、時間とともに滑らかに回る色相。",
"effects.colorCycle.name": "カラーサイクル",
+ "effects.contrast.description": "中間グレーを中心に段単位でコントラストを強めたり弱めたりします。白を超えるハイライトは保たれ、黒がつぶれることはありません。",
+ "effects.contrast.name": "コントラスト",
"effects.contrastPop.description": "シャドウをより深く、ハイライトをより明るく。",
"effects.contrastPop.name": "コントラストポップ",
"effects.cool.description": "画像を日陰の色へ寄せます。",
@@ -576,6 +578,8 @@
"effects.rosy.name": "ロージー",
"effects.sage.description": "Muted and green-teal through the midtones, a gentle film curve, warmth only where a face is. The quiet grade of an indie film.",
"effects.sage.name": "Sage",
+ "effects.saturation.description": "各ピクセル自身の明るさを中心に、色をより鮮やかに、またはよりグレーにします。",
+ "effects.saturation.name": "彩度",
"effects.scanlines.description": "Dark lines across the picture every few pixels, the way a tube television drew it.",
"effects.scanlines.name": "Scanlines",
"effects.sciFi.description": "彩度を抑えた、冷たく無機質なスチールとティールのグレード。",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "ウィップパン",
"effects.whisper.description": "低域を抑え存在感を高めた、空気感のある息まじりの音色。",
"effects.whisper.name": "ウィスパー",
+ "effects.whiteBalance.description": "目が光に順応するように、より暖かい光や冷たい光で照らしたかのように、またマゼンタやグリーン寄りにします。",
+ "effects.whiteBalance.name": "ホワイトバランス",
"effects.winterCool.description": "彩度を落として青みがかり、黒を持ち上げてマットな冬のもやに。",
"effects.winterCool.name": "ウィンタークール",
"effects.wordReveal.description": "クリップの再生に合わせて、タイトルの言葉が読む順に一つずつ現れます。",
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index c67fecf4..149dfa3a 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "Cloudless Sky",
"effects.colorCycle.description": "전체 스펙트럼을 매끄럽게 도는 색조 회전.",
"effects.colorCycle.name": "색상 순환",
+ "effects.contrast.description": "중간 회색을 기준으로 스톱 단위로 대비를 높이거나 낮춥니다. 흰색을 넘는 하이라이트는 유지되고 검은색은 뭉개지지 않습니다.",
+ "effects.contrast.name": "대비",
"effects.contrastPop.description": "더 깊은 어둠, 더 밝은 하이라이트.",
"effects.contrastPop.name": "선명한 대비",
"effects.cool.description": "화면을 한낮의 그늘 쪽으로 옮깁니다.",
@@ -576,6 +578,8 @@
"effects.rosy.name": "장밋빛",
"effects.sage.description": "Muted and green-teal through the midtones, a gentle film curve, warmth only where a face is. The quiet grade of an indie film.",
"effects.sage.name": "Sage",
+ "effects.saturation.description": "각 픽셀 자체의 밝기를 기준으로 색을 더 풍부하게 또는 더 회색으로 만듭니다.",
+ "effects.saturation.name": "채도",
"effects.scanlines.description": "Dark lines across the picture every few pixels, the way a tube television drew it.",
"effects.scanlines.name": "Scanlines",
"effects.sciFi.description": "채도를 억누른 차갑고 무기질적인 강철빛과 청록의 색보정.",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "휩 팬",
"effects.whisper.description": "저음을 줄이고 존재감을 살린, 가볍고 숨결 섞인 음색.",
"effects.whisper.name": "속삭임",
+ "effects.whiteBalance.description": "눈이 빛에 적응하듯, 더 따뜻하거나 차가운 빛으로 비춘 것처럼 바꾸고 마젠타나 녹색 쪽으로 돌립니다.",
+ "effects.whiteBalance.name": "화이트 밸런스",
"effects.winterCool.description": "채도를 뺀 푸른빛에 블랙을 들어 올려 겨울 안개처럼 매트한 느낌.",
"effects.winterCool.name": "겨울의 차가움",
"effects.wordReveal.description": "클립이 재생되는 동안 자막의 단어가 읽는 순서대로 하나씩 나타납니다.",
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index d0ad7e03..39eb7fed 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "Cloudless Sky",
"effects.colorCycle.description": "Rotação temporal suave do matiz por todo o espectro.",
"effects.colorCycle.name": "Ciclo de cores",
+ "effects.contrast.description": "Mais ou menos contraste em stops em torno do cinza médio, preservando os realces acima do branco e sem nunca esmagar o preto.",
+ "effects.contrast.name": "Contraste",
"effects.contrastPop.description": "Sombras mais profundas, realces mais brilhantes.",
"effects.contrastPop.name": "Contraste vivo",
"effects.cool.description": "Puxa a imagem para a sombra da luz do dia.",
@@ -576,6 +578,8 @@
"effects.rosy.name": "Rosado",
"effects.sage.description": "Muted and green-teal through the midtones, a gentle film curve, warmth only where a face is. The quiet grade of an indie film.",
"effects.sage.name": "Sage",
+ "effects.saturation.description": "Cores mais ricas ou mais acinzentadas, em torno do próprio brilho de cada pixel.",
+ "effects.saturation.name": "Saturação",
"effects.scanlines.description": "Dark lines across the picture every few pixels, the way a tube television drew it.",
"effects.scanlines.name": "Scanlines",
"effects.sciFi.description": "Uma gradação fria e estéril de aço e teal, com a saturação contida.",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "Panorâmica chicote",
"effects.whisper.description": "Tom arejado e soproso, com graves atenuados e presença realçada.",
"effects.whisper.name": "Sussurro",
+ "effects.whiteBalance.description": "A imagem como se iluminada por uma luz mais quente ou mais fria, e puxada para o magenta ou o verde, como o olho se adapta à luz.",
+ "effects.whiteBalance.name": "Balanço de branco",
"effects.winterCool.description": "Dessaturado e azul, com os pretos elevados a uma névoa fosca de inverno.",
"effects.winterCool.name": "Frio de inverno",
"effects.wordReveal.description": "As palavras de um título aparecem uma de cada vez enquanto o clipe toca, na ordem de leitura.",
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index c3c3a324..d2aeb85a 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "Безоблачное небо",
"effects.colorCycle.description": "Плавное вращение оттенка во времени по всему спектру.",
"effects.colorCycle.name": "Цикл цвета",
+ "effects.contrast.description": "Больше или меньше контраста в стопах вокруг среднего серого: света выше белого сохраняются, а чёрный никогда не заваливается.",
+ "effects.contrast.name": "Контраст",
"effects.contrastPop.description": "Глубже тени, ярче света.",
"effects.contrastPop.name": "Сочный контраст",
"effects.cool.description": "Сдвигает картинку к дневной тени.",
@@ -576,6 +578,8 @@
"effects.rosy.name": "Румянец",
"effects.sage.description": "Приглушённо и зелёно-бирюзово в средних тонах, мягкая плёночная кривая, тепло только там, где лицо. Тихая цветокоррекция инди-фильма.",
"effects.sage.name": "Шалфей",
+ "effects.saturation.description": "Более насыщенный или более серый цвет — относительно собственной яркости каждого пикселя.",
+ "effects.saturation.name": "Насыщенность",
"effects.scanlines.description": "Тёмные линии через каждые несколько пикселей — так рисовал кинескопный телевизор.",
"effects.scanlines.name": "Строки развёртки",
"effects.sciFi.description": "Холодная стерильная сталь с бирюзой, насыщенность сдержана.",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "Резкая панорама",
"effects.whisper.description": "Воздушный, дыхательный тон с приглушённым низом и усиленным присутствием.",
"effects.whisper.name": "Шёпот",
+ "effects.whiteBalance.description": "Изображение, словно освещённое более тёплым или холодным светом и сдвинутое к пурпурному или зелёному, — так глаз привыкает к свету.",
+ "effects.whiteBalance.name": "Баланс белого",
"effects.winterCool.description": "Обесцвечено и сине, чёрные приподняты до матовой зимней дымки.",
"effects.winterCool.name": "Зимний холод",
"effects.wordReveal.description": "Слова титра появляются по одному по ходу клипа, в порядке чтения.",
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index dacec407..71f8eb33 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "Cloudless Sky",
"effects.colorCycle.description": "Tüm tayf boyunca zamanla yumuşak ton döndürmesi.",
"effects.colorCycle.name": "Renk döngüsü",
+ "effects.contrast.description": "Orta gri çevresinde, durak durak daha fazla ya da daha az kontrast; beyazın ötesindeki ışıklar korunur, siyah asla ezilmez.",
+ "effects.contrast.name": "Kontrast",
"effects.contrastPop.description": "Daha derin gölgeler, daha parlak ışıklar.",
"effects.contrastPop.name": "Canlı kontrast",
"effects.cool.description": "Görüntüyü gün ışığı gölgesine doğru kaydırır.",
@@ -576,6 +578,8 @@
"effects.rosy.name": "Pembemsi",
"effects.sage.description": "Muted and green-teal through the midtones, a gentle film curve, warmth only where a face is. The quiet grade of an indie film.",
"effects.sage.name": "Sage",
+ "effects.saturation.description": "Her pikselin kendi parlaklığı çevresinde daha zengin ya da daha gri renk.",
+ "effects.saturation.name": "Doygunluk",
"effects.scanlines.description": "Dark lines across the picture every few pixels, the way a tube television drew it.",
"effects.scanlines.name": "Scanlines",
"effects.sciFi.description": "Soğuk, steril bir çelik ve turkuaz renklendirmesi; doygunluk geride tutulmuş.",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "Hızlı çevrinme",
"effects.whisper.description": "Basları zayıflatılmış, varlığı artırılmış; havadar, nefesli bir ton.",
"effects.whisper.name": "Fısıltı",
+ "effects.whiteBalance.description": "Gözün ışığa uyum sağlaması gibi; görüntü daha sıcak ya da daha soğuk bir ışıkla aydınlatılmış gibi, macentaya ya da yeşile çevrilmiş olur.",
+ "effects.whiteBalance.name": "Beyaz dengesi",
"effects.winterCool.description": "Doygunluğu alınmış ve mavi; siyahlar mat bir kış pusuna kaldırılmış.",
"effects.winterCool.name": "Kış soğuğu",
"effects.wordReveal.description": "Bir yazının kelimeleri klip oynarken okuma sırasıyla teker teker belirir.",
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index 8184d3b2..e194f396 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "万里晴空",
"effects.colorCycle.description": "色相随时间在整个色谱上平滑轮转。",
"effects.colorCycle.name": "颜色循环",
+ "effects.contrast.description": "以中灰为中心按档增减对比度,保留白色以上的高光,黑色也绝不会死黑。",
+ "effects.contrast.name": "对比度",
"effects.contrastPop.description": "阴影更深,高光更亮。",
"effects.contrastPop.name": "对比强化",
"effects.cool.description": "让画面偏向日光下阴影处的冷色调。",
@@ -576,6 +578,8 @@
"effects.rosy.name": "红润",
"effects.sage.description": "中间调柔和、偏青绿,胶片曲线温和,只在人脸处留有暖意。独立电影般安静的调色。",
"effects.sage.name": "鼠尾草",
+ "effects.saturation.description": "以每个像素自身的亮度为中心,让颜色更浓郁或更灰。",
+ "effects.saturation.name": "饱和度",
"effects.scanlines.description": "每隔几个像素就有一道横贯画面的暗线,就像显像管电视的成像方式。",
"effects.scanlines.name": "扫描线",
"effects.sciFi.description": "冷峻无菌的钢青色调,饱和度收敛。",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "甩镜",
"effects.whisper.description": "轻盈、带气声的音色,低频衰减,临场感增强。",
"effects.whisper.name": "Whisper",
+ "effects.whiteBalance.description": "让画面仿佛被更暖或更冷的光照亮,并偏向洋红或绿色,就像眼睛适应光线那样。",
+ "effects.whiteBalance.name": "白平衡",
"effects.winterCool.description": "低饱和、偏蓝,黑位提亮,呈现哑光般的冬日薄雾。",
"effects.winterCool.name": "冬日冷调",
"effects.wordReveal.description": "标题中的文字随片段播放按阅读顺序逐个出现。",
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index 79d6ccd2..efa47e63 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -263,6 +263,8 @@
"effects.cloudlessSky.name": "萬里晴空",
"effects.colorCycle.description": "色相隨時間在整個色譜上平滑輪轉。",
"effects.colorCycle.name": "顏色循環",
+ "effects.contrast.description": "以中間灰為中心按格增減對比度,保留白色以上的亮部,黑色也絕不會死黑。",
+ "effects.contrast.name": "對比度",
"effects.contrastPop.description": "陰影更深,亮部更亮。",
"effects.contrastPop.name": "對比強化",
"effects.cool.description": "讓畫面偏向日光下陰影處的冷色調。",
@@ -576,6 +578,8 @@
"effects.rosy.name": "紅潤",
"effects.sage.description": "中間調柔和、偏青綠,底片曲線溫和,只在人臉處留有暖意。獨立電影般安靜的調色。",
"effects.sage.name": "鼠尾草",
+ "effects.saturation.description": "以每個像素自身的亮度為中心,讓顏色更濃郁或更灰。",
+ "effects.saturation.name": "飽和度",
"effects.scanlines.description": "每隔幾個像素就有一道橫貫畫面的暗線,就像映像管電視的成像方式。",
"effects.scanlines.name": "掃描線",
"effects.sciFi.description": "冷峻無菌的鋼青色調,飽和度收斂。",
@@ -662,6 +666,8 @@
"effects.whipPan.name": "甩鏡",
"effects.whisper.description": "輕盈、帶氣聲的音色,低頻衰減,臨場感增強。",
"effects.whisper.name": "Whisper",
+ "effects.whiteBalance.description": "讓畫面彷彿被更暖或更冷的光照亮,並偏向洋紅或綠色,就像眼睛適應光線那樣。",
+ "effects.whiteBalance.name": "白平衡",
"effects.winterCool.description": "低飽和、偏藍,黑位提亮,呈現霧面般的冬日薄霧。",
"effects.winterCool.name": "冬日冷調",
"effects.wordReveal.description": "標題中的文字隨片段播放按閱讀順序逐一出現。",
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 6cd83270..022a25c4 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -1121,54 +1121,6 @@ struct ShelfStamp {
/// The built-in colour package's id; see `adjust_rows` and `Studio::adjust_set`.
const ADJUST_ID: &str = "concat.adjust";
-/// Makes a package folder under `dir` from the table at `path`, and
-/// returns the package's id. The id is `user.` and the file's name slugged;
-/// a second import of the same name replaces the first.
-fn import_cube(dir: &std::path::Path, path: &std::path::Path) -> Result<String, String> {
- let stem = path
- .file_stem()
- .map(|stem| stem.to_string_lossy().into_owned())
- .unwrap_or_default();
- let mut slug: String = stem
- .to_lowercase()
- .chars()
- .map(|c| if c.is_ascii_alphanumeric() { c } else { '-' })
- .collect::<String>()
- .split('-')
- .filter(|part| !part.is_empty())
- .collect::<Vec<_>>()
- .join("-");
- if slug.is_empty() {
- slug = "look".to_owned();
- }
- let id = format!("user.{slug}");
- let text = std::fs::read_to_string(path).map_err(|error| error.to_string())?;
- concat_effects::cube::parse(&text)?;
- let folder = dir.join(&id);
- std::fs::create_dir_all(&folder).map_err(|error| error.to_string())?;
- let name = stem.trim().to_owned();
- // Format 1: a table is made for the gamma-encoded picture, which is
- // what a format 1 shader is handed. The look-up effect with a log
- // shaper (phase 2, step 5) is what takes an imported table into light.
- let manifest = format!(
- "format = 1\n\n[effect]\nid = \"{id}\"\nname = {name:?}\nkind = \"filter\"\ncategory = \"Imported\"\n\
- description = \"A look imported from a .cube table.\"\n\n[lut]\nfile = \"look.cube\"\n\n\
- [ffmpeg]\nchain = \"lut3d=file={{lut}}\"\n\n[wgsl]\nentry = \"effect.wgsl\"\n"
- );
- std::fs::write(folder.join("effect.toml"), manifest).map_err(|error| error.to_string())?;
- std::fs::write(
- folder.join("effect.wgsl"),
- "// The table, and nothing else; the host mixes it by intensity.\n\
- fn effect(uv: vec2<f32>) -> vec4<f32> {\n let c = sample(uv);\n return vec4<f32>(lut(c.rgb), c.a);\n}\n",
- )
- .map_err(|error| error.to_string())?;
- std::fs::write(folder.join("look.cube"), &text).map_err(|error| error.to_string())?;
- // A still an earlier import drew for this name: the card drawn from
- // the package's own shader replaces it.
- let _ = std::fs::remove_file(folder.join("preview.png"));
- Ok(id)
-}
-
/// The ease a key put on at `at` inherits: that of whichever key it joins
/// behind, so laying a run of keys down does not alternate between shapes.
/// The first key on a parameter has nothing to inherit and gets the
@@ -5901,6 +5853,10 @@ impl Studio {
/// How long that trial may take before the package is refused.
const TRIAL_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(3);
let dir = Self::looks_dir(&self.host.dirs);
+ // Looks an earlier build imported, onto the format 2 look first.
+ for id in concat_effects::looks::upgrade(&dir) {
+ log::info!("{id}: the imported look now reads its table in light");
+ }
let monitor = &self.host.monitor;
let errors = Catalogue::install_with(&dir, &mut |package| {
let Some(pass) = package.trial_pass() else {
@@ -5981,9 +5937,10 @@ impl Studio {
}
/// Imports one or more `.cube` tables as looks: each becomes a package
- /// folder under `looks_dir` - a manifest that names the table and a
- /// shader that reads it - with a card still rendered through the table
- /// here, and the catalogue is rebuilt so the Filters page shows them.
+ /// folder under `looks_dir` - a manifest that names the table, a shader
+ /// that reads it, the table (see `concat_effects::looks`) - and the
+ /// catalogue is rebuilt so the Filters page shows them, their cards
+ /// drawn by their own shaders.
pub fn import_lut(&mut self) {
let Some(paths) = crate::platform::pick_files(
&t("studio.importLut"),
@@ -5994,7 +5951,7 @@ impl Studio {
let dir = Self::looks_dir(&self.host.dirs);
let mut imported = 0;
for path in paths {
- match import_cube(&dir, &path) {
+ match concat_effects::looks::import(&dir, &path) {
Ok(id) => {
self.look_art.borrow_mut().remove(&id);
imported += 1;