@remotion/effects 4.0.538 → 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 +19 -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/curves.d.ts +65 -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 +357 -0
- 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 +204 -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 +868 -0
- 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/levels.d.ts +69 -2
- 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/geometry.d.ts +19 -0
- package/dist/shatter/index.d.ts +39 -0
- package/dist/shatter/runtime.d.ts +19 -0
- package/dist/shatter/webgpu-shader.d.ts +1 -0
- package/dist/shatter.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 +59 -3
|
@@ -1,110 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setupWebGpuColors,
|
|
3
|
+
getWebGpuColors
|
|
4
|
+
} from "./index-8jx11jyn.mjs";
|
|
5
|
+
import {
|
|
6
|
+
assertOptionalFiniteNumber,
|
|
7
|
+
validateUnitInterval,
|
|
8
|
+
parseColorRgba
|
|
9
|
+
} from "./index-wxhvgv2s.mjs";
|
|
10
|
+
import {
|
|
11
|
+
WEBGPU_SINGLE_PASS_VERTEX,
|
|
12
|
+
cleanupWebGpuSinglePass,
|
|
13
|
+
applyWebGpuSinglePass
|
|
14
|
+
} from "./index-tvfexb7s.mjs";
|
|
15
|
+
import {
|
|
16
|
+
assertEffectParamsObject,
|
|
17
|
+
assertOptionalColor,
|
|
18
|
+
assertOptionalBoolean
|
|
19
|
+
} from "./index-4fvp93ps.mjs";
|
|
20
|
+
|
|
1
21
|
// src/contour-lines.ts
|
|
2
22
|
import { Internals } from "remotion";
|
|
3
23
|
|
|
4
|
-
// src/
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
var assertOptionalColor = (value, name) => {
|
|
21
|
-
if (value === undefined) {
|
|
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
|
-
};
|
|
24
|
+
// src/contour-lines-webgpu-shader.ts
|
|
25
|
+
var CONTOUR_LINES_WEBGPU_SHADER = `
|
|
26
|
+
${WEBGPU_SINGLE_PASS_VERTEX}
|
|
27
|
+
@group(0) @binding(0) var sourceTexture: texture_2d<f32>;
|
|
28
|
+
@group(0) @binding(1) var sourceSampler: sampler;
|
|
29
|
+
@group(0) @binding(2) var<uniform> params: Params;
|
|
30
|
+
struct Params {
|
|
31
|
+
geometry: vec4f,
|
|
32
|
+
noise: vec4f,
|
|
33
|
+
offset: vec4f,
|
|
34
|
+
lineColor: vec4f,
|
|
35
|
+
}
|
|
36
|
+
fn sampleSource(uv: vec2f) -> vec4f {
|
|
37
|
+
return textureSampleLevel(sourceTexture, sourceSampler, vec2f(uv.x, 1.0 - uv.y), 0);
|
|
38
|
+
}
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
};
|
|
40
|
+
fn hash(p: vec2f) -> f32 {
|
|
41
|
+
var p3 = fract(p.xyx * 0.1031);
|
|
42
|
+
p3 += vec3f(dot(p3, p3.yzx + vec3f(33.33) + vec3f(params.noise.z * 0.013)));
|
|
43
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
44
|
+
}
|
|
45
|
+
fn valueNoise(p: vec2f) -> f32 {
|
|
46
|
+
let i = floor(p);
|
|
47
|
+
let f = fract(p);
|
|
48
|
+
let u = f * f * f * (f * (f * 6.0 - vec2f(15.0)) + vec2f(10.0));
|
|
49
|
+
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);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fn fbm(position: vec2f) -> f32 {
|
|
53
|
+
var p = position;
|
|
54
|
+
var value = 0.0;
|
|
55
|
+
var amplitude = 0.5;
|
|
56
|
+
var totalAmplitude = 0.0;
|
|
57
|
+
let persistence = mix(0.18, 0.58, clamp(params.noise.x, 0.0, 1.0));
|
|
58
|
+
let smoothness = clamp(params.noise.y, 0.0, 1.0);
|
|
59
|
+
let rotate = mat2x2f(0.80, 0.60, -0.60, 0.80);
|
|
60
|
+
for (var i = 0; i < 5; i++) {
|
|
61
|
+
let octave = f32(i) / 4.0;
|
|
62
|
+
let detailWeight = mix(1.0, 1.0 - smoothstep(0.15, 1.0, octave), smoothness);
|
|
63
|
+
value += amplitude * detailWeight * valueNoise(p);
|
|
64
|
+
totalAmplitude += amplitude * detailWeight;
|
|
65
|
+
p = rotate * p * 2.04 + vec2f(13.17, 7.31);
|
|
66
|
+
amplitude *= persistence;
|
|
67
|
+
}
|
|
68
|
+
return value / totalAmplitude;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fn contourAt(pixel: vec2f) -> f32 {
|
|
72
|
+
let pixelPosition = pixel + params.offset.xy;
|
|
73
|
+
let scale = max(params.geometry.w, 0.001);
|
|
74
|
+
let p = pixelPosition / scale + vec2f(params.noise.z * 0.137, params.noise.z * 0.193);
|
|
75
|
+
let complexity = clamp(params.noise.x, 0.0, 1.0);
|
|
76
|
+
let smoothness = clamp(params.noise.y, 0.0, 1.0);
|
|
77
|
+
let warp = vec2f(fbm(p + vec2f(5.2, 1.3)), fbm(p + vec2f(1.7, 9.2))) - vec2f(0.5);
|
|
78
|
+
let terrain = fbm(p + warp * complexity * mix(2.8, 1.2, smoothness));
|
|
79
|
+
let levels = max(max(params.geometry.x, params.geometry.y) / (max(params.geometry.z, 0.001) * 2.0), 1.0);
|
|
80
|
+
return terrain * levels;
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {
|
|
85
|
+
let vUv = vec2f(input.uv.x, 1.0 - input.uv.y);
|
|
86
|
+
|
|
87
|
+
let texColor = sampleSource(vUv);
|
|
88
|
+
let pixel = vec2f(input.position.x, params.geometry.y - input.position.y);
|
|
89
|
+
let contourPosition = contourAt(pixel);
|
|
90
|
+
let contourFraction = fract(contourPosition);
|
|
91
|
+
let distanceToContour = min(contourFraction, 1.0 - contourFraction);
|
|
92
|
+
var derivative = fwidth(contourPosition);
|
|
93
|
+
if (i32(params.geometry.y) % 2 != 0) {
|
|
94
|
+
// WebGL derivative quads start at the bottom edge. Odd-height targets shift
|
|
95
|
+
// WebGPU's top-origin Y pairs, so evaluate the matching vertical neighbor.
|
|
96
|
+
let neighborY = select(-1.0, 1.0, i32(pixel.y) % 2 == 0);
|
|
97
|
+
derivative = abs(dpdx(contourPosition)) + abs(contourAt(pixel + vec2f(0, neighborY)) - contourPosition);
|
|
98
|
+
}
|
|
99
|
+
derivative = max(derivative, 0.0001);
|
|
100
|
+
let halfLineWidth = max(params.noise.w, 0.001) * 0.5 * derivative;
|
|
101
|
+
let coverage = 1.0 - smoothstep(halfLineWidth, halfLineWidth + derivative, distanceToContour);
|
|
102
|
+
let lineAlpha = params.lineColor.a * params.offset.z * coverage;
|
|
103
|
+
let premultipliedLine = params.lineColor.rgb * lineAlpha;
|
|
104
|
+
if (params.offset.w != 0.0) { return vec4f(premultipliedLine * texColor.a + texColor.rgb * (1.0 - lineAlpha), texColor.a); }
|
|
105
|
+
return vec4f(premultipliedLine + texColor.rgb * (1.0 - lineAlpha), lineAlpha + texColor.a * (1.0 - lineAlpha));
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
108
109
|
|
|
109
110
|
// src/contour-lines.ts
|
|
110
111
|
var { createEffect, createWebGL2ContextError } = Internals;
|
|
@@ -319,7 +320,7 @@ float fbm(vec2 p) {
|
|
|
319
320
|
|
|
320
321
|
void main() {
|
|
321
322
|
vec4 texColor = texture(uSource, vUv);
|
|
322
|
-
vec2 pixelPosition =
|
|
323
|
+
vec2 pixelPosition = gl_FragCoord.xy + uOffset;
|
|
323
324
|
float scale = max(uScale, 0.001);
|
|
324
325
|
vec2 p = pixelPosition / scale + vec2(uSeed * 0.137, uSeed * 0.193);
|
|
325
326
|
|
|
@@ -496,67 +497,107 @@ var contourLines = createEffect({
|
|
|
496
497
|
type: "dev.remotion.effects.contourLines",
|
|
497
498
|
label: "contourLines()",
|
|
498
499
|
documentationLink: "https://www.remotion.dev/docs/effects/contour-lines",
|
|
499
|
-
backend: "webgl2",
|
|
500
500
|
calculateKey: (params) => {
|
|
501
501
|
const r = resolve(params);
|
|
502
502
|
const maskSuffix = r.maskToSourceAlpha ? "-mask-to-source-alpha" : "";
|
|
503
503
|
return `contour-lines-${r.lineColor}-${r.lineWidth}-${r.spacing}-${r.scale}-${r.complexity}-${r.smoothness}-${r.seed}-${r.offsetX}-${r.offsetY}-${r.opacity}${maskSuffix}`;
|
|
504
504
|
},
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
505
|
+
implementations: {
|
|
506
|
+
webgpu: Internals.createEffectImplementation({
|
|
507
|
+
setup: (target) => setupWebGpuColors(target, "contour-lines"),
|
|
508
|
+
apply: ({ source, width, height, params, state, gpuDevice }) => {
|
|
509
|
+
if (!gpuDevice)
|
|
510
|
+
throw new Error("A WebGPU device is required for the contour-lines effect");
|
|
511
|
+
const r = resolve(params);
|
|
512
|
+
const colors = getWebGpuColors(state, [r.lineColor]);
|
|
513
|
+
const uniformData = new Float32Array([
|
|
514
|
+
width,
|
|
515
|
+
height,
|
|
516
|
+
r.spacing,
|
|
517
|
+
r.scale,
|
|
518
|
+
r.complexity,
|
|
519
|
+
r.smoothness,
|
|
520
|
+
r.seed,
|
|
521
|
+
r.lineWidth,
|
|
522
|
+
r.offsetX,
|
|
523
|
+
r.offsetY,
|
|
524
|
+
r.opacity,
|
|
525
|
+
r.maskToSourceAlpha ? 1 : 0,
|
|
526
|
+
colors[0] / 255,
|
|
527
|
+
colors[1] / 255,
|
|
528
|
+
colors[2] / 255,
|
|
529
|
+
colors[3] / 255
|
|
530
|
+
]);
|
|
531
|
+
applyWebGpuSinglePass({
|
|
532
|
+
state,
|
|
533
|
+
source,
|
|
534
|
+
width,
|
|
535
|
+
height,
|
|
536
|
+
device: gpuDevice,
|
|
537
|
+
shader: CONTOUR_LINES_WEBGPU_SHADER,
|
|
538
|
+
uniformData
|
|
539
|
+
});
|
|
540
|
+
},
|
|
541
|
+
cleanup: cleanupWebGpuSinglePass
|
|
542
|
+
}),
|
|
543
|
+
webgl2: Internals.createEffectImplementation({
|
|
544
|
+
setup: (target) => setupContourLines(target),
|
|
545
|
+
apply: ({ source, width, height, params, state, flipSourceY }) => {
|
|
546
|
+
const r = resolve(params);
|
|
547
|
+
const { gl, program, sourceTexture, uniforms, vao } = state;
|
|
548
|
+
if (state.cachedLineColor !== r.lineColor) {
|
|
549
|
+
state.cachedLineColor = r.lineColor;
|
|
550
|
+
state.cachedLineColorRgba = parseColorRgba(state.colorCtx, r.lineColor);
|
|
551
|
+
}
|
|
552
|
+
const [cr, cg, cb, ca] = state.cachedLineColorRgba;
|
|
553
|
+
gl.viewport(0, 0, width, height);
|
|
554
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
555
|
+
gl.clearColor(0, 0, 0, 0);
|
|
556
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
557
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
558
|
+
gl.bindTexture(gl.TEXTURE_2D, sourceTexture);
|
|
559
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
560
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
|
|
561
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
|
|
562
|
+
gl.useProgram(program);
|
|
563
|
+
if (uniforms.uSource)
|
|
564
|
+
gl.uniform1i(uniforms.uSource, 0);
|
|
565
|
+
if (uniforms.uResolution)
|
|
566
|
+
gl.uniform2f(uniforms.uResolution, width, height);
|
|
567
|
+
if (uniforms.uLineColor) {
|
|
568
|
+
gl.uniform4f(uniforms.uLineColor, cr / 255, cg / 255, cb / 255, ca / 255);
|
|
569
|
+
}
|
|
570
|
+
if (uniforms.uLineWidth)
|
|
571
|
+
gl.uniform1f(uniforms.uLineWidth, r.lineWidth);
|
|
572
|
+
if (uniforms.uSpacing)
|
|
573
|
+
gl.uniform1f(uniforms.uSpacing, r.spacing);
|
|
574
|
+
if (uniforms.uScale)
|
|
575
|
+
gl.uniform1f(uniforms.uScale, r.scale);
|
|
576
|
+
if (uniforms.uComplexity)
|
|
577
|
+
gl.uniform1f(uniforms.uComplexity, r.complexity);
|
|
578
|
+
if (uniforms.uSmoothness)
|
|
579
|
+
gl.uniform1f(uniforms.uSmoothness, r.smoothness);
|
|
580
|
+
if (uniforms.uSeed)
|
|
581
|
+
gl.uniform1f(uniforms.uSeed, r.seed);
|
|
582
|
+
if (uniforms.uOffset)
|
|
583
|
+
gl.uniform2f(uniforms.uOffset, r.offsetX, r.offsetY);
|
|
584
|
+
if (uniforms.uOpacity)
|
|
585
|
+
gl.uniform1f(uniforms.uOpacity, r.opacity);
|
|
586
|
+
if (uniforms.uMaskToSourceAlpha)
|
|
587
|
+
gl.uniform1i(uniforms.uMaskToSourceAlpha, r.maskToSourceAlpha ? 1 : 0);
|
|
588
|
+
gl.bindVertexArray(vao);
|
|
589
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
590
|
+
gl.bindVertexArray(null);
|
|
591
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
592
|
+
gl.useProgram(null);
|
|
593
|
+
},
|
|
594
|
+
cleanup: ({ gl, program, vao, vbo, sourceTexture }) => {
|
|
595
|
+
gl.deleteTexture(sourceTexture);
|
|
596
|
+
gl.deleteBuffer(vbo);
|
|
597
|
+
gl.deleteProgram(program);
|
|
598
|
+
gl.deleteVertexArray(vao);
|
|
599
|
+
}
|
|
600
|
+
})
|
|
560
601
|
},
|
|
561
602
|
schema: contourLinesSchema,
|
|
562
603
|
validateParams: validateContourLinesParams
|
package/dist/esm/contrast.mjs
CHANGED
|
@@ -1,112 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
var assertRequiredColor = (value, name) => {
|
|
16
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
17
|
-
throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
var assertOptionalColor = (value, name) => {
|
|
21
|
-
if (value === undefined) {
|
|
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
|
-
};
|
|
1
|
+
import"./index-8p04sssx.mjs";
|
|
2
|
+
import {
|
|
3
|
+
createColorMatrixImplementations
|
|
4
|
+
} from "./index-cdp7tr8x.mjs";
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_AMOUNT,
|
|
7
|
+
colorMultiplierSchema,
|
|
8
|
+
assertOptionalFiniteNumber,
|
|
9
|
+
validateNonNegative,
|
|
10
|
+
clampColorChannel
|
|
11
|
+
} from "./index-wxhvgv2s.mjs";
|
|
12
|
+
import {
|
|
13
|
+
assertEffectParamsObject
|
|
14
|
+
} from "./index-4fvp93ps.mjs";
|
|
108
15
|
|
|
109
16
|
// src/contrast.ts
|
|
17
|
+
import { Internals } from "remotion";
|
|
110
18
|
var { createEffect } = Internals;
|
|
111
19
|
var contrastSchema = {
|
|
112
20
|
amount: colorMultiplierSchema
|
|
@@ -124,35 +32,60 @@ var contrast = createEffect({
|
|
|
124
32
|
type: "dev.remotion.effects.contrast",
|
|
125
33
|
label: "contrast()",
|
|
126
34
|
documentationLink: "https://www.remotion.dev/docs/effects/contrast",
|
|
127
|
-
backend: "2d",
|
|
128
35
|
calculateKey: (params) => {
|
|
129
36
|
const r = resolve(params);
|
|
130
37
|
return `contrast-${r.amount}`;
|
|
131
38
|
},
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
39
|
+
implementations: {
|
|
40
|
+
...createColorMatrixImplementations("contrast", (params) => {
|
|
41
|
+
const { amount } = resolve(params);
|
|
42
|
+
const factor = Math.min(amount, 256);
|
|
43
|
+
return new Float32Array([
|
|
44
|
+
factor,
|
|
45
|
+
0,
|
|
46
|
+
0,
|
|
47
|
+
0,
|
|
48
|
+
0,
|
|
49
|
+
factor,
|
|
50
|
+
0,
|
|
51
|
+
0,
|
|
52
|
+
0,
|
|
53
|
+
0,
|
|
54
|
+
factor,
|
|
55
|
+
0,
|
|
56
|
+
2,
|
|
57
|
+
0,
|
|
58
|
+
amount === 1 ? 1 : 0,
|
|
59
|
+
0
|
|
60
|
+
]);
|
|
61
|
+
}),
|
|
62
|
+
"2d": Internals.createEffectImplementation({
|
|
63
|
+
setup: () => null,
|
|
64
|
+
apply: ({ source, target, width, height, params }) => {
|
|
65
|
+
const ctx = target.getContext("2d");
|
|
66
|
+
if (!ctx) {
|
|
67
|
+
throw new Error("Failed to acquire 2D context for contrast effect. The canvas may have been assigned a different context type.");
|
|
68
|
+
}
|
|
69
|
+
const r = resolve(params);
|
|
70
|
+
ctx.clearRect(0, 0, width, height);
|
|
71
|
+
ctx.drawImage(source, 0, 0, width, height);
|
|
72
|
+
if (r.amount === 1) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const imageData = ctx.getImageData(0, 0, width, height);
|
|
76
|
+
const { data } = imageData;
|
|
77
|
+
const factor = r.amount;
|
|
78
|
+
for (let i = 0;i < data.length; i += 4) {
|
|
79
|
+
data[i] = clampColorChannel((data[i] - 128) * factor + 128);
|
|
80
|
+
data[i + 1] = clampColorChannel((data[i + 1] - 128) * factor + 128);
|
|
81
|
+
data[i + 2] = clampColorChannel((data[i + 2] - 128) * factor + 128);
|
|
82
|
+
}
|
|
83
|
+
ctx.putImageData(imageData, 0, 0);
|
|
84
|
+
},
|
|
85
|
+
cleanup: () => {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
})
|
|
156
89
|
},
|
|
157
90
|
schema: contrastSchema,
|
|
158
91
|
validateParams: validateContrastParams
|