fix(export): keep values above 1.0 in EXR output (#339)

The EXR sequence writer and comp.saveFrameAsExr clamped colour to 0..1 before the sRGB decode, so a 32 bpc project lost every over-range value. The lower bound stays at 0 and alpha stays clamped. Tests cover Rgba and Rgb sequences and saveFrameAsExr.
This commit is contained in:
MindlessRuff
2026-10-08 20:22:49 -07:00
parent d60cb71e29
commit 1b2c5d1944
4 changed files with 114 additions and 3 deletions
+3 -2
View File
@@ -293,6 +293,7 @@ fn write_still<W: std::io::Write + std::io::Seek>(
match fmt {
OutputFormat::ExrSequence => {
// Linear light, premultiplied (the EXR convention); RGB keeps alpha = 1 over the background.
// Colour is floored at 0 but not capped at 1: a 32 bpc frame's over-range values survive (#339).
let lin = |v: f32| if v <= 0.04045 { v / 12.92 } else { ((v + 0.055) / 1.055).powf(2.4) };
let mut data = Vec::with_capacity((w * h * 4) as usize);
for y in 0..h {
@@ -305,12 +306,12 @@ fn write_still<W: std::io::Write + std::io::Seek>(
}
Channels::Rgba => {
let a = p[3].clamp(0.0, 1.0);
let s = |c: f32| if a > 0.0 { lin((c / a).clamp(0.0, 1.0)) * a } else { 0.0 };
let s = |c: f32| if a > 0.0 { lin((c / a).max(0.0)) * a } else { 0.0 };
([s(p[0]), s(p[1]), s(p[2])], a)
}
Channels::Rgb => {
let k = 1.0 - p[3].clamp(0.0, 1.0);
let c = |i: usize| lin((p[i] + comp.background[i] * k).clamp(0.0, 1.0));
let c = |i: usize| lin((p[i] + comp.background[i] * k).max(0.0));
([c(0), c(1), c(2)], 1.0)
}
};