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:
@@ -296,6 +296,13 @@ try {
|
||||
const dabSoft = pixelAt(0.25, 0.2);
|
||||
const dabRimSoft = pixelAt(0.25, 0.2 + dabRadiusY * 0.75);
|
||||
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({
|
||||
clipPixels,
|
||||
@@ -328,6 +335,13 @@ try {
|
||||
dabSoft,
|
||||
dabRimSoft,
|
||||
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.
|
||||
dabCoreDarkened: dabHard[0] < 140,
|
||||
dabSoftCoreDarkened: dabSoft[0] < 140,
|
||||
@@ -554,18 +568,26 @@ async function main() {
|
||||
` outsideHard=${JSON.stringify(result.dabOutsideHard)} soft=${JSON.stringify(result.dabSoft)}` +
|
||||
` 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 (
|
||||
!result.dabCoreDarkened ||
|
||||
!result.dabSoftCoreDarkened ||
|
||||
!result.dabRimSmooth ||
|
||||
!result.dabBoundedHard ||
|
||||
!result.dabBoundedSoft
|
||||
!result.dabBoundedSoft ||
|
||||
!result.tintFollowsMask ||
|
||||
!result.tintBounded
|
||||
) {
|
||||
console.error(
|
||||
'render check FAILED: the brush mask does not follow the brush circle ' +
|
||||
`(hard=${JSON.stringify(result.dabHard)}, rim=${JSON.stringify(result.dabRimSoft)}, ` +
|
||||
`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;
|
||||
}
|
||||
|
||||
+24
-12
@@ -597,6 +597,14 @@ 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.
|
||||
const maskView =
|
||||
showOriginal || !localMode
|
||||
? -1
|
||||
: (edits.local ?? []).findIndex((layer) => layer.id === localSelected);
|
||||
|
||||
try {
|
||||
renderer.setImage(bitmap, hdrSource);
|
||||
// "Show original" must show the untouched source, not the cleaned proxy.
|
||||
@@ -606,7 +614,7 @@ export default function Develop({
|
||||
height: pxH,
|
||||
cropPreview: cropMode,
|
||||
// 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,
|
||||
// Holding the grain still keeps the noise from crawling while a crop
|
||||
// handle moves; the new crop-relative scale applies on release.
|
||||
@@ -618,6 +626,7 @@ export default function Develop({
|
||||
clipping: clipping ?? undefined,
|
||||
lens: showOriginal ? null : lensCorrection,
|
||||
lensSplit: lensSplit && !showOriginal ? lensSplitAt : undefined,
|
||||
maskView,
|
||||
});
|
||||
histRef.current = renderer.histogram;
|
||||
setHistVersion((v) => v + 1);
|
||||
@@ -639,6 +648,8 @@ export default function Develop({
|
||||
lensCorrection,
|
||||
lensSplit,
|
||||
lensSplitAt,
|
||||
localMode,
|
||||
localSelected,
|
||||
// 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,
|
||||
@@ -2210,36 +2221,37 @@ export default function Develop({
|
||||
/** Brush diameter in canvas pixels, for the stroke preview. */
|
||||
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 strokes = localDraft
|
||||
? [...activeComponent.brush.strokes, localDraft]
|
||||
: activeComponent.brush.strokes;
|
||||
// Committed strokes are not redrawn here: the shader tints the
|
||||
// baked mask, which is the real feathered shape. Only the stroke
|
||||
// in progress is drawn, as a preview of what will be baked.
|
||||
const draft = localDraft && localDraft.points.length ? localDraft : null;
|
||||
return (
|
||||
<svg className="local-layer" viewBox="0 0 100 100" preserveAspectRatio="none">
|
||||
{activeComponent.kind === 'brush' &&
|
||||
strokes.map((stroke, i) => {
|
||||
if (!stroke.points.length) return null;
|
||||
const points = stroke.points.map(marker).map((p) => `${p.x},${p.y}`).join(' ');
|
||||
const width = Math.max(1, diameterPx(stroke.size));
|
||||
(() => {
|
||||
if (!draft) return null;
|
||||
const points = draft.points.map(marker).map((p) => `${p.x},${p.y}`).join(' ');
|
||||
const width = Math.max(1, diameterPx(draft.size));
|
||||
const core = Math.max(1, width * (1 - feather));
|
||||
return (
|
||||
<g key={i}>
|
||||
<g>
|
||||
{core < width - 0.5 && (
|
||||
<polyline
|
||||
points={points}
|
||||
className={`local-brush band ${stroke.erase ? 'erase' : ''}`}
|
||||
className={`local-brush band ${draft.erase ? 'erase' : ''}`}
|
||||
strokeWidth={width}
|
||||
vectorEffect="non-scaling-stroke"
|
||||
/>
|
||||
)}
|
||||
<polyline
|
||||
points={points}
|
||||
className={`local-brush ${stroke.erase ? 'erase' : ''}`}
|
||||
className={`local-brush ${draft.erase ? 'erase' : ''}`}
|
||||
strokeWidth={core}
|
||||
vectorEffect="non-scaling-stroke"
|
||||
/>
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
})()}
|
||||
{activeComponent.kind === 'radial' && (() => {
|
||||
const c = marker({ x: activeComponent.radial.cx, y: activeComponent.radial.cy });
|
||||
const edge = marker({
|
||||
|
||||
+21
-1
@@ -77,6 +77,8 @@ uniform vec2 u_healSize[24];
|
||||
uniform sampler2D u_masks; // layers 1-4
|
||||
uniform sampler2D u_masks2; // layers 5-8
|
||||
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_localAdj2[8]; // saturation, highlights, shadows, unused
|
||||
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);
|
||||
}`;
|
||||
|
||||
@@ -1792,6 +1806,7 @@ export class Renderer {
|
||||
bounds: { w: number; h: number },
|
||||
upscale: boolean,
|
||||
srcLod = 0,
|
||||
maskView = -1,
|
||||
) {
|
||||
const g = this.grade;
|
||||
this.gl.useProgram(g.program);
|
||||
@@ -1878,6 +1893,8 @@ export class Renderer {
|
||||
g.tex('u_masks2', this.maskTex2, 7);
|
||||
g.tex('u_localCurves', curveTex, 8);
|
||||
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++) {
|
||||
const layer = edits.local[i];
|
||||
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.
|
||||
const split = this.lensSplit;
|
||||
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.lensSplit = split;
|
||||
this.grade.f('u_pick', 1);
|
||||
@@ -1961,6 +1979,8 @@ export class Renderer {
|
||||
clipPreview?: boolean;
|
||||
/** paint blown highlights or crushed shadows outside the range */
|
||||
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 */
|
||||
floatOut?: boolean;
|
||||
},
|
||||
@@ -2005,7 +2025,7 @@ export class Renderer {
|
||||
const cropPxW = Math.max(1, bounds.w * crop.w);
|
||||
const cropPxH = Math.max(1, bounds.h * crop.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();
|
||||
|
||||
// Passes 2-3: small blur (detail) and large blur (clarity) from the graded image
|
||||
|
||||
Reference in New Issue
Block a user