@remotion/effects 4.0.540 → 4.0.542

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 (133) hide show
  1. package/THIRD_PARTY_LICENSES.md +10 -0
  2. package/dist/esm/lightning.mjs +603 -0
  3. package/dist/esm/magnify.mjs +403 -0
  4. package/dist/esm/preview/barrel-distortion.mjs +303 -0
  5. package/dist/esm/preview/bevel-alpha.mjs +525 -0
  6. package/dist/esm/preview/blur.mjs +435 -0
  7. package/dist/esm/preview/brightness.mjs +95 -0
  8. package/dist/esm/preview/burlap.mjs +481 -0
  9. package/dist/esm/preview/checkerboard.mjs +8 -0
  10. package/dist/esm/preview/chromatic-aberration.mjs +308 -0
  11. package/dist/esm/preview/color-correction.mjs +522 -0
  12. package/dist/esm/preview/color-key.mjs +440 -0
  13. package/dist/esm/preview/contour-lines.mjs +608 -0
  14. package/dist/esm/preview/contrast.mjs +95 -0
  15. package/dist/esm/preview/corner-pin.mjs +6 -0
  16. package/dist/esm/preview/curves.mjs +357 -0
  17. package/dist/esm/preview/cylinder.mjs +273 -0
  18. package/dist/esm/preview/dot-grid.mjs +333 -0
  19. package/dist/esm/preview/drop-shadow.mjs +607 -0
  20. package/dist/esm/preview/duotone.mjs +344 -0
  21. package/dist/esm/preview/emboss.mjs +479 -0
  22. package/dist/esm/preview/evolve.mjs +485 -0
  23. package/dist/esm/preview/exposure.mjs +264 -0
  24. package/dist/esm/preview/film-burn.mjs +298 -0
  25. package/dist/esm/preview/fisheye.mjs +422 -0
  26. package/dist/esm/preview/flannel.mjs +401 -0
  27. package/dist/esm/preview/fractal-noise.mjs +642 -0
  28. package/dist/esm/preview/glow.mjs +598 -0
  29. package/dist/esm/preview/grayscale.mjs +86 -0
  30. package/dist/esm/preview/gridlines.mjs +8 -0
  31. package/dist/esm/preview/halftone-linear-gradient.mjs +523 -0
  32. package/dist/esm/preview/halftone.mjs +552 -0
  33. package/dist/esm/preview/hue.mjs +83 -0
  34. package/dist/esm/preview/index-00v3hr66.mjs +299 -0
  35. package/dist/esm/preview/index-0w4eqht8.mjs +351 -0
  36. package/dist/esm/preview/index-18y0zcy2.mjs +440 -0
  37. package/dist/esm/preview/index-1m1b1ad7.mjs +520 -0
  38. package/dist/esm/preview/index-34fxm3ax.mjs +518 -0
  39. package/dist/esm/preview/index-4fvp93ps.mjs +32 -0
  40. package/dist/esm/preview/index-4scpn12x.mjs +224 -0
  41. package/dist/esm/preview/index-4z6pt3ka.mjs +104 -0
  42. package/dist/esm/preview/index-618ky75w.mjs +51 -0
  43. package/dist/esm/preview/index-6agxdrvr.mjs +411 -0
  44. package/dist/esm/preview/index-6jkps947.mjs +120 -0
  45. package/dist/esm/preview/index-8agtsbw4.mjs +617 -0
  46. package/dist/esm/preview/index-8jx11jyn.mjs +29 -0
  47. package/dist/esm/preview/index-8p04sssx.mjs +123 -0
  48. package/dist/esm/preview/index-afdtmrh2.mjs +596 -0
  49. package/dist/esm/preview/index-b86qstcs.mjs +18 -0
  50. package/dist/esm/preview/index-cb77qg3g.mjs +587 -0
  51. package/dist/esm/preview/index-cdp7tr8x.mjs +122 -0
  52. package/dist/esm/preview/index-evy8hyah.mjs +55 -0
  53. package/dist/esm/preview/index-gnsce796.mjs +6 -0
  54. package/dist/esm/preview/index-kkvzt8b7.mjs +199 -0
  55. package/dist/esm/preview/index-r0v18b2n.mjs +425 -0
  56. package/dist/esm/preview/index-rswpzmm5.mjs +926 -0
  57. package/dist/esm/preview/index-s9mrx750.mjs +97 -0
  58. package/dist/esm/preview/index-tvfexb7s.mjs +164 -0
  59. package/dist/esm/preview/index-vp56k1gj.mjs +215 -0
  60. package/dist/esm/preview/index-wxhvgv2s.mjs +79 -0
  61. package/dist/esm/preview/index-wy95a41r.mjs +407 -0
  62. package/dist/esm/preview/index-ysnwfc4t.mjs +306 -0
  63. package/dist/esm/preview/index.mjs +51 -0
  64. package/dist/esm/preview/invert.mjs +84 -0
  65. package/dist/esm/preview/iris-wipe.mjs +315 -0
  66. package/dist/esm/preview/lens-blur.mjs +563 -0
  67. package/dist/esm/preview/levels.mjs +400 -0
  68. package/dist/esm/preview/light-leak.mjs +8 -0
  69. package/dist/esm/preview/light-trail.mjs +516 -0
  70. package/dist/esm/preview/lightning.mjs +603 -0
  71. package/dist/esm/preview/linear-gradient-tint.mjs +6 -0
  72. package/dist/esm/preview/linear-gradient.mjs +6 -0
  73. package/dist/esm/preview/linear-progressive-blur.mjs +516 -0
  74. package/dist/esm/preview/linear-progressive-pixelate.mjs +176 -0
  75. package/dist/esm/preview/lines.mjs +536 -0
  76. package/dist/esm/preview/liquid-contours.mjs +512 -0
  77. package/dist/esm/preview/long-shadows.mjs +437 -0
  78. package/dist/esm/preview/lut.mjs +601 -0
  79. package/dist/esm/preview/magnify.mjs +403 -0
  80. package/dist/esm/preview/mirror.mjs +341 -0
  81. package/dist/esm/preview/noise-displacement.mjs +584 -0
  82. package/dist/esm/preview/noise.mjs +318 -0
  83. package/dist/esm/preview/outline.mjs +725 -0
  84. package/dist/esm/preview/page-turn.mjs +302 -0
  85. package/dist/esm/preview/paper.mjs +1249 -0
  86. package/dist/esm/preview/pattern.mjs +6 -0
  87. package/dist/esm/preview/pixel-dissolve.mjs +360 -0
  88. package/dist/esm/preview/pixelate.mjs +249 -0
  89. package/dist/esm/preview/radial-progressive-blur.mjs +582 -0
  90. package/dist/esm/preview/radial-progressive-pixelate.mjs +220 -0
  91. package/dist/esm/preview/radial-wipe.mjs +224 -0
  92. package/dist/esm/preview/rain-fall.mjs +114 -0
  93. package/dist/esm/preview/region-blur.mjs +500 -0
  94. package/dist/esm/preview/rings.mjs +8 -0
  95. package/dist/esm/preview/roughen-edges.mjs +590 -0
  96. package/dist/esm/preview/saturation.mjs +86 -0
  97. package/dist/esm/preview/scale.mjs +109 -0
  98. package/dist/esm/preview/scanlines.mjs +362 -0
  99. package/dist/esm/preview/shadows-highlights.mjs +284 -0
  100. package/dist/esm/preview/shatter.mjs +868 -0
  101. package/dist/esm/preview/shine.mjs +368 -0
  102. package/dist/esm/preview/shrinkwrap.mjs +769 -0
  103. package/dist/esm/preview/skew.mjs +300 -0
  104. package/dist/esm/preview/snow-fall.mjs +170 -0
  105. package/dist/esm/preview/speckle.mjs +356 -0
  106. package/dist/esm/preview/sphere.mjs +252 -0
  107. package/dist/esm/preview/starburst.mjs +8 -0
  108. package/dist/esm/preview/tear.mjs +375 -0
  109. package/dist/esm/preview/thermal-vision.mjs +387 -0
  110. package/dist/esm/preview/tile.mjs +7 -0
  111. package/dist/esm/preview/tint.mjs +125 -0
  112. package/dist/esm/preview/translate.mjs +151 -0
  113. package/dist/esm/preview/turbulent-displace.mjs +613 -0
  114. package/dist/esm/preview/tv-signal-off.mjs +308 -0
  115. package/dist/esm/preview/venetian-blinds.mjs +341 -0
  116. package/dist/esm/preview/vibrance.mjs +254 -0
  117. package/dist/esm/preview/vignette.mjs +458 -0
  118. package/dist/esm/preview/wave.mjs +384 -0
  119. package/dist/esm/preview/waves.mjs +599 -0
  120. package/dist/esm/preview/white-balance.mjs +280 -0
  121. package/dist/esm/preview/white-noise.mjs +244 -0
  122. package/dist/esm/preview/zigzag.mjs +8 -0
  123. package/dist/esm/preview/zoom-blur.mjs +389 -0
  124. package/dist/lightning/geometry.d.ts +10 -0
  125. package/dist/lightning/index.d.ts +4 -0
  126. package/dist/lightning/mask.d.ts +2 -0
  127. package/dist/lightning/params.d.ts +259 -0
  128. package/dist/lightning/shaders.d.ts +2 -0
  129. package/dist/lightning.d.ts +2 -0
  130. package/dist/magnify/shader.d.ts +1 -0
  131. package/dist/magnify/webgpu-shader.d.ts +1 -0
  132. package/dist/magnify.d.ts +28 -0
  133. package/package.json +30 -6
@@ -0,0 +1,122 @@
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/color-matrix-runtime.ts
15
+ import { Internals } from "remotion";
16
+ var FRAGMENT_SHADER = `#version 300 es
17
+ precision highp float;
18
+ in vec2 vUv;
19
+ out vec4 fragColor;
20
+ uniform sampler2D uSource;
21
+ uniform vec4 uRed;
22
+ uniform vec4 uGreen;
23
+ uniform vec4 uBlue;
24
+ uniform vec4 uFlags;
25
+ void main() {
26
+ vec4 source = texture(uSource, vUv);
27
+ if (uFlags.z > 0.0 || source.a == 0.0) { fragColor = source; return; }
28
+ vec3 rgb = source.rgb / source.a;
29
+ if (uFlags.x > 0.0) {
30
+ vec3 bytes = floor(rgb * 255.0 + 0.5);
31
+ bytes = uFlags.x == 1.0 ? bytes + uRed.w : (bytes - 128.0) * uRed.x + 128.0;
32
+ rgb = roundEven(clamp(bytes, 0.0, 255.0)) / 255.0;
33
+ } else {
34
+ vec4 color = vec4(rgb, 1.0);
35
+ rgb = clamp(vec3(dot(uRed, color), dot(uGreen, color), dot(uBlue, color)), 0.0, 1.0);
36
+ }
37
+ fragColor = vec4(rgb * source.a, source.a);
38
+ }
39
+ `;
40
+ var WEBGPU_SHADER = `
41
+ ${WEBGPU_SINGLE_PASS_VERTEX}
42
+ struct Params {
43
+ red: vec4f,
44
+ green: vec4f,
45
+ blue: vec4f,
46
+ flags: vec4f,
47
+ }
48
+ @group(0) @binding(0) var source: texture_2d<f32>;
49
+ @group(0) @binding(1) var sourceSampler: sampler;
50
+ @group(0) @binding(2) var<uniform> params: Params;
51
+ @fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {
52
+ let sampled = textureSample(source, sourceSampler, input.uv);
53
+ if (params.flags.z > 0.0 || sampled.a == 0.0) { return sampled; }
54
+ var rgb = sampled.rgb / sampled.a;
55
+ if (params.flags.x > 0.0) {
56
+ var bytes = floor(rgb * 255.0 + vec3f(0.5));
57
+ if (params.flags.x == 1.0) {
58
+ bytes += vec3f(params.red.w);
59
+ } else {
60
+ bytes = (bytes - vec3f(128.0)) * params.red.x + vec3f(128.0);
61
+ }
62
+ bytes = clamp(bytes, vec3f(0.0), vec3f(255.0));
63
+ let lower = floor(bytes);
64
+ let fraction = bytes - lower;
65
+ let odd = lower - floor(lower * 0.5) * 2.0 == vec3f(1.0);
66
+ let aboveHalf = fraction > vec3f(0.5);
67
+ let halfway = fraction == vec3f(0.5);
68
+ rgb = (lower + select(vec3f(0.0), vec3f(1.0), aboveHalf | (halfway & odd))) / 255.0;
69
+ } else {
70
+ let color = vec4f(rgb, 1.0);
71
+ rgb = clamp(vec3f(dot(params.red, color), dot(params.green, color), dot(params.blue, color)), vec3f(0.0), vec3f(1.0));
72
+ }
73
+ return vec4f(rgb * sampled.a, sampled.a);
74
+ }
75
+ `;
76
+ var createColorMatrixImplementations = (label, getUniformData) => ({
77
+ webgl2: Internals.createEffectImplementation({
78
+ setup: (target) => setupSinglePass(target, FRAGMENT_SHADER, label, [
79
+ "uRed",
80
+ "uGreen",
81
+ "uBlue",
82
+ "uFlags"
83
+ ]),
84
+ apply: ({ source, width, height, params, state, flipSourceY }) => {
85
+ prepareSinglePassSource({
86
+ state,
87
+ source,
88
+ width,
89
+ height,
90
+ flipSourceY
91
+ });
92
+ const data = getUniformData(params);
93
+ const { gl, uniforms } = state;
94
+ gl.uniform4fv(uniforms.uRed, data.subarray(0, 4));
95
+ gl.uniform4fv(uniforms.uGreen, data.subarray(4, 8));
96
+ gl.uniform4fv(uniforms.uBlue, data.subarray(8, 12));
97
+ gl.uniform4fv(uniforms.uFlags, data.subarray(12, 16));
98
+ drawSinglePass(state);
99
+ },
100
+ cleanup: cleanupSinglePass
101
+ }),
102
+ webgpu: Internals.createEffectImplementation({
103
+ setup: (target) => setupWebGpuSinglePass(target, label),
104
+ apply: ({ source, width, height, params, state, gpuDevice }) => {
105
+ if (!gpuDevice) {
106
+ throw new Error(`A WebGPU device is required for the ${label} effect`);
107
+ }
108
+ applyWebGpuSinglePass({
109
+ state,
110
+ source,
111
+ width,
112
+ height,
113
+ device: gpuDevice,
114
+ shader: WEBGPU_SHADER,
115
+ uniformData: getUniformData(params)
116
+ });
117
+ },
118
+ cleanup: cleanupWebGpuSinglePass
119
+ })
120
+ });
121
+
122
+ export { createColorMatrixImplementations };
@@ -0,0 +1,55 @@
1
+ // src/gaussian-blur-shader.ts
2
+ var buildGaussianBlurFs = (direction) => {
3
+ const dirVec = direction === "horizontal" ? "vec2(1.0, 0.0)" : "vec2(0.0, 1.0)";
4
+ return `#version 300 es
5
+ precision highp float;
6
+
7
+ in vec2 vUv;
8
+ out vec4 fragColor;
9
+
10
+ uniform sampler2D uSource;
11
+ uniform float uRadius;
12
+ uniform vec2 uTexelSize;
13
+
14
+ const int MIN_KERNEL_HALF = 4;
15
+ const int MAX_KERNEL_HALF = 32;
16
+ const float TARGET_SAMPLE_DISTANCE_PX = 2.0;
17
+ const vec2 DIRECTION = ${dirVec};
18
+
19
+ void main() {
20
+ if (uRadius <= 0.0) {
21
+ fragColor = texture(uSource, vUv);
22
+ return;
23
+ }
24
+
25
+ int kernelHalf = int(
26
+ min(
27
+ float(MAX_KERNEL_HALF),
28
+ max(float(MIN_KERNEL_HALF), ceil(uRadius / TARGET_SAMPLE_DISTANCE_PX))
29
+ )
30
+ );
31
+ float pixelStride = uRadius / float(kernelHalf);
32
+ float sigma = uRadius / 3.0;
33
+ float twoSigmaSq = 2.0 * sigma * sigma;
34
+
35
+ vec4 sum = vec4(0.0);
36
+ float weightSum = 0.0;
37
+
38
+ for (int i = -MAX_KERNEL_HALF; i <= MAX_KERNEL_HALF; ++i) {
39
+ if (abs(i) > kernelHalf) {
40
+ continue;
41
+ }
42
+
43
+ float offsetPx = float(i) * pixelStride;
44
+ float w = exp(-(offsetPx * offsetPx) / twoSigmaSq);
45
+ vec2 uv = vUv + DIRECTION * uTexelSize * offsetPx;
46
+ sum += texture(uSource, uv) * w;
47
+ weightSum += w;
48
+ }
49
+
50
+ fragColor = sum / weightSum;
51
+ }
52
+ `;
53
+ };
54
+
55
+ export { buildGaussianBlurFs };
@@ -0,0 +1,6 @@
1
+ // src/uv-coordinate.ts
2
+ var publicUvToShaderUv = (uv) => {
3
+ return [uv[0], 1 - uv[1]];
4
+ };
5
+
6
+ export { publicUvToShaderUv };
@@ -0,0 +1,199 @@
1
+ import {
2
+ WEBGPU_SINGLE_PASS_VERTEX
3
+ } from "./index-tvfexb7s.mjs";
4
+
5
+ // src/webgpu-multipass-runtime.ts
6
+ var WEBGPU_MULTIPASS_BINDINGS = `
7
+ ${WEBGPU_SINGLE_PASS_VERTEX}
8
+ @group(0) @binding(0) var source: texture_2d<f32>;
9
+ @group(0) @binding(1) var sourceSampler: sampler;
10
+ @group(0) @binding(2) var<uniform> params: Params;
11
+ @group(0) @binding(3) var secondary: texture_2d<f32>;
12
+ `;
13
+ var setupWebGpuMultipass = (target, label) => {
14
+ const context = target.getContext("webgpu");
15
+ if (!context)
16
+ throw new Error(`WebGPU is not available for the ${label} effect`);
17
+ return { context, label, resources: null };
18
+ };
19
+ var cleanupWebGpuMultipass = (state) => {
20
+ state.resources?.source?.texture.destroy();
21
+ state.resources?.auxiliary?.texture.destroy();
22
+ state.resources?.textures.forEach((texture) => texture.destroy());
23
+ state.resources?.passes.forEach((pass) => pass.uniforms.destroy());
24
+ state.resources = null;
25
+ state.context.unconfigure();
26
+ };
27
+ var applyWebGpuMultipass = ({
28
+ state,
29
+ source,
30
+ width,
31
+ height,
32
+ device,
33
+ passes,
34
+ auxiliarySource
35
+ }) => {
36
+ if (state.resources && state.resources.device !== device)
37
+ cleanupWebGpuMultipass(state);
38
+ if (!state.resources) {
39
+ const format = navigator.gpu.getPreferredCanvasFormat();
40
+ state.context.configure({ device, format, alphaMode: "premultiplied" });
41
+ const layout = device.createBindGroupLayout({
42
+ entries: [
43
+ { binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: {} },
44
+ { binding: 1, visibility: GPUShaderStage.FRAGMENT, sampler: {} },
45
+ {
46
+ binding: 2,
47
+ visibility: GPUShaderStage.FRAGMENT,
48
+ buffer: { type: "uniform" }
49
+ },
50
+ { binding: 3, visibility: GPUShaderStage.FRAGMENT, texture: {} }
51
+ ]
52
+ });
53
+ state.resources = {
54
+ device,
55
+ format,
56
+ layout,
57
+ sampler: device.createSampler({ magFilter: "linear", minFilter: "linear" }),
58
+ passes: [],
59
+ textures: [],
60
+ source: null,
61
+ auxiliary: null,
62
+ width,
63
+ height
64
+ };
65
+ }
66
+ const r = state.resources;
67
+ const sourceWidth = "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;
68
+ const sourceHeight = "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;
69
+ if (r.source && (r.source.width !== sourceWidth || r.source.height !== sourceHeight)) {
70
+ r.source.texture.destroy();
71
+ r.source = null;
72
+ }
73
+ if (!r.source) {
74
+ r.source = {
75
+ width: sourceWidth,
76
+ height: sourceHeight,
77
+ texture: device.createTexture({
78
+ size: [sourceWidth, sourceHeight],
79
+ format: "rgba8unorm",
80
+ usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT
81
+ })
82
+ };
83
+ }
84
+ device.queue.copyExternalImageToTexture({ source }, { texture: r.source.texture, premultipliedAlpha: true }, [sourceWidth, sourceHeight]);
85
+ if (r.auxiliary && (!auxiliarySource || r.auxiliary.width !== auxiliarySource.width || r.auxiliary.height !== auxiliarySource.height)) {
86
+ r.auxiliary.texture.destroy();
87
+ r.auxiliary = null;
88
+ }
89
+ if (auxiliarySource) {
90
+ if (!r.auxiliary)
91
+ r.auxiliary = {
92
+ width: auxiliarySource.width,
93
+ height: auxiliarySource.height,
94
+ texture: device.createTexture({
95
+ size: [auxiliarySource.width, auxiliarySource.height],
96
+ format: "rgba8unorm",
97
+ usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT
98
+ })
99
+ };
100
+ device.queue.copyExternalImageToTexture({ source: auxiliarySource }, { texture: r.auxiliary.texture, premultipliedAlpha: true }, [auxiliarySource.width, auxiliarySource.height]);
101
+ }
102
+ if (r.width !== width || r.height !== height) {
103
+ r.textures.forEach((texture) => texture.destroy());
104
+ r.textures.length = 0;
105
+ r.width = width;
106
+ r.height = height;
107
+ }
108
+ const lastReaders = passes.map((_, index) => index);
109
+ for (let index = 0;index < passes.length; index++) {
110
+ for (const input of [passes[index].source, passes[index].secondary]) {
111
+ if (input >= 0)
112
+ lastReaders[input] = index;
113
+ }
114
+ }
115
+ const outputSlots = [];
116
+ const freeAfter = [];
117
+ for (let index = 0;index < passes.length - 1; index++) {
118
+ let slot = freeAfter.findIndex((lastReader) => lastReader < index);
119
+ if (slot === -1)
120
+ slot = freeAfter.length;
121
+ freeAfter[slot] = lastReaders[index];
122
+ outputSlots.push(slot);
123
+ }
124
+ while (r.textures.length < freeAfter.length) {
125
+ r.textures.push(device.createTexture({
126
+ size: [width, height],
127
+ format: "rgba8unorm",
128
+ usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.RENDER_ATTACHMENT
129
+ }));
130
+ }
131
+ while (r.textures.length > freeAfter.length)
132
+ r.textures.pop()?.destroy();
133
+ while (r.passes.length > passes.length)
134
+ r.passes.pop()?.uniforms.destroy();
135
+ const encoder = device.createCommandEncoder();
136
+ for (let index = 0;index < passes.length; index++) {
137
+ const pass = passes[index];
138
+ const format = index === passes.length - 1 ? r.format : "rgba8unorm";
139
+ const size = Math.max(16, Math.ceil(pass.uniforms.byteLength / 16) * 16);
140
+ let resources = r.passes[index];
141
+ if (!resources || resources.shader !== pass.shader || resources.size !== size || resources.format !== format) {
142
+ resources?.uniforms.destroy();
143
+ const module = device.createShaderModule({
144
+ code: pass.shader,
145
+ label: state.label
146
+ });
147
+ resources = {
148
+ shader: pass.shader,
149
+ size,
150
+ format,
151
+ pipeline: device.createRenderPipeline({
152
+ label: state.label,
153
+ layout: device.createPipelineLayout({ bindGroupLayouts: [r.layout] }),
154
+ vertex: { module, entryPoint: "vertex" },
155
+ fragment: { module, entryPoint: "fragment", targets: [{ format }] },
156
+ primitive: { topology: "triangle-list" }
157
+ }),
158
+ uniforms: device.createBuffer({
159
+ size,
160
+ usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
161
+ })
162
+ };
163
+ r.passes[index] = resources;
164
+ }
165
+ device.queue.writeBuffer(resources.uniforms, 0, pass.uniforms);
166
+ const bindGroup = device.createBindGroup({
167
+ layout: r.layout,
168
+ entries: [
169
+ {
170
+ binding: 0,
171
+ resource: (pass.source === -1 ? r.source.texture : r.textures[outputSlots[pass.source]]).createView()
172
+ },
173
+ { binding: 1, resource: r.sampler },
174
+ { binding: 2, resource: { buffer: resources.uniforms } },
175
+ {
176
+ binding: 3,
177
+ resource: (pass.secondary === -2 && r.auxiliary ? r.auxiliary.texture : pass.secondary === -1 ? r.source.texture : r.textures[outputSlots[pass.secondary]]).createView()
178
+ }
179
+ ]
180
+ });
181
+ const renderPass = encoder.beginRenderPass({
182
+ colorAttachments: [
183
+ {
184
+ view: (index === passes.length - 1 ? state.context.getCurrentTexture() : r.textures[outputSlots[index]]).createView(),
185
+ clearValue: { r: 0, g: 0, b: 0, a: 0 },
186
+ loadOp: "clear",
187
+ storeOp: "store"
188
+ }
189
+ ]
190
+ });
191
+ renderPass.setPipeline(resources.pipeline);
192
+ renderPass.setBindGroup(0, bindGroup);
193
+ renderPass.draw(3);
194
+ renderPass.end();
195
+ }
196
+ device.queue.submit([encoder.finish()]);
197
+ };
198
+
199
+ export { WEBGPU_MULTIPASS_BINDINGS, setupWebGpuMultipass, cleanupWebGpuMultipass, applyWebGpuMultipass };