@luma.gl/effects 9.3.0-alpha.4 → 9.3.0-alpha.8
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 +1934 -415
- package/dist/dist.min.js +6 -6
- package/dist/index.cjs +736 -285
- package/dist/index.cjs.map +3 -3
- package/dist/passes/postprocessing/fxaa/fxaa.d.ts +1 -0
- package/dist/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
- package/dist/passes/postprocessing/fxaa/fxaa.js +287 -0
- package/dist/passes/postprocessing/fxaa/fxaa.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +5 -6
- 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 +32 -24
- 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 +25 -32
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/noise.js +9 -8
- package/dist/passes/postprocessing/image-adjust-filters/noise.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/sepia.js +11 -10
- package/dist/passes/postprocessing/image-adjust-filters/sepia.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.js +9 -9
- 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 +10 -14
- package/dist/passes/postprocessing/image-adjust-filters/vignette.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts +2 -2
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.js +35 -17
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts +2 -2
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.js +26 -17
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts +2 -2
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.js +21 -12
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js +19 -17
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts +1 -1
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.js +11 -11
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/edgework.js +84 -13
- package/dist/passes/postprocessing/image-fun-filters/edgework.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js +34 -22
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.d.ts +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.js +25 -16
- package/dist/passes/postprocessing/image-fun-filters/ink.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.js +22 -12
- package/dist/passes/postprocessing/image-fun-filters/magnify.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts +3 -3
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js +27 -13
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts +3 -3
- package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/swirl.js +20 -15
- package/dist/passes/postprocessing/image-warp-filters/swirl.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.d.ts +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.js +9 -4
- package/dist/passes/postprocessing/image-warp-filters/warp.js.map +1 -1
- package/package.json +3 -3
- package/src/passes/postprocessing/fxaa/fxaa.ts +288 -0
- package/src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +5 -6
- package/src/passes/postprocessing/image-adjust-filters/denoise.ts +34 -26
- package/src/passes/postprocessing/image-adjust-filters/huesaturation.ts +27 -34
- package/src/passes/postprocessing/image-adjust-filters/noise.ts +9 -8
- package/src/passes/postprocessing/image-adjust-filters/sepia.ts +11 -10
- package/src/passes/postprocessing/image-adjust-filters/vibrance.ts +9 -9
- package/src/passes/postprocessing/image-adjust-filters/vignette.ts +10 -14
- package/src/passes/postprocessing/image-blur-filters/tiltshift.ts +37 -19
- package/src/passes/postprocessing/image-blur-filters/triangleblur.ts +26 -17
- package/src/passes/postprocessing/image-blur-filters/zoomblur.ts +22 -13
- package/src/passes/postprocessing/image-fun-filters/colorhalftone.ts +19 -17
- package/src/passes/postprocessing/image-fun-filters/dotscreen.ts +11 -11
- package/src/passes/postprocessing/image-fun-filters/edgework.ts +85 -14
- package/src/passes/postprocessing/image-fun-filters/hexagonalpixelate.ts +38 -26
- package/src/passes/postprocessing/image-fun-filters/ink.ts +25 -16
- package/src/passes/postprocessing/image-fun-filters/magnify.ts +22 -12
- package/src/passes/postprocessing/image-warp-filters/bulgepinch.ts +27 -13
- package/src/passes/postprocessing/image-warp-filters/swirl.ts +20 -15
- package/src/passes/postprocessing/image-warp-filters/warp.ts +9 -4
|
@@ -6,42 +6,50 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
|
|
7
7
|
// Do a 9x9 bilateral box filter
|
|
8
8
|
const source = /* wgsl */ `\
|
|
9
|
-
|
|
10
9
|
struct denoiseUniforms {
|
|
11
|
-
strength: f32
|
|
10
|
+
strength: f32,
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
@group(0)
|
|
15
|
-
|
|
16
|
-
fn denoise_sampleColor(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
@group(0) @binding(auto) var<uniform> denoise: denoiseUniforms;
|
|
14
|
+
|
|
15
|
+
fn denoise_sampleColor(
|
|
16
|
+
sourceTexture: texture_2d<f32>,
|
|
17
|
+
sourceTextureSampler: sampler,
|
|
18
|
+
texSize: vec2f,
|
|
19
|
+
texCoord: vec2f
|
|
20
|
+
) -> vec4f {
|
|
21
|
+
let adjustedExponent = 3.0 + 200.0 * pow(1.0 - denoise.strength, 4.0);
|
|
22
|
+
let center = textureSample(sourceTexture, sourceTextureSampler, texCoord);
|
|
23
|
+
var color = vec4f(0.0);
|
|
24
|
+
var total = 0.0;
|
|
25
|
+
|
|
26
|
+
for (var x = -4.0; x <= 4.0; x += 1.0) {
|
|
27
|
+
for (var y = -4.0; y <= 4.0; y += 1.0) {
|
|
28
|
+
let offsetColor = textureSample(
|
|
29
|
+
sourceTexture,
|
|
30
|
+
sourceTextureSampler,
|
|
31
|
+
texCoord + vec2f(x, y) / texSize
|
|
32
|
+
);
|
|
33
|
+
let weight = pow(
|
|
34
|
+
1.0 - abs(dot(offsetColor.rgb - center.rgb, vec3f(0.25))),
|
|
35
|
+
adjustedExponent
|
|
36
|
+
);
|
|
37
|
+
color += offsetColor * weight;
|
|
38
|
+
total += weight;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
}
|
|
42
|
+
return color / total;
|
|
43
|
+
}
|
|
36
44
|
`;
|
|
37
45
|
|
|
38
46
|
const fs = /* glsl */ `\
|
|
39
|
-
uniform
|
|
47
|
+
uniform denoiseUniforms {
|
|
40
48
|
float strength;
|
|
41
49
|
} denoise;
|
|
42
50
|
|
|
43
|
-
vec4
|
|
44
|
-
float adjustedExponent = 3. + 200. * pow(1. -
|
|
51
|
+
vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
52
|
+
float adjustedExponent = 3. + 200. * pow(1. - denoise.strength, 4.);
|
|
45
53
|
|
|
46
54
|
vec4 center = texture(source, texCoord);
|
|
47
55
|
vec4 color = vec4(0.0);
|
|
@@ -5,45 +5,38 @@
|
|
|
5
5
|
import type {ShaderPass} from '@luma.gl/shadertools';
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
|
-
|
|
9
8
|
struct hueSaturationUniforms {
|
|
10
9
|
hue: f32,
|
|
11
10
|
saturation: f32,
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
@group(0)
|
|
15
|
-
|
|
16
|
-
fn hueSaturation_filterColor(color:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return color;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
fn hueSaturation_filterColor_ext(color: vec4<f32>, texSize: vec2<f32>, texCoord: vec2<f32>) -> vec4<f32> {
|
|
45
|
-
return hueSaturation_filterColor(color);
|
|
46
|
-
}
|
|
13
|
+
@group(0) @binding(auto) var<uniform> hueSaturation: hueSaturationUniforms;
|
|
14
|
+
|
|
15
|
+
fn hueSaturation_filterColor(color: vec4f) -> vec4f {
|
|
16
|
+
let angle = hueSaturation.hue * 3.14159265;
|
|
17
|
+
let s = sin(angle);
|
|
18
|
+
let c = cos(angle);
|
|
19
|
+
let weights = (vec3f(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + vec3f(1.0)) / 3.0;
|
|
20
|
+
|
|
21
|
+
var resultRgb = vec3f(
|
|
22
|
+
dot(color.rgb, weights.xyz),
|
|
23
|
+
dot(color.rgb, weights.zxy),
|
|
24
|
+
dot(color.rgb, weights.yzx)
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
let average = (resultRgb.r + resultRgb.g + resultRgb.b) / 3.0;
|
|
28
|
+
if (hueSaturation.saturation > 0.0) {
|
|
29
|
+
resultRgb += (vec3f(average) - resultRgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));
|
|
30
|
+
} else {
|
|
31
|
+
resultRgb += (vec3f(average) - resultRgb) * (-hueSaturation.saturation);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return vec4f(resultRgb, color.a);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fn hueSaturation_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
38
|
+
return hueSaturation_filterColor(color);
|
|
39
|
+
}
|
|
47
40
|
`;
|
|
48
41
|
|
|
49
42
|
const fs = /* glsl */ `\
|
|
@@ -6,22 +6,23 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
8
|
struct noiseUniforms {
|
|
9
|
-
amount: f32
|
|
9
|
+
amount: f32,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
@group(0) @binding(
|
|
12
|
+
@group(0) @binding(auto) var<uniform> noise: noiseUniforms;
|
|
13
13
|
|
|
14
14
|
fn rand(co: vec2f) -> f32 {
|
|
15
15
|
return fract(sin(dot(co.xy, vec2f(12.9898, 78.233))) * 43758.547);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
fn noise_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
let diff = (rand(texCoord) - 0.5) * noise.amount;
|
|
20
|
+
var result = color;
|
|
21
|
+
result.r += diff;
|
|
22
|
+
result.g += diff;
|
|
23
|
+
result.b += diff;
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
25
26
|
`;
|
|
26
27
|
|
|
27
28
|
const fs = /* glsl */ `\
|
|
@@ -6,25 +6,26 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
8
|
struct sepiaUniforms {
|
|
9
|
-
amount: f32
|
|
9
|
+
amount: f32,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
@group(0) @binding(
|
|
12
|
+
@group(0) @binding(auto) var<uniform> sepia: sepiaUniforms;
|
|
13
13
|
|
|
14
14
|
fn sepia_filterColor(color: vec4f) -> vec4f {
|
|
15
|
-
let r
|
|
16
|
-
let g
|
|
17
|
-
let b
|
|
15
|
+
let r = color.r;
|
|
16
|
+
let g = color.g;
|
|
17
|
+
let b = color.b;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
var result = color;
|
|
20
|
+
result.r =
|
|
20
21
|
min(1.0, (r * (1.0 - (0.607 * sepia.amount))) + (g * (0.769 * sepia.amount)) + (b * (0.189 * sepia.amount)));
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
result.g = min(1.0, (r * 0.349 * sepia.amount) + (g * (1.0 - (0.314 * sepia.amount))) + (b * 0.168 * sepia.amount));
|
|
23
|
+
result.b = min(1.0, (r * 0.272 * sepia.amount) + (g * 0.534 * sepia.amount) + (b * (1.0 - (0.869 * sepia.amount))));
|
|
23
24
|
|
|
24
|
-
return
|
|
25
|
+
return result;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
fn sepia_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
28
29
|
return sepia_filterColor(color);
|
|
29
30
|
}
|
|
30
31
|
`;
|
|
@@ -6,20 +6,20 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
8
|
struct vibranceUniforms {
|
|
9
|
-
amount: f32
|
|
9
|
+
amount: f32,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
@group(0) @binding(
|
|
12
|
+
@group(0) @binding(auto) var<uniform> vibrance: vibranceUniforms;
|
|
13
13
|
|
|
14
|
-
fn vibrance_filterColor(vec4f
|
|
15
|
-
let average
|
|
16
|
-
let mx
|
|
17
|
-
let amt
|
|
18
|
-
|
|
19
|
-
return color;
|
|
14
|
+
fn vibrance_filterColor(color: vec4f) -> vec4f {
|
|
15
|
+
let average = (color.r + color.g + color.b) / 3.0;
|
|
16
|
+
let mx = max(color.r, max(color.g, color.b));
|
|
17
|
+
let amt = (mx - average) * (-vibrance.amount * 3.0);
|
|
18
|
+
let resultRgb = mix(color.rgb, vec3f(mx), amt);
|
|
19
|
+
return vec4f(resultRgb, color.a);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
fn vibrance_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
23
23
|
return vibrance_filterColor(color);
|
|
24
24
|
}
|
|
25
25
|
`;
|
|
@@ -7,23 +7,19 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
8
|
struct vignetteUniforms {
|
|
9
9
|
radius: f32,
|
|
10
|
-
amount: f32
|
|
10
|
+
amount: f32,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
@group(0) @binding(
|
|
13
|
+
@group(0) @binding(auto) var<uniform> vignette: vignetteUniforms;
|
|
14
14
|
|
|
15
|
-
fn
|
|
16
|
-
let
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
fn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) ->vec4f {
|
|
24
|
-
let dist: f32 = distance(texCoord, vec2f(0.5, 0.5));
|
|
25
|
-
let ratio: f32 = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));
|
|
26
|
-
return color.rgba * ratio + (1.0 - ratio)*vec4f(0.0, 0.0, 0.0, 1.0);
|
|
15
|
+
fn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
16
|
+
let dist = distance(texCoord, vec2f(0.5, 0.5));
|
|
17
|
+
let ratio = smoothstep(
|
|
18
|
+
0.8,
|
|
19
|
+
vignette.radius * 0.799,
|
|
20
|
+
dist * (vignette.amount + vignette.radius)
|
|
21
|
+
);
|
|
22
|
+
return color * ratio + vec4f(0.0, 0.0, 0.0, 1.0) * (1.0 - ratio);
|
|
27
23
|
}
|
|
28
24
|
`;
|
|
29
25
|
|
|
@@ -6,7 +6,7 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
import {random} from '@luma.gl/shadertools';
|
|
7
7
|
|
|
8
8
|
const source = /* wgsl */ `\
|
|
9
|
-
|
|
9
|
+
struct tiltShiftUniforms {
|
|
10
10
|
blurRadius: f32,
|
|
11
11
|
gradientRadius: f32,
|
|
12
12
|
start: vec2f,
|
|
@@ -14,34 +14,52 @@ uniform tiltShiftUniforms {
|
|
|
14
14
|
invert: u32,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
@group(0) @binding(
|
|
17
|
+
@group(0) @binding(auto) var<uniform> tiltShift: tiltShiftUniforms;
|
|
18
18
|
|
|
19
|
-
fn tiltShift_getDelta(
|
|
20
|
-
|
|
21
|
-
return
|
|
19
|
+
fn tiltShift_getDelta(texSize: vec2f) -> vec2f {
|
|
20
|
+
let vector = normalize((tiltShift.end - tiltShift.start) * texSize);
|
|
21
|
+
return select(vector, vec2f(-vector.y, vector.x), tiltShift.invert != 0u);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
fn tiltShift_sampleColor(
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
fn tiltShift_sampleColor(
|
|
25
|
+
sourceTexture: texture_2d<f32>,
|
|
26
|
+
sourceTextureSampler: sampler,
|
|
27
|
+
texSize: vec2f,
|
|
28
|
+
texCoord: vec2f
|
|
29
|
+
) -> vec4f {
|
|
30
|
+
var color = vec4f(0.0);
|
|
31
|
+
var total = 0.0;
|
|
27
32
|
|
|
28
33
|
/* randomize the lookup values to hide the fixed number of samples */
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);
|
|
35
|
+
|
|
36
|
+
let normal = normalize(
|
|
37
|
+
vec2f(
|
|
38
|
+
(tiltShift.start.y - tiltShift.end.y) * texSize.y,
|
|
39
|
+
(tiltShift.end.x - tiltShift.start.x) * texSize.x
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
let radius =
|
|
43
|
+
smoothstep(
|
|
44
|
+
0.0,
|
|
45
|
+
1.0,
|
|
46
|
+
abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius
|
|
47
|
+
) * tiltShift.blurRadius;
|
|
48
|
+
|
|
49
|
+
for (var t = -30.0; t <= 30.0; t += 1.0) {
|
|
50
|
+
let percent = (t + offset - 0.5) / 30.0;
|
|
51
|
+
let weight = 1.0 - abs(percent);
|
|
52
|
+
let offsetColor = textureSample(
|
|
53
|
+
sourceTexture,
|
|
54
|
+
sourceTextureSampler,
|
|
55
|
+
texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius
|
|
56
|
+
);
|
|
39
57
|
|
|
40
58
|
color += offsetColor * weight;
|
|
41
59
|
total += weight;
|
|
42
60
|
}
|
|
43
61
|
|
|
44
|
-
color
|
|
62
|
+
color /= total;
|
|
45
63
|
return color;
|
|
46
64
|
}
|
|
47
65
|
`;
|
|
@@ -6,40 +6,49 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
import {random} from '@luma.gl/shadertools';
|
|
7
7
|
|
|
8
8
|
const source = /* wgsl */ `\
|
|
9
|
-
|
|
9
|
+
struct triangleBlurUniforms {
|
|
10
10
|
radius: f32,
|
|
11
11
|
delta: vec2f,
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
13
|
|
|
14
|
-
@group(0) @binding(
|
|
14
|
+
@group(0) @binding(auto) var<uniform> triangleBlur: triangleBlurUniforms;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
fn triangleBlur_sampleColor(
|
|
17
|
+
sourceTexture: texture_2d<f32>,
|
|
18
|
+
sourceTextureSampler: sampler,
|
|
19
|
+
texSize: vec2f,
|
|
20
|
+
texCoord: vec2f
|
|
21
|
+
) -> vec4f {
|
|
22
|
+
let adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
var color = vec4f(0.0);
|
|
25
|
+
var total = 0.0;
|
|
21
26
|
|
|
22
27
|
/* randomize the lookup values to hide the fixed number of samples */
|
|
23
|
-
|
|
28
|
+
let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);
|
|
24
29
|
|
|
25
|
-
for (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
for (var t = -30.0; t <= 30.0; t += 1.0) {
|
|
31
|
+
let percent = (t + offset - 0.5) / 30.0;
|
|
32
|
+
let weight = 1.0 - abs(percent);
|
|
33
|
+
let offsetColor = textureSample(
|
|
34
|
+
sourceTexture,
|
|
35
|
+
sourceTextureSampler,
|
|
36
|
+
texCoord + adjustedDelta * percent
|
|
37
|
+
);
|
|
29
38
|
|
|
30
39
|
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
|
31
|
-
offsetColor.rgb
|
|
40
|
+
let premultipliedOffsetColor = vec4f(offsetColor.rgb * vec3f(offsetColor.a), offsetColor.a);
|
|
32
41
|
|
|
33
|
-
color +=
|
|
42
|
+
color += premultipliedOffsetColor * weight;
|
|
34
43
|
total += weight;
|
|
35
44
|
}
|
|
36
45
|
|
|
37
|
-
color
|
|
46
|
+
color /= total;
|
|
38
47
|
|
|
39
48
|
/* switch back from pre-multiplied alpha */
|
|
40
|
-
color.rgb
|
|
49
|
+
let unpremultipliedRgb = color.rgb / vec3f(color.a + 0.00001);
|
|
41
50
|
|
|
42
|
-
return color;
|
|
51
|
+
return vec4f(unpremultipliedRgb, color.a);
|
|
43
52
|
}
|
|
44
53
|
`;
|
|
45
54
|
|
|
@@ -6,31 +6,40 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
import {random} from '@luma.gl/shadertools';
|
|
7
7
|
|
|
8
8
|
const source = /* wgsl */ `
|
|
9
|
-
|
|
9
|
+
struct zoomBlurUniforms {
|
|
10
10
|
center: vec2f,
|
|
11
11
|
strength: f32,
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
@group(0) @binding(
|
|
14
|
+
@group(0) @binding(auto) var<uniform> zoomBlur : zoomBlurUniforms;
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
fn zoomBlur_sampleColor(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
fn zoomBlur_sampleColor(
|
|
18
|
+
sourceTexture: texture_2d<f32>,
|
|
19
|
+
sourceTextureSampler: sampler,
|
|
20
|
+
texSize: vec2f,
|
|
21
|
+
texCoord: vec2f
|
|
22
|
+
) -> vec4f {
|
|
23
|
+
var color = vec4f(0.0);
|
|
24
|
+
var total = 0.0;
|
|
25
|
+
let toCenter = zoomBlur.center * texSize - texCoord * texSize;
|
|
21
26
|
|
|
22
27
|
/* randomize the lookup values to hide the fixed number of samples */
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);
|
|
29
|
+
|
|
30
|
+
for (var t = 0.0; t <= 40.0; t += 1.0) {
|
|
31
|
+
let percent = (t + offset) / 40.0;
|
|
32
|
+
let weight = 4.0 * (percent - percent * percent);
|
|
33
|
+
let offsetColor = textureSample(
|
|
34
|
+
sourceTexture,
|
|
35
|
+
sourceTextureSampler,
|
|
36
|
+
texCoord + toCenter * percent * zoomBlur.strength / texSize
|
|
37
|
+
);
|
|
29
38
|
color += offsetColor * weight;
|
|
30
39
|
total += weight;
|
|
31
40
|
}
|
|
32
41
|
|
|
33
|
-
color
|
|
42
|
+
color /= total;
|
|
34
43
|
return color;
|
|
35
44
|
}
|
|
36
45
|
`;
|
|
@@ -8,38 +8,40 @@ const source = /* wgsl */ `\
|
|
|
8
8
|
struct colorHalftoneUniforms {
|
|
9
9
|
center: vec2f,
|
|
10
10
|
angle: f32,
|
|
11
|
-
size: f32
|
|
11
|
+
size: f32,
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
@group(0) @binding(
|
|
14
|
+
@group(0) @binding(auto) var<uniform> colorHalftone: colorHalftoneUniforms;
|
|
15
15
|
|
|
16
16
|
fn pattern(angle: f32, scale: f32, texSize: vec2f, texCoord: vec2f) -> f32 {
|
|
17
|
-
let s
|
|
18
|
-
let
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
let s = sin(angle);
|
|
18
|
+
let c = cos(angle);
|
|
19
|
+
let tex = texCoord * texSize - colorHalftone.center * texSize;
|
|
20
|
+
let point = vec2f(
|
|
21
|
+
c * tex.x - s * tex.y,
|
|
22
|
+
s * tex.x + c * tex.y
|
|
22
23
|
) * scale;
|
|
23
24
|
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
fn colorHalftone_filterColor_ext(vec4f
|
|
27
|
-
let scale
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
fn colorHalftone_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
28
|
+
let scale = 3.1514 / colorHalftone.size;
|
|
29
|
+
var cmy = vec3f(1.0) - color.rgb;
|
|
30
|
+
var k = min(cmy.x, min(cmy.y, cmy.z));
|
|
31
|
+
let safeDenominator = max(1.0 - k, 0.00001);
|
|
30
32
|
|
|
31
|
-
cmy = (cmy - k) /
|
|
33
|
+
cmy = (cmy - vec3f(k)) / safeDenominator;
|
|
32
34
|
cmy = clamp(
|
|
33
|
-
|
|
35
|
+
cmy * 10.0 - vec3f(3.0) + vec3f(
|
|
34
36
|
pattern(colorHalftone.angle + 0.26179, scale, texSize, texCoord),
|
|
35
|
-
|
|
37
|
+
pattern(colorHalftone.angle + 1.30899, scale, texSize, texCoord),
|
|
36
38
|
pattern(colorHalftone.angle, scale, texSize, texCoord)
|
|
37
39
|
),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
vec3f(0.0),
|
|
41
|
+
vec3f(1.0)
|
|
40
42
|
);
|
|
41
43
|
k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
|
|
42
|
-
return
|
|
44
|
+
return vec4f(vec3f(1.0) - cmy - vec3f(k), color.a);
|
|
43
45
|
}
|
|
44
46
|
`;
|
|
45
47
|
|
|
@@ -5,29 +5,29 @@
|
|
|
5
5
|
import type {ShaderPass} from '@luma.gl/shadertools';
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
|
-
|
|
8
|
+
struct dotScreenUniforms {
|
|
9
9
|
center: vec2f,
|
|
10
10
|
angle: f32,
|
|
11
11
|
size: f32,
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
@group(0) @binding(
|
|
14
|
+
@group(0) @binding(auto) var<uniform> dotScreen: dotScreenUniforms;
|
|
15
15
|
|
|
16
16
|
fn pattern(texSize: vec2f, texCoord: vec2f) -> f32 {
|
|
17
|
-
let scale
|
|
18
|
-
|
|
19
|
-
let
|
|
20
|
-
tex
|
|
21
|
-
point = vec2f(
|
|
22
|
-
c
|
|
17
|
+
let scale = 3.1415 / dotScreen.size;
|
|
18
|
+
let s = sin(dotScreen.angle);
|
|
19
|
+
let c = cos(dotScreen.angle);
|
|
20
|
+
let tex = texCoord * texSize - dotScreen.center * texSize;
|
|
21
|
+
let point = vec2f(
|
|
22
|
+
c * tex.x - s * tex.y,
|
|
23
23
|
s * tex.x + c * tex.y
|
|
24
24
|
) * scale;
|
|
25
25
|
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
fn dotScreen_filterColor_ext(
|
|
29
|
-
let average
|
|
30
|
-
return
|
|
28
|
+
fn dotScreen_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
29
|
+
let average = (color.r + color.g + color.b) / 3.0;
|
|
30
|
+
return vec4f(vec3f(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
|
|
31
31
|
}
|
|
32
32
|
`;
|
|
33
33
|
|