@remotion/effects 4.0.539 → 4.0.541

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.
Files changed (203) hide show
  1. package/THIRD_PARTY_LICENSES.md +15 -0
  2. package/dist/barrel-distortion/webgpu-shader.d.ts +1 -0
  3. package/dist/bevel-alpha/webgpu-shaders.d.ts +2 -0
  4. package/dist/burlap-webgpu-shader.d.ts +1 -0
  5. package/dist/checkerboard-webgpu-shader.d.ts +1 -0
  6. package/dist/chromatic-aberration/webgpu-shader.d.ts +1 -0
  7. package/dist/color-correction-webgpu-shader-utils.d.ts +4 -0
  8. package/dist/color-key-webgpu-shader.d.ts +1 -0
  9. package/dist/color-matrix-runtime.d.ts +4 -0
  10. package/dist/contour-lines-webgpu-shader.d.ts +1 -0
  11. package/dist/corner-pin/webgpu-shader.d.ts +1 -0
  12. package/dist/cylinder/webgl-shader.d.ts +1 -0
  13. package/dist/dot-grid-webgpu-shader.d.ts +1 -0
  14. package/dist/drop-shadow/webgpu-shaders.d.ts +2 -0
  15. package/dist/emboss-webgpu-shader.d.ts +1 -0
  16. package/dist/esm/barrel-distortion.mjs +67 -118
  17. package/dist/esm/bevel-alpha.mjs +247 -196
  18. package/dist/esm/blur.mjs +101 -115
  19. package/dist/esm/brightness.mjs +65 -132
  20. package/dist/esm/burlap.mjs +178 -151
  21. package/dist/esm/checkerboard.mjs +6 -514
  22. package/dist/esm/chromatic-aberration.mjs +72 -119
  23. package/dist/esm/color-correction.mjs +186 -224
  24. package/dist/esm/color-key.mjs +149 -136
  25. package/dist/esm/contour-lines.mjs +201 -160
  26. package/dist/esm/contrast.mjs +65 -132
  27. package/dist/esm/corner-pin.mjs +4 -390
  28. package/dist/esm/curves.mjs +195 -211
  29. package/dist/esm/cylinder.mjs +108 -225
  30. package/dist/esm/dot-grid.mjs +184 -213
  31. package/dist/esm/drop-shadow.mjs +162 -180
  32. package/dist/esm/duotone.mjs +110 -143
  33. package/dist/esm/emboss.mjs +153 -151
  34. package/dist/esm/evolve.mjs +228 -154
  35. package/dist/esm/exposure.mjs +93 -201
  36. package/dist/esm/film-burn.mjs +298 -0
  37. package/dist/esm/fisheye.mjs +97 -126
  38. package/dist/esm/flannel.mjs +158 -156
  39. package/dist/esm/fractal-noise.mjs +186 -232
  40. package/dist/esm/glow.mjs +164 -179
  41. package/dist/esm/grayscale.mjs +56 -122
  42. package/dist/esm/gridlines.mjs +6 -575
  43. package/dist/esm/halftone-linear-gradient.mjs +246 -245
  44. package/dist/esm/halftone.mjs +267 -243
  45. package/dist/esm/hue.mjs +55 -122
  46. package/dist/esm/index-00v3hr66.mjs +299 -0
  47. package/dist/esm/index-0w4eqht8.mjs +351 -0
  48. package/dist/esm/index-18y0zcy2.mjs +440 -0
  49. package/dist/esm/index-1m1b1ad7.mjs +520 -0
  50. package/dist/esm/index-34fxm3ax.mjs +518 -0
  51. package/dist/esm/index-4fvp93ps.mjs +32 -0
  52. package/dist/esm/index-4scpn12x.mjs +224 -0
  53. package/dist/esm/index-4z6pt3ka.mjs +104 -0
  54. package/dist/esm/index-618ky75w.mjs +51 -0
  55. package/dist/esm/index-6agxdrvr.mjs +411 -0
  56. package/dist/esm/index-6jkps947.mjs +120 -0
  57. package/dist/esm/index-8agtsbw4.mjs +617 -0
  58. package/dist/esm/index-8jx11jyn.mjs +29 -0
  59. package/dist/esm/index-8p04sssx.mjs +123 -0
  60. package/dist/esm/index-afdtmrh2.mjs +596 -0
  61. package/dist/esm/index-b86qstcs.mjs +18 -0
  62. package/dist/esm/index-cb77qg3g.mjs +587 -0
  63. package/dist/esm/index-cdp7tr8x.mjs +122 -0
  64. package/dist/esm/index-evy8hyah.mjs +55 -0
  65. package/dist/esm/index-gnsce796.mjs +6 -0
  66. package/dist/esm/index-kkvzt8b7.mjs +199 -0
  67. package/dist/esm/index-r0v18b2n.mjs +425 -0
  68. package/dist/esm/index-rswpzmm5.mjs +926 -0
  69. package/dist/esm/index-s9mrx750.mjs +97 -0
  70. package/dist/esm/index-tvfexb7s.mjs +164 -0
  71. package/dist/esm/index-vp56k1gj.mjs +215 -0
  72. package/dist/esm/index-wxhvgv2s.mjs +79 -0
  73. package/dist/esm/index-wy95a41r.mjs +407 -0
  74. package/dist/esm/index-ysnwfc4t.mjs +306 -0
  75. package/dist/esm/index.mjs +49 -4053
  76. package/dist/esm/invert.mjs +54 -122
  77. package/dist/esm/iris-wipe.mjs +315 -0
  78. package/dist/esm/lens-blur.mjs +169 -156
  79. package/dist/esm/levels.mjs +134 -151
  80. package/dist/esm/light-leak.mjs +6 -416
  81. package/dist/esm/light-trail.mjs +124 -128
  82. package/dist/esm/linear-gradient-tint.mjs +4 -424
  83. package/dist/esm/linear-gradient.mjs +4 -370
  84. package/dist/esm/linear-progressive-blur.mjs +92 -118
  85. package/dist/esm/linear-progressive-pixelate.mjs +83 -378
  86. package/dist/esm/lines.mjs +167 -162
  87. package/dist/esm/liquid-contours.mjs +192 -153
  88. package/dist/esm/long-shadows.mjs +278 -251
  89. package/dist/esm/lut.mjs +123 -23
  90. package/dist/esm/mirror.mjs +78 -120
  91. package/dist/esm/noise-displacement.mjs +156 -151
  92. package/dist/esm/noise.mjs +107 -143
  93. package/dist/esm/outline.mjs +192 -170
  94. package/dist/esm/page-turn.mjs +141 -244
  95. package/dist/esm/paper.mjs +522 -194
  96. package/dist/esm/pattern.mjs +4 -568
  97. package/dist/esm/pixel-dissolve.mjs +158 -186
  98. package/dist/esm/pixelate.mjs +92 -149
  99. package/dist/esm/radial-progressive-blur.mjs +96 -118
  100. package/dist/esm/radial-progressive-pixelate.mjs +91 -384
  101. package/dist/esm/radial-wipe.mjs +224 -0
  102. package/dist/esm/rain-fall.mjs +114 -0
  103. package/dist/esm/region-blur.mjs +138 -192
  104. package/dist/esm/rings.mjs +6 -512
  105. package/dist/esm/roughen-edges.mjs +180 -156
  106. package/dist/esm/saturation.mjs +56 -122
  107. package/dist/esm/scale.mjs +50 -60
  108. package/dist/esm/scanlines.mjs +115 -149
  109. package/dist/esm/shadows-highlights.mjs +103 -205
  110. package/dist/esm/shatter.mjs +133 -153
  111. package/dist/esm/shine.mjs +192 -227
  112. package/dist/esm/shrinkwrap.mjs +388 -225
  113. package/dist/esm/skew.mjs +100 -145
  114. package/dist/esm/snow-fall.mjs +170 -0
  115. package/dist/esm/speckle.mjs +192 -210
  116. package/dist/esm/sphere.mjs +101 -225
  117. package/dist/esm/starburst.mjs +6 -345
  118. package/dist/esm/tear.mjs +138 -155
  119. package/dist/esm/thermal-vision.mjs +135 -152
  120. package/dist/esm/tile.mjs +5 -184
  121. package/dist/esm/tint.mjs +80 -132
  122. package/dist/esm/translate.mjs +55 -137
  123. package/dist/esm/turbulent-displace.mjs +182 -221
  124. package/dist/esm/tv-signal-off.mjs +140 -149
  125. package/dist/esm/venetian-blinds.mjs +91 -140
  126. package/dist/esm/vibrance.mjs +95 -204
  127. package/dist/esm/vignette.mjs +136 -155
  128. package/dist/esm/wave.mjs +88 -47
  129. package/dist/esm/waves.mjs +181 -169
  130. package/dist/esm/white-balance.mjs +100 -204
  131. package/dist/esm/white-noise.mjs +98 -146
  132. package/dist/esm/zigzag.mjs +6 -575
  133. package/dist/esm/zoom-blur.mjs +90 -121
  134. package/dist/evolve.d.ts +46 -10
  135. package/dist/film-burn-webgpu-shader.d.ts +1 -0
  136. package/dist/film-burn.d.ts +40 -0
  137. package/dist/fisheye/webgpu-shader.d.ts +1 -0
  138. package/dist/flannel-webgpu-shader.d.ts +1 -0
  139. package/dist/fractal-noise/shader.d.ts +1 -1
  140. package/dist/fractal-noise/webgpu-shader.d.ts +1 -0
  141. package/dist/gaussian-blur-webgpu-shader.d.ts +1 -0
  142. package/dist/glow/webgpu-shaders.d.ts +2 -0
  143. package/dist/gridlines-webgpu-shader.d.ts +1 -0
  144. package/dist/halftone-linear-gradient-webgpu-shader.d.ts +1 -0
  145. package/dist/halftone-webgpu-shader.d.ts +1 -0
  146. package/dist/iris-wipe.d.ts +78 -0
  147. package/dist/lens-blur/webgpu-shader.d.ts +1 -0
  148. package/dist/light-leak-webgpu-shader.d.ts +1 -0
  149. package/dist/light-trail/webgpu-shader.d.ts +1 -0
  150. package/dist/linear-gradient-tint-webgpu-shader.d.ts +1 -0
  151. package/dist/linear-gradient-webgpu-shader.d.ts +1 -0
  152. package/dist/lines-webgpu-shader.d.ts +1 -0
  153. package/dist/liquid-contours-webgpu-shader.d.ts +1 -0
  154. package/dist/long-shadows-webgpu-shaders.d.ts +2 -0
  155. package/dist/lut/webgpu-shader.d.ts +1 -0
  156. package/dist/mirror/webgpu-shader.d.ts +1 -0
  157. package/dist/noise-displacement-webgpu-shader.d.ts +1 -0
  158. package/dist/noise-webgpu-shader.d.ts +1 -0
  159. package/dist/outline/webgpu-shader.d.ts +1 -0
  160. package/dist/page-turn/webgl-shader.d.ts +1 -0
  161. package/dist/paper-webgpu-shader.d.ts +2 -0
  162. package/dist/pattern-webgpu-shader.d.ts +1 -0
  163. package/dist/pixel-dissolve-webgpu-shader.d.ts +1 -0
  164. package/dist/progressive-pixelate-runtime.d.ts +1 -0
  165. package/dist/radial-wipe.d.ts +19 -0
  166. package/dist/rain-fall.d.ts +143 -0
  167. package/dist/rect-transform-runtime.d.ts +11 -0
  168. package/dist/region-blur/webgpu-shader.d.ts +1 -0
  169. package/dist/rings-webgpu-shader.d.ts +1 -0
  170. package/dist/roughen-edges-webgpu-shader.d.ts +1 -0
  171. package/dist/shatter/webgpu-shader.d.ts +1 -0
  172. package/dist/shine-webgpu-shader.d.ts +1 -0
  173. package/dist/shrinkwrap-webgpu-shader.d.ts +1 -0
  174. package/dist/single-pass-runtime.d.ts +18 -0
  175. package/dist/skew-webgpu-shader.d.ts +1 -0
  176. package/dist/snow-fall.d.ts +208 -0
  177. package/dist/speckle-webgpu-shader.d.ts +1 -0
  178. package/dist/sphere/webgl-shader.d.ts +1 -0
  179. package/dist/starburst-webgpu-shader.d.ts +1 -0
  180. package/dist/tear-webgpu-shader.d.ts +1 -0
  181. package/dist/thermal-vision-webgpu-shader.d.ts +1 -0
  182. package/dist/tile-gpu-runtime.d.ts +24 -0
  183. package/dist/turbulent-displace/webgpu-shader.d.ts +1 -0
  184. package/dist/value-noise-webgpu-shader.d.ts +1 -0
  185. package/dist/vignette-webgpu-shader.d.ts +1 -0
  186. package/dist/wave/wave-runtime.d.ts +2 -1
  187. package/dist/wave/webgpu-shader.d.ts +1 -0
  188. package/dist/waves-webgpu-shader.d.ts +1 -0
  189. package/dist/weather/params.d.ts +149 -0
  190. package/dist/weather/runtime.d.ts +52 -0
  191. package/dist/weather/shaders.d.ts +4 -0
  192. package/dist/weather/webgpu-runtime.d.ts +36 -0
  193. package/dist/weather/webgpu-shader.d.ts +1 -0
  194. package/dist/webgl-projection-runtime.d.ts +18 -0
  195. package/dist/webgpu-color-state.d.ts +10 -0
  196. package/dist/webgpu-mesh-runtime.d.ts +46 -0
  197. package/dist/webgpu-multipass-runtime.d.ts +50 -0
  198. package/dist/webgpu-projection-runtime.d.ts +9 -5
  199. package/dist/webgpu-single-pass-runtime.d.ts +47 -0
  200. package/dist/white-noise-webgpu-shader.d.ts +1 -0
  201. package/dist/zigzag-webgpu-shader.d.ts +1 -0
  202. package/dist/zoom-blur/webgpu-shader.d.ts +1 -0
  203. package/package.json +43 -3
@@ -0,0 +1,97 @@
1
+ import {
2
+ setupSinglePass,
3
+ prepareSinglePassSource,
4
+ drawSinglePass,
5
+ cleanupSinglePass
6
+ } from "./index-8p04sssx.mjs";
7
+ import {
8
+ WEBGPU_SINGLE_PASS_VERTEX,
9
+ setupWebGpuSinglePass,
10
+ cleanupWebGpuSinglePass,
11
+ applyWebGpuSinglePass
12
+ } from "./index-tvfexb7s.mjs";
13
+
14
+ // src/rect-transform-runtime.ts
15
+ import { Internals } from "remotion";
16
+ var WEBGL_SHADER = `#version 300 es
17
+ precision highp float;
18
+ in vec2 vUv;
19
+ out vec4 fragColor;
20
+ uniform sampler2D uSource;
21
+ uniform vec2 uResolution;
22
+ uniform vec4 uRect;
23
+ void main() {
24
+ vec2 p = vec2(gl_FragCoord.x, uResolution.y - gl_FragCoord.y);
25
+ vec2 coverage = clamp(min(p + 0.5, uRect.xy + uRect.zw) - max(p - 0.5, uRect.xy), 0.0, 1.0);
26
+ vec2 uv = (p - uRect.xy) / uRect.zw;
27
+ if (any(lessThanEqual(uv, vec2(0.0))) || any(greaterThan(uv, vec2(1.0)))) { fragColor = vec4(0.0); return; }
28
+ fragColor = texture(uSource, vec2(uv.x, 1.0 - uv.y)) * min(coverage.x, coverage.y);
29
+ }
30
+ `;
31
+ var WEBGPU_SHADER = `
32
+ ${WEBGPU_SINGLE_PASS_VERTEX}
33
+ struct Params {
34
+ resolution: vec2f,
35
+ padding: vec2f,
36
+ rect: vec4f,
37
+ }
38
+ @group(0) @binding(0) var source: texture_2d<f32>;
39
+ @group(0) @binding(1) var sourceSampler: sampler;
40
+ @group(0) @binding(2) var<uniform> params: Params;
41
+ @fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {
42
+ let p = input.position.xy;
43
+ let coverage = clamp(min(p + vec2f(0.5), params.rect.xy + params.rect.zw) - max(p - vec2f(0.5), params.rect.xy), vec2f(0), vec2f(1));
44
+ let uv = (p - params.rect.xy) / params.rect.zw;
45
+ if (any(uv <= vec2f(0)) || any(uv > vec2f(1))) { return vec4f(0); }
46
+ return textureSampleLevel(source, sourceSampler, uv, 0) * min(coverage.x, coverage.y);
47
+ }
48
+ `;
49
+ var createRectTransformImplementations = (label, getRect) => ({
50
+ webgl2: Internals.createEffectImplementation({
51
+ setup: (target) => setupSinglePass(target, WEBGL_SHADER, label, ["uResolution", "uRect"]),
52
+ apply: ({ source, width, height, params, state, flipSourceY }) => {
53
+ const rect = getRect(params, width, height);
54
+ prepareSinglePassSource({
55
+ state,
56
+ source,
57
+ width,
58
+ height,
59
+ flipSourceY
60
+ });
61
+ state.gl.uniform2f(state.uniforms.uResolution, width, height);
62
+ state.gl.uniform4f(state.uniforms.uRect, rect.x, rect.y, rect.width, rect.height);
63
+ drawSinglePass(state);
64
+ },
65
+ cleanup: cleanupSinglePass
66
+ }),
67
+ webgpu: Internals.createEffectImplementation({
68
+ setup: (target) => setupWebGpuSinglePass(target, label),
69
+ apply: ({ source, width, height, params, state, gpuDevice }) => {
70
+ if (!gpuDevice) {
71
+ throw new Error(`A WebGPU device is required for the ${label} effect`);
72
+ }
73
+ const rect = getRect(params, width, height);
74
+ applyWebGpuSinglePass({
75
+ state,
76
+ source,
77
+ width,
78
+ height,
79
+ device: gpuDevice,
80
+ shader: WEBGPU_SHADER,
81
+ uniformData: new Float32Array([
82
+ width,
83
+ height,
84
+ 0,
85
+ 0,
86
+ rect.x,
87
+ rect.y,
88
+ rect.width,
89
+ rect.height
90
+ ])
91
+ });
92
+ },
93
+ cleanup: cleanupWebGpuSinglePass
94
+ })
95
+ });
96
+
97
+ export { createRectTransformImplementations };
@@ -0,0 +1,164 @@
1
+ // src/webgpu-single-pass-runtime.ts
2
+ var WEBGPU_SINGLE_PASS_VERTEX = `
3
+ struct VertexOutput {
4
+ @builtin(position) position: vec4f,
5
+ @location(0) uv: vec2f,
6
+ }
7
+
8
+ @vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {
9
+ let positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));
10
+ let position = positions[index];
11
+ var output: VertexOutput;
12
+ output.position = vec4f(position, 0, 1);
13
+ output.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);
14
+ return output;
15
+ }
16
+ `;
17
+ var setupWebGpuSinglePass = (target, label) => {
18
+ const context = target.getContext("webgpu");
19
+ if (!context) {
20
+ throw new Error(`WebGPU is not available for the ${label} effect`);
21
+ }
22
+ return { context, label, resources: null };
23
+ };
24
+ var cleanupWebGpuSinglePass = (state) => {
25
+ state.resources?.source?.texture.destroy();
26
+ state.resources?.uniforms.destroy();
27
+ state.resources?.auxiliary?.texture.destroy();
28
+ state.resources = null;
29
+ state.context.unconfigure();
30
+ };
31
+ var applyWebGpuSinglePass = ({
32
+ state,
33
+ source,
34
+ device,
35
+ shader,
36
+ uniformData
37
+ }, options = null) => {
38
+ const sourceFilter = options?.sourceFilter ?? "linear";
39
+ const auxiliaryTexture = options?.auxiliaryTexture ?? null;
40
+ const width = "displayWidth" in source ? source.displayWidth : ("videoWidth" in source) ? source.videoWidth : ("naturalWidth" in source) ? source.naturalWidth : typeof source.width === "number" ? source.width : source.width.baseVal.value;
41
+ const height = "displayHeight" in source ? source.displayHeight : ("videoHeight" in source) ? source.videoHeight : ("naturalHeight" in source) ? source.naturalHeight : typeof source.height === "number" ? source.height : source.height.baseVal.value;
42
+ const uniformBufferSize = Math.max(16, Math.ceil(uniformData.byteLength / 16) * 16);
43
+ if (state.resources && (state.resources.device !== device || state.resources.shader !== shader || state.resources.uniformBufferSize !== uniformBufferSize || state.resources.sourceFilter !== sourceFilter || (state.resources.auxiliary?.width ?? null) !== (auxiliaryTexture?.width ?? null) || (state.resources.auxiliary?.height ?? null) !== (auxiliaryTexture?.height ?? null) || (state.resources.auxiliary?.format ?? null) !== (auxiliaryTexture?.format ?? null))) {
44
+ cleanupWebGpuSinglePass(state);
45
+ }
46
+ if (!state.resources) {
47
+ const format = navigator.gpu.getPreferredCanvasFormat();
48
+ state.context.configure({ device, format, alphaMode: "premultiplied" });
49
+ const module = device.createShaderModule({
50
+ code: shader,
51
+ label: state.label
52
+ });
53
+ const bindGroupLayout = device.createBindGroupLayout({
54
+ entries: [
55
+ ...auxiliaryTexture ? [
56
+ {
57
+ binding: 3,
58
+ visibility: GPUShaderStage.FRAGMENT,
59
+ texture: {
60
+ sampleType: auxiliaryTexture.format === "rgba32float" ? "unfilterable-float" : "float"
61
+ }
62
+ }
63
+ ] : [],
64
+ { binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: {} },
65
+ { binding: 1, visibility: GPUShaderStage.FRAGMENT, sampler: {} },
66
+ {
67
+ binding: 2,
68
+ visibility: GPUShaderStage.FRAGMENT,
69
+ buffer: { type: "uniform" }
70
+ }
71
+ ]
72
+ });
73
+ const pipeline = device.createRenderPipeline({
74
+ label: state.label,
75
+ layout: device.createPipelineLayout({
76
+ bindGroupLayouts: [bindGroupLayout]
77
+ }),
78
+ vertex: { module, entryPoint: "vertex" },
79
+ fragment: { module, entryPoint: "fragment", targets: [{ format }] },
80
+ primitive: { topology: "triangle-list" }
81
+ });
82
+ const uniforms = device.createBuffer({
83
+ size: uniformBufferSize,
84
+ usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
85
+ });
86
+ const sampler = device.createSampler({
87
+ addressModeU: "clamp-to-edge",
88
+ addressModeV: "clamp-to-edge",
89
+ magFilter: sourceFilter,
90
+ minFilter: sourceFilter
91
+ });
92
+ const auxiliary = auxiliaryTexture ? {
93
+ texture: device.createTexture({
94
+ size: [auxiliaryTexture.width, auxiliaryTexture.height],
95
+ format: auxiliaryTexture.format,
96
+ usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
97
+ }),
98
+ width: auxiliaryTexture.width,
99
+ height: auxiliaryTexture.height,
100
+ format: auxiliaryTexture.format,
101
+ uploadedData: null
102
+ } : null;
103
+ state.resources = {
104
+ device,
105
+ shader,
106
+ uniformBufferSize,
107
+ sourceFilter,
108
+ auxiliary,
109
+ pipeline,
110
+ uniforms,
111
+ sampler,
112
+ bindGroupLayout,
113
+ source: null
114
+ };
115
+ }
116
+ const { resources } = state;
117
+ if (resources.source && (resources.source.width !== width || resources.source.height !== height)) {
118
+ resources.source.texture.destroy();
119
+ resources.source = null;
120
+ }
121
+ if (!resources.source) {
122
+ const texture = device.createTexture({
123
+ size: [width, height],
124
+ format: "rgba8unorm",
125
+ usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT
126
+ });
127
+ const bindGroup = device.createBindGroup({
128
+ layout: resources.bindGroupLayout,
129
+ entries: [
130
+ ...resources.auxiliary ? [{ binding: 3, resource: resources.auxiliary.texture.createView() }] : [],
131
+ { binding: 0, resource: texture.createView() },
132
+ { binding: 1, resource: resources.sampler },
133
+ { binding: 2, resource: { buffer: resources.uniforms } }
134
+ ]
135
+ });
136
+ resources.source = { texture, bindGroup, width, height };
137
+ }
138
+ if (auxiliaryTexture && resources.auxiliary && resources.auxiliary.uploadedData !== auxiliaryTexture.data) {
139
+ device.queue.writeTexture({ texture: resources.auxiliary.texture }, auxiliaryTexture.data, {
140
+ bytesPerRow: auxiliaryTexture.width * 4 * auxiliaryTexture.data.BYTES_PER_ELEMENT
141
+ }, [auxiliaryTexture.width, auxiliaryTexture.height]);
142
+ resources.auxiliary.uploadedData = auxiliaryTexture.data;
143
+ }
144
+ device.queue.copyExternalImageToTexture({ source }, { texture: resources.source.texture, premultipliedAlpha: true }, [width, height]);
145
+ device.queue.writeBuffer(resources.uniforms, 0, uniformData);
146
+ const encoder = device.createCommandEncoder();
147
+ const pass = encoder.beginRenderPass({
148
+ colorAttachments: [
149
+ {
150
+ view: state.context.getCurrentTexture().createView(),
151
+ clearValue: { r: 0, g: 0, b: 0, a: 0 },
152
+ loadOp: "clear",
153
+ storeOp: "store"
154
+ }
155
+ ]
156
+ });
157
+ pass.setPipeline(resources.pipeline);
158
+ pass.setBindGroup(0, resources.source.bindGroup);
159
+ pass.draw(3);
160
+ pass.end();
161
+ device.queue.submit([encoder.finish()]);
162
+ };
163
+
164
+ export { WEBGPU_SINGLE_PASS_VERTEX, setupWebGpuSinglePass, cleanupWebGpuSinglePass, applyWebGpuSinglePass };
@@ -0,0 +1,215 @@
1
+ // src/webgl-projection-runtime.ts
2
+ import { Internals } from "remotion";
3
+ var setupWebGlProjection = (target, shader) => {
4
+ const gl = target.getContext("webgl2");
5
+ if (!gl)
6
+ throw Internals.createWebGL2ContextError("projection effect");
7
+ const program = gl.createProgram();
8
+ const shaders = [];
9
+ try {
10
+ for (const [type, code] of [
11
+ [
12
+ gl.VERTEX_SHADER,
13
+ `#version 300 es
14
+ void main() {
15
+ vec2 positions[3] = vec2[3](vec2(-1, -1), vec2(3, -1), vec2(-1, 3));
16
+ gl_Position = vec4(positions[gl_VertexID], 0, 1);
17
+ }`
18
+ ],
19
+ [gl.FRAGMENT_SHADER, shader]
20
+ ]) {
21
+ const compiled = gl.createShader(type);
22
+ shaders.push(compiled);
23
+ gl.shaderSource(compiled, code);
24
+ gl.compileShader(compiled);
25
+ if (!gl.getShaderParameter(compiled, gl.COMPILE_STATUS))
26
+ throw new Error(gl.getShaderInfoLog(compiled) ?? "Projection shader compilation failed");
27
+ gl.attachShader(program, compiled);
28
+ }
29
+ gl.linkProgram(program);
30
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS))
31
+ throw new Error(gl.getProgramInfoLog(program) ?? "Projection program linking failed");
32
+ } catch (err) {
33
+ gl.deleteProgram(program);
34
+ throw err;
35
+ } finally {
36
+ for (const compiled of shaders)
37
+ gl.deleteShader(compiled);
38
+ }
39
+ const texture = gl.createTexture();
40
+ gl.bindTexture(gl.TEXTURE_2D, texture);
41
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
42
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
43
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
44
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
45
+ return {
46
+ gl,
47
+ program,
48
+ texture,
49
+ vao: gl.createVertexArray(),
50
+ uniforms: gl.getUniformLocation(program, "uParams"),
51
+ source: gl.getUniformLocation(program, "uSource")
52
+ };
53
+ };
54
+ var applyWebGlProjection = ({
55
+ state,
56
+ source,
57
+ width,
58
+ height,
59
+ flipSourceY,
60
+ uniformData
61
+ }) => {
62
+ const { gl } = state;
63
+ gl.viewport(0, 0, width, height);
64
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
65
+ gl.disable(gl.BLEND);
66
+ gl.disable(gl.DEPTH_TEST);
67
+ gl.disable(gl.SCISSOR_TEST);
68
+ gl.useProgram(state.program);
69
+ gl.bindVertexArray(state.vao);
70
+ gl.activeTexture(gl.TEXTURE0);
71
+ gl.bindTexture(gl.TEXTURE_2D, state.texture);
72
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
73
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipSourceY);
74
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
75
+ gl.uniform1i(state.source, 0);
76
+ gl.uniform4fv(state.uniforms, uniformData);
77
+ gl.drawArrays(gl.TRIANGLES, 0, 3);
78
+ };
79
+ var cleanupWebGlProjection = ({
80
+ gl,
81
+ program,
82
+ texture,
83
+ vao
84
+ }) => {
85
+ gl.deleteTexture(texture);
86
+ gl.deleteProgram(program);
87
+ gl.deleteVertexArray(vao);
88
+ };
89
+
90
+ // src/webgpu-projection-runtime.ts
91
+ var deviceResources = new WeakMap;
92
+ var lostDevices = new WeakSet;
93
+ var cleanupWebGpuProjection = (state) => {
94
+ state.resources?.source?.texture.destroy();
95
+ state.resources?.uniforms.destroy();
96
+ state.resources = null;
97
+ state.context.unconfigure();
98
+ };
99
+ var setupWebGpuProjection = (target, label) => {
100
+ const context = target.getContext("webgpu");
101
+ if (!context) {
102
+ throw new Error(`WebGPU is not available for the ${label} effect`);
103
+ }
104
+ return { context, resources: null };
105
+ };
106
+ var applyWebGpuProjection = ({
107
+ state,
108
+ source,
109
+ device,
110
+ shader,
111
+ uniformData
112
+ }) => {
113
+ if (lostDevices.has(device)) {
114
+ throw new Error("Cannot apply a WebGPU projection with a lost device");
115
+ }
116
+ const width = "displayWidth" in source ? source.displayWidth : ("videoWidth" in source) ? source.videoWidth : ("naturalWidth" in source) ? source.naturalWidth : typeof source.width === "number" ? source.width : source.width.baseVal.value;
117
+ const height = "displayHeight" in source ? source.displayHeight : ("videoHeight" in source) ? source.videoHeight : ("naturalHeight" in source) ? source.naturalHeight : typeof source.height === "number" ? source.height : source.height.baseVal.value;
118
+ const format = navigator.gpu.getPreferredCanvasFormat();
119
+ if (state.resources && (state.resources.device !== device || state.resources.shader !== shader || state.resources.format !== format || state.resources.uniforms.size !== uniformData.byteLength)) {
120
+ cleanupWebGpuProjection(state);
121
+ }
122
+ if (!state.resources) {
123
+ let shared = deviceResources.get(device);
124
+ if (!shared) {
125
+ const pipelines = new Map;
126
+ shared = {
127
+ pipelines,
128
+ sampler: device.createSampler({
129
+ addressModeU: "repeat",
130
+ magFilter: "linear",
131
+ minFilter: "linear"
132
+ })
133
+ };
134
+ deviceResources.set(device, shared);
135
+ device.lost.then(() => {
136
+ lostDevices.add(device);
137
+ pipelines.clear();
138
+ deviceResources.delete(device);
139
+ });
140
+ }
141
+ let pipelinesByFormat = shared.pipelines.get(shader);
142
+ if (!pipelinesByFormat) {
143
+ pipelinesByFormat = new Map;
144
+ shared.pipelines.set(shader, pipelinesByFormat);
145
+ }
146
+ let pipeline = pipelinesByFormat.get(format);
147
+ if (!pipeline) {
148
+ const module = device.createShaderModule({ code: shader });
149
+ pipeline = device.createRenderPipeline({
150
+ layout: "auto",
151
+ vertex: { module, entryPoint: "vertex" },
152
+ fragment: { module, entryPoint: "fragment", targets: [{ format }] },
153
+ primitive: { topology: "triangle-list" }
154
+ });
155
+ pipelinesByFormat.set(format, pipeline);
156
+ }
157
+ state.context.configure({ device, format, alphaMode: "premultiplied" });
158
+ const uniforms = device.createBuffer({
159
+ size: uniformData.byteLength,
160
+ usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
161
+ });
162
+ state.resources = {
163
+ device,
164
+ shader,
165
+ format,
166
+ pipeline,
167
+ uniforms,
168
+ sampler: shared.sampler,
169
+ source: null
170
+ };
171
+ }
172
+ const { resources } = state;
173
+ if (!resources.source || resources.source.width !== width || resources.source.height !== height) {
174
+ const texture = device.createTexture({
175
+ size: [width, height],
176
+ format: "rgba8unorm",
177
+ usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT
178
+ });
179
+ try {
180
+ const bindGroup = device.createBindGroup({
181
+ layout: resources.pipeline.getBindGroupLayout(0),
182
+ entries: [
183
+ { binding: 0, resource: texture.createView() },
184
+ { binding: 1, resource: resources.sampler },
185
+ { binding: 2, resource: { buffer: resources.uniforms } }
186
+ ]
187
+ });
188
+ resources.source?.texture.destroy();
189
+ resources.source = { texture, bindGroup, width, height };
190
+ } catch (err) {
191
+ texture.destroy();
192
+ throw err;
193
+ }
194
+ }
195
+ device.queue.copyExternalImageToTexture({ source }, { texture: resources.source.texture, premultipliedAlpha: true }, [width, height]);
196
+ device.queue.writeBuffer(resources.uniforms, 0, uniformData);
197
+ const encoder = device.createCommandEncoder();
198
+ const pass = encoder.beginRenderPass({
199
+ colorAttachments: [
200
+ {
201
+ view: state.context.getCurrentTexture().createView(),
202
+ clearValue: { r: 0, g: 0, b: 0, a: 0 },
203
+ loadOp: "clear",
204
+ storeOp: "store"
205
+ }
206
+ ]
207
+ });
208
+ pass.setPipeline(resources.pipeline);
209
+ pass.setBindGroup(0, resources.source.bindGroup);
210
+ pass.draw(3);
211
+ pass.end();
212
+ device.queue.submit([encoder.finish()]);
213
+ };
214
+
215
+ export { setupWebGlProjection, applyWebGlProjection, cleanupWebGlProjection, cleanupWebGpuProjection, setupWebGpuProjection, applyWebGpuProjection };
@@ -0,0 +1,79 @@
1
+ import {
2
+ assertRequiredFiniteNumber
3
+ } from "./index-4fvp93ps.mjs";
4
+
5
+ // src/color-utils.ts
6
+ var DEFAULT_AMOUNT = 1;
7
+ var DEFAULT_BRIGHTNESS_AMOUNT = 0;
8
+ var DEFAULT_HUE_DEGREES = 0;
9
+ var colorAmountSchema = {
10
+ type: "number",
11
+ min: 0,
12
+ max: 1,
13
+ step: 0.01,
14
+ default: DEFAULT_AMOUNT,
15
+ description: "Amount",
16
+ hiddenFromList: false
17
+ };
18
+ var colorMultiplierSchema = {
19
+ type: "number",
20
+ min: 0,
21
+ step: 0.01,
22
+ default: DEFAULT_AMOUNT,
23
+ description: "Amount",
24
+ hiddenFromList: false
25
+ };
26
+ var brightnessAmountSchema = {
27
+ type: "number",
28
+ min: -1,
29
+ max: 1,
30
+ step: 0.01,
31
+ default: DEFAULT_BRIGHTNESS_AMOUNT,
32
+ description: "Amount",
33
+ hiddenFromList: false
34
+ };
35
+ var hueDegreesSchema = {
36
+ type: "rotation-degrees",
37
+ step: 1,
38
+ default: DEFAULT_HUE_DEGREES,
39
+ description: "Degrees"
40
+ };
41
+ var assertOptionalFiniteNumber = (value, name) => {
42
+ if (value === undefined) {
43
+ return;
44
+ }
45
+ assertRequiredFiniteNumber(value, name);
46
+ };
47
+ var validateUnitInterval = (value, name) => {
48
+ if (value < 0) {
49
+ throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
50
+ }
51
+ if (value > 1) {
52
+ throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
53
+ }
54
+ };
55
+ var validateNonNegative = (value, name) => {
56
+ if (value < 0) {
57
+ throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
58
+ }
59
+ };
60
+ var validateSignedUnitInterval = (value, name) => {
61
+ if (value < -1) {
62
+ throw new TypeError(`"${name}" must be >= -1, but got ${JSON.stringify(value)}`);
63
+ }
64
+ if (value > 1) {
65
+ throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
66
+ }
67
+ };
68
+ var clampColorChannel = (value) => {
69
+ return Math.max(0, Math.min(255, value));
70
+ };
71
+ var parseColorRgba = (ctx, color) => {
72
+ ctx.clearRect(0, 0, 1, 1);
73
+ ctx.fillStyle = color;
74
+ ctx.fillRect(0, 0, 1, 1);
75
+ const { data } = ctx.getImageData(0, 0, 1, 1);
76
+ return [data[0], data[1], data[2], data[3]];
77
+ };
78
+
79
+ export { DEFAULT_AMOUNT, DEFAULT_BRIGHTNESS_AMOUNT, DEFAULT_HUE_DEGREES, colorAmountSchema, colorMultiplierSchema, brightnessAmountSchema, hueDegreesSchema, assertOptionalFiniteNumber, validateUnitInterval, validateNonNegative, validateSignedUnitInterval, clampColorChannel, parseColorRgba };