@luma.gl/effects 9.3.0-alpha.2 → 9.3.0-alpha.6
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 +1265 -362
- package/dist/dist.min.js +10 -9
- package/dist/index.cjs +419 -258
- package/dist/index.cjs.map +2 -2
- 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 -4
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/denoise.d.ts +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/denoise.js +29 -21
- 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 +26 -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 +8 -7
- 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 +10 -9
- 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.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.js +9 -8
- 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 +9 -13
- 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 +34 -16
- 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 +21 -12
- 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 +20 -11
- 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 +18 -16
- 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 +83 -12
- 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 +33 -21
- 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 +24 -15
- 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 +16 -11
- package/dist/passes/postprocessing/image-fun-filters/magnify.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts +2 -2
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js +24 -10
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts +2 -2
- package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/swirl.js +18 -13
- 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 +2 -2
- package/src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +5 -4
- package/src/passes/postprocessing/image-adjust-filters/denoise.ts +31 -23
- package/src/passes/postprocessing/image-adjust-filters/huesaturation.ts +28 -34
- package/src/passes/postprocessing/image-adjust-filters/noise.ts +8 -7
- package/src/passes/postprocessing/image-adjust-filters/sepia.ts +10 -9
- package/src/passes/postprocessing/image-adjust-filters/vibrance.ts +9 -8
- package/src/passes/postprocessing/image-adjust-filters/vignette.ts +9 -13
- package/src/passes/postprocessing/image-blur-filters/tiltshift.ts +36 -18
- package/src/passes/postprocessing/image-blur-filters/triangleblur.ts +21 -12
- package/src/passes/postprocessing/image-blur-filters/zoomblur.ts +21 -12
- package/src/passes/postprocessing/image-fun-filters/colorhalftone.ts +18 -16
- package/src/passes/postprocessing/image-fun-filters/dotscreen.ts +11 -11
- package/src/passes/postprocessing/image-fun-filters/edgework.ts +84 -13
- package/src/passes/postprocessing/image-fun-filters/hexagonalpixelate.ts +36 -24
- package/src/passes/postprocessing/image-fun-filters/ink.ts +24 -15
- package/src/passes/postprocessing/image-fun-filters/magnify.ts +16 -11
- package/src/passes/postprocessing/image-warp-filters/bulgepinch.ts +24 -10
- package/src/passes/postprocessing/image-warp-filters/swirl.ts +18 -13
- package/src/passes/postprocessing/image-warp-filters/warp.ts +9 -4
|
@@ -3,33 +3,41 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
// Do a 9x9 bilateral box filter
|
|
5
5
|
const source = /* wgsl */ `\
|
|
6
|
-
|
|
7
6
|
struct denoiseUniforms {
|
|
8
|
-
strength: f32
|
|
7
|
+
strength: f32,
|
|
9
8
|
};
|
|
10
9
|
|
|
11
|
-
@group(0)
|
|
12
|
-
|
|
13
|
-
fn denoise_sampleColor(source: sampler2D, texSize: vec2<f32>, texCoord: vec2<f32>) -> vec4<f32> {
|
|
14
|
-
let adjustedExponent: f32 = 3. + 200. * pow(1. - denoise.strength, 4.);
|
|
15
|
-
let center: vec4<f32> = sample_texture(BUFFER_source, texCoord);
|
|
16
|
-
var color: vec4<f32> = vec4<f32>(0.);
|
|
17
|
-
var total: f32 = 0.;
|
|
18
|
-
|
|
19
|
-
for (var x: f32 = -4.; x <= 4.; x = x + (1.)) {
|
|
10
|
+
@group(0) @binding(1) var<uniform> denoise: denoiseUniforms;
|
|
20
11
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
fn denoise_sampleColor(
|
|
13
|
+
sourceTexture: texture_2d<f32>,
|
|
14
|
+
sourceTextureSampler: sampler,
|
|
15
|
+
texSize: vec2f,
|
|
16
|
+
texCoord: vec2f
|
|
17
|
+
) -> vec4f {
|
|
18
|
+
let adjustedExponent = 3.0 + 200.0 * pow(1.0 - denoise.strength, 4.0);
|
|
19
|
+
let center = textureSample(sourceTexture, sourceTextureSampler, texCoord);
|
|
20
|
+
var color = vec4f(0.0);
|
|
21
|
+
var total = 0.0;
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
for (var x = -4.0; x <= 4.0; x += 1.0) {
|
|
24
|
+
for (var y = -4.0; y <= 4.0; y += 1.0) {
|
|
25
|
+
let offsetColor = textureSample(
|
|
26
|
+
sourceTexture,
|
|
27
|
+
sourceTextureSampler,
|
|
28
|
+
texCoord + vec2f(x, y) / texSize
|
|
29
|
+
);
|
|
30
|
+
let weight = pow(
|
|
31
|
+
1.0 - abs(dot(offsetColor.rgb - center.rgb, vec3f(0.25))),
|
|
32
|
+
adjustedExponent
|
|
33
|
+
);
|
|
34
|
+
color += offsetColor * weight;
|
|
35
|
+
total += weight;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
}
|
|
39
|
+
return color / total;
|
|
40
|
+
}
|
|
33
41
|
`;
|
|
34
42
|
const fs = /* glsl */ `\
|
|
35
43
|
uniform dedenoiseUniforms {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"denoise.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/denoise.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,gCAAgC;AAChC,MAAM,MAAM,GAAG,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"denoise.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/denoise.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,gCAAgC;AAChC,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;CAuBrB,CAAC;AAkBF;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,KAAK,EAAE,EAAkB;IACzB,QAAQ,EAAE,EAAqB;IAE/B,IAAI,EAAE,SAAS;IACf,YAAY,EAAE;QACZ,QAAQ,EAAE,KAAK;KAChB;IACD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;QACrD,0HAA0H;KAC3H;IAED,MAAM;IACN,EAAE;IAEF,MAAM,EAAE,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,EAAE,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;CACkB,CAAC"}
|
|
@@ -21,7 +21,7 @@ export type HueSaturationUniforms = HueSaturationProps;
|
|
|
21
21
|
export declare const hueSaturation: {
|
|
22
22
|
readonly props: HueSaturationProps;
|
|
23
23
|
readonly name: "hueSaturation";
|
|
24
|
-
readonly source: "
|
|
24
|
+
readonly source: "struct hueSaturationUniforms {\n hue: f32,\n saturation: f32,\n};\n\n@group(0) @binding(1) var<uniform> hueSaturation: hueSaturationUniforms;\n\nfn hueSaturation_filterColor(color: vec4f) -> vec4f {\n let angle = hueSaturation.hue * 3.14159265;\n let s = sin(angle);\n let c = cos(angle);\n let weights = (vec3f(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + vec3f(1.0)) / 3.0;\n\n var result = color;\n result.rgb = vec3f(\n dot(result.rgb, weights.xyz),\n dot(result.rgb, weights.zxy),\n dot(result.rgb, weights.yzx)\n );\n\n let average = (result.r + result.g + result.b) / 3.0;\n if (hueSaturation.saturation > 0.0) {\n result.rgb += (vec3f(average) - result.rgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));\n } else {\n result.rgb += (vec3f(average) - result.rgb) * (-hueSaturation.saturation);\n }\n\n return result;\n}\n\nfn hueSaturation_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {\n return hueSaturation_filterColor(color);\n}\n";
|
|
25
25
|
readonly fs: "uniform hueSaturationUniforms {\n float hue;\n float saturation;\n} hueSaturation;\n\nvec4 hueSaturation_filterColor(vec4 color) {\n // hue adjustment, wolfram alpha: RotationTransform[angle, {1, 1, 1}][{x, y, z}]\n float angle = hueSaturation.hue * 3.14159265;\n float s = sin(angle), c = cos(angle);\n vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;\n float len = length(color.rgb);\n color.rgb = vec3(\n dot(color.rgb, weights.xyz),\n dot(color.rgb, weights.zxy),\n dot(color.rgb, weights.yzx)\n );\n\n // saturation adjustment\n float average = (color.r + color.g + color.b) / 3.0;\n if (hueSaturation.saturation > 0.0) {\n color.rgb += (average - color.rgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));\n } else {\n color.rgb += (average - color.rgb) * (-hueSaturation.saturation);\n }\n\n return color;\n}\n\nvec4 hueSaturation_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {\n return hueSaturation_filterColor(color);\n}\n";
|
|
26
26
|
readonly uniformTypes: {
|
|
27
27
|
readonly hue: "f32";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"huesaturation.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/huesaturation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"huesaturation.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/huesaturation.ts"],"names":[],"mappings":"AA4EA;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;iEAC6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAEvD;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa;oBACX,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;CAekB,CAAC"}
|
|
@@ -2,45 +2,39 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
const source = /* wgsl */ `\
|
|
5
|
-
|
|
6
5
|
struct hueSaturationUniforms {
|
|
7
6
|
hue: f32,
|
|
8
7
|
saturation: f32,
|
|
9
8
|
};
|
|
10
9
|
|
|
11
|
-
@group(0)
|
|
10
|
+
@group(0) @binding(1) var<uniform> hueSaturation: hueSaturationUniforms;
|
|
11
|
+
|
|
12
|
+
fn hueSaturation_filterColor(color: vec4f) -> vec4f {
|
|
13
|
+
let angle = hueSaturation.hue * 3.14159265;
|
|
14
|
+
let s = sin(angle);
|
|
15
|
+
let c = cos(angle);
|
|
16
|
+
let weights = (vec3f(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + vec3f(1.0)) / 3.0;
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var colorrgb = color.rgb;
|
|
20
|
-
colorrgb = vec3<f32>(dot(color.rgb, weights.xyz), dot(color.rgb, weights.zxy), dot(color.rgb, weights.yzx));
|
|
21
|
-
color.r = colorrgb.x;
|
|
22
|
-
color.g = colorrgb.y;
|
|
23
|
-
color.b = colorrgb.z;
|
|
24
|
-
let average: f32 = (color.r + color.g + color.b) / 3.;
|
|
25
|
-
if (hueSaturation.saturation > 0.) {
|
|
26
|
-
var colorrgb = color.rgb;
|
|
27
|
-
colorrgb = color.rgb + ((average - color.rgb) * (1. - 1. / (1.001 - hueSaturation.saturation)));
|
|
28
|
-
color.r = colorrgb.x;
|
|
29
|
-
color.g = colorrgb.y;
|
|
30
|
-
color.b = colorrgb.z;
|
|
31
|
-
} else {
|
|
32
|
-
var colorrgb = color.rgb;
|
|
33
|
-
colorrgb = color.rgb + ((average - color.rgb) * -hueSaturation.saturation);
|
|
34
|
-
color.r = colorrgb.x;
|
|
35
|
-
color.g = colorrgb.y;
|
|
36
|
-
color.b = colorrgb.z;
|
|
37
|
-
}
|
|
38
|
-
return color;
|
|
39
|
-
}
|
|
18
|
+
var result = color;
|
|
19
|
+
result.rgb = vec3f(
|
|
20
|
+
dot(result.rgb, weights.xyz),
|
|
21
|
+
dot(result.rgb, weights.zxy),
|
|
22
|
+
dot(result.rgb, weights.yzx)
|
|
23
|
+
);
|
|
40
24
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
let average = (result.r + result.g + result.b) / 3.0;
|
|
26
|
+
if (hueSaturation.saturation > 0.0) {
|
|
27
|
+
result.rgb += (vec3f(average) - result.rgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));
|
|
28
|
+
} else {
|
|
29
|
+
result.rgb += (vec3f(average) - result.rgb) * (-hueSaturation.saturation);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fn hueSaturation_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
36
|
+
return hueSaturation_filterColor(color);
|
|
37
|
+
}
|
|
44
38
|
`;
|
|
45
39
|
const fs = /* glsl */ `\
|
|
46
40
|
uniform hueSaturationUniforms {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"huesaturation.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/huesaturation.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"huesaturation.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/huesaturation.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCrB,CAAC;AAeF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK,EAAE,EAAwB;IAE/B,IAAI,EAAE,eAAe;IACrB,MAAM;IACN,EAAE;IAEF,YAAY,EAAE;QACZ,GAAG,EAAE,KAAK;QACV,UAAU,EAAE,KAAK;KAClB;IACD,SAAS,EAAE;QACT,GAAG,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;QAChC,UAAU,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;KACxC;IACD,MAAM,EAAE,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;CACyB,CAAC"}
|
|
@@ -13,7 +13,7 @@ export type NoiseUniforms = NoiseProps;
|
|
|
13
13
|
export declare const noise: {
|
|
14
14
|
readonly name: "noise";
|
|
15
15
|
readonly fs: "uniform noiseUniforms {\n float amount;\n} noise;\n\nfloat rand(vec2 co) {\n return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\nvec4 noise_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {\n float diff = (rand(texCoord) - 0.5) * noise.amount;\n color.r += diff;\n color.g += diff;\n color.b += diff;\n return color;\n}\n";
|
|
16
|
-
readonly source: "struct noiseUniforms {\n amount: f32
|
|
16
|
+
readonly source: "struct noiseUniforms {\n amount: f32,\n};\n\n@group(0) @binding(1) var<uniform> noise: noiseUniforms;\n\nfn rand(co: vec2f) -> f32 {\n\treturn fract(sin(dot(co.xy, vec2f(12.9898, 78.233))) * 43758.547);\n} \n\nfn noise_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {\n let diff = (rand(texCoord) - 0.5) * noise.amount;\n var result = color;\n result.r += diff;\n result.g += diff;\n result.b += diff;\n return result;\n}\n";
|
|
17
17
|
readonly props: NoiseProps;
|
|
18
18
|
readonly uniforms: NoiseUniforms;
|
|
19
19
|
readonly uniformTypes: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noise.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/noise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"noise.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/noise.ts"],"names":[],"mappings":"AA6CA;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,KAAK;;;;oBAKH,UAAU;uBACP,aAAa;;;;;;;;;;;;;;CASwB,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
const source = /* wgsl */ `\
|
|
5
5
|
struct noiseUniforms {
|
|
6
|
-
amount: f32
|
|
6
|
+
amount: f32,
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
@group(0) @binding(1) var<uniform> noise: noiseUniforms;
|
|
@@ -13,12 +13,13 @@ fn rand(co: vec2f) -> f32 {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
fn noise_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
let diff = (rand(texCoord) - 0.5) * noise.amount;
|
|
17
|
+
var result = color;
|
|
18
|
+
result.r += diff;
|
|
19
|
+
result.g += diff;
|
|
20
|
+
result.b += diff;
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
22
23
|
`;
|
|
23
24
|
const fs = /* glsl */ `\
|
|
24
25
|
uniform noiseUniforms {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noise.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/noise.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"noise.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/noise.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;CAmBzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;CAgBrB,CAAC;AAYF;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,EAAE;IACF,MAAM;IAEN,KAAK,EAAE,EAAgB;IACvB,QAAQ,EAAE,EAAmB;IAC7B,YAAY,EAAE;QACZ,MAAM,EAAE,KAAK;KACd;IACD,SAAS,EAAE;QACT,MAAM,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;KACrC;IAED,MAAM,EAAE,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;CAC6B,CAAC"}
|
|
@@ -22,7 +22,7 @@ export declare const sepia: {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
readonly fs: "uniform sepiaUniforms {\n float amount;\n} sepia;\n\nvec4 sepia_filterColor(vec4 color) {\n float r = color.r;\n float g = color.g;\n float b = color.b;\n\n color.r =\n min(1.0, (r * (1.0 - (0.607 * sepia.amount))) + (g * (0.769 * sepia.amount)) + (b * (0.189 * sepia.amount)));\n color.g = min(1.0, (r * 0.349 * sepia.amount) + (g * (1.0 - (0.314 * sepia.amount))) + (b * 0.168 * sepia.amount));\n color.b = min(1.0, (r * 0.272 * sepia.amount) + (g * 0.534 * sepia.amount) + (b * (1.0 - (0.869 * sepia.amount))));\n\n return color;\n}\n\nvec4 sepia_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {\n return sepia_filterColor(color);\n}\n";
|
|
25
|
-
readonly source: "struct sepiaUniforms {\n amount: f32
|
|
25
|
+
readonly source: "struct sepiaUniforms {\n amount: f32,\n};\n\n@group(0) @binding(1) var<uniform> sepia: sepiaUniforms;\n\nfn sepia_filterColor(color: vec4f) -> vec4f {\n let r = color.r;\n let g = color.g;\n let b = color.b;\n\n var result = color;\n result.r =\n min(1.0, (r * (1.0 - (0.607 * sepia.amount))) + (g * (0.769 * sepia.amount)) + (b * (0.189 * sepia.amount)));\n result.g = min(1.0, (r * 0.349 * sepia.amount) + (g * (1.0 - (0.314 * sepia.amount))) + (b * 0.168 * sepia.amount));\n result.b = min(1.0, (r * 0.272 * sepia.amount) + (g * 0.534 * sepia.amount) + (b * (1.0 - (0.869 * sepia.amount))));\n\n return result;\n}\n\nfn sepia_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {\n return sepia_filterColor(color);\n}\n";
|
|
26
26
|
readonly passes: [{
|
|
27
27
|
readonly filter: true;
|
|
28
28
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sepia.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/sepia.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sepia.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/sepia.ts"],"names":[],"mappings":"AAuDA,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,KAAK;oBACH,UAAU;uBACP,aAAa;;;;;;;;;;;;;;;;;CAYwB,CAAC"}
|
|
@@ -3,25 +3,26 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
const source = /* wgsl */ `\
|
|
5
5
|
struct sepiaUniforms {
|
|
6
|
-
amount: f32
|
|
6
|
+
amount: f32,
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
@group(0) @binding(1) var<uniform> sepia: sepiaUniforms;
|
|
10
10
|
|
|
11
11
|
fn sepia_filterColor(color: vec4f) -> vec4f {
|
|
12
|
-
let r
|
|
13
|
-
let g
|
|
14
|
-
let b
|
|
12
|
+
let r = color.r;
|
|
13
|
+
let g = color.g;
|
|
14
|
+
let b = color.b;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
var result = color;
|
|
17
|
+
result.r =
|
|
17
18
|
min(1.0, (r * (1.0 - (0.607 * sepia.amount))) + (g * (0.769 * sepia.amount)) + (b * (0.189 * sepia.amount)));
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
result.g = min(1.0, (r * 0.349 * sepia.amount) + (g * (1.0 - (0.314 * sepia.amount))) + (b * 0.168 * sepia.amount));
|
|
20
|
+
result.b = min(1.0, (r * 0.272 * sepia.amount) + (g * 0.534 * sepia.amount) + (b * (1.0 - (0.869 * sepia.amount))));
|
|
20
21
|
|
|
21
|
-
return
|
|
22
|
+
return result;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
fn sepia_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
25
26
|
return sepia_filterColor(color);
|
|
26
27
|
}
|
|
27
28
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sepia.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/sepia.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"sepia.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/sepia.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;CAwBzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;CAqBrB,CAAC;AAQF;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,EAAgB;IACvB,QAAQ,EAAE,EAAmB;IAE7B,IAAI,EAAE,OAAO;IACb,YAAY,EAAE;QACZ,MAAM,EAAE,KAAK;KACd;IACD,SAAS,EAAE;QACT,MAAM,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;KACrC;IACD,EAAE;IACF,MAAM;IACN,MAAM,EAAE,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;CAC6B,CAAC"}
|
|
@@ -21,7 +21,7 @@ export declare const vibrance: {
|
|
|
21
21
|
readonly max: 1;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
readonly source: "struct vibranceUniforms {\n amount: f32
|
|
24
|
+
readonly source: "struct vibranceUniforms {\n amount: f32,\n};\n\n@group(0) @binding(1) var<uniform> vibrance: vibranceUniforms;\n\nfn vibrance_filterColor(color: vec4f) -> vec4f {\n let average = (color.r + color.g + color.b) / 3.0;\n let mx = max(color.r, max(color.g, color.b));\n let amt = (mx - average) * (-vibrance.amount * 3.0);\n var result = color;\n result.rgb = mix(result.rgb, vec3f(mx), amt);\n return result;\n}\n\nfn vibrance_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {\n return vibrance_filterColor(color);\n}\n";
|
|
25
25
|
readonly fs: "uniform vibranceUniforms {\n float amount;\n} vibrance;\n\nvec4 vibrance_filterColor(vec4 color) {\n float average = (color.r + color.g + color.b) / 3.0;\n float mx = max(color.r, max(color.g, color.b));\n float amt = (mx - average) * (-vibrance.amount * 3.0);\n color.rgb = mix(color.rgb, vec3(mx), amt);\n return color;\n}\n\nvec4 vibrance_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {\n return vibrance_filterColor(color);\n}\n";
|
|
26
26
|
readonly passes: [{
|
|
27
27
|
readonly filter: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vibrance.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/vibrance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vibrance.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/vibrance.ts"],"names":[],"mappings":"AA6CA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAE7C,qGAAqG;AACrG,eAAO,MAAM,QAAQ;oBACN,aAAa;uBACV,gBAAgB;;;;;;;;;;;;;;;;;CAW2B,CAAC"}
|
|
@@ -3,20 +3,21 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
const source = /* wgsl */ `\
|
|
5
5
|
struct vibranceUniforms {
|
|
6
|
-
amount: f32
|
|
6
|
+
amount: f32,
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
@group(0) @binding(1) var<uniform> vibrance: vibranceUniforms;
|
|
10
10
|
|
|
11
|
-
fn vibrance_filterColor(vec4f
|
|
12
|
-
let average
|
|
13
|
-
let mx
|
|
14
|
-
let amt
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
fn vibrance_filterColor(color: vec4f) -> vec4f {
|
|
12
|
+
let average = (color.r + color.g + color.b) / 3.0;
|
|
13
|
+
let mx = max(color.r, max(color.g, color.b));
|
|
14
|
+
let amt = (mx - average) * (-vibrance.amount * 3.0);
|
|
15
|
+
var result = color;
|
|
16
|
+
result.rgb = mix(result.rgb, vec3f(mx), amt);
|
|
17
|
+
return result;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
fn vibrance_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
20
21
|
return vibrance_filterColor(color);
|
|
21
22
|
}
|
|
22
23
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vibrance.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/vibrance.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"vibrance.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/vibrance.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;CAmBzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;CAgBrB,CAAC;AAYF,qGAAqG;AACrG,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,KAAK,EAAE,EAAmB;IAC1B,QAAQ,EAAE,EAAsB;IAChC,IAAI,EAAE,UAAU;IAChB,YAAY,EAAE;QACZ,MAAM,EAAE,KAAK;KACd;IACD,SAAS,EAAE;QACT,MAAM,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;KACpC;IACD,MAAM;IACN,EAAE;IACF,MAAM,EAAE,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;CACmC,CAAC"}
|
|
@@ -16,7 +16,7 @@ export declare const vignette: {
|
|
|
16
16
|
readonly props: VignetteProps;
|
|
17
17
|
readonly uniforms: VignetteUniforms;
|
|
18
18
|
readonly name: "vignette";
|
|
19
|
-
readonly source: "struct vignetteUniforms {\n radius: f32,\n amount: f32
|
|
19
|
+
readonly source: "struct vignetteUniforms {\n radius: f32,\n amount: f32,\n};\n\n@group(0) @binding(1) var<uniform> vignette: vignetteUniforms;\n\nfn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {\n let dist = distance(texCoord, vec2f(0.5, 0.5));\n let ratio = smoothstep(\n 0.8,\n vignette.radius * 0.799,\n dist * (vignette.amount + vignette.radius)\n );\n return color * ratio + vec4f(0.0, 0.0, 0.0, 1.0) * (1.0 - ratio);\n}\n";
|
|
20
20
|
readonly fs: "uniform vignetteUniforms {\n float radius;\n float amount;\n} vignette;\n\nvec4 vignette_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {\n float dist = distance(texCoord, vec2(0.5, 0.5));\n float ratio = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));\n return color.rgba * ratio + (1.0 - ratio)*vec4(0.0, 0.0, 0.0, 1.0);\n}\n";
|
|
21
21
|
readonly uniformTypes: {
|
|
22
22
|
readonly radius: "f32";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vignette.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/vignette.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vignette.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/vignette.ts"],"names":[],"mappings":"AAsCA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,QAAQ;oBACN,aAAa;uBACV,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoB2B,CAAC"}
|
|
@@ -4,23 +4,19 @@
|
|
|
4
4
|
const source = /* wgsl */ `\
|
|
5
5
|
struct vignetteUniforms {
|
|
6
6
|
radius: f32,
|
|
7
|
-
amount: f32
|
|
7
|
+
amount: f32,
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
@group(0) @binding(1) var<uniform> vignette: vignetteUniforms;
|
|
11
11
|
|
|
12
|
-
fn
|
|
13
|
-
let
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
fn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) ->vec4f {
|
|
21
|
-
let dist: f32 = distance(texCoord, vec2f(0.5, 0.5));
|
|
22
|
-
let ratio: f32 = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));
|
|
23
|
-
return color.rgba * ratio + (1.0 - ratio)*vec4f(0.0, 0.0, 0.0, 1.0);
|
|
12
|
+
fn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
13
|
+
let dist = distance(texCoord, vec2f(0.5, 0.5));
|
|
14
|
+
let ratio = smoothstep(
|
|
15
|
+
0.8,
|
|
16
|
+
vignette.radius * 0.799,
|
|
17
|
+
dist * (vignette.amount + vignette.radius)
|
|
18
|
+
);
|
|
19
|
+
return color * ratio + vec4f(0.0, 0.0, 0.0, 1.0) * (1.0 - ratio);
|
|
24
20
|
}
|
|
25
21
|
`;
|
|
26
22
|
const fs = /* glsl */ `\
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vignette.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/vignette.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"vignette.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/vignette.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;CAiBzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;CAWrB,CAAC;AAcF;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,KAAK,EAAE,EAAmB;IAC1B,QAAQ,EAAE,EAAsB;IAEhC,IAAI,EAAE,UAAU;IAChB,MAAM;IACN,EAAE;IAEF,YAAY,EAAE;QACZ,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,KAAK;KACd;IACD,eAAe,EAAE;QACf,MAAM,EAAE,GAAG;QACX,MAAM,EAAE,GAAG;KACZ;IACD,SAAS,EAAE;QACT,MAAM,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;QACpC,MAAM,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;KACrC;IAED,MAAM,EAAE,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;CACmC,CAAC"}
|
|
@@ -30,10 +30,10 @@ export declare const tiltShift: {
|
|
|
30
30
|
readonly name: "tiltShift";
|
|
31
31
|
readonly dependencies: [{
|
|
32
32
|
readonly name: "random";
|
|
33
|
-
readonly source: "fn random(scale: vec3f, seed:
|
|
33
|
+
readonly source: "fn random(scale: vec3f, seed: f32) -> f32 {\n return fract(sin(dot(scale + vec3f(seed), vec3f(12.9898, 78.233, 151.7182))) * 43758.5453 + seed);\n}\n";
|
|
34
34
|
readonly fs: "float random(vec3 scale, float seed) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n";
|
|
35
35
|
}];
|
|
36
|
-
readonly source: "
|
|
36
|
+
readonly source: "struct tiltShiftUniforms {\n blurRadius: f32,\n gradientRadius: f32,\n start: vec2f,\n end: vec2f,\n invert: u32,\n};\n\n@group(0) @binding(1) var<uniform> tiltShift: tiltShiftUniforms;\n\nfn tiltShift_getDelta(texSize: vec2f) -> vec2f {\n let vector = normalize((tiltShift.end - tiltShift.start) * texSize);\n return select(vector, vec2f(-vector.y, vector.x), tiltShift.invert != 0u);\n}\n\nfn tiltShift_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n var color = vec4f(0.0);\n var total = 0.0;\n\n /* randomize the lookup values to hide the fixed number of samples */\n let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);\n\n let normal = normalize(\n vec2f(\n (tiltShift.start.y - tiltShift.end.y) * texSize.y,\n (tiltShift.end.x - tiltShift.start.x) * texSize.x\n )\n );\n let radius =\n smoothstep(\n 0.0,\n 1.0,\n abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius\n ) * tiltShift.blurRadius;\n\n for (var t = -30.0; t <= 30.0; t += 1.0) {\n let percent = (t + offset - 0.5) / 30.0;\n let weight = 1.0 - abs(percent);\n let offsetColor = textureSample(\n sourceTexture,\n sourceTextureSampler,\n texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius\n );\n\n color += offsetColor * weight;\n total += weight;\n }\n\n color /= total;\n return color;\n}\n";
|
|
37
37
|
readonly fs: "uniform tiltShiftUniforms {\n float blurRadius;\n float gradientRadius;\n vec2 start;\n vec2 end;\n bool invert;\n} tiltShift;\n\nvec2 tiltShift_getDelta(vec2 texSize) {\n vec2 vector = normalize((tiltShift.end - tiltShift.start) * texSize);\n return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;\n}\n\nvec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n vec2 normal = normalize(vec2((tiltShift.start.y - tiltShift.end.y) * texSize.y, (tiltShift.end.x - tiltShift.start.x) * texSize.x));\n float radius = smoothstep(0.0, 1.0,\n abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;\n\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);\n color += offsetColor * weight;\n total += weight;\n }\n\n color = color / total;\n return color;\n}\n";
|
|
38
38
|
readonly props: TiltShiftProps;
|
|
39
39
|
readonly uniforms: TiltShiftUniforms;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiltshift.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/tiltshift.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tiltshift.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/tiltshift.ts"],"names":[],"mappings":"AAwGA;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS;;;;;;;;;oBAMP,cAAc;uBACX,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoB4B,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { random } from '@luma.gl/shadertools';
|
|
5
5
|
const source = /* wgsl */ `\
|
|
6
|
-
|
|
6
|
+
struct tiltShiftUniforms {
|
|
7
7
|
blurRadius: f32,
|
|
8
8
|
gradientRadius: f32,
|
|
9
9
|
start: vec2f,
|
|
@@ -13,32 +13,50 @@ uniform tiltShiftUniforms {
|
|
|
13
13
|
|
|
14
14
|
@group(0) @binding(1) var<uniform> tiltShift: tiltShiftUniforms;
|
|
15
15
|
|
|
16
|
-
fn tiltShift_getDelta(
|
|
17
|
-
|
|
18
|
-
return
|
|
16
|
+
fn tiltShift_getDelta(texSize: vec2f) -> vec2f {
|
|
17
|
+
let vector = normalize((tiltShift.end - tiltShift.start) * texSize);
|
|
18
|
+
return select(vector, vec2f(-vector.y, vector.x), tiltShift.invert != 0u);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
fn tiltShift_sampleColor(
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
fn tiltShift_sampleColor(
|
|
22
|
+
sourceTexture: texture_2d<f32>,
|
|
23
|
+
sourceTextureSampler: sampler,
|
|
24
|
+
texSize: vec2f,
|
|
25
|
+
texCoord: vec2f
|
|
26
|
+
) -> vec4f {
|
|
27
|
+
var color = vec4f(0.0);
|
|
28
|
+
var total = 0.0;
|
|
24
29
|
|
|
25
30
|
/* randomize the lookup values to hide the fixed number of samples */
|
|
26
|
-
|
|
31
|
+
let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
let normal = normalize(
|
|
34
|
+
vec2f(
|
|
35
|
+
(tiltShift.start.y - tiltShift.end.y) * texSize.y,
|
|
36
|
+
(tiltShift.end.x - tiltShift.start.x) * texSize.x
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
let radius =
|
|
40
|
+
smoothstep(
|
|
41
|
+
0.0,
|
|
42
|
+
1.0,
|
|
43
|
+
abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius
|
|
44
|
+
) * tiltShift.blurRadius;
|
|
31
45
|
|
|
32
|
-
for (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
for (var t = -30.0; t <= 30.0; t += 1.0) {
|
|
47
|
+
let percent = (t + offset - 0.5) / 30.0;
|
|
48
|
+
let weight = 1.0 - abs(percent);
|
|
49
|
+
let offsetColor = textureSample(
|
|
50
|
+
sourceTexture,
|
|
51
|
+
sourceTextureSampler,
|
|
52
|
+
texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius
|
|
53
|
+
);
|
|
36
54
|
|
|
37
55
|
color += offsetColor * weight;
|
|
38
56
|
total += weight;
|
|
39
57
|
}
|
|
40
58
|
|
|
41
|
-
color
|
|
59
|
+
color /= total;
|
|
42
60
|
return color;
|
|
43
61
|
}
|
|
44
62
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiltshift.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/tiltshift.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAE5C,MAAM,MAAM,GAAG,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"tiltshift.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/tiltshift.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAE5C,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCrB,CAAC;AAqBF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,YAAY,EAAE,CAAC,MAAM,CAAC;IACtB,MAAM;IACN,EAAE;IAEF,KAAK,EAAE,EAAoB;IAC3B,QAAQ,EAAE,EAAuB;IACjC,YAAY,EAAE;QACZ,UAAU,EAAE,KAAK;QACjB,cAAc,EAAE,KAAK;QACrB,KAAK,EAAE,WAAW;QAClB,GAAG,EAAE,WAAW;QAChB,MAAM,EAAE,KAAK;KACd;IACD,SAAS,EAAE;QACT,UAAU,EAAE,EAAC,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAC;QACxC,cAAc,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAC;QAC9C,KAAK,EAAE,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC;QACtB,GAAG,EAAE,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC;QACpB,MAAM,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAC;KAClC;IAED,MAAM,EAAE;QACN,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAC,MAAM,EAAE,CAAC,EAAC,EAAC;QACtC,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAC,MAAM,EAAE,CAAC,EAAC,EAAC;KACvC;CAC4D,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;EAwBE"}
|
|
@@ -21,10 +21,10 @@ export declare const triangleBlur: {
|
|
|
21
21
|
readonly name: "triangleBlur";
|
|
22
22
|
readonly dependencies: [{
|
|
23
23
|
readonly name: "random";
|
|
24
|
-
readonly source: "fn random(scale: vec3f, seed:
|
|
24
|
+
readonly source: "fn random(scale: vec3f, seed: f32) -> f32 {\n return fract(sin(dot(scale + vec3f(seed), vec3f(12.9898, 78.233, 151.7182))) * 43758.5453 + seed);\n}\n";
|
|
25
25
|
readonly fs: "float random(vec3 scale, float seed) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n";
|
|
26
26
|
}];
|
|
27
|
-
readonly source: "
|
|
27
|
+
readonly source: "struct triangleBlurUniforms {\n radius: f32,\n delta: vec2f,\n};\n\n@group(0) @binding(1) var<uniform> triangleBlur: triangleBlurUniforms;\n\nfn triangleBlur_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;\n\n var color = vec4f(0.0);\n var total = 0.0;\n\n /* randomize the lookup values to hide the fixed number of samples */\n let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);\n\n for (var t = -30.0; t <= 30.0; t += 1.0) {\n let percent = (t + offset - 0.5) / 30.0;\n let weight = 1.0 - abs(percent);\n var offsetColor = textureSample(\n sourceTexture,\n sourceTextureSampler,\n texCoord + adjustedDelta * percent\n );\n\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n offsetColor.rgb *= offsetColor.a;\n\n color += offsetColor * weight;\n total += weight;\n }\n\n color /= total;\n\n /* switch back from pre-multiplied alpha */\n color.rgb /= color.a + 0.00001;\n\n return color;\n}\n";
|
|
28
28
|
readonly fs: "uniform triangleBlurUniforms {\n float radius;\n vec2 delta;\n} triangleBlur;\n\nvec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;\n\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 offsetColor = texture(source, texCoord + adjustedDelta * percent);\n\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n offsetColor.rgb *= offsetColor.a;\n\n color += offsetColor * weight;\n total += weight;\n }\n\n color = color / total;\n\n /* switch back from pre-multiplied alpha */\n color.rgb /= color.a + 0.00001;\n\n return color;\n}\n";
|
|
29
29
|
readonly props: TriangleBlurProps;
|
|
30
30
|
readonly uniforms: TriangleBlurUniforms;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triangleblur.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/triangleblur.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"triangleblur.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/triangleblur.ts"],"names":[],"mappings":"AA0FA;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,YAAY;;;;;;;;;oBAMV,iBAAiB;uBACd,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;CAc+B,CAAC"}
|
|
@@ -3,26 +3,35 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { random } from '@luma.gl/shadertools';
|
|
5
5
|
const source = /* wgsl */ `\
|
|
6
|
-
|
|
6
|
+
struct triangleBlurUniforms {
|
|
7
7
|
radius: f32,
|
|
8
8
|
delta: vec2f,
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
10
|
|
|
11
11
|
@group(0) @binding(1) var<uniform> triangleBlur: triangleBlurUniforms;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
fn triangleBlur_sampleColor(
|
|
14
|
+
sourceTexture: texture_2d<f32>,
|
|
15
|
+
sourceTextureSampler: sampler,
|
|
16
|
+
texSize: vec2f,
|
|
17
|
+
texCoord: vec2f
|
|
18
|
+
) -> vec4f {
|
|
19
|
+
let adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
var color = vec4f(0.0);
|
|
22
|
+
var total = 0.0;
|
|
18
23
|
|
|
19
24
|
/* randomize the lookup values to hide the fixed number of samples */
|
|
20
|
-
|
|
25
|
+
let offset = random(vec3f(12.9898, 78.233, 151.7182), 0.0);
|
|
21
26
|
|
|
22
|
-
for (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
for (var t = -30.0; t <= 30.0; t += 1.0) {
|
|
28
|
+
let percent = (t + offset - 0.5) / 30.0;
|
|
29
|
+
let weight = 1.0 - abs(percent);
|
|
30
|
+
var offsetColor = textureSample(
|
|
31
|
+
sourceTexture,
|
|
32
|
+
sourceTextureSampler,
|
|
33
|
+
texCoord + adjustedDelta * percent
|
|
34
|
+
);
|
|
26
35
|
|
|
27
36
|
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
|
28
37
|
offsetColor.rgb *= offsetColor.a;
|
|
@@ -31,7 +40,7 @@ vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
31
40
|
total += weight;
|
|
32
41
|
}
|
|
33
42
|
|
|
34
|
-
color
|
|
43
|
+
color /= total;
|
|
35
44
|
|
|
36
45
|
/* switch back from pre-multiplied alpha */
|
|
37
46
|
color.rgb /= color.a + 0.00001;
|