Name the channels in the shadow clipping warning too.

Shadow warnings were a flat blue, so a single crushed channel looked the same as
all three. The shadow branch now uses the highlight palette: red/green/blue for
one channel, yellow (red+green), magenta (red+blue) and cyan (green+blue) for
pairs, white for all three. The render check covers both ends of the range, and
`npm run predeploy` chains typecheck, tests, the render check and the build so a
shader regression cannot reach a deploy.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
2026-11-28 14:40:50 +00:00
parent a6491f6ef6
commit a67e9ef458
4 changed files with 62 additions and 13 deletions
+39 -9
View File
@@ -59,18 +59,24 @@ function spawnSyncOk(bin) {
}
/**
* 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.
* Horizontal bands that exercise both ends of the range: one and two channels
* blown, one clean band, then one and two channels crushed, plus a green+blue
* crush to check the secondary colour. The same image proves the clipping
* overlay names the channels instead of painting every warning one colour.
*/
const BANDS = [
[1.0, 0.55, 0.08], // highlight: red only
[1.0, 1.0, 0.08], // highlight: red + green (yellow)
[0.24, 0.28, 0.35], // nothing clipped
[0.0, 0.3, 0.35], // shadow: red only
[0.0, 0.0, 0.35], // shadow: red + green (yellow)
[0.3, 0.0, 0.0], // shadow: green + blue (cyan)
];
function buildSource() {
const rgb16 = new Uint16Array(W * H * 3);
const rgb8 = new Uint8Array(W * H * 3);
const bands = [
[1.0, 0.55, 0.08],
[1.0, 1.0, 0.08],
[0.24, 0.28, 0.35],
];
const bands = BANDS;
for (let y = 0; y < H; y++) {
const band = bands[Math.min(bands.length - 1, Math.floor((y / H) * bands.length))];
for (let x = 0; x < W; x++) {
@@ -188,7 +194,7 @@ try {
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 py = h - 1 - Math.floor((h * (index + 0.5)) / ${BANDS.length});
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]];
@@ -207,6 +213,10 @@ try {
renderer.render(brightEdits, { width: w, height: h, clipPreview: true });
const brightPixel = sampleBand(2);
// Shadow clipping: same palette at the other end of the histogram.
renderer.render(defaultEdits(), { width: w, height: h, clipping: 'shadows' });
const shadowPixels = [2, 3, 4, 5].map(sampleBand);
pre.textContent = 'RESULT ' + JSON.stringify({
clipPixels,
clipRed: near(clipPixels[0], RED_MARK),
@@ -217,6 +227,12 @@ try {
!near(clipPixels[2], [255, 255, 255]),
clipFollowsExposure: near(brightPixel, [255, 255, 255]),
brightPixel,
shadowPixels,
shadowClear:
!near(shadowPixels[0], RED_MARK) && !near(shadowPixels[0], YELLOW_MARK),
shadowRed: near(shadowPixels[1], RED_MARK),
shadowYellow: near(shadowPixels[2], YELLOW_MARK),
shadowCyan: near(shadowPixels[3], [26, 217, 255]),
flagHonouredForBitmap: !same(proxyTop, proxyNoFlipTop),
proxyTop: +proxyTop.toFixed(4),
sidecarTop: +sideTop.toFixed(4),
@@ -364,6 +380,12 @@ async function main() {
` clear=${JSON.stringify(result.clipPixels[2])}` +
` | at +6EV the clear band is ${JSON.stringify(result.brightPixel)}`,
);
console.log(
`render check: shadow overlay clear=${JSON.stringify(result.shadowPixels[0])}` +
` red=${JSON.stringify(result.shadowPixels[1])}` +
` yellow=${JSON.stringify(result.shadowPixels[2])}` +
` cyan=${JSON.stringify(result.shadowPixels[3])}`,
);
if (!result.matchTop || !result.matchBottom) {
console.error(
result.reversed
@@ -379,6 +401,14 @@ async function main() {
);
return 1;
}
if (!result.shadowClear || !result.shadowRed || !result.shadowYellow || !result.shadowCyan) {
console.error(
'render check FAILED: the shadow clipping overlay lost its channel colours ' +
`(clear=${result.shadowClear}, red=${result.shadowRed}, ` +
`yellow=${result.shadowYellow}, cyan=${result.shadowCyan}).`,
);
return 1;
}
if (!result.clipFollowsExposure) {
console.error(
'render check FAILED: the clipping overlay does not follow Exposure; ' +