Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
b8b0d0b
feat(mcp): give agents a contact sheet, region crops and an audio report
EtienneLescot Nov 22, 2026
a5d90fa
feat(mcp): set an annotation's font family from the shipped list
EtienneLescot Nov 22, 2026
b3e05de
feat(mcp): turn a clip upside down through setClipRange
EtienneLescot Nov 22, 2026
e6a90f9
feat(mcp): list and apply style presets
EtienneLescot Nov 22, 2026
bab809a
feat(mcp): export a project's captions to an SRT or WebVTT file
EtienneLescot Nov 22, 2026
ba067eb
feat(plugin): bundle OpenScreen's MCP server through a launcher
EtienneLescot Nov 22, 2026
1c65812
docs(plugin): describe the bundled server in the setup step and README
EtienneLescot Nov 22, 2026
b50ae76
chore(plugin): track commits in Claude Code, bump the Codex manifest …
EtienneLescot Nov 22, 2026
302a9fb
feat(plugin): add the openscreen-capture skill with a headless captur…
EtienneLescot Nov 22, 2026
516f01a
feat(plugin): add the openscreen-review skill
EtienneLescot Nov 22, 2026
4b084bf
feat(plugin): add the openscreen-deliver skill
EtienneLescot Nov 22, 2026
c37d2a9
feat(plugin): tighten openscreen-demo and hand depth to the workflow …
EtienneLescot Nov 22, 2026
a81c154
feat(plugin): add the openscreen-effects skill
EtienneLescot Nov 22, 2026
9e69af6
feat(plugin): add the openscreen-motion skill
EtienneLescot Nov 22, 2026
ffef64c
feat(plugin): add the openscreen-sound skill
EtienneLescot Nov 22, 2026
9d26e9a
docs(plugin): give callouts one length rule across the skills
EtienneLescot Nov 22, 2026
699c227
fix(mcp): measure the audio render where the runner says it wrote it
EtienneLescot Nov 22, 2026
9da96d9
fix(mcp): report the rotation a clip ended with when the edit folds it
EtienneLescot Nov 22, 2026
6d4d249
fix(mcp): escape what WebVTT reads as markup in exported captions
EtienneLescot Nov 22, 2026
9a92cb9
fix(mcp): keep reported silences clear of cuts, stage subtitle files
EtienneLescot Nov 22, 2026
eab935d
docs(plugin): name the seven skills in the README and the Codex manifest
EtienneLescot Nov 22, 2026
32d9b58
docs(website): document the new agent tools, the seven skills and the…
EtienneLescot Nov 22, 2026
6eddb2f
docs(website): carry the agent tools, skills and plugin server change…
EtienneLescot Nov 22, 2026
4cd92fe
feat(compositor): sample keyframed shader-effect parameters per frame
EtienneLescot Nov 22, 2026
2a9d086
feat(effects): let an agent animate a shader-effect parameter with ke…
EtienneLescot Nov 22, 2026
61c3a33
feat(inspector): hide the control of an animated effect parameter
EtienneLescot Nov 22, 2026
9d3236c
docs(plugin): teach the effects skill to animate a parameter with key…
EtienneLescot Nov 22, 2026
82f60b7
docs(plugin): point the skills at style presets and caption files
EtienneLescot Nov 22, 2026
065fe35
docs(website): say the editor and CLI write no caption file, and an a…
EtienneLescot Nov 22, 2026
cf78614
docs(website): carry the caption-file correction into every locale
EtienneLescot Nov 22, 2026
a94e0c5
feat(media): turn a still image into a silent video clip
EtienneLescot Nov 22, 2026
b208376
feat(mcp): import an image as a still clip
EtienneLescot Nov 22, 2026
b4e0141
feat(editor): import an image from the media picker as a still clip
EtienneLescot Nov 22, 2026
28b5b4b
fix(editor): show a still as an image and never transcribe it
EtienneLescot Nov 22, 2026
9070919
docs(testing): log the agent tools pass on the integration branch
EtienneLescot Nov 22, 2026
006ee5a
test(plugin): add a claude plugin eval suite for the seven skills
EtienneLescot Nov 22, 2026
6d5e14b
test(compositor): prove an animated effect parameter reaches the shader
EtienneLescot Nov 22, 2026
a2932e4
feat(mcp): show what a series of edits changed, moment by moment
EtienneLescot Nov 22, 2026
9c2530f
docs(testing): log the agent tools pass on macOS and Linux
EtienneLescot Nov 22, 2026
9e4bb7f
feat(usage): count the MCP tools an agent calls in the daily usage count
EtienneLescot Nov 22, 2026
b19e3eb
fix(mcp): compare each side at its own time, and keep media tools off…
EtienneLescot Nov 22, 2026
a91974c
fix(media): import a photo stored sideways with an EXIF orientation u…
EtienneLescot Nov 22, 2026
7a5d59b
fix(usage): keep the opt-out when another process rewrites a state it…
EtienneLescot Nov 22, 2026
cb6c7e7
fix(plugin): fall back to the setup notice when the app dies before a…
EtienneLescot Nov 22, 2026
9724096
fix(editor): subtitle tails, keyframe order and a few edge cases from…
EtienneLescot Nov 22, 2026
bfa21de
fix(evals): tighten the graders and mocks, and say caption files are …
EtienneLescot Nov 22, 2026
e6d2f4f
fix(mcp): keep compared moments as asked, size sheets by their talles…
EtienneLescot Nov 22, 2026
4c6df6d
fix(usage-ping): keep counts made across a change of the checkbox apart
EtienneLescot Nov 22, 2026
c8d8a93
fix(plugin): wait for a whole first message, and let a signal end the…
EtienneLescot Nov 22, 2026
e9d0656
docs(review): a film passes once the user watched it whole for privat…
EtienneLescot Nov 22, 2026
98003cb
fix(evals): judge what a pattern cannot tell, and keep the mocks' zoo…
EtienneLescot Nov 22, 2026
bbfb2c7
fix(usage-ping): serialize state changes across processes with a lock…
EtienneLescot Nov 22, 2026
4b31e3d
docs(review): sample privacy sheets every 35 s, so frames fall a seco…
EtienneLescot Nov 22, 2026
f376542
fix(evals): order the ring's windows, count a dangling link as taken,…
EtienneLescot Nov 22, 2026
082bbe7
fix(usage-ping): claim a ping's counts before it leaves, and write on…
EtienneLescot Nov 22, 2026
b376a39
docs(review): read the text a privacy sheet finds at full resolution
EtienneLescot Nov 22, 2026
ad18269
fix(evals): judge the click ring on the frames the tool samples, and …
EtienneLescot Nov 22, 2026
498fa30
fix(usage-ping): take a lock as abandoned only once the process holdi…
EtienneLescot Nov 22, 2026
391e32f
docs(review): read every privacy frame at a size where text reads
EtienneLescot Nov 22, 2026
876612b
fix(usage-ping): keep a ping's claim while the process that made it runs
EtienneLescot Nov 22, 2026
c629853
fix(usage-ping): keep the checkbox's choice in a file of its own and …
EtienneLescot Nov 22, 2026
67099f7
fix(evals): clamp the click ring's samples to the film, accept a wind…
EtienneLescot Nov 22, 2026
a4d0825
fix(usage-ping): keep the state as versions created once, instead of …
EtienneLescot Nov 22, 2026
dcc0569
fix(usage-ping): hand a ping's request over by a version of its own
EtienneLescot Nov 22, 2026
49f7173
fix(usage-ping): number a version only once it is whole, and prove a …
EtienneLescot Nov 22, 2026
d0f2963
fix(usage-ping): say so when the box's choice could not be saved
EtienneLescot Nov 22, 2026
de5ee2b
docs(skills): read the privacy pass in the exported file's seconds
EtienneLescot Nov 22, 2026
68f37f3
fix(usage-ping): mark a change as landed when another is built on it
EtienneLescot Nov 22, 2026
c64320d
fix(usage-ping): read the versions again when the listing went stale …
EtienneLescot Nov 22, 2026
4c12514
fix(usage-ping): build nothing over an unreadable newest version, and…
EtienneLescot Nov 22, 2026
2fa487a
fix(usage-ping): show the stored choice in the tray while a new one i…
EtienneLescot Nov 22, 2026
c973a7d
docs(skills): read the exported film whole for privacy again after ea…
EtienneLescot Nov 22, 2026
abb03b1
fix(usage-ping): count nothing over a released file that does not read
EtienneLescot Nov 22, 2026
b2284bd
test(e2e): log the on-screen pass of the agent studio on Windows
EtienneLescot Nov 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion crates/compositor/src/compositor_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ impl Compositor {
)
};
let params: Vec<u8> =
crate::shader_fx::pack_params(effect).iter().flat_map(|v| v.to_ne_bytes()).collect();
crate::shader_fx::pack_params(effect, ctx.region[2]).iter().flat_map(|v| v.to_ne_bytes()).collect();
let uniform = |label: &str, contents: &[u8]| {
self.gpu.device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some(label),
Expand Down Expand Up @@ -7305,6 +7305,19 @@ mod tests {
assert_eq!(corner, [0, 255, 0]);
}

/// Une piste d'images clés remplace la valeur fixe : `tint` est vert dans `values`, sa piste le
/// tient bleu jusqu'à 1,5 s. À 2 s de programme, soit 1 s dans la région, le shader lit bleu.
#[test]
fn an_animated_parameter_reaches_the_shader_at_its_keyframe_value() {
let mut effect = fx(TINT, "image");
effect["animate"] = serde_json::json!({"tint": [
{"atSec": 0.0, "value": [0.0, 0.0, 1.0, 1.0], "hold": true},
{"atSec": 1.5, "value": [0.0, 1.0, 0.0, 1.0]},
]});
let Some(corner) = corner_under(serde_json::json!([effect])) else { return };
assert_eq!(corner, [0, 0, 255]);
}

/// La scène de ces tests masque le curseur (`cursor.show` faux) : rien n'est dessiné, mais un
/// effet voit toujours la pointe et le clic de l'enregistrement (`effect_pointer`). Il peint
/// `ctx.cursor.z` en rouge et `ctx.clicks[0].w` en vert : jaune, il a vu les deux.
Expand Down
15 changes: 14 additions & 1 deletion crates/compositor/src/compositor_macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ impl Compositor {
// On ne lit pas la cible sur laquelle on dessine : copie dans `ann_copy` (les flous
// d'annotation et le cristal de Prism Glow l'ont déjà lue).
self.snapshot(cmd, dst, false);
let params = crate::shader_fx::pack_params(effect);
let params = crate::shader_fx::pack_params(effect, ctx.region[2]);
let e = self.begin_pass(cmd, dst, None, &pipeline)?;
e.set_fragment_texture(0, Some(&self.ann_copy));
// `footage()`, liée seulement pour un effet qui la lit : les autres ne la déclarent pas.
Expand Down Expand Up @@ -5266,6 +5266,19 @@ mod tests {
assert_eq!(corner, [0, 255, 0]);
}

/// Une piste d'images clés remplace la valeur fixe : `tint` est vert dans `values`, sa piste le
/// tient bleu jusqu'à 1,5 s. À 2 s de programme, soit 1 s dans la région, le shader lit bleu.
#[test]
fn an_animated_parameter_reaches_the_shader_at_its_keyframe_value() {
let mut effect = fx(TINT, "image");
effect["animate"] = serde_json::json!({"tint": [
{"atSec": 0.0, "value": [0.0, 0.0, 1.0, 1.0], "hold": true},
{"atSec": 1.5, "value": [0.0, 1.0, 0.0, 1.0]},
]});
let Some(corner) = corner_under(serde_json::json!([effect])) else { return };
assert_eq!(corner, [0, 0, 255]);
}

/// `fx_to_footage` retrouve le point du métrage que le compositeur a dessiné sous un pixel,
/// à plat, sous un angle fixe (warp bilinéaire) et sous la caméra réelle (homographie), et
/// `fx_from_footage` le ramène sur ce pixel. En 1080p, l'arrondi 8 bits et le demi-pixel
Expand Down
15 changes: 14 additions & 1 deletion crates/compositor/src/compositor_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ impl Compositor {
cb as *const crate::shader_fx::FxContext as *const u8,
std::mem::size_of::<crate::shader_fx::FxContext>(),
);
let params = crate::shader_fx::pack_params(effect);
let params = crate::shader_fx::pack_params(effect, cb.region[2]);
let params_bytes = std::slice::from_raw_parts(
params.as_ptr() as *const u8,
(params.len() * 4).min(crate::shader_fx::PARAMS_BUFFER_BYTES),
Expand Down Expand Up @@ -4237,6 +4237,19 @@ mod tests {
assert_eq!(corner, [0, 255, 0]);
}

/// Une piste d'images clés remplace la valeur fixe : `tint` est vert dans `values`, sa piste le
/// tient bleu jusqu'à 1,5 s. À 2 s de programme, soit 1 s dans la région, le shader lit bleu.
#[test]
fn an_animated_parameter_reaches_the_shader_at_its_keyframe_value() {
let mut effect = fx(TINT, "image");
effect["animate"] = serde_json::json!({"tint": [
{"atSec": 0.0, "value": [0.0, 0.0, 1.0, 1.0], "hold": true},
{"atSec": 1.5, "value": [0.0, 1.0, 0.0, 1.0]},
]});
let Some(corner) = corner_under(serde_json::json!([effect])) else { return };
assert_eq!(corner, [0, 0, 255]);
}

/// `fx_to_footage` retrouve le point du métrage que le compositeur a dessiné sous un pixel,
/// à plat, sous un angle fixe (warp bilinéaire) et sous la caméra réelle (homographie), et
/// `fx_from_footage` le ramène sur ce pixel. En 1080p, l'arrondi 8 bits et le demi-pixel
Expand Down
6 changes: 3 additions & 3 deletions crates/compositor/src/regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ const ZOOM_TRANSITION_BASE_S: f32 = 0.6;
const ZOOM_TRANSITION_PER_LN_S: f32 = 0.55;
// ω·T du ressort de `ease_spring` : assez haut pour que la fin de fenêtre soit à l'arrêt (1,5 %
// du pic), assez bas pour ne pas figer la seconde moitié.
const SPRING_OMEGA_T: f32 = 7.0;
pub(crate) const SPRING_OMEGA_T: f32 = 7.0;
// port de `CHAINED_ZOOM_PAN_GAP_MS` / `CONNECTED_ZOOM_PAN_DURATION_MS` (TS).
const CHAINED_ZOOM_PAN_GAP_S: f32 = 1.5;
const CONNECTED_ZOOM_PAN_DURATION_S: f32 = 1.0;
Expand All @@ -347,7 +347,7 @@ fn sample_cubic_bezier_derivative(a1: f32, a2: f32, t: f32) -> f32 {
}

/// Port direct de `cubicBezier` (TS) : Newton-Raphson puis bissection de repli.
fn cubic_bezier(x1: f32, y1: f32, x2: f32, y2: f32, t: f32) -> f32 {
pub(crate) fn cubic_bezier(x1: f32, y1: f32, x2: f32, y2: f32, t: f32) -> f32 {
let target_x = clamp01(t);
let mut solved_t = target_x;
for _ in 0..8 {
Expand Down Expand Up @@ -395,7 +395,7 @@ fn scale_lerp(a: f32, b: f32, t: f32) -> f32 {
/// Montée d'un ressort critique (sans rebond), ramenée pile sur [0, 1] à la fin de la fenêtre :
/// vitesse nulle au départ, donc pas d'à-coup, et arrivée amortie. L'ancienne courbe du zoom
/// (cubic-bezier(0.16, 1, 0.3, 1)) partait à pleine vitesse dès la première frame.
fn ease_spring(t: f32) -> f32 {
pub(crate) fn ease_spring(t: f32) -> f32 {
let x = SPRING_OMEGA_T * clamp01(t);
let end = 1.0 - (1.0 + SPRING_OMEGA_T) * (-SPRING_OMEGA_T).exp();
(1.0 - (1.0 + x) * (-x).exp()) / end
Expand Down
24 changes: 24 additions & 0 deletions crates/compositor/src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,30 @@ pub struct SceneShaderEffect {
/// Les valeurs, déjà normalisées par l'app : un nombre, ou 2 ou 4 floats.
#[serde(default)]
pub values: std::collections::HashMap<String, ShaderParamValue>,
/// Les paramètres animés : nom → images clés triées par `at_sec`. Une piste remplace la valeur
/// de `values` ; absente (le cas courant), le paramètre garde sa valeur fixe.
#[serde(default)]
pub animate: std::collections::HashMap<String, Vec<ShaderKeyframe>>,
}

/// Une image clé d'un paramètre animé. `at_sec` est compté depuis le début de la pilule, sur
/// l'horloge de `ctx.region.z`. La courbe va de cette image clé à la suivante : linéaire par
/// défaut, `bezier` (x1, y1, x2, y2), `spring` (le rebond, 0 à 0,9) ou `hold` (palier).
///
/// Des champs optionnels plutôt qu'une enum, pour la même raison que `SceneAnnotation::space` :
/// une forme de courbe inconnue d'un binaire plus ancien retombe sur le linéaire au lieu de faire
/// échouer toute la scène.
#[derive(Debug, Clone, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShaderKeyframe {
pub at_sec: f32,
pub value: ShaderParamValue,
#[serde(default)]
pub bezier: Option<[f32; 4]>,
#[serde(default)]
pub spring: Option<f32>,
#[serde(default)]
pub hold: bool,
}

fn default_contract() -> u32 {
Expand Down
165 changes: 157 additions & 8 deletions crates/compositor/src/shader_fx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
//! l'autre au seek) et l'export (qui les rend dans l'ordre) d'accord.

use crate::frame_geometry::FootageQuad;
use crate::scene::{SceneShaderEffect, ShaderEffectTarget, ShaderParamDecl, ShaderParamType, ShaderParamValue};
use crate::scene::{
SceneShaderEffect, ShaderEffectTarget, ShaderKeyframe, ShaderParamDecl, ShaderParamType, ShaderParamValue,
};
use std::hash::{Hash, Hasher};

/// La version du contrat que ce prélude implémente. Un prélude livré ne change plus : une entrée
Expand Down Expand Up @@ -863,20 +865,61 @@ pub fn context(
}
}

/// La valeur d'une piste d'images clés au temps `t` (secondes depuis le début de la pilule) :
/// palier avant la première et après la dernière, interpolation composante par composante entre
/// deux, selon la courbe de la première. Vide : aucune valeur.
pub fn sample_track(track: &[ShaderKeyframe], t: f32) -> Vec<f32> {
let floats = |v: &ShaderParamValue| match v {
ShaderParamValue::Scalar(x) => vec![*x],
ShaderParamValue::Vector(x) => x.clone(),
};
let Some(i) = track.iter().rposition(|k| k.at_sec <= t) else {
return track.first().map(|k| floats(&k.value)).unwrap_or_default();
};
let (a, Some(b)) = (&track[i], track.get(i + 1)) else { return floats(&track[i].value) };
let span = b.at_sec - a.at_sec;
if a.hold || span <= 0.0 {
return floats(&a.value);
}
let x = ((t - a.at_sec) / span).clamp(0.0, 1.0);
let k = match (a.bezier, a.spring) {
(Some([x1, y1, x2, y2]), _) => crate::regions::cubic_bezier(x1, y1, x2, y2, x),
(None, Some(bounce)) => spring(bounce, x),
(None, None) => x,
};
floats(&a.value).iter().zip(floats(&b.value)).map(|(from, to)| from + (to - from) * k).collect()
}

/// Un ressort sur [0, 1] qui part à vitesse nulle et arrive pile sur 1 à la fin. Sans rebond,
/// c'est le ressort critique des zooms ; avec, l'amortissement baisse (ζ = 1 − rebond) à la même
/// pulsation, et la petite erreur restante en fin de fenêtre est rattrapée linéairement.
fn spring(bounce: f32, t: f32) -> f32 {
let zeta = 1.0 - bounce.clamp(0.0, 0.9);
if zeta >= 0.999 {
return crate::regions::ease_spring(t);
}
let w = crate::regions::SPRING_OMEGA_T;
let wd = w * (1.0 - zeta * zeta).sqrt();
let x = |t: f32| 1.0 - (-zeta * w * t).exp() * ((wd * t).cos() + zeta * w / wd * (wd * t).sin());
x(t) + (1.0 - x(1.0)) * t
}

/// Les paramètres de la région, rangés comme la struct `FxParams` générée (règles d'alignement de
/// WGSL), en mots de 4 octets. Une valeur absente vaut 0 : l'app envoie déjà les défauts.
pub fn pack_params(effect: &SceneShaderEffect) -> Vec<f32> {
/// WGSL), en mots de 4 octets. Une valeur absente vaut 0 : l'app envoie déjà les défauts. Un
/// paramètre animé prend la valeur de sa piste à `region_sec` (`ctx.region.z`).
pub fn pack_params(effect: &SceneShaderEffect, region_sec: f32) -> Vec<f32> {
let mut words: Vec<f32> = Vec::new();
let mut offset = 0usize;
for p in &effect.params {
let (size, align) = p.ty.size_align();
offset = offset.div_ceil(align) * align;
let end = offset + size;
words.resize(end / 4, 0.0);
let value: Vec<f32> = match effect.values.get(&p.name) {
Some(ShaderParamValue::Scalar(v)) => vec![*v],
Some(ShaderParamValue::Vector(v)) => v.clone(),
None => Vec::new(),
let value: Vec<f32> = match (effect.animate.get(&p.name), effect.values.get(&p.name)) {
(Some(track), _) if !track.is_empty() => sample_track(track, region_sec),
(_, Some(ShaderParamValue::Scalar(v))) => vec![*v],
(_, Some(ShaderParamValue::Vector(v))) => v.clone(),
(_, None) => Vec::new(),
};
for (i, v) in value.into_iter().take(size / 4).enumerate() {
words[offset / 4 + i] = v;
Expand Down Expand Up @@ -999,6 +1042,7 @@ pub(crate) fn test_effect(code: &str, params: Vec<ShaderParamDecl>, values: &[(&
code: code.into(),
params,
values: values.iter().map(|(k, v)| (k.to_string(), v.clone())).collect(),
animate: Default::default(),
}
}

Expand Down Expand Up @@ -1111,7 +1155,7 @@ mod tests {
("at", ShaderParamValue::Vector(vec![7.0, 8.0])),
("b", ShaderParamValue::Scalar(9.0)),
];
let words = pack_params(&test_effect(code, params, &values));
let words = pack_params(&test_effect(code, params, &values), 0.0);
assert_eq!(words.len() * 4, (*span as usize).div_ceil(16) * 16);
let first = |name: &str| members.iter().find(|m| m.name.as_deref() == Some(name)).unwrap().offset as usize / 4;
assert_eq!(words[first("a")], 1.0);
Expand All @@ -1121,6 +1165,111 @@ mod tests {
assert_eq!(words[first("b")], 9.0);
}

fn key(at_sec: f32, value: ShaderParamValue) -> ShaderKeyframe {
ShaderKeyframe { at_sec, value, bezier: None, spring: None, hold: false }
}

fn scalar(track: &[ShaderKeyframe], t: f32) -> f32 {
sample_track(track, t)[0]
}

#[test]
fn a_track_holds_outside_its_keyframes_and_is_linear_between() {
let track = [key(1.0, ShaderParamValue::Scalar(2.0)), key(3.0, ShaderParamValue::Scalar(6.0))];
assert_eq!(scalar(&track, 0.0), 2.0);
assert_eq!(scalar(&track, 2.0), 4.0);
assert_eq!(scalar(&track, 3.0), 6.0);
assert_eq!(scalar(&track, 10.0), 6.0);
assert_eq!(sample_track(&[key(0.5, ShaderParamValue::Scalar(7.0))], 9.0), vec![7.0]);
// Composante par composante : une couleur, un point.
let color = [
key(0.0, ShaderParamValue::Vector(vec![0.0, 0.0, 0.0, 1.0])),
key(2.0, ShaderParamValue::Vector(vec![1.0, 0.5, 0.0, 1.0])),
];
assert_eq!(sample_track(&color, 1.0), vec![0.5, 0.25, 0.0, 1.0]);
}

#[test]
fn a_bezier_segment_follows_the_regions_curve() {
let mut from = key(0.0, ShaderParamValue::Scalar(0.0));
from.bezier = Some([0.42, 0.0, 0.58, 1.0]);
let track = [from, key(2.0, ShaderParamValue::Scalar(10.0))];
for t in [0.3_f32, 0.5, 1.0, 1.7] {
let expected = 10.0 * crate::regions::cubic_bezier(0.42, 0.0, 0.58, 1.0, t / 2.0);
assert_eq!(scalar(&track, t), expected);
}
assert!(scalar(&track, 0.3) < 1.5, "ease-in-out starts slow");
}

#[test]
fn a_spring_lands_exactly_on_the_next_keyframe() {
for bounce in [0.0_f32, 0.3, 0.9] {
let mut from = key(1.0, ShaderParamValue::Scalar(0.0));
from.spring = Some(bounce);
let track = [from, key(2.0, ShaderParamValue::Scalar(5.0))];
assert_eq!(scalar(&track, 1.0), 0.0);
assert!((scalar(&track, 1.999_99) - 5.0).abs() < 1e-3, "bounce {bounce}");
assert_eq!(scalar(&track, 2.0), 5.0);
}
// Avec du rebond, la courbe dépasse la cible avant d'y revenir.
let mut from = key(0.0, ShaderParamValue::Scalar(0.0));
from.spring = Some(0.5);
let track = [from, key(1.0, ShaderParamValue::Scalar(1.0))];
assert!((1..100).any(|i| scalar(&track, i as f32 / 100.0) > 1.01));
assert_eq!(spring(0.0, 0.4), crate::regions::ease_spring(0.4));
}

/// Un toggle arrive en `hold` (la scène le force) : il saute à chaque image clé, sans valeur
/// intermédiaire.
#[test]
fn a_hold_segment_steps_at_the_keyframe() {
let mut off = key(0.0, ShaderParamValue::Scalar(0.0));
off.hold = true;
let track = [off, key(1.0, ShaderParamValue::Scalar(1.0))];
assert_eq!(scalar(&track, 0.999), 0.0);
assert_eq!(scalar(&track, 1.0), 1.0);
}

/// Ce qui garde un projet sans animation identique à avant : sans piste, les mots sont ceux des
/// valeurs, quel que soit le temps.
#[test]
fn without_a_track_the_packed_words_are_the_values() {
let params = vec![decl("a", ShaderParamType::Number), decl("tint", ShaderParamType::Color)];
let values = [("a", ShaderParamValue::Scalar(0.25)), ("tint", ShaderParamValue::Vector(vec![0.1, 0.2, 0.3, 1.0]))];
let effect = test_effect(VIGNETTE, params, &values);
let expected = vec![0.25, 0.0, 0.0, 0.0, 0.1, 0.2, 0.3, 1.0];
assert_eq!(pack_params(&effect, 0.0), expected);
assert_eq!(pack_params(&effect, 42.0), expected);
}

#[test]
fn an_animated_parameter_packs_its_sampled_value() {
let params = vec![decl("a", ShaderParamType::Number), decl("b", ShaderParamType::Number)];
let values = [("a", ShaderParamValue::Scalar(9.0)), ("b", ShaderParamValue::Scalar(3.0))];
let mut effect = test_effect(VIGNETTE, params, &values);
effect.animate.insert(
"a".into(),
vec![key(0.0, ShaderParamValue::Scalar(0.0)), key(2.0, ShaderParamValue::Scalar(1.0))],
);
assert_eq!(pack_params(&effect, 1.0), vec![0.5, 3.0, 0.0, 0.0]);
}

#[test]
fn a_scene_without_animate_parses_and_one_with_it_reads_every_curve() {
let plain: SceneShaderEffect =
serde_json::from_str(r#"{"startSec":0,"endSec":1,"code":"x","values":{"a":1}}"#).unwrap();
assert!(plain.animate.is_empty());
let json = r#"{"startSec":0,"endSec":1,"code":"x","animate":{"a":[
{"atSec":0,"value":0,"bezier":[0.42,0,1,1]},{"atSec":1,"value":1,"spring":0.4},
{"atSec":2,"value":2,"hold":true},{"atSec":3,"value":3,"future":"curve"}]}}"#;
let animated: SceneShaderEffect = serde_json::from_str(json).unwrap();
let track = &animated.animate["a"];
assert_eq!(track[0].bezier, Some([0.42, 0.0, 1.0, 1.0]));
assert_eq!(track[1].spring, Some(0.4));
assert!(track[2].hold);
assert_eq!(track[3].bezier, None);
}

#[test]
fn the_context_matches_its_wgsl_struct() {
let parsed = analyze(VIGNETTE, &[decl("strength", ShaderParamType::Number)]).unwrap();
Expand Down
12 changes: 9 additions & 3 deletions crates/compositor/tests/render_frames_match_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
//! ici à la marche complète, où toutes les frames sont demandées et aucune n'est sautée.
//!
//! La scène met deux coupes du même fichier, une région 2× dans la seconde, un effet shader qui
//! lit le temps programme, et le curseur de la prise s'il a sa piste à côté.
//! lit le temps programme et un paramètre animé par images clés, et le curseur de la prise s'il a
//! sa piste à côté.
//!
//! La sortie est à 24 i/s : sur une source à 30 i/s, ses instants tombent entre deux frames
//! source, là où un rattrapage qui viserait la cible au lieu de la précéder montrerait la frame
Expand Down Expand Up @@ -51,8 +52,13 @@ fn scene_json(source: &str) -> String {
"output": {{"width":640,"height":360,"fps":null}},
"shaderEffects": [{{
"clipIndex": 1, "startSec": 6.0, "endSec": 20.0, "target": "image", "contract": 1,
"code": "fn effect(uv: vec2<f32>) -> vec4<f32> {{ let c = frame(uv); return vec4<f32>(c.rgb * (0.6 + 0.4 * sin(ctx.time * 3.0)), 1.0); }}",
"params": [], "values": {{}}
"code": "fn effect(uv: vec2<f32>) -> vec4<f32> {{ let c = frame(uv); return vec4<f32>(c.rgb * (0.6 + 0.4 * sin(ctx.time * 3.0)) * params.gain, 1.0); }}",
"params": [{{"name":"gain","type":"number"}}], "values": {{"gain":0.5}},
"animate": {{"gain": [
{{"atSec":0,"value":0.2,"bezier":[0.42,0,0.58,1]}},
{{"atSec":4,"value":1.0,"spring":0.4}},
{{"atSec":9,"value":0.6}}
]}}
}}]
}}"##,
clips = clips.join(",")
Expand Down
Loading
Loading