Name the clipped channels in the Ctrl clipping overlay again.
0c113e7 packed clipping into two alpha states (shadow / highlight), so the finish
pass could only paint white even though the legend still promised red, green,
blue and yellow. The grade pass now writes a 4-bit code (R/G/B + shadow) into
alpha and the overlay paints the channels it actually lost: red for one, yellow
for two, white for all three. The render check renders the overlay so this
cannot regress silently.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
@@ -58,14 +58,18 @@ function spawnSyncOk(bin) {
|
||||
});
|
||||
}
|
||||
|
||||
/** Three horizontal bands, so any vertical reversal changes every row band. */
|
||||
/**
|
||||
* Three horizontal bands. The first clips only red, the second clips red and
|
||||
* green (the yellow warning) and the third clips nothing, so the same image
|
||||
* also proves the clipping overlay still names the channels.
|
||||
*/
|
||||
function buildSource() {
|
||||
const rgb16 = new Uint16Array(W * H * 3);
|
||||
const rgb8 = new Uint8Array(W * H * 3);
|
||||
const bands = [
|
||||
[0.86, 0.22, 0.16],
|
||||
[0.24, 0.70, 0.28],
|
||||
[0.16, 0.26, 0.88],
|
||||
[1.0, 0.55, 0.08],
|
||||
[1.0, 1.0, 0.08],
|
||||
[0.24, 0.28, 0.35],
|
||||
];
|
||||
for (let y = 0; y < H; y++) {
|
||||
const band = bands[Math.min(bands.length - 1, Math.floor((y / H) * bands.length))];
|
||||
@@ -85,6 +89,8 @@ const PAGE_HTML = `<!doctype html>
|
||||
<pre id="out">boot</pre>
|
||||
<script type="module">
|
||||
import { parsePreview16 } from '/src/lib/preview16.ts';
|
||||
import { Renderer } from '/src/gl/renderer.ts';
|
||||
import { defaultEdits } from '/src/lib/edits.ts';
|
||||
const pre = document.getElementById('out');
|
||||
const half = (bits) => {
|
||||
const s = bits >> 15 ? -1 : 1;
|
||||
@@ -172,7 +178,37 @@ try {
|
||||
const sideBottom = rowLuma(sideBottomTex, 0, w);
|
||||
const same = (a, b) => Math.abs(a - b) < 0.02;
|
||||
|
||||
// Clipping overlay: red for one clipped channel, yellow for two. This renders
|
||||
// through the real Renderer, so a shader that collapses the warning to white
|
||||
// (or loses the shadow/highlight bit) fails here.
|
||||
const view = document.createElement('canvas');
|
||||
const renderer = new Renderer(view);
|
||||
renderer.setImage(bitmap, parsed);
|
||||
renderer.render(defaultEdits(), { width: w, height: h, clipPreview: true });
|
||||
const viewGl = view.getContext('webgl2');
|
||||
const sampleBand = (index) => {
|
||||
// readPixels rows start at the bottom, so flip the band centre.
|
||||
const py = h - 1 - Math.floor((h * (index + 0.5)) / 3);
|
||||
const px = new Uint8Array(4);
|
||||
viewGl.readPixels(Math.floor(w / 2), py, 1, 1, viewGl.RGBA, viewGl.UNSIGNED_BYTE, px);
|
||||
return [px[0], px[1], px[2]];
|
||||
};
|
||||
const clipPixels = [0, 1, 2].map(sampleBand);
|
||||
const near = (pixel, target) =>
|
||||
Math.abs(pixel[0] - target[0]) < 14 &&
|
||||
Math.abs(pixel[1] - target[1]) < 14 &&
|
||||
Math.abs(pixel[2] - target[2]) < 14;
|
||||
const RED_MARK = [255, 31, 31];
|
||||
const YELLOW_MARK = [255, 230, 26];
|
||||
|
||||
pre.textContent = 'RESULT ' + JSON.stringify({
|
||||
clipPixels,
|
||||
clipRed: near(clipPixels[0], RED_MARK),
|
||||
clipYellow: near(clipPixels[1], YELLOW_MARK),
|
||||
clipClear:
|
||||
!near(clipPixels[2], RED_MARK) &&
|
||||
!near(clipPixels[2], YELLOW_MARK) &&
|
||||
!near(clipPixels[2], [255, 255, 255]),
|
||||
flagHonouredForBitmap: !same(proxyTop, proxyNoFlipTop),
|
||||
proxyTop: +proxyTop.toFixed(4),
|
||||
sidecarTop: +sideTop.toFixed(4),
|
||||
@@ -314,6 +350,11 @@ async function main() {
|
||||
` | sidecar top=${result.sidecarTop} bottom=${result.sidecarBottom}` +
|
||||
` | flip flag honoured for ImageBitmap=${result.flagHonouredForBitmap}`,
|
||||
);
|
||||
console.log(
|
||||
`render check: clipping overlay red=${JSON.stringify(result.clipPixels[0])}` +
|
||||
` yellow=${JSON.stringify(result.clipPixels[1])}` +
|
||||
` clear=${JSON.stringify(result.clipPixels[2])}`,
|
||||
);
|
||||
if (!result.matchTop || !result.matchBottom) {
|
||||
console.error(
|
||||
result.reversed
|
||||
@@ -322,7 +363,16 @@ async function main() {
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
console.log('render check PASSED: proxy and sidecar upload in the same row order.');
|
||||
if (!result.clipRed || !result.clipYellow || !result.clipClear) {
|
||||
console.error(
|
||||
'render check FAILED: the clipping overlay lost its channel colours ' +
|
||||
`(red=${result.clipRed}, yellow=${result.clipYellow}, clear=${result.clipClear}).`,
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
console.log(
|
||||
'render check PASSED: proxy and sidecar share a row order and the clipping overlay names the channels.',
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user