@remotion/effects 4.0.539 → 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 +15 -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/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 +195 -211
- 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 +134 -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 +133 -153
- 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/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/webgpu-shader.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 +43 -3
package/THIRD_PARTY_LICENSES.md
CHANGED
|
@@ -11,6 +11,21 @@ The Shatter geometry and motion are adapted from EffectCraft's simulation
|
|
|
11
11
|
engine (`crates/effects/src/sim2.rs` and `crates/raster/src/lib.rs`), revision
|
|
12
12
|
`9581b53c3f8945683252af0eb5fac79e0e43aed4`, also under the MIT license.
|
|
13
13
|
|
|
14
|
+
The Evolve pixel feathering, Radial Wipe, and Iris Wipe shaders are adapted from
|
|
15
|
+
EffectCraft's transition effects (`crates/effects/src/misc.rs` and
|
|
16
|
+
`crates/effects/src/transition.rs`), revision
|
|
17
|
+
`eb5108786b90bf994a6abe4e6c0b2614c6aeaa29`, also under the MIT license.
|
|
18
|
+
|
|
19
|
+
The Film Burn shader is adapted from EffectCraft's CC Burn Film and value noise
|
|
20
|
+
(`crates/effects/src/stylize3.rs`, `crates/effects/src/generate.rs`,
|
|
21
|
+
`crates/effects/src/noise.rs`, and `crates/gpu/src/shaders/fx_pixel2.wgsl`),
|
|
22
|
+
revision `eb5108786b90bf994a6abe4e6c0b2614c6aeaa29`, also under the MIT license.
|
|
23
|
+
|
|
24
|
+
The Rain Fall and Snow Fall particle layout, shading, and hash are adapted from
|
|
25
|
+
EffectCraft's weather simulations (`crates/effects/src/sim.rs` and
|
|
26
|
+
`crates/raster/src/lib.rs`), revision
|
|
27
|
+
`eb5108786b90bf994a6abe4e6c0b2614c6aeaa29`, also under the MIT license.
|
|
28
|
+
|
|
14
29
|
MIT License
|
|
15
30
|
|
|
16
31
|
Copyright (c) 2026 ArtCraft Team and the EffectCraft contributors
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BARREL_DISTORTION_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 { amount: 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\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let centered = input.uv * 2.0 - 1.0;\n var warped = centered;\n warped.x *= 1.0 + params.amount.x * centered.y * centered.y;\n warped.y *= 1.0 + params.amount.x * centered.x * centered.x;\n let uv = warped * 0.5 + 0.5;\n if (any(uv < vec2f(0)) || any(uv > vec2f(1))) { return vec4f(0); }\n return textureSampleLevel(source, sourceSampler, uv, 0);\n}\n";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const BEVEL_ALPHA_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\n// Alpha-derived normals adapted from EffectCraft (MIT); see ../../THIRD_PARTY_LICENSES.md.\nstruct Params {resolution: vec2f, radius: f32, vertical: f32,}\nfn decodeHeight(color: vec4f) -> f32 {return dot(color.rg,vec2f(65280,255))/65535.0;}\nfn readHeight(uv: vec2f, x: f32) -> f32 {\n if (params.vertical==0.0) {return textureSampleLevel(source,sourceSampler,uv,0).a;}\n let pixel=uv*params.resolution-0.5;\n let lower=vec2i(i32(x),i32(floor(pixel.y)));\n let maximum=vec2i(params.resolution)-1;\n let a=decodeHeight(textureLoad(source,clamp(lower,vec2i(0),maximum),0));\n let b=decodeHeight(textureLoad(source,clamp(lower+vec2i(0,1),vec2i(0),maximum),0));\n return mix(a,b,fract(pixel.y));\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let radius=max(params.radius,0.0001);\n let halfKernel=i32(clamp(ceil(radius),4.0,64.0));\n let sigma=radius/3.0;\n var sum=0.0;var total=0.0;\n for (var i=-64;i<=64;i++) {\n if (abs(i)>halfKernel) {continue;}\n let offset=f32(i)*radius/f32(halfKernel);\n let weight=exp(-0.5*offset*offset/(sigma*sigma));\n let direction=select(vec2f(offset,0),vec2f(0,offset),params.vertical!=0.0);\n sum+=readHeight(input.uv+direction/params.resolution,input.position.x)*weight;\n total+=weight;\n }\n let value=floor(clamp(sum/total,0.0,1.0)*65535.0+0.5);\n return vec4f(floor(value/256.0),value-floor(value/256.0)*256.0,0,255)/255.0;\n}\n";
|
|
2
|
+
export declare const BEVEL_ALPHA_SHADE_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, thickness: f32, intensity: f32, direction: vec4f, color: vec4f,}\nfn heightAt(pixel: vec2i) -> f32 {\n return dot(textureLoad(secondary,clamp(pixel,vec2i(0),vec2i(params.resolution)-1),0).rg,vec2f(65280,255))/65535.0;\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let pixel=vec2i(input.position.xy);\n // The WebGL shading pass uses output pixel coordinates for texelFetch.\n // Retain that behavior for sources smaller than the output, with explicit\n // bounds because WebGPU robust texture access may clamp out-of-range loads.\n let size=vec2i(textureDimensions(source));\n let sourcePixel=vec2i(pixel.x,pixel.y+size.y-i32(params.resolution.y));\n if (any(sourcePixel<vec2i(0)) || any(sourcePixel>=size)) {return vec4f(0);}\n let color=textureLoad(source,sourcePixel,0);\n if (params.thickness==0.0 || params.intensity==0.0 || color.a==0.0) {return color;}\n let dx=(heightAt(pixel+vec2i(1,0))-heightAt(pixel-vec2i(1,0)))*0.5;\n let dy=(heightAt(pixel+vec2i(0,1))-heightAt(pixel-vec2i(0,1)))*0.5;\n let normal=normalize(vec3f(-dx*params.thickness*1.25,-dy*params.thickness*1.25,1));\n let shade=(dot(normal,params.direction.xyz)-params.direction.z)*params.intensity*2.0;\n var rgb=color.rgb;\n if (shade>0.0) {rgb+=params.color.rgb*shade*color.a;} else {rgb*=max(1.0+shade,0.0);}\n return vec4f(clamp(rgb,vec3f(0),vec3f(color.a)),color.a);\n}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BURLAP_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 values: vec4f,\n color: 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 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) + vec3f(params.values.y * 0.137)));\n return fract((p3.x + p3.y) * p3.z);\n}\nfn valueNoise(p: vec2f) -> f32 {\n let i = floor(p);\n var f = fract(p);\n f = f * f * (vec2f(3.0) - 2.0 * f);\n let a = hash21(i);\n let b = hash21(i + vec2f(1, 0));\n let c = hash21(i + vec2f(0, 1));\n let d = hash21(i + vec2f(1, 1));\n return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);\n}\nfn strand(value: f32) -> f32 {\n let centered = abs(fract(value) - 0.5);\n return 1.0 - smoothstep(0.2, 0.5, centered);\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 alpha = texColor.a;\n if (alpha <= 0.001) { return vec4f(0); }\n if (params.geometry.z <= 0.0) { return texColor; }\n // Match WebGL pixel centers without interpolated-UV rounding.\n let fragPos = vec2f(input.position.x, params.geometry.y - input.position.y);\n let strandSize = max(params.geometry.w, 0.001);\n let weave = fragPos / strandSize;\n let roughness = params.values.x;\n let seed = params.values.y;\n let rowJitter = (hash21(vec2f(floor(weave.y), 13.17)) - 0.5) * roughness * 0.28;\n let columnJitter = (hash21(vec2f(71.43, floor(weave.x))) - 0.5) * roughness * 0.28;\n let vertical = strand(weave.x + rowJitter);\n let horizontal = strand(weave.y + columnJitter);\n let cellParity = glslModulo(floor(weave.x) + floor(weave.y), 2.0);\n let overUnder = mix(vertical, horizontal, cellParity);\n let ridge = max(max(vertical, horizontal) * 0.45, overUnder * 0.75);\n let gaps = (1.0 - vertical) * (1.0 - horizontal);\n let coarse = valueNoise(fragPos / (strandSize * 7.0) + vec2f(seed * 1.7, seed * 0.6));\n let fine = valueNoise(fragPos / max(strandSize * 0.55, 0.5) + vec2f(seed * 3.1, 4.7));\n let dashH = smoothstep(0.64, 0.98, hash21(floor(vec2f(weave.x * 2.0, weave.y)) + vec2f(23.9))) * horizontal;\n let dashV = smoothstep(0.64, 0.98, hash21(floor(vec2f(weave.x, weave.y * 2.0)) + vec2f(91.4))) * vertical;\n var texture = 0.0;\n texture += (ridge - 0.42) * 0.22;\n texture -= gaps * 0.18;\n texture += (coarse - 0.5) * 0.18 * roughness;\n texture += (fine - 0.5) * 0.16 * roughness;\n texture -= (dashH + dashV) * 0.08 * roughness;\n var rgb = texColor.rgb / alpha;\n let darkFiber = clamp(-texture * 3.2 + gaps * 0.12 + (dashH + dashV) * 0.18, 0.0, 1.0);\n let shaded = mix(rgb, params.color.rgb, darkFiber * params.color.a);\n let textured = clamp(shaded * (1.0 + max(texture, 0.0) * 0.45), vec3f(0), vec3f(1));\n rgb = mix(rgb, textured, params.geometry.z);\n return vec4f(rgb * alpha, alpha);\n\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CHECKERBOARD_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 grid: 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 glslModulo2(value: vec2f, divisor: f32) -> vec2f { 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 cellSize = max(params.geometry.w, 0.001);\n let spacing = max(params.grid.x, 0.001);\n let centered = vec2f(input.position.x, params.geometry.y - input.position.y) - params.geometry.xy * 0.5;\n let s = sin(params.grid.y);\n let c = cos(params.grid.y);\n let rotated = vec2f(centered.x * c - centered.y * s, centered.x * s + centered.y * c);\n let position = rotated + params.grid.zw;\n var localPosition = glslModulo2(position, spacing);\n if (localPosition.x < 0.0) { localPosition.x += spacing; }\n if (localPosition.y < 0.0) { localPosition.y += spacing; }\n if (localPosition.x > cellSize || localPosition.y > cellSize) { return texColor; }\n let cell = floor(position / spacing);\n var colorIndex = glslModulo(cell.x + cell.y, params.geometry.z);\n if (colorIndex < 0.0) { colorIndex += params.geometry.z; }\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 CHROMATIC_ABERRATION_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 { offset: vec4f, }\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let red = textureSampleLevel(source, sourceSampler, input.uv - params.offset.xy, 0);\n let center = textureSampleLevel(source, sourceSampler, input.uv, 0);\n let blue = textureSampleLevel(source, sourceSampler, input.uv + params.offset.xy, 0);\n return vec4f(red.r, center.g, blue.b, center.a);\n}\n";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const COLOR_SPACE_WGSL = "\nfn srgbToLinear(color: vec3f) -> vec3f {\n\tlet lower = color / 12.92;\n\tlet upper = pow((color + 0.055) / 1.055, vec3f(2.4));\n\treturn mix(lower, upper, step(vec3f(0.04045), color));\n}\n\nfn linearToSrgb(color: vec3f) -> vec3f {\n\tlet nonNegative = max(color, vec3f(0.0));\n\tlet lower = nonNegative * 12.92;\n\tlet upper = 1.055 * pow(nonNegative, vec3f(1.0 / 2.4)) - 0.055;\n\treturn mix(lower, upper, step(vec3f(0.0031308), nonNegative));\n}\n";
|
|
2
|
+
export declare const WHITE_BALANCE_WGSL = "\nfn applyWhiteBalanceLinear(linear: vec3f, temperature: f32, tint: f32) -> vec3f {\n\tlet temperatureOffset = vec3f(0.3, 0.0, -0.3) * temperature;\n\tlet tintOffset = vec3f(0.15, -0.3, 0.15) * tint;\n\tlet gains = exp2(temperatureOffset + tintOffset);\n\tlet luminanceGain = dot(gains, vec3f(0.2126, 0.7152, 0.0722));\n\treturn linear * gains / luminanceGain;\n}\n";
|
|
3
|
+
export declare const SHADOWS_HIGHLIGHTS_WGSL = "\nfn getShadowsHighlightsStops(color: vec3f, shadows: f32, highlights: f32) -> f32 {\n\tlet luminance = dot(color, vec3f(0.2126, 0.7152, 0.0722));\n\tlet shadowWeight = 1.0 - smoothstep(0.0, 0.6, luminance);\n\tlet highlightWeight = smoothstep(0.4, 1.0, luminance);\n\treturn shadows * shadowWeight * shadowWeight + highlights * highlightWeight * highlightWeight;\n}\n";
|
|
4
|
+
export declare const VIBRANCE_WGSL = "\nfn applyVibrance(color: vec3f, amount: f32) -> vec3f {\n\tlet maximum = max(max(color.r, color.g), color.b);\n\tlet minimum = min(min(color.r, color.g), color.b);\n\tlet lightness = (maximum + minimum) * 0.5;\n\tlet chroma = maximum - minimum;\n\tlet saturationDenominator = 1.0 - abs(2.0 * lightness - 1.0);\n\tvar saturation = 0.0;\n\tif (saturationDenominator > 0.0) {\n\t\tsaturation = chroma / saturationDenominator;\n\t}\n\tif (saturation <= 0.000001) {\n\t\treturn color;\n\t}\n\tvar targetSaturation = saturation * (1.0 + amount);\n\tif (amount >= 0.0) {\n\t\ttargetSaturation = saturation + amount * (1.0 - saturation);\n\t}\n\treturn clamp(vec3f(lightness) + (color - vec3f(lightness)) * (targetSaturation / saturation), vec3f(0.0), vec3f(1.0));\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const COLOR_KEY_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\nstruct Params {\n keyColor: vec3f,\n similarity: f32,\n smoothness: f32,\n spillSuppression: 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\nfn suppressSpill(rgb: vec3f, keyColor: vec3f, amount: f32) -> vec3f {\n var color = rgb;\n if (keyColor.g > keyColor.r && keyColor.g > keyColor.b) {\n let limit = (color.r + color.b) * 0.5;\n color.g = mix(color.g, min(color.g, limit), amount);\n } else if (keyColor.r > keyColor.g && keyColor.r > keyColor.b) {\n let limit = (color.g + color.b) * 0.5;\n color.r = mix(color.r, min(color.r, limit), amount);\n } else if (keyColor.b > keyColor.r && keyColor.b > keyColor.g) {\n let limit = (color.r + color.g) * 0.5;\n color.b = mix(color.b, min(color.b, limit), amount);\n }\n return color;\n}\n\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let texColor = textureSampleLevel(source, sourceSampler, input.uv, 0);\n let alpha = texColor.a;\n if (alpha <= 0.001) { return vec4f(0); }\n\n let rgb = texColor.rgb / alpha;\n let distanceNormalized = distance(rgb, params.keyColor) / 1.7320508075688772;\n var keepMask: f32;\n if (params.smoothness <= 0.0001) {\n keepMask = step(params.similarity, distanceNormalized);\n } else {\n let edge0 = max(0.0, params.similarity - params.smoothness);\n let edge1 = min(1.0, params.similarity + params.smoothness);\n if (edge1 <= edge0 + 0.0001) {\n keepMask = step(params.similarity, distanceNormalized);\n } else {\n keepMask = smoothstep(edge0, edge1, distanceNormalized);\n }\n }\n\n var cleanRgb = rgb;\n if (params.spillSuppression > 0.0) {\n cleanRgb = suppressSpill(rgb, params.keyColor, params.spillSuppression);\n }\n let keyedAlpha = alpha * keepMask;\n return vec4f(cleanRgb * keyedAlpha, keyedAlpha);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CONTOUR_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;\nstruct Params {\n geometry: vec4f,\n noise: vec4f,\n offset: vec4f,\n lineColor: 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 totalAmplitude = 0.0;\n let persistence = mix(0.18, 0.58, clamp(params.noise.x, 0.0, 1.0));\n let smoothness = clamp(params.noise.y, 0.0, 1.0);\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 detailWeight = mix(1.0, 1.0 - smoothstep(0.15, 1.0, octave), smoothness);\n value += amplitude * detailWeight * valueNoise(p);\n totalAmplitude += amplitude * detailWeight;\n p = rotate * p * 2.04 + vec2f(13.17, 7.31);\n amplitude *= persistence;\n }\n return value / totalAmplitude;\n}\n\nfn contourAt(pixel: vec2f) -> f32 {\n let pixelPosition = pixel + params.offset.xy;\n let scale = max(params.geometry.w, 0.001);\n let p = pixelPosition / scale + vec2f(params.noise.z * 0.137, params.noise.z * 0.193);\n let complexity = clamp(params.noise.x, 0.0, 1.0);\n let smoothness = clamp(params.noise.y, 0.0, 1.0);\n let warp = vec2f(fbm(p + vec2f(5.2, 1.3)), fbm(p + vec2f(1.7, 9.2))) - vec2f(0.5);\n let terrain = fbm(p + warp * complexity * mix(2.8, 1.2, smoothness));\n let levels = max(max(params.geometry.x, params.geometry.y) / (max(params.geometry.z, 0.001) * 2.0), 1.0);\n return terrain * levels;\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 texColor = sampleSource(vUv);\n let pixel = vec2f(input.position.x, params.geometry.y - input.position.y);\n let contourPosition = contourAt(pixel);\n let contourFraction = fract(contourPosition);\n let distanceToContour = min(contourFraction, 1.0 - contourFraction);\n var derivative = fwidth(contourPosition);\n if (i32(params.geometry.y) % 2 != 0) {\n // WebGL derivative quads start at the bottom edge. Odd-height targets shift\n // WebGPU's top-origin Y pairs, so evaluate the matching vertical neighbor.\n let neighborY = select(-1.0, 1.0, i32(pixel.y) % 2 == 0);\n derivative = abs(dpdx(contourPosition)) + abs(contourAt(pixel + vec2f(0, neighborY)) - contourPosition);\n }\n derivative = max(derivative, 0.0001);\n let halfLineWidth = max(params.noise.w, 0.001) * 0.5 * derivative;\n let coverage = 1.0 - smoothstep(halfLineWidth, halfLineWidth + derivative, distanceToContour);\n let lineAlpha = params.lineColor.a * params.offset.z * coverage;\n let premultipliedLine = params.lineColor.rgb * lineAlpha;\n if (params.offset.w != 0.0) { return vec4f(premultipliedLine * texColor.a + texColor.rgb * (1.0 - lineAlpha), texColor.a); }\n return vec4f(premultipliedLine + texColor.rgb * (1.0 - lineAlpha), lineAlpha + texColor.a * (1.0 - lineAlpha));\n\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CORNER_PIN_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 {top: vec4f, bottom: vec4f,}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let p0 = params.bottom.zw; let p1 = params.bottom.xy;\n let p2 = params.top.zw; let p3 = params.top.xy;\n let dx1 = p1 - p2; let dx2 = p3 - p2; let dx3 = p0 - p1 + p2 - p3;\n var g = 0.0; var h = 0.0;\n if (abs(dx3.x) > 0.000001 || abs(dx3.y) > 0.000001) {\n let denominator = dx1.x * dx2.y - dx2.x * dx1.y;\n if (abs(denominator) < 0.000001) {return vec4f(0);}\n g = (dx3.x * dx2.y - dx2.x * dx3.y) / denominator;\n h = (dx1.x * dx3.y - dx3.x * dx1.y) / denominator;\n }\n let a = p1.x - p0.x + g * p1.x; let b = p3.x - p0.x + h * p3.x; let c = p0.x;\n let d = p1.y - p0.y + g * p1.y; let e = p3.y - p0.y + h * p3.y; let f = p0.y;\n let p = input.uv;\n let x = (e-f*h)*p.x + (c*h-b)*p.y + (b*f-c*e);\n let y = (f*g-d)*p.x + (a-c*g)*p.y + (c*d-a*f);\n let w = (d*h-e*g)*p.x + (b*g-a*h)*p.y + (a*e-b*d);\n if (abs(w) < 0.000001) {return vec4f(0);}\n let uv = vec2f(x/w, 1.0-y/w);\n if (any(uv < vec2f(0)) || any(uv > vec2f(1))) {return vec4f(0);}\n return textureSampleLevel(source, sourceSampler, uv, 0);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CYLINDER_WEBGL_SHADER = "#version 300 es\nprecision highp float;\nuniform sampler2D uSource;\nuniform vec4 uParams[3];\nout vec4 fragColor;\nvec4 sampleFace(vec3 point, mat3 inverseRotation, mat3 rotation) {\n vec3 local = inverseRotation * point;\n vec2 uv = vec2(fract((atan(local.x, local.z) + uParams[1].y) / 6.28318530718 + 0.5), local.y / uParams[0].xy.y + 0.5);\n vec4 color = textureLod(uSource, vec2(uv.x, 1.0 - uv.y), 0.0);\n if (uv.y < 0.0 || uv.y > 1.0) { return vec4(0); }\n vec3 normal = rotation * vec3(local.x / uParams[1].x, 0, local.z / uParams[1].x);\n float shade = mix(1.0, abs(normal.z), uParams[1].z);\n return vec4(color.rgb * shade, color.a);\n}\n\nvec4 project(vec2 position) {\n vec3 s = sin(uParams[2].xyz);\n vec3 c = cos(uParams[2].xyz);\n mat3 rx = mat3(vec3(1, 0, 0), vec3(0, c.x, s.x), vec3(0, -s.x, c.x));\n mat3 ry = mat3(vec3(c.y, 0, -s.y), vec3(0, 1, 0), vec3(s.y, 0, c.y));\n mat3 rz = mat3(vec3(c.z, s.z, 0), vec3(-s.z, c.z, 0), vec3(0, 0, 1));\n mat3 rotation = rz * ry * rx;\n vec3 axis = rotation[1];\n vec2 p = position - uParams[0].zw;\n // Orthographic viewing ray intersecting the rotated, open cylinder wall.\n float a = 1.0 - axis.z * axis.z;\n float da = dot(p, axis.xy);\n float b = -da * axis.z;\n float discriminant = b * b - a * (dot(p, p) - da * da - uParams[1].x * uParams[1].x);\n if (a < 0.000001 || discriminant <= 0.0) { return vec4(0); }\n float root = sqrt(discriminant);\n mat3 inverseRotation = transpose(rotation);\n vec4 front = sampleFace(vec3(p, (-b + root) / a), inverseRotation, rotation);\n vec4 back = sampleFace(vec3(p, (-b - root) / a), inverseRotation, rotation);\n if (uParams[1].w == 1.0) { return front; }\n if (uParams[1].w == 2.0) { return back; }\n // Both the texture and output use premultiplied alpha.\n return front + back * (1.0 - front.a);\n}\n\nvoid main() { fragColor = project(vec2(gl_FragCoord.x, uParams[0].y - gl_FragCoord.y)); }\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DOT_GRID_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 flags: vec4f,\n}\nfn sampleSource(uv: vec2f) -> vec4f {\n return textureSampleLevel(sourceTexture, sourceSampler, vec2f(uv.x, 1.0 - uv.y), 0);\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 gridPos = vec2f(input.position.x, params.geometry.y - input.position.y) - params.geometry.xy * 0.5;\n let gridSize = max(params.geometry.w, 0.001);\n let cellIndex = floor(gridPos / gridSize + vec2f(0.5));\n let diff = gridPos - cellIndex * gridSize;\n let radius = params.geometry.z * 0.5;\n var coverage = 0.0;\n if (radius > 0.005) { coverage = 1.0 - smoothstep(radius - 0.75, radius + 0.75, length(diff)); }\n if (params.flags.x != 0.0) { coverage = 1.0 - coverage; }\n return sampleSource(vUv) * coverage;\n\n}\n";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const DROP_SHADOW_EXTRACT_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, values: vec4f,}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let alpha=textureSampleLevel(source,sourceSampler,input.uv,0).a*params.color.a*clamp(params.values.x,0.0,1.0);\n return vec4f(params.color.rgb*alpha,alpha);\n}\n";
|
|
2
|
+
export declare const DROP_SHADOW_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 {resolution: vec2f, offset: vec2f,}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color=textureSampleLevel(source,sourceSampler,input.uv,0);\n let uv=input.uv-params.offset/params.resolution;\n var shadow=vec4f(0);\n if (all(uv >= vec2f(0)) && all(uv <= vec2f(1))) {shadow=textureSampleLevel(secondary,sourceSampler,uv,0);}\n return color+shadow*(1.0-color.a);\n}";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EMBOSS_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 resolution: vec2f, amount: f32, size: f32,\n lineWidth: f32, depth: f32, angle: f32, lightAngle: f32,\n offset: f32, padding1: f32, padding2: f32, padding3: 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\nfn rotation(angle: f32) -> mat2x2f {\n let c = cos(angle);\n let s = sin(angle);\n return mat2x2f(vec2f(c, -s), vec2f(s, c));\n}\nfn roundedBoxSdf(p: vec2f, halfSize: vec2f, radius: f32) -> f32 {\n let q = abs(p) - halfSize + vec2f(radius);\n return length(max(q, vec2f(0.0))) + min(max(q.x, q.y), 0.0) - radius;\n}\nfn reliefHeight(fragPos: vec2f) -> f32 {\n let size = max(params.size, 0.001);\n let lineWidth = clamp(params.lineWidth, 0.001, size * 0.85);\n var pos = rotation(params.angle) * (fragPos - params.resolution * 0.5);\n pos.x += params.offset;\n let cell = floor(pos / size);\n let local = (fract(pos / size) - vec2f(0.5)) * size;\n let cellSum = cell.x + cell.y;\n let alternate = cellSum - 2.0 * floor(cellSum / 2.0);\n let dashAngle = mix(0.78539816339, -0.78539816339, step(0.5, alternate));\n let dash = rotation(dashAngle) * local;\n let sdf = roundedBoxSdf(dash, vec2f(size * 0.36, lineWidth * 0.5), lineWidth * 0.5);\n return 1.0 - smoothstep(-1.0, 1.0, sdf);\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 if (params.amount <= 0.0 || params.depth <= 0.0) { return color; }\n let fragPos = vec2f(input.uv.x, 1.0 - input.uv.y) * params.resolution;\n let h = reliefHeight(fragPos);\n let hLeft = reliefHeight(fragPos - vec2f(1.0, 0.0));\n let hRight = reliefHeight(fragPos + vec2f(1.0, 0.0));\n let hDown = reliefHeight(fragPos - vec2f(0.0, 1.0));\n let hUp = reliefHeight(fragPos + vec2f(0.0, 1.0));\n let normal = normalize(vec3f((hLeft - hRight) * params.depth * 3.8, (hDown - hUp) * params.depth * 3.8, 1.0));\n let light = normalize(vec3f(cos(params.lightAngle), sin(params.lightAngle), 0.7));\n let lit = dot(normal, light);\n let bevel = (lit - 0.64) * 0.72 * params.depth;\n let plateau = (h - 0.5) * 0.08 * params.depth;\n let edge = min(abs(hRight - hLeft) + abs(hUp - hDown), 1.0);\n let rgb = color.rgb / alpha;\n let shaded = clamp(rgb + vec3f(bevel + plateau - edge * 0.035 * params.depth), vec3f(0.0), vec3f(1.0));\n return vec4f(mix(rgb, shaded, params.amount) * alpha, alpha);\n}\n";
|
|
@@ -1,111 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertOptionalFiniteNumber,
|
|
3
|
+
validateUnitInterval
|
|
4
|
+
} from "./index-wxhvgv2s.mjs";
|
|
5
|
+
import {
|
|
6
|
+
WEBGPU_SINGLE_PASS_VERTEX,
|
|
7
|
+
setupWebGpuSinglePass,
|
|
8
|
+
cleanupWebGpuSinglePass,
|
|
9
|
+
applyWebGpuSinglePass
|
|
10
|
+
} from "./index-tvfexb7s.mjs";
|
|
11
|
+
import {
|
|
12
|
+
assertEffectParamsObject
|
|
13
|
+
} from "./index-4fvp93ps.mjs";
|
|
14
|
+
|
|
1
15
|
// src/barrel-distortion/index.ts
|
|
2
16
|
import { Internals as Internals2 } from "remotion";
|
|
3
17
|
|
|
4
|
-
// src/validate-effect-param.ts
|
|
5
|
-
var assertEffectParamsObject = (params, effectLabel) => {
|
|
6
|
-
if (params === null || typeof params !== "object") {
|
|
7
|
-
throw new TypeError(`${effectLabel} effect requires a parameters object, but got ${JSON.stringify(params)}`);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var assertRequiredFiniteNumber = (value, name) => {
|
|
11
|
-
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
12
|
-
throw new TypeError(`"${name}" must be a finite number, but got ${JSON.stringify(value)}`);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
var assertRequiredColor = (value, name) => {
|
|
16
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
17
|
-
throw new TypeError(`"${name}" must be a non-empty string, but got ${JSON.stringify(value)}`);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
var assertOptionalColor = (value, name) => {
|
|
21
|
-
if (value === undefined) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
assertRequiredColor(value, name);
|
|
25
|
-
};
|
|
26
|
-
var assertOptionalBoolean = (value, name) => {
|
|
27
|
-
if (value === undefined) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (typeof value !== "boolean") {
|
|
31
|
-
throw new TypeError(`"${name}" must be a boolean, but got ${JSON.stringify(value)}`);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// src/color-utils.ts
|
|
36
|
-
var DEFAULT_AMOUNT = 1;
|
|
37
|
-
var DEFAULT_BRIGHTNESS_AMOUNT = 0;
|
|
38
|
-
var DEFAULT_HUE_DEGREES = 0;
|
|
39
|
-
var colorAmountSchema = {
|
|
40
|
-
type: "number",
|
|
41
|
-
min: 0,
|
|
42
|
-
max: 1,
|
|
43
|
-
step: 0.01,
|
|
44
|
-
default: DEFAULT_AMOUNT,
|
|
45
|
-
description: "Amount",
|
|
46
|
-
hiddenFromList: false
|
|
47
|
-
};
|
|
48
|
-
var colorMultiplierSchema = {
|
|
49
|
-
type: "number",
|
|
50
|
-
min: 0,
|
|
51
|
-
step: 0.01,
|
|
52
|
-
default: DEFAULT_AMOUNT,
|
|
53
|
-
description: "Amount",
|
|
54
|
-
hiddenFromList: false
|
|
55
|
-
};
|
|
56
|
-
var brightnessAmountSchema = {
|
|
57
|
-
type: "number",
|
|
58
|
-
min: -1,
|
|
59
|
-
max: 1,
|
|
60
|
-
step: 0.01,
|
|
61
|
-
default: DEFAULT_BRIGHTNESS_AMOUNT,
|
|
62
|
-
description: "Amount",
|
|
63
|
-
hiddenFromList: false
|
|
64
|
-
};
|
|
65
|
-
var hueDegreesSchema = {
|
|
66
|
-
type: "rotation-degrees",
|
|
67
|
-
step: 1,
|
|
68
|
-
default: DEFAULT_HUE_DEGREES,
|
|
69
|
-
description: "Degrees"
|
|
70
|
-
};
|
|
71
|
-
var assertOptionalFiniteNumber = (value, name) => {
|
|
72
|
-
if (value === undefined) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
assertRequiredFiniteNumber(value, name);
|
|
76
|
-
};
|
|
77
|
-
var validateUnitInterval = (value, name) => {
|
|
78
|
-
if (value < 0) {
|
|
79
|
-
throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
|
|
80
|
-
}
|
|
81
|
-
if (value > 1) {
|
|
82
|
-
throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
var validateNonNegative = (value, name) => {
|
|
86
|
-
if (value < 0) {
|
|
87
|
-
throw new TypeError(`"${name}" must be >= 0, but got ${JSON.stringify(value)}`);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
var validateSignedUnitInterval = (value, name) => {
|
|
91
|
-
if (value < -1) {
|
|
92
|
-
throw new TypeError(`"${name}" must be >= -1, but got ${JSON.stringify(value)}`);
|
|
93
|
-
}
|
|
94
|
-
if (value > 1) {
|
|
95
|
-
throw new TypeError(`"${name}" must be <= 1, but got ${JSON.stringify(value)}`);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
var clampColorChannel = (value) => {
|
|
99
|
-
return Math.max(0, Math.min(255, value));
|
|
100
|
-
};
|
|
101
|
-
var parseColorRgba = (ctx, color) => {
|
|
102
|
-
ctx.clearRect(0, 0, 1, 1);
|
|
103
|
-
ctx.fillStyle = color;
|
|
104
|
-
ctx.fillRect(0, 0, 1, 1);
|
|
105
|
-
const { data } = ctx.getImageData(0, 0, 1, 1);
|
|
106
|
-
return [data[0], data[1], data[2], data[3]];
|
|
107
|
-
};
|
|
108
|
-
|
|
109
18
|
// src/barrel-distortion/barrel-distortion-runtime.ts
|
|
110
19
|
import { Internals } from "remotion";
|
|
111
20
|
|
|
@@ -301,6 +210,25 @@ var applyBarrelDistortion = ({
|
|
|
301
210
|
gl.useProgram(null);
|
|
302
211
|
};
|
|
303
212
|
|
|
213
|
+
// src/barrel-distortion/webgpu-shader.ts
|
|
214
|
+
var BARREL_DISTORTION_WEBGPU_SHADER = `
|
|
215
|
+
${WEBGPU_SINGLE_PASS_VERTEX}
|
|
216
|
+
struct Params { amount: vec4f, }
|
|
217
|
+
@group(0) @binding(0) var source: texture_2d<f32>;
|
|
218
|
+
@group(0) @binding(1) var sourceSampler: sampler;
|
|
219
|
+
@group(0) @binding(2) var<uniform> params: Params;
|
|
220
|
+
|
|
221
|
+
@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {
|
|
222
|
+
let centered = input.uv * 2.0 - 1.0;
|
|
223
|
+
var warped = centered;
|
|
224
|
+
warped.x *= 1.0 + params.amount.x * centered.y * centered.y;
|
|
225
|
+
warped.y *= 1.0 + params.amount.x * centered.x * centered.x;
|
|
226
|
+
let uv = warped * 0.5 + 0.5;
|
|
227
|
+
if (any(uv < vec2f(0)) || any(uv > vec2f(1))) { return vec4f(0); }
|
|
228
|
+
return textureSampleLevel(source, sourceSampler, uv, 0);
|
|
229
|
+
}
|
|
230
|
+
`;
|
|
231
|
+
|
|
304
232
|
// src/barrel-distortion/index.ts
|
|
305
233
|
var { createEffect } = Internals2;
|
|
306
234
|
var DEFAULT_BARREL_DISTORTION_AMOUNT = 0.25;
|
|
@@ -328,24 +256,45 @@ var barrelDistortion = createEffect({
|
|
|
328
256
|
type: "dev.remotion.effects.barrelDistortion",
|
|
329
257
|
label: "barrelDistortion()",
|
|
330
258
|
documentationLink: "https://www.remotion.dev/docs/effects/barrel-distortion",
|
|
331
|
-
backend: "webgl2",
|
|
332
259
|
calculateKey: (params) => {
|
|
333
260
|
const r = resolve(params);
|
|
334
261
|
return `barrel-distortion-${r.amount}`;
|
|
335
262
|
},
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
263
|
+
implementations: {
|
|
264
|
+
webgpu: Internals2.createEffectImplementation({
|
|
265
|
+
setup: (target) => setupWebGpuSinglePass(target, "barrel-distortion"),
|
|
266
|
+
apply: ({ source, width, height, params, state, gpuDevice }) => {
|
|
267
|
+
if (!gpuDevice) {
|
|
268
|
+
throw new Error("A WebGPU device is required for the barrel-distortion effect");
|
|
269
|
+
}
|
|
270
|
+
applyWebGpuSinglePass({
|
|
271
|
+
state,
|
|
272
|
+
source,
|
|
273
|
+
width,
|
|
274
|
+
height,
|
|
275
|
+
device: gpuDevice,
|
|
276
|
+
shader: BARREL_DISTORTION_WEBGPU_SHADER,
|
|
277
|
+
uniformData: new Float32Array([resolve(params).amount, 0, 0, 0])
|
|
278
|
+
});
|
|
279
|
+
},
|
|
280
|
+
cleanup: cleanupWebGpuSinglePass
|
|
281
|
+
}),
|
|
282
|
+
webgl2: Internals2.createEffectImplementation({
|
|
283
|
+
setup: (target) => setupBarrelDistortion(target),
|
|
284
|
+
apply: ({ source, width, height, params, state, flipSourceY }) => {
|
|
285
|
+
const r = resolve(params);
|
|
286
|
+
applyBarrelDistortion({
|
|
287
|
+
state,
|
|
288
|
+
source,
|
|
289
|
+
width,
|
|
290
|
+
height,
|
|
291
|
+
amount: r.amount,
|
|
292
|
+
flipSourceY
|
|
293
|
+
});
|
|
294
|
+
},
|
|
295
|
+
cleanup: (state) => cleanupBarrelDistortion(state)
|
|
296
|
+
})
|
|
347
297
|
},
|
|
348
|
-
cleanup: (state) => cleanupBarrelDistortion(state),
|
|
349
298
|
schema: barrelDistortionSchema,
|
|
350
299
|
validateParams: validateBarrelDistortionParams
|
|
351
300
|
});
|