fix(raw): pin tone curve ends to eliminate shadow purple artifacts and fix camera matrix WB color cast

This commit is contained in:
2026-10-05 16:29:10 +07:00
parent f98ce2c042
commit fbed70b9da
3 changed files with 30 additions and 31 deletions
+12 -12
View File
@@ -72,7 +72,7 @@ const SETTINGS = {
outputBps: 16,
outputColor: 0,
noAutoScale: true,
useCameraWb: true,
useCameraWb: false,
noAutoBright: true,
gamm: [1, 1] as [number, number],
userQual: 3,
@@ -145,7 +145,7 @@ half4 main(float2 pos) {
// The matrix was fitted luma-preserving, so mx is the value to hold.
float hi = max(max(n.r, n.g), n.b);
hi = max(hi, max(max(lin.r, lin.g), lin.b));
rgb = mix(rgb, float3(mx), smoothstep(0.99, 1.02, hi));
rgb = mix(rgb, float3(mx), smoothstep(0.92, 1.0, hi));
// The overflow used to fade towards white — mix(rgb / mx, 1, 1 - 1 / mx) —
// which put every pixel of a blown sky on exactly 1.0 and threw the two stops
// the sensor held above white away with it: LIGHT's HIGHLIGHT row then had a
@@ -440,6 +440,16 @@ function invert3x3(m: number[][]): number[][] | null {
}
function getCamToSrgbMatrix(cd: any): number[][] {
if (cd?.rgb_cam && Array.isArray(cd.rgb_cam) && cd.rgb_cam.length >= 3) {
const m = [
[cd.rgb_cam[0][0], cd.rgb_cam[0][1], cd.rgb_cam[0][2]],
[cd.rgb_cam[1][0], cd.rgb_cam[1][1], cd.rgb_cam[1][2]],
[cd.rgb_cam[2][0], cd.rgb_cam[2][1], cd.rgb_cam[2][2]],
];
const inv = invert3x3(m);
if (inv) return inv;
}
if (cd?.cam_xyz && Array.isArray(cd.cam_xyz) && cd.cam_xyz.length >= 3) {
const cx = cd.cam_xyz;
const scale = (Math.abs(cx[0][0]) > 100) ? 10000.0 : 1.0;
@@ -462,16 +472,6 @@ function getCamToSrgbMatrix(cd: any): number[][] {
return [[m00, m01, m02], [m10, m11, m12], [m20, m21, m22]];
}
if (cd?.rgb_cam && Array.isArray(cd.rgb_cam) && cd.rgb_cam.length >= 3) {
const m = [
[cd.rgb_cam[0][0], cd.rgb_cam[0][1], cd.rgb_cam[0][2]],
[cd.rgb_cam[1][0], cd.rgb_cam[1][1], cd.rgb_cam[1][2]],
[cd.rgb_cam[2][0], cd.rgb_cam[2][1], cd.rgb_cam[2][2]],
];
const inv = invert3x3(m);
if (inv) return inv;
}
return [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
}