Show the baked local mask in the develop view instead of a drawn band.

The overlay redrew every stroke as a flat translucent band, so the feather
never appeared and the guide did not match the shape it stood for. The
develop view now tints the selected layer's baked mask, sampled with the
same source uv the adjustments use: the preview follows crops,
straightening, zoom, lens correction, subtract shapes and the feather
exactly as the mask stores it. Only the stroke still under the pointer is
drawn, as a preview of what will be baked, and the histogram is left
alone while a tint is showing.

The render gate now checks the overlay ranks its tint from the dab core
through the feathered rim to untouched pixels outside the brush circle.
This commit is contained in:
2026-11-28 17:14:00 +00:00
parent c05dbce580
commit 46dcc231a7
3 changed files with 69 additions and 15 deletions
+24 -2
View File
@@ -296,6 +296,13 @@ try {
const dabSoft = pixelAt(0.25, 0.2); const dabSoft = pixelAt(0.25, 0.2);
const dabRimSoft = pixelAt(0.25, 0.2 + dabRadiusY * 0.75); const dabRimSoft = pixelAt(0.25, 0.2 + dabRadiusY * 0.75);
const dabOutsideSoft = pixelAt(0.25, 0.2 + dabRadiusY * 1.15); const dabOutsideSoft = pixelAt(0.25, 0.2 + dabRadiusY * 1.15);
// The develop view tints the baked mask instead of redrawing the stroke, so
// the overlay has to follow the same coverage: strong in the core, a real
// gradient at the rim, and nothing at all outside the brush circle.
renderer.render(brushEdits(80), { width: w, height: h, maskView: 0 });
const tintCore = pixelAt(0.25, 0.2);
const tintRim = pixelAt(0.25, 0.2 + dabRadiusY * 0.75);
const tintOutside = pixelAt(0.25, 0.2 + dabRadiusY * 1.15);
pre.textContent = 'RESULT ' + JSON.stringify({ pre.textContent = 'RESULT ' + JSON.stringify({
clipPixels, clipPixels,
@@ -328,6 +335,13 @@ try {
dabSoft, dabSoft,
dabRimSoft, dabRimSoft,
dabOutsideSoft, dabOutsideSoft,
tintCore,
tintRim,
tintOutside,
// Orange tint: blue is the channel the overlay pushes up, so it ranks the
// coverage without depending on how dark the adjustment left the pixels.
tintFollowsMask: tintCore[2] > tintRim[2] && tintRim[2] > tintOutside[2] + 5,
tintBounded: Math.abs(tintOutside[2] - dabOutsideSoft[2]) <= 1,
// A hard dab covers the core, and even an 80 % feather stops at the rim. // A hard dab covers the core, and even an 80 % feather stops at the rim.
dabCoreDarkened: dabHard[0] < 140, dabCoreDarkened: dabHard[0] < 140,
dabSoftCoreDarkened: dabSoft[0] < 140, dabSoftCoreDarkened: dabSoft[0] < 140,
@@ -554,18 +568,26 @@ async function main() {
` outsideHard=${JSON.stringify(result.dabOutsideHard)} soft=${JSON.stringify(result.dabSoft)}` + ` outsideHard=${JSON.stringify(result.dabOutsideHard)} soft=${JSON.stringify(result.dabSoft)}` +
` rimSoft=${JSON.stringify(result.dabRimSoft)} outsideSoft=${JSON.stringify(result.dabOutsideSoft)}`, ` rimSoft=${JSON.stringify(result.dabRimSoft)} outsideSoft=${JSON.stringify(result.dabOutsideSoft)}`,
); );
console.log(
`render check: mask overlay core=${JSON.stringify(result.tintCore)}` +
` rim=${JSON.stringify(result.tintRim)} outside=${JSON.stringify(result.tintOutside)}`,
);
if ( if (
!result.dabCoreDarkened || !result.dabCoreDarkened ||
!result.dabSoftCoreDarkened || !result.dabSoftCoreDarkened ||
!result.dabRimSmooth || !result.dabRimSmooth ||
!result.dabBoundedHard || !result.dabBoundedHard ||
!result.dabBoundedSoft !result.dabBoundedSoft ||
!result.tintFollowsMask ||
!result.tintBounded
) { ) {
console.error( console.error(
'render check FAILED: the brush mask does not follow the brush circle ' + 'render check FAILED: the brush mask does not follow the brush circle ' +
`(hard=${JSON.stringify(result.dabHard)}, rim=${JSON.stringify(result.dabRimSoft)}, ` + `(hard=${JSON.stringify(result.dabHard)}, rim=${JSON.stringify(result.dabRimSoft)}, ` +
`outsideHard=${JSON.stringify(result.dabOutsideHard)}, ` + `outsideHard=${JSON.stringify(result.dabOutsideHard)}, ` +
`outsideSoft=${JSON.stringify(result.dabOutsideSoft)}).`, `outsideSoft=${JSON.stringify(result.dabOutsideSoft)}, ` +
`tint=${JSON.stringify(result.tintCore)}/${JSON.stringify(result.tintRim)}/` +
`${JSON.stringify(result.tintOutside)}).`,
); );
return 1; return 1;
} }
+24 -12
View File
@@ -597,6 +597,14 @@ export default function Develop({
: view, : view,
); );
// The mask overlay is the baked mask itself, so it can only be shown when a
// local layer is selected. The histogram ignores it: a tinted chart is not
// a measurement of the photo.
const maskView =
showOriginal || !localMode
? -1
: (edits.local ?? []).findIndex((layer) => layer.id === localSelected);
try { try {
renderer.setImage(bitmap, hdrSource); renderer.setImage(bitmap, hdrSource);
// "Show original" must show the untouched source, not the cleaned proxy. // "Show original" must show the untouched source, not the cleaned proxy.
@@ -606,7 +614,7 @@ export default function Develop({
height: pxH, height: pxH,
cropPreview: cropMode, cropPreview: cropMode,
// The histogram describes the whole photo, so it is only refreshed at fit. // The histogram describes the whole photo, so it is only refreshed at fit.
histogram: !cropMode && !showOriginal && zoomFactor <= 1.0001, histogram: !cropMode && !showOriginal && zoomFactor <= 1.0001 && maskView < 0,
view: zoomFactor <= 1.0001 ? undefined : view, view: zoomFactor <= 1.0001 ? undefined : view,
// Holding the grain still keeps the noise from crawling while a crop // Holding the grain still keeps the noise from crawling while a crop
// handle moves; the new crop-relative scale applies on release. // handle moves; the new crop-relative scale applies on release.
@@ -618,6 +626,7 @@ export default function Develop({
clipping: clipping ?? undefined, clipping: clipping ?? undefined,
lens: showOriginal ? null : lensCorrection, lens: showOriginal ? null : lensCorrection,
lensSplit: lensSplit && !showOriginal ? lensSplitAt : undefined, lensSplit: lensSplit && !showOriginal ? lensSplitAt : undefined,
maskView,
}); });
histRef.current = renderer.histogram; histRef.current = renderer.histogram;
setHistVersion((v) => v + 1); setHistVersion((v) => v + 1);
@@ -639,6 +648,8 @@ export default function Develop({
lensCorrection, lensCorrection,
lensSplit, lensSplit,
lensSplitAt, lensSplitAt,
localMode,
localSelected,
// Loading or clearing a printer profile changes the finish pass, and the // Loading or clearing a printer profile changes the finish pass, and the
// cube lives outside the edit record, so the redraw is keyed on it here. // cube lives outside the edit record, so the redraw is keyed on it here.
proofProfile, proofProfile,
@@ -2210,36 +2221,37 @@ export default function Develop({
/** Brush diameter in canvas pixels, for the stroke preview. */ /** Brush diameter in canvas pixels, for the stroke preview. */
const diameterPx = (r: number) => (r * 2 * bitmap.width * canvasW) / (frame.w * view.w); const diameterPx = (r: number) => (r * 2 * bitmap.width * canvasW) / (frame.w * view.w);
const feather = Math.max(0, Math.min(1, activeComponent.feather / 100)); const feather = Math.max(0, Math.min(1, activeComponent.feather / 100));
const strokes = localDraft // Committed strokes are not redrawn here: the shader tints the
? [...activeComponent.brush.strokes, localDraft] // baked mask, which is the real feathered shape. Only the stroke
: activeComponent.brush.strokes; // in progress is drawn, as a preview of what will be baked.
const draft = localDraft && localDraft.points.length ? localDraft : null;
return ( return (
<svg className="local-layer" viewBox="0 0 100 100" preserveAspectRatio="none"> <svg className="local-layer" viewBox="0 0 100 100" preserveAspectRatio="none">
{activeComponent.kind === 'brush' && {activeComponent.kind === 'brush' &&
strokes.map((stroke, i) => { (() => {
if (!stroke.points.length) return null; if (!draft) return null;
const points = stroke.points.map(marker).map((p) => `${p.x},${p.y}`).join(' '); const points = draft.points.map(marker).map((p) => `${p.x},${p.y}`).join(' ');
const width = Math.max(1, diameterPx(stroke.size)); const width = Math.max(1, diameterPx(draft.size));
const core = Math.max(1, width * (1 - feather)); const core = Math.max(1, width * (1 - feather));
return ( return (
<g key={i}> <g>
{core < width - 0.5 && ( {core < width - 0.5 && (
<polyline <polyline
points={points} points={points}
className={`local-brush band ${stroke.erase ? 'erase' : ''}`} className={`local-brush band ${draft.erase ? 'erase' : ''}`}
strokeWidth={width} strokeWidth={width}
vectorEffect="non-scaling-stroke" vectorEffect="non-scaling-stroke"
/> />
)} )}
<polyline <polyline
points={points} points={points}
className={`local-brush ${stroke.erase ? 'erase' : ''}`} className={`local-brush ${draft.erase ? 'erase' : ''}`}
strokeWidth={core} strokeWidth={core}
vectorEffect="non-scaling-stroke" vectorEffect="non-scaling-stroke"
/> />
</g> </g>
); );
})} })()}
{activeComponent.kind === 'radial' && (() => { {activeComponent.kind === 'radial' && (() => {
const c = marker({ x: activeComponent.radial.cx, y: activeComponent.radial.cy }); const c = marker({ x: activeComponent.radial.cx, y: activeComponent.radial.cy });
const edge = marker({ const edge = marker({
+21 -1
View File
@@ -77,6 +77,8 @@ uniform vec2 u_healSize[24];
uniform sampler2D u_masks; // layers 1-4 uniform sampler2D u_masks; // layers 1-4
uniform sampler2D u_masks2; // layers 5-8 uniform sampler2D u_masks2; // layers 5-8
uniform int u_localCount; uniform int u_localCount;
// Local mask overlay: index of the layer tinted over the picture, -1 = off.
uniform float u_maskView;
uniform vec4 u_localAdj[8]; // exposure, contrast, temp, tint uniform vec4 u_localAdj[8]; // exposure, contrast, temp, tint
uniform vec4 u_localAdj2[8]; // saturation, highlights, shadows, unused uniform vec4 u_localAdj2[8]; // saturation, highlights, shadows, unused
uniform vec4 u_localAdj3[8]; // whites, blacks, vibrance, hue degrees uniform vec4 u_localAdj3[8]; // whites, blacks, vibrance, hue degrees
@@ -566,6 +568,18 @@ void main(){
} }
} }
// Mask overlay: tint the baked shape, not a redrawn brush band. Reading the
// same source uv the adjustments use keeps the preview on the picture through
// crops, straightening, zoom and lens correction, and it shows the feather
// exactly as the mask stores it.
if (u_maskView >= 0.0 && u_localCount > 0) {
int mv = int(u_maskView + 0.5);
int mk = mv < 4 ? mv : mv - 4;
vec4 mtex = mv < 4 ? texture(u_masks, uv) : texture(u_masks2, uv);
float cov = mk == 0 ? mtex.r : mk == 1 ? mtex.g : mk == 2 ? mtex.b : mtex.a;
srgb = mix(srgb, vec3(0.98, 0.72, 0.35), clamp(cov, 0.0, 1.0) * 0.5);
}
outColor = vec4(clamp(srgb, 0.0, 1.0), 1.0); outColor = vec4(clamp(srgb, 0.0, 1.0), 1.0);
}`; }`;
@@ -1792,6 +1806,7 @@ export class Renderer {
bounds: { w: number; h: number }, bounds: { w: number; h: number },
upscale: boolean, upscale: boolean,
srcLod = 0, srcLod = 0,
maskView = -1,
) { ) {
const g = this.grade; const g = this.grade;
this.gl.useProgram(g.program); this.gl.useProgram(g.program);
@@ -1878,6 +1893,8 @@ export class Renderer {
g.tex('u_masks2', this.maskTex2, 7); g.tex('u_masks2', this.maskTex2, 7);
g.tex('u_localCurves', curveTex, 8); g.tex('u_localCurves', curveTex, 8);
g.i('u_localCount', localCount); g.i('u_localCount', localCount);
// Only tint a layer that this edit actually has; -1 leaves the picture alone.
g.f('u_maskView', maskView >= 0 && maskView < localCount ? maskView : -1);
for (let i = 0; i < localCount; i++) { for (let i = 0; i < localCount; i++) {
const layer = edits.local[i]; const layer = edits.local[i];
g.v4i('u_localAdj', i, layer.adjust.exposure, layer.adjust.contrast, layer.adjust.temp, layer.adjust.tint); g.v4i('u_localAdj', i, layer.adjust.exposure, layer.adjust.contrast, layer.adjust.temp, layer.adjust.tint);
@@ -1920,6 +1937,7 @@ export class Renderer {
// shows the Optics split. // shows the Optics split.
const split = this.lensSplit; const split = this.lensSplit;
this.lensSplit = -1; this.lensSplit = -1;
// No mask overlay here: the eyedropper must read the photo, not the tint.
this.bindGrade(edits, crop, valid, bounds, !!opts.upscale); this.bindGrade(edits, crop, valid, bounds, !!opts.upscale);
this.lensSplit = split; this.lensSplit = split;
this.grade.f('u_pick', 1); this.grade.f('u_pick', 1);
@@ -1961,6 +1979,8 @@ export class Renderer {
clipPreview?: boolean; clipPreview?: boolean;
/** paint blown highlights or crushed shadows outside the range */ /** paint blown highlights or crushed shadows outside the range */
clipping?: 'highlights' | 'shadows'; clipping?: 'highlights' | 'shadows';
/** tint this local layer's baked mask over the picture; -1 or omitted = off */
maskView?: number;
/** return the finished image as linear-space floats instead of drawing the canvas */ /** return the finished image as linear-space floats instead of drawing the canvas */
floatOut?: boolean; floatOut?: boolean;
}, },
@@ -2005,7 +2025,7 @@ export class Renderer {
const cropPxW = Math.max(1, bounds.w * crop.w); const cropPxW = Math.max(1, bounds.w * crop.w);
const cropPxH = Math.max(1, bounds.h * crop.h); const cropPxH = Math.max(1, bounds.h * crop.h);
const srcLod = Math.max(0, Math.log2(Math.max(cropPxW / w, cropPxH / h))); const srcLod = Math.max(0, Math.log2(Math.max(cropPxW / w, cropPxH / h)));
this.bindGrade(edits, crop, valid, bounds, !!opts.upscale, srcLod); this.bindGrade(edits, crop, valid, bounds, !!opts.upscale, srcLod, opts.maskView ?? -1);
this.drawQuad(); this.drawQuad();
// Passes 2-3: small blur (detail) and large blur (clarity) from the graded image // Passes 2-3: small blur (detail) and large blur (clarity) from the graded image