@luma.gl/shadertools 9.1.0-alpha.1 → 9.1.0-alpha.12
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 +1005 -487
- package/dist/dist.min.js +2489 -1625
- package/dist/index.cjs +2864 -1817
- 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 +46 -18
- 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 +30 -12
- 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 +9 -9
- 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 +10 -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-uniforms-wgsl.d.ts +2 -0
- package/dist/modules/lighting/lights/lighting-uniforms-wgsl.d.ts.map +1 -0
- package/dist/modules/lighting/lights/lighting-uniforms-wgsl.js +56 -0
- package/dist/modules/lighting/lights/lighting.d.ts +5 -4
- package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
- package/dist/modules/lighting/lights/lighting.js +7 -5
- package/dist/modules/lighting/no-material/dirlight.d.ts +8 -8
- package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
- package/dist/modules/lighting/no-material/dirlight.js +34 -20
- 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 +72 -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 +14 -12
- package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
- package/dist/modules/lighting/phong-material/phong-material.js +5 -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/lighting/phong-material/phong-shaders-wgsl.d.ts +41 -0
- package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts.map +1 -0
- package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js +130 -0
- package/dist/modules/math/fp32/fp32.d.ts.map +1 -1
- package/dist/modules/math/fp32/fp32.js +127 -100
- package/dist/modules/math/fp64/fp64-utils.d.ts +3 -3
- package/dist/modules/math/fp64/fp64-utils.d.ts.map +1 -1
- 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 +2 -2
- 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 +5 -5
- 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 +55 -22
- package/src/lib/shader-assembly/platform-defines.ts +5 -6
- package/src/lib/shader-module/shader-module-dependencies.ts +111 -0
- package/src/lib/shader-module/shader-module.ts +134 -19
- 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 +12 -10
- 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-uniforms-wgsl.ts +57 -0
- package/src/modules/lighting/lights/lighting.ts +9 -5
- package/src/modules/lighting/no-material/dirlight.ts +30 -19
- 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 +6 -3
- package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +2 -4
- package/src/modules/lighting/phong-material/phong-shaders-wgsl.ts +132 -0
- package/src/modules/math/fp32/fp32.ts +1 -2
- package/src/modules/math/fp64/fp64-utils.ts +3 -3
- 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 +3 -4
- 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
|
@@ -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"}
|
|
@@ -1,33 +1,33 @@
|
|
|
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 inkUniforms {
|
|
7
|
-
float strength;
|
|
6
|
+
float strength;
|
|
8
7
|
} ink;
|
|
8
|
+
|
|
9
9
|
vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
10
|
-
vec2 dx = vec2(1.0 / texSize.x, 0.0);
|
|
11
|
-
vec2 dy = vec2(0.0, 1.0 / texSize.y);
|
|
12
|
-
vec4 color = texture(source, texCoord);
|
|
13
|
-
float bigTotal = 0.0;
|
|
14
|
-
float smallTotal = 0.0;
|
|
15
|
-
vec3 bigAverage = vec3(0.0);
|
|
16
|
-
vec3 smallAverage = vec3(0.0);
|
|
17
|
-
for (float x = -2.0; x <= 2.0; x += 1.0) {
|
|
18
|
-
for (float y = -2.0; y <= 2.0; y += 1.0) {
|
|
19
|
-
vec3 offsetColor = texture(source, texCoord + dx * x + dy * y).rgb;
|
|
20
|
-
bigAverage += offsetColor;
|
|
21
|
-
bigTotal += 1.0;
|
|
22
|
-
if (abs(x) + abs(y) < 2.0) {
|
|
23
|
-
smallAverage += offsetColor;
|
|
24
|
-
smallTotal += 1.0;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);
|
|
29
|
-
float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
|
|
30
|
-
return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
|
|
10
|
+
vec2 dx = vec2(1.0 / texSize.x, 0.0);
|
|
11
|
+
vec2 dy = vec2(0.0, 1.0 / texSize.y);
|
|
12
|
+
vec4 color = texture(source, texCoord);
|
|
13
|
+
float bigTotal = 0.0;
|
|
14
|
+
float smallTotal = 0.0;
|
|
15
|
+
vec3 bigAverage = vec3(0.0);
|
|
16
|
+
vec3 smallAverage = vec3(0.0);
|
|
17
|
+
for (float x = -2.0; x <= 2.0; x += 1.0) {
|
|
18
|
+
for (float y = -2.0; y <= 2.0; y += 1.0) {
|
|
19
|
+
vec3 offsetColor = texture(source, texCoord + dx * x + dy * y).rgb;
|
|
20
|
+
bigAverage += offsetColor;
|
|
21
|
+
bigTotal += 1.0;
|
|
22
|
+
if (abs(x) + abs(y) < 2.0) {
|
|
23
|
+
smallAverage += offsetColor;
|
|
24
|
+
smallTotal += 1.0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);
|
|
29
|
+
float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
|
|
30
|
+
return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
|
|
31
31
|
}
|
|
32
32
|
`;
|
|
33
33
|
/**
|
|
@@ -37,13 +37,15 @@ return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
|
|
|
37
37
|
* copies of the image, each blurred using a blur of a different radius.
|
|
38
38
|
*/
|
|
39
39
|
export const ink = {
|
|
40
|
+
props: {},
|
|
41
|
+
uniforms: {},
|
|
40
42
|
name: 'ink',
|
|
43
|
+
fs,
|
|
41
44
|
uniformTypes: {
|
|
42
45
|
strength: 'f32'
|
|
43
46
|
},
|
|
44
47
|
uniformPropTypes: {
|
|
45
48
|
strength: { value: 0.25, min: 0, softMax: 1 }
|
|
46
49
|
},
|
|
47
|
-
fs,
|
|
48
50
|
passes: [{ sampler: true }]
|
|
49
51
|
};
|
|
@@ -13,6 +13,7 @@ export type MagnifyProps = {
|
|
|
13
13
|
/** border color of the effect circle. Default value is `[255, 255, 255, 255]`. */
|
|
14
14
|
borderColor?: number[];
|
|
15
15
|
};
|
|
16
|
+
export type MagnifyUniforms = MagnifyProps;
|
|
16
17
|
/**
|
|
17
18
|
* Magnify - display a circle with magnify effect applied to surrounding the pixels given position
|
|
18
19
|
*/
|
|
@@ -36,7 +37,7 @@ export declare const magnify: {
|
|
|
36
37
|
readonly value: readonly [255, 255, 255, 255];
|
|
37
38
|
};
|
|
38
39
|
};
|
|
39
|
-
readonly fs:
|
|
40
|
+
readonly fs: "uniform magnifyUniforms {\n vec2 screenXY;\n float radiusPixels;\n float zoom;\n float borderWidthPixels;\n vec4 borderColor;\n} magnify;\n\nvec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 pos = vec2(magnify.screenXY.x, 1.0 - magnify.screenXY.y);\n float dist = distance(texCoord * texSize, pos * texSize);\n if (dist < magnify.radiusPixels) {\n return texture(source, (texCoord - pos) / magnify.zoom + pos);\n }\n\n if (dist <= magnify.radiusPixels + magnify.borderWidthPixels) {\n return magnify.borderColor;\n }\n return texture(source, texCoord);\n}\n";
|
|
40
41
|
readonly passes: [{
|
|
41
42
|
readonly sampler: true;
|
|
42
43
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magnify.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/magnify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"magnify.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/magnify.ts"],"names":[],"mappings":"AA6BA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,wLAAwL;IACxL,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,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,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;CAmBuC,CAAC"}
|
|
@@ -1,25 +1,26 @@
|
|
|
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 magnifyUniforms {
|
|
7
|
-
vec2 screenXY;
|
|
8
|
-
float radiusPixels;
|
|
9
|
-
float zoom;
|
|
10
|
-
float borderWidthPixels;
|
|
11
|
-
vec4 borderColor;
|
|
6
|
+
vec2 screenXY;
|
|
7
|
+
float radiusPixels;
|
|
8
|
+
float zoom;
|
|
9
|
+
float borderWidthPixels;
|
|
10
|
+
vec4 borderColor;
|
|
12
11
|
} magnify;
|
|
12
|
+
|
|
13
13
|
vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
14
|
-
vec2 pos = vec2(magnify.screenXY.x, 1.0 - magnify.screenXY.y);
|
|
15
|
-
float dist = distance(texCoord * texSize, pos * texSize);
|
|
16
|
-
if (dist < magnify.radiusPixels) {
|
|
17
|
-
return texture(source, (texCoord - pos) / magnify.zoom + pos);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
vec2 pos = vec2(magnify.screenXY.x, 1.0 - magnify.screenXY.y);
|
|
15
|
+
float dist = distance(texCoord * texSize, pos * texSize);
|
|
16
|
+
if (dist < magnify.radiusPixels) {
|
|
17
|
+
return texture(source, (texCoord - pos) / magnify.zoom + pos);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (dist <= magnify.radiusPixels + magnify.borderWidthPixels) {
|
|
21
|
+
return magnify.borderColor;
|
|
22
|
+
}
|
|
23
|
+
return texture(source, texCoord);
|
|
23
24
|
}
|
|
24
25
|
`;
|
|
25
26
|
/**
|
|
@@ -7,18 +7,21 @@ export type BulgePinchProps = {
|
|
|
7
7
|
/** strength -1 to 1 (-1 is strong pinch, 0 is no effect, 1 is strong bulge) */
|
|
8
8
|
strength?: number;
|
|
9
9
|
};
|
|
10
|
+
export type BulgePinchUniforms = BulgePinchProps;
|
|
10
11
|
/**
|
|
11
12
|
* Bulge / Pinch -
|
|
12
13
|
* Bulges or pinches the image in a circle.
|
|
13
14
|
*/
|
|
14
15
|
export declare const bulgePinch: {
|
|
16
|
+
readonly props: BulgePinchProps;
|
|
17
|
+
readonly uniforms: BulgePinchUniforms;
|
|
15
18
|
readonly name: "bulgePinch";
|
|
16
19
|
readonly dependencies: [{
|
|
17
20
|
readonly name: "warp";
|
|
18
21
|
readonly passes: [];
|
|
19
|
-
readonly fs:
|
|
22
|
+
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\n return color;\n}\n";
|
|
20
23
|
}];
|
|
21
|
-
readonly fs:
|
|
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";
|
|
22
25
|
readonly uniformTypes: {
|
|
23
26
|
readonly center: "vec2<f32>";
|
|
24
27
|
readonly radius: "f32";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulgepinch.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-warp-filters/bulgepinch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bulgepinch.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-warp-filters/bulgepinch.ts"],"names":[],"mappings":"AAqCA,+CAA+C;AAC/C,MAAM,MAAM,eAAe,GAAG;IAC5B,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,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;oBACR,eAAe;uBACZ,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgB6B,CAAC"}
|
|
@@ -1,32 +1,34 @@
|
|
|
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 { warp } from "./warp.js";
|
|
6
|
-
const fs = `\
|
|
5
|
+
const fs = /* glsl */ `\
|
|
7
6
|
uniform bulgePinchUniforms {
|
|
8
|
-
float radius;
|
|
9
|
-
float strength;
|
|
10
|
-
vec2 center;
|
|
7
|
+
float radius;
|
|
8
|
+
float strength;
|
|
9
|
+
vec2 center;
|
|
11
10
|
} bulgePinch;
|
|
11
|
+
|
|
12
12
|
vec2 bulgePinch_warp(vec2 coord, vec2 texCenter) {
|
|
13
|
-
coord -= texCenter;
|
|
14
|
-
float distance = length(coord);
|
|
15
|
-
if (distance < bulgePinch.radius) {
|
|
16
|
-
float percent = distance / bulgePinch.radius;
|
|
17
|
-
if (bulgePinch.strength > 0.0) {
|
|
18
|
-
coord *= mix(1.0, smoothstep(0.0, bulgePinch.radius / distance, percent), bulgePinch.strength * 0.75);
|
|
19
|
-
} else {
|
|
20
|
-
coord *= mix(1.0, pow(percent, 1.0 + bulgePinch.strength * 0.75) * bulgePinch.radius / distance, 1.0 - percent);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
coord += texCenter;
|
|
24
|
-
return coord;
|
|
13
|
+
coord -= texCenter;
|
|
14
|
+
float distance = length(coord);
|
|
15
|
+
if (distance < bulgePinch.radius) {
|
|
16
|
+
float percent = distance / bulgePinch.radius;
|
|
17
|
+
if (bulgePinch.strength > 0.0) {
|
|
18
|
+
coord *= mix(1.0, smoothstep(0.0, bulgePinch.radius / distance, percent), bulgePinch.strength * 0.75);
|
|
19
|
+
} else {
|
|
20
|
+
coord *= mix(1.0, pow(percent, 1.0 + bulgePinch.strength * 0.75) * bulgePinch.radius / distance, 1.0 - percent);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
coord += texCenter;
|
|
24
|
+
return coord;
|
|
25
25
|
}
|
|
26
|
+
|
|
26
27
|
vec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
27
|
-
vec2 coord = texCoord * texSize;
|
|
28
|
-
coord = bulgePinch_warp(coord, bulgePinch.center * texSize);
|
|
29
|
-
|
|
28
|
+
vec2 coord = texCoord * texSize;
|
|
29
|
+
coord = bulgePinch_warp(coord, bulgePinch.center * texSize);
|
|
30
|
+
|
|
31
|
+
return warp_sampleColor(source, texSize, coord);
|
|
30
32
|
}
|
|
31
33
|
`;
|
|
32
34
|
/**
|
|
@@ -34,6 +36,8 @@ return warp_sampleColor(source, texSize, coord);
|
|
|
34
36
|
* Bulges or pinches the image in a circle.
|
|
35
37
|
*/
|
|
36
38
|
export const bulgePinch = {
|
|
39
|
+
props: {},
|
|
40
|
+
uniforms: {},
|
|
37
41
|
name: 'bulgePinch',
|
|
38
42
|
dependencies: [warp],
|
|
39
43
|
fs,
|
|
@@ -9,17 +9,20 @@ export type SwirlProps = {
|
|
|
9
9
|
/** The angle in radians that the pixels in the center of the circular region will be rotated by. */
|
|
10
10
|
angle?: number;
|
|
11
11
|
};
|
|
12
|
+
export type SwirlUniforms = SwirlProps;
|
|
12
13
|
/**
|
|
13
14
|
* Warps a circular region of the image in a swirl.
|
|
14
15
|
*/
|
|
15
16
|
export declare const swirl: {
|
|
17
|
+
readonly props: SwirlProps;
|
|
18
|
+
readonly uniforms: SwirlProps;
|
|
16
19
|
readonly name: "swirl";
|
|
17
20
|
readonly dependencies: [{
|
|
18
21
|
readonly name: "warp";
|
|
19
22
|
readonly passes: [];
|
|
20
|
-
readonly fs:
|
|
23
|
+
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\n return color;\n}\n";
|
|
21
24
|
}];
|
|
22
|
-
readonly fs:
|
|
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";
|
|
23
26
|
readonly uniformTypes: {
|
|
24
27
|
readonly center: "vec2<f32>";
|
|
25
28
|
readonly radius: "f32";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swirl.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-warp-filters/swirl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"swirl.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-warp-filters/swirl.ts"],"names":[],"mappings":"AAuCA;;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;oBACH,UAAU;uBACP,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkB2B,CAAC"}
|
|
@@ -1,40 +1,44 @@
|
|
|
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 { warp } from "./warp.js";
|
|
6
|
-
const fs = `\
|
|
5
|
+
const fs = /* glsl */ `\
|
|
7
6
|
uniform swirlUniforms {
|
|
8
|
-
float radius;
|
|
9
|
-
float angle;
|
|
10
|
-
vec2 center;
|
|
7
|
+
float radius;
|
|
8
|
+
float angle;
|
|
9
|
+
vec2 center;
|
|
11
10
|
} swirl;
|
|
11
|
+
|
|
12
12
|
vec2 swirl_warp(vec2 coord, vec2 texCenter) {
|
|
13
|
-
coord -= texCenter;
|
|
14
|
-
float distance = length(coord);
|
|
15
|
-
if (distance < swirl.radius) {
|
|
16
|
-
float percent = (swirl.radius - distance) / swirl.radius;
|
|
17
|
-
float theta = percent * percent * swirl.angle;
|
|
18
|
-
float s = sin(theta);
|
|
19
|
-
float c = cos(theta);
|
|
20
|
-
coord = vec2(
|
|
21
|
-
coord.x * c - coord.y * s,
|
|
22
|
-
coord.x * s + coord.y * c
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
coord += texCenter;
|
|
26
|
-
return coord;
|
|
13
|
+
coord -= texCenter;
|
|
14
|
+
float distance = length(coord);
|
|
15
|
+
if (distance < swirl.radius) {
|
|
16
|
+
float percent = (swirl.radius - distance) / swirl.radius;
|
|
17
|
+
float theta = percent * percent * swirl.angle;
|
|
18
|
+
float s = sin(theta);
|
|
19
|
+
float c = cos(theta);
|
|
20
|
+
coord = vec2(
|
|
21
|
+
coord.x * c - coord.y * s,
|
|
22
|
+
coord.x * s + coord.y * c
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
coord += texCenter;
|
|
26
|
+
return coord;
|
|
27
27
|
}
|
|
28
|
+
|
|
28
29
|
vec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
29
|
-
vec2 coord = texCoord * texSize;
|
|
30
|
-
coord = swirl_warp(coord, swirl.center * texSize);
|
|
31
|
-
|
|
30
|
+
vec2 coord = texCoord * texSize;
|
|
31
|
+
coord = swirl_warp(coord, swirl.center * texSize);
|
|
32
|
+
|
|
33
|
+
return warp_sampleColor(source, texSize, coord);
|
|
32
34
|
}
|
|
33
35
|
`;
|
|
34
36
|
/**
|
|
35
37
|
* Warps a circular region of the image in a swirl.
|
|
36
38
|
*/
|
|
37
39
|
export const swirl = {
|
|
40
|
+
props: {},
|
|
41
|
+
uniforms: {},
|
|
38
42
|
name: 'swirl',
|
|
39
43
|
dependencies: [warp],
|
|
40
44
|
fs,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export type WarpProps = {};
|
|
2
|
+
export type WarpUniforms = WarpProps;
|
|
2
3
|
export declare const warp: {
|
|
3
4
|
readonly name: "warp";
|
|
4
5
|
readonly passes: [];
|
|
5
|
-
readonly fs:
|
|
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\n return color;\n}\n";
|
|
6
7
|
};
|
|
7
8
|
//# sourceMappingURL=warp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warp.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-warp-filters/warp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"warp.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-warp-filters/warp.ts"],"names":[],"mappings":"AAmBA,MAAM,MAAM,SAAS,GAAG,EAAE,CAAC;AAE3B,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC;AAErC,eAAO,MAAM,IAAI;;;;CAIoC,CAAC"}
|
|
@@ -1,15 +1,16 @@
|
|
|
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
|
vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
|
|
7
|
-
vec4 color = texture(source, coord / texSize);
|
|
8
|
-
vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
|
|
9
|
-
if (coord != clampedCoord) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
vec4 color = texture(source, coord / texSize);
|
|
7
|
+
vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
|
|
8
|
+
if (coord != clampedCoord) {
|
|
9
|
+
/* fade to transparent if we are outside the image */
|
|
10
|
+
color.a *= max(0.0, 1.0 - length(coord - clampedCoord));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return color;
|
|
13
14
|
}
|
|
14
15
|
`;
|
|
15
16
|
export const warp = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../../src/modules-webgl1/geometry/geometry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../../src/modules-webgl1/geometry/geometry.ts"],"names":[],"mappings":"AAiCA;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC"}
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
// import {ShaderModule} from '../../types';
|
|
2
|
-
import { glsl } from "../../lib/glsl-utils/highlight.js";
|
|
3
2
|
// TODO - reuse normal from geometry module
|
|
4
|
-
const vs = `\
|
|
3
|
+
const vs = /* glsl */ `\
|
|
5
4
|
varying vec4 geometry_vPosition;
|
|
6
5
|
varying vec3 geometry_vNormal;
|
|
6
|
+
|
|
7
7
|
void geometry_setNormal(vec3 normal) {
|
|
8
|
-
geometry_vNormal = normal;
|
|
8
|
+
geometry_vNormal = normal;
|
|
9
9
|
}
|
|
10
|
+
|
|
10
11
|
void geometry_setPosition(vec4 position) {
|
|
11
|
-
geometry_vPosition = position;
|
|
12
|
+
geometry_vPosition = position;
|
|
12
13
|
}
|
|
14
|
+
|
|
13
15
|
void geometry_setPosition(vec3 position) {
|
|
14
|
-
geometry_vPosition = vec4(position, 1.);
|
|
16
|
+
geometry_vPosition = vec4(position, 1.);
|
|
15
17
|
}
|
|
16
18
|
`;
|
|
17
|
-
const fs = `\
|
|
19
|
+
const fs = /* glsl */ `\
|
|
18
20
|
varying vec4 geometry_vPosition;
|
|
19
21
|
varying vec3 geometry_vNormal;
|
|
22
|
+
|
|
20
23
|
vec4 geometry_getPosition() {
|
|
21
|
-
return geometry_vPosition;
|
|
24
|
+
return geometry_vPosition;
|
|
22
25
|
}
|
|
26
|
+
|
|
23
27
|
vec3 geometry_getNormal() {
|
|
24
|
-
return geometry_vNormal;
|
|
28
|
+
return geometry_vNormal;
|
|
25
29
|
}
|
|
26
30
|
`;
|
|
27
31
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ShaderModule } from "../../../lib/shader-module/shader-module.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { NumericArray } from "../../../types.js";
|
|
3
3
|
export type DirlightOptions = {
|
|
4
|
-
lightDirection?:
|
|
4
|
+
lightDirection?: NumericArray;
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
7
|
* Cheap lighting - single directional light, single dot product, one uniform
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dirlight.d.ts","sourceRoot":"","sources":["../../../../src/modules-webgl1/lighting/dirlight/dirlight.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,oDAAiD;
|
|
1
|
+
{"version":3,"file":"dirlight.d.ts","sourceRoot":"","sources":["../../../../src/modules-webgl1/lighting/dirlight/dirlight.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,oDAAiD;AACtE,OAAO,KAAK,EAAC,YAAY,EAAC,0BAAuB;AAKjD,MAAM,MAAM,eAAe,GAAG;IAC5B,cAAc,CAAC,EAAE,YAAY,CAAC;CAC/B,CAAC;AA4BF;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,YAMtB,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
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 { project } from "../../project/project.js";
|
|
6
5
|
const DEFAULT_MODULE_OPTIONS = {
|
|
7
6
|
lightDirection: new Float32Array([1, 1, 2])
|
|
@@ -14,12 +13,16 @@ function getUniforms(opts = DEFAULT_MODULE_OPTIONS) {
|
|
|
14
13
|
}
|
|
15
14
|
return uniforms;
|
|
16
15
|
}
|
|
17
|
-
const fs = `\
|
|
16
|
+
const fs = /* glsl */ `\
|
|
18
17
|
uniform vec3 dirlight_uLightDirection;
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* Returns color attenuated by angle from light source
|
|
21
|
+
*/
|
|
19
22
|
vec4 dirlight_filterColor(vec4 color) {
|
|
20
|
-
vec3 normal = project_getNormal_World();
|
|
21
|
-
float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));
|
|
22
|
-
return vec4(color.rgb * d, color.a);
|
|
23
|
+
vec3 normal = project_getNormal_World();
|
|
24
|
+
float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));
|
|
25
|
+
return vec4(color.rgb * d, color.a);
|
|
23
26
|
}
|
|
24
27
|
`;
|
|
25
28
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const lightingShader
|
|
1
|
+
export declare const lightingShader = "#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\n\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n\n // Constant-Linear-Exponential\n vec3 attenuation;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform AmbientLight lighting_uAmbientLight;\nuniform PointLight lighting_uPointLight[MAX_LIGHTS];\nuniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];\nuniform int lighting_uPointLightCount;\nuniform int lighting_uDirectionalLightCount;\n\nuniform bool lighting_uEnabled;\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n#endif\n";
|
|
2
2
|
//# sourceMappingURL=lights-glsl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lights-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules-webgl1/lighting/lights/lights-glsl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lights-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules-webgl1/lighting/lights/lights-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,w2BAmC1B,CAAC"}
|