@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LIGHT_LEAK_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n\nstruct Params { size: vec2f, progress: f32, seed: f32, hue: f32, }\nfn computePattern(uv: vec2f, s: f32, t: f32) -> vec3f {\n var p = uv * 0.8 + vec2f(sin(s * 1.61803) * 5.0, cos(s * 2.71828) * 5.0);\n for (var i = 1; i < 5; i++) {\n var newp = p;\n let fi = f32(i);\n let phase = s * 0.7 * fi;\n newp.x += 0.6 / fi * cos(fi * p.y + t * 0.7 + 0.3 * fi + phase) + 20.0;\n newp.y += 0.6 / fi * cos(fi * p.x + t * 0.7 + 0.3 * f32(i + 10) + phase) - 20.0 + 15.0;\n p = newp;\n }\n let v1 = 0.5 * sin(2.0 * p.x) + 0.5;\n let v2 = 0.5 * sin(2.0 * p.y) + 0.5;\n let blend = sin(p.x + p.y) * 0.5 + 0.5;\n let brightness = v1 * 0.5 + v2 * 0.5;\n return vec3f(brightness, blend, brightness * 0.6 + blend * 0.4);\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let evolveProgress = min(1.0, params.progress * 2.0);\n let retractProgress = max(0.0, params.progress * 2.0 - 1.0);\n let refScale = 1.92;\n let uv = (vec2f(input.position.x, params.size.y - input.position.y) / params.size) * vec2f(refScale, refScale * params.size.y / params.size.x);\n let patA = computePattern(uv, params.seed, evolveProgress * 3.14159);\n let threshA = 1.0 - evolveProgress;\n let revealAlpha = smoothstep(threshA, threshA + 0.3, patA.z);\n let maxUv = vec2f(refScale, refScale * params.size.y / params.size.x);\n let patB = computePattern(maxUv - uv, params.seed + 42.0, retractProgress * 3.14159);\n let threshB = 1.0 - retractProgress;\n let eraseAlpha = smoothstep(threshB, threshB + 0.3, patB.z);\n let alpha = revealAlpha * (1.0 - eraseAlpha);\n var col = mix(vec3f(1.0, 0.85, 0.2), vec3f(1.0, 0.5, 0.05), patA.y) * (0.6 + 0.6 * patA.x);\n let angle = params.hue * 3.14159 / 180.0;\n let a = cos(angle);\n let b = sin(angle) * 0.57735;\n let c = (1.0 - a) / 3.0;\n let hueRot = mat3x3f(vec3f(a+c,c-b,c+b),vec3f(c+b,a+c,c-b),vec3f(c-b,c+b,a+c));\n col = clamp(hueRot * col, vec3f(0), vec3f(1));\n let color = textureSampleLevel(source, sourceSampler, input.uv, 0);\n return vec4f(col * alpha, alpha) + color * (1.0 - alpha);\n}\n\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LIGHT_TRAIL_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params {resolution: vec2f, direction: vec2f, color: vec4f, values: vec4f, samples: vec4f,}\nfn contribution(color: vec4f) -> f32 {\n if (color.a<=0.001) {return 0.0;}\n let luminance=dot(color.rgb/color.a,vec3f(0.299,0.587,0.114));\n let value=max(color.a,luminance);let threshold=clamp(params.values.w,0.0,1.0);\n if (threshold>=1.0) {return step(1.0,value);}\n return clamp((value-threshold)/max(1.0-threshold,0.0001),0.0,1.0);\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color=textureSampleLevel(source,sourceSampler,input.uv,0);\n var trail=vec4f(0);let count=max(params.samples.x,1.0);\n for (var i=1; i<=64; i++) {\n if (f32(i)>params.samples.x) {break;}\n let progress=f32(i)/count;\n let offset=params.direction/params.resolution*params.values.x*progress;\n let sampled=textureSampleLevel(source,sourceSampler,input.uv-offset,0);\n let weight=pow(clamp(params.values.z,0.0,1.0),f32(i-1))*contribution(sampled);\n let alpha=sampled.a*params.color.a*weight;\n trail+=vec4f(params.color.rgb*alpha,alpha);\n }\n return min(color+trail*max(params.values.y,0.0)/count,vec4f(1));\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LINEAR_GRADIENT_TINT_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\nstruct Params { start: vec2f, end: vec2f, startColor: vec4f, endColor: vec4f, amount: f32, padding1: f32, padding2: f32, padding3: f32 }\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n\nfn gradientProgress(uv: vec2f) -> f32 {\n let gradient = params.end - params.start;\n let gradientLengthSq = dot(gradient, gradient);\n if (gradientLengthSq <= 0.0000001) { return 0.0; }\n return clamp(dot(uv - params.start, gradient) / gradientLengthSq, 0.0, 1.0);\n}\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color = textureSampleLevel(source, sourceSampler, input.uv, 0.0);\n let alpha = color.a;\n if (alpha <= 0.001) { return vec4f(0.0); }\n let tintColor = mix(params.startColor, params.endColor, gradientProgress(input.uv));\n let blended = mix(color.rgb / alpha, tintColor.rgb, params.amount * tintColor.a);\n return vec4f(blended * alpha, alpha);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LINEAR_GRADIENT_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\nstruct Params { start: vec2f, end: vec2f, startColor: vec4f, endColor: vec4f, amount: f32, padding1: f32, padding2: f32, padding3: f32 }\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n\nfn gradientProgress(uv: vec2f) -> f32 {\n let gradient = params.end - params.start;\n let gradientLengthSq = dot(gradient, gradient);\n if (gradientLengthSq <= 0.0000001) { return 0.0; }\n return clamp(dot(uv - params.start, gradient) / gradientLengthSq, 0.0, 1.0);\n}\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color = mix(params.startColor, params.endColor, gradientProgress(input.uv));\n return vec4f(color.rgb * color.a, color.a);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LINES_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var sourceTexture: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var palette: texture_2d<f32>;\nstruct Params {\n geometry: vec4f,\n stripe: vec4f,\n flags: vec4f,\n}\nfn sampleSource(uv: vec2f) -> vec4f {\n return textureSampleLevel(sourceTexture, sourceSampler, vec2f(uv.x, 1.0 - uv.y), 0);\n}\nfn glslModulo(value: f32, divisor: f32) -> f32 { return value - divisor * floor(value / divisor); }\nfn paletteColor(index: f32) -> vec4f { return textureLoad(palette, vec2i(i32(index), 0), 0); }\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let vUv = vec2f(input.uv.x, 1.0 - input.uv.y);\n\n let texColor = sampleSource(vUv);\n let thickness = max(params.stripe.x, 0.001);\n let spacing = max(params.stripe.y, 0.001);\n let cycle = spacing * params.geometry.z;\n let centered = vec2f(input.position.x, params.geometry.y - input.position.y) - params.geometry.xy * 0.5;\n let s = sin(params.stripe.z);\n let c = cos(params.stripe.z);\n let rotated = vec2f(centered.x * c - centered.y * s, centered.x * s + centered.y * c);\n var axis = select(rotated.x, rotated.y, params.geometry.w == 0.0);\n\n var position = glslModulo(axis + params.stripe.w, cycle);\n if (position < 0.0) { position += cycle; }\n let colorIndex = floor(position / spacing);\n let inStripe = glslModulo(position, spacing);\n if (inStripe > thickness) { return texColor; }\n\n let overlay = paletteColor(colorIndex);\n let premultiplied = overlay.rgb * overlay.a;\n if (params.flags.x != 0.0) {\n return vec4f(premultiplied * texColor.a + texColor.rgb * (1.0 - overlay.a), texColor.a);\n }\n return vec4f(premultiplied + texColor.rgb * (1.0 - overlay.a), overlay.a + texColor.a * (1.0 - overlay.a));\n\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LIQUID_CONTOURS_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var sourceTexture: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params {\n geometry: vec4f,\n noise: vec4f,\n offset: vec4f,\n first: vec4f,\n second: vec4f,\n}\nfn sampleSource(uv: vec2f) -> vec4f {\n return textureSampleLevel(sourceTexture, sourceSampler, vec2f(uv.x, 1.0 - uv.y), 0);\n}\n\nfn hash(p: vec2f) -> f32 {\n var p3 = fract(p.xyx * 0.1031);\n p3 += vec3f(dot(p3, p3.yzx + vec3f(33.33) + vec3f(params.noise.z * 0.013)));\n return fract((p3.x + p3.y) * p3.z);\n}\nfn valueNoise(p: vec2f) -> f32 {\n let i = floor(p);\n let f = fract(p);\n let u = f * f * f * (f * (f * 6.0 - vec2f(15.0)) + vec2f(10.0));\n return mix(mix(hash(i), hash(i + vec2f(1, 0)), u.x), mix(hash(i + vec2f(0, 1)), hash(i + vec2f(1)), u.x), u.y);\n}\n\nfn fbm(position: vec2f) -> f32 {\n var p = position;\n var value = 0.0;\n var amplitude = 0.5;\n var total = 0.0;\n let persistence = mix(0.2, 0.58, params.noise.x);\n let rotate = mat2x2f(0.80, 0.60, -0.60, 0.80);\n for (var i = 0; i < 5; i++) {\n let octave = f32(i) / 4.0;\n let detail = mix(0.45, 1.0, params.noise.x);\n let octaveWeight = mix(1.0, 1.0 - smoothstep(0.4, 1.0, octave), 1.0 - detail);\n value += amplitude * octaveWeight * valueNoise(p);\n total += amplitude * octaveWeight;\n p = rotate * p * 2.03 + vec2f(13.17, 7.31);\n amplitude *= persistence;\n }\n return value / total;\n}\n\nfn waveAt(pixel: vec2f) -> f32 {\n let position = pixel + params.offset.xy;\n let p = position / max(params.geometry.w, 0.001) + vec2f(params.noise.z * 0.137, params.noise.z * 0.193);\n let warp = vec2f(fbm(p + vec2f(5.2, 1.3)), fbm(p + vec2f(1.7, 9.2))) - vec2f(0.5);\n let roundRotation = mat2x2f(0.7071, 0.7071, -0.7071, 0.7071);\n let roundedField = mix(valueNoise(p * 0.9), valueNoise(roundRotation * p * 0.78 + vec2f(8.3, 2.7)), 0.45);\n let detailedField = fbm(p + warp * mix(0.35, 1.8, params.noise.x));\n let detailMix = smoothstep(0.0, 1.0, params.noise.x);\n let field = mix(roundedField, detailedField, detailMix);\n let levels = max(max(params.geometry.x, params.geometry.y) / max(params.geometry.z, 0.001), 1.0);\n return sin((field * levels + params.noise.w) * 6.28318530718);\n\n}\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let vUv = vec2f(input.uv.x, 1.0 - input.uv.y);\n\n let pixel = vec2f(input.position.x, params.geometry.y - input.position.y);\n let wave = waveAt(pixel);\n var derivative = fwidth(wave);\n if (i32(params.geometry.y) % 2 != 0) {\n // Match WebGL's bottom-origin derivative quads on odd-height targets.\n let neighborY = select(-1.0, 1.0, i32(pixel.y) % 2 == 0);\n derivative = abs(dpdx(wave)) + abs(waveAt(pixel + vec2f(0, neighborY)) - wave);\n }\n let edgeWidth = derivative * mix(0.15, 1.4, params.noise.y);\n let selector = smoothstep(-edgeWidth, edgeWidth, wave);\n let color = mix(params.first, params.second, selector);\n return vec4f(color.rgb * color.a, color.a);\n\n}\n";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const LONG_SHADOWS_EXTEND_WEBGPU_SHADER = "\n\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var secondary: texture_2d<f32>;\n\nstruct Params {offset: vec4f,}\nfn alphaAt(pixel: vec2i) -> f32 {\n let size=vec2i(textureDimensions(source));\n if (any(pixel<vec2i(0)) || any(pixel>=size)) {return 0.0;}\n return textureLoad(source,pixel,0).a;\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let pixel=(input.uv-params.offset.xy)*vec2f(textureDimensions(source))-0.5;\n let base=vec2i(floor(pixel));let fraction=fract(pixel);\n let shifted=mix(mix(alphaAt(base),alphaAt(base+vec2i(1,0)),fraction.x),mix(alphaAt(base+vec2i(0,1)),alphaAt(base+vec2i(1,1)),fraction.x),fraction.y);\n return vec4f(0,0,0,max(textureSampleLevel(source,sourceSampler,input.uv,0).a,shifted));\n}\n";
|
|
2
|
+
export declare const LONG_SHADOWS_COMPOSITE_WEBGPU_SHADER = "\n\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var secondary: texture_2d<f32>;\n\nstruct Params {color: vec4f,}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color=textureSampleLevel(source,sourceSampler,input.uv,0);\n let alpha=textureSampleLevel(secondary,sourceSampler,input.uv,0).a*params.color.a;\n return color+vec4f(params.color.rgb*alpha,alpha)*(1.0-color.a);\n}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LUT_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\nstruct Params {domainMin: vec4f, domainMax: vec4f,}\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var lut: texture_2d<f32>;\nfn lookup(p: vec3u) -> vec3f {\n let size = u32(params.domainMin.w);\n let index = p.x + size * (p.y + size * p.z);\n let width = textureDimensions(lut).x;\n // The WebGL LUT is RGBA16F. Preserve its rounding before interpolation.\n return quantizeToF16(textureLoad(lut, vec2u(index % width, index / width), 0).rgb);\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color = textureSampleLevel(source, sourceSampler, input.uv, 0);\n if (color.a <= 0.0) { return vec4f(0); }\n let normalized = clamp((color.rgb / color.a - params.domainMin.xyz) / (params.domainMax.xyz - params.domainMin.xyz), vec3f(0), vec3f(1));\n let position = normalized * (params.domainMin.w - 1.0);\n let lower = vec3u(floor(position));\n let upper = min(lower + vec3u(1), vec3u(u32(params.domainMin.w) - 1u));\n let fraction = fract(position);\n let c00 = mix(lookup(lower), lookup(vec3u(upper.x, lower.yz)), fraction.x);\n let c10 = mix(lookup(vec3u(lower.x, upper.y, lower.z)), lookup(vec3u(upper.xy, lower.z)), fraction.x);\n let c01 = mix(lookup(vec3u(lower.xy, upper.z)), lookup(vec3u(upper.x, lower.y, upper.z)), fraction.x);\n let c11 = mix(lookup(vec3u(lower.x, upper.yz)), lookup(upper), fraction.x);\n return vec4f(mix(mix(c00, c10, fraction.y), mix(c01, c11, fraction.y), fraction.z) * color.a, color.a);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MIRROR_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params { values: vec4f, }\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n var uv = vec2f(input.uv.x, 1.0 - input.uv.y);\n let vertical = params.values.y != 0.0;\n let coord = select(uv.x, uv.y, vertical);\n let position = params.values.x;\n let shouldMirror = select(coord > position, coord < position, params.values.z != 0.0);\n if (shouldMirror) {\n let mirrored = 2.0 * position - coord;\n if (vertical) { uv.y = mirrored; } else { uv.x = mirrored; }\n }\n return textureSampleLevel(source, sourceSampler, clamp(vec2f(uv.x, 1.0 - uv.y), vec2f(0), vec2f(1)), 0);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NOISE_DISPLACEMENT_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n\nstruct Params { size: vec2f, center: vec2f, radius: f32, strength: f32, seed: f32, grainSize: f32, passes: f32, blur: f32, feather: f32, biasDirection: f32, biasAmount: f32, }\nconst DISC = array<vec2f,9>(vec2f(0),vec2f(1,0),vec2f(-1,0),vec2f(0,1),vec2f(0,-1),vec2f(0.707,0.707),vec2f(-0.707,0.707),vec2f(0.707,-0.707),vec2f(-0.707,-0.707));\nconst DISC_W = array<f32,9>(1.0,0.7,0.7,0.7,0.7,0.5,0.5,0.5,0.5);\nfn hash12(p: vec2f) -> f32 {\n var p3=fract(p.xyx*0.1031+vec3f(params.seed*0.0973));\n p3 += vec3f(dot(p3,p3.yzx+vec3f(33.33)));\n return fract((p3.x+p3.y)*p3.z);\n}\nfn valueNoise(p: vec2f) -> f32 {\n let i=floor(p); let f=fract(p); let u=f*f*(vec2f(3.0)-2.0*f);\n return mix(mix(hash12(i),hash12(i+vec2f(1,0)),u.x),mix(hash12(i+vec2f(0,1)),hash12(i+vec2f(1,1)),u.x),u.y);\n}\nfn noiseVector(p: vec2f) -> vec2f { return vec2f(valueNoise(p+vec2f(17.13,71.79)),valueNoise(p+vec2f(83.41,29.67)))*2.0-vec2f(1.0); }\nfn effectMask(pixel: vec2f) -> f32 {\n let radius=params.radius*min(params.size.x,params.size.y);\n let distance=length(pixel-params.center*params.size);\n if(distance>=radius) { return 0.0; }\n if(params.feather<=0.0001) { return 1.0; }\n return 1.0-smoothstep(radius*(1.0-params.feather),radius,distance);\n}\nfn sampleSource(pixel: vec2f) -> vec4f { return textureSampleLevel(source,sourceSampler,clamp(pixel/params.size,vec2f(0),vec2f(1)),0); }\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let pixel=input.uv*params.size;\n let mask=effectMask(pixel);\n if(mask<=0.0 || params.strength<=0.0) { return textureSampleLevel(source,sourceSampler,input.uv,0); }\n let noiseCoord=pixel/max(params.grainSize,0.001);\n let direction=params.biasDirection*3.141592653589793/180.0;\n let displacement=(noiseVector(noiseCoord)+vec2f(cos(direction),sin(direction))*params.biasAmount)*params.strength*mask;\n let passes=max(i32(params.passes),1);\n let blurRadius=params.blur*mask;\n let blurTaps=select(1,9,blurRadius>0.5);\n var color=vec4f(0); var totalWeight=0.0;\n for(var s=0;s<12;s++) {\n if(s>=passes) { break; }\n let t=select(f32(s)/f32(max(passes-1,1)),1.0,passes==1);\n let samplePixel=pixel+displacement*t;\n let passWeight=1.0-t*0.6;\n for(var b=0;b<9;b++) {\n if(b>=blurTaps) { break; }\n let weight=passWeight*DISC_W[b];\n color += sampleSource(samplePixel+DISC[b]*blurRadius)*weight;\n totalWeight += weight;\n }\n }\n return color/totalWeight;\n}\n\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NOISE_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n\nstruct Params { size: vec2f, amount: f32, seed: f32, premultiply: f32, }\nfn random(co: vec2f) -> f32 {\n var p3 = fract(co.xyx * 0.1031 + vec3f(params.seed * 0.0973));\n p3 += vec3f(dot(p3, p3.yzx + vec3f(33.33)));\n return fract((p3.x + p3.y) * p3.z);\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color = textureSampleLevel(source, sourceSampler, input.uv, 0);\n if (color.a <= 0.001) { return vec4f(0); }\n let noise = random(vec2f(input.position.x, params.size.y - input.position.y)) - 0.5;\n let rgb = color.rgb / color.a;\n let layer = select(vec3f(noise), rgb * noise, params.premultiply != 0.0);\n return vec4f(clamp(rgb + layer * params.amount, vec3f(0), vec3f(1)) * color.a, color.a);\n}\n\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const OUTLINE_WEBGPU_SHADER = "\n\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var secondary: texture_2d<f32>;\n\nstruct Params {color: vec4f, width: f32, opacity: f32, outlineOnly: f32, polygon: f32,}\nconst MIN_ALPHA=0.5/255.0;\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color=textureSampleLevel(source,sourceSampler,input.uv,0);\n let only=params.outlineOnly!=0.0;\n if (params.opacity<=0.0 || params.color.a<=0.0) {return select(color,vec4f(0),only);}\n if (params.width<=0.0 && !only) {return color;}\n var mask=0.0;\n if (params.polygon!=0.0) {\n mask=step(MIN_ALPHA,textureSampleLevel(secondary,sourceSampler,input.uv,0).a);\n } else if (params.width>0.0) {\n let size=vec2i(textureDimensions(source));\n let position=clamp(vec2i(input.uv*vec2f(size)),vec2i(0),size-1);\n for (var ring=1;ring<=3;ring++) {\n let distance=params.width*f32(ring)/3.0;\n for (var direction=0;direction<32;direction++) {\n let angle=6.283185307179586*f32(direction)/32.0;\n let offset=vec2i(round(vec2f(cos(angle),-sin(angle))*distance));\n let samplePosition=clamp(position+offset,vec2i(0),size-1);\n mask=max(mask,step(MIN_ALPHA,textureLoad(source,samplePosition,0).a));\n }\n }\n }\n if (only) {\n let alpha=select(max(step(MIN_ALPHA,color.a),mask),mask,params.polygon!=0.0)*params.color.a*params.opacity;\n return vec4f(params.color.rgb*alpha,alpha);\n }\n let alpha=mask*params.color.a*params.opacity*(1.0-color.a);\n return vec4f(color.rgb+params.color.rgb*alpha,color.a+alpha);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PAGE_TURN_WEBGL_SHADER = "#version 300 es\nprecision highp float;\nuniform sampler2D uSource;\nuniform vec4 uParams[4];\nout vec4 fragColor;\n\nvec4 samplePage(vec2 pixel) {\n vec2 resolution = uParams[0].xy;\n if (any(lessThan(pixel, vec2(0))) || any(greaterThanEqual(pixel, resolution))) { return vec4(0); }\n // The shared projection sampler wraps horizontally; pages must not wrap at the edges.\n vec2 uv = clamp(pixel, vec2(0.5), resolution - vec2(0.5)) / resolution;\n return textureLod(uSource, vec2(uv.x, 1.0 - uv.y), 0.0);\n}\n\nvec4 project(vec2 position) {\n float radius = uParams[1].x;\n float direction = uParams[1].y;\n vec2 normal = vec2(-sin(direction), cos(direction));\n float distance = dot(position - uParams[0].zw, normal);\n float coverage = 1.0 - smoothstep(radius - max(fwidth(distance), 0.001), radius, distance);\n if (distance >= radius) { return vec4(0); }\n\n vec4 front = vec4(0);\n vec4 back = vec4(0);\n float backDistance = 3.14159265359 * radius - distance;\n float backShade = 0.9;\n if (distance <= 0.0) {\n front = samplePage(position);\n } else {\n float angle = asin(clamp(distance / radius, 0.0, 1.0));\n float frontDistance = radius * angle;\n backDistance = 3.14159265359 * radius - frontDistance;\n float light = uParams[1].z;\n float lightDot = normal.x * sin(light) - normal.y * cos(light);\n float shade = 1.0 - 0.4 * (angle / 1.57079632679) * (0.5 + 0.5 * lightDot);\n vec4 color = samplePage(position + normal * (frontDistance - distance));\n front = vec4(color.rgb * shade, color.a);\n backShade = 0.6 + 0.4 * cos(angle);\n }\n vec4 color = samplePage(position + normal * (backDistance - distance));\n float tint = (1.0 - uParams[3].x) * uParams[2].a;\n back = vec4(mix(color.rgb, uParams[2].rgb * color.a, tint) * backShade, color.a);\n if (uParams[1].w == 1.0) { return front * coverage; }\n if (uParams[1].w == 2.0) { return back * coverage; }\n // Premultiplied source-over: the curled back covers the front, which shows through its alpha.\n return (back + front * (1.0 - back.a)) * coverage;\n}\n\nvoid main() { fragColor = project(vec2(gl_FragCoord.x, uParams[0].y - gl_FragCoord.y)); }\n";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const PAPER_WEBGPU_SHADER = "\ndiagnostic(off, derivative_uniformity);\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params { size: vec2f, aspectRatio: f32, amount: f32, colorFront: vec4f, colorBack: vec4f, contrast: f32, roughness: f32, fiber: f32, fiberSize: f32, crumples: f32, crumpleSize: f32, folds: f32, foldCount: f32, drops: f32, fade: f32, seed: f32, scale: f32, offsetY: f32, }\n@group(0) @binding(3) var noiseTexture: texture_2d<f32>;\nconst TWO_PI=6.28318530718;\nconst PI=3.14159265358979323846;\nfn getUvFrame(uv: vec2f) -> f32 {\n\n\tvar aax: f32 = 2.0 * fwidth(uv.x);\n\tvar aay: f32 = 2.0 * fwidth(uv.y);\n\n\tvar left: f32 = smoothstep(0.0, aax, uv.x);\n\tvar right: f32 = 1.0 - smoothstep(1.0 - aax, 1.0, uv.x);\n\tvar bottom: f32 = smoothstep(0.0, aay, uv.y);\n\tvar top: f32 = 1.0 - smoothstep(1.0 - aay, 1.0, uv.y);\n\n\treturn left * right * bottom * top;\n}\n\nfn rotate(uv: vec2f, th: f32) -> vec2f {\n\n\treturn mat2x2f(vec2f(cos(th), sin(th)),vec2f(-sin(th), cos(th))) * uv;\n}\n\nfn seedOffset(salt: f32) -> vec2f {\n\n\tvar seeded: f32 = params.seed + salt;\n\treturn fract(\n\t\tsin(\n\t\t\tvec2f(\n\t\t\t\tseeded * 12.9898 + 78.233,\n\t\t\t\tseeded * 39.3468 + 11.135\n\t\t\t)\n\t\t) * 43758.5453\n\t);\n}\n\nfn randomR(p: vec2f) -> f32 {\n\n\tvar uv: vec2f = floor(p) / 100.0 + vec2f(0.5);\n\treturn textureLoad(noiseTexture,vec2i(floor(fract(uv)*vec2f(textureDimensions(noiseTexture)))),0).r;\n}\n\nfn valueNoise(st: vec2f) -> f32 {\n\n\tvar i: vec2f = floor(st);\n\tvar f: vec2f = fract(st);\n\tvar a: f32 = randomR(i);\n\tvar b: f32 = randomR(i + vec2f(1.0, 0.0));\n\tvar c: f32 = randomR(i + vec2f(0.0, 1.0));\n\tvar d: f32 = randomR(i + vec2f(1.0, 1.0));\n\tvar u: vec2f = f * f * (vec2f(3.0) - 2.0 * f);\n\tvar x1: f32 = mix(a, b, u.x);\n\tvar x2: f32 = mix(c, d, u.x);\n\treturn mix(x1, x2, u.y);\n}\n\nfn fbm(nInput: vec2f) -> f32 {\nvar n=nInput;\n\tvar total: f32 = 0.0;\n\tvar amplitude: f32 = 0.4;\n\tfor (var i: i32 = 0; i < 3; i++) {\n\t\ttotal += valueNoise(n) * amplitude;\n\t\tn *= 1.99;\n\t\tamplitude *= 0.65;\n\t}\n\treturn total;\n}\n\nfn randomG(p: vec2f) -> f32 {\n\n\tvar uv: vec2f = floor(p) / 50.0 + vec2f(0.5);\n\treturn textureLoad(noiseTexture,vec2i(floor(fract(uv)*vec2f(textureDimensions(noiseTexture)))),0).g;\n}\n\nfn roughnessNoise(pInput: vec2f) -> f32 {\nvar p=pInput;\n\tp *= 0.1;\n\tvar o: f32 = 0.0;\n\tfor (var i: f32 = 1.0; i < 4.0; i += 1.0) {\n\t\tvar w: vec4f = vec4f(floor(p), ceil(p));\n\t\tvar f: vec2f = fract(p);\n\t\to += mix(\n\t\t\tmix(randomG(w.xy), randomG(w.xw), f.y),\n\t\t\tmix(randomG(w.zy), randomG(w.zw), f.y),\n\t\t\tf.x\n\t\t);\n\t\to += 0.2 / exp(2.0 * abs(sin(0.2 * p.x + 0.5 * p.y)));\n p *= 2.1;\n\t}\n\treturn o / 3.0;\n}\n\nfn fiberRandom(p: vec2f) -> f32 {\n\n\tvar uv: vec2f = floor(p) / 100.0;\n\treturn textureLoad(noiseTexture,vec2i(floor(fract(uv)*vec2f(textureDimensions(noiseTexture)))),0).b;\n}\n\nfn fiberValueNoise(st: vec2f) -> f32 {\n\n\tvar i: vec2f = floor(st);\n\tvar f: vec2f = fract(st);\n\tvar a: f32 = fiberRandom(i);\n\tvar b: f32 = fiberRandom(i + vec2f(1.0, 0.0));\n\tvar c: f32 = fiberRandom(i + vec2f(0.0, 1.0));\n\tvar d: f32 = fiberRandom(i + vec2f(1.0, 1.0));\n\tvar u: vec2f = f * f * (vec2f(3.0) - 2.0 * f);\n\tvar x1: f32 = mix(a, b, u.x);\n\tvar x2: f32 = mix(c, d, u.x);\n\treturn mix(x1, x2, u.y);\n}\n\nfn fiberNoiseFbm(nInput: vec2f, seedOffset: vec2f) -> f32 {\nvar n=nInput;\n\tvar total: f32 = 0.0;\n\tvar amplitude: f32 = 1.0;\n\tfor (var i: i32 = 0; i < 4; i++) {\n\t\tn = rotate(n, 0.7);\n\t\ttotal += fiberValueNoise(n + seedOffset) * amplitude;\n\t\tn *= 2.0;\n\t\tamplitude *= 0.6;\n\t}\n\treturn total;\n}\n\nfn fiberNoise(uv: vec2f, seedOffset: vec2f) -> f32 {\n\n\tvar epsilon: f32 = 0.001;\n\tvar n1: f32 = fiberNoiseFbm(uv + vec2f(epsilon, 0.0), seedOffset);\n\tvar n2: f32 = fiberNoiseFbm(uv - vec2f(epsilon, 0.0), seedOffset);\n\tvar n3: f32 = fiberNoiseFbm(uv + vec2f(0.0, epsilon), seedOffset);\n\tvar n4: f32 = fiberNoiseFbm(uv - vec2f(0.0, epsilon), seedOffset);\n\treturn length(vec2f(n1 - n2, n3 - n4)) / (2.0 * epsilon);\n}\n\nfn randomGB(p: vec2f) -> vec2f {\n\n\tvar uv: vec2f = floor(p) / 50.0 + vec2f(0.5);\n\treturn textureLoad(noiseTexture,vec2i(floor(fract(uv)*vec2f(textureDimensions(noiseTexture)))),0).gb;\n}\n\nfn crumpledNoise(t: vec2f, pw: f32) -> f32 {\n\n\tvar p: vec2f = floor(t);\n\tvar wsum: f32 = 0.0;\n\tvar cl: f32 = 0.0;\n\tfor (var y: i32 = -1; y < 2; y += 1) {\n\t\tfor (var x: i32 = -1; x < 2; x += 1) {\n\t\t\tvar b: vec2f = vec2f(f32(x), f32(y));\n\t\t\tvar q: vec2f = b + p;\n\t\t\tvar q2: vec2f = q - floor(q / 8.0) * 8.0;\n\t\t\tvar c: vec2f = q + randomGB(q2);\n\t\t\tvar r: vec2f = c - t;\n\t\t\tvar w: f32 =\n\t\t\t\tpow(smoothstep(0.0, 1.0, 1.0 - abs(r.x)), pw) *\n\t\t\t\tpow(smoothstep(0.0, 1.0, 1.0 - abs(r.y)), pw);\n\t\t\tcl += (0.5 + 0.5 * sin((q2.x + q2.y * 5.0) * 8.0)) * w;\n\t\t\twsum += w;\n\t\t}\n\t}\n\treturn pow(select(0.0, cl / select(1.0, wsum, wsum != 0.0), wsum != 0.0), 0.5) * 2.0;\n}\n\nfn crumplesShape(uv: vec2f) -> f32 {\n\n\treturn crumpledNoise(uv * 0.25, 16.0) * crumpledNoise(uv * 0.5, 2.0);\n}\n\nfn folds(uv: vec2f) -> vec2f {\n\n\tvar pp: vec3f = vec3f(0.0);\n\tvar l: f32 = 9.0;\n\tfor (var i: f32 = 0.0; i < 15.0; i += 1.0) {\n\t\tif (i >= params.foldCount) {\n\t\t\tbreak;\n\t\t}\n\t\tvar rand: vec2f = randomGB(vec2f(i, i * params.seed));\n\t\tvar an: f32 = rand.x * TWO_PI;\n\t\tvar p: vec2f = vec2f(cos(an), sin(an)) * rand.y;\n\t\tvar dist: f32 = distance(uv, p);\n\t\tl = min(l, dist);\n\n\t\tif (l == dist) {\n\t\t\tpp = vec3f(uv-p,pp.z);\n\t\t\tpp.z = dist;\n\t\t}\n\t}\n\treturn mix(pp.xy, vec2f(0.0), pow(pp.z, 0.25));\n}\n\nfn drops(uv: vec2f) -> f32 {\n\n\tvar iDropsUV: vec2f = floor(uv);\n\tvar fDropsUV: vec2f = fract(uv);\n\tvar dropsMinDist: f32 = 1.0;\n\tfor (var j: i32 = -1; j <= 1; j++) {\n\t\tfor (var i: i32 = -1; i <= 1; i++) {\n\t\t\tvar neighbor: vec2f = vec2f(f32(i), f32(j));\n\t\t\tvar offset: vec2f = randomGB(iDropsUV + neighbor);\n\t\t\toffset = vec2f(0.5) + 0.5 * sin(vec2f(10.0 * params.seed) + TWO_PI * offset);\n\t\t\tvar pos: vec2f = neighbor + offset - fDropsUV;\n\t\t\tvar dist: f32 = length(pos);\n\t\t\tdropsMinDist = min(dropsMinDist, dropsMinDist * dist);\n\t\t}\n\t}\n\treturn 1.0 - smoothstep(0.05, 0.09, pow(dropsMinDist, 0.5));\n}\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let pixel=vec2f(input.position.x,params.size.y+params.offsetY-input.position.y);\n let vUv=pixel/params.size;\n\tvar color: vec4f = textureSampleLevel(source,sourceSampler,vec2f(vUv.x,1.0-vUv.y),0);\n\tvar sourceAlpha: f32 = color.a;\n\n\tif (sourceAlpha <= 0.001 || params.amount <= 0.0) {\n\t\treturn color;\n\t}\n\n\tvar sourceRgb: vec3f = color.rgb / sourceAlpha;\n\tvar imageUV: vec2f = vUv;\n\tvar patternUV: vec2f = vUv - vec2f(0.5);\n\tpatternUV /= max(params.scale, 0.001);\n\tpatternUV = 5.0 * (patternUV * vec2f(params.aspectRatio, 1.0));\n\n\tvar roughnessUv: vec2f =\n\t\t1.5 * (pixel - 0.5 * params.size) +\n\t\t128.0 * seedOffset(1.0);\n\tvar roughness: f32 =\n\t\troughnessNoise(roughnessUv + vec2f(1.0, 0.0)) -\n\t\troughnessNoise(roughnessUv - vec2f(1.0, 0.0));\n\n\tvar crumplesUV: vec2f =\n\t\tfract(patternUV * 0.02 / max(params.crumpleSize, 0.001) - vec2f(params.seed)) * 32.0;\n\tvar crumples: f32 =\n\t\tparams.crumples *\n\t\t(crumplesShape(crumplesUV + vec2f(0.05, 0.0)) -\n\t\t\tcrumplesShape(crumplesUV));\n\n\tvar fiberUV: vec2f = 2.0 / max(params.fiberSize, 0.001) * patternUV;\n\tvar fiber: f32 = fiberNoise(fiberUV, 64.0 * seedOffset(2.0));\n\tfiber = 0.5 * params.fiber * (fiber - 1.0);\n\n\tvar normal: vec2f = vec2f(0.0);\n\tvar normalImage: vec2f = vec2f(0.0);\n\n\tvar foldsUV: vec2f = patternUV * 0.12;\n\tfoldsUV = rotate(foldsUV, 4.0 * params.seed);\n\tvar w: vec2f = folds(foldsUV);\n\tfoldsUV = rotate(foldsUV + vec2f(0.007 * cos(params.seed)), 0.01 * sin(params.seed));\n\tvar w2: vec2f = folds(foldsUV);\n\n\tvar dropPattern: f32 = params.drops * drops(patternUV * 2.0);\n\n\tvar fade: f32 = params.fade * fbm(0.17 * patternUV + vec2f(10.0 * params.seed));\n\tfade = clamp(8.0 * fade * fade * fade, 0.0, 1.0);\n\n\tw = mix(w, vec2f(0.0), fade);\n\tw2 = mix(w2, vec2f(0.0), fade);\n\tcrumples = mix(crumples, 0.0, fade);\n\tdropPattern = mix(dropPattern, 0.0, fade);\n\tfiber *= mix(1.0, 0.5, fade);\n\troughness *= mix(1.0, 0.5, fade);\n\n\tnormal += params.folds * min(5.0 * params.contrast, 1.0) * 4.0 * max(vec2f(0.0), w + w2);\n\tnormalImage += params.folds * 2.0 * w;\n\tnormal += vec2f(crumples);\n\tnormalImage += vec2f(1.5 * crumples);\n\tnormal += vec2f(3.0 * dropPattern);\n\tnormalImage += vec2f(0.2 * dropPattern);\n\tnormal += vec2f(params.roughness * 1.5 * roughness);\n\tnormal += vec2f(fiber);\n\tnormalImage += vec2f(params.roughness * 0.75 * roughness);\n\tnormalImage += vec2f(0.2 * fiber);\n\n\tvar lightPos: vec3f = vec3f(1.0, 2.0, 1.0);\n\tvar res: f32 = dot(\n\t\tnormalize(vec3f(normal, 9.5 - 9.0 * pow(params.contrast, 0.1))),\n\t\tnormalize(lightPos)\n\t);\n\n\timageUV += 0.02 * normalImage;\n\tvar frame: f32 = getUvFrame(imageUV);\n\tvar displacedSource: vec4f = textureSampleLevel(source,sourceSampler,clamp(vec2f(imageUV.x,1.0-imageUV.y),vec2f(0),vec2f(1)),0);\n\tvar displacedRgb: vec3f = select(sourceRgb,displacedSource.rgb / max(displacedSource.a,0.001),displacedSource.a > 0.001);\n\tdisplacedRgb += vec3f(0.6 * pow(params.contrast, 0.4) * (res - 0.7));\n\n\tvar frontRgb: vec3f = mix(vec3f(1.0), params.colorFront.rgb, params.colorFront.a);\n\tvar backRgb: vec3f = mix(vec3f(1.0), params.colorBack.rgb, params.colorBack.a);\n\tvar paperTone: vec3f = mix(backRgb, frontRgb, clamp(res, 0.0, 1.0));\n\tvar texturedRgb: vec3f = displacedRgb * (0.72 + 0.42 * res);\n\ttexturedRgb = mix(texturedRgb, texturedRgb * paperTone, 0.65);\n\ttexturedRgb -= vec3f(0.007 * dropPattern);\n\ttexturedRgb = mix(sourceRgb, texturedRgb, frame);\n\n\tvar finalRgb: vec3f = mix(sourceRgb, clamp(texturedRgb, vec3f(0.0), vec3f(1.0)), params.amount);\n\treturn vec4f(finalRgb * sourceAlpha, sourceAlpha);\n}\n\n";
|
|
2
|
+
export declare const PAPER_CROP_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: vec4f;\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n return textureLoad(source,vec2i(input.position.xy)+vec2i(0,1),0);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PATTERN_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var sourceTexture: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params {\n geometry: vec4f,\n crop: vec4f,\n gapOffset: vec4f,\n stagger: vec4f,\n origin: vec4f,\n}\nfn sampleSource(uv: vec2f) -> vec4f {\n return textureSampleLevel(sourceTexture, sourceSampler, vec2f(uv.x, 1.0 - uv.y), 0);\n}\nfn glslModulo(value: f32, divisor: f32) -> f32 { return value - divisor * floor(value / divisor); }\n\nfn getPhase(index: f32, every: f32) -> f32 {\n if (every == 0.0) { return index; }\n return glslModulo(glslModulo(index, every) + every, every);\n}\nstruct CellSample {valid: bool, color: vec4f,}\nfn sampleCell(cell: vec2f, fragPx: vec2f, cropStart: vec2f, tileSize: vec2f, pitch: vec2f, originPx: vec2f) -> CellSample {\n if (params.geometry.w == 0.0 && (cell.x < 0.0 || cell.y < 0.0)) { return CellSample(false, vec4f(0)); }\n let rowPhase = getPhase(cell.y, params.stagger.y);\n let columnPhase = getPhase(cell.x, params.stagger.w);\n let stagger = vec2f(rowPhase * params.stagger.x, columnPhase * params.stagger.z);\n let localPx = fragPx - originPx - stagger - cell * pitch;\n if (localPx.x < 0.0 || localPx.y < 0.0 || localPx.x >= tileSize.x || localPx.y >= tileSize.y) { return CellSample(false, vec4f(0)); }\n let sourcePx = cropStart + localPx / params.geometry.z;\n let sourceUv = vec2f(sourcePx.x / params.geometry.x, 1.0 - sourcePx.y / params.geometry.y);\n if (sourceUv.x < 0.0 || sourceUv.y < 0.0 || sourceUv.x > 1.0 || sourceUv.y > 1.0) { return CellSample(false, vec4f(0)); }\n return CellSample(true, sampleSource(sourceUv));\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let vUv = vec2f(input.uv.x, 1.0 - input.uv.y);\n\n let cropStart = params.crop.xy;\n let cropEnd = params.geometry.xy - params.crop.zw;\n let cropSize = max(cropEnd - cropStart, vec2f(0.001));\n let tileSize = max(cropSize * params.geometry.z, vec2f(0.001));\n let pitch = max(tileSize + params.gapOffset.xy, vec2f(0.001));\n let originPx = (params.origin.xy + params.gapOffset.zw) * params.geometry.xy;\n let fragPx = input.position.xy;\n var cell = floor((fragPx - originPx) / pitch);\n for (var i = 0; i < 4; i++) {\n let rowPhase = getPhase(cell.y, params.stagger.y);\n let columnPhase = getPhase(cell.x, params.stagger.w);\n let stagger = vec2f(rowPhase * params.stagger.x, columnPhase * params.stagger.z);\n let nextCell = floor((fragPx - originPx - stagger) / pitch);\n if (all(nextCell == cell)) { break; }\n cell = nextCell;\n }\n for (var y = -4; y <= 4; y++) {\n for (var x = -4; x <= 4; x++) {\n let result = sampleCell(cell + vec2f(f32(x), f32(y)), fragPx, cropStart, tileSize, pitch, originPx);\n if (result.valid) { return result.color; }\n }\n }\n return vec4f(0);\n\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PIXEL_DISSOLVE_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n\nstruct Params { progress: f32, columns: f32, rows: f32, seed: f32, feather: f32, }\n\nfn hash21(p: vec2f) -> f32 {\n var p3 = fract(p.xyx * vec3f(443.8975, 397.2973, 491.1871));\n p3 += vec3f(dot(p3, p3.yzx + vec3f(19.19)));\n return fract((p3.x + p3.y) * p3.z);\n}\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let divisions = max(vec2f(params.columns, params.rows), vec2f(1));\n let uv = vec2f(input.uv.x, 1.0 - input.uv.y);\n let cell = floor(min(uv, vec2f(1.0 - 0.000001)) * divisions + vec2f(0.00001));\n let color = textureSampleLevel(source, sourceSampler, input.uv, 0);\n let noise = hash21(cell + vec2f(params.seed, params.seed * 1.618));\n let edge = max(params.feather, 0.0);\n let threshold = 1.0 - clamp(params.progress, 0.0, 1.0) * (1.0 + edge);\n var mask: f32;\n if (edge <= 0.0001) { mask = 1.0 - step(threshold, noise); }\n else { mask = 1.0 - smoothstep(threshold, threshold + edge, noise); }\n return color * mask;\n}\n\n";
|
|
@@ -30,3 +30,4 @@ export declare const prepareProgressivePixelate: ({ state, source, width, height
|
|
|
30
30
|
}) => void;
|
|
31
31
|
export declare const drawProgressivePixelate: (state: ProgressivePixelateState) => void;
|
|
32
32
|
export declare const cleanupProgressivePixelate: ({ gl, program, vao, vbo, texture, }: ProgressivePixelateState) => void;
|
|
33
|
+
export declare const PROGRESSIVE_PIXELATE_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\nstruct Params {\n resolutionModeBlock: vec4f,\n startEnd: vec4f,\n centerSize: vec4f,\n controls: vec4f,\n}\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nfn linearProgress(uv: vec2f) -> f32 {\n let gradient = params.startEnd.zw - params.startEnd.xy;\n let gradientLengthSq = dot(gradient, gradient);\n if (gradientLengthSq <= 0.0000001) { return 0.0; }\n return clamp(dot(uv - params.startEnd.xy, gradient) / gradientLengthSq, 0.0, 1.0);\n}\nfn radialProgress(uv: vec2f) -> f32 {\n let radii = params.centerSize.zw * params.resolutionModeBlock.xy * 0.5;\n if (radii.x <= 0.0000001 || radii.y <= 0.0000001) { return 0.0; }\n let delta = (uv - params.centerSize.xy) * params.resolutionModeBlock.xy;\n let angle = radians(params.controls.x);\n let c = cos(angle);\n let s = sin(angle);\n let local = vec2f(c * delta.x + s * delta.y, -s * delta.x + c * delta.y);\n let ellipseProgress = clamp(length(local / radii), 0.0, 1.0);\n let distance = 1.0 - params.controls.y;\n if (abs(distance) <= 0.0000001) { return step(params.controls.y, ellipseProgress); }\n return clamp((ellipseProgress - params.controls.y) / distance, 0.0, 1.0);\n}\nfn samplePixelated(uv: vec2f, blockSize: f32) -> vec4f {\n let pixelSizeUv = vec2f(blockSize) / params.resolutionModeBlock.xy;\n let blockUv = floor(uv / pixelSizeUv) * pixelSizeUv + pixelSizeUv * 0.5;\n return textureSampleLevel(source, sourceSampler, vec2f(blockUv.x, 1.0 - blockUv.y), 0);\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n var progress: f32;\n if (params.resolutionModeBlock.z == 0.0) { progress = linearProgress(input.uv); }\n else { progress = radialProgress(input.uv); }\n let targetBlockSize = max(1.0, mix(params.resolutionModeBlock.w, params.controls.z, progress));\n let level = log2(targetBlockSize);\n let lowerBlockSize = exp2(floor(level));\n let upperBlockSize = lowerBlockSize * 2.0;\n let levelProgress = fract(level);\n let uv = vec2f(input.uv.x, 1.0 - input.uv.y);\n return mix(samplePixelated(uv, lowerBlockSize), samplePixelated(uv, upperBlockSize), levelProgress);\n}\n";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const DIRECTIONS: readonly ['clockwise', 'counterclockwise', 'both'];
|
|
2
|
+
export type RadialWipeDirection = (typeof DIRECTIONS)[number];
|
|
3
|
+
export type RadialWipeCenter = readonly [number, number];
|
|
4
|
+
export type RadialWipeParams = {
|
|
5
|
+
/** Wipe progress from `0` (visible) to `1` (erased). Defaults to `0`. */
|
|
6
|
+
readonly progress?: number;
|
|
7
|
+
/** Start angle in degrees clockwise from up. Defaults to `0`. */
|
|
8
|
+
readonly startAngle?: number;
|
|
9
|
+
/** Normalized center from `[0, 0]` (top left) to `[1, 1]` (bottom right). Defaults to `[0.5, 0.5]`. */
|
|
10
|
+
readonly center?: RadialWipeCenter;
|
|
11
|
+
/** Sweep direction. `both` erases on both sides of the start angle. Defaults to `clockwise`. */
|
|
12
|
+
readonly direction?: RadialWipeDirection;
|
|
13
|
+
/** Width of the soft sweep edge in degrees, from `0` to `360`. Defaults to `0`. */
|
|
14
|
+
readonly feather?: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const radialWipe: (params?: (RadialWipeParams & {
|
|
17
|
+
readonly disabled?: boolean;
|
|
18
|
+
}) | undefined) => import("remotion").EffectDescriptor<unknown>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { type WeatherCommonParams } from './weather/params.js';
|
|
2
|
+
export type RainFallParams = WeatherCommonParams & {
|
|
3
|
+
/** Number of drops, an integer from `0` to `100000`. Defaults to `100000`. */
|
|
4
|
+
readonly drops?: number;
|
|
5
|
+
/** Refract the source color into each drop, or use a solid color. Defaults to `refracting`. */
|
|
6
|
+
readonly appearance?: 'refracting' | 'soft-solid';
|
|
7
|
+
};
|
|
8
|
+
export declare const rainFallSchema: {
|
|
9
|
+
readonly time: {
|
|
10
|
+
readonly type: 'number';
|
|
11
|
+
readonly min: 0;
|
|
12
|
+
readonly max: 10;
|
|
13
|
+
readonly step: 0.01;
|
|
14
|
+
readonly default: number;
|
|
15
|
+
readonly description: 'Time';
|
|
16
|
+
readonly hiddenFromList: false;
|
|
17
|
+
};
|
|
18
|
+
readonly size: {
|
|
19
|
+
readonly type: 'number';
|
|
20
|
+
readonly min: 0;
|
|
21
|
+
readonly max: 50;
|
|
22
|
+
readonly step: 0.01;
|
|
23
|
+
readonly default: number;
|
|
24
|
+
readonly description: 'Size';
|
|
25
|
+
readonly hiddenFromList: false;
|
|
26
|
+
};
|
|
27
|
+
readonly sceneDepth: {
|
|
28
|
+
readonly type: 'number';
|
|
29
|
+
readonly min: 0;
|
|
30
|
+
readonly max: 20000;
|
|
31
|
+
readonly step: 1;
|
|
32
|
+
readonly default: number;
|
|
33
|
+
readonly description: 'Scene depth';
|
|
34
|
+
readonly hiddenFromList: false;
|
|
35
|
+
};
|
|
36
|
+
readonly speed: {
|
|
37
|
+
readonly type: 'number';
|
|
38
|
+
readonly min: 0;
|
|
39
|
+
readonly max: number;
|
|
40
|
+
readonly step: 1;
|
|
41
|
+
readonly default: number;
|
|
42
|
+
readonly description: 'Speed';
|
|
43
|
+
readonly hiddenFromList: false;
|
|
44
|
+
};
|
|
45
|
+
readonly wind: {
|
|
46
|
+
readonly type: 'number';
|
|
47
|
+
readonly min: number;
|
|
48
|
+
readonly max: number;
|
|
49
|
+
readonly step: 1;
|
|
50
|
+
readonly default: number;
|
|
51
|
+
readonly description: 'Wind';
|
|
52
|
+
readonly hiddenFromList: false;
|
|
53
|
+
};
|
|
54
|
+
readonly windVariation: {
|
|
55
|
+
readonly type: 'number';
|
|
56
|
+
readonly min: 0;
|
|
57
|
+
readonly max: 1;
|
|
58
|
+
readonly step: 0.01;
|
|
59
|
+
readonly default: number;
|
|
60
|
+
readonly description: 'Wind variation';
|
|
61
|
+
readonly hiddenFromList: false;
|
|
62
|
+
};
|
|
63
|
+
readonly spread: {
|
|
64
|
+
readonly type: 'number';
|
|
65
|
+
readonly min: 0;
|
|
66
|
+
readonly max: 1000;
|
|
67
|
+
readonly step: 1;
|
|
68
|
+
readonly default: number;
|
|
69
|
+
readonly description: 'Spread';
|
|
70
|
+
readonly hiddenFromList: false;
|
|
71
|
+
};
|
|
72
|
+
readonly opacity: {
|
|
73
|
+
readonly type: 'number';
|
|
74
|
+
readonly min: 0;
|
|
75
|
+
readonly max: 1;
|
|
76
|
+
readonly step: 0.01;
|
|
77
|
+
readonly default: number;
|
|
78
|
+
readonly description: 'Opacity';
|
|
79
|
+
readonly hiddenFromList: false;
|
|
80
|
+
};
|
|
81
|
+
readonly color: {
|
|
82
|
+
readonly type: 'color';
|
|
83
|
+
readonly default: string;
|
|
84
|
+
readonly description: 'Color';
|
|
85
|
+
};
|
|
86
|
+
readonly transferMode: {
|
|
87
|
+
readonly type: 'enum';
|
|
88
|
+
readonly variants: {
|
|
89
|
+
readonly composite: {};
|
|
90
|
+
readonly lighten: {};
|
|
91
|
+
};
|
|
92
|
+
readonly default: "composite" | "lighten";
|
|
93
|
+
readonly description: 'Transfer mode';
|
|
94
|
+
};
|
|
95
|
+
readonly compositeWithOriginal: {
|
|
96
|
+
readonly type: 'boolean';
|
|
97
|
+
readonly default: boolean;
|
|
98
|
+
readonly description: 'Composite with original';
|
|
99
|
+
};
|
|
100
|
+
readonly offset: {
|
|
101
|
+
readonly type: 'uv-coordinate';
|
|
102
|
+
readonly step: 0.01;
|
|
103
|
+
readonly default: readonly [number, number];
|
|
104
|
+
readonly description: 'Offset';
|
|
105
|
+
};
|
|
106
|
+
readonly seed: {
|
|
107
|
+
readonly type: 'number';
|
|
108
|
+
readonly min: 0;
|
|
109
|
+
readonly max: 4294967295;
|
|
110
|
+
readonly step: 1;
|
|
111
|
+
readonly integer: true;
|
|
112
|
+
readonly default: number;
|
|
113
|
+
readonly description: 'Seed';
|
|
114
|
+
readonly hiddenFromList: false;
|
|
115
|
+
};
|
|
116
|
+
readonly drops: {
|
|
117
|
+
readonly type: 'number';
|
|
118
|
+
readonly min: 0;
|
|
119
|
+
readonly max: 100000;
|
|
120
|
+
readonly step: 1;
|
|
121
|
+
readonly integer: true;
|
|
122
|
+
readonly default: 100000;
|
|
123
|
+
readonly description: 'Drops';
|
|
124
|
+
readonly hiddenFromList: false;
|
|
125
|
+
};
|
|
126
|
+
readonly appearance: {
|
|
127
|
+
readonly type: 'enum';
|
|
128
|
+
readonly variants: {
|
|
129
|
+
readonly refracting: {};
|
|
130
|
+
readonly 'soft-solid': {};
|
|
131
|
+
};
|
|
132
|
+
readonly default: "refracting";
|
|
133
|
+
readonly description: 'Appearance';
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
export declare const rainFall: (params?: (WeatherCommonParams & {
|
|
137
|
+
/** Number of drops, an integer from `0` to `100000`. Defaults to `100000`. */
|
|
138
|
+
readonly drops?: number;
|
|
139
|
+
/** Refract the source color into each drop, or use a solid color. Defaults to `refracting`. */
|
|
140
|
+
readonly appearance?: 'refracting' | 'soft-solid';
|
|
141
|
+
} & {
|
|
142
|
+
readonly disabled?: boolean;
|
|
143
|
+
}) | undefined) => import("remotion").EffectDescriptor<unknown>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type DestinationRect = {
|
|
2
|
+
readonly x: number;
|
|
3
|
+
readonly y: number;
|
|
4
|
+
readonly width: number;
|
|
5
|
+
readonly height: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const createRectTransformImplementations: <P>(label: string, getRect: (params: P, width: number, height: number) => DestinationRect) => {
|
|
8
|
+
webgl2: import("remotion").EffectImplementation<P, unknown>;
|
|
9
|
+
webgpu: import("remotion").EffectImplementation<P, unknown>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const REGION_BLUR_WEBGPU_SHADER = "\n\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var secondary: texture_2d<f32>;\n\nstruct Params {resolution: vec2f, feather: f32, roundness: f32, corners: vec4f,}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let minimum = params.corners.xy * params.resolution;\n let maximum = params.corners.zw * params.resolution;\n let halfSize = (maximum - minimum) * 0.5;\n let center = (minimum + maximum) * 0.5;\n let radius = min(halfSize.x, halfSize.y) * params.roundness;\n let offset = abs(input.uv * params.resolution - center) - halfSize + vec2f(radius);\n let distance = length(max(offset, vec2f(0))) + min(max(offset.x, offset.y), 0.0) - radius;\n var mask = select(0.0, 1.0, distance <= 0.0);\n if (params.feather > 0.0) {mask = 1.0 - smoothstep(-params.feather * 0.5, params.feather * 0.5, distance);}\n return mix(textureSampleLevel(source, sourceSampler, input.uv, 0), textureSampleLevel(secondary, sourceSampler, input.uv, 0), mask);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RINGS_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var sourceTexture: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var palette: texture_2d<f32>;\nstruct Params {\n geometry: vec4f,\n stripe: vec4f,\n center: vec4f,\n flags: vec4f,\n}\nfn sampleSource(uv: vec2f) -> vec4f {\n return textureSampleLevel(sourceTexture, sourceSampler, vec2f(uv.x, 1.0 - uv.y), 0);\n}\nfn glslModulo(value: f32, divisor: f32) -> f32 { return value - divisor * floor(value / divisor); }\nfn paletteColor(index: f32) -> vec4f { return textureLoad(palette, vec2i(i32(index), 0), 0); }\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let vUv = vec2f(input.uv.x, 1.0 - input.uv.y);\n\n let texColor = sampleSource(vUv);\n let thickness = max(params.stripe.x, 0.001);\n let spacing = max(params.stripe.y, 0.001);\n let cycle = spacing * params.geometry.z;\n let pixelPosition = vec2f(input.position.x, params.geometry.y - input.position.y);\n let centerPosition = params.center.xy * params.geometry.xy;\n let radius = length(pixelPosition - centerPosition);\n var position = glslModulo(radius + params.stripe.w, cycle);\n if (position < 0.0) { position += cycle; }\n let colorIndex = floor(position / spacing);\n let inStripe = glslModulo(position, spacing);\n if (inStripe > thickness) { return texColor; }\n\n let overlay = paletteColor(colorIndex);\n let premultiplied = overlay.rgb * overlay.a;\n if (params.flags.x != 0.0) {\n return vec4f(premultiplied * texColor.a + texColor.rgb * (1.0 - overlay.a), texColor.a);\n }\n return vec4f(premultiplied + texColor.rgb * (1.0 - overlay.a), overlay.a + texColor.a * (1.0 - overlay.a));\n\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ROUGHEN_EDGES_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n\nstruct Params { size: vec2f, amount: f32, border: f32, scale: f32, seed: f32, }\n@group(0) @binding(3) var noiseTexture: texture_2d<f32>;\nfn sampleSource(uv: vec2f) -> vec4f { return textureSampleLevel(source,sourceSampler,clamp(vec2f(uv.x,1.0-uv.y),vec2f(0),vec2f(1)),0); }\nfn sampleAlpha(uv: vec2f) -> f32 { return sampleSource(uv).a; }\nfn seedOffset(salt: f32) -> vec2f {\n let seeded=params.seed+salt;\n return fract(sin(vec2f(seeded*12.9898+78.233,seeded*39.3468+11.135))*43758.5453);\n}\nfn randomR(p: vec2f) -> f32 {\n let uv=fract(floor(p)/100.0+vec2f(0.5));\n return textureLoad(noiseTexture,vec2i(floor(uv*vec2f(textureDimensions(noiseTexture)))),0).r;\n}\nfn valueNoise(st: vec2f) -> f32 {\n let i=floor(st); let f=fract(st); let u=f*f*(vec2f(3.0)-2.0*f);\n let a=randomR(i);let b=randomR(i+vec2f(1,0));let c=randomR(i+vec2f(0,1));let d=randomR(i+vec2f(1,1));\n return mix(mix(a,b,u.x),mix(c,d,u.x),u.y);\n}\nfn fbm(point: vec2f) -> f32 {\n var n=point; var total=0.0; var amplitude=0.5;\n for(var i=0;i<4;i++) { total += valueNoise(n)*amplitude; n *= 2.03; amplitude *= 0.55; }\n return total;\n}\nfn edgeProximity(uv: vec2f,alpha: f32) -> f32 {\n if(params.border<=0.0) { return 0.0; }\n let reach=vec2f(max(params.border,1.0))/params.size;\n var minAlpha=alpha;var maxAlpha=alpha;\n for(var y=-1;y<=1;y++) { for(var x=-1;x<=1;x++) {\n let a=sampleAlpha(uv+vec2f(f32(x),f32(y))*reach);minAlpha=min(minAlpha,a);maxAlpha=max(maxAlpha,a);\n } }\n return smoothstep(0.02,0.35,maxAlpha-minAlpha);\n}\nfn alphaGradient(uv: vec2f) -> vec2f {\n let reach=vec2f(max(params.border*0.25,1.0))/params.size;\n return vec2f(sampleAlpha(uv+vec2f(reach.x,0))-sampleAlpha(uv-vec2f(reach.x,0)),sampleAlpha(uv+vec2f(0,reach.y))-sampleAlpha(uv-vec2f(0,reach.y)));\n}\nfn edgeNoise(uv: vec2f,salt: f32) -> f32 {\n var patternUV=uv-vec2f(0.5);\n patternUV *= vec2f(params.size.x/max(params.size.y,1.0),1.0);\n patternUV *= 7.0/max(params.scale,0.001);\n patternUV += 64.0*seedOffset(salt);\n return fbm(patternUV);\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let uv=vec2f(input.uv.x,1.0-input.uv.y);\n let color=sampleSource(uv);\n if(params.amount<=0.0 || params.border<=0.0) { return color; }\n let proximity=edgeProximity(uv,color.a);\n if(proximity<=0.001) { return color; }\n let gradient=alphaGradient(uv);\n let noiseVector=vec2f(edgeNoise(uv+vec2f(0.17,0),2.0),edgeNoise(uv+vec2f(0,0.31),3.0))*2.0-vec2f(1.0);\n var direction=gradient+0.7*noiseVector;\n if(length(direction)<=0.0001) { direction=select(noiseVector,vec2f(1,0),length(noiseVector)<=0.0001); }\n direction=normalize(direction);\n let scalar=edgeNoise(uv,4.0)*2.0-1.0;\n let offset=direction*scalar*params.border/params.size;\n return mix(color,sampleSource(uv+offset),clamp(proximity*params.amount,0.0,1.0));\n}\n\n";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ShatterGeometryParams = {
|
|
2
|
+
time: number;
|
|
3
|
+
pattern: 'bricks' | 'glass' | 'hexagons' | 'squares' | 'triangles';
|
|
4
|
+
repetitions: number;
|
|
5
|
+
direction: number;
|
|
6
|
+
origin: readonly [number, number];
|
|
7
|
+
center: readonly [number, number];
|
|
8
|
+
radius: number;
|
|
9
|
+
depth: number;
|
|
10
|
+
strength: number;
|
|
11
|
+
rotationSpeed: number;
|
|
12
|
+
randomness: number;
|
|
13
|
+
viscosity: number;
|
|
14
|
+
massVariance: number;
|
|
15
|
+
gravity: number;
|
|
16
|
+
seed: number;
|
|
17
|
+
extrusionDepth: number;
|
|
18
|
+
};
|
|
19
|
+
export declare const createShatterGeometry: (width: number, height: number, params: ShatterGeometryParams) => Float32Array;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ShatterGeometryParams } from './geometry.js';
|
|
2
|
+
export type ShatterPattern = ShatterGeometryParams['pattern'];
|
|
3
|
+
export type ShatterParams = {
|
|
4
|
+
/** Elapsed simulation time in seconds. Must be nonnegative. Defaults to 0.5. */
|
|
5
|
+
readonly time?: number;
|
|
6
|
+
/** Shape of the shards. Defaults to 'bricks'. */
|
|
7
|
+
readonly pattern?: ShatterPattern;
|
|
8
|
+
/** Number of pattern cells across the canvas width, from 1 to 100. Defaults to 10. */
|
|
9
|
+
readonly repetitions?: number;
|
|
10
|
+
/** Clockwise rotation of the pattern in degrees. Defaults to 0. */
|
|
11
|
+
readonly direction?: number;
|
|
12
|
+
/** Pattern origin as fractions of the canvas width and height. Defaults to [0.5, 0.5]. */
|
|
13
|
+
readonly origin?: readonly [number, number];
|
|
14
|
+
/** Force center as fractions of the canvas width and height. Defaults to [0.5, 0.5]. */
|
|
15
|
+
readonly center?: readonly [number, number];
|
|
16
|
+
/** Force sphere radius as a nonnegative fraction of the canvas width. Defaults to 0.4. */
|
|
17
|
+
readonly radius?: number;
|
|
18
|
+
/** Force depth in front of the canvas, as a fraction of its width. Defaults to 0.1. */
|
|
19
|
+
readonly depth?: number;
|
|
20
|
+
/** Radial force strength. Negative values pull shards inward. Defaults to 5. */
|
|
21
|
+
readonly strength?: number;
|
|
22
|
+
/** Nonnegative multiplier for shard rotation in turns per second. Defaults to 0.2. */
|
|
23
|
+
readonly rotationSpeed?: number;
|
|
24
|
+
/** Random variation in shard velocity, from 0 to 1. Defaults to 0.1. */
|
|
25
|
+
readonly randomness?: number;
|
|
26
|
+
/** Drag slowing shard motion and rotation, from 0 to 1. Defaults to 0.1. */
|
|
27
|
+
readonly viscosity?: number;
|
|
28
|
+
/** Variation in shard mass, from 0 to 1. Defaults to 0.3. */
|
|
29
|
+
readonly massVariance?: number;
|
|
30
|
+
/** Nonnegative downward acceleration, in tenths of the canvas width per second squared. Defaults to 3. */
|
|
31
|
+
readonly gravity?: number;
|
|
32
|
+
/** Integer random seed from 0 to 4294967295. Defaults to 0. */
|
|
33
|
+
readonly seed?: number;
|
|
34
|
+
/** Shard thickness as a fraction of the pattern cell size, from 0 to 1. Defaults to 0.05. */
|
|
35
|
+
readonly extrusionDepth?: number;
|
|
36
|
+
};
|
|
37
|
+
export declare const shatter: (params?: (ShatterParams & {
|
|
38
|
+
readonly disabled?: boolean;
|
|
39
|
+
}) | undefined) => import("remotion").EffectDescriptor<unknown>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ShatterState = {
|
|
2
|
+
readonly gl: WebGL2RenderingContext;
|
|
3
|
+
readonly program: WebGLProgram;
|
|
4
|
+
readonly vao: WebGLVertexArrayObject;
|
|
5
|
+
readonly vbo: WebGLBuffer;
|
|
6
|
+
readonly texture: WebGLTexture;
|
|
7
|
+
readonly uSource: WebGLUniformLocation | null;
|
|
8
|
+
readonly uResolution: WebGLUniformLocation | null;
|
|
9
|
+
};
|
|
10
|
+
export declare const setupShatter: (gl: WebGL2RenderingContext) => ShatterState;
|
|
11
|
+
export declare const drawShatter: ({ state, source, width, height, flipSourceY, vertices, }: {
|
|
12
|
+
readonly state: ShatterState;
|
|
13
|
+
readonly source: CanvasImageSource;
|
|
14
|
+
readonly width: number;
|
|
15
|
+
readonly height: number;
|
|
16
|
+
readonly flipSourceY: boolean;
|
|
17
|
+
readonly vertices: Float32Array;
|
|
18
|
+
}) => void;
|
|
19
|
+
export declare const cleanupShatter: ({ gl, program, vao, vbo, texture, }: ShatterState) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SHATTER_WEBGPU_SHADER = "\nstruct Params {resolution: vec2f,}\nstruct VertexOutput {\n @builtin(position) position: vec4f,\n @location(0) uv: vec2f,\n @location(1) shade: f32,\n @location(2) side: f32,\n}\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n@group(0) @binding(3) var<storage, read> vertices: array<f32>;\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n let offset=index*7u;\n let point=vec3f(vertices[offset],vertices[offset+1u],vertices[offset+2u]);\n let distance=max(params.resolution.x,params.resolution.y)*2.0;\n let near=distance*0.05;\n let w=distance+point.z;\n let position=vec2f((point.x-params.resolution.x*0.5)*2.0/params.resolution.x,(params.resolution.y*0.5-point.y)*2.0/params.resolution.y);\n var output: VertexOutput;\n // WebGPU's clip depth is [0,w], corresponding to WebGL's [-w,w].\n output.position=vec4f(position*vec2f(1,-1)*distance,w-near,w);\n output.uv=vec2f(vertices[offset+3u],vertices[offset+4u]);\n output.shade=vertices[offset+5u];output.side=vertices[offset+6u];\n return output;\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color=textureSample(source,sourceSampler,input.uv);\n return vec4f(mix(color.rgb,vec3f(color.a),input.side)*input.shade,color.a);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { shatter, type ShatterParams, type ShatterPattern, } from './shatter/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SHINE_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params {resolution: vec2f, normal: vec2f, band: vec4f, intensity: vec4f,}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color = textureSampleLevel(source, sourceSampler, input.uv, 0);\n let dist = dot(input.uv * params.resolution - params.resolution * 0.5, params.normal) - params.band.x;\n let halo = exp(-(dist*dist)/(params.band.y*params.band.y))*params.band.w;\n let core = exp(-(dist*dist)/(params.band.z*params.band.z))*params.intensity.x;\n let intensity = clamp(halo+core, 0.0, 1.0);\n return vec4f(color.rgb * (1.0-intensity)+vec3f(intensity*color.a), color.a);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SHRINKWRAP_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\nstruct Params { size: vec2f, amount: f32, displacement: f32, highlightIntensity: f32, wrinkleDensity: f32, edgeTension: f32, phase: f32, seed: f32, }\nfn hash21(p: vec2f) -> f32 {\n\tvar p3: vec3f = fract(vec3f(p.xyx) * vec3f(443.8975, 397.2973, 491.1871));\n\tp3 += vec3f(dot(p3, p3.yzx + vec3f(19.19) + vec3f(params.seed * 0.131)));\n\treturn fract((p3.x + p3.y) * p3.z);\n}\n\nfn valueNoise(p: vec2f) -> f32 {\n\tvar i: vec2f = floor(p);\n\tvar f: vec2f = fract(p);\n\tf = f * f * (vec2f(3.0) - 2.0 * f);\n\n\tvar a: f32 = hash21(i);\n\tvar b: f32 = hash21(i + vec2f(1.0, 0.0));\n\tvar c: f32 = hash21(i + vec2f(0.0, 1.0));\n\tvar d: f32 = hash21(i + vec2f(1.0, 1.0));\n\n\treturn mix(mix(a, b, f.x), mix(c, d, f.x), f.y);\n}\n\nfn fbm(point: vec2f) -> f32 {\n var p=point;\n\tvar value: f32 = 0.0;\n\tvar amplitude: f32 = 0.5;\n\n\tfor (var i: i32 = 0; i < 4; i++) {\n\t\tvalue += valueNoise(p) * amplitude;\n\t\tp = p * 2.03 + vec2f(17.1, 31.7);\n\t\tamplitude *= 0.5;\n\t}\n\n\treturn value;\n}\n\nfn rotate2d(angle: f32) -> mat2x2f {\n\tvar c: f32 = cos(angle);\n\tvar s: f32 = sin(angle);\n\treturn mat2x2f(vec2f(c,-s),vec2f(s,c));\n}\n\nfn phaseVec(xFactor: f32, yFactor: f32) -> vec2f {\n\treturn vec2f(params.phase * xFactor, params.phase * yFactor);\n}\n\nfn warpVec(p: vec2f, scale: f32, amount: f32, seedOffset: f32) -> vec2f {\n\treturn vec2f(\n\t\tfbm(p / scale + phaseVec(0.21, 0.13) + vec2f(seedOffset, 1.7)) - 0.5,\n\t\tfbm(p / scale + phaseVec(-0.17, 0.29) + vec2f(seedOffset + 9.1, 6.4))\n\t\t\t- 0.5\n\t) * amount;\n}\n\nfn bandField(coord: f32, spacing: f32, width: f32) -> f32 {\n\tvar centered: f32 = abs(fract(coord / spacing) - 0.5) * spacing;\n\treturn 1.0 - smoothstep(width, width * 3.8, centered);\n}\n\nfn curvedFoldField(px: vec2f, baseAngle: f32, spacing: f32, width: f32, seedOffset: f32) -> f32 {\n\tvar angleNoise: f32 =\n\t\t(fbm(px / (spacing * 5.8) + phaseVec(0.08, -0.11) + vec2f(seedOffset, 3.1))\n\t\t\t- 0.5) * 1.35;\n\tvar warped: vec2f = px + warpVec(\n\t\tpx + vec2f(seedOffset * 13.0, seedOffset * 7.0),\n\t\tspacing * 5.4,\n\t\tspacing * 0.95,\n\t\tseedOffset\n\t);\n\tvar q: vec2f = rotate2d(baseAngle + angleNoise) * warped;\n\tvar phase: f32 =\n\t\t(fbm(q / (spacing * 3.4) + phaseVec(-0.14, 0.19) + vec2f(seedOffset, 8.6))\n\t\t\t- 0.5) * spacing * 1.3;\n\tvar band: f32 = bandField(q.y + phase, spacing, width);\n\tvar breakup: f32 = smoothstep(\n\t\t0.24,\n\t\t0.88,\n\t\tfbm(\n\t\t\tvec2f(q.x / (spacing * 2.6), q.y / (spacing * 7.5)) +\n\t\t\t\tphaseVec(0.12, 0.07) +\n\t\t\t\tvec2f(seedOffset)\n\t\t)\n\t);\n\tvar softness: f32 =\n\t\t0.65 +\n\t\tfbm(q / (spacing * 8.2) + phaseVec(-0.05, 0.16) + vec2f(seedOffset, 2.3)) *\n\t\t\t0.35;\n\n\treturn band * breakup * softness;\n}\n\nfn edgeMask(uv: vec2f) -> f32 {\n\tvar pxFromEdge: vec2f = min(uv, vec2f(1.0) - uv) * params.size;\n\tvar minSide: f32 = min(params.size.x, params.size.y);\n\tvar side: f32 = 1.0 - smoothstep(0.0, minSide * 0.16, min(pxFromEdge.x, pxFromEdge.y));\n\tvar corner: f32 = 1.0 - smoothstep(\n\t\t0.0,\n\t\tminSide * 0.23,\n\t\tlength(pxFromEdge)\n\t);\n\n\treturn clamp(side * 0.55 + corner * 0.85, 0.0, 1.0);\n}\n\nfn heightMap(uv: vec2f) -> f32 {\n\tvar px: vec2f = uv * params.size;\n\tvar minSide: f32 = min(params.size.x, params.size.y);\n\tvar density: f32 = clamp(params.wrinkleDensity, 0.0, 1.0);\n\tvar spacing: f32 = mix(minSide * 0.31, minSide * 0.13, density);\n\tvar width: f32 = mix(minSide * 0.03, minSide * 0.013, density);\n\n\tvar broadWarp: vec2f = warpVec(px, minSide * 0.42, minSide * 0.06, params.seed + 1.0);\n\tvar detailWarp: vec2f = warpVec(px, minSide * 0.17, minSide * 0.018, params.seed + 6.0);\n\tvar warpedPx: vec2f = px + broadWarp + detailWarp;\n\n\tvar h: f32 =\n\t\t(fbm(warpedPx / (minSide * 0.26) + phaseVec(0.11, -0.09) + vec2f(params.seed * 0.17))\n\t\t\t- 0.5) * 0.08;\n\tvar broadFold: f32 = curvedFoldField(warpedPx, -0.74, spacing * 1.0, width, 3.1);\n\tvar crossFold: f32 = curvedFoldField(\n\t\twarpedPx + broadWarp * 0.7,\n\t\t0.31,\n\t\tspacing * 1.9,\n\t\twidth * 1.55,\n\t\t9.7\n\t);\n\tvar microFold: f32 = curvedFoldField(\n\t\twarpedPx - detailWarp * 0.6,\n\t\t1.04,\n\t\tspacing * 0.66,\n\t\twidth * 0.62,\n\t\t15.3\n\t);\n\th += broadFold * 0.22;\n\th += crossFold * 0.11;\n\th += microFold * 0.045;\n\th +=\n\t\t(1.0 -\n\t\t\tabs(\n\t\t\t\tfbm(\n\t\t\t\t\twarpedPx / (minSide * 0.11) +\n\t\t\t\t\t\tphaseVec(-0.23, 0.27) +\n\t\t\t\t\t\tvec2f(params.seed * 0.3)\n\t\t\t\t) *\n\t\t\t\t\t2.0 -\n\t\t\t\t\t1.0\n\t\t\t)) * 0.018;\n\n\tvar edge: f32 = edgeMask(uv) * clamp(params.edgeTension, 0.0, 1.0);\n\tvar edgeNoise: f32 =\n\t\tfbm(warpedPx / (minSide * 0.18) + phaseVec(0.18, 0.21) + vec2f(params.seed * 0.41, 8.0));\n\th += edge * (0.16 + edgeNoise * 0.11);\n\n\treturn h;\n}\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let vUv=vec2f(input.uv.x,1.0-input.uv.y);\n\tif (params.amount <= 0.0) {\n\t\treturn textureSampleLevel(source, sourceSampler, vec2f(vUv.x,1.0-vUv.y), 0);\n\t}\n\n\tvar texel: vec2f = vec2f(1.0) / params.size;\n\tvar left: f32 = heightMap(vUv - vec2f(texel.x, 0.0));\n\tvar right: f32 = heightMap(vUv + vec2f(texel.x, 0.0));\n\tvar down: f32 = heightMap(vUv - vec2f(0.0, texel.y));\n\tvar up: f32 = heightMap(vUv + vec2f(0.0, texel.y));\n\tvar gradient: vec2f = vec2f(right - left, up - down);\n\tvar reliefScale: f32 = mix(42.0, 115.0, params.wrinkleDensity);\n\tvar warpStrength: f32 = reliefScale * 0.32;\n\n\tvar sampleOffset: vec2f = gradient * warpStrength * params.displacement * params.amount;\n\tvar sampleUv: vec2f = clamp(vUv - sampleOffset * texel, vec2f(0.0), vec2f(1.0));\n\tvar color: vec4f = textureSampleLevel(source, sourceSampler, vec2f(sampleUv.x,1.0-sampleUv.y), 0);\n\n\tvar alpha: f32 = color.a;\n\tif (alpha <= 0.001) {\n\t\treturn vec4f(0.0);\n\t}\n\n\tvar rgb: vec3f = color.rgb / alpha;\n\tvar normal: vec3f = normalize(vec3f(-gradient * reliefScale, 1.0));\n\tvar light: vec3f = normalize(vec3f(-0.42, 0.58, 0.72));\n\tvar halfVector: vec3f = normalize(light + vec3f(0.0, 0.0, 1.0));\n\tvar specular: f32 = pow(max(dot(normal, halfVector), 0.0), 24.0);\n\tvar directional: f32 = dot(gradient, normalize(vec2f(-0.45, 0.72)));\n\tvar creaseHighlight: f32 = smoothstep(0.02, 0.07, directional);\n\tvar creaseShadow: f32 = smoothstep(0.02, 0.07, -directional);\n\tvar edge: f32 = edgeMask(vUv) * params.edgeTension;\n\tvar edgeGlint: f32 = edge * smoothstep(\n\t\t0.35,\n\t\t0.95,\n\t\tfbm(vUv * params.size / 90.0 + phaseVec(0.31, -0.24) + vec2f(params.seed))\n\t);\n\n\tvar highlight: f32 = clamp(\n\t\t(specular * 0.55 + creaseHighlight * 0.4 + edgeGlint * 0.18)\n\t\t\t* params.highlightIntensity\n\t\t\t* params.amount,\n\t\t0.0,\n\t\t1.15\n\t);\n\tvar shadow: f32 = clamp((creaseShadow * 0.1 + edge * 0.06) * params.amount, 0.0, 0.25);\n\n\trgb *= 1.0 - shadow;\n\trgb += (vec3f(1.0) - rgb) * min(highlight, 1.0);\n\trgb += vec3f(max(highlight - 1.0, 0.0)) * 0.35;\n\n\treturn vec4f(clamp(rgb, vec3f(0.0), vec3f(1.0)) * alpha, alpha);\n}\n\n";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type SinglePassState = {
|
|
2
|
+
readonly gl: WebGL2RenderingContext;
|
|
3
|
+
readonly program: WebGLProgram;
|
|
4
|
+
readonly vao: WebGLVertexArrayObject;
|
|
5
|
+
readonly vbo: WebGLBuffer;
|
|
6
|
+
readonly texture: WebGLTexture;
|
|
7
|
+
readonly uniforms: Record<string, WebGLUniformLocation | null>;
|
|
8
|
+
};
|
|
9
|
+
export declare const setupSinglePass: (target: HTMLCanvasElement, fragmentShader: string, effectName: string, uniformNames: readonly string[]) => SinglePassState;
|
|
10
|
+
export declare const prepareSinglePassSource: ({ state, source, width, height, flipSourceY, }: {
|
|
11
|
+
state: SinglePassState;
|
|
12
|
+
source: TexImageSource;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
flipSourceY: boolean;
|
|
16
|
+
}) => void;
|
|
17
|
+
export declare const drawSinglePass: ({ gl }: SinglePassState) => void;
|
|
18
|
+
export declare const cleanupSinglePass: ({ gl, program, vao, vbo, texture, }: SinglePassState) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SKEW_WEBGPU_SHADER = "\n\nstruct VertexOutput {\n\t@builtin(position) position: vec4f,\n\t@location(0) uv: vec2f,\n}\n\n@vertex fn vertex(@builtin(vertex_index) index: u32) -> VertexOutput {\n\tlet positions = array<vec2f, 3>(vec2f(-1, -1), vec2f(3, -1), vec2f(-1, 3));\n\tlet position = positions[index];\n\tvar output: VertexOutput;\n\toutput.position = vec4f(position, 0, 1);\n\toutput.uv = vec2f(position.x * 0.5 + 0.5, 0.5 - position.y * 0.5);\n\treturn output;\n}\n\nstruct Params { resolution: vec2f, skew: vec2f, origin: vec2f, padding: vec2f }\n@group(0) @binding(0) var source: texture_2d<f32>;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var<uniform> params: Params;\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let uv = vec2f(input.uv.x, 1.0 - input.uv.y);\n let destination = (uv - params.origin) * params.resolution;\n let sourceY = destination.y - params.skew.y * destination.x;\n let sourceX = destination.x - params.skew.x * sourceY;\n let sourceUv = vec2f(sourceX, sourceY) / params.resolution + params.origin;\n if (any(sourceUv < vec2f(0.0)) || any(sourceUv > vec2f(1.0))) { return vec4f(0.0); }\n return textureSampleLevel(source, sourceSampler, vec2f(sourceUv.x, 1.0 - sourceUv.y), 0.0);\n}\n";
|