@luma.gl/shadertools 9.1.0-alpha.1 → 9.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +816 -483
- package/dist/dist.min.js +2325 -1622
- package/dist/index.cjs +2669 -1808
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +29 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -12
- package/dist/lib/glsl-utils/shader-utils.d.ts.map +1 -1
- package/dist/lib/glsl-utils/shader-utils.js +2 -3
- package/dist/lib/shader-assembler.d.ts +3 -4
- package/dist/lib/shader-assembler.d.ts.map +1 -1
- package/dist/lib/shader-assembler.js +3 -2
- package/dist/lib/shader-assembly/assemble-shaders.d.ts +4 -3
- package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
- package/dist/lib/shader-assembly/assemble-shaders.js +43 -16
- package/dist/lib/shader-assembly/platform-defines.d.ts.map +1 -1
- package/dist/lib/shader-assembly/platform-defines.js +14 -6
- package/dist/lib/shader-module/shader-module-dependencies.d.ts +53 -0
- package/dist/lib/shader-module/shader-module-dependencies.d.ts.map +1 -0
- package/dist/lib/{shader-assembly/resolve-modules.js → shader-module/shader-module-dependencies.js} +38 -14
- package/dist/lib/shader-module/shader-module.d.ts +29 -11
- package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
- package/dist/lib/shader-module/shader-module.js +76 -6
- package/dist/lib/shader-module/shader-pass.d.ts +3 -2
- package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
- package/dist/module-injectors.d.ts +2 -2
- package/dist/module-injectors.d.ts.map +1 -1
- package/dist/module-injectors.js +13 -10
- package/dist/modules/engine/geometry/geometry.d.ts.map +1 -1
- package/dist/modules/engine/geometry/geometry.js +12 -8
- package/dist/modules/engine/picking/picking.d.ts +4 -4
- package/dist/modules/engine/picking/picking.d.ts.map +1 -1
- package/dist/modules/engine/picking/picking.js +103 -66
- package/dist/modules/engine/project/project.d.ts +2 -2
- package/dist/modules/engine/project/project.d.ts.map +1 -1
- package/dist/modules/engine/project/project.js +36 -22
- package/dist/modules/engine/transform/transform.d.ts.map +1 -1
- package/dist/modules/engine/transform/transform.js +28 -16
- package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +9 -7
- package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-material.js +2 -0
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts +2 -2
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +79 -53
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts +1 -1
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +38 -23
- package/dist/modules/lighting/lights/lighting.d.ts +4 -4
- package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
- package/dist/modules/lighting/lights/lighting.js +2 -2
- package/dist/modules/lighting/no-material/dirlight.d.ts +4 -4
- package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
- package/dist/modules/lighting/no-material/dirlight.js +12 -9
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts +1 -1
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js +304 -181
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts +71 -69
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material.js +4 -2
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts +1 -1
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js +38 -20
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +1 -1
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +21 -16
- package/dist/modules/lighting/phong-material/phong-material.d.ts +12 -12
- package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
- package/dist/modules/lighting/phong-material/phong-material.js +3 -3
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +2 -2
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +82 -54
- package/dist/modules/math/fp32/fp32.d.ts.map +1 -1
- package/dist/modules/math/fp32/fp32.js +127 -100
- package/dist/modules/math/random/random.d.ts +1 -1
- package/dist/modules/math/random/random.d.ts.map +1 -1
- package/dist/modules/math/random/random.js +3 -3
- package/dist/modules/module-injectors.d.ts +2 -2
- package/dist/modules/module-injectors.d.ts.map +1 -1
- package/dist/modules/module-injectors.js +13 -10
- package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +4 -1
- package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.js +16 -12
- package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts +4 -1
- package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/denoise.js +21 -17
- package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts +5 -2
- package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/huesaturation.js +29 -22
- package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts +4 -1
- package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/noise.js +14 -10
- package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts +4 -1
- package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/sepia.js +17 -12
- package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts +4 -1
- package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/vibrance.js +12 -9
- package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts +4 -1
- package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/vignette.js +13 -10
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts +5 -2
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.js +40 -26
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts +5 -2
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.js +32 -19
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts +4 -1
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.js +2 -0
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts +4 -1
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.js +31 -27
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts +4 -1
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.js +19 -15
- package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts +8 -5
- package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/edgework.js +53 -42
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +4 -1
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.js +41 -33
- package/dist/modules/postprocessing/image-fun-filters/ink.d.ts +4 -1
- package/dist/modules/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/ink.js +27 -25
- package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts +2 -1
- package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/magnify.js +17 -16
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts +5 -2
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.js +24 -20
- package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts +5 -2
- package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-warp-filters/swirl.js +26 -22
- package/dist/modules/postprocessing/image-warp-filters/warp.d.ts +2 -1
- package/dist/modules/postprocessing/image-warp-filters/warp.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-warp-filters/warp.js +9 -8
- package/dist/modules-webgl1/geometry/geometry.d.ts.map +1 -1
- package/dist/modules-webgl1/geometry/geometry.js +12 -8
- package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts.map +1 -1
- package/dist/modules-webgl1/lighting/dirlight/dirlight.js +8 -5
- package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts +1 -1
- package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts.map +1 -1
- package/dist/modules-webgl1/lighting/lights/lights-glsl.js +19 -11
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts +1 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts.map +1 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js +268 -157
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts +1 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts.map +1 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js +16 -12
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts +1 -1
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts.map +1 -1
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js +64 -55
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts +1 -1
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -1
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js +113 -81
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts +1 -1
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts.map +1 -1
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js +588 -433
- package/dist/modules-webgl1/project/project.d.ts +2 -2
- package/dist/modules-webgl1/project/project.d.ts.map +1 -1
- package/dist/modules-webgl1/project/project.js +5 -4
- package/package.json +2 -2
- package/src/index.ts +78 -32
- package/src/lib/glsl-utils/shader-utils.ts +1 -3
- package/src/lib/shader-assembler.ts +7 -8
- package/src/lib/shader-assembly/assemble-shaders.ts +52 -20
- package/src/lib/shader-assembly/platform-defines.ts +5 -6
- package/src/lib/shader-module/shader-module-dependencies.ts +112 -0
- package/src/lib/shader-module/shader-module.ts +129 -18
- package/src/lib/shader-module/shader-pass.ts +3 -2
- package/src/module-injectors.ts +2 -4
- package/src/modules/engine/geometry/geometry.ts +2 -3
- package/src/modules/engine/picking/picking.ts +7 -5
- package/src/modules/engine/project/project.ts +2 -3
- package/src/modules/engine/transform/transform.ts +1 -3
- package/src/modules/lighting/gouraud-material/gouraud-material.ts +4 -0
- package/src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts +2 -4
- package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +1 -3
- package/src/modules/lighting/lights/lighting.ts +4 -2
- package/src/modules/lighting/no-material/dirlight.ts +6 -5
- package/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts +1 -2
- package/src/modules/lighting/pbr-material/pbr-material.ts +44 -38
- package/src/modules/lighting/pbr-material/pbr-uniforms-glsl.ts +1 -3
- package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +1 -3
- package/src/modules/lighting/phong-material/phong-material.ts +4 -3
- package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +2 -4
- package/src/modules/math/fp32/fp32.ts +1 -2
- package/src/modules/math/random/random.ts +1 -2
- package/src/modules/module-injectors.ts +2 -4
- package/src/modules/postprocessing/image-adjust-filters/brightnesscontrast.ts +6 -2
- package/src/modules/postprocessing/image-adjust-filters/denoise.ts +7 -3
- package/src/modules/postprocessing/image-adjust-filters/huesaturation.ts +9 -4
- package/src/modules/postprocessing/image-adjust-filters/noise.ts +6 -2
- package/src/modules/postprocessing/image-adjust-filters/sepia.ts +6 -2
- package/src/modules/postprocessing/image-adjust-filters/vibrance.ts +5 -2
- package/src/modules/postprocessing/image-adjust-filters/vignette.ts +11 -4
- package/src/modules/postprocessing/image-blur-filters/tiltshift.ts +6 -2
- package/src/modules/postprocessing/image-blur-filters/triangleblur.ts +6 -2
- package/src/modules/postprocessing/image-blur-filters/zoomblur.ts +5 -0
- package/src/modules/postprocessing/image-fun-filters/colorhalftone.ts +6 -2
- package/src/modules/postprocessing/image-fun-filters/dotscreen.ts +6 -2
- package/src/modules/postprocessing/image-fun-filters/edgework.ts +10 -4
- package/src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts +6 -2
- package/src/modules/postprocessing/image-fun-filters/ink.ts +8 -3
- package/src/modules/postprocessing/image-fun-filters/magnify.ts +3 -2
- package/src/modules/postprocessing/image-warp-filters/bulgepinch.ts +6 -2
- package/src/modules/postprocessing/image-warp-filters/swirl.ts +8 -2
- package/src/modules/postprocessing/image-warp-filters/warp.ts +3 -2
- package/src/modules-webgl1/geometry/geometry.ts +2 -3
- package/src/modules-webgl1/lighting/dirlight/dirlight.ts +1 -2
- package/src/modules-webgl1/lighting/lights/lights-glsl.ts +1 -3
- package/src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts +1 -2
- package/src/modules-webgl1/lighting/pbr/pbr-vertex-glsl.ts +1 -3
- package/src/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.ts +1 -3
- package/src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts +1 -3
- package/src/modules-webgl1/math/fp64/fp64-functions-glsl.ts +1 -3
- package/src/modules-webgl1/project/project.ts +1 -2
- package/dist/lib/glsl-utils/highlight.d.ts +0 -6
- package/dist/lib/glsl-utils/highlight.d.ts.map +0 -1
- package/dist/lib/glsl-utils/highlight.js +0 -9
- package/dist/lib/shader-assembly/resolve-modules.d.ts +0 -40
- package/dist/lib/shader-assembly/resolve-modules.d.ts.map +0 -1
- package/dist/lib/shader-module/normalize-shader-module.d.ts +0 -3
- package/dist/lib/shader-module/normalize-shader-module.d.ts.map +0 -1
- package/dist/lib/shader-module/normalize-shader-module.js +0 -14
- package/dist/lib/shader-module/shader-module-instance.d.ts +0 -28
- package/dist/lib/shader-module/shader-module-instance.d.ts.map +0 -1
- package/dist/lib/shader-module/shader-module-instance.js +0 -126
- package/src/lib/glsl-utils/highlight.ts +0 -11
- package/src/lib/shader-assembly/resolve-modules.ts +0 -81
- package/src/lib/shader-module/normalize-shader-module.ts +0 -17
- package/src/lib/shader-module/shader-module-instance.ts +0 -167
|
@@ -1,29 +1,40 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { glsl } from "../../../lib/glsl-utils/highlight.js";
|
|
5
4
|
import { random } from "../..//math/random/random.js";
|
|
6
|
-
const fs = `\
|
|
5
|
+
const fs = /* glsl */ `\
|
|
7
6
|
uniform triangleBlurUniforms {
|
|
8
|
-
float radius;
|
|
9
|
-
vec2 delta;
|
|
7
|
+
float radius;
|
|
8
|
+
vec2 delta;
|
|
10
9
|
} triangleBlur;
|
|
10
|
+
|
|
11
11
|
vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
12
|
-
vec2 adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
float
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
float
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
vec2 adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;
|
|
13
|
+
|
|
14
|
+
vec4 color = vec4(0.0);
|
|
15
|
+
float total = 0.0;
|
|
16
|
+
|
|
17
|
+
/* randomize the lookup values to hide the fixed number of samples */
|
|
18
|
+
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
19
|
+
|
|
20
|
+
for (float t = -30.0; t <= 30.0; t++) {
|
|
21
|
+
float percent = (t + offset - 0.5) / 30.0;
|
|
22
|
+
float weight = 1.0 - abs(percent);
|
|
23
|
+
vec4 offsetColor = texture(source, texCoord + adjustedDelta * percent);
|
|
24
|
+
|
|
25
|
+
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
|
26
|
+
offsetColor.rgb *= offsetColor.a;
|
|
27
|
+
|
|
28
|
+
color += offsetColor * weight;
|
|
29
|
+
total += weight;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
color = color / total;
|
|
33
|
+
|
|
34
|
+
/* switch back from pre-multiplied alpha */
|
|
35
|
+
color.rgb /= color.a + 0.00001;
|
|
36
|
+
|
|
37
|
+
return color;
|
|
27
38
|
}
|
|
28
39
|
`;
|
|
29
40
|
/**
|
|
@@ -33,6 +44,8 @@ return color;
|
|
|
33
44
|
* perpendicular triangle filters.
|
|
34
45
|
*/
|
|
35
46
|
export const triangleBlur = {
|
|
47
|
+
props: {},
|
|
48
|
+
uniforms: {},
|
|
36
49
|
name: 'triangleBlur',
|
|
37
50
|
uniformTypes: {
|
|
38
51
|
radius: 'f32',
|
|
@@ -7,11 +7,14 @@ export type ZoomBlurProps = {
|
|
|
7
7
|
/** - The strength of the blur. Values in the range 0 to 1 are usually sufficient, where 0 doesn't change the image and 1 creates a highly blurred image. */
|
|
8
8
|
strength?: number;
|
|
9
9
|
};
|
|
10
|
+
export type ZoomBlurUniforms = ZoomBlurProps;
|
|
10
11
|
/**
|
|
11
12
|
* Zoom Blur
|
|
12
13
|
* Blurs the image away from a certain point, which looks like radial motion blur.
|
|
13
14
|
*/
|
|
14
15
|
export declare const zoomBlur: {
|
|
16
|
+
readonly props: ZoomBlurProps;
|
|
17
|
+
readonly uniforms: ZoomBlurUniforms;
|
|
15
18
|
readonly name: "zoomBlur";
|
|
16
19
|
readonly uniformTypes: {
|
|
17
20
|
readonly center: "vec2<f32>";
|
|
@@ -30,7 +33,7 @@ export declare const zoomBlur: {
|
|
|
30
33
|
readonly fs: "\nuniform zoomBlurUniforms {\n vec2 center;\n float strength;\n} zoomBlur;\n\nvec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec4 color = vec4(0.0);\n float total = 0.0;\n vec2 toCenter = zoomBlur.center * texSize - texCoord * texSize;\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 = 0.0; t <= 40.0; t++) {\n float percent = (t + offset) / 40.0;\n float weight = 4.0 * (percent - percent * percent);\n vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);\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";
|
|
31
34
|
readonly dependencies: [{
|
|
32
35
|
readonly name: "random";
|
|
33
|
-
readonly fs:
|
|
36
|
+
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";
|
|
34
37
|
}];
|
|
35
38
|
readonly passes: [{
|
|
36
39
|
readonly sampler: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zoomblur.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-blur-filters/zoomblur.ts"],"names":[],"mappings":"AA0CA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,4JAA4J;IAC5J,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"zoomblur.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-blur-filters/zoomblur.ts"],"names":[],"mappings":"AA0CA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,4JAA4J;IAC5J,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,QAAQ;oBACN,aAAa;uBACV,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;CAc2B,CAAC"}
|
|
@@ -41,6 +41,8 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
41
41
|
* Blurs the image away from a certain point, which looks like radial motion blur.
|
|
42
42
|
*/
|
|
43
43
|
export const zoomBlur = {
|
|
44
|
+
props: {},
|
|
45
|
+
uniforms: {},
|
|
44
46
|
name: 'zoomBlur',
|
|
45
47
|
uniformTypes: {
|
|
46
48
|
center: 'vec2<f32>',
|
|
@@ -12,6 +12,7 @@ export type ColorHalftoneProps = {
|
|
|
12
12
|
/** The diameter of a dot in pixels. */
|
|
13
13
|
size?: number;
|
|
14
14
|
};
|
|
15
|
+
export type ColorHalftoneUniforms = ColorHalftoneProps;
|
|
15
16
|
/**
|
|
16
17
|
* Color Halftone -
|
|
17
18
|
* Simulates a CMYK halftone rendering of the image by multiplying pixel values
|
|
@@ -19,6 +20,8 @@ export type ColorHalftoneProps = {
|
|
|
19
20
|
* and black.
|
|
20
21
|
*/
|
|
21
22
|
export declare const colorHalftone: {
|
|
23
|
+
readonly props: ColorHalftoneProps;
|
|
24
|
+
readonly uniforms: ColorHalftoneUniforms;
|
|
22
25
|
readonly name: "colorHalftone";
|
|
23
26
|
readonly uniformTypes: {
|
|
24
27
|
readonly center: "vec2<f32>";
|
|
@@ -41,7 +44,7 @@ export declare const colorHalftone: {
|
|
|
41
44
|
readonly softMax: 20;
|
|
42
45
|
};
|
|
43
46
|
};
|
|
44
|
-
readonly fs:
|
|
47
|
+
readonly fs: "uniform colorHalftoneUniforms {\n vec2 center;\n float angle;\n float size;\n} colorHalftone;\n\nfloat pattern(float angle, float scale, vec2 texSize, vec2 texCoord) {\n float s = sin(angle), c = cos(angle);\n vec2 tex = texCoord * texSize - colorHalftone.center * texSize;\n vec2 point = vec2(\n\tc * tex.x - s * tex.y,\n\ts * tex.x + c * tex.y\n ) * scale;\n return (sin(point.x) * sin(point.y)) * 4.0;\n}\n\nvec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {\n float scale = 3.1514 / colorHalftone.size;\n vec3 cmy = 1.0 - color.rgb;\n float k = min(cmy.x, min(cmy.y, cmy.z));\n\n cmy = (cmy - k) / (1.0 - k);\n cmy = clamp(\n\t cmy * 10.0 - 3.0 + vec3(\n pattern(colorHalftone.angle + 0.26179, scale, texSize, texCoord),\n\t pattern(colorHalftone.angle + 1.30899, scale, texSize, texCoord),\n pattern(colorHalftone.angle, scale, texSize, texCoord)\n ),\n\t 0.0,\n\t 1.0\n );\n k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);\n return vec4(1.0 - cmy - k, color.a);\n}\n";
|
|
45
48
|
readonly passes: [{
|
|
46
49
|
readonly filter: true;
|
|
47
50
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorhalftone.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/colorhalftone.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"colorhalftone.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/colorhalftone.ts"],"names":[],"mappings":"AA4CA;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,aAAa;oBACX,kBAAkB;uBACf,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;CAegC,CAAC"}
|
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { glsl } from "../../../lib/glsl-utils/highlight.js";
|
|
5
4
|
// TODO pass texCoord to angle
|
|
6
|
-
const fs = `\
|
|
5
|
+
const fs = /* glsl */ `\
|
|
7
6
|
uniform colorHalftoneUniforms {
|
|
8
|
-
vec2 center;
|
|
9
|
-
float angle;
|
|
10
|
-
float size;
|
|
7
|
+
vec2 center;
|
|
8
|
+
float angle;
|
|
9
|
+
float size;
|
|
11
10
|
} colorHalftone;
|
|
11
|
+
|
|
12
12
|
float pattern(float angle, float scale, vec2 texSize, vec2 texCoord) {
|
|
13
|
-
float s = sin(angle), c = cos(angle);
|
|
14
|
-
vec2 tex = texCoord * texSize - colorHalftone.center * texSize;
|
|
15
|
-
vec2 point = vec2(
|
|
16
|
-
c * tex.x - s * tex.y,
|
|
17
|
-
s * tex.x + c * tex.y
|
|
18
|
-
) * scale;
|
|
19
|
-
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
13
|
+
float s = sin(angle), c = cos(angle);
|
|
14
|
+
vec2 tex = texCoord * texSize - colorHalftone.center * texSize;
|
|
15
|
+
vec2 point = vec2(
|
|
16
|
+
c * tex.x - s * tex.y,
|
|
17
|
+
s * tex.x + c * tex.y
|
|
18
|
+
) * scale;
|
|
19
|
+
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
20
20
|
}
|
|
21
|
+
|
|
21
22
|
vec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
22
|
-
float scale = 3.1514 / colorHalftone.size;
|
|
23
|
-
vec3 cmy = 1.0 - color.rgb;
|
|
24
|
-
float k = min(cmy.x, min(cmy.y, cmy.z));
|
|
25
|
-
|
|
26
|
-
cmy =
|
|
27
|
-
cmy
|
|
28
|
-
|
|
29
|
-
pattern(colorHalftone.angle +
|
|
30
|
-
pattern(colorHalftone.angle, scale, texSize, texCoord)
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
float scale = 3.1514 / colorHalftone.size;
|
|
24
|
+
vec3 cmy = 1.0 - color.rgb;
|
|
25
|
+
float k = min(cmy.x, min(cmy.y, cmy.z));
|
|
26
|
+
|
|
27
|
+
cmy = (cmy - k) / (1.0 - k);
|
|
28
|
+
cmy = clamp(
|
|
29
|
+
cmy * 10.0 - 3.0 + vec3(
|
|
30
|
+
pattern(colorHalftone.angle + 0.26179, scale, texSize, texCoord),
|
|
31
|
+
pattern(colorHalftone.angle + 1.30899, scale, texSize, texCoord),
|
|
32
|
+
pattern(colorHalftone.angle, scale, texSize, texCoord)
|
|
33
|
+
),
|
|
34
|
+
0.0,
|
|
35
|
+
1.0
|
|
36
|
+
);
|
|
37
|
+
k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
|
|
38
|
+
return vec4(1.0 - cmy - k, color.a);
|
|
37
39
|
}
|
|
38
40
|
`;
|
|
39
41
|
/**
|
|
@@ -43,6 +45,8 @@ return vec4(1.0 - cmy - k, color.a);
|
|
|
43
45
|
* and black.
|
|
44
46
|
*/
|
|
45
47
|
export const colorHalftone = {
|
|
48
|
+
props: {},
|
|
49
|
+
uniforms: {},
|
|
46
50
|
name: 'colorHalftone',
|
|
47
51
|
uniformTypes: {
|
|
48
52
|
center: 'vec2<f32>',
|
|
@@ -11,12 +11,15 @@ export type DotScreenProps = {
|
|
|
11
11
|
/** The diameter of a dot in pixels. */
|
|
12
12
|
size?: number;
|
|
13
13
|
};
|
|
14
|
+
export type DotScreenUniforms = DotScreenProps;
|
|
14
15
|
/**
|
|
15
16
|
* Dot Screen -
|
|
16
17
|
* Simulates a black and white halftone rendering of the image by multiplying
|
|
17
18
|
* pixel values with a rotated 2D sine wave pattern.
|
|
18
19
|
*/
|
|
19
20
|
export declare const dotScreen: {
|
|
21
|
+
readonly props: DotScreenProps;
|
|
22
|
+
readonly uniforms: DotScreenUniforms;
|
|
20
23
|
readonly name: "dotScreen";
|
|
21
24
|
readonly uniformTypes: {
|
|
22
25
|
readonly center: "vec2<f32>";
|
|
@@ -39,7 +42,7 @@ export declare const dotScreen: {
|
|
|
39
42
|
readonly softMax: 20;
|
|
40
43
|
};
|
|
41
44
|
};
|
|
42
|
-
readonly fs:
|
|
45
|
+
readonly fs: "uniform dotScreenUniforms {\n vec2 center;\n float angle;\n float size;\n} dotScreen;\n\nfloat pattern(vec2 texSize, vec2 texCoord) {\n float scale = 3.1415 / dotScreen.size;\n\n float s = sin(dotScreen.angle), c = cos(dotScreen.angle);\n vec2 tex = texCoord * texSize - dotScreen.center * texSize;\n vec2 point = vec2(\n c * tex.x - s * tex.y,\n s * tex.x + c * tex.y\n ) * scale;\n return (sin(point.x) * sin(point.y)) * 4.0;\n}\n\nvec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {\n float average = (color.r + color.g + color.b) / 3.0;\n return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);\n}\n";
|
|
43
46
|
readonly passes: [{
|
|
44
47
|
readonly filter: true;
|
|
45
48
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dotscreen.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/dotscreen.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dotscreen.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/dotscreen.ts"],"names":[],"mappings":"AA+BA;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,SAAS;oBACP,cAAc;uBACX,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;CAe4B,CAAC"}
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
const fs = `\
|
|
4
|
+
const fs = /* glsl */ `\
|
|
6
5
|
uniform dotScreenUniforms {
|
|
7
|
-
vec2 center;
|
|
8
|
-
float angle;
|
|
9
|
-
float size;
|
|
6
|
+
vec2 center;
|
|
7
|
+
float angle;
|
|
8
|
+
float size;
|
|
10
9
|
} dotScreen;
|
|
10
|
+
|
|
11
11
|
float pattern(vec2 texSize, vec2 texCoord) {
|
|
12
|
-
float scale = 3.1415 / dotScreen.size;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
vec2
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
float scale = 3.1415 / dotScreen.size;
|
|
13
|
+
|
|
14
|
+
float s = sin(dotScreen.angle), c = cos(dotScreen.angle);
|
|
15
|
+
vec2 tex = texCoord * texSize - dotScreen.center * texSize;
|
|
16
|
+
vec2 point = vec2(
|
|
17
|
+
c * tex.x - s * tex.y,
|
|
18
|
+
s * tex.x + c * tex.y
|
|
19
|
+
) * scale;
|
|
20
|
+
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
20
21
|
}
|
|
22
|
+
|
|
21
23
|
vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
22
|
-
float average = (color.r + color.g + color.b) / 3.0;
|
|
23
|
-
return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
|
|
24
|
+
float average = (color.r + color.g + color.b) / 3.0;
|
|
25
|
+
return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
|
|
24
26
|
}
|
|
25
27
|
`;
|
|
26
28
|
/**
|
|
@@ -29,6 +31,8 @@ return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
|
|
|
29
31
|
* pixel values with a rotated 2D sine wave pattern.
|
|
30
32
|
*/
|
|
31
33
|
export const dotScreen = {
|
|
34
|
+
props: {},
|
|
35
|
+
uniforms: {},
|
|
32
36
|
name: 'dotScreen',
|
|
33
37
|
uniformTypes: {
|
|
34
38
|
center: 'vec2<f32>',
|
|
@@ -9,13 +9,21 @@ export type EdgeWorkProps = {
|
|
|
9
9
|
/** @deprecated internal */
|
|
10
10
|
delta?: number;
|
|
11
11
|
};
|
|
12
|
+
export type EdgeWorkUniforms = EdgeWorkProps;
|
|
12
13
|
/**
|
|
13
14
|
* Edge Work -
|
|
14
15
|
* Picks out different frequencies in the image by subtracting two
|
|
15
16
|
* copies of the image blurred with different radii.
|
|
16
17
|
*/
|
|
17
18
|
export declare const edgeWork: {
|
|
19
|
+
readonly props: EdgeWorkProps;
|
|
20
|
+
readonly uniforms: EdgeWorkProps;
|
|
18
21
|
readonly name: "edgeWork";
|
|
22
|
+
readonly dependencies: [{
|
|
23
|
+
readonly name: "random";
|
|
24
|
+
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";
|
|
25
|
+
}];
|
|
26
|
+
readonly fs: "uniform edgeWorkUniforms {\n float radius;\n vec2 delta;\n} edgeWork;\n\nvec4 edgeWork_sampleColor1(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 relativeDelta = edgeWork.radius * edgeWork.delta / texSize;\n\n vec2 color = vec2(0.0);\n vec2 total = vec2(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 vec3 sampleColor = texture(source, texCoord + relativeDelta * percent).rgb;\n float average = (sampleColor.r + sampleColor.g + sampleColor.b) / 3.0;\n color.x += average * weight;\n total.x += weight;\n if (abs(t) < 15.0) {\n weight = weight * 2.0 - 1.0;\n color.y += average * weight;\n total.y += weight;\n }\n }\n return vec4(color / total, 0.0, 1.0);\n}\n\nvec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 relativeDelta = edgeWork.radius * edgeWork.delta / texSize;\n\n vec2 color = vec2(0.0);\n vec2 total = vec2(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 vec2 sampleColor = texture(source, texCoord + relativeDelta * percent).xy;\n color.x += sampleColor.x * weight;\n total.x += weight;\n if (abs(t) < 15.0) {\n weight = weight * 2.0 - 1.0;\n color.y += sampleColor.y * weight;\n total.y += weight;\n }\n }\n float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);\n return vec4(c, c, c, 1.0);\n}\n";
|
|
19
27
|
readonly uniformPropTypes: {
|
|
20
28
|
readonly radius: {
|
|
21
29
|
readonly value: 2;
|
|
@@ -27,11 +35,6 @@ export declare const edgeWork: {
|
|
|
27
35
|
readonly private: true;
|
|
28
36
|
};
|
|
29
37
|
};
|
|
30
|
-
readonly fs: string;
|
|
31
|
-
readonly dependencies: [{
|
|
32
|
-
readonly name: "random";
|
|
33
|
-
readonly fs: string;
|
|
34
|
-
}];
|
|
35
38
|
readonly passes: [{
|
|
36
39
|
readonly sampler: "edgeWork_sampleColor1";
|
|
37
40
|
readonly uniformPropTypes: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edgework.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/edgework.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edgework.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/edgework.ts"],"names":[],"mappings":"AAgEA;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAE7C;;;;GAIG;AACH,eAAO,MAAM,QAAQ;oBACN,aAAa;uBACV,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuB8B,CAAC"}
|
|
@@ -1,52 +1,61 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { glsl } from "../../../lib/glsl-utils/highlight.js";
|
|
5
4
|
import { random } from "../../math/random/random.js";
|
|
6
|
-
const fs = `\
|
|
5
|
+
const fs = /* glsl */ `\
|
|
7
6
|
uniform edgeWorkUniforms {
|
|
8
|
-
float radius;
|
|
9
|
-
vec2 delta;
|
|
7
|
+
float radius;
|
|
8
|
+
vec2 delta;
|
|
10
9
|
} edgeWork;
|
|
10
|
+
|
|
11
11
|
vec4 edgeWork_sampleColor1(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
12
|
-
vec2 relativeDelta = edgeWork.radius * edgeWork.delta / texSize;
|
|
13
|
-
|
|
14
|
-
vec2
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
float
|
|
19
|
-
|
|
20
|
-
float
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
color.
|
|
26
|
-
total.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
vec2 relativeDelta = edgeWork.radius * edgeWork.delta / texSize;
|
|
13
|
+
|
|
14
|
+
vec2 color = vec2(0.0);
|
|
15
|
+
vec2 total = vec2(0.0);
|
|
16
|
+
|
|
17
|
+
/* randomize the lookup values to hide the fixed number of samples */
|
|
18
|
+
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
19
|
+
|
|
20
|
+
for (float t = -30.0; t <= 30.0; t++) {
|
|
21
|
+
float percent = (t + offset - 0.5) / 30.0;
|
|
22
|
+
float weight = 1.0 - abs(percent);
|
|
23
|
+
vec3 sampleColor = texture(source, texCoord + relativeDelta * percent).rgb;
|
|
24
|
+
float average = (sampleColor.r + sampleColor.g + sampleColor.b) / 3.0;
|
|
25
|
+
color.x += average * weight;
|
|
26
|
+
total.x += weight;
|
|
27
|
+
if (abs(t) < 15.0) {
|
|
28
|
+
weight = weight * 2.0 - 1.0;
|
|
29
|
+
color.y += average * weight;
|
|
30
|
+
total.y += weight;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return vec4(color / total, 0.0, 1.0);
|
|
30
34
|
}
|
|
35
|
+
|
|
31
36
|
vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
32
|
-
vec2 relativeDelta = edgeWork.radius * edgeWork.delta / texSize;
|
|
33
|
-
|
|
34
|
-
vec2
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
float
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
color.
|
|
45
|
-
total.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
vec2 relativeDelta = edgeWork.radius * edgeWork.delta / texSize;
|
|
38
|
+
|
|
39
|
+
vec2 color = vec2(0.0);
|
|
40
|
+
vec2 total = vec2(0.0);
|
|
41
|
+
|
|
42
|
+
/* randomize the lookup values to hide the fixed number of samples */
|
|
43
|
+
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
44
|
+
|
|
45
|
+
for (float t = -30.0; t <= 30.0; t++) {
|
|
46
|
+
float percent = (t + offset - 0.5) / 30.0;
|
|
47
|
+
float weight = 1.0 - abs(percent);
|
|
48
|
+
vec2 sampleColor = texture(source, texCoord + relativeDelta * percent).xy;
|
|
49
|
+
color.x += sampleColor.x * weight;
|
|
50
|
+
total.x += weight;
|
|
51
|
+
if (abs(t) < 15.0) {
|
|
52
|
+
weight = weight * 2.0 - 1.0;
|
|
53
|
+
color.y += sampleColor.y * weight;
|
|
54
|
+
total.y += weight;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
|
|
58
|
+
return vec4(c, c, c, 1.0);
|
|
50
59
|
}
|
|
51
60
|
`;
|
|
52
61
|
/**
|
|
@@ -55,13 +64,15 @@ return vec4(c, c, c, 1.0);
|
|
|
55
64
|
* copies of the image blurred with different radii.
|
|
56
65
|
*/
|
|
57
66
|
export const edgeWork = {
|
|
67
|
+
props: {},
|
|
68
|
+
uniforms: {},
|
|
58
69
|
name: 'edgeWork',
|
|
70
|
+
dependencies: [random],
|
|
71
|
+
fs,
|
|
59
72
|
uniformPropTypes: {
|
|
60
73
|
radius: { value: 2, min: 1, softMax: 50 },
|
|
61
74
|
delta: { value: [1, 0], private: true }
|
|
62
75
|
},
|
|
63
|
-
fs,
|
|
64
|
-
dependencies: [random],
|
|
65
76
|
passes: [
|
|
66
77
|
{
|
|
67
78
|
// @ts-expect-error
|
|
@@ -9,12 +9,15 @@ export type HexagonalPixelateProps = {
|
|
|
9
9
|
/** The width of an individual tile, in pixels. */
|
|
10
10
|
scale?: number;
|
|
11
11
|
};
|
|
12
|
+
export type HexagonalPixelateUniforms = HexagonalPixelateProps;
|
|
12
13
|
/**
|
|
13
14
|
* Hexagonal Pixelate
|
|
14
15
|
* Renders the image using a pattern of hexagonal tiles. Tile colors
|
|
15
16
|
* are nearest-neighbor sampled from the centers of the tiles.
|
|
16
17
|
*/
|
|
17
18
|
export declare const hexagonalPixelate: {
|
|
19
|
+
readonly props: HexagonalPixelateProps;
|
|
20
|
+
readonly uniforms: HexagonalPixelateUniforms;
|
|
18
21
|
readonly name: "hexagonalPixelate";
|
|
19
22
|
readonly uniformTypes: {
|
|
20
23
|
readonly center: "vec2<f32>";
|
|
@@ -32,7 +35,7 @@ export declare const hexagonalPixelate: {
|
|
|
32
35
|
readonly softMax: 50;
|
|
33
36
|
};
|
|
34
37
|
};
|
|
35
|
-
readonly fs:
|
|
38
|
+
readonly fs: "uniform hexagonalPixelateUniforms {\n vec2 center;\n float scale;\n} hexagonalPixelate;\n\nvec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 tex = (texCoord * texSize - hexagonalPixelate.center * texSize) / hexagonalPixelate.scale;\n tex.y /= 0.866025404;\n tex.x -= tex.y * 0.5;\n\n vec2 a;\n if (tex.x + tex.y - floor(tex.x) - floor(tex.y) < 1.0) {\n a = vec2(floor(tex.x), floor(tex.y));\n }\n else a = vec2(ceil(tex.x), ceil(tex.y));\n vec2 b = vec2(ceil(tex.x), floor(tex.y));\n vec2 c = vec2(floor(tex.x), ceil(tex.y));\n\n vec3 TEX = vec3(tex.x, tex.y, 1.0 - tex.x - tex.y);\n vec3 A = vec3(a.x, a.y, 1.0 - a.x - a.y);\n vec3 B = vec3(b.x, b.y, 1.0 - b.x - b.y);\n vec3 C = vec3(c.x, c.y, 1.0 - c.x - c.y);\n\n float alen = length(TEX - A);\n float blen = length(TEX - B);\n float clen = length(TEX - C);\n\n vec2 choice;\n if (alen < blen) {\n if (alen < clen) choice = a;\n else choice = c;\n } else {\n if (blen < clen) choice = b;\n else choice = c;\n }\n\n choice.x += choice.y * 0.5;\n choice.y *= 0.866025404;\n choice *= hexagonalPixelate.scale / texSize;\n\n return texture(source, choice + hexagonalPixelate.center);\n}\n";
|
|
36
39
|
readonly passes: [{
|
|
37
40
|
readonly sampler: true;
|
|
38
41
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hexagonalpixelate.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hexagonalpixelate.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts"],"names":[],"mappings":"AAmDA;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;oBACf,sBAAsB;uBACnB,yBAAyB;;;;;;;;;;;;;;;;;;;;;;CAaoC,CAAC"}
|
|
@@ -1,42 +1,48 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
const fs = `\
|
|
4
|
+
const fs = /* glsl */ `\
|
|
6
5
|
uniform hexagonalPixelateUniforms {
|
|
7
|
-
vec2 center;
|
|
8
|
-
float scale;
|
|
6
|
+
vec2 center;
|
|
7
|
+
float scale;
|
|
9
8
|
} hexagonalPixelate;
|
|
9
|
+
|
|
10
10
|
vec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
11
|
-
vec2 tex = (texCoord * texSize - hexagonalPixelate.center * texSize) / hexagonalPixelate.scale;
|
|
12
|
-
tex.y /= 0.866025404;
|
|
13
|
-
tex.x -= tex.y * 0.5;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
vec2
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
vec3
|
|
24
|
-
vec3
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
choice
|
|
38
|
-
choice
|
|
39
|
-
|
|
11
|
+
vec2 tex = (texCoord * texSize - hexagonalPixelate.center * texSize) / hexagonalPixelate.scale;
|
|
12
|
+
tex.y /= 0.866025404;
|
|
13
|
+
tex.x -= tex.y * 0.5;
|
|
14
|
+
|
|
15
|
+
vec2 a;
|
|
16
|
+
if (tex.x + tex.y - floor(tex.x) - floor(tex.y) < 1.0) {
|
|
17
|
+
a = vec2(floor(tex.x), floor(tex.y));
|
|
18
|
+
}
|
|
19
|
+
else a = vec2(ceil(tex.x), ceil(tex.y));
|
|
20
|
+
vec2 b = vec2(ceil(tex.x), floor(tex.y));
|
|
21
|
+
vec2 c = vec2(floor(tex.x), ceil(tex.y));
|
|
22
|
+
|
|
23
|
+
vec3 TEX = vec3(tex.x, tex.y, 1.0 - tex.x - tex.y);
|
|
24
|
+
vec3 A = vec3(a.x, a.y, 1.0 - a.x - a.y);
|
|
25
|
+
vec3 B = vec3(b.x, b.y, 1.0 - b.x - b.y);
|
|
26
|
+
vec3 C = vec3(c.x, c.y, 1.0 - c.x - c.y);
|
|
27
|
+
|
|
28
|
+
float alen = length(TEX - A);
|
|
29
|
+
float blen = length(TEX - B);
|
|
30
|
+
float clen = length(TEX - C);
|
|
31
|
+
|
|
32
|
+
vec2 choice;
|
|
33
|
+
if (alen < blen) {
|
|
34
|
+
if (alen < clen) choice = a;
|
|
35
|
+
else choice = c;
|
|
36
|
+
} else {
|
|
37
|
+
if (blen < clen) choice = b;
|
|
38
|
+
else choice = c;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
choice.x += choice.y * 0.5;
|
|
42
|
+
choice.y *= 0.866025404;
|
|
43
|
+
choice *= hexagonalPixelate.scale / texSize;
|
|
44
|
+
|
|
45
|
+
return texture(source, choice + hexagonalPixelate.center);
|
|
40
46
|
}
|
|
41
47
|
`;
|
|
42
48
|
/**
|
|
@@ -45,6 +51,8 @@ return texture(source, choice + hexagonalPixelate.center);
|
|
|
45
51
|
* are nearest-neighbor sampled from the centers of the tiles.
|
|
46
52
|
*/
|
|
47
53
|
export const hexagonalPixelate = {
|
|
54
|
+
props: {},
|
|
55
|
+
uniforms: {},
|
|
48
56
|
name: 'hexagonalPixelate',
|
|
49
57
|
uniformTypes: {
|
|
50
58
|
center: 'vec2<f32>',
|
|
@@ -11,6 +11,7 @@ export type InkProps = {
|
|
|
11
11
|
*/
|
|
12
12
|
strength?: number;
|
|
13
13
|
};
|
|
14
|
+
export type InkUniforms = InkProps;
|
|
14
15
|
/**
|
|
15
16
|
* Ink -
|
|
16
17
|
* Simulates outlining the image in ink by darkening edges stronger than a
|
|
@@ -18,7 +19,10 @@ export type InkProps = {
|
|
|
18
19
|
* copies of the image, each blurred using a blur of a different radius.
|
|
19
20
|
*/
|
|
20
21
|
export declare const ink: {
|
|
22
|
+
readonly props: InkProps;
|
|
23
|
+
readonly uniforms: InkUniforms;
|
|
21
24
|
readonly name: "ink";
|
|
25
|
+
readonly fs: "uniform inkUniforms {\n float strength;\n} ink;\n\nvec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 dx = vec2(1.0 / texSize.x, 0.0);\n vec2 dy = vec2(0.0, 1.0 / texSize.y);\n vec4 color = texture(source, texCoord);\n float bigTotal = 0.0;\n float smallTotal = 0.0;\n vec3 bigAverage = vec3(0.0);\n vec3 smallAverage = vec3(0.0);\n for (float x = -2.0; x <= 2.0; x += 1.0) {\n for (float y = -2.0; y <= 2.0; y += 1.0) {\n vec3 offsetColor = texture(source, texCoord + dx * x + dy * y).rgb;\n bigAverage += offsetColor;\n bigTotal += 1.0;\n if (abs(x) + abs(y) < 2.0) {\n smallAverage += offsetColor;\n smallTotal += 1.0;\n }\n }\n }\n vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);\n float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;\n return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);\n}\n";
|
|
22
26
|
readonly uniformTypes: {
|
|
23
27
|
readonly strength: "f32";
|
|
24
28
|
};
|
|
@@ -29,7 +33,6 @@ export declare const ink: {
|
|
|
29
33
|
readonly softMax: 1;
|
|
30
34
|
};
|
|
31
35
|
};
|
|
32
|
-
readonly fs: string;
|
|
33
36
|
readonly passes: [{
|
|
34
37
|
readonly sampler: true;
|
|
35
38
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ink.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/ink.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ink.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/ink.ts"],"names":[],"mappings":"AAoCA;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,GAAG;oBACD,QAAQ;uBACL,WAAW;;;;;;;;;;;;;;;;CAYsB,CAAC"}
|