Show the clipping overlay's per-channel colours and follow the sliders.

The overlay had been collapsed to a single highlight bit, so every warning was
white. It now reads the finished frame per channel again: red for one clipped
channel, yellow for two, white for all three, and it updates as Exposure or
Recovery moves, which is what holding Ctrl is for. The render check renders the
overlay and asserts both the colours and that +6 EV turns a clear band white.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
2026-11-28 14:38:48 +00:00
parent fe9d2aff3f
commit a6491f6ef6
3 changed files with 32 additions and 29 deletions
+2 -1
View File
@@ -997,7 +997,8 @@ real GPU pixels. It encodes a 16-bit sidecar with the server's own encoder, serv
beside the matching JPEG proxy and measures the rows that reach a WebGL2 texture in beside the matching JPEG proxy and measures the rows that reach a WebGL2 texture in
headless Chrome. Then it renders that image through the real `Renderer` with the Ctrl headless Chrome. Then it renders that image through the real `Renderer` with the Ctrl
clipping preview on, so the overlay has to paint red for one clipped channel and yellow clipping preview on, so the overlay has to paint red for one clipped channel and yellow
for two instead of collapsing to white. It fails on either regression, printing the for two instead of collapsing to white, and an unclipped band has to turn white once
Exposure is pushed past the top of the range. It fails on either regression, printing the
measured values, needs Chrome (`CHROME_PATH` overrides discovery) and skips with a notice measured values, needs Chrome (`CHROME_PATH` overrides discovery) and skips with a notice
when none is installed. when none is installed.
+17 -1
View File
@@ -200,6 +200,12 @@ try {
Math.abs(pixel[2] - target[2]) < 14; Math.abs(pixel[2] - target[2]) < 14;
const RED_MARK = [255, 31, 31]; const RED_MARK = [255, 31, 31];
const YELLOW_MARK = [255, 230, 26]; const YELLOW_MARK = [255, 230, 26];
// The preview has to follow the sliders it is shown for: +6 EV blows every
// channel of the unclipped band, so it must turn white, not stay clear.
const brightEdits = defaultEdits();
brightEdits.exposure = 6;
renderer.render(brightEdits, { width: w, height: h, clipPreview: true });
const brightPixel = sampleBand(2);
pre.textContent = 'RESULT ' + JSON.stringify({ pre.textContent = 'RESULT ' + JSON.stringify({
clipPixels, clipPixels,
@@ -209,6 +215,8 @@ try {
!near(clipPixels[2], RED_MARK) && !near(clipPixels[2], RED_MARK) &&
!near(clipPixels[2], YELLOW_MARK) && !near(clipPixels[2], YELLOW_MARK) &&
!near(clipPixels[2], [255, 255, 255]), !near(clipPixels[2], [255, 255, 255]),
clipFollowsExposure: near(brightPixel, [255, 255, 255]),
brightPixel,
flagHonouredForBitmap: !same(proxyTop, proxyNoFlipTop), flagHonouredForBitmap: !same(proxyTop, proxyNoFlipTop),
proxyTop: +proxyTop.toFixed(4), proxyTop: +proxyTop.toFixed(4),
sidecarTop: +sideTop.toFixed(4), sidecarTop: +sideTop.toFixed(4),
@@ -353,7 +361,8 @@ async function main() {
console.log( console.log(
`render check: clipping overlay red=${JSON.stringify(result.clipPixels[0])}` + `render check: clipping overlay red=${JSON.stringify(result.clipPixels[0])}` +
` yellow=${JSON.stringify(result.clipPixels[1])}` + ` yellow=${JSON.stringify(result.clipPixels[1])}` +
` clear=${JSON.stringify(result.clipPixels[2])}`, ` clear=${JSON.stringify(result.clipPixels[2])}` +
` | at +6EV the clear band is ${JSON.stringify(result.brightPixel)}`,
); );
if (!result.matchTop || !result.matchBottom) { if (!result.matchTop || !result.matchBottom) {
console.error( console.error(
@@ -370,6 +379,13 @@ async function main() {
); );
return 1; return 1;
} }
if (!result.clipFollowsExposure) {
console.error(
'render check FAILED: the clipping overlay does not follow Exposure; ' +
`the unclipped band stayed ${JSON.stringify(result.brightPixel)} at +6 EV.`,
);
return 1;
}
console.log( console.log(
'render check PASSED: proxy and sidecar share a row order and the clipping overlay names the channels.', 'render check PASSED: proxy and sidecar share a row order and the clipping overlay names the channels.',
); );
+13 -27
View File
@@ -547,17 +547,7 @@ void main(){
} }
} }
// Alpha carries the *source* clipping state to the finish pass, so the outColor = vec4(clamp(srgb, 0.0, 1.0), 1.0);
// warning reflects the pixels the sensor/proxy had, not the graded result.
// It is a 4-bit code in sixteenths: bit 0/1/2 = red/green/blue clipped and
// bit 3 = shadow clipped, so the overlay can still name the channels instead
// of collapsing every highlight warning to white.
float clipCode = 0.0;
if (src.r >= 0.996) clipCode += 1.0;
if (src.g >= 0.996) clipCode += 2.0;
if (src.b >= 0.996) clipCode += 4.0;
if (min(src.r, min(src.g, src.b)) <= 0.004) clipCode += 8.0;
outColor = vec4(clamp(srgb, 0.0, 1.0), clipCode / 16.0);
}`; }`;
const BLUR_FRAG = `#version 300 es const BLUR_FRAG = `#version 300 es
@@ -861,28 +851,24 @@ void main(){
vec3 finalCol = clamp(col, 0.0, 1.0); vec3 finalCol = clamp(col, 0.0, 1.0);
// Clipping overlay: which channels have run out of headroom. Red/green/blue // Clipping overlay: which channels have run out of headroom. Red/green/blue
// mean one channel clipped, yellow means two, white means all three — the // mean one channel clipped, yellow means two, white means all three — the
// same reading Aperture's exposure warnings gave while you dragged. // same reading Aperture's exposure warnings gave while you dragged. It reads
// The grade pass wrote the untouched source's clipping state into alpha as a // the finished frame rather than the source, so holding Ctrl while moving
// 4-bit code in sixteenths, so warning about the source still tells the truth // Exposure or Recovery shows the warnings appear and clear as you go.
// after a curve or a shadow lift and the channels are still known here.
int clipCode = int(texture(u_graded, v_uv).a * 16.0 + 0.5);
bool clipR = (clipCode & 1) != 0;
bool clipG = (clipCode & 2) != 0;
bool clipB = (clipCode & 4) != 0;
bool clipShadow = (clipCode & 8) != 0;
if (u_clip > 1.5) { if (u_clip > 1.5) {
// Shadow clipping: everything that has fallen to the bottom of the range. // Shadow clipping: everything that has fallen to the bottom of the range.
if (clipShadow) finalCol = vec3(0.15, 0.4, 1.0); if (max(finalCol.r, max(finalCol.g, finalCol.b)) < 0.02) {
finalCol = vec3(0.15, 0.4, 1.0);
}
} else if (u_clip > 0.5) { } else if (u_clip > 0.5) {
float n = float(clipR) + float(clipG) + float(clipB); vec3 k = step(0.985, finalCol);
float n = k.r + k.g + k.b;
if (n > 0.5) { if (n > 0.5) {
vec3 mark = vec3(1.0); vec3 mark = vec3(1.0);
if (n < 1.5) { if (n < 2.5) {
if (clipR) mark = vec3(1.0, 0.12, 0.12); if (n > 1.5) mark = vec3(1.0, 0.9, 0.1);
else if (clipG) mark = vec3(0.1, 1.0, 0.2); else if (k.r > 0.5) mark = vec3(1.0, 0.12, 0.12);
else if (k.g > 0.5) mark = vec3(0.1, 1.0, 0.2);
else mark = vec3(0.15, 0.4, 1.0); else mark = vec3(0.15, 0.4, 1.0);
} else if (n < 2.5) {
mark = vec3(1.0, 0.9, 0.1);
} }
finalCol = mark; finalCol = mark;
} }