@nodetool-ai/timeline 0.8.11 → 0.8.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.nodetool-build-stamp +1 -1
- package/dist/animation/compile.d.ts +1 -1
- package/dist/animation/compile.d.ts.map +1 -1
- package/dist/animation/compile.js +2 -1
- package/dist/animation/compile.js.map +1 -1
- package/dist/animation/custom.d.ts +3 -1
- package/dist/animation/custom.d.ts.map +1 -1
- package/dist/animation/custom.js +6 -4
- package/dist/animation/custom.js.map +1 -1
- package/dist/audioCrossfade.d.ts +2 -0
- package/dist/audioCrossfade.d.ts.map +1 -1
- package/dist/audioCrossfade.js +8 -3
- package/dist/audioCrossfade.js.map +1 -1
- package/dist/automation.js +21 -23
- package/dist/automation.js.map +1 -1
- package/dist/clipSpeed.js +1 -1
- package/dist/clipSpeed.js.map +1 -1
- package/dist/colorSpaceVersion.d.ts +11 -0
- package/dist/colorSpaceVersion.d.ts.map +1 -0
- package/dist/colorSpaceVersion.js +21 -0
- package/dist/colorSpaceVersion.js.map +1 -0
- package/dist/defaults.d.ts.map +1 -1
- package/dist/defaults.js +7 -1
- package/dist/defaults.js.map +1 -1
- package/dist/effectMasks.d.ts +43 -0
- package/dist/effectMasks.d.ts.map +1 -0
- package/dist/effectMasks.js +170 -0
- package/dist/effectMasks.js.map +1 -0
- package/dist/harmony/expand.d.ts.map +1 -1
- package/dist/harmony/expand.js +19 -4
- package/dist/harmony/expand.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/interchange.d.ts +17 -0
- package/dist/interchange.d.ts.map +1 -1
- package/dist/interchange.js +310 -61
- package/dist/interchange.js.map +1 -1
- package/dist/interchangeImport.d.ts +16 -2
- package/dist/interchangeImport.d.ts.map +1 -1
- package/dist/interchangeImport.js +185 -27
- package/dist/interchangeImport.js.map +1 -1
- package/dist/interchangeMotion.d.ts +49 -0
- package/dist/interchangeMotion.d.ts.map +1 -0
- package/dist/interchangeMotion.js +109 -0
- package/dist/interchangeMotion.js.map +1 -0
- package/dist/interchangeMotionImport.d.ts +84 -0
- package/dist/interchangeMotionImport.d.ts.map +1 -0
- package/dist/interchangeMotionImport.js +204 -0
- package/dist/interchangeMotionImport.js.map +1 -0
- package/dist/keyframes.d.ts +8 -1
- package/dist/keyframes.d.ts.map +1 -1
- package/dist/keyframes.js +22 -19
- package/dist/keyframes.js.map +1 -1
- package/dist/ops/apply.d.ts.map +1 -1
- package/dist/ops/apply.js +8 -0
- package/dist/ops/apply.js.map +1 -1
- package/dist/ops/types.d.ts +1 -0
- package/dist/ops/types.d.ts.map +1 -1
- package/dist/paramCurves.d.ts +43 -0
- package/dist/paramCurves.d.ts.map +1 -0
- package/dist/paramCurves.js +83 -0
- package/dist/paramCurves.js.map +1 -0
- package/dist/render/canvas2d.d.ts +2 -27
- package/dist/render/canvas2d.d.ts.map +1 -1
- package/dist/render/canvas2d.js +35 -7
- package/dist/render/canvas2d.js.map +1 -1
- package/dist/render/clipAnalysis.d.ts +20 -0
- package/dist/render/clipAnalysis.d.ts.map +1 -0
- package/dist/render/clipAnalysis.js +92 -0
- package/dist/render/clipAnalysis.js.map +1 -0
- package/dist/render/cpuLegacyEffects.d.ts +2 -1
- package/dist/render/cpuLegacyEffects.d.ts.map +1 -1
- package/dist/render/cpuLegacyEffects.js +100 -30
- package/dist/render/cpuLegacyEffects.js.map +1 -1
- package/dist/render/curveTransfer.d.ts +5 -0
- package/dist/render/curveTransfer.d.ts.map +1 -0
- package/dist/render/curveTransfer.js +37 -0
- package/dist/render/curveTransfer.js.map +1 -0
- package/dist/render/deband.d.ts +4 -0
- package/dist/render/deband.d.ts.map +1 -0
- package/dist/render/deband.js +51 -0
- package/dist/render/deband.js.map +1 -0
- package/dist/render/denoise.d.ts +12 -0
- package/dist/render/denoise.d.ts.map +1 -0
- package/dist/render/denoise.js +173 -0
- package/dist/render/denoise.js.map +1 -0
- package/dist/render/effects.d.ts +16 -5
- package/dist/render/effects.d.ts.map +1 -1
- package/dist/render/effects.js +238 -47
- package/dist/render/effects.js.map +1 -1
- package/dist/render/exposure.d.ts +3 -0
- package/dist/render/exposure.d.ts.map +1 -0
- package/dist/render/exposure.js +20 -0
- package/dist/render/exposure.js.map +1 -0
- package/dist/render/frameCompositor.d.ts +28 -2
- package/dist/render/frameCompositor.d.ts.map +1 -1
- package/dist/render/frameCompositor.js +196 -54
- package/dist/render/frameCompositor.js.map +1 -1
- package/dist/render/headlessRender.d.ts +1 -0
- package/dist/render/headlessRender.d.ts.map +1 -1
- package/dist/render/hueSatCurves.d.ts +11 -0
- package/dist/render/hueSatCurves.d.ts.map +1 -0
- package/dist/render/hueSatCurves.js +55 -0
- package/dist/render/hueSatCurves.js.map +1 -0
- package/dist/render/index.d.ts +3 -0
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/index.js +3 -0
- package/dist/render/index.js.map +1 -1
- package/dist/render/sceneModel.d.ts +3 -2
- package/dist/render/sceneModel.d.ts.map +1 -1
- package/dist/render/sceneModel.js +11 -7
- package/dist/render/sceneModel.js.map +1 -1
- package/dist/render/secondaryColor.d.ts +12 -0
- package/dist/render/secondaryColor.d.ts.map +1 -0
- package/dist/render/secondaryColor.js +88 -0
- package/dist/render/secondaryColor.js.map +1 -0
- package/dist/render/stabilization.d.ts +29 -0
- package/dist/render/stabilization.d.ts.map +1 -0
- package/dist/render/stabilization.js +185 -0
- package/dist/render/stabilization.js.map +1 -0
- package/dist/render/textLayout.d.ts +4 -2
- package/dist/render/textLayout.d.ts.map +1 -1
- package/dist/render/textLayout.js +5 -3
- package/dist/render/textLayout.js.map +1 -1
- package/dist/render/trackEffects.d.ts.map +1 -1
- package/dist/render/trackEffects.js +8 -1
- package/dist/render/trackEffects.js.map +1 -1
- package/dist/render/vignette.d.ts +7 -0
- package/dist/render/vignette.d.ts.map +1 -0
- package/dist/render/vignette.js +16 -0
- package/dist/render/vignette.js.map +1 -0
- package/dist/scene.d.ts +1 -0
- package/dist/scene.d.ts.map +1 -1
- package/dist/scene.js +1 -0
- package/dist/scene.js.map +1 -1
- package/dist/script.d.ts +4 -2
- package/dist/script.d.ts.map +1 -1
- package/dist/script.js +52 -18
- package/dist/script.js.map +1 -1
- package/dist/shotLink.d.ts +2 -1
- package/dist/shotLink.d.ts.map +1 -1
- package/dist/shotLink.js +10 -1
- package/dist/shotLink.js.map +1 -1
- package/dist/slideEdit.d.ts.map +1 -1
- package/dist/slideEdit.js +65 -28
- package/dist/slideEdit.js.map +1 -1
- package/dist/source-merge.d.ts +1 -0
- package/dist/source-merge.d.ts.map +1 -1
- package/dist/source-merge.js +6 -0
- package/dist/source-merge.js.map +1 -1
- package/dist/splitClip.d.ts.map +1 -1
- package/dist/splitClip.js +22 -9
- package/dist/splitClip.js.map +1 -1
- package/dist/timeRemap.d.ts +4 -3
- package/dist/timeRemap.d.ts.map +1 -1
- package/dist/timeRemap.js +9 -4
- package/dist/timeRemap.js.map +1 -1
- package/dist/trimClip.d.ts.map +1 -1
- package/dist/trimClip.js +12 -7
- package/dist/trimClip.js.map +1 -1
- package/dist/types.d.ts +284 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +29 -0
- package/dist/types.js.map +1 -1
- package/package.json +11 -5
package/dist/render/effects.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stabilizationNeutral } from "./stabilization.js";
|
|
2
|
+
import { secondaryCurveTransfer, secondaryNeutral } from "./secondaryColor.js";
|
|
3
|
+
import { hueSatCurvesNeutral, hueSatCurvesTransfer } from "./hueSatCurves.js";
|
|
4
|
+
import { curveTransfer } from "./curveTransfer.js";
|
|
2
5
|
import { GENERATOR_MODES, STYLIZE_MODES } from "../types.js";
|
|
3
|
-
import { isClipBlurEffect, isClipChromaKeyEffect, isClipColorEffect, isClipCurvesEffect, isClipDropShadowEffect, isClipGlowEffect, isClipLevelsEffect, isClipLiftGammaGainEffect, isClipSharpenEffect, isClipVignetteEffect, isClipGrainEffect } from "../types.js";
|
|
4
|
-
import { createDefaultRegistry, createGPUContextFromDevice, createExecutor, createLabeledTexture, createRecipeRunner, LabeledTexture, colorCdlV1,
|
|
6
|
+
import { isClipBlurEffect, isClipDenoiseEffect, isClipStabilizeEffect, isClipDebandEffect, isClipSecondaryColorEffect, isClipHueSatCurvesEffect, isClipExposureEffect, isClipChromaKeyEffect, isClipColorEffect, isClipCurvesEffect, isClipDropShadowEffect, isClipGlowEffect, isClipLevelsEffect, isClipLiftGammaGainEffect, isClipSharpenEffect, isClipVignetteEffect, isClipGrainEffect } from "../types.js";
|
|
7
|
+
import { createDefaultRegistry, createGPUContextFromDevice, createExecutor, createLabeledTexture, createRecipeRunner, LabeledTexture, filtersDenoiseSpatialV1, filtersDenoiseTemporalV1, transformStabilizeV1, filterDebandV1, colorSecondaryV1, colorHueSatCurvesV1, colorExposureLinearV1, colorCdlV1, colorCurveTransferV1, colorGradeV1, colorLevelsV1, colorLiftGammaGainV1, blurGaussianV1, filtersGlowV1, mixerDropShadowV1, sharpenUnsharpMaskV1, sharpenGaussianV1, vignetteV2, filtersGrainV2, filtersPixelateV1, colorPosterizeV1, colorCubeLutV1, transformSpherizeV1, filtersVisualFxV1, chromaKeyV1, maskApplyV1, maskMixV1, maskFromImageV1, alphaPremulToStraightV1, alphaStraightToPremulV1 } from "@nodetool-ai/gpu/pool";
|
|
5
8
|
import * as d from "typegpu/data";
|
|
6
9
|
import { parseCssColorOrBlack } from "./color.js";
|
|
7
10
|
import { parseCubeLut } from "./cubeLut.js";
|
|
8
11
|
import { trackEffectsAsClipEffects } from "./trackEffects.js";
|
|
12
|
+
import { effectMaskCoverage, effectMasksOf, isMaskedEffect } from "../effectMasks.js";
|
|
9
13
|
const NEUTRAL_COLOR = {
|
|
10
14
|
brightness: 0,
|
|
11
15
|
contrast: 1,
|
|
@@ -63,6 +67,7 @@ const MASK_FROM_IMAGE_MODE = { alpha: 0, luma: 1 };
|
|
|
63
67
|
* are the ones `packages/image-nodes` already settled for the same modules.
|
|
64
68
|
*/
|
|
65
69
|
export class WebGPUEffectsProcessor {
|
|
70
|
+
workingFormat;
|
|
66
71
|
device;
|
|
67
72
|
ctx;
|
|
68
73
|
executor;
|
|
@@ -72,7 +77,9 @@ export class WebGPUEffectsProcessor {
|
|
|
72
77
|
registry;
|
|
73
78
|
pools = new Map();
|
|
74
79
|
lutTextures = new Map();
|
|
75
|
-
|
|
80
|
+
coverages = new Map();
|
|
81
|
+
constructor(device, workingFormat = "rgba8unorm") {
|
|
82
|
+
this.workingFormat = workingFormat;
|
|
76
83
|
this.device = device;
|
|
77
84
|
this.ctx = createGPUContextFromDevice(device);
|
|
78
85
|
this.executor = createExecutor();
|
|
@@ -102,7 +109,7 @@ export class WebGPUEffectsProcessor {
|
|
|
102
109
|
* {@link WebGPUEffectsProcessor.stepClipEffect} is the only place that knows
|
|
103
110
|
* which shader module an effect type is.
|
|
104
111
|
*
|
|
105
|
-
* Order:
|
|
112
|
+
* Order: source noise reduction and stabilization, then the track key and the clip's
|
|
106
113
|
* own new-type effects in the order the document lists them; then the
|
|
107
114
|
* aggregated clip+track colour and blur, and the track sharpen and vignette.
|
|
108
115
|
* The aggregate is one pass over both scopes, so a clip `color` cannot hold
|
|
@@ -118,8 +125,9 @@ export class WebGPUEffectsProcessor {
|
|
|
118
125
|
* and the GPU idles between them. Given an encoder, this records and lets
|
|
119
126
|
* the caller submit the frame once. Omitted, it behaves as it always did.
|
|
120
127
|
*/
|
|
121
|
-
frameEncoder) {
|
|
122
|
-
const enabledClip = clipEffects.filter((e) => e.enabled);
|
|
128
|
+
frameEncoder, temporalSources) {
|
|
129
|
+
const enabledClip = clipEffects.filter((e) => e.enabled && !(isMaskedEffect(e) && (isClipColorEffect(e) || isClipBlurEffect(e))));
|
|
130
|
+
const maskedAggregates = clipEffects.filter((e) => isMaskedEffect(e) && (isClipColorEffect(e) || isClipBlurEffect(e)));
|
|
123
131
|
const enabledTrack = trackEffectsAsClipEffects(trackEffects).filter((e) => e.enabled);
|
|
124
132
|
// Aggregate color & blur across clip + track scopes.
|
|
125
133
|
const color = aggregateColor(enabledClip, enabledTrack);
|
|
@@ -132,7 +140,10 @@ export class WebGPUEffectsProcessor {
|
|
|
132
140
|
const sharpenActive = sharpen != null && sharpen.amount > 0.001;
|
|
133
141
|
const vignetteActive = vignette != null && vignette.amount > 0.001;
|
|
134
142
|
const chromaKeyActive = chromaKey != null && chromaKey.tolerance > 0.001;
|
|
135
|
-
const shaderClip =
|
|
143
|
+
const shaderClip = [
|
|
144
|
+
...clipEffects.filter((e) => e.enabled && (isShaderStepEffect(e) || maskedAggregates.includes(e))),
|
|
145
|
+
...enabledTrack.filter(isClipExposureEffect)
|
|
146
|
+
];
|
|
136
147
|
if (!colorActive &&
|
|
137
148
|
!blurActive &&
|
|
138
149
|
!sharpenActive &&
|
|
@@ -144,7 +155,8 @@ export class WebGPUEffectsProcessor {
|
|
|
144
155
|
if (!frameEncoder) {
|
|
145
156
|
this.ctx.uniformRing.beginSubmission();
|
|
146
157
|
}
|
|
147
|
-
const
|
|
158
|
+
const workingFormat = this.workingFormat === "rgba16float" && source.format === "rgba16float" ? "rgba16float" : "rgba8unorm";
|
|
159
|
+
const pool = this.getPool(poolKey, width, height, workingFormat);
|
|
148
160
|
const encoder = frameEncoder ??
|
|
149
161
|
this.device.createCommandEncoder({
|
|
150
162
|
label: `preview-effects-${poolKey}`
|
|
@@ -158,10 +170,10 @@ export class WebGPUEffectsProcessor {
|
|
|
158
170
|
// straight→premul→straight round-trip when chromaKey runs first.
|
|
159
171
|
const sourceLabeled = new LabeledTexture(source, {
|
|
160
172
|
label: `preview-effects-${poolKey}-src`,
|
|
161
|
-
format:
|
|
173
|
+
format: source.format,
|
|
162
174
|
width,
|
|
163
175
|
height,
|
|
164
|
-
meta: { colorSpace: "
|
|
176
|
+
meta: { colorSpace: "encoded-sdr", alpha: sourceAlpha, bindingKind: "texture_2d" }
|
|
165
177
|
});
|
|
166
178
|
let pendingFirst = true;
|
|
167
179
|
/** The texture the next pass reads, and the pool slot it writes. */
|
|
@@ -183,11 +195,23 @@ export class WebGPUEffectsProcessor {
|
|
|
183
195
|
const step = (module, params) => {
|
|
184
196
|
const { input, outIdx } = pick();
|
|
185
197
|
const [wgX, wgY] = module.workgroupSize;
|
|
198
|
+
const inputs = { source: input };
|
|
199
|
+
if (module.id === filtersDenoiseTemporalV1.id) {
|
|
200
|
+
if (!temporalSources) {
|
|
201
|
+
throw new Error("Temporal noise reduction requires neighboring source frames.");
|
|
202
|
+
}
|
|
203
|
+
for (const key of ["before", "after"]) {
|
|
204
|
+
const texture = temporalSources[key];
|
|
205
|
+
inputs[key] = new LabeledTexture(texture, { label: `${poolKey}-denoise-${key}`, format: texture.format, width: texture.width, height: texture.height,
|
|
206
|
+
meta: { colorSpace: "encoded-sdr", alpha: "straight", bindingKind: "texture_2d" } });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
186
209
|
this.executor.encode({
|
|
187
210
|
ctx: this.ctx,
|
|
211
|
+
workingFormat,
|
|
188
212
|
module,
|
|
189
213
|
encoder,
|
|
190
|
-
inputs
|
|
214
|
+
inputs,
|
|
191
215
|
output: pool.textures[outIdx],
|
|
192
216
|
params,
|
|
193
217
|
dispatch: module.kind === "fragment"
|
|
@@ -205,6 +229,7 @@ export class WebGPUEffectsProcessor {
|
|
|
205
229
|
const { input, outIdx } = pick();
|
|
206
230
|
this.recipes.encode({
|
|
207
231
|
ctx: this.ctx,
|
|
232
|
+
workingFormat,
|
|
208
233
|
module,
|
|
209
234
|
encoder,
|
|
210
235
|
inputs: { source: input },
|
|
@@ -215,15 +240,22 @@ export class WebGPUEffectsProcessor {
|
|
|
215
240
|
});
|
|
216
241
|
settle(outIdx, module.io.output.alpha);
|
|
217
242
|
};
|
|
243
|
+
for (const effect of shaderClip.filter(isClipDenoiseEffect)) {
|
|
244
|
+
this.stepClipEffect(effect, width, height, step, stepRecipe);
|
|
245
|
+
}
|
|
246
|
+
for (const effect of shaderClip.filter(isClipStabilizeEffect)) {
|
|
247
|
+
this.stepClipEffect(effect, width, height, step, stepRecipe);
|
|
248
|
+
}
|
|
218
249
|
if (chromaKeyActive && chromaKey) {
|
|
219
250
|
this.stepClipEffect(chromaKey, width, height, step, stepRecipe);
|
|
220
251
|
}
|
|
221
|
-
for (const effect of shaderClip) {
|
|
252
|
+
for (const effect of shaderClip.filter(effect => !isClipStabilizeEffect(effect) && !isClipDenoiseEffect(effect))) {
|
|
222
253
|
if (effect.type === "lut" && typeof effect.cube === "string") {
|
|
223
254
|
const { texture: lut, parsed } = this.getLutTexture(effect.cube);
|
|
224
255
|
const { input, outIdx } = pick();
|
|
225
256
|
this.executor.encode({
|
|
226
257
|
ctx: this.ctx,
|
|
258
|
+
workingFormat,
|
|
227
259
|
module: colorCubeLutV1,
|
|
228
260
|
encoder,
|
|
229
261
|
inputs: { source: input, lut },
|
|
@@ -238,6 +270,53 @@ export class WebGPUEffectsProcessor {
|
|
|
238
270
|
});
|
|
239
271
|
settle(outIdx, colorCubeLutV1.io.output.alpha);
|
|
240
272
|
}
|
|
273
|
+
else if (isMaskedEffect(effect)) {
|
|
274
|
+
let before;
|
|
275
|
+
if (pendingFirst) {
|
|
276
|
+
before = sourceLabeled;
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
const current = pool.textures[pool.currentIndex];
|
|
280
|
+
pool.saved ??= this.makeIntermediate(`preview-effects-${poolKey}-saved`, width, height, workingFormat);
|
|
281
|
+
encoder.copyTextureToTexture({ texture: current.texture }, { texture: pool.saved.texture }, [width, height, 1]);
|
|
282
|
+
pool.saved.meta.alpha = current.meta.alpha;
|
|
283
|
+
before = pool.saved;
|
|
284
|
+
}
|
|
285
|
+
if (isClipColorEffect(effect)) {
|
|
286
|
+
const own = aggregateColor([effect], []);
|
|
287
|
+
if (isColorActive(own))
|
|
288
|
+
step(colorGradeV1, { ...own });
|
|
289
|
+
}
|
|
290
|
+
else if (isClipBlurEffect(effect)) {
|
|
291
|
+
const radius = aggregateBlurRadius([effect], []);
|
|
292
|
+
if (radius >= 0.5) {
|
|
293
|
+
step(blurGaussianV1, { radius, sigma: radius / 3, direction: d.vec2f(1, 0) });
|
|
294
|
+
step(blurGaussianV1, { radius, sigma: radius / 3, direction: d.vec2f(0, 1) });
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
this.stepClipEffect(effect, width, height, step, stepRecipe);
|
|
299
|
+
}
|
|
300
|
+
if (pendingFirst)
|
|
301
|
+
continue;
|
|
302
|
+
const coverage = this.coverageTexture(poolKey, effect, width, height);
|
|
303
|
+
const { input, outIdx } = pick();
|
|
304
|
+
this.executor.encode({
|
|
305
|
+
ctx: this.ctx,
|
|
306
|
+
workingFormat,
|
|
307
|
+
module: maskMixV1,
|
|
308
|
+
encoder,
|
|
309
|
+
inputs: {
|
|
310
|
+
source: input,
|
|
311
|
+
base: before,
|
|
312
|
+
mask: this.label(coverage, `${poolKey}-effect-mask`, width, height, "premultiplied")
|
|
313
|
+
},
|
|
314
|
+
output: pool.textures[outIdx],
|
|
315
|
+
params: { amount: 1 },
|
|
316
|
+
dispatch: { kind: "fragment" }
|
|
317
|
+
});
|
|
318
|
+
settle(outIdx, maskMixV1.io.output.alpha);
|
|
319
|
+
}
|
|
241
320
|
else {
|
|
242
321
|
this.stepClipEffect(effect, width, height, step, stepRecipe);
|
|
243
322
|
}
|
|
@@ -280,10 +359,55 @@ export class WebGPUEffectsProcessor {
|
|
|
280
359
|
* Encode one clip effect as its shader step, with the parameters
|
|
281
360
|
* `packages/image-nodes/src/nodes/lib-image-*.ts` already settled for the
|
|
282
361
|
* same modules (D7). Only the units the timeline document differs in are
|
|
283
|
-
* converted here: pixel offsets become UV
|
|
284
|
-
*
|
|
362
|
+
* converted here: pixel offsets become UV and control-point curves become
|
|
363
|
+
* transfer samples.
|
|
285
364
|
*/
|
|
286
365
|
stepClipEffect(effect, width, height, step, stepRecipe) {
|
|
366
|
+
if (isClipDenoiseEffect(effect)) {
|
|
367
|
+
if ((effect.temporalStrength ?? 0) > 0) {
|
|
368
|
+
step(filtersDenoiseTemporalV1, { strength: effect.temporalStrength });
|
|
369
|
+
}
|
|
370
|
+
if ((effect.lumaStrength ?? 0) > 0 || (effect.chromaStrength ?? 0) > 0) {
|
|
371
|
+
step(filtersDenoiseSpatialV1, { lumaStrength: effect.lumaStrength ?? 0, chromaStrength: effect.chromaStrength ?? 0, radius: Math.round(Math.max(1, Math.min(4, effect.radius ?? 2))) });
|
|
372
|
+
}
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (isClipStabilizeEffect(effect)) {
|
|
376
|
+
if (effect._matrix && !stabilizationNeutral(effect)) {
|
|
377
|
+
const [a, b, x, c, e, y] = effect._matrix;
|
|
378
|
+
step(transformStabilizeV1, { a, b, x, c, e, y });
|
|
379
|
+
}
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (isClipDebandEffect(effect)) {
|
|
383
|
+
step(filterDebandV1, { strength: effect.strength ?? 0, range: Math.round(Math.max(1, Math.min(64, effect.range ?? 16))), threshold: effect.threshold ?? 0.02, dither: effect.dither ?? 0.5 });
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (isClipSecondaryColorEffect(effect)) {
|
|
387
|
+
step(colorSecondaryV1, {
|
|
388
|
+
hueCenter: effect.hueCenter ?? 0,
|
|
389
|
+
hueWidth: effect.hueWidth ?? 180,
|
|
390
|
+
hueSoftness: effect.hueSoftness ?? 15,
|
|
391
|
+
rangeSoftness: effect.rangeSoftness ?? 0.1,
|
|
392
|
+
saturationMin: effect.saturationMin ?? 0,
|
|
393
|
+
saturationMax: effect.saturationMax ?? 1,
|
|
394
|
+
lightnessMin: effect.lightnessMin ?? 0,
|
|
395
|
+
lightnessMax: effect.lightnessMax ?? 1,
|
|
396
|
+
hueShift: effect.hueShift ?? 0,
|
|
397
|
+
saturation: effect.saturation ?? 1,
|
|
398
|
+
lightness: effect.lightness ?? 0,
|
|
399
|
+
table: secondaryCurveTransfer(effect).map(value => d.vec4f(...value))
|
|
400
|
+
});
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
if (isClipExposureEffect(effect)) {
|
|
404
|
+
step(colorExposureLinearV1, { exposure: effect.exposure ?? 0, rolloff: effect.rolloff ?? 0, whites: effect.whites ?? 0, blacks: effect.blacks ?? 0 });
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
if (isClipHueSatCurvesEffect(effect)) {
|
|
408
|
+
step(colorHueSatCurvesV1, { table: hueSatCurvesTransfer(effect).map(value => d.vec4f(...value)) });
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
287
411
|
if (effect.type === "stylize" && typeof effect.mode === "string") {
|
|
288
412
|
const index = STYLIZE_MODES.indexOf(effect.mode);
|
|
289
413
|
if (index >= 0) {
|
|
@@ -343,14 +467,13 @@ export class WebGPUEffectsProcessor {
|
|
|
343
467
|
return;
|
|
344
468
|
}
|
|
345
469
|
if (isClipGlowEffect(effect)) {
|
|
346
|
-
|
|
347
|
-
// bloom takes the source's own colour. Threshold and softness are the
|
|
348
|
-
// recipe's defaults, which is what `lib.image.effects.Glow` ships.
|
|
470
|
+
const [r, g, b] = colorChannels(effect.color ?? "#ffffff");
|
|
349
471
|
stepRecipe(filtersGlowV1, {
|
|
350
472
|
threshold: filtersGlowV1.paramDefaults.threshold,
|
|
351
473
|
softness: filtersGlowV1.paramDefaults.softness,
|
|
352
474
|
radius: effect.radius,
|
|
353
|
-
intensity: effect.intensity
|
|
475
|
+
intensity: effect.intensity,
|
|
476
|
+
tint: d.vec3f(r, g, b)
|
|
354
477
|
});
|
|
355
478
|
return;
|
|
356
479
|
}
|
|
@@ -371,18 +494,25 @@ export class WebGPUEffectsProcessor {
|
|
|
371
494
|
if (isClipVignetteEffect(effect)) {
|
|
372
495
|
// Without a midpoint the vignette starts where `lib.image.filter.Vignette`
|
|
373
496
|
// starts. A track vignette always carries one.
|
|
374
|
-
step(
|
|
497
|
+
step(vignetteV2, {
|
|
375
498
|
intensity: effect.amount,
|
|
376
|
-
radius: effect.radius ??
|
|
377
|
-
softness: effect.softness
|
|
499
|
+
radius: effect.radius ?? vignetteV2.paramDefaults.radius,
|
|
500
|
+
softness: effect.softness,
|
|
501
|
+
centerX: effect.centerX ?? 0.5,
|
|
502
|
+
centerY: effect.centerY ?? 0.5,
|
|
503
|
+
roundness: effect.roundness ?? 0
|
|
378
504
|
});
|
|
379
505
|
return;
|
|
380
506
|
}
|
|
381
507
|
if (isClipSharpenEffect(effect)) {
|
|
382
|
-
|
|
383
|
-
|
|
508
|
+
const radius = Math.max(0, Math.min(256, effect.radius ?? 1));
|
|
509
|
+
if (radius > 1) {
|
|
510
|
+
stepRecipe(sharpenGaussianV1, { amount: effect.amount, threshold: effect.threshold ?? 0, radius });
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
// Preserve the historical box kernel at radius 1.
|
|
384
514
|
step(sharpenUnsharpMaskV1, {
|
|
385
|
-
amount: effect.amount,
|
|
515
|
+
amount: effect.amount * radius,
|
|
386
516
|
threshold: effect.threshold ?? sharpenUnsharpMaskV1.paramDefaults.threshold
|
|
387
517
|
});
|
|
388
518
|
return;
|
|
@@ -412,17 +542,7 @@ export class WebGPUEffectsProcessor {
|
|
|
412
542
|
return;
|
|
413
543
|
}
|
|
414
544
|
if (isClipCurvesEffect(effect)) {
|
|
415
|
-
|
|
416
|
-
step(colorCurvesV1, {
|
|
417
|
-
blackPoint: master.blackPoint,
|
|
418
|
-
whitePoint: master.whitePoint,
|
|
419
|
-
shadows: master.shadows,
|
|
420
|
-
midtones: master.midtones,
|
|
421
|
-
highlights: master.highlights,
|
|
422
|
-
redMidtones: channelMidtones(effect.r),
|
|
423
|
-
greenMidtones: channelMidtones(effect.g),
|
|
424
|
-
blueMidtones: channelMidtones(effect.b)
|
|
425
|
-
});
|
|
545
|
+
step(colorCurveTransferV1, { table: curveTransfer(effect).map(value => d.vec4f(...value)) });
|
|
426
546
|
return;
|
|
427
547
|
}
|
|
428
548
|
if (isClipLevelsEffect(effect)) {
|
|
@@ -496,13 +616,15 @@ export class WebGPUEffectsProcessor {
|
|
|
496
616
|
if (!frameEncoder) {
|
|
497
617
|
this.ctx.uniformRing.beginSubmission();
|
|
498
618
|
}
|
|
499
|
-
const
|
|
619
|
+
const workingFormat = this.workingFormat === "rgba16float" && source.format === "rgba16float" ? "rgba16float" : "rgba8unorm";
|
|
620
|
+
const pool = this.getPool(poolKey, width, height, workingFormat);
|
|
500
621
|
const encoder = frameEncoder ??
|
|
501
622
|
this.device.createCommandEncoder({
|
|
502
623
|
label: `preview-mask-${poolKey}`
|
|
503
624
|
});
|
|
504
625
|
this.executor.encode({
|
|
505
626
|
ctx: this.ctx,
|
|
627
|
+
workingFormat,
|
|
506
628
|
module: maskApplyV1,
|
|
507
629
|
encoder,
|
|
508
630
|
inputs: {
|
|
@@ -520,6 +642,7 @@ export class WebGPUEffectsProcessor {
|
|
|
520
642
|
const [wgX, wgY] = alphaPremulToStraightV1.workgroupSize;
|
|
521
643
|
this.executor.encode({
|
|
522
644
|
ctx: this.ctx,
|
|
645
|
+
workingFormat,
|
|
523
646
|
module: alphaPremulToStraightV1,
|
|
524
647
|
encoder,
|
|
525
648
|
inputs: { source: pool.textures[0] },
|
|
@@ -557,16 +680,18 @@ export class WebGPUEffectsProcessor {
|
|
|
557
680
|
if (!frameEncoder) {
|
|
558
681
|
this.ctx.uniformRing.beginSubmission();
|
|
559
682
|
}
|
|
683
|
+
const workingFormat = this.workingFormat === "rgba16float" && source.format === "rgba16float" ? "rgba16float" : "rgba8unorm";
|
|
560
684
|
const pool = this.getPool(poolKey, width, height);
|
|
561
685
|
const encoder = frameEncoder ??
|
|
562
686
|
this.device.createCommandEncoder({
|
|
563
687
|
label: `preview-matte-${poolKey}`
|
|
564
688
|
});
|
|
565
689
|
const weighted = mode === "luma"
|
|
566
|
-
? this.premultiplyForLuma(encoder, pool, source, poolKey, width, height, sourceAlpha)
|
|
690
|
+
? this.premultiplyForLuma(encoder, workingFormat === "rgba16float" ? this.getPool(`${poolKey}:luma`, width, height, workingFormat) : pool, source, poolKey, width, height, sourceAlpha)
|
|
567
691
|
: this.label(source, `${poolKey}-src`, width, height, sourceAlpha);
|
|
568
692
|
this.executor.encode({
|
|
569
693
|
ctx: this.ctx,
|
|
694
|
+
workingFormat,
|
|
570
695
|
module: maskFromImageV1,
|
|
571
696
|
encoder,
|
|
572
697
|
inputs: {
|
|
@@ -594,6 +719,7 @@ export class WebGPUEffectsProcessor {
|
|
|
594
719
|
const [wgX, wgY] = alphaStraightToPremulV1.workgroupSize;
|
|
595
720
|
this.executor.encode({
|
|
596
721
|
ctx: this.ctx,
|
|
722
|
+
workingFormat: pool.textures[1].format === "rgba16float" ? "rgba16float" : "rgba8unorm",
|
|
597
723
|
module: alphaStraightToPremulV1,
|
|
598
724
|
encoder,
|
|
599
725
|
inputs: {
|
|
@@ -615,20 +741,59 @@ export class WebGPUEffectsProcessor {
|
|
|
615
741
|
label(texture, label, width, height, alpha) {
|
|
616
742
|
return new LabeledTexture(texture, {
|
|
617
743
|
label: `preview-effects-${label}`,
|
|
618
|
-
format:
|
|
744
|
+
format: texture.format,
|
|
745
|
+
width,
|
|
746
|
+
height,
|
|
747
|
+
meta: { colorSpace: "encoded-sdr", alpha, bindingKind: "texture_2d" }
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
makeIntermediate(label, width, height, format) {
|
|
751
|
+
return createLabeledTexture(this.device, {
|
|
752
|
+
label,
|
|
619
753
|
width,
|
|
620
754
|
height,
|
|
621
|
-
|
|
755
|
+
format,
|
|
756
|
+
usage: intermediateUsage(),
|
|
757
|
+
meta: { colorSpace: "encoded-sdr", alpha: "premultiplied" }
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
/** The effect's mask coverage in alpha (RGB = alpha, valid premultiplied), cached per effect. */
|
|
761
|
+
coverageTexture(poolKey, effect, width, height) {
|
|
762
|
+
const masks = effectMasksOf(effect);
|
|
763
|
+
const id = `${poolKey}:${effect.id}`;
|
|
764
|
+
const key = `${width}x${height}:${JSON.stringify(masks)}`;
|
|
765
|
+
const cached = this.coverages.get(id);
|
|
766
|
+
if (cached && cached.key === key)
|
|
767
|
+
return cached.texture;
|
|
768
|
+
cached?.texture.destroy();
|
|
769
|
+
const coverage = effectMaskCoverage(masks, width, height) ?? new Float32Array(width * height).fill(1);
|
|
770
|
+
const bytesPerRow = Math.ceil(width * 4 / 256) * 256;
|
|
771
|
+
const bytes = new Uint8Array(bytesPerRow * height);
|
|
772
|
+
for (let y = 0; y < height; y++) {
|
|
773
|
+
for (let x = 0; x < width; x++) {
|
|
774
|
+
const v = Math.round(Math.max(0, Math.min(1, coverage[y * width + x])) * 255);
|
|
775
|
+
bytes.fill(v, y * bytesPerRow + x * 4, y * bytesPerRow + x * 4 + 4);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
const texture = this.device.createTexture({
|
|
779
|
+
label: `preview-effects-${id}-mask`,
|
|
780
|
+
size: [width, height],
|
|
781
|
+
format: "rgba8unorm",
|
|
782
|
+
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
|
|
622
783
|
});
|
|
784
|
+
this.device.queue.writeTexture({ texture }, bytes, { bytesPerRow }, [width, height]);
|
|
785
|
+
this.coverages.set(id, { key, texture });
|
|
786
|
+
return texture;
|
|
623
787
|
}
|
|
624
|
-
getPool(key, width, height) {
|
|
788
|
+
getPool(key, width, height, format = "rgba8unorm") {
|
|
625
789
|
const existing = this.pools.get(key);
|
|
626
|
-
if (existing && existing.width === width && existing.height === height) {
|
|
790
|
+
if (existing && existing.width === width && existing.height === height && existing.textures[0].format === format) {
|
|
627
791
|
return existing;
|
|
628
792
|
}
|
|
629
793
|
if (existing) {
|
|
630
794
|
existing.textures[0].destroy();
|
|
631
795
|
existing.textures[1].destroy();
|
|
796
|
+
existing.saved?.destroy();
|
|
632
797
|
}
|
|
633
798
|
// `alpha` here is only the label a fresh, never-written texture carries.
|
|
634
799
|
// Every pass re-labels its output with what that module declares it wrote,
|
|
@@ -637,9 +802,9 @@ export class WebGPUEffectsProcessor {
|
|
|
637
802
|
label,
|
|
638
803
|
width,
|
|
639
804
|
height,
|
|
640
|
-
format
|
|
805
|
+
format,
|
|
641
806
|
usage: intermediateUsage(),
|
|
642
|
-
meta: { colorSpace: "
|
|
807
|
+
meta: { colorSpace: "encoded-sdr", alpha: "premultiplied" }
|
|
643
808
|
});
|
|
644
809
|
const pool = {
|
|
645
810
|
width,
|
|
@@ -684,7 +849,7 @@ export class WebGPUEffectsProcessor {
|
|
|
684
849
|
format: "rgba16float",
|
|
685
850
|
width,
|
|
686
851
|
height,
|
|
687
|
-
meta: { colorSpace: "
|
|
852
|
+
meta: { colorSpace: "data", alpha: "premultiplied", bindingKind: "texture_2d" }
|
|
688
853
|
});
|
|
689
854
|
const entry = { texture: labeled, parsed };
|
|
690
855
|
this.lutTextures.set(cube, entry);
|
|
@@ -699,7 +864,11 @@ export class WebGPUEffectsProcessor {
|
|
|
699
864
|
this.pools.delete(key);
|
|
700
865
|
}
|
|
701
866
|
retainOnly(keys) {
|
|
702
|
-
const keep = new Set(
|
|
867
|
+
const keep = new Set();
|
|
868
|
+
for (const key of keys) {
|
|
869
|
+
keep.add(key);
|
|
870
|
+
keep.add(`${key}:luma`);
|
|
871
|
+
}
|
|
703
872
|
for (const key of [...this.pools.keys()]) {
|
|
704
873
|
if (!keep.has(key))
|
|
705
874
|
this.releasePool(key);
|
|
@@ -709,8 +878,12 @@ export class WebGPUEffectsProcessor {
|
|
|
709
878
|
for (const pool of this.pools.values()) {
|
|
710
879
|
pool.textures[0].destroy();
|
|
711
880
|
pool.textures[1].destroy();
|
|
881
|
+
pool.saved?.destroy();
|
|
712
882
|
}
|
|
713
883
|
this.pools.clear();
|
|
884
|
+
for (const coverage of this.coverages.values())
|
|
885
|
+
coverage.texture.destroy();
|
|
886
|
+
this.coverages.clear();
|
|
714
887
|
for (const lut of this.lutTextures.values())
|
|
715
888
|
lut.texture.destroy();
|
|
716
889
|
this.lutTextures.clear();
|
|
@@ -786,7 +959,13 @@ function clamp(v, lo, hi) {
|
|
|
786
959
|
* and track scopes.
|
|
787
960
|
*/
|
|
788
961
|
function isShaderStepEffect(effect) {
|
|
789
|
-
return (effect.
|
|
962
|
+
return ((isClipDenoiseEffect(effect) && !!(effect.lumaStrength || effect.chromaStrength || effect.temporalStrength)) ||
|
|
963
|
+
(isClipStabilizeEffect(effect) && !stabilizationNeutral(effect)) ||
|
|
964
|
+
(isClipDebandEffect(effect) && (effect.strength ?? 0) > 0) ||
|
|
965
|
+
(isClipSecondaryColorEffect(effect) && !secondaryNeutral(effect)) ||
|
|
966
|
+
(isClipHueSatCurvesEffect(effect) && !hueSatCurvesNeutral(effect)) ||
|
|
967
|
+
(isClipExposureEffect(effect) && !!(effect.exposure || effect.rolloff || effect.whites || effect.blacks)) ||
|
|
968
|
+
effect.type === "lut" ||
|
|
790
969
|
effect.type === "stylize" ||
|
|
791
970
|
effect.type === "generator" ||
|
|
792
971
|
effect.type === "pixelate" ||
|
|
@@ -803,4 +982,16 @@ function isShaderStepEffect(effect) {
|
|
|
803
982
|
isClipLiftGammaGainEffect(effect) ||
|
|
804
983
|
isClipGrainEffect(effect));
|
|
805
984
|
}
|
|
985
|
+
/** Enabled effect types the GPU chain cannot execute, including future types. */
|
|
986
|
+
export function unsupportedGpuEffectTypes(layers) {
|
|
987
|
+
const supported = new Set(["denoise", "stabilize", "deband", "secondaryColor", "hueSatCurves", "exposure", "color", "blur", "dropShadow", "glow", "vignette", "sharpen", "chromaKey", "curves", "levels", "liftGammaGain", "grain", "pixelate", "posterize", "directionalBlur", "lensDistortion", "stylize", "generator", "lut"]);
|
|
988
|
+
const found = new Set();
|
|
989
|
+
for (const layer of layers) {
|
|
990
|
+
for (const effect of [...layer.effects ?? [], ...trackEffectsAsClipEffects(layer.trackEffects)]) {
|
|
991
|
+
if (effect.enabled && !supported.has(effect.type))
|
|
992
|
+
found.add(effect.type);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
return [...found].sort();
|
|
996
|
+
}
|
|
806
997
|
//# sourceMappingURL=effects.js.map
|