Match After Effects non-legacy Brightness & Contrast.

The modern curve used g = 2^(2c), so Contrast 100 crushed 0.25 to about 8/255 while AE is about 40/255. Brightness is now a pin-black-and-white power toward white or black, then a milder S-curve g = 1 + 0.53 c, fitted to kasper9n's AE grey ramps. Legacy linear mode is unchanged. The GPU kernel matches the CPU.
This commit is contained in:
Vikram Bhaskaran
2026-10-11 14:31:10 +11:00
parent 9a7d3e7699
commit a81c98d33c
2 changed files with 57 additions and 14 deletions
+15 -8
View File
@@ -621,18 +621,25 @@ fn pointwise(@builtin(global_invocation_id) gid: vec3<u32>) {
if (P.u[0].y == 1u) {
px = vec4<f32>(max((c + br - 0.5) * k + 0.5, vec3<f32>(0.0)) * a, a);
} else if (P.u[0].y == 2u) {
// Brightness & Contrast tone curves (effects crate bc_modern).
// Brightness & Contrast tone curves (effects crate bc_modern, AE-fitted #681).
var o = c;
let pb = exp2(-br);
let g = exp2(2.0 * ct);
let g = max(1.0 + 0.53 * ct, 0.05);
for (var i = 0; i < 3; i++) {
if (c[i] < 1.0) {
let v = powz(max(c[i], 0.0), pb);
if (v < 0.5) {
o[i] = 0.5 * powz(2.0 * v, g);
} else {
o[i] = 1.0 - 0.5 * powz(max(2.0 - 2.0 * v, 0.0), g);
var v = max(c[i], 0.0);
if (br > 0.0) {
v = 1.0 - powz(1.0 - v, exp2(1.24 * br));
} else if (br < 0.0) {
v = powz(v, exp2(-1.32 * br));
}
if (ct != 0.0) {
if (v < 0.5) {
v = 0.5 * powz(2.0 * v, g);
} else {
v = 1.0 - 0.5 * powz(max(2.0 - 2.0 * v, 0.0), g);
}
}
o[i] = v;
}
}
px = vec4<f32>(o * a, a);