@luma.gl/effects 9.1.9 → 9.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +1162 -851
- package/dist/dist.min.js +7 -6
- package/dist/index.cjs +560 -65
- package/dist/index.cjs.map +3 -3
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +3 -3
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +9 -9
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/denoise.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/denoise.js +9 -5
- package/dist/passes/postprocessing/image-adjust-filters/denoise.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js +5 -4
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts +3 -3
- package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/noise.js +7 -7
- package/dist/passes/postprocessing/image-adjust-filters/noise.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts +1 -0
- package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/sepia.js +25 -0
- package/dist/passes/postprocessing/image-adjust-filters/sepia.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts +1 -0
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.js +20 -0
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vignette.js +19 -9
- package/dist/passes/postprocessing/image-adjust-filters/vignette.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts +5 -3
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.js +52 -4
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts +8 -6
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.js +41 -3
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts +8 -6
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.js +42 -4
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts +3 -2
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js +41 -2
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts +3 -2
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.js +29 -2
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts +4 -2
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/edgework.js +36 -2
- package/dist/passes/postprocessing/image-fun-filters/edgework.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +3 -2
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js +49 -2
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.d.ts +3 -2
- package/dist/passes/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.js +34 -2
- package/dist/passes/postprocessing/image-fun-filters/ink.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts +2 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.js +26 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts +5 -3
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js +33 -2
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts +5 -3
- package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/swirl.js +35 -2
- package/dist/passes/postprocessing/image-warp-filters/swirl.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.d.ts +2 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.js +14 -3
- package/dist/passes/postprocessing/image-warp-filters/warp.js.map +1 -1
- package/package.json +3 -3
- package/src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +10 -10
- package/src/passes/postprocessing/image-adjust-filters/denoise.ts +9 -5
- package/src/passes/postprocessing/image-adjust-filters/huesaturation.ts +5 -4
- package/src/passes/postprocessing/image-adjust-filters/noise.ts +9 -8
- package/src/passes/postprocessing/image-adjust-filters/sepia.ts +26 -0
- package/src/passes/postprocessing/image-adjust-filters/vibrance.ts +21 -0
- package/src/passes/postprocessing/image-adjust-filters/vignette.ts +20 -10
- package/src/passes/postprocessing/image-blur-filters/tiltshift.ts +55 -5
- package/src/passes/postprocessing/image-blur-filters/triangleblur.ts +44 -4
- package/src/passes/postprocessing/image-blur-filters/zoomblur.ts +45 -5
- package/src/passes/postprocessing/image-fun-filters/colorhalftone.ts +44 -3
- package/src/passes/postprocessing/image-fun-filters/dotscreen.ts +32 -3
- package/src/passes/postprocessing/image-fun-filters/edgework.ts +38 -3
- package/src/passes/postprocessing/image-fun-filters/hexagonalpixelate.ts +52 -3
- package/src/passes/postprocessing/image-fun-filters/ink.ts +36 -3
- package/src/passes/postprocessing/image-fun-filters/magnify.ts +29 -1
- package/src/passes/postprocessing/image-warp-filters/bulgepinch.ts +36 -3
- package/src/passes/postprocessing/image-warp-filters/swirl.ts +36 -3
- package/src/passes/postprocessing/image-warp-filters/warp.ts +16 -3
|
@@ -4,10 +4,14 @@
|
|
|
4
4
|
// Do a 9x9 bilateral box filter
|
|
5
5
|
const source = /* wgsl */ `\
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
struct denoiseUniforms {
|
|
8
|
+
strength: f32
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
@group(0), @binding(1) var<uniform> denoise: denoiseUniforms;
|
|
8
12
|
|
|
9
13
|
fn denoise_sampleColor(source: sampler2D, texSize: vec2<f32>, texCoord: vec2<f32>) -> vec4<f32> {
|
|
10
|
-
let adjustedExponent: f32 = 3. + 200. * pow(1. -
|
|
14
|
+
let adjustedExponent: f32 = 3. + 200. * pow(1. - denoise.strength, 4.);
|
|
11
15
|
let center: vec4<f32> = sample_texture(BUFFER_source, texCoord);
|
|
12
16
|
var color: vec4<f32> = vec4<f32>(0.);
|
|
13
17
|
var total: f32 = 0.;
|
|
@@ -28,11 +32,11 @@ fn denoise_sampleColor(source: sampler2D, texSize: vec2<f32>, texCoord: vec2<f32
|
|
|
28
32
|
}
|
|
29
33
|
`;
|
|
30
34
|
const fs = /* glsl */ `\
|
|
31
|
-
uniform
|
|
35
|
+
uniform dedenoiseUniforms {
|
|
32
36
|
float strength;
|
|
33
|
-
}
|
|
37
|
+
} denoise;
|
|
34
38
|
|
|
35
|
-
vec4
|
|
39
|
+
vec4 dedenoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
36
40
|
float adjustedExponent = 3. + 200. * pow(1. - noise.strength, 4.);
|
|
37
41
|
|
|
38
42
|
vec4 center = texture(source, texCoord);
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BzB,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: "\nstruct hueSaturationUniforms {\n hue: f32,\n saturation: f32,\n};\n\n@group(0), @binding(1) var<uniform> hueSaturation: hueSaturationUniforms;\n\nfn hueSaturation_filterColor(color: vec4<f32>) -> vec4<f32> {\n\tlet angle: f32 = hueSaturation.hue * 3.1415927;\n\tlet s: f32 = sin(angle);\n\tlet c: f32 = cos(angle);\n\tlet weights: vec3<f32> = (vec3<f32>(2. * c, -sqrt(3.) * s - c, sqrt(3.) * s - c) + 1.) / 3.;\n\tlet len: f32 = length(color.rgb);\n\tvar colorrgb = color.rgb;\n\tcolorrgb = vec3<f32>(dot(color.rgb, weights.xyz), dot(color.rgb, weights.zxy), dot(color.rgb, weights.yzx));\n\tcolor.r = colorrgb.x;\n\tcolor.g = colorrgb.y;\n\tcolor.b = colorrgb.z;\n\tlet average: f32 = (color.r + color.g + color.b) / 3.;\n\tif (hueSaturation.saturation > 0.) {\n\t\tvar colorrgb = color.rgb;\n\tcolorrgb = color.rgb + ((average - color.rgb) * (1. - 1. / (1.001 - hueSaturation.saturation)));\n\tcolor.r = colorrgb.x;\n\tcolor.g = colorrgb.y;\n\tcolor.b = colorrgb.z;\n\t} else { \n\t\tvar colorrgb = color.rgb;\n\tcolorrgb = color.rgb + ((average - color.rgb) * -hueSaturation.saturation);\n\tcolor.r = colorrgb.x;\n\tcolor.g = colorrgb.y;\n\tcolor.b = colorrgb.z;\n\t}\n\treturn color;\n} \n\nfn hueSaturation_filterColor_ext(color: vec4<f32>, texSize: vec2<f32>, texCoord: vec2<f32>) -> vec4<f32> {\n\treturn 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":"AAkFA;;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,12 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
const source = /* wgsl */ `\
|
|
5
|
-
@group(?), @binding(?)
|
|
6
|
-
var<uniform> hueSaturationUniforms { hue: f32,
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
struct hueSaturationUniforms {
|
|
7
|
+
hue: f32,
|
|
8
|
+
saturation: f32,
|
|
9
|
+
};
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
@group(0), @binding(1) var<uniform> hueSaturation: hueSaturationUniforms;
|
|
11
12
|
|
|
12
13
|
fn hueSaturation_filterColor(color: vec4<f32>) -> vec4<f32> {
|
|
13
14
|
let angle: f32 = hueSaturation.hue * 3.1415927;
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCzB,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"}
|
|
@@ -11,9 +11,11 @@ export type NoiseUniforms = NoiseProps;
|
|
|
11
11
|
* Adds black and white noise to the image.
|
|
12
12
|
*/
|
|
13
13
|
export declare const noise: {
|
|
14
|
+
readonly name: "noise";
|
|
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\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\tlet diff: f32 = (rand(texCoord) - 0.5) * noise.amount;\n\tcolor.r = color.r + (diff);\n\tcolor.g = color.g + (diff);\n\tcolor.b = color.b + (diff);\n\treturn color;\n} \n";
|
|
14
17
|
readonly props: NoiseProps;
|
|
15
18
|
readonly uniforms: NoiseUniforms;
|
|
16
|
-
readonly name: "noise";
|
|
17
19
|
readonly uniformTypes: {
|
|
18
20
|
readonly amount: "f32";
|
|
19
21
|
};
|
|
@@ -24,8 +26,6 @@ export declare const noise: {
|
|
|
24
26
|
readonly max: 1;
|
|
25
27
|
};
|
|
26
28
|
};
|
|
27
|
-
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";
|
|
28
|
-
readonly source: "struct noiseUniforms {\n amount: f32\n};\n\n@group(0), @binding(0) var<uniform> noise: NoiseUniforms;\n\nfn rand(co: vec2<f32>) -> f32 {\n\treturn fract(sin(dot(co.xy, vec2<f32>(12.9898, 78.233))) * 43758.547);\n} \n\nfn noise_filterColor_ext(color: vec4<f32>, texSize: vec2<f32>, texCoord: vec2<f32>) -> vec4<f32> {\n\tlet diff: f32 = (rand(texCoord) - 0.5) * noise.amount;\n\tcolor.r = color.r + (diff);\n\tcolor.g = color.g + (diff);\n\tcolor.b = color.b + (diff);\n\treturn color;\n} \n";
|
|
29
29
|
readonly passes: [{
|
|
30
30
|
readonly filter: true;
|
|
31
31
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noise.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/noise.ts"],"names":[],"mappings":"AA4CA;;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
|
|
1
|
+
{"version":3,"file":"noise.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/noise.ts"],"names":[],"mappings":"AA4CA;;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"}
|
|
@@ -6,13 +6,13 @@ struct noiseUniforms {
|
|
|
6
6
|
amount: f32
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
@group(0)
|
|
9
|
+
@group(0) @binding(1) var<uniform> noise: noiseUniforms;
|
|
10
10
|
|
|
11
|
-
fn rand(co:
|
|
12
|
-
return fract(sin(dot(co.xy,
|
|
11
|
+
fn rand(co: vec2f) -> f32 {
|
|
12
|
+
return fract(sin(dot(co.xy, vec2f(12.9898, 78.233))) * 43758.547);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
fn noise_filterColor_ext(color:
|
|
15
|
+
fn noise_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
16
16
|
let diff: f32 = (rand(texCoord) - 0.5) * noise.amount;
|
|
17
17
|
color.r = color.r + (diff);
|
|
18
18
|
color.g = color.g + (diff);
|
|
@@ -42,17 +42,17 @@ vec4 noise_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
|
42
42
|
* Adds black and white noise to the image.
|
|
43
43
|
*/
|
|
44
44
|
export const noise = {
|
|
45
|
+
name: 'noise',
|
|
46
|
+
fs,
|
|
47
|
+
source,
|
|
45
48
|
props: {},
|
|
46
49
|
uniforms: {},
|
|
47
|
-
name: 'noise',
|
|
48
50
|
uniformTypes: {
|
|
49
51
|
amount: 'f32'
|
|
50
52
|
},
|
|
51
53
|
propTypes: {
|
|
52
54
|
amount: { value: 0.5, min: 0, max: 1 }
|
|
53
55
|
},
|
|
54
|
-
fs,
|
|
55
|
-
source,
|
|
56
56
|
passes: [{ filter: true }]
|
|
57
57
|
};
|
|
58
58
|
//# sourceMappingURL=noise.js.map
|
|
@@ -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;;;;;;;;;;;;;;;;;;CAkBzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;CAgBrB,CAAC;AAYF;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,EAAgB;IACvB,QAAQ,EAAE,EAAmB;
|
|
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;;;;;;;;;;;;;;;;;;CAkBzB,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,6 +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\n};\n\n@group(0) @binding(1) var<uniform> sepia: sepiaUniforms;\n\nfn sepia_filterColor(color: vec4f) -> vec4f {\n let r: f32 = color.r;\n let g: f32 = color.g;\n let b: f32 = 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
26
|
readonly passes: [{
|
|
26
27
|
readonly filter: true;
|
|
27
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":"AAsDA,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"}
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
+
const source = /* wgsl */ `\
|
|
5
|
+
struct sepiaUniforms {
|
|
6
|
+
amount: f32
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
@group(0) @binding(1) var<uniform> sepia: sepiaUniforms;
|
|
10
|
+
|
|
11
|
+
fn sepia_filterColor(color: vec4f) -> vec4f {
|
|
12
|
+
let r: f32 = color.r;
|
|
13
|
+
let g: f32 = color.g;
|
|
14
|
+
let b: f32 = color.b;
|
|
15
|
+
|
|
16
|
+
color.r =
|
|
17
|
+
min(1.0, (r * (1.0 - (0.607 * sepia.amount))) + (g * (0.769 * sepia.amount)) + (b * (0.189 * sepia.amount)));
|
|
18
|
+
color.g = min(1.0, (r * 0.349 * sepia.amount) + (g * (1.0 - (0.314 * sepia.amount))) + (b * 0.168 * sepia.amount));
|
|
19
|
+
color.b = min(1.0, (r * 0.272 * sepia.amount) + (g * 0.534 * sepia.amount) + (b * (1.0 - (0.869 * sepia.amount))));
|
|
20
|
+
|
|
21
|
+
return color;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
vec4 sepia_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
25
|
+
return sepia_filterColor(color);
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
4
28
|
const fs = /* glsl */ `\
|
|
5
29
|
uniform sepiaUniforms {
|
|
6
30
|
float amount;
|
|
@@ -39,6 +63,7 @@ export const sepia = {
|
|
|
39
63
|
amount: { value: 0.5, min: 0, max: 1 }
|
|
40
64
|
},
|
|
41
65
|
fs,
|
|
66
|
+
source,
|
|
42
67
|
passes: [{ filter: true }]
|
|
43
68
|
};
|
|
44
69
|
//# sourceMappingURL=sepia.js.map
|
|
@@ -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,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,EAAE,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;CAC6B,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;;;;;;;;;;;;;;;;;;;;;;;CAuBzB,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,6 +21,7 @@ export declare const vibrance: {
|
|
|
21
21
|
readonly max: 1;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
+
readonly source: "struct vibranceUniforms {\n amount: f32\n};\n\n@group(0) @binding(1) var<uniform> vibrance: vibranceUniforms;\n\nfn vibrance_filterColor(vec4f color) -> vec4f {\n let average: f32 = (color.r + color.g + color.b) / 3.0;\n let mx: f32 = max(color.r, max(color.g, color.b));\n let amt: f32 = (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";
|
|
24
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";
|
|
25
26
|
readonly passes: [{
|
|
26
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":"AA4CA;;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"}
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
+
const source = /* wgsl */ `\
|
|
5
|
+
struct vibranceUniforms {
|
|
6
|
+
amount: f32
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
@group(0) @binding(1) var<uniform> vibrance: vibranceUniforms;
|
|
10
|
+
|
|
11
|
+
fn vibrance_filterColor(vec4f color) -> vec4f {
|
|
12
|
+
let average: f32 = (color.r + color.g + color.b) / 3.0;
|
|
13
|
+
let mx: f32 = max(color.r, max(color.g, color.b));
|
|
14
|
+
let amt: f32 = (mx - average) * (-vibrance.amount * 3.0);
|
|
15
|
+
color.rgb = mix(color.rgb, vec3(mx), amt);
|
|
16
|
+
return color;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
vec4 vibrance_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
20
|
+
return vibrance_filterColor(color);
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
4
23
|
const fs = /* glsl */ `\
|
|
5
24
|
uniform vibranceUniforms {
|
|
6
25
|
float amount;
|
|
@@ -29,6 +48,7 @@ export const vibrance = {
|
|
|
29
48
|
propTypes: {
|
|
30
49
|
amount: { value: 0, min: -1, max: 1 }
|
|
31
50
|
},
|
|
51
|
+
source,
|
|
32
52
|
fs,
|
|
33
53
|
passes: [{ filter: true }]
|
|
34
54
|
};
|
|
@@ -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,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,EAAE;IACF,MAAM,EAAE,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;CACmC,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;;;;;;;;;;;;;;;;;;CAkBzB,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"}
|
|
@@ -39,6 +39,6 @@ export declare const vignette: {
|
|
|
39
39
|
readonly passes: [{
|
|
40
40
|
readonly filter: true;
|
|
41
41
|
}];
|
|
42
|
-
readonly fs: "uniform vignetteUniforms {\n
|
|
42
|
+
readonly fs: "struct vignetteUniforms {\n radius: f32,\n amount: f32\n};\n\n@group(0) @binding(1) var<uniform> vignette: vignetteUniforms;\n\nfn vibrance_filterColor(color: vec4f) -> vec4f {\n let average: f32 = (color.r + color.g + color.b) / 3.0;\n let mx: f32 = max(color.r, max(color.g, color.b));\n let amt: f32 = (mx - average) * (-vibrance.amount * 3.0);\n color.rgb = mix(color.rgb, vec3f(mx), amt);\n return color;\n}\n\nfn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) ->vec4f {\n let dist: f32 = distance(texCoord, vec2f(0.5, 0.5));\n let ratio: f32 = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));\n return color.rgba * ratio + (1.0 - ratio)*vec4f(0.0, 0.0, 0.0, 1.0);\n}\n";
|
|
43
43
|
};
|
|
44
44
|
//# sourceMappingURL=vignette.d.ts.map
|
|
@@ -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":"AA6BA;;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"}
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
const fs = /*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
4
|
+
const fs = /* wgsl */ `\
|
|
5
|
+
struct vignetteUniforms {
|
|
6
|
+
radius: f32,
|
|
7
|
+
amount: f32
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
@group(0) @binding(1) var<uniform> vignette: vignetteUniforms;
|
|
11
|
+
|
|
12
|
+
fn vibrance_filterColor(color: vec4f) -> vec4f {
|
|
13
|
+
let average: f32 = (color.r + color.g + color.b) / 3.0;
|
|
14
|
+
let mx: f32 = max(color.r, max(color.g, color.b));
|
|
15
|
+
let amt: f32 = (mx - average) * (-vibrance.amount * 3.0);
|
|
16
|
+
color.rgb = mix(color.rgb, vec3f(mx), amt);
|
|
17
|
+
return color;
|
|
18
|
+
}
|
|
9
19
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return color.rgba * ratio + (1.0 - ratio)*
|
|
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);
|
|
14
24
|
}
|
|
15
25
|
`;
|
|
16
26
|
/**
|
|
@@ -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,EAAE,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,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;CAqBrB,CAAC;AAcF;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,KAAK,EAAE,EAAmB;IAC1B,QAAQ,EAAE,EAAsB;IAEhC,IAAI,EAAE,UAAU;IAEhB,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;IAExB,EAAE;CACyD,CAAC"}
|
|
@@ -27,13 +27,16 @@ export type TiltShiftUniforms = TiltShiftProps;
|
|
|
27
27
|
* on the line and increases further from the line.
|
|
28
28
|
*/
|
|
29
29
|
export declare const tiltShift: {
|
|
30
|
-
readonly props: TiltShiftProps;
|
|
31
|
-
readonly uniforms: TiltShiftUniforms;
|
|
32
30
|
readonly name: "tiltShift";
|
|
33
31
|
readonly dependencies: [{
|
|
34
32
|
readonly name: "random";
|
|
33
|
+
readonly source: "fn random(scale: vec3f, seed: float) -> f32 {\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
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";
|
|
36
35
|
}];
|
|
36
|
+
readonly source: "uniform 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(vec2 texSize) -> vec2f {\n vec2 vector = normalize((tiltShift.end - tiltShift.start) * texSize);\n return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;\n}\n\nfn tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {\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\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";
|
|
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\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";
|
|
38
|
+
readonly props: TiltShiftProps;
|
|
39
|
+
readonly uniforms: TiltShiftUniforms;
|
|
37
40
|
readonly uniformTypes: {
|
|
38
41
|
readonly blurRadius: "f32";
|
|
39
42
|
readonly gradientRadius: "f32";
|
|
@@ -74,6 +77,5 @@ export declare const tiltShift: {
|
|
|
74
77
|
readonly invert: 1;
|
|
75
78
|
};
|
|
76
79
|
}];
|
|
77
|
-
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\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";
|
|
78
80
|
};
|
|
79
81
|
//# sourceMappingURL=tiltshift.d.ts.map
|
|
@@ -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":"AAqGA;;;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"}
|
|
@@ -2,6 +2,53 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { random } from '@luma.gl/shadertools';
|
|
5
|
+
const source = /* wgsl */ `\
|
|
6
|
+
uniform tiltShiftUniforms {
|
|
7
|
+
blurRadius: f32,
|
|
8
|
+
gradientRadius: f32,
|
|
9
|
+
start: vec2f,
|
|
10
|
+
end: vec2f,
|
|
11
|
+
invert: u32,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
@group(0) @binding(1) var<uniform> tiltShift: tiltShiftUniforms;
|
|
15
|
+
|
|
16
|
+
fn tiltShift_getDelta(vec2 texSize) -> vec2f {
|
|
17
|
+
vec2 vector = normalize((tiltShift.end - tiltShift.start) * texSize);
|
|
18
|
+
return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fn tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
|
|
22
|
+
vec4 color = vec4(0.0);
|
|
23
|
+
float total = 0.0;
|
|
24
|
+
|
|
25
|
+
/* randomize the lookup values to hide the fixed number of samples */
|
|
26
|
+
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
27
|
+
|
|
28
|
+
vec2 normal = normalize(vec2((tiltShift.start.y - tiltShift.end.y) * texSize.y, (tiltShift.end.x - tiltShift.start.x) * texSize.x));
|
|
29
|
+
float radius = smoothstep(0.0, 1.0,
|
|
30
|
+
abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;
|
|
31
|
+
|
|
32
|
+
for (float t = -30.0; t <= 30.0; t++) {
|
|
33
|
+
float percent = (t + offset - 0.5) / 30.0;
|
|
34
|
+
float weight = 1.0 - abs(percent);
|
|
35
|
+
vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);
|
|
36
|
+
|
|
37
|
+
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
|
38
|
+
offsetColor.rgb *= offsetColor.a;
|
|
39
|
+
|
|
40
|
+
color += offsetColor * weight;
|
|
41
|
+
total += weight;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
color = color / total;
|
|
45
|
+
|
|
46
|
+
/* switch back from pre-multiplied alpha */
|
|
47
|
+
color.rgb /= color.a + 0.00001;
|
|
48
|
+
|
|
49
|
+
return color;
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
5
52
|
const fs = /* glsl */ `\
|
|
6
53
|
uniform tiltShiftUniforms {
|
|
7
54
|
float blurRadius;
|
|
@@ -59,10 +106,12 @@ vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
59
106
|
* on the line and increases further from the line.
|
|
60
107
|
*/
|
|
61
108
|
export const tiltShift = {
|
|
62
|
-
props: {},
|
|
63
|
-
uniforms: {},
|
|
64
109
|
name: 'tiltShift',
|
|
65
110
|
dependencies: [random],
|
|
111
|
+
source,
|
|
112
|
+
fs,
|
|
113
|
+
props: {},
|
|
114
|
+
uniforms: {},
|
|
66
115
|
uniformTypes: {
|
|
67
116
|
blurRadius: 'f32',
|
|
68
117
|
gradientRadius: 'f32',
|
|
@@ -80,8 +129,7 @@ export const tiltShift = {
|
|
|
80
129
|
passes: [
|
|
81
130
|
{ sampler: true, uniforms: { invert: 0 } },
|
|
82
131
|
{ sampler: true, uniforms: { invert: 1 } }
|
|
83
|
-
]
|
|
84
|
-
fs
|
|
132
|
+
]
|
|
85
133
|
};
|
|
86
134
|
/*
|
|
87
135
|
function tiltShift(startX, startY, endX, endY, blurRadius, gradientRadius) {
|
|
@@ -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,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CrB,CAAC;AAqBF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CrB,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"}
|
|
@@ -18,9 +18,16 @@ export type TriangleBlurUniforms = TriangleBlurProps;
|
|
|
18
18
|
* perpendicular triangle filters.
|
|
19
19
|
*/
|
|
20
20
|
export declare const triangleBlur: {
|
|
21
|
+
readonly name: "triangleBlur";
|
|
22
|
+
readonly dependencies: [{
|
|
23
|
+
readonly name: "random";
|
|
24
|
+
readonly source: "fn random(scale: vec3f, seed: float) -> f32 {\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";
|
|
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
|
+
}];
|
|
27
|
+
readonly source: "uniform triangleBlurUniforms {\n radius: f32,\n delta: vec2f,\n}\n\n@group(0) @binding(1) var<uniform> triangleBlur: triangleBlurUniforms;\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";
|
|
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";
|
|
21
29
|
readonly props: TriangleBlurProps;
|
|
22
30
|
readonly uniforms: TriangleBlurUniforms;
|
|
23
|
-
readonly name: "triangleBlur";
|
|
24
31
|
readonly uniformTypes: {
|
|
25
32
|
readonly radius: "f32";
|
|
26
33
|
readonly delta: "vec2<f32>";
|
|
@@ -36,11 +43,6 @@ export declare const triangleBlur: {
|
|
|
36
43
|
readonly private: true;
|
|
37
44
|
};
|
|
38
45
|
};
|
|
39
|
-
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";
|
|
40
|
-
readonly dependencies: [{
|
|
41
|
-
readonly name: "random";
|
|
42
|
-
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";
|
|
43
|
-
}];
|
|
44
46
|
readonly passes: [{
|
|
45
47
|
readonly sampler: true;
|
|
46
48
|
readonly uniforms: {
|
|
@@ -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":"AAiFA;;;;;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"}
|
|
@@ -2,6 +2,43 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { random } from '@luma.gl/shadertools';
|
|
5
|
+
const source = /* wgsl */ `\
|
|
6
|
+
uniform triangleBlurUniforms {
|
|
7
|
+
radius: f32,
|
|
8
|
+
delta: vec2f,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@group(0) @binding(1) var<uniform> triangleBlur: triangleBlurUniforms;
|
|
12
|
+
|
|
13
|
+
vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
14
|
+
vec2 adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;
|
|
15
|
+
|
|
16
|
+
vec4 color = vec4(0.0);
|
|
17
|
+
float total = 0.0;
|
|
18
|
+
|
|
19
|
+
/* randomize the lookup values to hide the fixed number of samples */
|
|
20
|
+
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
21
|
+
|
|
22
|
+
for (float t = -30.0; t <= 30.0; t++) {
|
|
23
|
+
float percent = (t + offset - 0.5) / 30.0;
|
|
24
|
+
float weight = 1.0 - abs(percent);
|
|
25
|
+
vec4 offsetColor = texture(source, texCoord + adjustedDelta * percent);
|
|
26
|
+
|
|
27
|
+
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
|
28
|
+
offsetColor.rgb *= offsetColor.a;
|
|
29
|
+
|
|
30
|
+
color += offsetColor * weight;
|
|
31
|
+
total += weight;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
color = color / total;
|
|
35
|
+
|
|
36
|
+
/* switch back from pre-multiplied alpha */
|
|
37
|
+
color.rgb /= color.a + 0.00001;
|
|
38
|
+
|
|
39
|
+
return color;
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
5
42
|
const fs = /* glsl */ `\
|
|
6
43
|
uniform triangleBlurUniforms {
|
|
7
44
|
float radius;
|
|
@@ -44,9 +81,12 @@ vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
44
81
|
* perpendicular triangle filters.
|
|
45
82
|
*/
|
|
46
83
|
export const triangleBlur = {
|
|
84
|
+
name: 'triangleBlur',
|
|
85
|
+
dependencies: [random],
|
|
86
|
+
source,
|
|
87
|
+
fs,
|
|
47
88
|
props: {},
|
|
48
89
|
uniforms: {},
|
|
49
|
-
name: 'triangleBlur',
|
|
50
90
|
uniformTypes: {
|
|
51
91
|
radius: 'f32',
|
|
52
92
|
delta: 'vec2<f32>'
|
|
@@ -55,8 +95,6 @@ export const triangleBlur = {
|
|
|
55
95
|
radius: { value: 20, min: 0, softMax: 100 },
|
|
56
96
|
delta: { value: [1, 0], private: true }
|
|
57
97
|
},
|
|
58
|
-
fs,
|
|
59
|
-
dependencies: [random],
|
|
60
98
|
passes: [
|
|
61
99
|
{ sampler: true, uniforms: { delta: [1, 0] } },
|
|
62
100
|
{ sampler: true, uniforms: { delta: [0, 1] } }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triangleblur.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/triangleblur.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAE5C,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCrB,CAAC;AAiBF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,KAAK,EAAE,EAAuB;IAC9B,QAAQ,EAAE,EAA0B;
|
|
1
|
+
{"version":3,"file":"triangleblur.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-blur-filters/triangleblur.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCrB,CAAC;AAiBF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,YAAY,EAAE,CAAC,MAAM,CAAC;IACtB,MAAM;IACN,EAAE;IAEF,KAAK,EAAE,EAAuB;IAC9B,QAAQ,EAAE,EAA0B;IACpC,YAAY,EAAE;QACZ,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,WAAW;KACnB;IACD,SAAS,EAAE;QACT,MAAM,EAAE,EAAC,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAC;QACzC,KAAK,EAAE,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAC;KACtC;IAED,MAAM,EAAE;QACN,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,EAAC;QAC1C,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,EAAC;KAC3C;CACkE,CAAC"}
|