@thi.ng/shader-ast-stdlib 0.13.17 → 0.14.0

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**: 2023-06-14T07:58:51Z
3
+ - **Last updated**: 2023-07-14T11:37:51Z
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
+ ## [0.14.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/shader-ast-stdlib@0.14.0) (2023-07-14)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add smootherStep() ([859fa5d](https://github.com/thi-ng/umbrella/commit/859fa5d))
17
+
12
18
  ### [0.13.15](https://github.com/thi-ng/umbrella/tree/@thi.ng/shader-ast-stdlib@0.13.15) (2023-05-11)
13
19
 
14
20
  #### ♻️ Refactoring
package/README.md CHANGED
@@ -101,7 +101,7 @@ For Node.js REPL:
101
101
  const shaderAstStdlib = await import("@thi.ng/shader-ast-stdlib");
102
102
  ```
103
103
 
104
- Package sizes (brotli'd, pre-treeshake): ESM: 11.64 KB
104
+ Package sizes (brotli'd, pre-treeshake): ESM: 11.82 KB
105
105
 
106
106
  ## Dependencies
107
107
 
@@ -386,6 +386,8 @@ for reference.
386
386
  - `orthogonal3`
387
387
  - `polar2` / `polar3`
388
388
  - `sincos` / `cossin`
389
+ - `smootherStep` / `smootherStep2` / `smootherStep3` / `smootherStep4`
390
+ - `smootherStep01` / `smootherStep01_2` / `smootherStep01_3` / `smootherStep01_4`
389
391
 
390
392
  ### Oscillators
391
393
 
package/index.d.ts CHANGED
@@ -26,6 +26,7 @@ export * from "./math/orthogonal.js";
26
26
  export * from "./math/osc.js";
27
27
  export * from "./math/polar.js";
28
28
  export * from "./math/sincos.js";
29
+ export * from "./math/smoother-step.js";
29
30
  export * from "./matrix/lookat.js";
30
31
  export * from "./matrix/mvp.js";
31
32
  export * from "./matrix/normal.js";
package/index.js CHANGED
@@ -26,6 +26,7 @@ export * from "./math/orthogonal.js";
26
26
  export * from "./math/osc.js";
27
27
  export * from "./math/polar.js";
28
28
  export * from "./math/sincos.js";
29
+ export * from "./math/smoother-step.js";
29
30
  export * from "./matrix/lookat.js";
30
31
  export * from "./matrix/mvp.js";
31
32
  export * from "./matrix/normal.js";
@@ -0,0 +1,23 @@
1
+ import type { TaggedFn1 } from "@thi.ng/shader-ast";
2
+ /**
3
+ * Specialized version of {@link smootherStep}, assuming edges are 0/1
4
+ * respectively and `x` is in [0..1]. No clamping performed.
5
+ *
6
+ * @param x
7
+ */
8
+ export declare const smootherStep01: TaggedFn1<"float", "float">;
9
+ export declare const smootherStep01_2: TaggedFn1<"vec2", "vec2">;
10
+ export declare const smootherStep01_3: TaggedFn1<"vec3", "vec3">;
11
+ export declare const smootherStep01_4: TaggedFn1<"vec4", "vec4">;
12
+ /**
13
+ * Similar to GLSL-native `smoothstep()` but using different, higher degree
14
+ * polynomial.
15
+ *
16
+ * @remarks
17
+ * Also see {@link smootherStep01}
18
+ */
19
+ export declare const smootherStep: import("@thi.ng/shader-ast").TaggedFn3<"float", "float", "float", "float">;
20
+ export declare const smootherStep2: import("@thi.ng/shader-ast").TaggedFn3<"vec2", "vec2", "vec2", "vec2">;
21
+ export declare const smootherStep3: import("@thi.ng/shader-ast").TaggedFn3<"vec3", "vec3", "vec3", "vec3">;
22
+ export declare const smootherStep4: import("@thi.ng/shader-ast").TaggedFn3<"vec4", "vec4", "vec4", "vec4">;
23
+ //# sourceMappingURL=smoother-step.d.ts.map
@@ -0,0 +1,30 @@
1
+ import { F, V2, V3, V4 } from "@thi.ng/shader-ast/api/types";
2
+ import { defn, ret } from "@thi.ng/shader-ast/ast/function";
3
+ import { add, div, mul, sub } from "@thi.ng/shader-ast/ast/ops";
4
+ import { clamp01 } from "./clamp.js";
5
+ const $ = (n, type) => defn(type, `smootherStep01${n > 1 ? "_" + n : ""}`, [type], (x) => [
6
+ // @ts-ignore
7
+ ret(mul(x, mul(x, mul(x, add(mul(x, sub(mul(x, 6), 15)), 10))))),
8
+ ]);
9
+ /**
10
+ * Specialized version of {@link smootherStep}, assuming edges are 0/1
11
+ * respectively and `x` is in [0..1]. No clamping performed.
12
+ *
13
+ * @param x
14
+ */
15
+ export const smootherStep01 = $(1, F);
16
+ export const smootherStep01_2 = $(2, V2);
17
+ export const smootherStep01_3 = $(3, V3);
18
+ export const smootherStep01_4 = $(4, V4);
19
+ const $$ = (n, type, fn) => defn(type, `smootherStep${n > 1 ? n : ""}`, [type, type, type], (e0, e1, x) => [ret(fn(clamp01(div(sub(x, e0), sub(e1, e0)))))]);
20
+ /**
21
+ * Similar to GLSL-native `smoothstep()` but using different, higher degree
22
+ * polynomial.
23
+ *
24
+ * @remarks
25
+ * Also see {@link smootherStep01}
26
+ */
27
+ export const smootherStep = $$(1, F, smootherStep01);
28
+ export const smootherStep2 = $$(2, V2, smootherStep01_2);
29
+ export const smootherStep3 = $$(3, V3, smootherStep01_3);
30
+ export const smootherStep4 = $$(4, V4, smootherStep01_4);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/shader-ast-stdlib",
3
- "version": "0.13.17",
3
+ "version": "0.14.0",
4
4
  "description": "Function collection for modular GPGPU / shader programming with @thi.ng/shader-ast",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@thi.ng/api": "^8.8.2",
38
- "@thi.ng/shader-ast": "^0.12.53"
38
+ "@thi.ng/shader-ast": "^0.12.54"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@microsoft/api-extractor": "^7.35.3",
@@ -179,6 +179,9 @@
179
179
  "./math/sincos": {
180
180
  "default": "./math/sincos.js"
181
181
  },
182
+ "./math/smoother-step": {
183
+ "default": "./math/smoother-step.js"
184
+ },
182
185
  "./matrix/convert": {
183
186
  "default": "./matrix/convert.js"
184
187
  },
@@ -330,5 +333,5 @@
330
333
  ],
331
334
  "year": 2019
332
335
  },
333
- "gitHead": "54e825a976c72067a244cff8725ca98f5416d26d\n"
336
+ "gitHead": "88cfe77770f3b07c788301dccefcb9547cd4aff6\n"
334
337
  }