@thi.ng/webgl-msdf 2.1.114 → 2.1.115

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-01-30T21:37:19Z
3
+ - **Last updated**: 2024-02-06T23:18:11Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ### [2.1.115](https://github.com/thi-ng/umbrella/tree/@thi.ng/webgl-msdf@2.1.115) (2024-02-06)
13
+
14
+ #### ♻️ Refactoring
15
+
16
+ - use shader type consts ([b230780](https://github.com/thi-ng/umbrella/commit/b230780))
17
+
12
18
  ### [2.1.95](https://github.com/thi-ng/umbrella/tree/@thi.ng/webgl-msdf@2.1.95) (2023-11-09)
13
19
 
14
20
  #### ♻️ Refactoring
package/README.md CHANGED
@@ -67,7 +67,7 @@ For Node.js REPL:
67
67
  const webglMsdf = await import("@thi.ng/webgl-msdf");
68
68
  ```
69
69
 
70
- Package sizes (brotli'd, pre-treeshake): ESM: 1.56 KB
70
+ Package sizes (brotli'd, pre-treeshake): ESM: 1.57 KB
71
71
 
72
72
  ## Dependencies
73
73
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/webgl-msdf",
3
- "version": "2.1.114",
3
+ "version": "2.1.115",
4
4
  "description": "Multi-channel SDF font rendering & basic text layout for WebGL",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -36,11 +36,11 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@thi.ng/api": "^8.9.22",
39
- "@thi.ng/shader-ast": "^0.13.6",
40
- "@thi.ng/transducers": "^8.8.26",
41
- "@thi.ng/vector-pools": "^3.1.102",
42
- "@thi.ng/vectors": "^7.10.4",
43
- "@thi.ng/webgl": "^6.6.25"
39
+ "@thi.ng/shader-ast": "^0.13.7",
40
+ "@thi.ng/transducers": "^8.9.0",
41
+ "@thi.ng/vector-pools": "^3.1.103",
42
+ "@thi.ng/vectors": "^7.10.5",
43
+ "@thi.ng/webgl": "^6.6.26"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@microsoft/api-extractor": "^7.39.0",
@@ -93,5 +93,5 @@
93
93
  "parent": "@thi.ng/webgl",
94
94
  "year": 2019
95
95
  },
96
- "gitHead": "a86521dfac00768f7e51a607209325eb72004730\n"
96
+ "gitHead": "ce8202c237a367c4038d41919a8acf75e1122507\n"
97
97
  }
package/shader.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { F, M4, S2D, V2, V3, V4 } from "@thi.ng/shader-ast/api/types";
1
2
  import { assign } from "@thi.ng/shader-ast/ast/assign";
2
3
  import { discard, ifThen } from "@thi.ng/shader-ast/ast/controlflow";
3
4
  import { defMain, defn, ret } from "@thi.ng/shader-ast/ast/function";
@@ -15,23 +16,18 @@ import { clamp, max, min, mix } from "@thi.ng/shader-ast/builtin/math";
15
16
  import { fwidth, texture } from "@thi.ng/shader-ast/builtin/texture";
16
17
  import { ONE4, ZERO4 } from "@thi.ng/vectors/api";
17
18
  import { BLEND_NORMAL } from "@thi.ng/webgl/api/blend";
18
- const median3 = defn("float", "median3", ["vec3"], (v) => [
19
+ const median3 = defn(F, "median3", [V3], (v) => [
19
20
  ret(max(min($x(v), $y(v)), min(max($x(v), $y(v)), $z(v))))
20
21
  ]);
21
- const msdfSample = defn(
22
- "vec2",
23
- "msdfSample",
24
- ["sampler2D", "vec2"],
25
- (tex, uv) => {
26
- let sd;
27
- let w;
28
- return [
29
- sd = sym(sub(median3($xyz(texture(tex, uv))), FLOAT05)),
30
- w = sym(clamp(add(div(sd, fwidth(sd)), FLOAT05), FLOAT0, FLOAT1)),
31
- ret(vec2(sd, w))
32
- ];
33
- }
34
- );
22
+ const msdfSample = defn(V2, "msdfSample", [S2D, V2], (tex, uv) => {
23
+ let sd;
24
+ let w;
25
+ return [
26
+ sd = sym(sub(median3($xyz(texture(tex, uv))), FLOAT05)),
27
+ w = sym(clamp(add(div(sd, fwidth(sd)), FLOAT05), FLOAT0, FLOAT1)),
28
+ ret(vec2(sd, w))
29
+ ];
30
+ });
35
31
  const msdfShader = (opts = {}) => ({
36
32
  vs: (gl, unis, ins, outs) => [
37
33
  defMain(() => [
@@ -60,21 +56,21 @@ const msdfShader = (opts = {}) => ({
60
56
  OES_standard_derivatives: true
61
57
  },
62
58
  attribs: {
63
- position: "vec3",
64
- uv: "vec2",
65
- ...opts.color ? { color: "vec4" } : null
59
+ position: V3,
60
+ uv: V2,
61
+ ...opts.color ? { color: V4 } : null
66
62
  },
67
63
  varying: {
68
- vuv: "vec2",
69
- ...opts.color ? { vcolor: "vec4" } : null
64
+ vuv: V2,
65
+ ...opts.color ? { vcolor: V4 } : null
70
66
  },
71
67
  uniforms: {
72
- modelview: "mat4",
73
- proj: "mat4",
74
- tex: "sampler2D",
75
- thresh: ["float", 1e-3],
76
- bg: ["vec4", ZERO4],
77
- ...!opts.color ? { fg: ["vec4", ONE4] } : null
68
+ modelview: M4,
69
+ proj: M4,
70
+ tex: S2D,
71
+ thresh: [F, 1e-3],
72
+ bg: [V4, ZERO4],
73
+ ...!opts.color ? { fg: [V4, ONE4] } : null
78
74
  },
79
75
  state: {
80
76
  blend: true,