@luma.gl/effects 9.1.9 → 9.2.0-alpha.2
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/dist/dist.dev.js +1162 -851
- package/dist/dist.min.js +7 -6
- package/dist/index.cjs +560 -65
- package/dist/index.cjs.map +3 -3
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +3 -3
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +9 -9
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/denoise.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/denoise.js +9 -5
- package/dist/passes/postprocessing/image-adjust-filters/denoise.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js +5 -4
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts +3 -3
- package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/noise.js +7 -7
- package/dist/passes/postprocessing/image-adjust-filters/noise.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts +1 -0
- package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/sepia.js +25 -0
- package/dist/passes/postprocessing/image-adjust-filters/sepia.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts +1 -0
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.js +20 -0
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vignette.js +19 -9
- package/dist/passes/postprocessing/image-adjust-filters/vignette.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts +5 -3
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.js +52 -4
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts +8 -6
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.js +41 -3
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts +8 -6
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.js +42 -4
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts +3 -2
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js +41 -2
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts +3 -2
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.js +29 -2
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts +4 -2
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/edgework.js +36 -2
- package/dist/passes/postprocessing/image-fun-filters/edgework.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +3 -2
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js +49 -2
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.d.ts +3 -2
- package/dist/passes/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.js +34 -2
- package/dist/passes/postprocessing/image-fun-filters/ink.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts +2 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.js +26 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts +5 -3
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js +33 -2
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts +5 -3
- package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/swirl.js +35 -2
- package/dist/passes/postprocessing/image-warp-filters/swirl.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.d.ts +2 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.js +14 -3
- package/dist/passes/postprocessing/image-warp-filters/warp.js.map +1 -1
- package/package.json +3 -3
- package/src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +10 -10
- package/src/passes/postprocessing/image-adjust-filters/denoise.ts +9 -5
- package/src/passes/postprocessing/image-adjust-filters/huesaturation.ts +5 -4
- package/src/passes/postprocessing/image-adjust-filters/noise.ts +9 -8
- package/src/passes/postprocessing/image-adjust-filters/sepia.ts +26 -0
- package/src/passes/postprocessing/image-adjust-filters/vibrance.ts +21 -0
- package/src/passes/postprocessing/image-adjust-filters/vignette.ts +20 -10
- package/src/passes/postprocessing/image-blur-filters/tiltshift.ts +55 -5
- package/src/passes/postprocessing/image-blur-filters/triangleblur.ts +44 -4
- package/src/passes/postprocessing/image-blur-filters/zoomblur.ts +45 -5
- package/src/passes/postprocessing/image-fun-filters/colorhalftone.ts +44 -3
- package/src/passes/postprocessing/image-fun-filters/dotscreen.ts +32 -3
- package/src/passes/postprocessing/image-fun-filters/edgework.ts +38 -3
- package/src/passes/postprocessing/image-fun-filters/hexagonalpixelate.ts +52 -3
- package/src/passes/postprocessing/image-fun-filters/ink.ts +36 -3
- package/src/passes/postprocessing/image-fun-filters/magnify.ts +29 -1
- package/src/passes/postprocessing/image-warp-filters/bulgepinch.ts +36 -3
- package/src/passes/postprocessing/image-warp-filters/swirl.ts +36 -3
- package/src/passes/postprocessing/image-warp-filters/warp.ts +16 -3
package/dist/index.cjs
CHANGED
|
@@ -47,21 +47,21 @@ module.exports = __toCommonJS(dist_exports);
|
|
|
47
47
|
var source = (
|
|
48
48
|
/* wgsl */
|
|
49
49
|
`struct brightnessContrastUniforms {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
brightness: f32,
|
|
51
|
+
contrast: f32
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
// Binding 0:1 is reserved for shader passes
|
|
55
|
-
@
|
|
55
|
+
@group(0) @binding(1) var<uniform> brightnessContrast : brightnessContrastUniforms;
|
|
56
56
|
|
|
57
|
-
fn brightnessContrast_filterColor_ext(color:
|
|
57
|
+
fn brightnessContrast_filterColor_ext(color: vec4f, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4f {
|
|
58
58
|
color.rgb += brightnessContrast.brightness;
|
|
59
59
|
if (brightnessContrast.contrast > 0.0) {
|
|
60
60
|
color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;
|
|
61
61
|
} else {
|
|
62
62
|
color.rgb = (color.rgb - 0.5) * (1.0 + brightnessContrast.contrast) + 0.5;
|
|
63
63
|
}
|
|
64
|
-
return
|
|
64
|
+
return vec4f(1.0, 0.0, 0.0, 1.0);
|
|
65
65
|
}
|
|
66
66
|
`
|
|
67
67
|
);
|
|
@@ -88,8 +88,10 @@ vec4 brightnessContrast_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord)
|
|
|
88
88
|
`
|
|
89
89
|
);
|
|
90
90
|
var brightnessContrast = {
|
|
91
|
-
props: {},
|
|
92
91
|
name: "brightnessContrast",
|
|
92
|
+
source,
|
|
93
|
+
fs,
|
|
94
|
+
props: {},
|
|
93
95
|
uniformTypes: {
|
|
94
96
|
brightness: "f32",
|
|
95
97
|
contrast: "f32"
|
|
@@ -102,19 +104,21 @@ var brightnessContrast = {
|
|
|
102
104
|
brightness: { format: "f32", value: 0, min: -1, max: 1 },
|
|
103
105
|
contrast: { format: "f32", value: 0, min: -1, max: 1 }
|
|
104
106
|
},
|
|
105
|
-
passes: [{ filter: true }]
|
|
106
|
-
source,
|
|
107
|
-
fs
|
|
107
|
+
passes: [{ filter: true }]
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
// dist/passes/postprocessing/image-adjust-filters/denoise.js
|
|
111
111
|
var source2 = (
|
|
112
112
|
/* wgsl */
|
|
113
113
|
`
|
|
114
|
-
|
|
114
|
+
struct denoiseUniforms {
|
|
115
|
+
strength: f32
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
@group(0), @binding(1) var<uniform> denoise: denoiseUniforms;
|
|
115
119
|
|
|
116
120
|
fn denoise_sampleColor(source: sampler2D, texSize: vec2<f32>, texCoord: vec2<f32>) -> vec4<f32> {
|
|
117
|
-
let adjustedExponent: f32 = 3. + 200. * pow(1. -
|
|
121
|
+
let adjustedExponent: f32 = 3. + 200. * pow(1. - denoise.strength, 4.);
|
|
118
122
|
let center: vec4<f32> = sample_texture(BUFFER_source, texCoord);
|
|
119
123
|
var color: vec4<f32> = vec4<f32>(0.);
|
|
120
124
|
var total: f32 = 0.;
|
|
@@ -137,11 +141,11 @@ fn denoise_sampleColor(source: sampler2D, texSize: vec2<f32>, texCoord: vec2<f32
|
|
|
137
141
|
);
|
|
138
142
|
var fs2 = (
|
|
139
143
|
/* glsl */
|
|
140
|
-
`uniform
|
|
144
|
+
`uniform dedenoiseUniforms {
|
|
141
145
|
float strength;
|
|
142
|
-
}
|
|
146
|
+
} denoise;
|
|
143
147
|
|
|
144
|
-
vec4
|
|
148
|
+
vec4 dedenoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
145
149
|
float adjustedExponent = 3. + 200. * pow(1. - noise.strength, 4.);
|
|
146
150
|
|
|
147
151
|
vec4 center = texture(source, texCoord);
|
|
@@ -180,12 +184,13 @@ var denoise = {
|
|
|
180
184
|
// dist/passes/postprocessing/image-adjust-filters/huesaturation.js
|
|
181
185
|
var source3 = (
|
|
182
186
|
/* wgsl */
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
+
`
|
|
188
|
+
struct hueSaturationUniforms {
|
|
189
|
+
hue: f32,
|
|
190
|
+
saturation: f32,
|
|
191
|
+
};
|
|
187
192
|
|
|
188
|
-
|
|
193
|
+
@group(0), @binding(1) var<uniform> hueSaturation: hueSaturationUniforms;
|
|
189
194
|
|
|
190
195
|
fn hueSaturation_filterColor(color: vec4<f32>) -> vec4<f32> {
|
|
191
196
|
let angle: f32 = hueSaturation.hue * 3.1415927;
|
|
@@ -278,13 +283,13 @@ var source4 = (
|
|
|
278
283
|
amount: f32
|
|
279
284
|
};
|
|
280
285
|
|
|
281
|
-
@group(0)
|
|
286
|
+
@group(0) @binding(1) var<uniform> noise: noiseUniforms;
|
|
282
287
|
|
|
283
|
-
fn rand(co:
|
|
284
|
-
return fract(sin(dot(co.xy,
|
|
288
|
+
fn rand(co: vec2f) -> f32 {
|
|
289
|
+
return fract(sin(dot(co.xy, vec2f(12.9898, 78.233))) * 43758.547);
|
|
285
290
|
}
|
|
286
291
|
|
|
287
|
-
fn noise_filterColor_ext(color:
|
|
292
|
+
fn noise_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
288
293
|
let diff: f32 = (rand(texCoord) - 0.5) * noise.amount;
|
|
289
294
|
color.r = color.r + (diff);
|
|
290
295
|
color.g = color.g + (diff);
|
|
@@ -313,21 +318,47 @@ vec4 noise_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
|
313
318
|
`
|
|
314
319
|
);
|
|
315
320
|
var noise = {
|
|
321
|
+
name: "noise",
|
|
322
|
+
fs: fs4,
|
|
323
|
+
source: source4,
|
|
316
324
|
props: {},
|
|
317
325
|
uniforms: {},
|
|
318
|
-
name: "noise",
|
|
319
326
|
uniformTypes: {
|
|
320
327
|
amount: "f32"
|
|
321
328
|
},
|
|
322
329
|
propTypes: {
|
|
323
330
|
amount: { value: 0.5, min: 0, max: 1 }
|
|
324
331
|
},
|
|
325
|
-
fs: fs4,
|
|
326
|
-
source: source4,
|
|
327
332
|
passes: [{ filter: true }]
|
|
328
333
|
};
|
|
329
334
|
|
|
330
335
|
// dist/passes/postprocessing/image-adjust-filters/sepia.js
|
|
336
|
+
var source5 = (
|
|
337
|
+
/* wgsl */
|
|
338
|
+
`struct sepiaUniforms {
|
|
339
|
+
amount: f32
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
@group(0) @binding(1) var<uniform> sepia: sepiaUniforms;
|
|
343
|
+
|
|
344
|
+
fn sepia_filterColor(color: vec4f) -> vec4f {
|
|
345
|
+
let r: f32 = color.r;
|
|
346
|
+
let g: f32 = color.g;
|
|
347
|
+
let b: f32 = color.b;
|
|
348
|
+
|
|
349
|
+
color.r =
|
|
350
|
+
min(1.0, (r * (1.0 - (0.607 * sepia.amount))) + (g * (0.769 * sepia.amount)) + (b * (0.189 * sepia.amount)));
|
|
351
|
+
color.g = min(1.0, (r * 0.349 * sepia.amount) + (g * (1.0 - (0.314 * sepia.amount))) + (b * 0.168 * sepia.amount));
|
|
352
|
+
color.b = min(1.0, (r * 0.272 * sepia.amount) + (g * 0.534 * sepia.amount) + (b * (1.0 - (0.869 * sepia.amount))));
|
|
353
|
+
|
|
354
|
+
return color;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
vec4 sepia_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
358
|
+
return sepia_filterColor(color);
|
|
359
|
+
}
|
|
360
|
+
`
|
|
361
|
+
);
|
|
331
362
|
var fs5 = (
|
|
332
363
|
/* glsl */
|
|
333
364
|
`uniform sepiaUniforms {
|
|
@@ -363,10 +394,32 @@ var sepia = {
|
|
|
363
394
|
amount: { value: 0.5, min: 0, max: 1 }
|
|
364
395
|
},
|
|
365
396
|
fs: fs5,
|
|
397
|
+
source: source5,
|
|
366
398
|
passes: [{ filter: true }]
|
|
367
399
|
};
|
|
368
400
|
|
|
369
401
|
// dist/passes/postprocessing/image-adjust-filters/vibrance.js
|
|
402
|
+
var source6 = (
|
|
403
|
+
/* wgsl */
|
|
404
|
+
`struct vibranceUniforms {
|
|
405
|
+
amount: f32
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
@group(0) @binding(1) var<uniform> vibrance: vibranceUniforms;
|
|
409
|
+
|
|
410
|
+
fn vibrance_filterColor(vec4f color) -> vec4f {
|
|
411
|
+
let average: f32 = (color.r + color.g + color.b) / 3.0;
|
|
412
|
+
let mx: f32 = max(color.r, max(color.g, color.b));
|
|
413
|
+
let amt: f32 = (mx - average) * (-vibrance.amount * 3.0);
|
|
414
|
+
color.rgb = mix(color.rgb, vec3(mx), amt);
|
|
415
|
+
return color;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
vec4 vibrance_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
419
|
+
return vibrance_filterColor(color);
|
|
420
|
+
}
|
|
421
|
+
`
|
|
422
|
+
);
|
|
370
423
|
var fs6 = (
|
|
371
424
|
/* glsl */
|
|
372
425
|
`uniform vibranceUniforms {
|
|
@@ -396,22 +449,33 @@ var vibrance = {
|
|
|
396
449
|
propTypes: {
|
|
397
450
|
amount: { value: 0, min: -1, max: 1 }
|
|
398
451
|
},
|
|
452
|
+
source: source6,
|
|
399
453
|
fs: fs6,
|
|
400
454
|
passes: [{ filter: true }]
|
|
401
455
|
};
|
|
402
456
|
|
|
403
457
|
// dist/passes/postprocessing/image-adjust-filters/vignette.js
|
|
404
458
|
var fs7 = (
|
|
405
|
-
/*
|
|
406
|
-
`
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}
|
|
459
|
+
/* wgsl */
|
|
460
|
+
`struct vignetteUniforms {
|
|
461
|
+
radius: f32,
|
|
462
|
+
amount: f32
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
@group(0) @binding(1) var<uniform> vignette: vignetteUniforms;
|
|
466
|
+
|
|
467
|
+
fn vibrance_filterColor(color: vec4f) -> vec4f {
|
|
468
|
+
let average: f32 = (color.r + color.g + color.b) / 3.0;
|
|
469
|
+
let mx: f32 = max(color.r, max(color.g, color.b));
|
|
470
|
+
let amt: f32 = (mx - average) * (-vibrance.amount * 3.0);
|
|
471
|
+
color.rgb = mix(color.rgb, vec3f(mx), amt);
|
|
472
|
+
return color;
|
|
473
|
+
}
|
|
410
474
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
return color.rgba * ratio + (1.0 - ratio)*
|
|
475
|
+
fn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) ->vec4f {
|
|
476
|
+
let dist: f32 = distance(texCoord, vec2f(0.5, 0.5));
|
|
477
|
+
let ratio: f32 = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));
|
|
478
|
+
return color.rgba * ratio + (1.0 - ratio)*vec4f(0.0, 0.0, 0.0, 1.0);
|
|
415
479
|
}
|
|
416
480
|
`
|
|
417
481
|
);
|
|
@@ -437,6 +501,55 @@ var vignette = {
|
|
|
437
501
|
|
|
438
502
|
// dist/passes/postprocessing/image-blur-filters/tiltshift.js
|
|
439
503
|
var import_shadertools = require("@luma.gl/shadertools");
|
|
504
|
+
var source7 = (
|
|
505
|
+
/* wgsl */
|
|
506
|
+
`uniform tiltShiftUniforms {
|
|
507
|
+
blurRadius: f32,
|
|
508
|
+
gradientRadius: f32,
|
|
509
|
+
start: vec2f,
|
|
510
|
+
end: vec2f,
|
|
511
|
+
invert: u32,
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
@group(0) @binding(1) var<uniform> tiltShift: tiltShiftUniforms;
|
|
515
|
+
|
|
516
|
+
fn tiltShift_getDelta(vec2 texSize) -> vec2f {
|
|
517
|
+
vec2 vector = normalize((tiltShift.end - tiltShift.start) * texSize);
|
|
518
|
+
return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
fn tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
|
|
522
|
+
vec4 color = vec4(0.0);
|
|
523
|
+
float total = 0.0;
|
|
524
|
+
|
|
525
|
+
/* randomize the lookup values to hide the fixed number of samples */
|
|
526
|
+
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
527
|
+
|
|
528
|
+
vec2 normal = normalize(vec2((tiltShift.start.y - tiltShift.end.y) * texSize.y, (tiltShift.end.x - tiltShift.start.x) * texSize.x));
|
|
529
|
+
float radius = smoothstep(0.0, 1.0,
|
|
530
|
+
abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;
|
|
531
|
+
|
|
532
|
+
for (float t = -30.0; t <= 30.0; t++) {
|
|
533
|
+
float percent = (t + offset - 0.5) / 30.0;
|
|
534
|
+
float weight = 1.0 - abs(percent);
|
|
535
|
+
vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);
|
|
536
|
+
|
|
537
|
+
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
|
538
|
+
offsetColor.rgb *= offsetColor.a;
|
|
539
|
+
|
|
540
|
+
color += offsetColor * weight;
|
|
541
|
+
total += weight;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
color = color / total;
|
|
545
|
+
|
|
546
|
+
/* switch back from pre-multiplied alpha */
|
|
547
|
+
color.rgb /= color.a + 0.00001;
|
|
548
|
+
|
|
549
|
+
return color;
|
|
550
|
+
}
|
|
551
|
+
`
|
|
552
|
+
);
|
|
440
553
|
var fs8 = (
|
|
441
554
|
/* glsl */
|
|
442
555
|
`uniform tiltShiftUniforms {
|
|
@@ -485,10 +598,12 @@ vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
485
598
|
`
|
|
486
599
|
);
|
|
487
600
|
var tiltShift = {
|
|
488
|
-
props: {},
|
|
489
|
-
uniforms: {},
|
|
490
601
|
name: "tiltShift",
|
|
491
602
|
dependencies: [import_shadertools.random],
|
|
603
|
+
source: source7,
|
|
604
|
+
fs: fs8,
|
|
605
|
+
props: {},
|
|
606
|
+
uniforms: {},
|
|
492
607
|
uniformTypes: {
|
|
493
608
|
blurRadius: "f32",
|
|
494
609
|
gradientRadius: "f32",
|
|
@@ -506,12 +621,50 @@ var tiltShift = {
|
|
|
506
621
|
passes: [
|
|
507
622
|
{ sampler: true, uniforms: { invert: 0 } },
|
|
508
623
|
{ sampler: true, uniforms: { invert: 1 } }
|
|
509
|
-
]
|
|
510
|
-
fs: fs8
|
|
624
|
+
]
|
|
511
625
|
};
|
|
512
626
|
|
|
513
627
|
// dist/passes/postprocessing/image-blur-filters/triangleblur.js
|
|
514
628
|
var import_shadertools2 = require("@luma.gl/shadertools");
|
|
629
|
+
var source8 = (
|
|
630
|
+
/* wgsl */
|
|
631
|
+
`uniform triangleBlurUniforms {
|
|
632
|
+
radius: f32,
|
|
633
|
+
delta: vec2f,
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
@group(0) @binding(1) var<uniform> triangleBlur: triangleBlurUniforms;
|
|
637
|
+
|
|
638
|
+
vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
639
|
+
vec2 adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;
|
|
640
|
+
|
|
641
|
+
vec4 color = vec4(0.0);
|
|
642
|
+
float total = 0.0;
|
|
643
|
+
|
|
644
|
+
/* randomize the lookup values to hide the fixed number of samples */
|
|
645
|
+
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
646
|
+
|
|
647
|
+
for (float t = -30.0; t <= 30.0; t++) {
|
|
648
|
+
float percent = (t + offset - 0.5) / 30.0;
|
|
649
|
+
float weight = 1.0 - abs(percent);
|
|
650
|
+
vec4 offsetColor = texture(source, texCoord + adjustedDelta * percent);
|
|
651
|
+
|
|
652
|
+
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
|
653
|
+
offsetColor.rgb *= offsetColor.a;
|
|
654
|
+
|
|
655
|
+
color += offsetColor * weight;
|
|
656
|
+
total += weight;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
color = color / total;
|
|
660
|
+
|
|
661
|
+
/* switch back from pre-multiplied alpha */
|
|
662
|
+
color.rgb /= color.a + 0.00001;
|
|
663
|
+
|
|
664
|
+
return color;
|
|
665
|
+
}
|
|
666
|
+
`
|
|
667
|
+
);
|
|
515
668
|
var fs9 = (
|
|
516
669
|
/* glsl */
|
|
517
670
|
`uniform triangleBlurUniforms {
|
|
@@ -550,9 +703,12 @@ vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
550
703
|
`
|
|
551
704
|
);
|
|
552
705
|
var triangleBlur = {
|
|
706
|
+
name: "triangleBlur",
|
|
707
|
+
dependencies: [import_shadertools2.random],
|
|
708
|
+
source: source8,
|
|
709
|
+
fs: fs9,
|
|
553
710
|
props: {},
|
|
554
711
|
uniforms: {},
|
|
555
|
-
name: "triangleBlur",
|
|
556
712
|
uniformTypes: {
|
|
557
713
|
radius: "f32",
|
|
558
714
|
delta: "vec2<f32>"
|
|
@@ -561,8 +717,6 @@ var triangleBlur = {
|
|
|
561
717
|
radius: { value: 20, min: 0, softMax: 100 },
|
|
562
718
|
delta: { value: [1, 0], private: true }
|
|
563
719
|
},
|
|
564
|
-
fs: fs9,
|
|
565
|
-
dependencies: [import_shadertools2.random],
|
|
566
720
|
passes: [
|
|
567
721
|
{ sampler: true, uniforms: { delta: [1, 0] } },
|
|
568
722
|
{ sampler: true, uniforms: { delta: [0, 1] } }
|
|
@@ -571,7 +725,49 @@ var triangleBlur = {
|
|
|
571
725
|
|
|
572
726
|
// dist/passes/postprocessing/image-blur-filters/zoomblur.js
|
|
573
727
|
var import_shadertools3 = require("@luma.gl/shadertools");
|
|
574
|
-
var
|
|
728
|
+
var source9 = (
|
|
729
|
+
/* wgsl */
|
|
730
|
+
`
|
|
731
|
+
uniform zoomBlurUniforms {
|
|
732
|
+
center: vec2f,
|
|
733
|
+
strength: f32,
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
@group(0) @binding(1) var<uniform> zoomBlur : zoomBlurUniforms;
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
fn zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
|
|
740
|
+
vec4 color = vec4(0.0);
|
|
741
|
+
float total = 0.0;
|
|
742
|
+
vec2 toCenter = zoomBlur.center * texSize - texCoord * texSize;
|
|
743
|
+
|
|
744
|
+
/* randomize the lookup values to hide the fixed number of samples */
|
|
745
|
+
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
746
|
+
|
|
747
|
+
for (float t = 0.0; t <= 40.0; t++) {
|
|
748
|
+
float percent = (t + offset) / 40.0;
|
|
749
|
+
float weight = 4.0 * (percent - percent * percent);
|
|
750
|
+
vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);
|
|
751
|
+
|
|
752
|
+
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
|
753
|
+
offsetColor.rgb *= offsetColor.a;
|
|
754
|
+
|
|
755
|
+
color += offsetColor * weight;
|
|
756
|
+
total += weight;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
color = color / total;
|
|
760
|
+
|
|
761
|
+
/* switch back from pre-multiplied alpha */
|
|
762
|
+
color.rgb /= color.a + 0.00001;
|
|
763
|
+
|
|
764
|
+
return color;
|
|
765
|
+
}
|
|
766
|
+
`
|
|
767
|
+
);
|
|
768
|
+
var fs10 = (
|
|
769
|
+
/* glsl */
|
|
770
|
+
`
|
|
575
771
|
uniform zoomBlurUniforms {
|
|
576
772
|
vec2 center;
|
|
577
773
|
float strength;
|
|
@@ -604,11 +800,15 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
604
800
|
|
|
605
801
|
return color;
|
|
606
802
|
}
|
|
607
|
-
|
|
803
|
+
`
|
|
804
|
+
);
|
|
608
805
|
var zoomBlur = {
|
|
806
|
+
name: "zoomBlur",
|
|
807
|
+
dependencies: [import_shadertools3.random],
|
|
808
|
+
source: source9,
|
|
809
|
+
fs: fs10,
|
|
609
810
|
props: {},
|
|
610
811
|
uniforms: {},
|
|
611
|
-
name: "zoomBlur",
|
|
612
812
|
uniformTypes: {
|
|
613
813
|
center: "vec2<f32>",
|
|
614
814
|
strength: "f32"
|
|
@@ -617,12 +817,50 @@ var zoomBlur = {
|
|
|
617
817
|
center: { value: [0.5, 0.5] },
|
|
618
818
|
strength: { value: 0.3, min: 0, softMax: 1 }
|
|
619
819
|
},
|
|
620
|
-
fs: fs10,
|
|
621
|
-
dependencies: [import_shadertools3.random],
|
|
622
820
|
passes: [{ sampler: true }]
|
|
623
821
|
};
|
|
624
822
|
|
|
625
823
|
// dist/passes/postprocessing/image-fun-filters/colorhalftone.js
|
|
824
|
+
var source10 = (
|
|
825
|
+
/* wgsl */
|
|
826
|
+
`struct colorHalftoneUniforms {
|
|
827
|
+
center: vec2f,
|
|
828
|
+
angle: f32,
|
|
829
|
+
size: f32.
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
@group(0) @binding(1) var<uniform> colorHalftone: colorHalftoneUniforms;
|
|
833
|
+
|
|
834
|
+
fn pattern(angle: f32, scale: f32, texSize: vec2f, texCoord: vec2f) -> f32 {
|
|
835
|
+
let s: f32 = sin(angle), c = cos(angle);
|
|
836
|
+
let tex: vec2f = texCoord * texSize - colorHalftone.center * texSize;
|
|
837
|
+
let point: vec2f = vec2(
|
|
838
|
+
c * tex.x - s * tex.y,
|
|
839
|
+
s * tex.x + c * tex.y
|
|
840
|
+
) * scale;
|
|
841
|
+
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
fn colorHalftone_filterColor_ext(vec4f color, vec2f texSize, vec2f texCoord) -> vec4f {
|
|
845
|
+
let scale: f32 = 3.1514 / colorHalftone.size;
|
|
846
|
+
let cmy: vec3f = 1.0 - color.rgb;
|
|
847
|
+
let k: f32 = min(cmy.x, min(cmy.y, cmy.z));
|
|
848
|
+
|
|
849
|
+
cmy = (cmy - k) / (1.0 - k);
|
|
850
|
+
cmy = clamp(
|
|
851
|
+
cmy * 10.0 - 3.0 + vec3(
|
|
852
|
+
pattern(colorHalftone.angle + 0.26179, scale, texSize, texCoord),
|
|
853
|
+
pattern(colorHalftone.angle + 1.30899, scale, texSize, texCoord),
|
|
854
|
+
pattern(colorHalftone.angle, scale, texSize, texCoord)
|
|
855
|
+
),
|
|
856
|
+
0.0,
|
|
857
|
+
1.0
|
|
858
|
+
);
|
|
859
|
+
k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
|
|
860
|
+
return vec4(1.0 - cmy - k, color.a);
|
|
861
|
+
}
|
|
862
|
+
`
|
|
863
|
+
);
|
|
626
864
|
var fs11 = (
|
|
627
865
|
/* glsl */
|
|
628
866
|
`uniform colorHalftoneUniforms {
|
|
@@ -662,9 +900,11 @@ vec4 colorHalftone_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
|
662
900
|
`
|
|
663
901
|
);
|
|
664
902
|
var colorHalftone = {
|
|
903
|
+
name: "colorHalftone",
|
|
904
|
+
source: source10,
|
|
905
|
+
fs: fs11,
|
|
665
906
|
props: {},
|
|
666
907
|
uniforms: {},
|
|
667
|
-
name: "colorHalftone",
|
|
668
908
|
uniformTypes: {
|
|
669
909
|
center: "vec2<f32>",
|
|
670
910
|
angle: "f32",
|
|
@@ -675,11 +915,38 @@ var colorHalftone = {
|
|
|
675
915
|
angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
|
|
676
916
|
size: { value: 4, min: 1, softMin: 3, softMax: 20 }
|
|
677
917
|
},
|
|
678
|
-
fs: fs11,
|
|
679
918
|
passes: [{ filter: true }]
|
|
680
919
|
};
|
|
681
920
|
|
|
682
921
|
// dist/passes/postprocessing/image-fun-filters/dotscreen.js
|
|
922
|
+
var source11 = (
|
|
923
|
+
/* wgsl */
|
|
924
|
+
`uniform dotScreenUniforms {
|
|
925
|
+
center: vec2f,
|
|
926
|
+
angle: f32,
|
|
927
|
+
size: f32,
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
@group(0) @binding(1) dotScreen: dotScreenUniforms;
|
|
931
|
+
|
|
932
|
+
fn pattern(texSize: vec2f, texCoord: vec2f) -> f32 {
|
|
933
|
+
let scale: f32 = 3.1415 / dotScreen.size;
|
|
934
|
+
|
|
935
|
+
let s: f32 = sin(dotScreen.angle), c = cos(dotScreen.angle);
|
|
936
|
+
tex: vec2f = texCoord * texSize - dotScreen.center * texSize;
|
|
937
|
+
point = vec2f(
|
|
938
|
+
c: * tex.x - s * tex.y,
|
|
939
|
+
s * tex.x + c * tex.y
|
|
940
|
+
) * scale;
|
|
941
|
+
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
fn dotScreen_filterColor_ext(vec4 color, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
945
|
+
let average: f32 = (color.r + color.g + color.b) / 3.0;
|
|
946
|
+
return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
|
|
947
|
+
}
|
|
948
|
+
`
|
|
949
|
+
);
|
|
683
950
|
var fs12 = (
|
|
684
951
|
/* glsl */
|
|
685
952
|
`uniform dotScreenUniforms {
|
|
@@ -707,9 +974,11 @@ vec4 dotScreen_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
|
707
974
|
`
|
|
708
975
|
);
|
|
709
976
|
var dotScreen = {
|
|
977
|
+
name: "dotScreen",
|
|
978
|
+
source: source11,
|
|
979
|
+
fs: fs12,
|
|
710
980
|
props: {},
|
|
711
981
|
uniforms: {},
|
|
712
|
-
name: "dotScreen",
|
|
713
982
|
uniformTypes: {
|
|
714
983
|
center: "vec2<f32>",
|
|
715
984
|
angle: "f32",
|
|
@@ -720,12 +989,46 @@ var dotScreen = {
|
|
|
720
989
|
angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
|
|
721
990
|
size: { value: 3, min: 1, softMin: 3, softMax: 20 }
|
|
722
991
|
},
|
|
723
|
-
fs: fs12,
|
|
724
992
|
passes: [{ filter: true }]
|
|
725
993
|
};
|
|
726
994
|
|
|
727
995
|
// dist/passes/postprocessing/image-fun-filters/edgework.js
|
|
728
996
|
var import_shadertools4 = require("@luma.gl/shadertools");
|
|
997
|
+
var source12 = (
|
|
998
|
+
/* wgsl */
|
|
999
|
+
`struct edgeWorkUniforms {
|
|
1000
|
+
radius: f32,
|
|
1001
|
+
int mode: uint32,
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
@group(0) @binding(1) var<uniform> edgeWork: edgeWorkUniforms;
|
|
1005
|
+
|
|
1006
|
+
fn edgeWork_sampleColorRGB(sampler2D source, vec2 texSize, vec2 texCoord, vec2 delta) -> vec4f {
|
|
1007
|
+
vec2 relativeDelta = edgeWork.radius * delta / texSize;
|
|
1008
|
+
|
|
1009
|
+
vec2 color = vec2(0.0);
|
|
1010
|
+
vec2 total = vec2(0.0);
|
|
1011
|
+
|
|
1012
|
+
/* randomize the lookup values to hide the fixed number of samples */
|
|
1013
|
+
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
1014
|
+
|
|
1015
|
+
for (float t = -30.0; t <= 30.0; t++) {
|
|
1016
|
+
float percent = (t + offset - 0.5) / 30.0;
|
|
1017
|
+
float weight = 1.0 - abs(percent);
|
|
1018
|
+
vec3 sampleColor = texture(source, texCoord + relativeDelta * percent).rgb;
|
|
1019
|
+
float average = (sampleColor.r + sampleColor.g + sampleColor.b) / 3.0;
|
|
1020
|
+
color.x += average * weight;
|
|
1021
|
+
total.x += weight;
|
|
1022
|
+
if (abs(t) < 15.0) {
|
|
1023
|
+
weight = weight * 2.0 - 1.0;
|
|
1024
|
+
color.y += average * weight;
|
|
1025
|
+
total.y += weight;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
return vec4(color / total, 0.0, 1.0);
|
|
1029
|
+
}
|
|
1030
|
+
`
|
|
1031
|
+
);
|
|
729
1032
|
var fs13 = (
|
|
730
1033
|
/* glsl */
|
|
731
1034
|
`uniform edgeWorkUniforms {
|
|
@@ -795,11 +1098,12 @@ vec4 edgeWork_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
795
1098
|
`
|
|
796
1099
|
);
|
|
797
1100
|
var edgeWork = {
|
|
798
|
-
props: {},
|
|
799
|
-
uniforms: {},
|
|
800
1101
|
name: "edgeWork",
|
|
801
1102
|
dependencies: [import_shadertools4.random],
|
|
1103
|
+
source: source12,
|
|
802
1104
|
fs: fs13,
|
|
1105
|
+
props: {},
|
|
1106
|
+
uniforms: {},
|
|
803
1107
|
uniformTypes: {
|
|
804
1108
|
radius: "f32",
|
|
805
1109
|
mode: "i32"
|
|
@@ -821,6 +1125,54 @@ var edgeWork = {
|
|
|
821
1125
|
};
|
|
822
1126
|
|
|
823
1127
|
// dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js
|
|
1128
|
+
var source13 = (
|
|
1129
|
+
/* wgsl */
|
|
1130
|
+
`struct hexagonalPixelateUniforms {
|
|
1131
|
+
center: vec2f,
|
|
1132
|
+
scale: f32,
|
|
1133
|
+
};
|
|
1134
|
+
|
|
1135
|
+
@group(0) @binding(1) var<uniform> hexagonalPixelate: hexagonalPixelateUniforms;
|
|
1136
|
+
|
|
1137
|
+
fn hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
|
|
1138
|
+
vec2 tex = (texCoord * texSize - hexagonalPixelate.center * texSize) / hexagonalPixelate.scale;
|
|
1139
|
+
tex.y /= 0.866025404;
|
|
1140
|
+
tex.x -= tex.y * 0.5;
|
|
1141
|
+
|
|
1142
|
+
vec2 a;
|
|
1143
|
+
if (tex.x + tex.y - floor(tex.x) - floor(tex.y) < 1.0) {
|
|
1144
|
+
a = vec2(floor(tex.x), floor(tex.y));
|
|
1145
|
+
}
|
|
1146
|
+
else a = vec2(ceil(tex.x), ceil(tex.y));
|
|
1147
|
+
vec2 b = vec2(ceil(tex.x), floor(tex.y));
|
|
1148
|
+
vec2 c = vec2(floor(tex.x), ceil(tex.y));
|
|
1149
|
+
|
|
1150
|
+
vec3 TEX = vec3(tex.x, tex.y, 1.0 - tex.x - tex.y);
|
|
1151
|
+
vec3 A = vec3(a.x, a.y, 1.0 - a.x - a.y);
|
|
1152
|
+
vec3 B = vec3(b.x, b.y, 1.0 - b.x - b.y);
|
|
1153
|
+
vec3 C = vec3(c.x, c.y, 1.0 - c.x - c.y);
|
|
1154
|
+
|
|
1155
|
+
float alen = length(TEX - A);
|
|
1156
|
+
float blen = length(TEX - B);
|
|
1157
|
+
float clen = length(TEX - C);
|
|
1158
|
+
|
|
1159
|
+
vec2 choice;
|
|
1160
|
+
if (alen < blen) {
|
|
1161
|
+
if (alen < clen) choice = a;
|
|
1162
|
+
else choice = c;
|
|
1163
|
+
} else {
|
|
1164
|
+
if (blen < clen) choice = b;
|
|
1165
|
+
else choice = c;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
choice.x += choice.y * 0.5;
|
|
1169
|
+
choice.y *= 0.866025404;
|
|
1170
|
+
choice *= hexagonalPixelate.scale / texSize;
|
|
1171
|
+
|
|
1172
|
+
return texture(source, choice + hexagonalPixelate.center);
|
|
1173
|
+
}
|
|
1174
|
+
`
|
|
1175
|
+
);
|
|
824
1176
|
var fs14 = (
|
|
825
1177
|
/* glsl */
|
|
826
1178
|
`uniform hexagonalPixelateUniforms {
|
|
@@ -868,9 +1220,11 @@ vec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord
|
|
|
868
1220
|
`
|
|
869
1221
|
);
|
|
870
1222
|
var hexagonalPixelate = {
|
|
1223
|
+
name: "hexagonalPixelate",
|
|
1224
|
+
source: source13,
|
|
1225
|
+
fs: fs14,
|
|
871
1226
|
props: {},
|
|
872
1227
|
uniforms: {},
|
|
873
|
-
name: "hexagonalPixelate",
|
|
874
1228
|
uniformTypes: {
|
|
875
1229
|
center: "vec2<f32>",
|
|
876
1230
|
scale: "f32"
|
|
@@ -879,11 +1233,43 @@ var hexagonalPixelate = {
|
|
|
879
1233
|
center: { value: [0.5, 0.5], hint: "screenspace" },
|
|
880
1234
|
scale: { value: 10, min: 1, softMin: 5, softMax: 50 }
|
|
881
1235
|
},
|
|
882
|
-
fs: fs14,
|
|
883
1236
|
passes: [{ sampler: true }]
|
|
884
1237
|
};
|
|
885
1238
|
|
|
886
1239
|
// dist/passes/postprocessing/image-fun-filters/ink.js
|
|
1240
|
+
var source14 = (
|
|
1241
|
+
/* wgsl */
|
|
1242
|
+
`uniform inkUniforms {
|
|
1243
|
+
strength: f32,
|
|
1244
|
+
};
|
|
1245
|
+
|
|
1246
|
+
@group(0) @binding(1) var<uniform> ink: inkUniforms;
|
|
1247
|
+
|
|
1248
|
+
fn ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
|
|
1249
|
+
vec2 dx = vec2(1.0 / texSize.x, 0.0);
|
|
1250
|
+
vec2 dy = vec2(0.0, 1.0 / texSize.y);
|
|
1251
|
+
vec4 color = texture(source, texCoord);
|
|
1252
|
+
float bigTotal = 0.0;
|
|
1253
|
+
float smallTotal = 0.0;
|
|
1254
|
+
vec3 bigAverage = vec3(0.0);
|
|
1255
|
+
vec3 smallAverage = vec3(0.0);
|
|
1256
|
+
for (float x = -2.0; x <= 2.0; x += 1.0) {
|
|
1257
|
+
for (float y = -2.0; y <= 2.0; y += 1.0) {
|
|
1258
|
+
vec3 offsetColor = texture(source, texCoord + dx * x + dy * y).rgb;
|
|
1259
|
+
bigAverage += offsetColor;
|
|
1260
|
+
bigTotal += 1.0;
|
|
1261
|
+
if (abs(x) + abs(y) < 2.0) {
|
|
1262
|
+
smallAverage += offsetColor;
|
|
1263
|
+
smallTotal += 1.0;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);
|
|
1268
|
+
float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
|
|
1269
|
+
return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
|
|
1270
|
+
}
|
|
1271
|
+
`
|
|
1272
|
+
);
|
|
887
1273
|
var fs15 = (
|
|
888
1274
|
/* glsl */
|
|
889
1275
|
`uniform inkUniforms {
|
|
@@ -916,10 +1302,11 @@ vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
916
1302
|
`
|
|
917
1303
|
);
|
|
918
1304
|
var ink = {
|
|
919
|
-
props: {},
|
|
920
|
-
uniforms: {},
|
|
921
1305
|
name: "ink",
|
|
1306
|
+
source: source14,
|
|
922
1307
|
fs: fs15,
|
|
1308
|
+
props: {},
|
|
1309
|
+
uniforms: {},
|
|
923
1310
|
uniformTypes: {
|
|
924
1311
|
strength: "f32"
|
|
925
1312
|
},
|
|
@@ -930,6 +1317,32 @@ var ink = {
|
|
|
930
1317
|
};
|
|
931
1318
|
|
|
932
1319
|
// dist/passes/postprocessing/image-fun-filters/magnify.js
|
|
1320
|
+
var source15 = (
|
|
1321
|
+
/* wgsl */
|
|
1322
|
+
`uniform magnifyUniforms {
|
|
1323
|
+
screenXY: vec2f;
|
|
1324
|
+
radiusPixels: f32;
|
|
1325
|
+
zoom: f32;
|
|
1326
|
+
borderWidthPixels: f32;
|
|
1327
|
+
borderColor: vec4f;
|
|
1328
|
+
};
|
|
1329
|
+
|
|
1330
|
+
@group(0) @binding(1) var<uniform> magnify: magnifyUniforms;
|
|
1331
|
+
|
|
1332
|
+
fn magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
|
|
1333
|
+
vec2 pos = vec2(magnify.screenXY.x, 1.0 - magnify.screenXY.y);
|
|
1334
|
+
float dist = distance(texCoord * texSize, pos * texSize);
|
|
1335
|
+
if (dist < magnify.radiusPixels) {
|
|
1336
|
+
return texture(source, (texCoord - pos) / magnify.zoom + pos);
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
if (dist <= magnify.radiusPixels + magnify.borderWidthPixels) {
|
|
1340
|
+
return magnify.borderColor;
|
|
1341
|
+
}
|
|
1342
|
+
return texture(source, texCoord);
|
|
1343
|
+
}
|
|
1344
|
+
`
|
|
1345
|
+
);
|
|
933
1346
|
var fs16 = (
|
|
934
1347
|
/* glsl */
|
|
935
1348
|
`uniform magnifyUniforms {
|
|
@@ -956,6 +1369,8 @@ vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
956
1369
|
);
|
|
957
1370
|
var magnify = {
|
|
958
1371
|
name: "magnify",
|
|
1372
|
+
source: source15,
|
|
1373
|
+
fs: fs16,
|
|
959
1374
|
uniformTypes: {
|
|
960
1375
|
screenXY: "vec2<f32>",
|
|
961
1376
|
radiusPixels: "f32",
|
|
@@ -971,11 +1386,23 @@ var magnify = {
|
|
|
971
1386
|
borderWidthPixels: 0,
|
|
972
1387
|
borderColor: { value: [255, 255, 255, 255] }
|
|
973
1388
|
},
|
|
974
|
-
fs: fs16,
|
|
975
1389
|
passes: [{ sampler: true }]
|
|
976
1390
|
};
|
|
977
1391
|
|
|
978
1392
|
// dist/passes/postprocessing/image-warp-filters/warp.js
|
|
1393
|
+
var source16 = (
|
|
1394
|
+
/* wgsl */
|
|
1395
|
+
`vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
|
|
1396
|
+
vec4 color = texture(source, coord / texSize);
|
|
1397
|
+
vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
|
|
1398
|
+
if (coord != clampedCoord) {
|
|
1399
|
+
/* fade to transparent if we are outside the image */
|
|
1400
|
+
color.a *= max(0.0, 1.0 - length(coord - clampedCoord));
|
|
1401
|
+
}
|
|
1402
|
+
return color;
|
|
1403
|
+
}
|
|
1404
|
+
`
|
|
1405
|
+
);
|
|
979
1406
|
var fs17 = (
|
|
980
1407
|
/* glsl */
|
|
981
1408
|
`vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
|
|
@@ -985,18 +1412,50 @@ var fs17 = (
|
|
|
985
1412
|
/* fade to transparent if we are outside the image */
|
|
986
1413
|
color.a *= max(0.0, 1.0 - length(coord - clampedCoord));
|
|
987
1414
|
}
|
|
988
|
-
|
|
989
1415
|
return color;
|
|
990
1416
|
}
|
|
991
1417
|
`
|
|
992
1418
|
);
|
|
993
1419
|
var warp = {
|
|
994
1420
|
name: "warp",
|
|
995
|
-
|
|
996
|
-
fs: fs17
|
|
1421
|
+
source: source16,
|
|
1422
|
+
fs: fs17,
|
|
1423
|
+
passes: []
|
|
997
1424
|
};
|
|
998
1425
|
|
|
999
1426
|
// dist/passes/postprocessing/image-warp-filters/bulgepinch.js
|
|
1427
|
+
var source17 = (
|
|
1428
|
+
/* wgsl */
|
|
1429
|
+
`uniform bulgePinchUniforms {
|
|
1430
|
+
radius: f32,
|
|
1431
|
+
strength: f32,
|
|
1432
|
+
center: vec2f,
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1435
|
+
@group(0) @binding(1) var<uniform> bulgePinch: bulgePinchUniforms;
|
|
1436
|
+
|
|
1437
|
+
fn bulgePinch_warp(vec2 coord, vec2 texCenter) -> vec2f {
|
|
1438
|
+
coord -= texCenter;
|
|
1439
|
+
float distance = length(coord);
|
|
1440
|
+
if (distance < bulgePinch.radius) {
|
|
1441
|
+
float percent = distance / bulgePinch.radius;
|
|
1442
|
+
if (bulgePinch.strength > 0.0) {
|
|
1443
|
+
coord *= mix(1.0, smoothstep(0.0, bulgePinch.radius / distance, percent), bulgePinch.strength * 0.75);
|
|
1444
|
+
} else {
|
|
1445
|
+
coord *= mix(1.0, pow(percent, 1.0 + bulgePinch.strength * 0.75) * bulgePinch.radius / distance, 1.0 - percent);
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
coord += texCenter;
|
|
1449
|
+
return coord;
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
fn bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
|
|
1453
|
+
vec2 coord = texCoord * texSize;
|
|
1454
|
+
coord = bulgePinch_warp(coord, bulgePinch.center * texSize);
|
|
1455
|
+
return warp_sampleColor(source, texSize, coord);
|
|
1456
|
+
}
|
|
1457
|
+
`
|
|
1458
|
+
);
|
|
1000
1459
|
var fs18 = (
|
|
1001
1460
|
/* glsl */
|
|
1002
1461
|
`uniform bulgePinchUniforms {
|
|
@@ -1029,11 +1488,12 @@ vec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
1029
1488
|
`
|
|
1030
1489
|
);
|
|
1031
1490
|
var bulgePinch = {
|
|
1032
|
-
props: {},
|
|
1033
|
-
uniforms: {},
|
|
1034
1491
|
name: "bulgePinch",
|
|
1035
1492
|
dependencies: [warp],
|
|
1493
|
+
source: source17,
|
|
1036
1494
|
fs: fs18,
|
|
1495
|
+
props: {},
|
|
1496
|
+
uniforms: {},
|
|
1037
1497
|
uniformTypes: {
|
|
1038
1498
|
center: "vec2<f32>",
|
|
1039
1499
|
radius: "f32",
|
|
@@ -1048,6 +1508,40 @@ var bulgePinch = {
|
|
|
1048
1508
|
};
|
|
1049
1509
|
|
|
1050
1510
|
// dist/passes/postprocessing/image-warp-filters/swirl.js
|
|
1511
|
+
var source18 = (
|
|
1512
|
+
/* wgsl */
|
|
1513
|
+
`uniform swirlUniforms {
|
|
1514
|
+
radius: f32,
|
|
1515
|
+
angle: f32,
|
|
1516
|
+
center: vec2f,
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1519
|
+
@group(0) @binding(1) swirl: swirlUniforms;
|
|
1520
|
+
|
|
1521
|
+
fn swirl_warp(vec2 coord, vec2 texCenter) -> vec2f {
|
|
1522
|
+
coord -= texCenter;
|
|
1523
|
+
float distance = length(coord);
|
|
1524
|
+
if (distance < swirl.radius) {
|
|
1525
|
+
float percent = (swirl.radius - distance) / swirl.radius;
|
|
1526
|
+
float theta = percent * percent * swirl.angle;
|
|
1527
|
+
float s = sin(theta);
|
|
1528
|
+
float c = cos(theta);
|
|
1529
|
+
coord = vec2(
|
|
1530
|
+
coord.x * c - coord.y * s,
|
|
1531
|
+
coord.x * s + coord.y * c
|
|
1532
|
+
);
|
|
1533
|
+
}
|
|
1534
|
+
coord += texCenter;
|
|
1535
|
+
return coord;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
fn swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
|
|
1539
|
+
vec2 coord = texCoord * texSize;
|
|
1540
|
+
coord = swirl_warp(coord, swirl.center * texSize);
|
|
1541
|
+
return warp_sampleColor(source, texSize, coord);
|
|
1542
|
+
}
|
|
1543
|
+
`
|
|
1544
|
+
);
|
|
1051
1545
|
var fs19 = (
|
|
1052
1546
|
/* glsl */
|
|
1053
1547
|
`uniform swirlUniforms {
|
|
@@ -1082,11 +1576,12 @@ vec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
1082
1576
|
`
|
|
1083
1577
|
);
|
|
1084
1578
|
var swirl = {
|
|
1085
|
-
props: {},
|
|
1086
|
-
uniforms: {},
|
|
1087
1579
|
name: "swirl",
|
|
1088
1580
|
dependencies: [warp],
|
|
1581
|
+
source: source18,
|
|
1089
1582
|
fs: fs19,
|
|
1583
|
+
props: {},
|
|
1584
|
+
uniforms: {},
|
|
1090
1585
|
uniformTypes: {
|
|
1091
1586
|
center: "vec2<f32>",
|
|
1092
1587
|
radius: "f32",
|