@luma.gl/effects 9.2.6 → 9.3.0-alpha.10
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 +2686 -644
- package/dist/dist.min.js +10 -9
- package/dist/index.cjs +753 -302
- 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 +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +6 -7
- 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 +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js +26 -33
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/noise.js +10 -9
- package/dist/passes/postprocessing/image-adjust-filters/noise.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/sepia.js +12 -11
- package/dist/passes/postprocessing/image-adjust-filters/sepia.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.js +10 -10
- package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vignette.js +11 -15
- package/dist/passes/postprocessing/image-adjust-filters/vignette.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts +3 -3
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.js +36 -18
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts +3 -3
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.js +27 -18
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts +3 -3
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.js +22 -13
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js +20 -18
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.js +12 -12
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts +3 -3
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/edgework.js +85 -14
- package/dist/passes/postprocessing/image-fun-filters/edgework.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js +35 -23
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.js +26 -17
- package/dist/passes/postprocessing/image-fun-filters/ink.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.js +23 -13
- 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 +28 -14
- 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 +21 -16
- 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 +4 -5
- package/src/passes/postprocessing/fxaa/fxaa.ts +288 -0
- package/src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +6 -7
- package/src/passes/postprocessing/image-adjust-filters/denoise.ts +34 -26
- package/src/passes/postprocessing/image-adjust-filters/huesaturation.ts +28 -35
- package/src/passes/postprocessing/image-adjust-filters/noise.ts +10 -9
- package/src/passes/postprocessing/image-adjust-filters/sepia.ts +12 -11
- package/src/passes/postprocessing/image-adjust-filters/vibrance.ts +10 -10
- package/src/passes/postprocessing/image-adjust-filters/vignette.ts +11 -15
- package/src/passes/postprocessing/image-blur-filters/tiltshift.ts +38 -20
- package/src/passes/postprocessing/image-blur-filters/triangleblur.ts +27 -18
- package/src/passes/postprocessing/image-blur-filters/zoomblur.ts +23 -14
- package/src/passes/postprocessing/image-fun-filters/colorhalftone.ts +20 -18
- package/src/passes/postprocessing/image-fun-filters/dotscreen.ts +12 -12
- package/src/passes/postprocessing/image-fun-filters/edgework.ts +86 -15
- package/src/passes/postprocessing/image-fun-filters/hexagonalpixelate.ts +39 -27
- package/src/passes/postprocessing/image-fun-filters/ink.ts +26 -17
- package/src/passes/postprocessing/image-fun-filters/magnify.ts +23 -13
- package/src/passes/postprocessing/image-warp-filters/bulgepinch.ts +28 -14
- package/src/passes/postprocessing/image-warp-filters/swirl.ts +21 -16
- package/src/passes/postprocessing/image-warp-filters/warp.ts +9 -4
|
@@ -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,40 +14,58 @@ 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
|
`;
|
|
48
66
|
|
|
49
67
|
const fs = /* glsl */ `\
|
|
50
|
-
uniform tiltShiftUniforms {
|
|
68
|
+
layout(std140) uniform tiltShiftUniforms {
|
|
51
69
|
float blurRadius;
|
|
52
70
|
float gradientRadius;
|
|
53
71
|
vec2 start;
|
|
@@ -6,45 +6,54 @@ 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
|
|
|
46
55
|
const fs = /* glsl */ `\
|
|
47
|
-
uniform triangleBlurUniforms {
|
|
56
|
+
layout(std140) uniform triangleBlurUniforms {
|
|
48
57
|
float radius;
|
|
49
58
|
vec2 delta;
|
|
50
59
|
} triangleBlur;
|
|
@@ -6,37 +6,46 @@ 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
|
`;
|
|
37
46
|
|
|
38
47
|
const fs = /* glsl */ `
|
|
39
|
-
uniform zoomBlurUniforms {
|
|
48
|
+
layout(std140) uniform zoomBlurUniforms {
|
|
40
49
|
vec2 center;
|
|
41
50
|
float strength;
|
|
42
51
|
} zoomBlur;
|
|
@@ -8,44 +8,46 @@ 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
|
|
|
46
48
|
// TODO pass texCoord to angle
|
|
47
49
|
const fs = /* glsl */ `\
|
|
48
|
-
uniform colorHalftoneUniforms {
|
|
50
|
+
layout(std140) uniform colorHalftoneUniforms {
|
|
49
51
|
vec2 center;
|
|
50
52
|
float angle;
|
|
51
53
|
float size;
|
|
@@ -5,34 +5,34 @@
|
|
|
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
|
|
|
34
34
|
const fs = /* glsl */ `\
|
|
35
|
-
uniform dotScreenUniforms {
|
|
35
|
+
layout(std140) uniform dotScreenUniforms {
|
|
36
36
|
vec2 center;
|
|
37
37
|
float angle;
|
|
38
38
|
float size;
|
|
@@ -8,25 +8,35 @@ import {random} from '@luma.gl/shadertools';
|
|
|
8
8
|
const source = /* wgsl */ `\
|
|
9
9
|
struct edgeWorkUniforms {
|
|
10
10
|
radius: f32,
|
|
11
|
-
|
|
11
|
+
mode: u32,
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
@group(0) @binding(
|
|
14
|
+
@group(0) @binding(auto) var<uniform> edgeWork: edgeWorkUniforms;
|
|
15
15
|
|
|
16
|
-
fn edgeWork_sampleColorRGB(
|
|
17
|
-
|
|
16
|
+
fn edgeWork_sampleColorRGB(
|
|
17
|
+
sourceTexture: texture_2d<f32>,
|
|
18
|
+
sourceTextureSampler: sampler,
|
|
19
|
+
texSize: vec2f,
|
|
20
|
+
texCoord: vec2f,
|
|
21
|
+
delta: vec2f
|
|
22
|
+
) -> vec4f {
|
|
23
|
+
let relativeDelta = edgeWork.radius * delta / texSize;
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
var color = vec2f(0.0);
|
|
26
|
+
var total = vec2f(0.0);
|
|
21
27
|
|
|
22
28
|
/* randomize the lookup values to hide the fixed number of samples */
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);
|
|
30
|
+
|
|
31
|
+
for (var t = -30.0; t <= 30.0; t += 1.0) {
|
|
32
|
+
let percent = (t + offset - 0.5) / 30.0;
|
|
33
|
+
var weight = 1.0 - abs(percent);
|
|
34
|
+
let sampleColor = textureSample(
|
|
35
|
+
sourceTexture,
|
|
36
|
+
sourceTextureSampler,
|
|
37
|
+
texCoord + relativeDelta * percent
|
|
38
|
+
).rgb;
|
|
39
|
+
let average = (sampleColor.r + sampleColor.g + sampleColor.b) / 3.0;
|
|
30
40
|
color.x += average * weight;
|
|
31
41
|
total.x += weight;
|
|
32
42
|
if (abs(t) < 15.0) {
|
|
@@ -35,12 +45,73 @@ fn edgeWork_sampleColorRGB(sampler2D source, vec2 texSize, vec2 texCoord, vec2 d
|
|
|
35
45
|
total.y += weight;
|
|
36
46
|
}
|
|
37
47
|
}
|
|
38
|
-
return
|
|
48
|
+
return vec4f(color / total, 0.0, 1.0);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
fn edgeWork_sampleColorXY(
|
|
52
|
+
sourceTexture: texture_2d<f32>,
|
|
53
|
+
sourceTextureSampler: sampler,
|
|
54
|
+
texSize: vec2f,
|
|
55
|
+
texCoord: vec2f,
|
|
56
|
+
delta: vec2f
|
|
57
|
+
) -> vec4f {
|
|
58
|
+
let relativeDelta = edgeWork.radius * delta / texSize;
|
|
59
|
+
|
|
60
|
+
var color = vec2f(0.0);
|
|
61
|
+
var total = vec2f(0.0);
|
|
62
|
+
|
|
63
|
+
/* randomize the lookup values to hide the fixed number of samples */
|
|
64
|
+
let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);
|
|
65
|
+
|
|
66
|
+
for (var t = -30.0; t <= 30.0; t += 1.0) {
|
|
67
|
+
let percent = (t + offset - 0.5) / 30.0;
|
|
68
|
+
var weight = 1.0 - abs(percent);
|
|
69
|
+
let sampleColor = textureSample(
|
|
70
|
+
sourceTexture,
|
|
71
|
+
sourceTextureSampler,
|
|
72
|
+
texCoord + relativeDelta * percent
|
|
73
|
+
).xy;
|
|
74
|
+
color.x += sampleColor.x * weight;
|
|
75
|
+
total.x += weight;
|
|
76
|
+
if (abs(t) < 15.0) {
|
|
77
|
+
weight = weight * 2.0 - 1.0;
|
|
78
|
+
color.y += sampleColor.y * weight;
|
|
79
|
+
total.y += weight;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
|
|
84
|
+
return vec4f(c, c, c, 1.0);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
fn edgeWork_sampleColor(
|
|
88
|
+
sourceTexture: texture_2d<f32>,
|
|
89
|
+
sourceTextureSampler: sampler,
|
|
90
|
+
texSize: vec2f,
|
|
91
|
+
texCoord: vec2f
|
|
92
|
+
) -> vec4f {
|
|
93
|
+
if (edgeWork.mode == 0u) {
|
|
94
|
+
return edgeWork_sampleColorRGB(
|
|
95
|
+
sourceTexture,
|
|
96
|
+
sourceTextureSampler,
|
|
97
|
+
texSize,
|
|
98
|
+
texCoord,
|
|
99
|
+
vec2f(1.0, 0.0)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return edgeWork_sampleColorXY(
|
|
104
|
+
sourceTexture,
|
|
105
|
+
sourceTextureSampler,
|
|
106
|
+
texSize,
|
|
107
|
+
texCoord,
|
|
108
|
+
vec2f(0.0, 1.0)
|
|
109
|
+
);
|
|
39
110
|
}
|
|
40
111
|
`;
|
|
41
112
|
|
|
42
113
|
const fs = /* glsl */ `\
|
|
43
|
-
uniform edgeWorkUniforms {
|
|
114
|
+
layout(std140) uniform edgeWorkUniforms {
|
|
44
115
|
float radius;
|
|
45
116
|
int mode;
|
|
46
117
|
} edgeWork;
|
|
@@ -10,49 +10,61 @@ struct hexagonalPixelateUniforms {
|
|
|
10
10
|
scale: f32,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
@group(0) @binding(
|
|
14
|
-
|
|
15
|
-
fn hexagonalPixelate_sampleColor(
|
|
16
|
-
|
|
13
|
+
@group(0) @binding(auto) var<uniform> hexagonalPixelate: hexagonalPixelateUniforms;
|
|
14
|
+
|
|
15
|
+
fn hexagonalPixelate_sampleColor(
|
|
16
|
+
sourceTexture: texture_2d<f32>,
|
|
17
|
+
sourceTextureSampler: sampler,
|
|
18
|
+
texSize: vec2f,
|
|
19
|
+
texCoord: vec2f
|
|
20
|
+
) -> vec4f {
|
|
21
|
+
var tex = (texCoord * texSize - hexagonalPixelate.center * texSize) / hexagonalPixelate.scale;
|
|
17
22
|
tex.y /= 0.866025404;
|
|
18
23
|
tex.x -= tex.y * 0.5;
|
|
19
24
|
|
|
20
|
-
|
|
25
|
+
var a = vec2f(0.0);
|
|
21
26
|
if (tex.x + tex.y - floor(tex.x) - floor(tex.y) < 1.0) {
|
|
22
|
-
a =
|
|
27
|
+
a = vec2f(floor(tex.x), floor(tex.y));
|
|
28
|
+
} else {
|
|
29
|
+
a = vec2f(ceil(tex.x), ceil(tex.y));
|
|
23
30
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
else
|
|
31
|
+
let b = vec2f(ceil(tex.x), floor(tex.y));
|
|
32
|
+
let c = vec2f(floor(tex.x), ceil(tex.y));
|
|
33
|
+
|
|
34
|
+
let texBarycentric = vec3f(tex.x, tex.y, 1.0 - tex.x - tex.y);
|
|
35
|
+
let aBarycentric = vec3f(a.x, a.y, 1.0 - a.x - a.y);
|
|
36
|
+
let bBarycentric = vec3f(b.x, b.y, 1.0 - b.x - b.y);
|
|
37
|
+
let cBarycentric = vec3f(c.x, c.y, 1.0 - c.x - c.y);
|
|
38
|
+
|
|
39
|
+
let aLength = length(texBarycentric - aBarycentric);
|
|
40
|
+
let bLength = length(texBarycentric - bBarycentric);
|
|
41
|
+
let cLength = length(texBarycentric - cBarycentric);
|
|
42
|
+
|
|
43
|
+
var choice = vec2f(0.0);
|
|
44
|
+
if (aLength < bLength) {
|
|
45
|
+
if (aLength < cLength) {
|
|
46
|
+
choice = a;
|
|
47
|
+
} else {
|
|
48
|
+
choice = c;
|
|
49
|
+
}
|
|
41
50
|
} else {
|
|
42
|
-
if (
|
|
43
|
-
|
|
51
|
+
if (bLength < cLength) {
|
|
52
|
+
choice = b;
|
|
53
|
+
} else {
|
|
54
|
+
choice = c;
|
|
55
|
+
}
|
|
44
56
|
}
|
|
45
57
|
|
|
46
58
|
choice.x += choice.y * 0.5;
|
|
47
59
|
choice.y *= 0.866025404;
|
|
48
60
|
choice *= hexagonalPixelate.scale / texSize;
|
|
49
61
|
|
|
50
|
-
return
|
|
62
|
+
return textureSample(sourceTexture, sourceTextureSampler, choice + hexagonalPixelate.center);
|
|
51
63
|
}
|
|
52
64
|
`;
|
|
53
65
|
|
|
54
66
|
const fs = /* glsl */ `\
|
|
55
|
-
uniform hexagonalPixelateUniforms {
|
|
67
|
+
layout(std140) uniform hexagonalPixelateUniforms {
|
|
56
68
|
vec2 center;
|
|
57
69
|
float scale;
|
|
58
70
|
} hexagonalPixelate;
|
|
@@ -5,23 +5,32 @@
|
|
|
5
5
|
import type {ShaderPass} from '@luma.gl/shadertools';
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
|
-
|
|
8
|
+
struct inkUniforms {
|
|
9
9
|
strength: f32,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
@group(0) @binding(
|
|
12
|
+
@group(0) @binding(auto) var<uniform> ink: inkUniforms;
|
|
13
13
|
|
|
14
|
-
fn ink_sampleColor(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
fn ink_sampleColor(
|
|
15
|
+
sourceTexture: texture_2d<f32>,
|
|
16
|
+
sourceTextureSampler: sampler,
|
|
17
|
+
texSize: vec2f,
|
|
18
|
+
texCoord: vec2f
|
|
19
|
+
) -> vec4f {
|
|
20
|
+
let dx = vec2f(1.0 / texSize.x, 0.0);
|
|
21
|
+
let dy = vec2f(0.0, 1.0 / texSize.y);
|
|
22
|
+
let color = textureSample(sourceTexture, sourceTextureSampler, texCoord);
|
|
23
|
+
var bigTotal = 0.0;
|
|
24
|
+
var smallTotal = 0.0;
|
|
25
|
+
var bigAverage = vec3f(0.0);
|
|
26
|
+
var smallAverage = vec3f(0.0);
|
|
27
|
+
for (var x = -2.0; x <= 2.0; x += 1.0) {
|
|
28
|
+
for (var y = -2.0; y <= 2.0; y += 1.0) {
|
|
29
|
+
let offsetColor = textureSample(
|
|
30
|
+
sourceTexture,
|
|
31
|
+
sourceTextureSampler,
|
|
32
|
+
texCoord + dx * x + dy * y
|
|
33
|
+
).rgb;
|
|
25
34
|
bigAverage += offsetColor;
|
|
26
35
|
bigTotal += 1.0;
|
|
27
36
|
if (abs(x) + abs(y) < 2.0) {
|
|
@@ -30,14 +39,14 @@ fn ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
|
|
|
30
39
|
}
|
|
31
40
|
}
|
|
32
41
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return
|
|
42
|
+
let edge = max(vec3f(0.0), bigAverage / bigTotal - smallAverage / smallTotal);
|
|
43
|
+
let power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
|
|
44
|
+
return vec4f(color.rgb - vec3f(dot(edge, edge) * power * 100000.0), color.a);
|
|
36
45
|
}
|
|
37
46
|
`;
|
|
38
47
|
|
|
39
48
|
const fs = /* glsl */ `\
|
|
40
|
-
uniform inkUniforms {
|
|
49
|
+
layout(std140) uniform inkUniforms {
|
|
41
50
|
float strength;
|
|
42
51
|
} ink;
|
|
43
52
|
|
|
@@ -5,32 +5,42 @@
|
|
|
5
5
|
import type {ShaderPass} from '@luma.gl/shadertools';
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
|
-
|
|
9
|
-
screenXY: vec2f
|
|
10
|
-
radiusPixels: f32
|
|
11
|
-
zoom: f32
|
|
12
|
-
borderWidthPixels: f32
|
|
13
|
-
borderColor: vec4f
|
|
8
|
+
struct magnifyUniforms {
|
|
9
|
+
screenXY: vec2f,
|
|
10
|
+
radiusPixels: f32,
|
|
11
|
+
zoom: f32,
|
|
12
|
+
borderWidthPixels: f32,
|
|
13
|
+
borderColor: vec4f,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
@group(0) @binding(
|
|
16
|
+
@group(0) @binding(auto) var<uniform> magnify: magnifyUniforms;
|
|
17
17
|
|
|
18
|
-
fn magnify_sampleColor(
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
fn magnify_sampleColor(
|
|
19
|
+
sourceTexture: texture_2d<f32>,
|
|
20
|
+
sourceTextureSampler: sampler,
|
|
21
|
+
texSize: vec2f,
|
|
22
|
+
texCoord: vec2f
|
|
23
|
+
) -> vec4f {
|
|
24
|
+
let pos = vec2f(magnify.screenXY.x, 1.0 - magnify.screenXY.y);
|
|
25
|
+
let dist = distance(texCoord * texSize, pos * texSize);
|
|
21
26
|
if (dist < magnify.radiusPixels) {
|
|
22
|
-
return
|
|
27
|
+
return textureSampleLevel(
|
|
28
|
+
sourceTexture,
|
|
29
|
+
sourceTextureSampler,
|
|
30
|
+
(texCoord - pos) / magnify.zoom + pos,
|
|
31
|
+
0.0
|
|
32
|
+
);
|
|
23
33
|
}
|
|
24
34
|
|
|
25
35
|
if (dist <= magnify.radiusPixels + magnify.borderWidthPixels) {
|
|
26
36
|
return magnify.borderColor;
|
|
27
37
|
}
|
|
28
|
-
return
|
|
38
|
+
return textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0.0);
|
|
29
39
|
}
|
|
30
40
|
`;
|
|
31
41
|
|
|
32
42
|
const fs = /* glsl */ `\
|
|
33
|
-
uniform magnifyUniforms {
|
|
43
|
+
layout(std140) uniform magnifyUniforms {
|
|
34
44
|
vec2 screenXY;
|
|
35
45
|
float radiusPixels;
|
|
36
46
|
float zoom;
|