@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
|
@@ -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 @@
|
|
|
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 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";
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { type WeatherCommonParams } from './weather/params.js';
|
|
2
|
+
export type SnowFallParams = WeatherCommonParams & {
|
|
3
|
+
/** Number of flakes, an integer from `0` to `200000`. Defaults to `10000`. */
|
|
4
|
+
readonly flakes?: number;
|
|
5
|
+
/** Size variation, from `0` to `1`. Defaults to `0.5`. */
|
|
6
|
+
readonly sizeVariation?: number;
|
|
7
|
+
/** Speed variation, from `0` to `1`. Defaults to `0.5`. */
|
|
8
|
+
readonly speedVariation?: number;
|
|
9
|
+
/** Sideways oscillation strength, from `0` to `100`. Defaults to `2`. */
|
|
10
|
+
readonly wiggleAmount?: number;
|
|
11
|
+
/** Wiggle amplitude variation, from `0` to `1`. Defaults to `0.5`. */
|
|
12
|
+
readonly wiggleAmountVariation?: number;
|
|
13
|
+
/** Sideways oscillations per second, from `0` to `20`. Defaults to `1`. */
|
|
14
|
+
readonly wiggleFrequency?: number;
|
|
15
|
+
/** Wiggle frequency variation, from `0` to `1`. Defaults to `0.5`. */
|
|
16
|
+
readonly wiggleFrequencyVariation?: number;
|
|
17
|
+
};
|
|
18
|
+
export declare const snowFallSchema: {
|
|
19
|
+
readonly time: {
|
|
20
|
+
readonly type: 'number';
|
|
21
|
+
readonly min: 0;
|
|
22
|
+
readonly max: 10;
|
|
23
|
+
readonly step: 0.01;
|
|
24
|
+
readonly default: number;
|
|
25
|
+
readonly description: 'Time';
|
|
26
|
+
readonly hiddenFromList: false;
|
|
27
|
+
};
|
|
28
|
+
readonly size: {
|
|
29
|
+
readonly type: 'number';
|
|
30
|
+
readonly min: 0;
|
|
31
|
+
readonly max: 50;
|
|
32
|
+
readonly step: 0.01;
|
|
33
|
+
readonly default: number;
|
|
34
|
+
readonly description: 'Size';
|
|
35
|
+
readonly hiddenFromList: false;
|
|
36
|
+
};
|
|
37
|
+
readonly sceneDepth: {
|
|
38
|
+
readonly type: 'number';
|
|
39
|
+
readonly min: 0;
|
|
40
|
+
readonly max: 20000;
|
|
41
|
+
readonly step: 1;
|
|
42
|
+
readonly default: number;
|
|
43
|
+
readonly description: 'Scene depth';
|
|
44
|
+
readonly hiddenFromList: false;
|
|
45
|
+
};
|
|
46
|
+
readonly speed: {
|
|
47
|
+
readonly type: 'number';
|
|
48
|
+
readonly min: 0;
|
|
49
|
+
readonly max: number;
|
|
50
|
+
readonly step: 1;
|
|
51
|
+
readonly default: number;
|
|
52
|
+
readonly description: 'Speed';
|
|
53
|
+
readonly hiddenFromList: false;
|
|
54
|
+
};
|
|
55
|
+
readonly wind: {
|
|
56
|
+
readonly type: 'number';
|
|
57
|
+
readonly min: number;
|
|
58
|
+
readonly max: number;
|
|
59
|
+
readonly step: 1;
|
|
60
|
+
readonly default: number;
|
|
61
|
+
readonly description: 'Wind';
|
|
62
|
+
readonly hiddenFromList: false;
|
|
63
|
+
};
|
|
64
|
+
readonly windVariation: {
|
|
65
|
+
readonly type: 'number';
|
|
66
|
+
readonly min: 0;
|
|
67
|
+
readonly max: 1;
|
|
68
|
+
readonly step: 0.01;
|
|
69
|
+
readonly default: number;
|
|
70
|
+
readonly description: 'Wind variation';
|
|
71
|
+
readonly hiddenFromList: false;
|
|
72
|
+
};
|
|
73
|
+
readonly spread: {
|
|
74
|
+
readonly type: 'number';
|
|
75
|
+
readonly min: 0;
|
|
76
|
+
readonly max: 1000;
|
|
77
|
+
readonly step: 1;
|
|
78
|
+
readonly default: number;
|
|
79
|
+
readonly description: 'Spread';
|
|
80
|
+
readonly hiddenFromList: false;
|
|
81
|
+
};
|
|
82
|
+
readonly opacity: {
|
|
83
|
+
readonly type: 'number';
|
|
84
|
+
readonly min: 0;
|
|
85
|
+
readonly max: 1;
|
|
86
|
+
readonly step: 0.01;
|
|
87
|
+
readonly default: number;
|
|
88
|
+
readonly description: 'Opacity';
|
|
89
|
+
readonly hiddenFromList: false;
|
|
90
|
+
};
|
|
91
|
+
readonly color: {
|
|
92
|
+
readonly type: 'color';
|
|
93
|
+
readonly default: string;
|
|
94
|
+
readonly description: 'Color';
|
|
95
|
+
};
|
|
96
|
+
readonly transferMode: {
|
|
97
|
+
readonly type: 'enum';
|
|
98
|
+
readonly variants: {
|
|
99
|
+
readonly composite: {};
|
|
100
|
+
readonly lighten: {};
|
|
101
|
+
};
|
|
102
|
+
readonly default: "composite" | "lighten";
|
|
103
|
+
readonly description: 'Transfer mode';
|
|
104
|
+
};
|
|
105
|
+
readonly compositeWithOriginal: {
|
|
106
|
+
readonly type: 'boolean';
|
|
107
|
+
readonly default: boolean;
|
|
108
|
+
readonly description: 'Composite with original';
|
|
109
|
+
};
|
|
110
|
+
readonly offset: {
|
|
111
|
+
readonly type: 'uv-coordinate';
|
|
112
|
+
readonly step: 0.01;
|
|
113
|
+
readonly default: readonly [number, number];
|
|
114
|
+
readonly description: 'Offset';
|
|
115
|
+
};
|
|
116
|
+
readonly seed: {
|
|
117
|
+
readonly type: 'number';
|
|
118
|
+
readonly min: 0;
|
|
119
|
+
readonly max: 4294967295;
|
|
120
|
+
readonly step: 1;
|
|
121
|
+
readonly integer: true;
|
|
122
|
+
readonly default: number;
|
|
123
|
+
readonly description: 'Seed';
|
|
124
|
+
readonly hiddenFromList: false;
|
|
125
|
+
};
|
|
126
|
+
readonly flakes: {
|
|
127
|
+
readonly type: 'number';
|
|
128
|
+
readonly min: 0;
|
|
129
|
+
readonly max: 200000;
|
|
130
|
+
readonly step: 1;
|
|
131
|
+
readonly integer: true;
|
|
132
|
+
readonly default: 10000;
|
|
133
|
+
readonly description: 'Flakes';
|
|
134
|
+
readonly hiddenFromList: false;
|
|
135
|
+
};
|
|
136
|
+
readonly sizeVariation: {
|
|
137
|
+
readonly type: 'number';
|
|
138
|
+
readonly min: 0;
|
|
139
|
+
readonly max: 1;
|
|
140
|
+
readonly step: 0.01;
|
|
141
|
+
readonly default: 0.5;
|
|
142
|
+
readonly description: 'Size variation';
|
|
143
|
+
readonly hiddenFromList: false;
|
|
144
|
+
};
|
|
145
|
+
readonly speedVariation: {
|
|
146
|
+
readonly type: 'number';
|
|
147
|
+
readonly min: 0;
|
|
148
|
+
readonly max: 1;
|
|
149
|
+
readonly step: 0.01;
|
|
150
|
+
readonly default: 0.5;
|
|
151
|
+
readonly description: 'Speed variation';
|
|
152
|
+
readonly hiddenFromList: false;
|
|
153
|
+
};
|
|
154
|
+
readonly wiggleAmount: {
|
|
155
|
+
readonly type: 'number';
|
|
156
|
+
readonly min: 0;
|
|
157
|
+
readonly max: 100;
|
|
158
|
+
readonly step: 0.01;
|
|
159
|
+
readonly default: 2;
|
|
160
|
+
readonly description: 'Wiggle amount';
|
|
161
|
+
readonly hiddenFromList: false;
|
|
162
|
+
};
|
|
163
|
+
readonly wiggleAmountVariation: {
|
|
164
|
+
readonly type: 'number';
|
|
165
|
+
readonly min: 0;
|
|
166
|
+
readonly max: 1;
|
|
167
|
+
readonly step: 0.01;
|
|
168
|
+
readonly default: 0.5;
|
|
169
|
+
readonly description: 'Wiggle amount variation';
|
|
170
|
+
readonly hiddenFromList: false;
|
|
171
|
+
};
|
|
172
|
+
readonly wiggleFrequency: {
|
|
173
|
+
readonly type: 'number';
|
|
174
|
+
readonly min: 0;
|
|
175
|
+
readonly max: 20;
|
|
176
|
+
readonly step: 0.01;
|
|
177
|
+
readonly default: 1;
|
|
178
|
+
readonly description: 'Wiggle frequency';
|
|
179
|
+
readonly hiddenFromList: false;
|
|
180
|
+
};
|
|
181
|
+
readonly wiggleFrequencyVariation: {
|
|
182
|
+
readonly type: 'number';
|
|
183
|
+
readonly min: 0;
|
|
184
|
+
readonly max: 1;
|
|
185
|
+
readonly step: 0.01;
|
|
186
|
+
readonly default: 0.5;
|
|
187
|
+
readonly description: 'Wiggle frequency variation';
|
|
188
|
+
readonly hiddenFromList: false;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
export declare const snowFall: (params?: (WeatherCommonParams & {
|
|
192
|
+
/** Number of flakes, an integer from `0` to `200000`. Defaults to `10000`. */
|
|
193
|
+
readonly flakes?: number;
|
|
194
|
+
/** Size variation, from `0` to `1`. Defaults to `0.5`. */
|
|
195
|
+
readonly sizeVariation?: number;
|
|
196
|
+
/** Speed variation, from `0` to `1`. Defaults to `0.5`. */
|
|
197
|
+
readonly speedVariation?: number;
|
|
198
|
+
/** Sideways oscillation strength, from `0` to `100`. Defaults to `2`. */
|
|
199
|
+
readonly wiggleAmount?: number;
|
|
200
|
+
/** Wiggle amplitude variation, from `0` to `1`. Defaults to `0.5`. */
|
|
201
|
+
readonly wiggleAmountVariation?: number;
|
|
202
|
+
/** Sideways oscillations per second, from `0` to `20`. Defaults to `1`. */
|
|
203
|
+
readonly wiggleFrequency?: number;
|
|
204
|
+
/** Wiggle frequency variation, from `0` to `1`. Defaults to `0.5`. */
|
|
205
|
+
readonly wiggleFrequencyVariation?: number;
|
|
206
|
+
} & {
|
|
207
|
+
readonly disabled?: boolean;
|
|
208
|
+
}) | undefined) => import("remotion").EffectDescriptor<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SPECKLE_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, density: f32, radius: f32, randomness: 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\nfn hash22(p: vec2f) -> vec2f { return vec2f(hash21(p + vec2f(17.13)), hash21(p + vec2f(83.71))); }\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n let color = textureSampleLevel(source, sourceSampler, input.uv, 0);\n if (params.density <= 0.0 || params.radius <= 0.0) { return color; }\n let fragPos = vec2f(input.uv.x, 1.0 - input.uv.y) * params.size;\n let cellSize = max(params.radius * 2.5, 1.0);\n let baseCell = floor(fragPos / cellSize);\n var hole = 0.0;\n for (var y = -1; y <= 1; y++) {\n for (var x = -1; x <= 1; x++) {\n let cell = baseCell + vec2f(f32(x), f32(y));\n if (hash21(cell) <= params.density) {\n let randomOffset = (hash22(cell + vec2f(11.7)) - vec2f(0.5)) * params.randomness;\n let center = (cell + vec2f(0.5) + randomOffset) * cellSize;\n let variation = mix(1.0, 0.35 + hash21(cell + vec2f(29.43)) * 0.65, params.randomness);\n let radius = params.radius * 0.5 * variation;\n let edge = min(1.0, max(radius * 0.5, 0.35));\n hole = max(hole, 1.0 - smoothstep(radius - edge, radius + edge, length(fragPos - center)));\n }\n }\n }\n return color * (1.0 - clamp(hole, 0.0, 1.0));\n}\n\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SPHERE_WEBGL_SHADER = "#version 300 es\nprecision highp float;\nuniform sampler2D uSource;\nuniform vec4 uParams[3];\nout vec4 fragColor;\nvec4 sampleFace(vec3 normal, mat3 inverseRotation) {\n vec3 local = inverseRotation * normal;\n // Longitude wraps at the seam; latitude spans the complete image height.\n vec2 uv = vec2(fract(atan(local.x, local.z) / 6.28318530718 + 0.5), asin(clamp(local.y, -1.0, 1.0)) / 3.14159265359 + 0.5);\n vec4 color = textureLod(uSource, vec2(uv.x, 1.0 - uv.y), 0.0);\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 vec2 p = (position - uParams[0].zw) / uParams[1].x;\n float distanceSquared = dot(p, p);\n float coverage = 1.0 - smoothstep(1.0 - fwidth(distanceSquared), 1.0, distanceSquared);\n if (distanceSquared >= 1.0) { return vec4(0); }\n float z = sqrt(1.0 - distanceSquared);\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 inverseRotation = transpose(rz * ry * rx);\n vec4 front = sampleFace(vec3(p, z), inverseRotation);\n vec4 back = sampleFace(vec3(p, -z), inverseRotation);\n if (uParams[1].w == 1.0) { return front * coverage; }\n if (uParams[1].w == 2.0) { return back * coverage; }\n return (front + back * (1.0 - front.a)) * coverage;\n}\n\nvoid main() { fragColor = project(vec2(gl_FragCoord.x, uParams[0].y - gl_FragCoord.y)); }\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const STARBURST_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 values: 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 var center = vec2f(input.position.x, params.geometry.y - input.position.y) / params.geometry.xy - params.values.zw;\n center.x *= params.geometry.x / params.geometry.y;\n let angle = atan2(center.y, center.x) + params.values.x;\n let normalizedAngle = (angle + 3.14159265359) / (2.0 * 3.14159265359);\n let sector = normalizedAngle * params.geometry.z;\n let rayIndex = glslModulo(floor(sector), params.geometry.z);\n let colorIndex = glslModulo(rayIndex, params.geometry.w);\n var col = paletteColor(colorIndex).rgb;\n let fractSector = fract(sector);\n let edgeSmooth = params.values.y * 0.5;\n let nextColorIndex = glslModulo(rayIndex + 1.0, params.geometry.w);\n let nextCol = paletteColor(nextColorIndex).rgb;\n let blend = smoothstep(1.0 - edgeSmooth, 1.0, fractSector);\n col = mix(col, nextCol, blend);\n let blendStart = smoothstep(edgeSmooth, 0.0, fractSector);\n let prevColorIndex = glslModulo(rayIndex - 1.0 + params.geometry.w, params.geometry.w);\n let prevCol = paletteColor(prevColorIndex).rgb;\n col = mix(col, prevCol, blendStart);\n return vec4f(col, 1.0);\n\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TEAR_WEBGPU_SHADER = "\nstruct Params {resolution: vec2f, angle: f32, progress: f32, rotation: f32, jaggedness: f32,}\nstruct VertexOutput {@builtin(position) position: vec4f, @location(0) uv: vec2f,}\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@vertex fn vertex(@builtin(vertex_index) index: u32, @builtin(instance_index) instance: u32) -> VertexOutput {\n let aPos=vec2f(f32(index%2u),f32(index/2u)/192.0);\n let side=select(-1.0,1.0,instance!=0u);\n let direction=radians(params.angle);let dc=cos(direction);let ds=sin(direction);\n let toCanvas=mat2x2f(vec2f(dc,-ds),vec2f(ds,dc));\n let extent=vec2f(abs(dc)*params.resolution.x+abs(ds)*params.resolution.y,abs(ds)*params.resolution.x+abs(dc)*params.resolution.y);\n let outerEdge=select(0.0,extent.x,side>=0.0);\n let zigzag=1.0-4.0*abs(fract(aPos.y*6.0+0.25)-0.5);\n let seam=extent.x*0.5+zigzag*min(params.jaggedness,extent.x*0.45);\n let source=vec2f(mix(outerEdge,seam,aPos.x),aPos.y*extent.y);\n let sourceCanvas=toCanvas*(source-extent*0.5)+params.resolution*0.5;\n let tearProgress=min(params.progress,1.0);\n let tipY=tearProgress*extent.y;\n let pivot=vec2f(extent.x*0.5,tipY);\n let fullAngle=radians(params.rotation)*tearProgress;\n let bendHeight=max(extent.y*0.15,fullAngle*extent.x*1.5);\n let bend=smoothstep(0.0,bendHeight,tipY-source.y);\n let angle=side*fullAngle*bend;let c=cos(angle);let s=sin(angle);\n let delta=source-pivot;\n var position=pivot+vec2f(c*delta.x-s*delta.y,s*delta.x+c*delta.y);\n position.x+=side*max(params.progress-1.0,0.0)*extent.x*0.5;\n position=toCanvas*(position-extent*0.5)+params.resolution*0.5;\n var output: VertexOutput;\n // Mesh runtime restores orientation after resolving WebGL-compatible samples.\n output.position=vec4f(position.x/params.resolution.x*2.0-1.0,position.y/params.resolution.y*2.0-1.0,0,1);\n output.uv=sourceCanvas/params.resolution;\n return output;\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n if (any(input.uv<vec2f(0)) || any(input.uv>vec2f(1))) {discard;}\n return textureSample(sourceTexture,sourceSampler,input.uv);\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const THERMAL_VISION_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 { amount: f32, paletteLength: f32, }\n@group(0) @binding(3) var palette: texture_2d<f32>;\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 rgb=color.rgb/color.a;\n let luminance=dot(rgb,vec3f(0.299,0.587,0.114));\n let position=clamp(luminance,0.0,1.0)*(max(params.paletteLength,2.0)-1.0);\n let index=i32(floor(position));\n let first=textureLoad(palette,vec2i(index,0),0).rgb;\n let last=textureLoad(palette,vec2i(min(index+1,i32(params.paletteLength)-1),0),0).rgb;\n let thermal=mix(first,last,fract(position));\n return vec4f(mix(rgb,thermal,clamp(params.amount,0.0,1.0))*color.a,color.a);\n}\n\n";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type TileBounds = {
|
|
2
|
+
left: number;
|
|
3
|
+
top: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const createTileGpuImplementations: <P, S>({ setupBounds, getBounds, resolve, }: {
|
|
8
|
+
setupBounds: (target: HTMLCanvasElement) => S;
|
|
9
|
+
getBounds: (input: {
|
|
10
|
+
source: CanvasImageSource;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
params: P;
|
|
14
|
+
state: S;
|
|
15
|
+
}) => TileBounds | null;
|
|
16
|
+
resolve: (params: P) => {
|
|
17
|
+
horizontal: boolean;
|
|
18
|
+
vertical: boolean;
|
|
19
|
+
};
|
|
20
|
+
}) => {
|
|
21
|
+
webgl2: import("remotion").EffectImplementation<P, unknown>;
|
|
22
|
+
webgpu: import("remotion").EffectImplementation<P, unknown>;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TURBULENT_DISPLACE_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, offset: vec2f, amount: f32, scale: f32, complexity: f32, evolution: f32, cycle: f32, seed: u32, displacement: f32, pinning: f32, cycleEvolution: f32, }\nfn noiseType() -> i32 { return 2; }\n\nfn lattice(point: vec3i, seed: u32) -> f32 {\n let p = bitcast<vec3u>(point) & vec3u(65535u);\n var h = (p.x*0x27d4eb2du) ^ (p.y*0x165667b1u) ^ (p.z*0x9e3779b9u) ^ (seed*0x85ebca6bu);\n h ^= h >> 15u; h *= 0x2c1b3c6du; h ^= h >> 12u; h *= 0x297a2d39u; h ^= h >> 15u;\n return f32(h & 65535u)/65535.0;\n}\nfn catmull(p: vec4f, t: f32) -> f32 {\n return 0.5*(2.0*p.y+(p.z-p.x)*t+(2.0*p.x-5.0*p.y+4.0*p.z-p.w)*t*t+(3.0*p.y-p.x-3.0*p.z+p.w)*t*t*t);\n}\nfn bspline(t: f32) -> vec3f { return vec3f(0.5*(1.0-t)*(1.0-t),0.5+t*(1.0-t),0.5*t*t); }\nfn sliceNoise(p: vec3i,t: vec2f,seed: u32) -> f32 {\n if(noiseType()==0) { return lattice(p,seed); }\n if(noiseType()==1) { return mix(mix(lattice(p,seed),lattice(p+vec3i(1,0,0),seed),t.x),mix(lattice(p+vec3i(0,1,0),seed),lattice(p+vec3i(1,1,0),seed),t.x),t.y); }\n if(noiseType()==2) {\n let wx=bspline(t.x); let wy=bspline(t.y); var result=0.0;\n for(var y=0;y<3;y++) { for(var x=0;x<3;x++) { result += wx[x]*wy[y]*lattice(p+vec3i(x-1,y-1,0),seed); } }\n return result;\n }\n var rows: vec4f;\n for(var y=0;y<4;y++) {\n var row: vec4f;\n for(var x=0;x<4;x++) { row[x]=lattice(p+vec3i(x-1,y-1,0),seed); }\n rows[y]=catmull(row,t.x);\n }\n return catmull(rows,t.y);\n}\nfn valueNoise(point: vec3f,seed: u32) -> f32 {\n let offset=select(0.0,0.5,noiseType()==2);\n let shifted=point+vec3f(offset,offset,0.0);\n let p=shifted-floor(shifted/65536.0)*65536.0;\n let cell=vec3i(floor(p)); let t=fract(p);\n let fz=t.z*t.z*t.z*(t.z*(t.z*6.0-15.0)+10.0);\n let n=mix(sliceNoise(cell,t.xy,seed),sliceNoise(cell+vec3i(0,0,1),t.xy,seed),fz);\n return select(n,0.5+(n-0.5)*(181.0/231.0)/0.55,noiseType()==2);\n}\n\nfn noiseLayer(p: vec2f,z: f32,seed: u32) -> f32 {\n if(params.cycleEvolution==0.0) { return valueNoise(vec3f(p,params.evolution+z),seed); }\n let t=params.evolution-floor(params.evolution/params.cycle)*params.cycle;\n let weight=smoothstep(0.0,1.0,t/params.cycle);\n return mix(valueNoise(vec3f(p,t+z),seed),valueNoise(vec3f(p,t-params.cycle+z),seed),weight);\n}\nfn turbulence(p: vec2f,channel: u32) -> f32 {\n var sum=0.0; var norm=0.0; var amplitude=1.0; var frequency=1.0;\n let falloff=select(0.5,0.3,params.displacement>=3.0 && params.displacement<=5.0);\n for(var octave=0;octave<10;octave++) {\n let weight=clamp(params.complexity-f32(octave),0.0,1.0);\n if(weight==0.0) { break; }\n let seed=(params.seed ^ 0x7d15u)+channel+u32(octave)*101u;\n sum += noiseLayer(p*frequency,f32(octave)*5.17,seed)*amplitude*weight;\n norm += amplitude*weight; amplitude *= falloff; frequency *= 2.0;\n }\n return sum/norm-0.5;\n}\nfn readPixel(p: vec2i) -> vec4f {\n if(any(p<vec2i(0)) || any(p>=vec2i(params.size))) { return vec4f(0); }\n let sourceSize=vec2i(textureDimensions(source));\n let sourcePixel=p+vec2i(0,sourceSize.y-i32(params.size.y));\n if(any(sourcePixel<vec2i(0)) || any(sourcePixel>=sourceSize)) { return vec4f(0); }\n return textureLoad(source,sourcePixel,0);\n}\nfn sampleSource(p: vec2f) -> vec4f {\n let base=vec2i(floor(p-vec2f(0.5))); let t=fract(p-vec2f(0.5));\n return mix(mix(readPixel(base),readPixel(base+vec2i(1,0)),t.x),mix(readPixel(base+vec2i(0,1)),readPixel(base+vec2i(1,1)),t.x),t.y);\n}\n@fragment fn fragment(input: VertexOutput) -> @location(0) vec4f {\n if(params.amount==0.0) { return textureSampleLevel(source,sourceSampler,input.uv,0); }\n let pixel=input.uv*params.size;\n let p=(pixel-params.offset*params.size)/params.scale;\n let mode=i32(params.displacement);\n var displacement: vec2f;\n if(mode==1 || mode==2 || mode==4 || mode==5) {\n let epsilon=0.05;\n let gradient=vec2f(turbulence(p+vec2f(epsilon,0),0u)-turbulence(p-vec2f(epsilon,0),0u),turbulence(p+vec2f(0,epsilon),0u)-turbulence(p-vec2f(0,epsilon),0u))/(2.0*epsilon);\n displacement=select(vec2f(-gradient.y,gradient.x),gradient,mode==1 || mode==4)*params.amount*0.25;\n } else if(mode==6) { displacement=vec2f(0,turbulence(p,17u)*params.amount); }\n else if(mode==7) { displacement=vec2f(turbulence(p,0u)*params.amount,0); }\n else if(mode==8) { displacement=vec2f(turbulence(p,0u)*params.amount); }\n else { displacement=vec2f(turbulence(p,0u),turbulence(p,17u))*params.amount; }\n let locked=params.pinning>=8.0;\n let pin=select(params.pinning,params.pinning-7.0,locked);\n let edge=max(1.0,min(params.size.x,params.size.y)*select(0.1,0.25,locked));\n let nearEdge=clamp((pixel-vec2f(0.5))/edge,vec2f(0),vec2f(1));\n let farEdge=clamp((params.size-vec2f(0.5)-pixel)/edge,vec2f(0),vec2f(1));\n let horizontal=min(nearEdge.x,farEdge.x); let vertical=min(nearEdge.y,farEdge.y);\n var weight=1.0;\n if(pin==1.0) { weight=min(horizontal,vertical); }\n if(pin==2.0) { weight=vertical; } if(pin==3.0) { weight=horizontal; }\n if(pin==4.0) { weight=nearEdge.x; } if(pin==5.0) { weight=nearEdge.y; }\n if(pin==6.0) { weight=farEdge.x; } if(pin==7.0) { weight=farEdge.y; }\n var sourcePixel=pixel+displacement*weight;\n if(locked) { sourcePixel=clamp(sourcePixel,vec2f(0.5),params.size-vec2f(0.5)); }\n return sampleSource(sourcePixel);\n}\n\n";
|