Make the mask tint a view toggle and mask local detail in source space

The mask overlay was always painted while the mask tool was open, at a fixed
strength; it is now a persisted view toggle (O or the Mask button) with its own
strength slider, so the photo underneath stays readable. The mask HUD also
gains + and - so a brush can erase and a shape can subtract without leaving the
canvas.

Local texture, clarity, dehaze and sharpen sampled the baked masks at the view
coordinate in the finish pass, so their coverage slid off the subject under a
crop or zoom. The grade pass now writes each pixel's source coordinate to a
second render target and the finish pass reads the masks through it, which also
follows straightening and lens correction.

The render gate checks the tint and a local dehaze amount through a quarter
frame crop and a synthetic lens warp, plus the tint strength and toggle.
This commit is contained in:
2026-11-28 17:39:31 +00:00
parent 46dcc231a7
commit fb43ca8e99
4 changed files with 297 additions and 27 deletions
+93 -6
View File
@@ -267,6 +267,12 @@ export default function Develop({
const [localBrush, setLocalBrush] = useState(72);
const [localHover, setLocalHover] = useState<{ x: number; y: number } | null>(null);
const [localDraft, setLocalDraft] = useState<LocalStroke | null>(null);
// The mask tint is a view aid, not an edit: it has its own toggle (O) and
// strength, and both are display preferences rather than catalog data.
const [maskOverlay, setMaskOverlay] = usePersistentState('develop.maskOverlay', true);
const [maskStrength, setMaskStrength] = usePersistentState('develop.maskStrength', 50);
// How the next mask gesture combines with the group: paint or erase.
const [localErase, setLocalErase] = useState(false);
const [lensCorrection, setLensCorrection] = useState<LensCorrection | null>(null);
const [lensSplit, setLensSplit] = useState(false);
const [lensSplitAt, setLensSplitAt] = useState(0.5);
@@ -597,11 +603,12 @@ export default function Develop({
: 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.
// The mask overlay is the baked mask itself, and it is a view toggle: off
// while holding \\ (before/after), while the mask tool is closed, or when
// the user hides it. The histogram ignores it: a tinted chart is not a
// measurement of the photo.
const maskView =
showOriginal || !localMode
showOriginal || !localMode || !maskOverlay
? -1
: (edits.local ?? []).findIndex((layer) => layer.id === localSelected);
@@ -627,6 +634,7 @@ export default function Develop({
lens: showOriginal ? null : lensCorrection,
lensSplit: lensSplit && !showOriginal ? lensSplitAt : undefined,
maskView,
maskStrength: maskStrength / 100,
});
histRef.current = renderer.histogram;
setHistVersion((v) => v + 1);
@@ -650,6 +658,8 @@ export default function Develop({
lensSplitAt,
localMode,
localSelected,
maskOverlay,
maskStrength,
// 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.
proofProfile,
@@ -1246,7 +1256,11 @@ export default function Develop({
e.preventDefault();
e.currentTarget.setPointerCapture(e.pointerId);
if (activeComponent.kind === 'brush') {
const stroke: LocalStroke = { points: [p], size: localRadius(), erase: e.altKey };
const stroke: LocalStroke = {
points: [p],
size: localRadius(),
erase: e.altKey || localErase,
};
localDrag.current = { layerId: activeLocal.id, componentId: activeComponent.id, mode: 'brush', stroke };
setLocalDraft(stroke);
return;
@@ -1381,9 +1395,16 @@ export default function Develop({
setLocalComponentSelected(null);
setLocalMode(false);
setLocalDraft(null);
setLocalErase(false);
localDrag.current = null;
}, [photo.id]);
// Leaving the mask tool drops the erase mode, so the next visit starts by
// painting rather than cutting holes into the mask.
useEffect(() => {
if (!localMode) setLocalErase(false);
}, [localMode]);
useEffect(() => {
if (!(edits.local ?? []).some((layer) => layer.id === localSelected)) {
setLocalSelected(null);
@@ -1529,6 +1550,13 @@ export default function Develop({
toggleLocalMode();
e.preventDefault();
}
} else if (e.key.toLowerCase() === 'o' && !e.metaKey && !e.ctrlKey && !e.altKey) {
// The mask tint is a view, so it can be hidden while painting or
// checking the photo underneath without leaving the mask tool.
if (localMode) {
setMaskOverlay((v) => !v);
e.preventDefault();
}
} else if (e.key === 'Enter' && cropMode) {
setCropMode(false);
} else if (e.key === 'Escape') {
@@ -2382,6 +2410,42 @@ export default function Develop({
<span className="heal-read">{Math.round(activeComponent.feather)}%</span>
</>
)}
<button
className={`heal-act ${(activeComponent.kind === 'brush' ? !localErase : activeComponent.mode !== 'subtract') ? 'on' : ''}`}
onClick={() => {
if (activeComponent.kind === 'brush') {
setLocalErase(false);
} else if (activeComponent.mode === 'subtract') {
patchComponent(activeLocal.id, activeComponent.id, { mode: 'add' }, 'Shape add');
}
}}
title="Add to the mask (+)"
>
+
</button>
<button
className={`heal-act ${(activeComponent.kind === 'brush' ? localErase : activeComponent.mode === 'subtract') ? 'on' : ''}`}
onClick={() => {
if (activeComponent.kind === 'brush') {
setLocalErase(true);
} else {
patchComponent(activeLocal.id, activeComponent.id, { mode: 'subtract' }, 'Shape subtract');
}
}}
disabled={
activeComponent.kind !== 'brush' &&
activeLocal.components[0]?.id === activeComponent.id
}
title={
activeComponent.kind === 'brush'
? 'Erase from the mask (−)'
: activeLocal.components[0]?.id === activeComponent.id
? 'The first shape starts the mask, so it always adds'
: 'Subtract this shape from the mask (−)'
}
>
−
</button>
<button
className="heal-act"
onClick={() => {
@@ -2411,12 +2475,35 @@ export default function Develop({
>
Clear
</button>
<button
className={`heal-act ${maskOverlay ? 'on' : ''}`}
onClick={() => setMaskOverlay((v) => !v)}
title="Show or hide the mask tint (O)"
>
Mask
</button>
{maskOverlay && (
<>
<label className="heal-field">
Tint
<input
type="range"
min={10}
max={100}
step={1}
value={maskStrength}
onChange={(e) => setMaskStrength(Number(e.target.value))}
/>
</label>
<span className="heal-read">{Math.round(maskStrength)}%</span>
</>
)}
<button className="heal-act on" onClick={() => setLocalMode(false)}>
Done
</button>
<span className="heal-tip">
{activeComponent.kind === 'brush'
? 'Paint the mask · Alt paints an erase stroke · wheel sizes the brush'
? 'Paint the mask · − erases · Alt erases one stroke · wheel sizes the brush'
: activeComponent.kind === 'radial'
? 'Drag the centre or the edge handle · wheel zooms'
: 'Drag either end of the gradient'}