@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
@@ -1,201 +1,22 @@
1
+ import {
2
+ setupWebGlProjection,
3
+ applyWebGlProjection,
4
+ cleanupWebGlProjection,
5
+ cleanupWebGpuProjection,
6
+ setupWebGpuProjection,
7
+ applyWebGpuProjection
8
+ } from "./index-vp56k1gj.mjs";
9
+ import {
10
+ assertOptionalFiniteNumber,
11
+ validateUnitInterval
12
+ } from "./index-wxhvgv2s.mjs";
13
+ import {
14
+ assertEffectParamsObject
15
+ } from "./index-4fvp93ps.mjs";
16
+
1
17
  // src/sphere/index.ts
2
18
  import { Internals } from "remotion";
3
19
 
4
- // src/validate-effect-param.ts
5
- var assertEffectParamsObject = (params, effectLabel) => {
6
- if (params === null || typeof params !== "object") {
7
- throw new TypeError(`${effectLabel} effect requires a parameters object, but got ${JSON.stringify(params)}`);
8
- }
9
- };
10
- var assertRequiredFiniteNumber = (value, name) => {
11
- if (typeof value !== "number" || !Number.isFinite(value)) {
12
- throw new TypeError(`"${name}" must be a finite number, but got ${JSON.stringify(value)}`);
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
- };
108
-
109
- // src/webgpu-projection-runtime.ts
110
- var cleanupWebGpuProjection = (state) => {
111
- state.resources?.texture.destroy();
112
- state.resources?.uniforms.destroy();
113
- state.resources = null;
114
- state.context.unconfigure();
115
- };
116
- var setupWebGpuProjection = (target, label) => {
117
- const context = target.getContext("webgpu");
118
- if (!context) {
119
- throw new Error(`WebGPU is not available for the ${label} effect`);
120
- }
121
- return { context, resources: null };
122
- };
123
- var applyWebGpuProjection = ({
124
- state,
125
- source,
126
- width,
127
- height,
128
- device,
129
- shader,
130
- uniformData
131
- }) => {
132
- if (state.resources && (state.resources.device !== device || state.resources.width !== width || state.resources.height !== height)) {
133
- cleanupWebGpuProjection(state);
134
- }
135
- if (!state.resources) {
136
- const format = navigator.gpu.getPreferredCanvasFormat();
137
- state.context.configure({ device, format, alphaMode: "premultiplied" });
138
- const module = device.createShaderModule({ code: shader });
139
- const pipeline = device.createRenderPipeline({
140
- layout: "auto",
141
- vertex: { module, entryPoint: "vertex" },
142
- fragment: { module, entryPoint: "fragment", targets: [{ format }] },
143
- primitive: { topology: "triangle-list" }
144
- });
145
- const uniforms = device.createBuffer({
146
- size: uniformData.byteLength,
147
- usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
148
- });
149
- const sampler = device.createSampler({
150
- addressModeU: "repeat",
151
- magFilter: "linear",
152
- minFilter: "linear"
153
- });
154
- const texture = device.createTexture({
155
- size: [width, height],
156
- format: "rgba8unorm",
157
- usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT
158
- });
159
- const bindGroup = device.createBindGroup({
160
- layout: pipeline.getBindGroupLayout(0),
161
- entries: [
162
- { binding: 0, resource: texture.createView() },
163
- { binding: 1, resource: sampler },
164
- { binding: 2, resource: { buffer: uniforms } }
165
- ]
166
- });
167
- state.resources = {
168
- device,
169
- pipeline,
170
- uniforms,
171
- sampler,
172
- texture,
173
- bindGroup,
174
- width,
175
- height
176
- };
177
- }
178
- const { resources } = state;
179
- device.queue.copyExternalImageToTexture({ source }, { texture: resources.texture, premultipliedAlpha: true }, [width, height]);
180
- device.queue.writeBuffer(resources.uniforms, 0, uniformData);
181
- const encoder = device.createCommandEncoder();
182
- const pass = encoder.beginRenderPass({
183
- colorAttachments: [
184
- {
185
- view: state.context.getCurrentTexture().createView(),
186
- clearValue: { r: 0, g: 0, b: 0, a: 0 },
187
- loadOp: "clear",
188
- storeOp: "store"
189
- }
190
- ]
191
- });
192
- pass.setPipeline(resources.pipeline);
193
- pass.setBindGroup(0, resources.bindGroup);
194
- pass.draw(3);
195
- pass.end();
196
- device.queue.submit([encoder.finish()]);
197
- };
198
-
199
20
  // src/sphere/shader.ts
200
21
  var SPHERE_SHADER = `
201
22
  struct Params {
@@ -245,6 +66,43 @@ fn sampleFace(normal: vec3f, inverse: mat3x3f) -> vec4f {
245
66
  }
246
67
  `;
247
68
 
69
+ // src/sphere/webgl-shader.ts
70
+ var SPHERE_WEBGL_SHADER = `#version 300 es
71
+ precision highp float;
72
+ uniform sampler2D uSource;
73
+ uniform vec4 uParams[3];
74
+ out vec4 fragColor;
75
+ vec4 sampleFace(vec3 normal, mat3 inverseRotation) {
76
+ vec3 local = inverseRotation * normal;
77
+ // Longitude wraps at the seam; latitude spans the complete image height.
78
+ vec2 uv = vec2(fract(atan(local.x, local.z) / 6.28318530718 + 0.5), asin(clamp(local.y, -1.0, 1.0)) / 3.14159265359 + 0.5);
79
+ vec4 color = textureLod(uSource, vec2(uv.x, 1.0 - uv.y), 0.0);
80
+ float shade = mix(1.0, abs(normal.z), uParams[1].z);
81
+ return vec4(color.rgb * shade, color.a);
82
+ }
83
+
84
+ vec4 project(vec2 position) {
85
+ vec2 p = (position - uParams[0].zw) / uParams[1].x;
86
+ float distanceSquared = dot(p, p);
87
+ float coverage = 1.0 - smoothstep(1.0 - fwidth(distanceSquared), 1.0, distanceSquared);
88
+ if (distanceSquared >= 1.0) { return vec4(0); }
89
+ float z = sqrt(1.0 - distanceSquared);
90
+ vec3 s = sin(uParams[2].xyz);
91
+ vec3 c = cos(uParams[2].xyz);
92
+ mat3 rx = mat3(vec3(1, 0, 0), vec3(0, c.x, s.x), vec3(0, -s.x, c.x));
93
+ mat3 ry = mat3(vec3(c.y, 0, -s.y), vec3(0, 1, 0), vec3(s.y, 0, c.y));
94
+ mat3 rz = mat3(vec3(c.z, s.z, 0), vec3(-s.z, c.z, 0), vec3(0, 0, 1));
95
+ mat3 inverseRotation = transpose(rz * ry * rx);
96
+ vec4 front = sampleFace(vec3(p, z), inverseRotation);
97
+ vec4 back = sampleFace(vec3(p, -z), inverseRotation);
98
+ if (uParams[1].w == 1.0) { return front * coverage; }
99
+ if (uParams[1].w == 2.0) { return back * coverage; }
100
+ return (front + back * (1.0 - front.a)) * coverage;
101
+ }
102
+
103
+ void main() { fragColor = project(vec2(gl_FragCoord.x, uParams[0].y - gl_FragCoord.y)); }
104
+ `;
105
+
248
106
  // src/sphere/index.ts
249
107
  var DEFAULT_RADIUS = 250;
250
108
  var DEFAULT_ROTATION = 0;
@@ -306,11 +164,28 @@ var resolve = (params) => ({
306
164
  render: params.render ?? DEFAULT_RENDER,
307
165
  shading: params.shading ?? DEFAULT_SHADING
308
166
  });
167
+ var getUniformData = (params, width, height) => {
168
+ const r = resolve(params);
169
+ const radians = Math.PI / 180;
170
+ return new Float32Array([
171
+ width,
172
+ height,
173
+ r.position[0] * width,
174
+ r.position[1] * height,
175
+ r.radius,
176
+ 0,
177
+ r.shading,
178
+ r.render === "front" ? 1 : r.render === "back" ? 2 : 0,
179
+ r.rotationX % 360 * radians,
180
+ r.rotationY % 360 * radians,
181
+ r.rotationZ % 360 * radians,
182
+ 0
183
+ ]);
184
+ };
309
185
  var sphere = Internals.createEffect({
310
186
  type: "remotion/sphere",
311
187
  label: "sphere()",
312
188
  documentationLink: "https://www.remotion.dev/docs/effects/sphere",
313
- backend: "webgpu",
314
189
  schema: sphereSchema,
315
190
  validateParams: (params) => {
316
191
  assertEffectParamsObject(params, "Sphere");
@@ -339,37 +214,38 @@ var sphere = Internals.createEffect({
339
214
  const r = resolve(params);
340
215
  return `sphere-${r.radius}-${r.rotationX}-${r.rotationY}-${r.rotationZ}-${r.position.join(",")}-${r.render}-${r.shading}`;
341
216
  },
342
- setup: (target) => setupWebGpuProjection(target, "sphere"),
343
- apply: ({ source, width, height, params, state, gpuDevice }) => {
344
- if (!gpuDevice) {
345
- throw new Error("A WebGPU device is required for the sphere effect");
346
- }
347
- const r = resolve(params);
348
- const radians = Math.PI / 180;
349
- applyWebGpuProjection({
350
- source,
351
- width,
352
- height,
353
- state,
354
- device: gpuDevice,
355
- shader: SPHERE_SHADER,
356
- uniformData: new Float32Array([
217
+ implementations: {
218
+ webgpu: Internals.createEffectImplementation({
219
+ setup: (target) => setupWebGpuProjection(target, "sphere"),
220
+ apply: ({ source, width, height, params, state, gpuDevice }) => {
221
+ if (!gpuDevice) {
222
+ throw new Error("A WebGPU device is required for the sphere effect");
223
+ }
224
+ applyWebGpuProjection({
225
+ source,
226
+ width,
227
+ height,
228
+ state,
229
+ device: gpuDevice,
230
+ shader: SPHERE_SHADER,
231
+ uniformData: getUniformData(params, width, height)
232
+ });
233
+ },
234
+ cleanup: cleanupWebGpuProjection
235
+ }),
236
+ webgl2: Internals.createEffectImplementation({
237
+ setup: (target) => setupWebGlProjection(target, SPHERE_WEBGL_SHADER),
238
+ apply: ({ source, width, height, params, state, flipSourceY }) => applyWebGlProjection({
239
+ source,
357
240
  width,
358
241
  height,
359
- r.position[0] * width,
360
- r.position[1] * height,
361
- r.radius,
362
- 0,
363
- r.shading,
364
- r.render === "front" ? 1 : r.render === "back" ? 2 : 0,
365
- r.rotationX % 360 * radians,
366
- r.rotationY % 360 * radians,
367
- r.rotationZ % 360 * radians,
368
- 0
369
- ])
370
- });
371
- },
372
- cleanup: cleanupWebGpuProjection
242
+ state,
243
+ flipSourceY,
244
+ uniformData: getUniformData(params, width, height)
245
+ }),
246
+ cleanup: cleanupWebGlProjection
247
+ })
248
+ }
373
249
  });
374
250
  export {
375
251
  sphere
@@ -1,347 +1,8 @@
1
- // src/starburst.ts
2
- import { Internals } from "remotion";
3
- import { NoReactInternals } from "remotion/no-react";
4
- var { createEffect, createWebGL2ContextError } = Internals;
5
- var colorToRgb = (color) => {
6
- const packed = NoReactInternals.processColor(color);
7
- return [packed >>> 16 & 255, packed >>> 8 & 255, packed & 255];
8
- };
9
- var DEFAULT_ORIGIN = [0.5, 0.5];
10
- var starburstEffectSchema = {
11
- rays: {
12
- type: "number",
13
- min: 2,
14
- max: 100,
15
- step: 1,
16
- default: undefined,
17
- description: "Number of Rays",
18
- hiddenFromList: false
19
- },
20
- colors: {
21
- type: "array",
22
- item: {
23
- type: "color"
24
- },
25
- default: undefined,
26
- minLength: 2,
27
- newItemDefault: "#ff0000",
28
- description: "Colors",
29
- keyframable: false
30
- },
31
- rotation: {
32
- type: "number",
33
- min: 0,
34
- max: 360,
35
- step: 1,
36
- default: 0,
37
- description: "Rotation",
38
- hiddenFromList: false
39
- },
40
- smoothness: {
41
- type: "number",
42
- min: 0,
43
- max: 1,
44
- step: 0.01,
45
- default: 0,
46
- description: "Edge Smoothness",
47
- hiddenFromList: false
48
- },
49
- origin: {
50
- type: "uv-coordinate",
51
- min: 0,
52
- max: 1,
53
- step: 0.01,
54
- default: DEFAULT_ORIGIN,
55
- description: "Origin"
56
- }
57
- };
58
- var resolve = (p) => ({
59
- rays: p.rays,
60
- colors: p.colors,
61
- rotation: p.rotation ?? 0,
62
- smoothness: p.smoothness ?? 0,
63
- origin: p.origin ?? DEFAULT_ORIGIN
64
- });
65
- var validateStarburstEffectParams = (params) => {
66
- if (params === null || typeof params !== "object") {
67
- throw new TypeError(`Starburst effect requires a parameters object, but got ${JSON.stringify(params)}`);
68
- }
69
- const { rays, colors } = params;
70
- if (typeof rays !== "number" || !Number.isFinite(rays)) {
71
- throw new TypeError(`"rays" must be a finite number, but got ${JSON.stringify(rays)}`);
72
- }
73
- if (rays < 2 || rays > 100) {
74
- throw new RangeError(`"rays" must be between 2 and 100, but got ${rays}`);
75
- }
76
- if (!Array.isArray(colors) || colors.length < 2) {
77
- throw new TypeError(`"colors" must be an array with at least 2 colors, but got ${JSON.stringify(colors)}`);
78
- }
79
- const r = resolve(params);
80
- if (typeof r.rotation !== "number" || !Number.isFinite(r.rotation)) {
81
- throw new TypeError(`"rotation" must be a finite number, but got ${JSON.stringify(params.rotation)}`);
82
- }
83
- if (typeof r.smoothness !== "number" || !Number.isFinite(r.smoothness)) {
84
- throw new TypeError(`"smoothness" must be a finite number, but got ${JSON.stringify(params.smoothness)}`);
85
- }
86
- if (r.smoothness < 0 || r.smoothness > 1) {
87
- throw new RangeError(`"smoothness" must be between 0 and 1, but got ${r.smoothness}`);
88
- }
89
- if (!Array.isArray(r.origin) || r.origin.length !== 2 || r.origin.some((coordinate) => {
90
- return typeof coordinate !== "number" || !Number.isFinite(coordinate);
91
- })) {
92
- throw new TypeError('"origin" must be a [number, number] tuple');
93
- }
94
- if (r.origin.some((coordinate) => coordinate < 0 || coordinate > 1)) {
95
- throw new RangeError(`"origin" must contain coordinates between 0 and 1, but got ${JSON.stringify(r.origin)}`);
96
- }
97
- for (const c of r.colors) {
98
- colorToRgb(c);
99
- }
100
- };
101
- var STARBURST_VS = `#version 300 es
102
- in vec2 aPos;
103
- in vec2 aUv;
104
- out vec2 vUv;
105
- void main() {
106
- vUv = aUv;
107
- gl_Position = vec4(aPos, 0.0, 1.0);
108
- }
109
- `;
110
- var STARBURST_FS = `#version 300 es
111
- precision highp float;
112
-
113
- uniform sampler2D colorPalette;
114
- uniform float numRays;
115
- uniform float rotationOffset;
116
- uniform float smoothEdge;
117
- uniform vec2 resolution;
118
- uniform float numColors;
119
- uniform vec2 origin;
120
-
121
- in vec2 vUv;
122
- out vec4 fragColor;
123
-
124
- const float Pi = 3.14159265359;
125
-
126
- void main() {
127
- vec2 uv = vUv;
128
- vec2 center = uv - origin;
129
- center.x *= resolution.x / resolution.y;
130
-
131
- float angle = atan(center.y, center.x) + rotationOffset;
132
- float normalizedAngle = (angle + Pi) / (2.0 * Pi);
133
- float sector = normalizedAngle * numRays;
134
- float rayIndex = mod(floor(sector), numRays);
135
-
136
- float colorIndex = mod(rayIndex, numColors);
137
- float texCoord = (colorIndex + 0.5) / numColors;
138
- vec3 col = texture(colorPalette, vec2(texCoord, 0.5)).rgb;
139
-
140
- float fractSector = fract(sector);
141
- float edgeSmooth = smoothEdge * 0.5;
142
- float nextColorIndex = mod(rayIndex + 1.0, numColors);
143
- float nextTexCoord = (nextColorIndex + 0.5) / numColors;
144
- vec3 nextCol = texture(colorPalette, vec2(nextTexCoord, 0.5)).rgb;
145
-
146
- float blend = smoothstep(1.0 - edgeSmooth, 1.0, fractSector);
147
- col = mix(col, nextCol, blend);
148
- float blendStart = smoothstep(edgeSmooth, 0.0, fractSector);
149
- float prevColorIndex = mod(rayIndex - 1.0 + numColors, numColors);
150
- float prevTexCoord = (prevColorIndex + 0.5) / numColors;
151
- vec3 prevCol = texture(colorPalette, vec2(prevTexCoord, 0.5)).rgb;
152
- col = mix(col, prevCol, blendStart);
153
-
154
- fragColor = vec4(col, 1.0);
155
- }
156
- `;
157
- var compileShader = (gl, type, source) => {
158
- const shader = gl.createShader(type);
159
- if (!shader) {
160
- throw new Error("Failed to create WebGL shader");
161
- }
162
- gl.shaderSource(shader, source);
163
- gl.compileShader(shader);
164
- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
165
- const log = gl.getShaderInfoLog(shader);
166
- gl.deleteShader(shader);
167
- throw new Error(`Starburst shader compile failed: ${log ?? "(no log)"}`);
168
- }
169
- return shader;
170
- };
171
- var linkProgram = (gl, vs, fs) => {
172
- const program = gl.createProgram();
173
- if (!program) {
174
- throw new Error("Failed to create WebGL program");
175
- }
176
- gl.attachShader(program, vs);
177
- gl.attachShader(program, fs);
178
- gl.linkProgram(program);
179
- if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
180
- const log = gl.getProgramInfoLog(program);
181
- gl.deleteProgram(program);
182
- throw new Error(`Starburst program link failed: ${log ?? "(no log)"}`);
183
- }
184
- return program;
185
- };
186
- var starburst = createEffect({
187
- type: "remotion/starburst",
188
- label: "starburst()",
189
- documentationLink: "https://www.remotion.dev/docs/effects/starburst",
190
- backend: "webgl2",
191
- calculateKey: (params) => {
192
- const r = resolve(params);
193
- return `starburst-${r.rays}-${r.colors.join("|")}-${r.rotation}-${r.smoothness}-${r.origin.join(":")}`;
194
- },
195
- setup: (target) => {
196
- const gl = target.getContext("webgl2", {
197
- premultipliedAlpha: true,
198
- alpha: true,
199
- preserveDrawingBuffer: true
200
- });
201
- if (!gl) {
202
- throw createWebGL2ContextError("starburst effect");
203
- }
204
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
205
- const vs = compileShader(gl, gl.VERTEX_SHADER, STARBURST_VS);
206
- const fs = compileShader(gl, gl.FRAGMENT_SHADER, STARBURST_FS);
207
- const program = linkProgram(gl, vs, fs);
208
- gl.deleteShader(vs);
209
- gl.deleteShader(fs);
210
- const vao = gl.createVertexArray();
211
- if (!vao) {
212
- throw new Error("Failed to create WebGL vertex array");
213
- }
214
- gl.bindVertexArray(vao);
215
- const data = new Float32Array([
216
- -1,
217
- -1,
218
- 0,
219
- 0,
220
- 1,
221
- -1,
222
- 1,
223
- 0,
224
- -1,
225
- 1,
226
- 0,
227
- 1,
228
- 1,
229
- 1,
230
- 1,
231
- 1
232
- ]);
233
- const vbo = gl.createBuffer();
234
- if (!vbo) {
235
- throw new Error("Failed to create WebGL buffer");
236
- }
237
- gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
238
- gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
239
- const aPos = gl.getAttribLocation(program, "aPos");
240
- const aUv = gl.getAttribLocation(program, "aUv");
241
- gl.enableVertexAttribArray(aPos);
242
- gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);
243
- gl.enableVertexAttribArray(aUv);
244
- gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);
245
- gl.bindVertexArray(null);
246
- const paletteTexture = gl.createTexture();
247
- if (!paletteTexture) {
248
- throw new Error("Failed to create WebGL palette texture");
249
- }
250
- gl.bindTexture(gl.TEXTURE_2D, paletteTexture);
251
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
252
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
253
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
254
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
255
- gl.bindTexture(gl.TEXTURE_2D, null);
256
- return {
257
- gl,
258
- program,
259
- vao,
260
- vbo,
261
- paletteTexture,
262
- uColorPalette: gl.getUniformLocation(program, "colorPalette"),
263
- uNumRays: gl.getUniformLocation(program, "numRays"),
264
- uRotationOffset: gl.getUniformLocation(program, "rotationOffset"),
265
- uSmoothEdge: gl.getUniformLocation(program, "smoothEdge"),
266
- uResolution: gl.getUniformLocation(program, "resolution"),
267
- uNumColors: gl.getUniformLocation(program, "numColors"),
268
- uOrigin: gl.getUniformLocation(program, "origin"),
269
- cachedPaletteKey: "",
270
- palettePixelData: new Uint8Array(0)
271
- };
272
- },
273
- apply: ({ width, height, params, state }) => {
274
- const r = resolve(params);
275
- const {
276
- gl,
277
- program,
278
- vao,
279
- paletteTexture,
280
- uColorPalette,
281
- uNumRays,
282
- uRotationOffset,
283
- uSmoothEdge,
284
- uResolution,
285
- uNumColors,
286
- uOrigin
287
- } = state;
288
- const rotationRad = r.rotation * Math.PI / 180;
289
- const paletteKey = r.colors.join("|");
290
- const paletteDirty = state.cachedPaletteKey !== paletteKey;
291
- if (paletteDirty) {
292
- state.cachedPaletteKey = paletteKey;
293
- const len = r.colors.length * 4;
294
- if (state.palettePixelData.length !== len) {
295
- state.palettePixelData = new Uint8Array(len);
296
- }
297
- const { palettePixelData } = state;
298
- for (let i = 0;i < r.colors.length; i++) {
299
- const rgb = colorToRgb(r.colors[i]);
300
- palettePixelData[i * 4] = rgb[0];
301
- palettePixelData[i * 4 + 1] = rgb[1];
302
- palettePixelData[i * 4 + 2] = rgb[2];
303
- palettePixelData[i * 4 + 3] = 255;
304
- }
305
- }
306
- gl.viewport(0, 0, width, height);
307
- gl.clearColor(0, 0, 0, 0);
308
- gl.clear(gl.COLOR_BUFFER_BIT);
309
- gl.useProgram(program);
310
- gl.bindVertexArray(vao);
311
- gl.activeTexture(gl.TEXTURE0);
312
- gl.bindTexture(gl.TEXTURE_2D, paletteTexture);
313
- if (paletteDirty) {
314
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, r.colors.length, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, state.palettePixelData);
315
- }
316
- if (uColorPalette)
317
- gl.uniform1i(uColorPalette, 0);
318
- if (uNumRays)
319
- gl.uniform1f(uNumRays, r.rays);
320
- if (uNumColors)
321
- gl.uniform1f(uNumColors, r.colors.length);
322
- if (uRotationOffset)
323
- gl.uniform1f(uRotationOffset, rotationRad);
324
- if (uSmoothEdge)
325
- gl.uniform1f(uSmoothEdge, r.smoothness);
326
- if (uOrigin)
327
- gl.uniform2f(uOrigin, r.origin[0], 1 - r.origin[1]);
328
- if (uResolution)
329
- gl.uniform2f(uResolution, width, height);
330
- gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
331
- gl.bindVertexArray(null);
332
- gl.bindTexture(gl.TEXTURE_2D, null);
333
- gl.useProgram(null);
334
- },
335
- cleanup: ({ gl, program, vao, vbo, paletteTexture }) => {
336
- gl.deleteBuffer(vbo);
337
- gl.deleteProgram(program);
338
- gl.deleteVertexArray(vao);
339
- gl.deleteTexture(paletteTexture);
340
- },
341
- schema: starburstEffectSchema,
342
- validateParams: validateStarburstEffectParams
343
- });
1
+ import {
2
+ starburstEffectSchema2,
3
+ starburst2
4
+ } from "./index-18y0zcy2.mjs";
344
5
  export {
345
- starburst,
346
- starburstEffectSchema
6
+ starburst2 as starburst,
7
+ starburstEffectSchema2 as starburstEffectSchema
347
8
  };