Effects: OCIO custom configs read Blender's v2 transforms and warn (#410)
Cause: the config reader didn't know ColorSpaceTransform or ExponentWithLinearTransform and passed colours through them silently. Blender's Linear Rec.709 -> sRGB therefore stayed in its E-white XYZ reference space (the blue cast) without the sRGB curve. Display colorspaces, view transforms, v2 views, looks, AllocationTransform, BuiltinTransform and .spi1d / .spimtx files were missing too, and nothing told the user. Fix (from the OCIO v2 documentation and the CLF "moncurve", not OCIO's source): ExponentWithLinear, ColorSpace, Look, DisplayView, Allocation and Builtin transforms (identity, ACES AP0/AP1 matrices, ACEScct / ACEScc, the sRGB / P3 / Rec.1886 / gamma / PQ displays). RangeTransform now clamps and takes one-sided ranges. Display colorspaces meet the scene reference through the default view transform. Added v2 views, view looks, the looks section and .spi1d / .spi3d / .spimtx files. A conversion is built once as a flat list of steps (Config::path / display_path) for both the CPU effect and the GPU colour program (new moncurve and clamp ops and the ACEScc curve; a program over the kernel's 255 ops renders on the CPU). Named-transform resolution is limited to 16 levels and 4096 steps, and YAML nesting to 64 levels, so hostile or looping configs stop. Transforms that are still unsupported (Grading Primary / Tone, ACES output, HLG…), unreadable configs and unknown spaces are now reported: a warning under the effect in Effect Controls, and the new effect.warning query. Tests: ocio_config::blender_like_config_converts_linear_rec709_to_srgb (CST, display colorspaces, v1 / v2 views, allocation, looks, builtin, range, loops), moncurve_matches_srgb_and_inverts, builtin_styles, yaml_nesting_is_bounded, ocio::spi_files_parse, tests_effects::ocio_effect_warns_about_unsupported_config_transforms, gpu tests_fx_lut::ocio_custom_config_v2 (GPU = CPU). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d6de68b20d
commit
492fa6de0a
@@ -126,6 +126,19 @@ fn find_fx(s: &Session, p: &Value, cmd: &str) -> Result<(effectcraft_project::It
|
||||
Ok((cid, lid, g.uid))
|
||||
}
|
||||
|
||||
/// `effect.warning`: what Effect Controls warns about an effect (a custom OCIO config it can't
|
||||
/// read, or transforms it passes through), `null` when it renders as asked.
|
||||
fn warning(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let cmd = "effect.warning";
|
||||
let (cid, lid, uid) = find_fx(s, p, cmd)?;
|
||||
let comp = s.project.comp(cid).ok_or(EngineError::NoComp)?;
|
||||
let layer = comp.layer(lid).ok_or(EngineError::NoComp)?;
|
||||
let g = layer.effects().and_then(|fx| fx.groups().find(|g| g.uid == uid)).ok_or_else(|| bad(cmd, "no such effect"))?;
|
||||
let t = super::time_p(s, p, Some(comp));
|
||||
let ctx = effectcraft_render::EvalCtx { project: &s.project, comp_id: cid, comp, time: t, expr: s.expr.as_deref(), footage: None };
|
||||
Ok(json!({"effect": uid, "warning": effectcraft_effects::warning(g, &mut |pr| ctx.value(layer, pr))}))
|
||||
}
|
||||
|
||||
/// A colour parameter's eyedropper on a keyer (Effect Controls): the colour of the effect's input
|
||||
/// (the layer's pixels before this effect, so a keyed screen can still be picked) at a
|
||||
/// layer-space point, set on the parameter. `average` takes the 5 × 5 pixels around it.
|
||||
@@ -457,6 +470,12 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
cmd!("effect.paste", "Paste Effects", [], None, "{layers?} — adds the copied effects to the layers", has_layers, paste),
|
||||
cmd!("effect.reset", "Reset Effect", [], None, "{layer?, effect}", has_layers, reset),
|
||||
crate::query!("effect.list", "List Effects", "{filter?}", list),
|
||||
crate::query!(
|
||||
"effect.warning",
|
||||
"Effect Warning",
|
||||
"{layer?, effect?: index|uid|name (default: the selected effect), time?} → {effect, warning: string|null} — what Effect Controls warns about (an OCIO config it can't read, transforms it passes through)",
|
||||
warning
|
||||
),
|
||||
crate::query!(
|
||||
"effect.plugins.list",
|
||||
"List Effect Plug-ins",
|
||||
|
||||
@@ -317,3 +317,32 @@ fn opening_a_schema_1_project_moves_shape_layer_effect_points_into_effect_space(
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
check(&s3);
|
||||
}
|
||||
|
||||
/// #410: `effect.warning` reports what an OCIO effect can't render as asked (Effect Controls
|
||||
/// shows it under the effect's name): a transform of its custom config that passes colours
|
||||
/// through, a colour space the config lacks or a config it can't read; nothing for the
|
||||
/// built-in config.
|
||||
#[test]
|
||||
fn ocio_effect_warns_about_unsupported_config_transforms() {
|
||||
let (mut s, a, _) = comp_with_two_solids();
|
||||
let fx = apply(&mut s, a, "OCIO Color Space Transform");
|
||||
let warning = |s: &mut Session| s.execute("effect.warning", json!({"layer": a, "effect": fx})).unwrap()["warning"].clone();
|
||||
assert!(warning(&mut s).is_null(), "built-in config");
|
||||
let set = |s: &mut Session, param: &str, value: serde_json::Value| {
|
||||
let uid = layer(s, a).effects().unwrap().groups().next().unwrap().get(param).unwrap().uid;
|
||||
s.execute("prop.set", json!({"layer": a, "prop": uid, "value": value})).unwrap();
|
||||
};
|
||||
let config = "ocio_profile_version: 2\ncolorspaces:\n - !<ColorSpace>\n name: lin\n - !<ColorSpace>\n name: graded\n from_scene_reference: !<GradingToneTransform> {}\n";
|
||||
set(&mut s, "config", json!(1));
|
||||
set(&mut s, "configFile", json!(config));
|
||||
set(&mut s, "sourceName", json!("lin"));
|
||||
set(&mut s, "destinationName", json!("graded"));
|
||||
let w = warning(&mut s);
|
||||
assert!(w.as_str().is_some_and(|w| w.contains("GradingToneTransform")), "{w}");
|
||||
set(&mut s, "destinationName", json!("lin"));
|
||||
assert!(warning(&mut s).is_null());
|
||||
set(&mut s, "destinationName", json!("nowhere"));
|
||||
assert!(warning(&mut s).as_str().is_some_and(|w| w.contains("no color space `nowhere`")));
|
||||
set(&mut s, "configFile", json!("/no/such/config.ocio"));
|
||||
assert!(warning(&mut s).as_str().is_some_and(|w| w.starts_with("Can't read the OCIO config")));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user