@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magnify.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-fun-filters/magnify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"magnify.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-fun-filters/magnify.ts"],"names":[],"mappings":"AA2DA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,wLAAwL;IACxL,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qGAAqG;IACrG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kFAAkF;IAClF,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;CAsBuC,CAAC"}
|
|
@@ -2,27 +2,32 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
const source = /* wgsl */ `\
|
|
5
|
-
|
|
6
|
-
screenXY: vec2f
|
|
7
|
-
radiusPixels: f32
|
|
8
|
-
zoom: f32
|
|
9
|
-
borderWidthPixels: f32
|
|
10
|
-
borderColor: vec4f
|
|
5
|
+
struct magnifyUniforms {
|
|
6
|
+
screenXY: vec2f,
|
|
7
|
+
radiusPixels: f32,
|
|
8
|
+
zoom: f32,
|
|
9
|
+
borderWidthPixels: f32,
|
|
10
|
+
borderColor: vec4f,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
@group(0) @binding(1) var<uniform> magnify: magnifyUniforms;
|
|
14
14
|
|
|
15
|
-
fn magnify_sampleColor(
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
fn magnify_sampleColor(
|
|
16
|
+
sourceTexture: texture_2d<f32>,
|
|
17
|
+
sourceTextureSampler: sampler,
|
|
18
|
+
texSize: vec2f,
|
|
19
|
+
texCoord: vec2f
|
|
20
|
+
) -> vec4f {
|
|
21
|
+
let pos = vec2f(magnify.screenXY.x, 1.0 - magnify.screenXY.y);
|
|
22
|
+
let dist = distance(texCoord * texSize, pos * texSize);
|
|
18
23
|
if (dist < magnify.radiusPixels) {
|
|
19
|
-
return
|
|
24
|
+
return textureSample(sourceTexture, sourceTextureSampler, (texCoord - pos) / magnify.zoom + pos);
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
if (dist <= magnify.radiusPixels + magnify.borderWidthPixels) {
|
|
23
28
|
return magnify.borderColor;
|
|
24
29
|
}
|
|
25
|
-
return
|
|
30
|
+
return textureSample(sourceTexture, sourceTextureSampler, texCoord);
|
|
26
31
|
}
|
|
27
32
|
`;
|
|
28
33
|
const fs = /* glsl */ `\
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magnify.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-fun-filters/magnify.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"magnify.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-fun-filters/magnify.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;CAqBrB,CAAC;AAoBF;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,SAAS;IACf,MAAM;IACN,EAAE;IAEF,YAAY,EAAE;QACZ,QAAQ,EAAE,WAAW;QACrB,YAAY,EAAE,KAAK;QACnB,IAAI,EAAE,KAAK;QACX,iBAAiB,EAAE,KAAK;QACxB,WAAW,EAAE,WAAW;KACzB;IACD,SAAS,EAAE;QACT,eAAe;QACf,QAAQ,EAAE,EAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC;QACzB,YAAY,EAAE,GAAG;QACjB,IAAI,EAAE,GAAG;QACT,iBAAiB,EAAE,GAAG;QACtB,WAAW,EAAE,EAAC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAC;KAC3C;IAED,MAAM,EAAE,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;CACgC,CAAC"}
|
|
@@ -16,11 +16,11 @@ export declare const bulgePinch: {
|
|
|
16
16
|
readonly name: "bulgePinch";
|
|
17
17
|
readonly dependencies: [{
|
|
18
18
|
readonly name: "warp";
|
|
19
|
-
readonly source: "
|
|
19
|
+
readonly source: "fn warp_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n coord: vec2f\n) -> vec4f {\n var color = textureSample(sourceTexture, sourceTextureSampler, coord / texSize);\n let clampedCoord = clamp(coord, vec2f(0.0), texSize);\n if (any(coord != clampedCoord)) {\n /* fade to transparent if we are outside the image */\n color.a *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n return color;\n}\n";
|
|
20
20
|
readonly fs: "vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {\n vec4 color = texture(source, coord / texSize);\n vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);\n if (coord != clampedCoord) {\n /* fade to transparent if we are outside the image */\n color.a *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n return color;\n}\n";
|
|
21
21
|
readonly passes: [];
|
|
22
22
|
}];
|
|
23
|
-
readonly source: "
|
|
23
|
+
readonly source: "struct bulgePinchUniforms {\n radius: f32,\n strength: f32,\n center: vec2f,\n};\n\n@group(0) @binding(1) var<uniform> bulgePinch: bulgePinchUniforms;\n\nfn bulgePinch_warp(coordIn: vec2f, texCenter: vec2f) -> vec2f {\n var coord = coordIn - texCenter;\n let distance = length(coord);\n if (distance < bulgePinch.radius) {\n let percent = distance / bulgePinch.radius;\n let safeDistance = max(distance, 0.00001);\n if (bulgePinch.strength > 0.0) {\n coord *= mix(\n 1.0,\n smoothstep(0.0, bulgePinch.radius / safeDistance, percent),\n bulgePinch.strength * 0.75\n );\n } else {\n coord *= mix(\n 1.0,\n pow(percent, 1.0 + bulgePinch.strength * 0.75) * bulgePinch.radius / safeDistance,\n 1.0 - percent\n );\n }\n }\n coord += texCenter;\n return coord;\n}\n\nfn bulgePinch_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n var coord = texCoord * texSize;\n coord = bulgePinch_warp(coord, bulgePinch.center * texSize);\n return warp_sampleColor(sourceTexture, sourceTextureSampler, texSize, coord);\n}\n";
|
|
24
24
|
readonly fs: "uniform bulgePinchUniforms {\n float radius;\n float strength;\n vec2 center;\n} bulgePinch;\n\nvec2 bulgePinch_warp(vec2 coord, vec2 texCenter) {\n coord -= texCenter;\n float distance = length(coord);\n if (distance < bulgePinch.radius) {\n float percent = distance / bulgePinch.radius;\n if (bulgePinch.strength > 0.0) {\n coord *= mix(1.0, smoothstep(0.0, bulgePinch.radius / distance, percent), bulgePinch.strength * 0.75);\n } else {\n coord *= mix(1.0, pow(percent, 1.0 + bulgePinch.strength * 0.75) * bulgePinch.radius / distance, 1.0 - percent);\n }\n }\n coord += texCenter;\n return coord;\n}\n\nvec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 coord = texCoord * texSize;\n coord = bulgePinch_warp(coord, bulgePinch.center * texSize);\n\n return warp_sampleColor(source, texSize, coord);\n}\n";
|
|
25
25
|
readonly props: BulgePinchProps;
|
|
26
26
|
readonly uniforms: BulgePinchUniforms;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulgepinch.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-warp-filters/bulgepinch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bulgepinch.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-warp-filters/bulgepinch.ts"],"names":[],"mappings":"AAkFA,+CAA+C;AAC/C,MAAM,MAAM,eAAe,GAAG;IAC5B,oEAAoE;IACpE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;oBAMR,eAAe;uBACZ,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;CAa6B,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { warp } from "./warp.js";
|
|
5
5
|
const source = /* wgsl */ `\
|
|
6
|
-
|
|
6
|
+
struct bulgePinchUniforms {
|
|
7
7
|
radius: f32,
|
|
8
8
|
strength: f32,
|
|
9
9
|
center: vec2f,
|
|
@@ -11,25 +11,39 @@ uniform bulgePinchUniforms {
|
|
|
11
11
|
|
|
12
12
|
@group(0) @binding(1) var<uniform> bulgePinch: bulgePinchUniforms;
|
|
13
13
|
|
|
14
|
-
fn bulgePinch_warp(
|
|
15
|
-
coord
|
|
16
|
-
|
|
14
|
+
fn bulgePinch_warp(coordIn: vec2f, texCenter: vec2f) -> vec2f {
|
|
15
|
+
var coord = coordIn - texCenter;
|
|
16
|
+
let distance = length(coord);
|
|
17
17
|
if (distance < bulgePinch.radius) {
|
|
18
|
-
|
|
18
|
+
let percent = distance / bulgePinch.radius;
|
|
19
|
+
let safeDistance = max(distance, 0.00001);
|
|
19
20
|
if (bulgePinch.strength > 0.0) {
|
|
20
|
-
coord *= mix(
|
|
21
|
+
coord *= mix(
|
|
22
|
+
1.0,
|
|
23
|
+
smoothstep(0.0, bulgePinch.radius / safeDistance, percent),
|
|
24
|
+
bulgePinch.strength * 0.75
|
|
25
|
+
);
|
|
21
26
|
} else {
|
|
22
|
-
coord *= mix(
|
|
27
|
+
coord *= mix(
|
|
28
|
+
1.0,
|
|
29
|
+
pow(percent, 1.0 + bulgePinch.strength * 0.75) * bulgePinch.radius / safeDistance,
|
|
30
|
+
1.0 - percent
|
|
31
|
+
);
|
|
23
32
|
}
|
|
24
33
|
}
|
|
25
34
|
coord += texCenter;
|
|
26
35
|
return coord;
|
|
27
36
|
}
|
|
28
37
|
|
|
29
|
-
fn bulgePinch_sampleColor(
|
|
30
|
-
|
|
38
|
+
fn bulgePinch_sampleColor(
|
|
39
|
+
sourceTexture: texture_2d<f32>,
|
|
40
|
+
sourceTextureSampler: sampler,
|
|
41
|
+
texSize: vec2f,
|
|
42
|
+
texCoord: vec2f
|
|
43
|
+
) -> vec4f {
|
|
44
|
+
var coord = texCoord * texSize;
|
|
31
45
|
coord = bulgePinch_warp(coord, bulgePinch.center * texSize);
|
|
32
|
-
return warp_sampleColor(
|
|
46
|
+
return warp_sampleColor(sourceTexture, sourceTextureSampler, texSize, coord);
|
|
33
47
|
}
|
|
34
48
|
`;
|
|
35
49
|
const fs = /* glsl */ `\
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulgepinch.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-warp-filters/bulgepinch.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,IAAI,EAAC,kBAAe;AAE5B,MAAM,MAAM,GAAG,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"bulgepinch.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-warp-filters/bulgepinch.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,IAAI,EAAC,kBAAe;AAE5B,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BrB,CAAC;AAcF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,YAAY,EAAE,CAAC,IAAI,CAAC;IACpB,MAAM;IACN,EAAE;IAEF,KAAK,EAAE,EAAqB;IAC5B,QAAQ,EAAE,EAAwB;IAClC,YAAY,EAAE;QACZ,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,KAAK;KAChB;IACD,SAAS,EAAE;QACT,MAAM,EAAE,EAAC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAC;QAC3B,MAAM,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAC;QAC1C,QAAQ,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;KACxC;IAED,MAAM,EAAE,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;CACsC,CAAC"}
|
|
@@ -17,11 +17,11 @@ export declare const swirl: {
|
|
|
17
17
|
readonly name: "swirl";
|
|
18
18
|
readonly dependencies: [{
|
|
19
19
|
readonly name: "warp";
|
|
20
|
-
readonly source: "
|
|
20
|
+
readonly source: "fn warp_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n coord: vec2f\n) -> vec4f {\n var color = textureSample(sourceTexture, sourceTextureSampler, coord / texSize);\n let clampedCoord = clamp(coord, vec2f(0.0), texSize);\n if (any(coord != clampedCoord)) {\n /* fade to transparent if we are outside the image */\n color.a *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n return color;\n}\n";
|
|
21
21
|
readonly fs: "vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {\n vec4 color = texture(source, coord / texSize);\n vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);\n if (coord != clampedCoord) {\n /* fade to transparent if we are outside the image */\n color.a *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n return color;\n}\n";
|
|
22
22
|
readonly passes: [];
|
|
23
23
|
}];
|
|
24
|
-
readonly source: "
|
|
24
|
+
readonly source: "struct swirlUniforms {\n radius: f32,\n angle: f32,\n center: vec2f,\n};\n\n@group(0) @binding(1) var<uniform> swirl: swirlUniforms;\n\nfn swirl_warp(coordIn: vec2f, texCenter: vec2f) -> vec2f {\n var coord = coordIn - texCenter;\n let distance = length(coord);\n if (distance < swirl.radius) {\n let percent = (swirl.radius - distance) / swirl.radius;\n let theta = percent * percent * swirl.angle;\n let s = sin(theta);\n let c = cos(theta);\n coord = vec2f(\n coord.x * c - coord.y * s,\n coord.x * s + coord.y * c\n );\n }\n coord += texCenter;\n return coord;\n}\n\nfn swirl_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n var coord = texCoord * texSize;\n coord = swirl_warp(coord, swirl.center * texSize);\n return warp_sampleColor(sourceTexture, sourceTextureSampler, texSize, coord);\n}\n";
|
|
25
25
|
readonly fs: "uniform swirlUniforms {\n float radius;\n float angle;\n vec2 center;\n} swirl;\n\nvec2 swirl_warp(vec2 coord, vec2 texCenter) {\n coord -= texCenter;\n float distance = length(coord);\n if (distance < swirl.radius) {\n float percent = (swirl.radius - distance) / swirl.radius;\n float theta = percent * percent * swirl.angle;\n float s = sin(theta);\n float c = cos(theta);\n coord = vec2(\n coord.x * c - coord.y * s,\n coord.x * s + coord.y * c\n );\n }\n coord += texCenter;\n return coord;\n}\n\nvec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 coord = texCoord * texSize;\n coord = swirl_warp(coord, swirl.center * texSize);\n\n return warp_sampleColor(source, texSize, coord);\n}\n";
|
|
26
26
|
readonly props: SwirlProps;
|
|
27
27
|
readonly uniforms: SwirlProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swirl.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-warp-filters/swirl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"swirl.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-warp-filters/swirl.ts"],"names":[],"mappings":"AA6EA;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,oFAAoF;IACpF,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oGAAoG;IACpG,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;oBAMH,UAAU;uBACP,UAAU;;;;;;;;;;;;;;;;;;;;;;;;CAa2B,CAAC"}
|
|
@@ -3,23 +3,23 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { warp } from "./warp.js";
|
|
5
5
|
const source = /* wgsl */ `\
|
|
6
|
-
|
|
6
|
+
struct swirlUniforms {
|
|
7
7
|
radius: f32,
|
|
8
8
|
angle: f32,
|
|
9
9
|
center: vec2f,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
@group(0) @binding(1) swirl: swirlUniforms;
|
|
12
|
+
@group(0) @binding(1) var<uniform> swirl: swirlUniforms;
|
|
13
13
|
|
|
14
|
-
fn swirl_warp(
|
|
15
|
-
coord
|
|
16
|
-
|
|
14
|
+
fn swirl_warp(coordIn: vec2f, texCenter: vec2f) -> vec2f {
|
|
15
|
+
var coord = coordIn - texCenter;
|
|
16
|
+
let distance = length(coord);
|
|
17
17
|
if (distance < swirl.radius) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
coord =
|
|
18
|
+
let percent = (swirl.radius - distance) / swirl.radius;
|
|
19
|
+
let theta = percent * percent * swirl.angle;
|
|
20
|
+
let s = sin(theta);
|
|
21
|
+
let c = cos(theta);
|
|
22
|
+
coord = vec2f(
|
|
23
23
|
coord.x * c - coord.y * s,
|
|
24
24
|
coord.x * s + coord.y * c
|
|
25
25
|
);
|
|
@@ -28,10 +28,15 @@ fn swirl_warp(vec2 coord, vec2 texCenter) -> vec2f {
|
|
|
28
28
|
return coord;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
fn swirl_sampleColor(
|
|
32
|
-
|
|
31
|
+
fn swirl_sampleColor(
|
|
32
|
+
sourceTexture: texture_2d<f32>,
|
|
33
|
+
sourceTextureSampler: sampler,
|
|
34
|
+
texSize: vec2f,
|
|
35
|
+
texCoord: vec2f
|
|
36
|
+
) -> vec4f {
|
|
37
|
+
var coord = texCoord * texSize;
|
|
33
38
|
coord = swirl_warp(coord, swirl.center * texSize);
|
|
34
|
-
return warp_sampleColor(
|
|
39
|
+
return warp_sampleColor(sourceTexture, sourceTextureSampler, texSize, coord);
|
|
35
40
|
}
|
|
36
41
|
`;
|
|
37
42
|
const fs = /* glsl */ `\
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swirl.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-warp-filters/swirl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,IAAI,EAAC,kBAAe;AAE5B,MAAM,MAAM,GAAG,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"swirl.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-warp-filters/swirl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,IAAI,EAAC,kBAAe;AAE5B,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BrB,CAAC;AAgBF;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,YAAY,EAAE,CAAC,IAAI,CAAC;IACpB,MAAM;IACN,EAAE;IAEF,KAAK,EAAE,EAAgB;IACvB,QAAQ,EAAE,EAAgB;IAC1B,YAAY,EAAE;QACZ,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,KAAK;KACb;IACD,SAAS,EAAE;QACT,MAAM,EAAE,EAAC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAC;QAC3B,MAAM,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAC;QAC1C,KAAK,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAC;KAC7C;IAED,MAAM,EAAE,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;CAC4B,CAAC"}
|
|
@@ -2,7 +2,7 @@ export type WarpProps = {};
|
|
|
2
2
|
export type WarpUniforms = WarpProps;
|
|
3
3
|
export declare const warp: {
|
|
4
4
|
readonly name: "warp";
|
|
5
|
-
readonly source: "
|
|
5
|
+
readonly source: "fn warp_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n coord: vec2f\n) -> vec4f {\n var color = textureSample(sourceTexture, sourceTextureSampler, coord / texSize);\n let clampedCoord = clamp(coord, vec2f(0.0), texSize);\n if (any(coord != clampedCoord)) {\n /* fade to transparent if we are outside the image */\n color.a *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n return color;\n}\n";
|
|
6
6
|
readonly fs: "vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {\n vec4 color = texture(source, coord / texSize);\n vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);\n if (coord != clampedCoord) {\n /* fade to transparent if we are outside the image */\n color.a *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n return color;\n}\n";
|
|
7
7
|
readonly passes: [];
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warp.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-warp-filters/warp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"warp.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-warp-filters/warp.ts"],"names":[],"mappings":"AAmCA,MAAM,MAAM,SAAS,GAAG,EAAE,CAAC;AAE3B,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC;AAErC,eAAO,MAAM,IAAI;;;;;CAMoC,CAAC"}
|
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
const source = /* wgsl */ `\
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
fn warp_sampleColor(
|
|
6
|
+
sourceTexture: texture_2d<f32>,
|
|
7
|
+
sourceTextureSampler: sampler,
|
|
8
|
+
texSize: vec2f,
|
|
9
|
+
coord: vec2f
|
|
10
|
+
) -> vec4f {
|
|
11
|
+
var color = textureSample(sourceTexture, sourceTextureSampler, coord / texSize);
|
|
12
|
+
let clampedCoord = clamp(coord, vec2f(0.0), texSize);
|
|
13
|
+
if (any(coord != clampedCoord)) {
|
|
9
14
|
/* fade to transparent if we are outside the image */
|
|
10
15
|
color.a *= max(0.0, 1.0 - length(coord - clampedCoord));
|
|
11
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warp.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-warp-filters/warp.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"warp.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-warp-filters/warp.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;CAezB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;CAUrB,CAAC;AAMF,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,IAAI,EAAE,MAAM;IACZ,MAAM;IACN,EAAE;IAEF,MAAM,EAAE,EAAE;CACyC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/effects",
|
|
3
|
-
"version": "9.3.0-alpha.
|
|
3
|
+
"version": "9.3.0-alpha.6",
|
|
4
4
|
"description": "Post-processing effects for luma.gl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"@math.gl/core": "^4.1.0",
|
|
53
53
|
"@math.gl/types": "^4.1.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "59fda5480c4d0bb3d64545d4621175221f2b6c7c"
|
|
56
56
|
}
|
|
@@ -14,13 +14,14 @@ struct brightnessContrastUniforms {
|
|
|
14
14
|
@group(0) @binding(1) var<uniform> brightnessContrast : brightnessContrastUniforms;
|
|
15
15
|
|
|
16
16
|
fn brightnessContrast_filterColor_ext(color: vec4f, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4f {
|
|
17
|
-
|
|
17
|
+
var result = color;
|
|
18
|
+
result.rgb += vec3f(brightnessContrast.brightness);
|
|
18
19
|
if (brightnessContrast.contrast > 0.0) {
|
|
19
|
-
|
|
20
|
+
result.rgb = (result.rgb - vec3f(0.5)) / (1.0 - brightnessContrast.contrast) + vec3f(0.5);
|
|
20
21
|
} else {
|
|
21
|
-
|
|
22
|
+
result.rgb = (result.rgb - vec3f(0.5)) * (1.0 + brightnessContrast.contrast) + vec3f(0.5);
|
|
22
23
|
}
|
|
23
|
-
return
|
|
24
|
+
return result;
|
|
24
25
|
}
|
|
25
26
|
`;
|
|
26
27
|
|
|
@@ -6,33 +6,41 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
|
|
7
7
|
// Do a 9x9 bilateral box filter
|
|
8
8
|
const source = /* wgsl */ `\
|
|
9
|
-
|
|
10
9
|
struct denoiseUniforms {
|
|
11
|
-
strength: f32
|
|
10
|
+
strength: f32,
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
@group(0)
|
|
15
|
-
|
|
16
|
-
fn denoise_sampleColor(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
@group(0) @binding(1) var<uniform> denoise: denoiseUniforms;
|
|
14
|
+
|
|
15
|
+
fn denoise_sampleColor(
|
|
16
|
+
sourceTexture: texture_2d<f32>,
|
|
17
|
+
sourceTextureSampler: sampler,
|
|
18
|
+
texSize: vec2f,
|
|
19
|
+
texCoord: vec2f
|
|
20
|
+
) -> vec4f {
|
|
21
|
+
let adjustedExponent = 3.0 + 200.0 * pow(1.0 - denoise.strength, 4.0);
|
|
22
|
+
let center = textureSample(sourceTexture, sourceTextureSampler, texCoord);
|
|
23
|
+
var color = vec4f(0.0);
|
|
24
|
+
var total = 0.0;
|
|
25
|
+
|
|
26
|
+
for (var x = -4.0; x <= 4.0; x += 1.0) {
|
|
27
|
+
for (var y = -4.0; y <= 4.0; y += 1.0) {
|
|
28
|
+
let offsetColor = textureSample(
|
|
29
|
+
sourceTexture,
|
|
30
|
+
sourceTextureSampler,
|
|
31
|
+
texCoord + vec2f(x, y) / texSize
|
|
32
|
+
);
|
|
33
|
+
let weight = pow(
|
|
34
|
+
1.0 - abs(dot(offsetColor.rgb - center.rgb, vec3f(0.25))),
|
|
35
|
+
adjustedExponent
|
|
36
|
+
);
|
|
37
|
+
color += offsetColor * weight;
|
|
38
|
+
total += weight;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
}
|
|
42
|
+
return color / total;
|
|
43
|
+
}
|
|
36
44
|
`;
|
|
37
45
|
|
|
38
46
|
const fs = /* glsl */ `\
|
|
@@ -5,45 +5,39 @@
|
|
|
5
5
|
import type {ShaderPass} from '@luma.gl/shadertools';
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
|
-
|
|
9
8
|
struct hueSaturationUniforms {
|
|
10
9
|
hue: f32,
|
|
11
10
|
saturation: f32,
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
@group(0)
|
|
15
|
-
|
|
16
|
-
fn hueSaturation_filterColor(color:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
fn hueSaturation_filterColor_ext(color: vec4<f32>, texSize: vec2<f32>, texCoord: vec2<f32>) -> vec4<f32> {
|
|
45
|
-
return hueSaturation_filterColor(color);
|
|
46
|
-
}
|
|
13
|
+
@group(0) @binding(1) var<uniform> hueSaturation: hueSaturationUniforms;
|
|
14
|
+
|
|
15
|
+
fn hueSaturation_filterColor(color: vec4f) -> vec4f {
|
|
16
|
+
let angle = hueSaturation.hue * 3.14159265;
|
|
17
|
+
let s = sin(angle);
|
|
18
|
+
let c = cos(angle);
|
|
19
|
+
let weights = (vec3f(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + vec3f(1.0)) / 3.0;
|
|
20
|
+
|
|
21
|
+
var result = color;
|
|
22
|
+
result.rgb = vec3f(
|
|
23
|
+
dot(result.rgb, weights.xyz),
|
|
24
|
+
dot(result.rgb, weights.zxy),
|
|
25
|
+
dot(result.rgb, weights.yzx)
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
let average = (result.r + result.g + result.b) / 3.0;
|
|
29
|
+
if (hueSaturation.saturation > 0.0) {
|
|
30
|
+
result.rgb += (vec3f(average) - result.rgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));
|
|
31
|
+
} else {
|
|
32
|
+
result.rgb += (vec3f(average) - result.rgb) * (-hueSaturation.saturation);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fn hueSaturation_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
39
|
+
return hueSaturation_filterColor(color);
|
|
40
|
+
}
|
|
47
41
|
`;
|
|
48
42
|
|
|
49
43
|
const fs = /* glsl */ `\
|
|
@@ -6,7 +6,7 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
8
|
struct noiseUniforms {
|
|
9
|
-
amount: f32
|
|
9
|
+
amount: f32,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
@group(0) @binding(1) var<uniform> noise: noiseUniforms;
|
|
@@ -16,12 +16,13 @@ fn rand(co: vec2f) -> f32 {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
fn noise_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
let diff = (rand(texCoord) - 0.5) * noise.amount;
|
|
20
|
+
var result = color;
|
|
21
|
+
result.r += diff;
|
|
22
|
+
result.g += diff;
|
|
23
|
+
result.b += diff;
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
25
26
|
`;
|
|
26
27
|
|
|
27
28
|
const fs = /* glsl */ `\
|
|
@@ -6,25 +6,26 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
8
|
struct sepiaUniforms {
|
|
9
|
-
amount: f32
|
|
9
|
+
amount: f32,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
@group(0) @binding(1) var<uniform> sepia: sepiaUniforms;
|
|
13
13
|
|
|
14
14
|
fn sepia_filterColor(color: vec4f) -> vec4f {
|
|
15
|
-
let r
|
|
16
|
-
let g
|
|
17
|
-
let b
|
|
15
|
+
let r = color.r;
|
|
16
|
+
let g = color.g;
|
|
17
|
+
let b = color.b;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
var result = color;
|
|
20
|
+
result.r =
|
|
20
21
|
min(1.0, (r * (1.0 - (0.607 * sepia.amount))) + (g * (0.769 * sepia.amount)) + (b * (0.189 * sepia.amount)));
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
result.g = min(1.0, (r * 0.349 * sepia.amount) + (g * (1.0 - (0.314 * sepia.amount))) + (b * 0.168 * sepia.amount));
|
|
23
|
+
result.b = min(1.0, (r * 0.272 * sepia.amount) + (g * 0.534 * sepia.amount) + (b * (1.0 - (0.869 * sepia.amount))));
|
|
23
24
|
|
|
24
|
-
return
|
|
25
|
+
return result;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
fn sepia_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
28
29
|
return sepia_filterColor(color);
|
|
29
30
|
}
|
|
30
31
|
`;
|
|
@@ -6,20 +6,21 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
6
6
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
8
|
struct vibranceUniforms {
|
|
9
|
-
amount: f32
|
|
9
|
+
amount: f32,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
@group(0) @binding(1) var<uniform> vibrance: vibranceUniforms;
|
|
13
13
|
|
|
14
|
-
fn vibrance_filterColor(vec4f
|
|
15
|
-
let average
|
|
16
|
-
let mx
|
|
17
|
-
let amt
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
fn vibrance_filterColor(color: vec4f) -> vec4f {
|
|
15
|
+
let average = (color.r + color.g + color.b) / 3.0;
|
|
16
|
+
let mx = max(color.r, max(color.g, color.b));
|
|
17
|
+
let amt = (mx - average) * (-vibrance.amount * 3.0);
|
|
18
|
+
var result = color;
|
|
19
|
+
result.rgb = mix(result.rgb, vec3f(mx), amt);
|
|
20
|
+
return result;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
fn vibrance_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
23
24
|
return vibrance_filterColor(color);
|
|
24
25
|
}
|
|
25
26
|
`;
|
|
@@ -7,23 +7,19 @@ import type {ShaderPass} from '@luma.gl/shadertools';
|
|
|
7
7
|
const source = /* wgsl */ `\
|
|
8
8
|
struct vignetteUniforms {
|
|
9
9
|
radius: f32,
|
|
10
|
-
amount: f32
|
|
10
|
+
amount: f32,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
@group(0) @binding(1) var<uniform> vignette: vignetteUniforms;
|
|
14
14
|
|
|
15
|
-
fn
|
|
16
|
-
let
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
fn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) ->vec4f {
|
|
24
|
-
let dist: f32 = distance(texCoord, vec2f(0.5, 0.5));
|
|
25
|
-
let ratio: f32 = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));
|
|
26
|
-
return color.rgba * ratio + (1.0 - ratio)*vec4f(0.0, 0.0, 0.0, 1.0);
|
|
15
|
+
fn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
|
|
16
|
+
let dist = distance(texCoord, vec2f(0.5, 0.5));
|
|
17
|
+
let ratio = smoothstep(
|
|
18
|
+
0.8,
|
|
19
|
+
vignette.radius * 0.799,
|
|
20
|
+
dist * (vignette.amount + vignette.radius)
|
|
21
|
+
);
|
|
22
|
+
return color * ratio + vec4f(0.0, 0.0, 0.0, 1.0) * (1.0 - ratio);
|
|
27
23
|
}
|
|
28
24
|
`;
|
|
29
25
|
|