@remotion/effects 4.0.539 → 4.0.540
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/THIRD_PARTY_LICENSES.md +15 -0
- package/dist/barrel-distortion/webgpu-shader.d.ts +1 -0
- package/dist/bevel-alpha/webgpu-shaders.d.ts +2 -0
- package/dist/burlap-webgpu-shader.d.ts +1 -0
- package/dist/checkerboard-webgpu-shader.d.ts +1 -0
- package/dist/chromatic-aberration/webgpu-shader.d.ts +1 -0
- package/dist/color-correction-webgpu-shader-utils.d.ts +4 -0
- package/dist/color-key-webgpu-shader.d.ts +1 -0
- package/dist/color-matrix-runtime.d.ts +4 -0
- package/dist/contour-lines-webgpu-shader.d.ts +1 -0
- package/dist/corner-pin/webgpu-shader.d.ts +1 -0
- package/dist/cylinder/webgl-shader.d.ts +1 -0
- package/dist/dot-grid-webgpu-shader.d.ts +1 -0
- package/dist/drop-shadow/webgpu-shaders.d.ts +2 -0
- package/dist/emboss-webgpu-shader.d.ts +1 -0
- package/dist/esm/barrel-distortion.mjs +67 -118
- package/dist/esm/bevel-alpha.mjs +247 -196
- package/dist/esm/blur.mjs +101 -115
- package/dist/esm/brightness.mjs +65 -132
- package/dist/esm/burlap.mjs +178 -151
- package/dist/esm/checkerboard.mjs +6 -514
- package/dist/esm/chromatic-aberration.mjs +72 -119
- package/dist/esm/color-correction.mjs +186 -224
- package/dist/esm/color-key.mjs +149 -136
- package/dist/esm/contour-lines.mjs +201 -160
- package/dist/esm/contrast.mjs +65 -132
- package/dist/esm/corner-pin.mjs +4 -390
- package/dist/esm/curves.mjs +195 -211
- package/dist/esm/cylinder.mjs +108 -225
- package/dist/esm/dot-grid.mjs +184 -213
- package/dist/esm/drop-shadow.mjs +162 -180
- package/dist/esm/duotone.mjs +110 -143
- package/dist/esm/emboss.mjs +153 -151
- package/dist/esm/evolve.mjs +228 -154
- package/dist/esm/exposure.mjs +93 -201
- package/dist/esm/film-burn.mjs +298 -0
- package/dist/esm/fisheye.mjs +97 -126
- package/dist/esm/flannel.mjs +158 -156
- package/dist/esm/fractal-noise.mjs +186 -232
- package/dist/esm/glow.mjs +164 -179
- package/dist/esm/grayscale.mjs +56 -122
- package/dist/esm/gridlines.mjs +6 -575
- package/dist/esm/halftone-linear-gradient.mjs +246 -245
- package/dist/esm/halftone.mjs +267 -243
- package/dist/esm/hue.mjs +55 -122
- package/dist/esm/index-00v3hr66.mjs +299 -0
- package/dist/esm/index-0w4eqht8.mjs +351 -0
- package/dist/esm/index-18y0zcy2.mjs +440 -0
- package/dist/esm/index-1m1b1ad7.mjs +520 -0
- package/dist/esm/index-34fxm3ax.mjs +518 -0
- package/dist/esm/index-4fvp93ps.mjs +32 -0
- package/dist/esm/index-4scpn12x.mjs +224 -0
- package/dist/esm/index-4z6pt3ka.mjs +104 -0
- package/dist/esm/index-618ky75w.mjs +51 -0
- package/dist/esm/index-6agxdrvr.mjs +411 -0
- package/dist/esm/index-6jkps947.mjs +120 -0
- package/dist/esm/index-8agtsbw4.mjs +617 -0
- package/dist/esm/index-8jx11jyn.mjs +29 -0
- package/dist/esm/index-8p04sssx.mjs +123 -0
- package/dist/esm/index-afdtmrh2.mjs +596 -0
- package/dist/esm/index-b86qstcs.mjs +18 -0
- package/dist/esm/index-cb77qg3g.mjs +587 -0
- package/dist/esm/index-cdp7tr8x.mjs +122 -0
- package/dist/esm/index-evy8hyah.mjs +55 -0
- package/dist/esm/index-gnsce796.mjs +6 -0
- package/dist/esm/index-kkvzt8b7.mjs +199 -0
- package/dist/esm/index-r0v18b2n.mjs +425 -0
- package/dist/esm/index-rswpzmm5.mjs +926 -0
- package/dist/esm/index-s9mrx750.mjs +97 -0
- package/dist/esm/index-tvfexb7s.mjs +164 -0
- package/dist/esm/index-vp56k1gj.mjs +215 -0
- package/dist/esm/index-wxhvgv2s.mjs +79 -0
- package/dist/esm/index-wy95a41r.mjs +407 -0
- package/dist/esm/index-ysnwfc4t.mjs +306 -0
- package/dist/esm/index.mjs +49 -4053
- package/dist/esm/invert.mjs +54 -122
- package/dist/esm/iris-wipe.mjs +315 -0
- package/dist/esm/lens-blur.mjs +169 -156
- package/dist/esm/levels.mjs +134 -151
- package/dist/esm/light-leak.mjs +6 -416
- package/dist/esm/light-trail.mjs +124 -128
- package/dist/esm/linear-gradient-tint.mjs +4 -424
- package/dist/esm/linear-gradient.mjs +4 -370
- package/dist/esm/linear-progressive-blur.mjs +92 -118
- package/dist/esm/linear-progressive-pixelate.mjs +83 -378
- package/dist/esm/lines.mjs +167 -162
- package/dist/esm/liquid-contours.mjs +192 -153
- package/dist/esm/long-shadows.mjs +278 -251
- package/dist/esm/lut.mjs +123 -23
- package/dist/esm/mirror.mjs +78 -120
- package/dist/esm/noise-displacement.mjs +156 -151
- package/dist/esm/noise.mjs +107 -143
- package/dist/esm/outline.mjs +192 -170
- package/dist/esm/page-turn.mjs +141 -244
- package/dist/esm/paper.mjs +522 -194
- package/dist/esm/pattern.mjs +4 -568
- package/dist/esm/pixel-dissolve.mjs +158 -186
- package/dist/esm/pixelate.mjs +92 -149
- package/dist/esm/radial-progressive-blur.mjs +96 -118
- package/dist/esm/radial-progressive-pixelate.mjs +91 -384
- package/dist/esm/radial-wipe.mjs +224 -0
- package/dist/esm/rain-fall.mjs +114 -0
- package/dist/esm/region-blur.mjs +138 -192
- package/dist/esm/rings.mjs +6 -512
- package/dist/esm/roughen-edges.mjs +180 -156
- package/dist/esm/saturation.mjs +56 -122
- package/dist/esm/scale.mjs +50 -60
- package/dist/esm/scanlines.mjs +115 -149
- package/dist/esm/shadows-highlights.mjs +103 -205
- package/dist/esm/shatter.mjs +133 -153
- package/dist/esm/shine.mjs +192 -227
- package/dist/esm/shrinkwrap.mjs +388 -225
- package/dist/esm/skew.mjs +100 -145
- package/dist/esm/snow-fall.mjs +170 -0
- package/dist/esm/speckle.mjs +192 -210
- package/dist/esm/sphere.mjs +101 -225
- package/dist/esm/starburst.mjs +6 -345
- package/dist/esm/tear.mjs +138 -155
- package/dist/esm/thermal-vision.mjs +135 -152
- package/dist/esm/tile.mjs +5 -184
- package/dist/esm/tint.mjs +80 -132
- package/dist/esm/translate.mjs +55 -137
- package/dist/esm/turbulent-displace.mjs +182 -221
- package/dist/esm/tv-signal-off.mjs +140 -149
- package/dist/esm/venetian-blinds.mjs +91 -140
- package/dist/esm/vibrance.mjs +95 -204
- package/dist/esm/vignette.mjs +136 -155
- package/dist/esm/wave.mjs +88 -47
- package/dist/esm/waves.mjs +181 -169
- package/dist/esm/white-balance.mjs +100 -204
- package/dist/esm/white-noise.mjs +98 -146
- package/dist/esm/zigzag.mjs +6 -575
- package/dist/esm/zoom-blur.mjs +90 -121
- package/dist/evolve.d.ts +46 -10
- package/dist/film-burn-webgpu-shader.d.ts +1 -0
- package/dist/film-burn.d.ts +40 -0
- package/dist/fisheye/webgpu-shader.d.ts +1 -0
- package/dist/flannel-webgpu-shader.d.ts +1 -0
- package/dist/fractal-noise/shader.d.ts +1 -1
- package/dist/fractal-noise/webgpu-shader.d.ts +1 -0
- package/dist/gaussian-blur-webgpu-shader.d.ts +1 -0
- package/dist/glow/webgpu-shaders.d.ts +2 -0
- package/dist/gridlines-webgpu-shader.d.ts +1 -0
- package/dist/halftone-linear-gradient-webgpu-shader.d.ts +1 -0
- package/dist/halftone-webgpu-shader.d.ts +1 -0
- package/dist/iris-wipe.d.ts +78 -0
- package/dist/lens-blur/webgpu-shader.d.ts +1 -0
- package/dist/light-leak-webgpu-shader.d.ts +1 -0
- package/dist/light-trail/webgpu-shader.d.ts +1 -0
- package/dist/linear-gradient-tint-webgpu-shader.d.ts +1 -0
- package/dist/linear-gradient-webgpu-shader.d.ts +1 -0
- package/dist/lines-webgpu-shader.d.ts +1 -0
- package/dist/liquid-contours-webgpu-shader.d.ts +1 -0
- package/dist/long-shadows-webgpu-shaders.d.ts +2 -0
- package/dist/lut/webgpu-shader.d.ts +1 -0
- package/dist/mirror/webgpu-shader.d.ts +1 -0
- package/dist/noise-displacement-webgpu-shader.d.ts +1 -0
- package/dist/noise-webgpu-shader.d.ts +1 -0
- package/dist/outline/webgpu-shader.d.ts +1 -0
- package/dist/page-turn/webgl-shader.d.ts +1 -0
- package/dist/paper-webgpu-shader.d.ts +2 -0
- package/dist/pattern-webgpu-shader.d.ts +1 -0
- package/dist/pixel-dissolve-webgpu-shader.d.ts +1 -0
- package/dist/progressive-pixelate-runtime.d.ts +1 -0
- package/dist/radial-wipe.d.ts +19 -0
- package/dist/rain-fall.d.ts +143 -0
- package/dist/rect-transform-runtime.d.ts +11 -0
- package/dist/region-blur/webgpu-shader.d.ts +1 -0
- package/dist/rings-webgpu-shader.d.ts +1 -0
- package/dist/roughen-edges-webgpu-shader.d.ts +1 -0
- package/dist/shatter/webgpu-shader.d.ts +1 -0
- package/dist/shine-webgpu-shader.d.ts +1 -0
- package/dist/shrinkwrap-webgpu-shader.d.ts +1 -0
- package/dist/single-pass-runtime.d.ts +18 -0
- package/dist/skew-webgpu-shader.d.ts +1 -0
- package/dist/snow-fall.d.ts +208 -0
- package/dist/speckle-webgpu-shader.d.ts +1 -0
- package/dist/sphere/webgl-shader.d.ts +1 -0
- package/dist/starburst-webgpu-shader.d.ts +1 -0
- package/dist/tear-webgpu-shader.d.ts +1 -0
- package/dist/thermal-vision-webgpu-shader.d.ts +1 -0
- package/dist/tile-gpu-runtime.d.ts +24 -0
- package/dist/turbulent-displace/webgpu-shader.d.ts +1 -0
- package/dist/value-noise-webgpu-shader.d.ts +1 -0
- package/dist/vignette-webgpu-shader.d.ts +1 -0
- package/dist/wave/wave-runtime.d.ts +2 -1
- package/dist/wave/webgpu-shader.d.ts +1 -0
- package/dist/waves-webgpu-shader.d.ts +1 -0
- package/dist/weather/params.d.ts +149 -0
- package/dist/weather/runtime.d.ts +52 -0
- package/dist/weather/shaders.d.ts +4 -0
- package/dist/weather/webgpu-runtime.d.ts +36 -0
- package/dist/weather/webgpu-shader.d.ts +1 -0
- package/dist/webgl-projection-runtime.d.ts +18 -0
- package/dist/webgpu-color-state.d.ts +10 -0
- package/dist/webgpu-mesh-runtime.d.ts +46 -0
- package/dist/webgpu-multipass-runtime.d.ts +50 -0
- package/dist/webgpu-projection-runtime.d.ts +9 -5
- package/dist/webgpu-single-pass-runtime.d.ts +47 -0
- package/dist/white-noise-webgpu-shader.d.ts +1 -0
- package/dist/zigzag-webgpu-shader.d.ts +1 -0
- package/dist/zoom-blur/webgpu-shader.d.ts +1 -0
- package/package.json +43 -3
package/dist/esm/zoom-blur.mjs
CHANGED
|
@@ -1,110 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertOptionalFiniteNumber,
|
|
3
|
+
validateUnitInterval,
|
|
4
|
+
validateNonNegative
|
|
5
|
+
} from "./index-wxhvgv2s.mjs";
|
|
6
|
+
import {
|
|
7
|
+
WEBGPU_SINGLE_PASS_VERTEX,
|
|
8
|
+
setupWebGpuSinglePass,
|
|
9
|
+
cleanupWebGpuSinglePass,
|
|
10
|
+
applyWebGpuSinglePass
|
|
11
|
+
} from "./index-tvfexb7s.mjs";
|
|
12
|
+
import {
|
|
13
|
+
assertEffectParamsObject
|
|
14
|
+
} from "./index-4fvp93ps.mjs";
|
|
15
|
+
|
|
1
16
|
// src/zoom-blur/index.ts
|
|
2
17
|
import { Internals as Internals2 } from "remotion";
|
|
3
18
|
|
|
4
|
-
// src/
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
// src/zoom-blur/webgpu-shader.ts
|
|
20
|
+
var ZOOM_BLUR_WEBGPU_SHADER = `
|
|
21
|
+
${WEBGPU_SINGLE_PASS_VERTEX}
|
|
22
|
+
@group(0) @binding(0) var source: texture_2d<f32>;
|
|
23
|
+
@group(0) @binding(1) var sourceSampler: sampler;
|
|
24
|
+
@group(0) @binding(2) var<uniform> params: Params;
|
|
25
|
+
struct Params { resolutionAndCenter: vec4f, amountAndSamples: vec4f, }
|
|
26
|
+
@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {
|
|
27
|
+
let resolution = params.resolutionAndCenter.xy;
|
|
28
|
+
let center = vec2f(params.resolutionAndCenter.z, 1.0 - params.resolutionAndCenter.w);
|
|
29
|
+
let direction = input.uv - center;
|
|
30
|
+
let amount = params.amountAndSamples.x / min(resolution.x, resolution.y);
|
|
31
|
+
let samples = i32(params.amountAndSamples.y);
|
|
32
|
+
var color = vec4f(0);
|
|
33
|
+
var total = 0.0;
|
|
34
|
+
for (var i = 0; i < 64; i++) {
|
|
35
|
+
if (i >= samples) { break; }
|
|
36
|
+
let denominator = max(f32(samples - 1), 1.0);
|
|
37
|
+
let progress = f32(i) / denominator;
|
|
38
|
+
let uv = clamp(input.uv - direction * amount * progress, vec2f(0), vec2f(1));
|
|
39
|
+
color += textureSampleLevel(source, sourceSampler, uv, 0);
|
|
40
|
+
total += 1.0;
|
|
18
41
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
assertRequiredColor(value, name);
|
|
25
|
-
};
|
|
26
|
-
var assertOptionalBoolean = (value, name) => {
|
|
27
|
-
if (value === undefined) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (typeof value !== "boolean") {
|
|
31
|
-
throw new TypeError(`"${name}" must be a boolean, but got ${JSON.stringify(value)}`);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// src/color-utils.ts
|
|
36
|
-
var DEFAULT_AMOUNT = 1;
|
|
37
|
-
var DEFAULT_BRIGHTNESS_AMOUNT = 0;
|
|
38
|
-
var DEFAULT_HUE_DEGREES = 0;
|
|
39
|
-
var colorAmountSchema = {
|
|
40
|
-
type: "number",
|
|
41
|
-
min: 0,
|
|
42
|
-
max: 1,
|
|
43
|
-
step: 0.01,
|
|
44
|
-
default: DEFAULT_AMOUNT,
|
|
45
|
-
description: "Amount",
|
|
46
|
-
hiddenFromList: false
|
|
47
|
-
};
|
|
48
|
-
var colorMultiplierSchema = {
|
|
49
|
-
type: "number",
|
|
50
|
-
min: 0,
|
|
51
|
-
step: 0.01,
|
|
52
|
-
default: DEFAULT_AMOUNT,
|
|
53
|
-
description: "Amount",
|
|
54
|
-
hiddenFromList: false
|
|
55
|
-
};
|
|
56
|
-
var brightnessAmountSchema = {
|
|
57
|
-
type: "number",
|
|
58
|
-
min: -1,
|
|
59
|
-
max: 1,
|
|
60
|
-
step: 0.01,
|
|
61
|
-
default: DEFAULT_BRIGHTNESS_AMOUNT,
|
|
62
|
-
description: "Amount",
|
|
63
|
-
hiddenFromList: false
|
|
64
|
-
};
|
|
65
|
-
var hueDegreesSchema = {
|
|
66
|
-
type: "rotation-degrees",
|
|
67
|
-
step: 1,
|
|
68
|
-
default: DEFAULT_HUE_DEGREES,
|
|
69
|
-
description: "Degrees"
|
|
70
|
-
};
|
|
71
|
-
var assertOptionalFiniteNumber = (value, name) => {
|
|
72
|
-
if (value === undefined) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
assertRequiredFiniteNumber(value, name);
|
|
76
|
-
};
|
|
77
|
-
var validateUnitInterval = (value, name) => {
|
|
78
|
-
if (value < 0) {
|
|
79
|
-
throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
|
|
80
|
-
}
|
|
81
|
-
if (value > 1) {
|
|
82
|
-
throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
var validateNonNegative = (value, name) => {
|
|
86
|
-
if (value < 0) {
|
|
87
|
-
throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
var validateSignedUnitInterval = (value, name) => {
|
|
91
|
-
if (value < -1) {
|
|
92
|
-
throw new TypeError(`"${name}" must be >= -1, but got ${JSON.stringify(value)}`);
|
|
93
|
-
}
|
|
94
|
-
if (value > 1) {
|
|
95
|
-
throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
var clampColorChannel = (value) => {
|
|
99
|
-
return Math.max(0, Math.min(255, value));
|
|
100
|
-
};
|
|
101
|
-
var parseColorRgba = (ctx, color) => {
|
|
102
|
-
ctx.clearRect(0, 0, 1, 1);
|
|
103
|
-
ctx.fillStyle = color;
|
|
104
|
-
ctx.fillRect(0, 0, 1, 1);
|
|
105
|
-
const { data } = ctx.getImageData(0, 0, 1, 1);
|
|
106
|
-
return [data[0], data[1], data[2], data[3]];
|
|
107
|
-
};
|
|
42
|
+
return color / total;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
108
45
|
|
|
109
46
|
// src/zoom-blur/zoom-blur-runtime.ts
|
|
110
47
|
import { Internals } from "remotion";
|
|
@@ -319,7 +256,7 @@ var applyZoomBlur = ({
|
|
|
319
256
|
|
|
320
257
|
// src/zoom-blur/index.ts
|
|
321
258
|
var { createEffect } = Internals2;
|
|
322
|
-
var
|
|
259
|
+
var DEFAULT_AMOUNT = 40;
|
|
323
260
|
var DEFAULT_CENTER = [0.5, 0.5];
|
|
324
261
|
var DEFAULT_SAMPLES = 24;
|
|
325
262
|
var MAX_SAMPLES = 64;
|
|
@@ -329,7 +266,7 @@ var zoomBlurSchema = {
|
|
|
329
266
|
min: 0,
|
|
330
267
|
max: 200,
|
|
331
268
|
step: 1,
|
|
332
|
-
default:
|
|
269
|
+
default: DEFAULT_AMOUNT,
|
|
333
270
|
description: "Amount",
|
|
334
271
|
hiddenFromList: false
|
|
335
272
|
},
|
|
@@ -351,7 +288,7 @@ var zoomBlurSchema = {
|
|
|
351
288
|
}
|
|
352
289
|
};
|
|
353
290
|
var resolve = (params) => ({
|
|
354
|
-
amount: params.amount ??
|
|
291
|
+
amount: params.amount ?? DEFAULT_AMOUNT,
|
|
355
292
|
center: [...params.center ?? DEFAULT_CENTER],
|
|
356
293
|
samples: params.samples ?? DEFAULT_SAMPLES
|
|
357
294
|
});
|
|
@@ -392,26 +329,58 @@ var zoomBlur = createEffect({
|
|
|
392
329
|
type: "remotion/zoom-blur",
|
|
393
330
|
label: "zoomBlur()",
|
|
394
331
|
documentationLink: "https://www.remotion.dev/docs/effects/zoom-blur",
|
|
395
|
-
backend: "webgl2",
|
|
396
332
|
calculateKey: (params) => {
|
|
397
333
|
const r = resolve(params);
|
|
398
334
|
return `zoom-blur-${r.amount}-${r.center[0]}-${r.center[1]}-${r.samples}`;
|
|
399
335
|
},
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
336
|
+
implementations: {
|
|
337
|
+
webgpu: Internals2.createEffectImplementation({
|
|
338
|
+
setup: (target) => setupWebGpuSinglePass(target, "zoom-blur"),
|
|
339
|
+
apply: ({ source, width, height, params, state, gpuDevice }) => {
|
|
340
|
+
if (!gpuDevice) {
|
|
341
|
+
throw new Error("A WebGPU device is required for the zoom-blur effect");
|
|
342
|
+
}
|
|
343
|
+
const r = resolve(params);
|
|
344
|
+
const uniformData = new Float32Array([
|
|
345
|
+
width,
|
|
346
|
+
height,
|
|
347
|
+
r.center[0],
|
|
348
|
+
r.center[1],
|
|
349
|
+
r.amount,
|
|
350
|
+
r.samples,
|
|
351
|
+
0,
|
|
352
|
+
0
|
|
353
|
+
]);
|
|
354
|
+
applyWebGpuSinglePass({
|
|
355
|
+
state,
|
|
356
|
+
source,
|
|
357
|
+
width,
|
|
358
|
+
height,
|
|
359
|
+
device: gpuDevice,
|
|
360
|
+
shader: ZOOM_BLUR_WEBGPU_SHADER,
|
|
361
|
+
uniformData
|
|
362
|
+
});
|
|
363
|
+
},
|
|
364
|
+
cleanup: cleanupWebGpuSinglePass
|
|
365
|
+
}),
|
|
366
|
+
webgl2: Internals2.createEffectImplementation({
|
|
367
|
+
setup: (target) => setupZoomBlur(target),
|
|
368
|
+
apply: ({ source, width, height, params, state, flipSourceY }) => {
|
|
369
|
+
const r = resolve(params);
|
|
370
|
+
applyZoomBlur({
|
|
371
|
+
state,
|
|
372
|
+
source,
|
|
373
|
+
width,
|
|
374
|
+
height,
|
|
375
|
+
amount: r.amount,
|
|
376
|
+
center: r.center,
|
|
377
|
+
samples: r.samples,
|
|
378
|
+
flipSourceY
|
|
379
|
+
});
|
|
380
|
+
},
|
|
381
|
+
cleanup: (state) => cleanupZoomBlur(state)
|
|
382
|
+
})
|
|
413
383
|
},
|
|
414
|
-
cleanup: (state) => cleanupZoomBlur(state),
|
|
415
384
|
schema: zoomBlurSchema,
|
|
416
385
|
validateParams: validateZoomBlurParams
|
|
417
386
|
});
|
package/dist/evolve.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
declare const EVOLVE_DIRECTIONS: readonly ['left', 'right', 'top', 'bottom'];
|
|
1
|
+
declare const EVOLVE_DIRECTIONS: readonly ['left', 'right', 'top', 'bottom', 'angle'];
|
|
2
|
+
declare const EVOLVE_FEATHER_UNITS: readonly ['relative', 'pixels'];
|
|
2
3
|
export type EvolveDirection = (typeof EVOLVE_DIRECTIONS)[number];
|
|
4
|
+
export type EvolveFeatherUnit = (typeof EVOLVE_FEATHER_UNITS)[number];
|
|
3
5
|
export declare const evolveSchema: {
|
|
4
6
|
readonly progress: {
|
|
5
7
|
readonly type: 'number';
|
|
@@ -17,18 +19,46 @@ export declare const evolveSchema: {
|
|
|
17
19
|
readonly right: {};
|
|
18
20
|
readonly top: {};
|
|
19
21
|
readonly bottom: {};
|
|
22
|
+
readonly angle: {
|
|
23
|
+
readonly angle: {
|
|
24
|
+
readonly type: 'rotation-degrees';
|
|
25
|
+
readonly step: 1;
|
|
26
|
+
readonly default: 90;
|
|
27
|
+
readonly description: 'Angle';
|
|
28
|
+
};
|
|
29
|
+
};
|
|
20
30
|
};
|
|
21
31
|
readonly default: "left";
|
|
22
32
|
readonly description: 'Direction';
|
|
23
33
|
};
|
|
24
|
-
readonly
|
|
25
|
-
readonly type: '
|
|
26
|
-
readonly
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
readonly featherUnit: {
|
|
35
|
+
readonly type: 'enum';
|
|
36
|
+
readonly variants: {
|
|
37
|
+
readonly relative: {
|
|
38
|
+
readonly feather: {
|
|
39
|
+
readonly type: 'number';
|
|
40
|
+
readonly min: 0;
|
|
41
|
+
readonly max: 1;
|
|
42
|
+
readonly step: 0.01;
|
|
43
|
+
readonly default: 0.1;
|
|
44
|
+
readonly description: 'Feather';
|
|
45
|
+
readonly hiddenFromList: false;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
readonly pixels: {
|
|
49
|
+
readonly featherPixels: {
|
|
50
|
+
readonly type: 'number';
|
|
51
|
+
readonly min: 0;
|
|
52
|
+
readonly max: 500;
|
|
53
|
+
readonly step: 1;
|
|
54
|
+
readonly default: 0;
|
|
55
|
+
readonly description: 'Feather in pixels';
|
|
56
|
+
readonly hiddenFromList: false;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
readonly default: "relative";
|
|
61
|
+
readonly description: 'Feather unit';
|
|
32
62
|
};
|
|
33
63
|
};
|
|
34
64
|
export type EvolveParams = {
|
|
@@ -36,8 +66,14 @@ export type EvolveParams = {
|
|
|
36
66
|
readonly progress?: number;
|
|
37
67
|
/** Reveal direction. Defaults to `left`. */
|
|
38
68
|
readonly direction?: EvolveDirection;
|
|
39
|
-
/**
|
|
69
|
+
/** Relative softness from `0` (sharp) to `1` (fully feathered), used with `featherUnit: 'relative'`. Defaults to `0.1`. */
|
|
40
70
|
readonly feather?: number;
|
|
71
|
+
/** Reveal travel direction in degrees clockwise from up, used with `direction: 'angle'`. Defaults to `90` (left to right). */
|
|
72
|
+
readonly angle?: number;
|
|
73
|
+
/** Use relative feathering or a pixel-wide linear edge. Defaults to `relative`. */
|
|
74
|
+
readonly featherUnit?: EvolveFeatherUnit;
|
|
75
|
+
/** Width of the soft edge in pixels when `featherUnit` is `pixels`. Defaults to `0`. */
|
|
76
|
+
readonly featherPixels?: number;
|
|
41
77
|
};
|
|
42
78
|
export declare const evolve: (params?: (EvolveParams & {
|
|
43
79
|
readonly disabled?: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FILM_BURN_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n\nstruct Params { size: vec2f, progress: f32, seed: u32, center: vec2f, }\nfn lattice(point: vec3i, seed: u32) -> f32 {\n let p = bitcast<vec3u>(point);\n var h = (p.x * 0x27d4eb2du) ^ (p.y * 0x165667b1u) ^ (p.z * 0x9e3779b9u) ^ (seed * 0x85ebca6bu);\n h ^= h >> 15u; h *= 0x2c1b3c6du; h ^= h >> 12u; h *= 0x297a2d39u; h ^= h >> 15u;\n return f32(h & 65535u) / 65535.0;\n}\nfn valueNoise(point: vec3f, seed: u32) -> f32 {\n let cell = vec3i(floor(point));\n let t = fract(point);\n let fade = t * t * t * (t * (t * 6.0 - vec3f(15.0)) + vec3f(10.0));\n let lower = mix(mix(lattice(cell,seed),lattice(cell+vec3i(1,0,0),seed),fade.x),mix(lattice(cell+vec3i(0,1,0),seed),lattice(cell+vec3i(1,1,0),seed),fade.x),fade.y);\n let upper = mix(mix(lattice(cell+vec3i(0,0,1),seed),lattice(cell+vec3i(1,0,1),seed),fade.x),mix(lattice(cell+vec3i(0,1,1),seed),lattice(cell+vec3i(1,1,1),seed),fade.x),fade.y);\n return mix(lower,upper,fade.z);\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color = textureSampleLevel(source,sourceSampler,input.uv,0);\n if (params.progress <= 0.0 || color.a == 0.0) { return color; }\n if (params.progress >= 1.0) { return vec4f(0); }\n let pixel = input.uv * params.size;\n let distanceFromCenter = length(pixel-params.center*params.size)/max(length(params.size),1.0);\n var noise = 0.0; var amplitude = 1.0; var frequency = 1.0;\n for(var octave=0;octave<4;octave++) {\n noise += valueNoise(vec3f(pixel/60.0*frequency,f32(octave)*7.31),params.seed+17u+u32(octave))*amplitude;\n amplitude *= 0.5; frequency *= 2.0;\n }\n noise /= 1.875;\n let field = noise*0.65+(1.0-min(distanceFromCenter,1.0))*0.35;\n let threshold = 1.0-params.progress*1.25;\n let band = 0.12*min(params.progress*10.0,1.0);\n if(field>threshold+band) { return vec4f(0); }\n if(field<=threshold-band*2.0) { return color; }\n let scorch = smoothstep(threshold-band*2.0,threshold,field);\n let hot = smoothstep(threshold,threshold+band,field);\n var rgb = color.rgb/color.a*(1.0-scorch*0.85);\n rgb = vec3f(rgb.r+(1.0-rgb.r)*hot*0.9,rgb.g+(0.45-rgb.g)*hot*0.9,rgb.b*(1.0-hot));\n let alpha = color.a*(1.0-hot*0.6);\n return vec4f(rgb*alpha,alpha);\n}\n\n";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type FilmBurnParams = {
|
|
2
|
+
/** Burn progress from `0` (unchanged) to `1` (transparent). Defaults to `0`. */
|
|
3
|
+
readonly progress?: number;
|
|
4
|
+
/** Normalized burn center measured from the top-left corner. Defaults to `[0.5, 0.5]`. */
|
|
5
|
+
readonly center?: readonly [number, number];
|
|
6
|
+
/** Unsigned 32-bit integer seed for a repeatable burn pattern. Defaults to `0`. */
|
|
7
|
+
readonly seed?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const filmBurnSchema: {
|
|
10
|
+
readonly progress: {
|
|
11
|
+
readonly type: 'number';
|
|
12
|
+
readonly min: 0;
|
|
13
|
+
readonly max: 1;
|
|
14
|
+
readonly step: 0.01;
|
|
15
|
+
readonly default: 0;
|
|
16
|
+
readonly description: 'Progress';
|
|
17
|
+
readonly hiddenFromList: false;
|
|
18
|
+
};
|
|
19
|
+
readonly center: {
|
|
20
|
+
readonly type: 'uv-coordinate';
|
|
21
|
+
readonly min: 0;
|
|
22
|
+
readonly max: 1;
|
|
23
|
+
readonly step: 0.01;
|
|
24
|
+
readonly default: readonly [0.5, 0.5];
|
|
25
|
+
readonly description: 'Center';
|
|
26
|
+
};
|
|
27
|
+
readonly seed: {
|
|
28
|
+
readonly type: 'number';
|
|
29
|
+
readonly min: 0;
|
|
30
|
+
readonly max: 4294967295;
|
|
31
|
+
readonly step: 1;
|
|
32
|
+
readonly integer: true;
|
|
33
|
+
readonly default: 0;
|
|
34
|
+
readonly description: 'Seed';
|
|
35
|
+
readonly hiddenFromList: false;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export declare const filmBurn: (params?: (FilmBurnParams & {
|
|
39
|
+
readonly disabled?: boolean;
|
|
40
|
+
}) | undefined) => import("remotion").EffectDescriptor<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FISHEYE_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params { centerAndLens: vec4f, zoomAndAspect: vec4f, }\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let center = params.centerAndLens.xy;\n let fieldOfView = params.centerAndLens.z;\n let radius = params.centerAndLens.w;\n let zoom = params.zoomAndAspect.x;\n let aspect = params.zoomAndAspect.y;\n let toCenter = input.uv - center;\n let corrected = vec2f(toCenter.x * aspect, toCenter.y);\n let dist = length(corrected);\n let r = dist / max(radius, 0.0001);\n if (r > 1.0 || fieldOfView <= 0.0001) {\n return textureSampleLevel(source, sourceSampler, input.uv, 0);\n }\n let halfFov = fieldOfView * 0.5;\n let warped = tan(r * halfFov) / tan(halfFov);\n var scale = 0.0;\n if (dist > 0.00001) { scale = warped * radius / dist; }\n let warpedAspect = corrected * scale;\n let offset = vec2f(warpedAspect.x / aspect, warpedAspect.y) / max(zoom, 0.0001);\n let uv = center + offset;\n if (any(uv < vec2f(0)) || any(uv > vec2f(1))) { return vec4f(0); }\n return textureSampleLevel(source, sourceSampler, uv, 0);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FLANNEL_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var sourceTexture: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params {\n geometry: vec4f,\n values: vec4f,\n base: vec4f,\n stripe: vec4f,\n}\nfn sampleSource(uv: vec2f) -> vec4f {\n return textureSampleLevel(sourceTexture, sourceSampler, vec2f(uv.x, 1.0 - uv.y), 0);\n}\nfn stripe(coordinate: f32, center: f32, width: f32, softness: f32) -> f32 {\n let distanceFromCenter = abs(fract(coordinate) - center);\n let halfWidth = width * 0.5;\n return 1.0 - smoothstep(halfWidth, halfWidth + softness, distanceFromCenter);\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let vUv = vec2f(input.uv.x, 1.0 - input.uv.y);\n\n let source = sampleSource(vUv);\n if (source.a <= 0.001 || params.geometry.z <= 0.0) { return source; }\n let pixel = vec2f(input.position.x, params.geometry.y - input.position.y);\n let plaid = pixel / max(params.geometry.w, 0.001);\n let edge = mix(0.002, 0.08, params.values.x);\n let verticalWide = stripe(plaid.x, 0.5, 0.34, edge);\n let horizontalWide = stripe(plaid.y, 0.5, 0.34, edge);\n let verticalFine = stripe(plaid.x * 2.0, 0.5, 0.07, edge * 0.5);\n let horizontalFine = stripe(plaid.y * 2.0, 0.5, 0.07, edge * 0.5);\n let bands = max(max(verticalWide, horizontalWide), max(verticalFine, horizontalFine) * 0.72);\n let crossing = max(verticalWide * horizontalWide, verticalFine * horizontalFine);\n let threadX = 0.5 + 0.5 * sin(pixel.x * 3.14159265);\n let threadY = 0.5 + 0.5 * sin(pixel.y * 3.14159265);\n let weave = (threadX - 0.5) * (threadY - 0.5) * 0.12;\n let sourceRgb = source.rgb / source.a;\n let luminance = dot(sourceRgb, vec3f(0.2126, 0.7152, 0.0722));\n var plaidColor = mix(params.base.rgb, params.stripe.rgb, bands * params.stripe.a);\n plaidColor = mix(plaidColor, params.stripe.rgb * 0.72, crossing * params.stripe.a);\n plaidColor *= mix(0.58, 1.18, luminance) + weave;\n let result = mix(sourceRgb, clamp(plaidColor, vec3f(0), vec3f(1)), params.geometry.z);\n return vec4f(result * source.a, source.a);\n\n}\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const FRACTAL_NOISE_FRAGMENT_SHADER = "#version 300 es\nprecision highp float;\nprecision highp int;\n\nin vec2 vUv;\nout vec4 fragColor;\nuniform sampler2D uSource;\nuniform vec2 uResolution;\nuniform vec2 uOffset;\nuniform float uScale;\nuniform float uComplexity;\nuniform float uEvolution;\nuniform float uSubInfluence;\nuniform float uSubScaling;\nuniform float uContrast;\nuniform float uBrightness;\nuniform float uAmount;\nuniform float uCycle;\nuniform uint uSeed;\nuniform int uFractalType;\nuniform int uNoiseType;\nuniform bool uInvert;\nuniform bool uCycleEvolution;\n\n\nfloat lattice(ivec3 point, uint seed) {\n // Wrap lattice indices as well as coordinates so interpolation stays continuous\n // across the period boundary, including negative coordinates.\n uvec3 p = uvec3(point) & uvec3(65535u);\n uint h = p.x * 0x27d4eb2du ^ p.y * 0x165667b1u ^ p.z * 0x9e3779b9u ^ seed * 0x85ebca6bu;\n h ^= h >> 15;\n h *= 0x2c1b3c6du;\n h ^= h >> 12;\n h *= 0x297a2d39u;\n h ^= h >> 15;\n return float(h & 65535u) / 65535.0;\n}\n\nfloat catmull(vec4 p, float t) {\n return 0.5 * (2.0 * p.y + (p.z - p.x) * t\n + (2.0 * p.x - 5.0 * p.y + 4.0 * p.z - p.w) * t * t\n + (3.0 * p.y - p.x - 3.0 * p.z + p.w) * t * t * t);\n}\n\nvec3 bspline(float t) {\n return vec3(0.5 * (1.0-t) * (1.0-t), 0.5 + t * (1.0-t), 0.5 * t * t);\n}\n\nfloat sliceNoise(ivec3 p, vec2 t, uint seed) {\n if (uNoiseType == 0) return lattice(p, seed);\n if (uNoiseType == 1) {\n return mix(mix(lattice(p, seed), lattice(p + ivec3(1,0,0), seed), t.x),\n mix(lattice(p + ivec3(0,1,0), seed), lattice(p + ivec3(1,1,0), seed), t.x), t.y);\n }\n if (uNoiseType == 2) {\n vec3 wx = bspline(t.x);\n vec3 wy = bspline(t.y);\n float result = 0.0;\n for (int y = 0; y < 3; y++) {\n for (int x = 0; x < 3; x++) {\n result += wx[x] * wy[y] * lattice(p + ivec3(x-1, y-1, 0), seed);\n }\n }\n return result;\n }\n vec4 rows;\n for (int y = 0; y < 4; y++) {\n vec4 row;\n for (int x = 0; x < 4; x++) {\n row[x] = lattice(p + ivec3(x-1, y-1, 0), seed);\n }\n rows[y] = catmull(row, t.x);\n }\n return catmull(rows, t.y);\n}\n\nfloat valueNoise(vec3 point, uint seed) {\n // A large period keeps conversion to integer coordinates defined at extreme scales.\n vec3 p = mod(point + vec3(uNoiseType == 2 ? 0.5 : 0.0, uNoiseType == 2 ? 0.5 : 0.0, 0.0), 65536.0);\n ivec3 cell = ivec3(floor(p));\n vec3 t = fract(p);\n float fz = t.z * t.z * t.z * (t.z * (t.z * 6.0 - 15.0) + 10.0);\n float n = mix(sliceNoise(cell, t.xy, seed), sliceNoise(cell + ivec3(0,0,1), t.xy, seed), fz);\n return uNoiseType == 2 ? 0.5 + (n - 0.5) * (181.0 / 231.0) / 0.55 : n;\n}\n\n\nfloat layer(vec2 p, float z, uint seed) {\n if (!uCycleEvolution) return valueNoise(vec3(p, uEvolution + z), seed);\n float t = mod(uEvolution, uCycle);\n return mix(valueNoise(vec3(p, t + z), seed), valueNoise(vec3(p, t - uCycle + z), seed), t / uCycle);\n}\n\nfloat shape(float n) {\n float s = 2.0 * n - 1.0;\n if (uFractalType == 1) return 1.0 - s * s;\n if (uFractalType == 2) return 1.0 - abs(s);\n if (uFractalType == 3) return (1.0 - abs(s)) * (1.0 - abs(s));\n if (uFractalType == 8) {\n float distance = clamp(abs(s) / 0.12, 0.0, 1.0);\n return 1.0 - distance * distance;\n }\n return n;\n}\n\nvoid main() {\n vec4 source = texture(uSource, vUv);\n if (source.a == 0.0 || uAmount == 0.0) {\n fragColor = source;\n return;\n }\n vec2 pixel = vec2(
|
|
1
|
+
export declare const FRACTAL_NOISE_FRAGMENT_SHADER = "#version 300 es\nprecision highp float;\nprecision highp int;\n\nin vec2 vUv;\nout vec4 fragColor;\nuniform sampler2D uSource;\nuniform vec2 uResolution;\nuniform vec2 uOffset;\nuniform float uScale;\nuniform float uComplexity;\nuniform float uEvolution;\nuniform float uSubInfluence;\nuniform float uSubScaling;\nuniform float uContrast;\nuniform float uBrightness;\nuniform float uAmount;\nuniform float uCycle;\nuniform uint uSeed;\nuniform int uFractalType;\nuniform int uNoiseType;\nuniform bool uInvert;\nuniform bool uCycleEvolution;\n\n\nfloat lattice(ivec3 point, uint seed) {\n // Wrap lattice indices as well as coordinates so interpolation stays continuous\n // across the period boundary, including negative coordinates.\n uvec3 p = uvec3(point) & uvec3(65535u);\n uint h = p.x * 0x27d4eb2du ^ p.y * 0x165667b1u ^ p.z * 0x9e3779b9u ^ seed * 0x85ebca6bu;\n h ^= h >> 15;\n h *= 0x2c1b3c6du;\n h ^= h >> 12;\n h *= 0x297a2d39u;\n h ^= h >> 15;\n return float(h & 65535u) / 65535.0;\n}\n\nfloat catmull(vec4 p, float t) {\n return 0.5 * (2.0 * p.y + (p.z - p.x) * t\n + (2.0 * p.x - 5.0 * p.y + 4.0 * p.z - p.w) * t * t\n + (3.0 * p.y - p.x - 3.0 * p.z + p.w) * t * t * t);\n}\n\nvec3 bspline(float t) {\n return vec3(0.5 * (1.0-t) * (1.0-t), 0.5 + t * (1.0-t), 0.5 * t * t);\n}\n\nfloat sliceNoise(ivec3 p, vec2 t, uint seed) {\n if (uNoiseType == 0) return lattice(p, seed);\n if (uNoiseType == 1) {\n return mix(mix(lattice(p, seed), lattice(p + ivec3(1,0,0), seed), t.x),\n mix(lattice(p + ivec3(0,1,0), seed), lattice(p + ivec3(1,1,0), seed), t.x), t.y);\n }\n if (uNoiseType == 2) {\n vec3 wx = bspline(t.x);\n vec3 wy = bspline(t.y);\n float result = 0.0;\n for (int y = 0; y < 3; y++) {\n for (int x = 0; x < 3; x++) {\n result += wx[x] * wy[y] * lattice(p + ivec3(x-1, y-1, 0), seed);\n }\n }\n return result;\n }\n vec4 rows;\n for (int y = 0; y < 4; y++) {\n vec4 row;\n for (int x = 0; x < 4; x++) {\n row[x] = lattice(p + ivec3(x-1, y-1, 0), seed);\n }\n rows[y] = catmull(row, t.x);\n }\n return catmull(rows, t.y);\n}\n\nfloat valueNoise(vec3 point, uint seed) {\n // A large period keeps conversion to integer coordinates defined at extreme scales.\n vec3 p = mod(point + vec3(uNoiseType == 2 ? 0.5 : 0.0, uNoiseType == 2 ? 0.5 : 0.0, 0.0), 65536.0);\n ivec3 cell = ivec3(floor(p));\n vec3 t = fract(p);\n float fz = t.z * t.z * t.z * (t.z * (t.z * 6.0 - 15.0) + 10.0);\n float n = mix(sliceNoise(cell, t.xy, seed), sliceNoise(cell + ivec3(0,0,1), t.xy, seed), fz);\n return uNoiseType == 2 ? 0.5 + (n - 0.5) * (181.0 / 231.0) / 0.55 : n;\n}\n\n\nfloat layer(vec2 p, float z, uint seed) {\n if (!uCycleEvolution) return valueNoise(vec3(p, uEvolution + z), seed);\n float t = mod(uEvolution, uCycle);\n return mix(valueNoise(vec3(p, t + z), seed), valueNoise(vec3(p, t - uCycle + z), seed), t / uCycle);\n}\n\nfloat shape(float n) {\n float s = 2.0 * n - 1.0;\n if (uFractalType == 1) return 1.0 - s * s;\n if (uFractalType == 2) return 1.0 - abs(s);\n if (uFractalType == 3) return (1.0 - abs(s)) * (1.0 - abs(s));\n if (uFractalType == 8) {\n float distance = clamp(abs(s) / 0.12, 0.0, 1.0);\n return 1.0 - distance * distance;\n }\n return n;\n}\n\nvoid main() {\n vec4 source = texture(uSource, vUv);\n if (source.a == 0.0 || uAmount == 0.0) {\n fragColor = source;\n return;\n }\n // Use exact pixel centers so block noise stays stable at cell boundaries.\n vec2 pixel = vec2(gl_FragCoord.x, uResolution.y - gl_FragCoord.y);\n vec2 base = (pixel - uResolution * 0.5 - uOffset) / uScale;\n float sum = 0.0;\n float norm = 0.0;\n float amplitude = 1.0;\n float frequency = 1.0;\n float best = 0.0;\n for (int octave = 0; octave < 20; octave++) {\n float weight = clamp(uComplexity - float(octave), 0.0, 1.0);\n if (weight == 0.0 || amplitude == 0.0) break;\n vec2 p = base * frequency;\n float z = float(octave) * 7.31;\n uint seed = (uSeed ^ 0x51edu) + uint(octave);\n if (uFractalType >= 4 && uFractalType <= 6) {\n float a = layer(p * 0.5, z + 3.1, seed ^ 0x55u) - 0.5;\n if (uFractalType == 5) {\n float angle = a * 3.0;\n p = mat2(cos(angle), sin(angle), -sin(angle), cos(angle)) * p;\n } else {\n float b = layer(p * 0.5, z + 5.7, seed ^ 0xaau) - 0.5;\n float strength = uFractalType == 6 ? 0.5 + float(octave) * 0.35 : 1.0;\n p += vec2(a, b) * 1.5 * strength;\n }\n }\n float n = shape(layer(p, z, seed));\n // Fade fractional octaves in for Max too, so animating complexity is continuous.\n best = max(best, n * amplitude * weight);\n sum += n * amplitude * weight;\n norm += amplitude * weight;\n amplitude *= uSubInfluence;\n frequency /= uSubScaling;\n }\n float noise = uFractalType == 7 ? best : sum / norm;\n noise = clamp((noise - 0.5) * uContrast + 0.5 + uBrightness, 0.0, 1.0);\n if (uInvert) noise = 1.0 - noise;\n fragColor = vec4(mix(source.rgb, vec3(noise) * source.a, uAmount), source.a);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FRACTAL_NOISE_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n\nstruct Params { size: vec2f, offset: vec2f, scale: f32, complexity: f32, evolution: f32, subInfluence: f32, subScaling: f32, contrast: f32, brightness: f32, amount: f32, cycle: f32, seed: u32, fractalType: f32, noiseType: f32, invert: f32, cycleEvolution: f32, }\nfn noiseType() -> i32 { return i32(params.noiseType); }\n\nfn lattice(point: vec3i, seed: u32) -> f32 {\n let p = bitcast<vec3u>(point) & vec3u(65535u);\n var h = (p.x*0x27d4eb2du) ^ (p.y*0x165667b1u) ^ (p.z*0x9e3779b9u) ^ (seed*0x85ebca6bu);\n h ^= h >> 15u; h *= 0x2c1b3c6du; h ^= h >> 12u; h *= 0x297a2d39u; h ^= h >> 15u;\n return f32(h & 65535u)/65535.0;\n}\nfn catmull(p: vec4f, t: f32) -> f32 {\n return 0.5*(2.0*p.y+(p.z-p.x)*t+(2.0*p.x-5.0*p.y+4.0*p.z-p.w)*t*t+(3.0*p.y-p.x-3.0*p.z+p.w)*t*t*t);\n}\nfn bspline(t: f32) -> vec3f { return vec3f(0.5*(1.0-t)*(1.0-t),0.5+t*(1.0-t),0.5*t*t); }\nfn sliceNoise(p: vec3i,t: vec2f,seed: u32) -> f32 {\n if(noiseType()==0) { return lattice(p,seed); }\n if(noiseType()==1) { return mix(mix(lattice(p,seed),lattice(p+vec3i(1,0,0),seed),t.x),mix(lattice(p+vec3i(0,1,0),seed),lattice(p+vec3i(1,1,0),seed),t.x),t.y); }\n if(noiseType()==2) {\n let wx=bspline(t.x); let wy=bspline(t.y); var result=0.0;\n for(var y=0;y<3;y++) { for(var x=0;x<3;x++) { result += wx[x]*wy[y]*lattice(p+vec3i(x-1,y-1,0),seed); } }\n return result;\n }\n var rows: vec4f;\n for(var y=0;y<4;y++) {\n var row: vec4f;\n for(var x=0;x<4;x++) { row[x]=lattice(p+vec3i(x-1,y-1,0),seed); }\n rows[y]=catmull(row,t.x);\n }\n return catmull(rows,t.y);\n}\nfn valueNoise(point: vec3f,seed: u32) -> f32 {\n let offset=select(0.0,0.5,noiseType()==2);\n let shifted=point+vec3f(offset,offset,0.0);\n let p=shifted-floor(shifted/65536.0)*65536.0;\n let cell=vec3i(floor(p)); let t=fract(p);\n let fz=t.z*t.z*t.z*(t.z*(t.z*6.0-15.0)+10.0);\n let n=mix(sliceNoise(cell,t.xy,seed),sliceNoise(cell+vec3i(0,0,1),t.xy,seed),fz);\n return select(n,0.5+(n-0.5)*(181.0/231.0)/0.55,noiseType()==2);\n}\n\nfn layer(p: vec2f,z: f32,seed: u32) -> f32 {\n if(params.cycleEvolution==0.0) { return valueNoise(vec3f(p,params.evolution+z),seed); }\n let t=params.evolution-floor(params.evolution/params.cycle)*params.cycle;\n return mix(valueNoise(vec3f(p,t+z),seed),valueNoise(vec3f(p,t-params.cycle+z),seed),t/params.cycle);\n}\nfn shape(n: f32) -> f32 {\n let s=2.0*n-1.0;\n if(params.fractalType==1.0) { return 1.0-s*s; }\n if(params.fractalType==2.0) { return 1.0-abs(s); }\n if(params.fractalType==3.0) { return (1.0-abs(s))*(1.0-abs(s)); }\n if(params.fractalType==8.0) { let distance=clamp(abs(s)/0.12,0.0,1.0); return 1.0-distance*distance; }\n return n;\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color=textureSampleLevel(source,sourceSampler,input.uv,0);\n if(color.a==0.0 || params.amount==0.0) { return color; }\n let pixel=input.position.xy;\n let base=(pixel-params.size*0.5-params.offset)/params.scale;\n var sum=0.0; var norm=0.0; var amplitude=1.0; var frequency=1.0; var best=0.0;\n for(var octave=0;octave<20;octave++) {\n let weight=clamp(params.complexity-f32(octave),0.0,1.0);\n if(weight==0.0 || amplitude==0.0) { break; }\n var p=base*frequency;\n let z=f32(octave)*7.31;\n let seed=(params.seed ^ 0x51edu)+u32(octave);\n if(params.fractalType>=4.0 && params.fractalType<=6.0) {\n let a=layer(p*0.5,z+3.1,seed ^ 0x55u)-0.5;\n if(params.fractalType==5.0) {\n let angle=a*3.0;\n p=mat2x2f(vec2f(cos(angle),sin(angle)),vec2f(-sin(angle),cos(angle)))*p;\n } else {\n let b=layer(p*0.5,z+5.7,seed ^ 0xaau)-0.5;\n let strength=select(1.0,0.5+f32(octave)*0.35,params.fractalType==6.0);\n p += vec2f(a,b)*1.5*strength;\n }\n }\n let n=shape(layer(p,z,seed));\n best=max(best,n*amplitude*weight); sum += n*amplitude*weight; norm += amplitude*weight;\n amplitude *= params.subInfluence; frequency /= params.subScaling;\n }\n var noise=select(sum/norm,best,params.fractalType==7.0);\n noise=clamp((noise-0.5)*params.contrast+0.5+params.brightness,0.0,1.0);\n if(params.invert!=0.0) { noise=1.0-noise; }\n return vec4f(mix(color.rgb,vec3f(noise)*color.a,params.amount),color.a);\n}\n\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GAUSSIAN_BLUR_WEBGPU_SHADER = "\n\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var secondary: texture_2d<f32>;\n\nstruct Params { resolution: vec2f, direction: vec2f, values: vec4f, startEnd: vec4f, radial: vec4f, }\nfn radiusAt(uv: vec2f) -> f32 {\n let mode = params.values.y;\n if (mode == 0.0) {return params.values.x;}\n if (mode == 1.0) {\n let gradient = params.startEnd.zw - params.startEnd.xy;\n let lengthSq = dot(gradient, gradient);\n if (lengthSq <= 0.0000001) {return max(0.0, params.values.z);}\n let progress = clamp(dot(uv - params.startEnd.xy, gradient) / lengthSq, 0.0, 1.0);\n return max(0.0, mix(params.values.z, params.values.w, progress));\n }\n let radii = params.startEnd.zw * params.resolution * 0.5;\n if (radii.x <= 0.0000001 || radii.y <= 0.0000001) {return max(0.0, params.values.z);}\n let delta = (uv - params.startEnd.xy) * params.resolution;\n let angle = radians(params.radial.x);\n let c = cos(angle); let s = sin(angle);\n let local = vec2f(c * delta.x + s * delta.y, -s * delta.x + c * delta.y);\n let ellipseProgress = clamp(length(local / radii), 0.0, 1.0);\n let distance = 1.0 - params.radial.y;\n var progress = step(params.radial.y, ellipseProgress);\n if (abs(distance) > 0.0000001) {progress = clamp((ellipseProgress - params.radial.y) / distance, 0.0, 1.0);}\n return max(0.0, mix(params.values.z, params.values.w, progress));\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let radius = radiusAt(input.uv);\n if (radius <= 0.0) {return textureSampleLevel(source, sourceSampler, input.uv, 0);}\n let halfKernel = i32(clamp(ceil(radius / 2.0), 4.0, 32.0));\n let stride = radius / f32(halfKernel);\n let sigma = select(max(radius / 3.0, 0.0001), radius / 3.0, params.values.y == 0.0);\n let twoSigmaSq = 2.0 * sigma * sigma;\n var sum = vec4f(0); var weightSum = 0.0;\n for (var i = -32; i <= 32; i++) {\n if (abs(i) > halfKernel) {continue;}\n let offset = f32(i) * stride;\n let weight = exp(-(offset * offset) / twoSigmaSq);\n let uv = input.uv + params.direction / params.resolution * offset;\n sum += textureSampleLevel(source, sourceSampler, uv, 0) * weight;\n weightSum += weight;\n }\n return sum / weightSum;\n}\n";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const GLOW_EXTRACT_WEBGPU_SHADER = "\n\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var secondary: texture_2d<f32>;\n\nstruct Params {color: vec4f, values: vec4f,}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color = textureSampleLevel(source, sourceSampler, input.uv, 0);\n if (color.a <= 0.001) {return vec4f(0);}\n let luminance = dot(color.rgb/color.a, vec3f(0.299,0.587,0.114));\n let threshold = clamp(params.values.x,0.0,1.0);\n var contribution = step(1.0,luminance);\n if (threshold < 1.0) {contribution=clamp((luminance-threshold)/max(1.0-threshold,0.0001),0.0,1.0);}\n let alpha=color.a*contribution*params.color.a;\n return vec4f(params.color.rgb*alpha,alpha);\n}\n";
|
|
2
|
+
export declare const GLOW_COMPOSITE_WEBGPU_SHADER = "\n\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var secondary: texture_2d<f32>;\n\nstruct Params {values: vec4f,}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color=textureSampleLevel(source,sourceSampler,input.uv,0)+textureSampleLevel(secondary,sourceSampler,input.uv,0)*max(params.values.x,0.0);\n return min(color,vec4f(1));\n}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GRIDLINES_WEBGPU_SHADER = "\ndiagnostic(off, derivative_uniformity);\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var sourceTexture: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params {\n geometry: vec4f,\n rotation: vec4f,\n offset: vec4f,\n lineColor: vec4f,\n backgroundColor: vec4f,\n}\nfn sampleSource(uv: vec2f) -> vec4f {\n return textureSampleLevel(sourceTexture, sourceSampler, vec2f(uv.x, 1.0 - uv.y), 0);\n}\n\nfn sourceOver(backdrop: vec4f, overlay: vec4f) -> vec4f { return overlay + backdrop * (1.0 - overlay.a); }\nfn sourceAtop(backdrop: vec4f, overlay: vec4f) -> vec4f { return vec4f(overlay.rgb * backdrop.a + backdrop.rgb * (1.0 - overlay.a), backdrop.a); }\nfn rotationMatrix(rotationX: f32, rotationY: f32, rotationZ: f32) -> mat3x3f {\n let sx = sin(rotationX); let cx = cos(rotationX);\n let sy = sin(rotationY); let cy = cos(rotationY);\n let sz = sin(rotationZ); let cz = cos(rotationZ);\n let rx = mat3x3f(1, 0, 0, 0, cx, sx, 0, -sx, cx);\n let ry = mat3x3f(cy, 0, -sy, 0, 1, 0, sy, 0, cy);\n let rz = mat3x3f(cz, sz, 0, -sz, cz, 0, 0, 0, 1);\n return rz * ry * rx;\n}\nstruct GridPoint {coordinate: vec2f, valid: bool,}\nfn gridAt(centered: vec2f, rotation: mat3x3f) -> GridPoint {\n var gridCoord = vec2f(0);\n if (params.rotation.w <= 0.0) {\n let rotated = rotation * vec3f(centered, 0);\n gridCoord = rotated.xy + params.offset.xy;\n } else {\n let camera = vec3f(0, 0, params.rotation.w);\n let ray = normalize(vec3f(centered, -params.rotation.w));\n let normal = rotation * vec3f(0, 0, 1);\n let denominator = dot(ray, normal);\n let t = -dot(camera, normal) / denominator;\n if (abs(denominator) < 0.0001 || t <= 0.0) { return GridPoint(vec2f(0), false); }\n let worldPosition = camera + ray * t;\n let localPosition = transpose(rotation) * worldPosition;\n gridCoord = localPosition.xy + params.offset.xy;\n }\n return GridPoint(gridCoord, true);\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let vUv = vec2f(input.uv.x, 1.0 - input.uv.y);\n\n let texColor = sampleSource(vUv);\n let centered = vec2f(input.position.x, params.geometry.y - input.position.y) - params.geometry.xy * 0.5;\n let rotation = rotationMatrix(params.rotation.y, params.rotation.z, params.rotation.x);\n let gridPoint = gridAt(centered, rotation);\n if (!gridPoint.valid) { return sourceOver(texColor, params.backgroundColor); }\n let gridCoord = gridPoint.coordinate;\n let gridSize = max(params.geometry.z, 0.001);\n let cell = abs(fract(gridCoord / gridSize + vec2f(0.5)) - vec2f(0.5)) * gridSize;\n let halfLineWidth = params.geometry.w * 0.5;\n var derivatives = fwidth(gridCoord);\n if (i32(params.geometry.y) % 2 != 0) {\n // Match WebGL's bottom-origin derivative quads on odd-height targets.\n let neighborY = select(-1.0, 1.0, i32(params.geometry.y - input.position.y) % 2 == 0);\n let neighbor = gridAt(centered + vec2f(0, neighborY), rotation);\n derivatives = abs(dpdx(gridCoord)) + abs(neighbor.coordinate - gridCoord);\n }\n let gridUnitsPerPixel = max(derivatives, vec2f(0.001));\n let halfWidthInGridUnits = halfLineWidth * gridUnitsPerPixel;\n let projectedCellSize = gridSize / gridUnitsPerPixel;\n let densityFade = smoothstep(vec2f(max(params.geometry.w * 1.5, 1.0)), vec2f(max(params.geometry.w * 4.0, 2.0)), projectedCellSize);\n var lineCoverage = vec2f(0);\n if (halfLineWidth > 0.001) { lineCoverage = vec2f(1) - smoothstep(halfWidthInGridUnits - gridUnitsPerPixel, halfWidthInGridUnits + gridUnitsPerPixel, cell); }\n lineCoverage *= densityFade;\n let coverage = max(lineCoverage.x, lineCoverage.y);\n let line = params.lineColor * coverage;\n if (params.offset.z != 0.0) { return sourceAtop(sourceAtop(texColor, params.backgroundColor), line); }\n return sourceOver(sourceOver(texColor, params.backgroundColor), line);\n\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HALFTONE_LINEAR_GRADIENT_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var sourceTexture: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params {\n geometry: vec4f,\n stops: vec4f,\n flags: vec4f,\n color: vec4f,\n}\nfn sampleSource(uv: vec2f) -> vec4f {\n return textureSampleLevel(sourceTexture, sourceSampler, vec2f(uv.x, 1.0 - uv.y), 0);\n}\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let vUv = vec2f(input.uv.x, 1.0 - input.uv.y);\n\n let center = params.geometry.xy * 0.5;\n let gridPos = vec2f(input.position.x, params.geometry.y - input.position.y) - center;\n let gridSize = max(params.flags.x, 0.001);\n let cellIndex = floor(gridPos / gridSize + vec2f(0.5));\n let gridCenter = cellIndex * gridSize;\n let canvasCenter = center + gridCenter;\n let centerUv = canvasCenter / params.geometry.xy;\n let gradientUv = vec2f(centerUv.x, 1.0 - centerUv.y);\n let stopVector = params.stops.zw - params.stops.xy;\n let stopDistance = dot(stopVector, stopVector);\n var progress = 0.0;\n if (stopDistance > 0.0) { progress = clamp(dot(gradientUv - params.stops.xy, stopVector) / stopDistance, 0.0, 1.0); }\n let dotSize = mix(params.geometry.z, params.geometry.w, progress);\n if (dotSize <= 0.01) { return vec4f(0); }\n let radius = dotSize * 0.5;\n let coverage = 1.0 - smoothstep(radius - 0.75, radius + 0.75, length(gridPos - gridCenter));\n let texColor = sampleSource(clamp(centerUv, vec2f(0), vec2f(1)));\n let dotColor = select(params.color, texColor, params.flags.y != 0.0) * coverage;\n if (params.flags.y != 0.0) { return dotColor; }\n if (params.flags.z != 0.0) { return vec4f(dotColor.rgb * texColor.a + texColor.rgb * (1.0 - dotColor.a), texColor.a); }\n return dotColor + texColor * (1.0 - dotColor.a);\n\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HALFTONE_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var sourceTexture: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params {\n geometry: vec4f,\n grid: vec4f,\n flags: vec4f,\n color: vec4f,\n}\nfn sampleSource(uv: vec2f) -> vec4f {\n return textureSampleLevel(sourceTexture, sourceSampler, vec2f(uv.x, 1.0 - uv.y), 0);\n}\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let vUv = vec2f(input.uv.x, 1.0 - input.uv.y);\n\n let center = params.geometry.xy * 0.5;\n let d = vec2f(input.position.x, params.geometry.y - input.position.y) - center;\n let cosR = cos(params.grid.x);\n let sinR = sin(params.grid.x);\n let gridPos = vec2f(d.x * cosR + d.y * sinR, -d.x * sinR + d.y * cosR);\n let spacing = max(params.geometry.w, 0.001);\n let cellIndex = floor((gridPos + params.grid.yz) / spacing + vec2f(0.5));\n let gridCenter = cellIndex * spacing - params.grid.yz;\n let canvasPos = center + vec2f(gridCenter.x * cosR - gridCenter.y * sinR, gridCenter.x * sinR + gridCenter.y * cosR);\n let sampleUv = clamp(canvasPos / params.geometry.xy, vec2f(0), vec2f(1));\n let texColor = sampleSource(sampleUv);\n let alpha = texColor.a;\n var rgb = vec3f(0);\n if (alpha > 0.001) { rgb = texColor.rgb / alpha; }\n let lum = dot(rgb, vec3f(0.299, 0.587, 0.114));\n let lumDefault = lum * alpha + (1.0 - alpha);\n let dotScale = select(1.0 - lumDefault, lumDefault, params.flags.x != 0.0);\n if (dotScale <= 0.01) { return vec4f(0); }\n let diff = gridPos - gridCenter;\n let halfSize = params.geometry.z * 0.5;\n var coverage = 0.0;\n if (params.grid.w == 0.0) {\n let radius = halfSize * dotScale;\n coverage = 1.0 - smoothstep(radius - 0.75, radius + 0.75, length(diff));\n } else if (params.grid.w == 1.0) {\n let s = params.geometry.z * dotScale * 0.5;\n coverage = (1.0 - smoothstep(s - 0.5, s + 0.5, abs(diff.x))) * (1.0 - smoothstep(s - 0.5, s + 0.5, abs(diff.y)));\n } else {\n let localTexColor = sampleSource(vUv);\n let localAlpha = localTexColor.a;\n var localRgb = vec3f(0);\n if (localAlpha > 0.001) { localRgb = localTexColor.rgb / localAlpha; }\n let localLum = dot(localRgb, vec3f(0.299, 0.587, 0.114));\n let localLumDefault = localLum * localAlpha + (1.0 - localAlpha);\n let localDotScale = select(1.0 - localLumDefault, localLumDefault, params.flags.x != 0.0);\n if (localDotScale <= 0.12) { return vec4f(0); }\n let lineHalf = params.geometry.z * dotScale * 0.5;\n if (lineHalf <= 1.0) { return vec4f(0); }\n coverage = (1.0 - smoothstep(halfSize - 0.5, halfSize + 0.5, abs(diff.x))) * (1.0 - smoothstep(lineHalf - 0.5, lineHalf + 0.5, abs(diff.y)));\n }\n return select(params.color, texColor, params.flags.y != 0.0) * coverage;\n\n}\n";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export type IrisWipeCenter = readonly [number, number];
|
|
2
|
+
export type IrisWipeParams = {
|
|
3
|
+
/** Normalized center measured from the top-left corner. Defaults to `[0.5, 0.5]`. */
|
|
4
|
+
readonly center?: IrisWipeCenter;
|
|
5
|
+
/** Number of polygon vertices or star points, from 3 to 64. Defaults to `6`. */
|
|
6
|
+
readonly points?: number;
|
|
7
|
+
/** Distance to the outer vertices in pixels. Defaults to `0`, leaving the source unchanged. */
|
|
8
|
+
readonly outerRadius?: number;
|
|
9
|
+
/** Alternate outer and inner vertices to create a star. Defaults to `false`. */
|
|
10
|
+
readonly useInnerRadius?: boolean;
|
|
11
|
+
/** Distance to the inner star vertices in pixels. Defaults to `0`. */
|
|
12
|
+
readonly innerRadius?: number;
|
|
13
|
+
/** Clockwise rotation in degrees from the top. Defaults to `0`. */
|
|
14
|
+
readonly rotation?: number;
|
|
15
|
+
/** Width of the feathered boundary in pixels. Defaults to `0`. */
|
|
16
|
+
readonly feather?: number;
|
|
17
|
+
};
|
|
18
|
+
export declare const irisWipeSchema: {
|
|
19
|
+
readonly center: {
|
|
20
|
+
readonly type: 'uv-coordinate';
|
|
21
|
+
readonly min: 0;
|
|
22
|
+
readonly max: 1;
|
|
23
|
+
readonly step: 0.01;
|
|
24
|
+
readonly default: readonly [0.5, 0.5];
|
|
25
|
+
readonly description: 'Center';
|
|
26
|
+
};
|
|
27
|
+
readonly points: {
|
|
28
|
+
readonly type: 'number';
|
|
29
|
+
readonly min: 3;
|
|
30
|
+
readonly max: 64;
|
|
31
|
+
readonly step: 1;
|
|
32
|
+
readonly integer: true;
|
|
33
|
+
readonly default: 6;
|
|
34
|
+
readonly description: 'Points';
|
|
35
|
+
readonly hiddenFromList: false;
|
|
36
|
+
};
|
|
37
|
+
readonly outerRadius: {
|
|
38
|
+
readonly type: 'number';
|
|
39
|
+
readonly min: 0;
|
|
40
|
+
readonly max: 2000;
|
|
41
|
+
readonly step: 1;
|
|
42
|
+
readonly default: 0;
|
|
43
|
+
readonly description: 'Outer radius';
|
|
44
|
+
readonly hiddenFromList: false;
|
|
45
|
+
};
|
|
46
|
+
readonly useInnerRadius: {
|
|
47
|
+
readonly type: 'boolean';
|
|
48
|
+
readonly default: false;
|
|
49
|
+
readonly description: 'Use inner radius';
|
|
50
|
+
};
|
|
51
|
+
readonly innerRadius: {
|
|
52
|
+
readonly type: 'number';
|
|
53
|
+
readonly min: 0;
|
|
54
|
+
readonly max: 2000;
|
|
55
|
+
readonly step: 1;
|
|
56
|
+
readonly default: 0;
|
|
57
|
+
readonly description: 'Inner radius';
|
|
58
|
+
readonly hiddenFromList: false;
|
|
59
|
+
};
|
|
60
|
+
readonly rotation: {
|
|
61
|
+
readonly type: 'rotation-degrees';
|
|
62
|
+
readonly step: 1;
|
|
63
|
+
readonly default: 0;
|
|
64
|
+
readonly description: 'Rotation';
|
|
65
|
+
};
|
|
66
|
+
readonly feather: {
|
|
67
|
+
readonly type: 'number';
|
|
68
|
+
readonly min: 0;
|
|
69
|
+
readonly max: 500;
|
|
70
|
+
readonly step: 1;
|
|
71
|
+
readonly default: 0;
|
|
72
|
+
readonly description: 'Feather';
|
|
73
|
+
readonly hiddenFromList: false;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export declare const irisWipe: (params?: (IrisWipeParams & {
|
|
77
|
+
readonly disabled?: boolean;
|
|
78
|
+
}) | undefined) => import("remotion").EffectDescriptor<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LENS_BLUR_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n// Aperture geometry and highlight controls adapted from EffectCraft's blur2.rs (MIT).\n// See ../../THIRD_PARTY_LICENSES.md.\nstruct Params {resolution: vec2f, radius: f32, shape: f32, iris: vec4f, highlights: vec4f, options: vec4f,}\nconst PI=3.141592653589793;\nconst GOLDEN_ANGLE=2.399963229728653;\nfn toLinear(color: vec3f) -> vec3f {\n return mix(color/12.92,pow((color+0.055)/1.055,vec3f(2.4)),step(vec3f(0.04045),color));\n}\nfn toSrgb(color: vec3f) -> vec3f {\n return mix(color*12.92,1.055*pow(max(color,vec3f(0)),vec3f(1.0/2.4))-0.055,step(vec3f(0.0031308),color));\n}\nfn readSource(uv: vec2f) -> vec4f {\n let sampled=textureSampleLevel(source,sourceSampler,uv,0);\n if (sampled.a<=0.0) {return vec4f(0);}\n var color=sampled.rgb/sampled.a;\n let luminance=dot(color,vec3f(0.2126,0.7152,0.0722));\n if (params.options.y!=0.0) {color=toLinear(color);}\n if (luminance>=params.highlights.y) {\n let brightest=max(color.r,max(color.g,color.b));\n let highlight=mix(vec3f(brightest),color,params.highlights.z);\n color+=highlight*(4.0*params.highlights.x);\n }\n var coverage=1.0;\n if (params.highlights.w==0.0) {\n let pixel=uv*params.resolution;\n let nearEdge=clamp(pixel+0.5,vec2f(0),vec2f(1));\n let farEdge=clamp(params.resolution+0.5-pixel,vec2f(0),vec2f(1));\n coverage=nearEdge.x*nearEdge.y*farEdge.x*farEdge.y;\n }\n return vec4f(color*sampled.a,sampled.a)*coverage;\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n if (params.radius==0.0) {return textureSampleLevel(source,sourceSampler,input.uv,0);}\n var sum=vec4f(0);var total=0.0;\n for (var i=0;i<2048;i++) {\n if (f32(i)>=params.options.x) {break;}\n let angle=f32(i)*GOLDEN_ANGLE;\n var boundary=1.0;\n if (params.shape<11.0) {\n let halfSector=PI/params.shape;\n let value=angle+PI/2.0;\n let localAngle=value-floor(value/(2.0*halfSector))*(2.0*halfSector)-halfSector;\n let polygon=cos(halfSector)/cos(localAngle);\n boundary=mix(polygon,1.0,params.iris.x);\n }\n let distance=sqrt((f32(i)+0.5)/params.options.x)*boundary;\n let rotatedAngle=angle+params.iris.y;\n let offset=vec2f(cos(rotatedAngle)*params.iris.z,sin(rotatedAngle))*distance*params.radius;\n let weight=boundary*boundary;\n sum+=readSource(input.uv-offset/params.resolution)*weight;\n total+=weight;\n }\n var color=sum/total;\n if (params.options.y!=0.0 && color.a>0.0) {color=vec4f(toSrgb(color.rgb/color.a)*color.a,color.a);}\n return vec4f(clamp(color.rgb,vec3f(0),vec3f(color.a)),color.a);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LIGHT_LEAK_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n\nstruct Params { size: vec2f, progress: f32, seed: f32, hue: f32, }\nfn computePattern(uv: vec2f, s: f32, t: f32) -> vec3f {\n var p = uv * 0.8 + vec2f(sin(s * 1.61803) * 5.0, cos(s * 2.71828) * 5.0);\n for (var i = 1; i < 5; i++) {\n var newp = p;\n let fi = f32(i);\n let phase = s * 0.7 * fi;\n newp.x += 0.6 / fi * cos(fi * p.y + t * 0.7 + 0.3 * fi + phase) + 20.0;\n newp.y += 0.6 / fi * cos(fi * p.x + t * 0.7 + 0.3 * f32(i + 10) + phase) - 20.0 + 15.0;\n p = newp;\n }\n let v1 = 0.5 * sin(2.0 * p.x) + 0.5;\n let v2 = 0.5 * sin(2.0 * p.y) + 0.5;\n let blend = sin(p.x + p.y) * 0.5 + 0.5;\n let brightness = v1 * 0.5 + v2 * 0.5;\n return vec3f(brightness, blend, brightness * 0.6 + blend * 0.4);\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let evolveProgress = min(1.0, params.progress * 2.0);\n let retractProgress = max(0.0, params.progress * 2.0 - 1.0);\n let refScale = 1.92;\n let uv = (vec2f(input.position.x, params.size.y - input.position.y) / params.size) * vec2f(refScale, refScale * params.size.y / params.size.x);\n let patA = computePattern(uv, params.seed, evolveProgress * 3.14159);\n let threshA = 1.0 - evolveProgress;\n let revealAlpha = smoothstep(threshA, threshA + 0.3, patA.z);\n let maxUv = vec2f(refScale, refScale * params.size.y / params.size.x);\n let patB = computePattern(maxUv - uv, params.seed + 42.0, retractProgress * 3.14159);\n let threshB = 1.0 - retractProgress;\n let eraseAlpha = smoothstep(threshB, threshB + 0.3, patB.z);\n let alpha = revealAlpha * (1.0 - eraseAlpha);\n var col = mix(vec3f(1.0, 0.85, 0.2), vec3f(1.0, 0.5, 0.05), patA.y) * (0.6 + 0.6 * patA.x);\n let angle = params.hue * 3.14159 / 180.0;\n let a = cos(angle);\n let b = sin(angle) * 0.57735;\n let c = (1.0 - a) / 3.0;\n let hueRot = mat3x3f(vec3f(a+c,c-b,c+b),vec3f(c+b,a+c,c-b),vec3f(c-b,c+b,a+c));\n col = clamp(hueRot * col, vec3f(0), vec3f(1));\n let color = textureSampleLevel(source, sourceSampler, input.uv, 0);\n return vec4f(col * alpha, alpha) + color * (1.0 - alpha);\n}\n\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LIGHT_TRAIL_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params {resolution: vec2f, direction: vec2f, color: vec4f, values: vec4f, samples: vec4f,}\nfn contribution(color: vec4f) -> f32 {\n if (color.a<=0.001) {return 0.0;}\n let luminance=dot(color.rgb/color.a,vec3f(0.299,0.587,0.114));\n let value=max(color.a,luminance);let threshold=clamp(params.values.w,0.0,1.0);\n if (threshold>=1.0) {return step(1.0,value);}\n return clamp((value-threshold)/max(1.0-threshold,0.0001),0.0,1.0);\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color=textureSampleLevel(source,sourceSampler,input.uv,0);\n var trail=vec4f(0);let count=max(params.samples.x,1.0);\n for (var i=1; i<=64; i++) {\n if (f32(i)>params.samples.x) {break;}\n let progress=f32(i)/count;\n let offset=params.direction/params.resolution*params.values.x*progress;\n let sampled=textureSampleLevel(source,sourceSampler,input.uv-offset,0);\n let weight=pow(clamp(params.values.z,0.0,1.0),f32(i-1))*contribution(sampled);\n let alpha=sampled.a*params.color.a*weight;\n trail+=vec4f(params.color.rgb*alpha,alpha);\n }\n return min(color+trail*max(params.values.y,0.0)/count,vec4f(1));\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LINEAR_GRADIENT_TINT_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\nstruct Params { start: vec2f, end: vec2f, startColor: vec4f, endColor: vec4f, amount: f32, padding1: f32, padding2: f32, padding3: f32 }\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n\nfn gradientProgress(uv: vec2f) -> f32 {\n let gradient = params.end - params.start;\n let gradientLengthSq = dot(gradient, gradient);\n if (gradientLengthSq <= 0.0000001) { return 0.0; }\n return clamp(dot(uv - params.start, gradient) / gradientLengthSq, 0.0, 1.0);\n}\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color = textureSampleLevel(source, sourceSampler, input.uv, 0.0);\n let alpha = color.a;\n if (alpha <= 0.001) { return vec4f(0.0); }\n let tintColor = mix(params.startColor, params.endColor, gradientProgress(input.uv));\n let blended = mix(color.rgb / alpha, tintColor.rgb, params.amount * tintColor.a);\n return vec4f(blended * alpha, alpha);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LINEAR_GRADIENT_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\nstruct Params { start: vec2f, end: vec2f, startColor: vec4f, endColor: vec4f, amount: f32, padding1: f32, padding2: f32, padding3: f32 }\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n\nfn gradientProgress(uv: vec2f) -> f32 {\n let gradient = params.end - params.start;\n let gradientLengthSq = dot(gradient, gradient);\n if (gradientLengthSq <= 0.0000001) { return 0.0; }\n return clamp(dot(uv - params.start, gradient) / gradientLengthSq, 0.0, 1.0);\n}\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color = mix(params.startColor, params.endColor, gradientProgress(input.uv));\n return vec4f(color.rgb * color.a, color.a);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LINES_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var sourceTexture: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var palette: texture_2d<f32>;\nstruct Params {\n geometry: vec4f,\n stripe: vec4f,\n flags: vec4f,\n}\nfn sampleSource(uv: vec2f) -> vec4f {\n return textureSampleLevel(sourceTexture, sourceSampler, vec2f(uv.x, 1.0 - uv.y), 0);\n}\nfn glslModulo(value: f32, divisor: f32) -> f32 { return value - divisor * floor(value / divisor); }\nfn paletteColor(index: f32) -> vec4f { return textureLoad(palette, vec2i(i32(index), 0), 0); }\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let vUv = vec2f(input.uv.x, 1.0 - input.uv.y);\n\n let texColor = sampleSource(vUv);\n let thickness = max(params.stripe.x, 0.001);\n let spacing = max(params.stripe.y, 0.001);\n let cycle = spacing * params.geometry.z;\n let centered = vec2f(input.position.x, params.geometry.y - input.position.y) - params.geometry.xy * 0.5;\n let s = sin(params.stripe.z);\n let c = cos(params.stripe.z);\n let rotated = vec2f(centered.x * c - centered.y * s, centered.x * s + centered.y * c);\n var axis = select(rotated.x, rotated.y, params.geometry.w == 0.0);\n\n var position = glslModulo(axis + params.stripe.w, cycle);\n if (position < 0.0) { position += cycle; }\n let colorIndex = floor(position / spacing);\n let inStripe = glslModulo(position, spacing);\n if (inStripe > thickness) { return texColor; }\n\n let overlay = paletteColor(colorIndex);\n let premultiplied = overlay.rgb * overlay.a;\n if (params.flags.x != 0.0) {\n return vec4f(premultiplied * texColor.a + texColor.rgb * (1.0 - overlay.a), texColor.a);\n }\n return vec4f(premultiplied + texColor.rgb * (1.0 - overlay.a), overlay.a + texColor.a * (1.0 - overlay.a));\n\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LIQUID_CONTOURS_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var sourceTexture: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params {\n geometry: vec4f,\n noise: vec4f,\n offset: vec4f,\n first: vec4f,\n second: vec4f,\n}\nfn sampleSource(uv: vec2f) -> vec4f {\n return textureSampleLevel(sourceTexture, sourceSampler, vec2f(uv.x, 1.0 - uv.y), 0);\n}\n\nfn hash(p: vec2f) -> f32 {\n var p3 = fract(p.xyx * 0.1031);\n p3 += vec3f(dot(p3, p3.yzx + vec3f(33.33) + vec3f(params.noise.z * 0.013)));\n return fract((p3.x + p3.y) * p3.z);\n}\nfn valueNoise(p: vec2f) -> f32 {\n let i = floor(p);\n let f = fract(p);\n let u = f * f * f * (f * (f * 6.0 - vec2f(15.0)) + vec2f(10.0));\n return mix(mix(hash(i), hash(i + vec2f(1, 0)), u.x), mix(hash(i + vec2f(0, 1)), hash(i + vec2f(1)), u.x), u.y);\n}\n\nfn fbm(position: vec2f) -> f32 {\n var p = position;\n var value = 0.0;\n var amplitude = 0.5;\n var total = 0.0;\n let persistence = mix(0.2, 0.58, params.noise.x);\n let rotate = mat2x2f(0.80, 0.60, -0.60, 0.80);\n for (var i = 0; i < 5; i++) {\n let octave = f32(i) / 4.0;\n let detail = mix(0.45, 1.0, params.noise.x);\n let octaveWeight = mix(1.0, 1.0 - smoothstep(0.4, 1.0, octave), 1.0 - detail);\n value += amplitude * octaveWeight * valueNoise(p);\n total += amplitude * octaveWeight;\n p = rotate * p * 2.03 + vec2f(13.17, 7.31);\n amplitude *= persistence;\n }\n return value / total;\n}\n\nfn waveAt(pixel: vec2f) -> f32 {\n let position = pixel + params.offset.xy;\n let p = position / max(params.geometry.w, 0.001) + vec2f(params.noise.z * 0.137, params.noise.z * 0.193);\n let warp = vec2f(fbm(p + vec2f(5.2, 1.3)), fbm(p + vec2f(1.7, 9.2))) - vec2f(0.5);\n let roundRotation = mat2x2f(0.7071, 0.7071, -0.7071, 0.7071);\n let roundedField = mix(valueNoise(p * 0.9), valueNoise(roundRotation * p * 0.78 + vec2f(8.3, 2.7)), 0.45);\n let detailedField = fbm(p + warp * mix(0.35, 1.8, params.noise.x));\n let detailMix = smoothstep(0.0, 1.0, params.noise.x);\n let field = mix(roundedField, detailedField, detailMix);\n let levels = max(max(params.geometry.x, params.geometry.y) / max(params.geometry.z, 0.001), 1.0);\n return sin((field * levels + params.noise.w) * 6.28318530718);\n\n}\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let vUv = vec2f(input.uv.x, 1.0 - input.uv.y);\n\n let pixel = vec2f(input.position.x, params.geometry.y - input.position.y);\n let wave = waveAt(pixel);\n var derivative = fwidth(wave);\n if (i32(params.geometry.y) % 2 != 0) {\n // Match WebGL's bottom-origin derivative quads on odd-height targets.\n let neighborY = select(-1.0, 1.0, i32(pixel.y) % 2 == 0);\n derivative = abs(dpdx(wave)) + abs(waveAt(pixel + vec2f(0, neighborY)) - wave);\n }\n let edgeWidth = derivative * mix(0.15, 1.4, params.noise.y);\n let selector = smoothstep(-edgeWidth, edgeWidth, wave);\n let color = mix(params.first, params.second, selector);\n return vec4f(color.rgb * color.a, color.a);\n\n}\n";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const LONG_SHADOWS_EXTEND_WEBGPU_SHADER = "\n\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var secondary: texture_2d<f32>;\n\nstruct Params {offset: vec4f,}\nfn alphaAt(pixel: vec2i) -> f32 {\n let size=vec2i(textureDimensions(source));\n if (any(pixel<vec2i(0)) || any(pixel>=size)) {return 0.0;}\n return textureLoad(source,pixel,0).a;\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let pixel=(input.uv-params.offset.xy)*vec2f(textureDimensions(source))-0.5;\n let base=vec2i(floor(pixel));let fraction=fract(pixel);\n let shifted=mix(mix(alphaAt(base),alphaAt(base+vec2i(1,0)),fraction.x),mix(alphaAt(base+vec2i(0,1)),alphaAt(base+vec2i(1,1)),fraction.x),fraction.y);\n return vec4f(0,0,0,max(textureSampleLevel(source,sourceSampler,input.uv,0).a,shifted));\n}\n";
|
|
2
|
+
export declare const LONG_SHADOWS_COMPOSITE_WEBGPU_SHADER = "\n\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var secondary: texture_2d<f32>;\n\nstruct Params {color: vec4f,}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color=textureSampleLevel(source,sourceSampler,input.uv,0);\n let alpha=textureSampleLevel(secondary,sourceSampler,input.uv,0).a*params.color.a;\n return color+vec4f(params.color.rgb*alpha,alpha)*(1.0-color.a);\n}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LUT_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\nstruct Params {domainMin: vec4f, domainMax: vec4f,}\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var lut: texture_2d<f32>;\nfn lookup(p: vec3u) -> vec3f {\n let size = u32(params.domainMin.w);\n let index = p.x + size * (p.y + size * p.z);\n let width = textureDimensions(lut).x;\n // The WebGL LUT is RGBA16F. Preserve its rounding before interpolation.\n return quantizeToF16(textureLoad(lut, vec2u(index % width, index / width), 0).rgb);\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color = textureSampleLevel(source, sourceSampler, input.uv, 0);\n if (color.a <= 0.0) { return vec4f(0); }\n let normalized = clamp((color.rgb / color.a - params.domainMin.xyz) / (params.domainMax.xyz - params.domainMin.xyz), vec3f(0), vec3f(1));\n let position = normalized * (params.domainMin.w - 1.0);\n let lower = vec3u(floor(position));\n let upper = min(lower + vec3u(1), vec3u(u32(params.domainMin.w) - 1u));\n let fraction = fract(position);\n let c00 = mix(lookup(lower), lookup(vec3u(upper.x, lower.yz)), fraction.x);\n let c10 = mix(lookup(vec3u(lower.x, upper.y, lower.z)), lookup(vec3u(upper.xy, lower.z)), fraction.x);\n let c01 = mix(lookup(vec3u(lower.xy, upper.z)), lookup(vec3u(upper.x, lower.y, upper.z)), fraction.x);\n let c11 = mix(lookup(vec3u(lower.x, upper.yz)), lookup(upper), fraction.x);\n return vec4f(mix(mix(c00, c10, fraction.y), mix(c01, c11, fraction.y), fraction.z) * color.a, color.a);\n}\n";
|