diff --git a/README.md b/README.md index bcbb27f..9060340 100644 --- a/README.md +++ b/README.md @@ -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 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 -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 when none is installed. diff --git a/scripts/render-check.mjs b/scripts/render-check.mjs index be66101..5a0d23f 100644 --- a/scripts/render-check.mjs +++ b/scripts/render-check.mjs @@ -200,6 +200,12 @@ try { Math.abs(pixel[2] - target[2]) < 14; const RED_MARK = [255, 31, 31]; 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({ clipPixels, @@ -209,6 +215,8 @@ try { !near(clipPixels[2], RED_MARK) && !near(clipPixels[2], YELLOW_MARK) && !near(clipPixels[2], [255, 255, 255]), + clipFollowsExposure: near(brightPixel, [255, 255, 255]), + brightPixel, flagHonouredForBitmap: !same(proxyTop, proxyNoFlipTop), proxyTop: +proxyTop.toFixed(4), sidecarTop: +sideTop.toFixed(4), @@ -353,7 +361,8 @@ async function main() { console.log( `render check: clipping overlay red=${JSON.stringify(result.clipPixels[0])}` + ` 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) { console.error( @@ -370,6 +379,13 @@ async function main() { ); 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( 'render check PASSED: proxy and sidecar share a row order and the clipping overlay names the channels.', ); diff --git a/src/gl/renderer.ts b/src/gl/renderer.ts index 756159e..eb01205 100644 --- a/src/gl/renderer.ts +++ b/src/gl/renderer.ts @@ -547,17 +547,7 @@ void main(){ } } - // Alpha carries the *source* clipping state to the finish pass, so the - // 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); + outColor = vec4(clamp(srgb, 0.0, 1.0), 1.0); }`; const BLUR_FRAG = `#version 300 es @@ -861,28 +851,24 @@ void main(){ vec3 finalCol = clamp(col, 0.0, 1.0); // Clipping overlay: which channels have run out of headroom. Red/green/blue // mean one channel clipped, yellow means two, white means all three — the - // same reading Aperture's exposure warnings gave while you dragged. - // The grade pass wrote the untouched source's clipping state into alpha as a - // 4-bit code in sixteenths, so warning about the source still tells the truth - // 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; + // same reading Aperture's exposure warnings gave while you dragged. It reads + // the finished frame rather than the source, so holding Ctrl while moving + // Exposure or Recovery shows the warnings appear and clear as you go. if (u_clip > 1.5) { // 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) { - 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) { vec3 mark = vec3(1.0); - if (n < 1.5) { - if (clipR) mark = vec3(1.0, 0.12, 0.12); - else if (clipG) mark = vec3(0.1, 1.0, 0.2); + if (n < 2.5) { + if (n > 1.5) mark = vec3(1.0, 0.9, 0.1); + 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 if (n < 2.5) { - mark = vec3(1.0, 0.9, 0.1); } finalCol = mark; }