@thi.ng/shader-ast-stdlib 0.13.13 → 0.13.14
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 +8 -1
- package/math/additive.js +3 -2
- package/noise/worley2.d.ts +12 -7
- package/noise/worley2.js +13 -7
- package/package.json +3 -3
- package/raymarch/ao.d.ts +2 -1
- package/raymarch/ao.js +4 -2
- package/raymarch/normal.js +2 -1
- package/raymarch/scene.js +3 -2
- package/sdf/polygon.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-
|
|
3
|
+
- **Last updated**: 2023-05-05T21:29:28Z
|
|
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,13 @@ 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.13.14](https://github.com/thi-ng/umbrella/tree/@thi.ng/shader-ast-stdlib@0.13.14) (2023-05-05)
|
|
13
|
+
|
|
14
|
+
#### 🩹 Bug fixes
|
|
15
|
+
|
|
16
|
+
- fix [#399](https://github.com/thi-ng/umbrella/issues/399) update HOF function naming ([f4b62d7](https://github.com/thi-ng/umbrella/commit/f4b62d7))
|
|
17
|
+
- ensure generated HOFs are using unique names to allow multiple instances
|
|
18
|
+
|
|
12
19
|
## [0.13.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/shader-ast-stdlib@0.13.0) (2023-01-10)
|
|
13
20
|
|
|
14
21
|
#### 🚀 Features
|
package/math/additive.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { assign } from "@thi.ng/shader-ast/ast/assign";
|
|
2
2
|
import { forLoop } from "@thi.ng/shader-ast/ast/controlflow";
|
|
3
3
|
import { defn, ret } from "@thi.ng/shader-ast/ast/function";
|
|
4
|
-
import {
|
|
4
|
+
import { gensym } from "@thi.ng/shader-ast/ast/idgen";
|
|
5
|
+
import { FLOAT0, FLOAT05, float } from "@thi.ng/shader-ast/ast/lit";
|
|
5
6
|
import { add, inc, lt, mul } from "@thi.ng/shader-ast/ast/ops";
|
|
6
7
|
import { sym } from "@thi.ng/shader-ast/ast/sym";
|
|
7
8
|
/**
|
|
@@ -23,7 +24,7 @@ import { sym } from "@thi.ng/shader-ast/ast/sym";
|
|
|
23
24
|
* @param oct -
|
|
24
25
|
* @param name -
|
|
25
26
|
*/
|
|
26
|
-
export const additive = (type, fn, oct = 4, name = "
|
|
27
|
+
export const additive = (type, fn, oct = 4, name = gensym("additive_")) => defn("float", name, [[type], [type], "float"], (pos, shift, decay) => {
|
|
27
28
|
let n;
|
|
28
29
|
let amp;
|
|
29
30
|
return [
|
package/noise/worley2.d.ts
CHANGED
|
@@ -2,17 +2,22 @@ import type { Func2 } from "@thi.ng/shader-ast";
|
|
|
2
2
|
export declare const worleyDist: import("@thi.ng/shader-ast").TaggedFn2<"vec3", "vec3", "vec3">;
|
|
3
3
|
export declare const worleyDistManhattan: import("@thi.ng/shader-ast").TaggedFn2<"vec3", "vec3", "vec3">;
|
|
4
4
|
/**
|
|
5
|
-
* Higher order function. Computes 2D Worley noise using provided
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* Higher order function. Computes 2D Worley noise using provided distance
|
|
6
|
+
* function. The returned function takes 2 args: position and jitter amount, the
|
|
7
|
+
* latter in [0..1] interval. Returns noise components as vec2, with the x
|
|
8
|
+
* component containing the distance from closest simplex center and y the noise
|
|
9
|
+
* value. The vector components can be used individually or combined (e.g.
|
|
10
|
+
* `noise.y - noise.x`)...
|
|
11
11
|
*
|
|
12
|
+
* THe optional `name` arg can be used to customize the name of the generated
|
|
13
|
+
* function.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
12
16
|
* Based on implementation by Stefan Gustavson:
|
|
13
17
|
* http://webstaff.itn.liu.se/~stegu/GLSL-cellular/GLSL-cellular-notes.pdf
|
|
14
18
|
*
|
|
15
19
|
* @param distFn -
|
|
20
|
+
* @param name -
|
|
16
21
|
*/
|
|
17
|
-
export declare const worley2: (distFn: Func2<"vec3", "vec3", "vec3"
|
|
22
|
+
export declare const worley2: (distFn: Func2<"vec3", "vec3", "vec3">, name?: string) => import("@thi.ng/shader-ast").TaggedFn2<"vec2", "float", "vec2">;
|
|
18
23
|
//# sourceMappingURL=worley2.d.ts.map
|
package/noise/worley2.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { assign } from "@thi.ng/shader-ast/ast/assign";
|
|
2
2
|
import { ternary } from "@thi.ng/shader-ast/ast/controlflow";
|
|
3
3
|
import { defn, ret } from "@thi.ng/shader-ast/ast/function";
|
|
4
|
+
import { gensym } from "@thi.ng/shader-ast/ast/idgen";
|
|
4
5
|
import { float, vec3 } from "@thi.ng/shader-ast/ast/lit";
|
|
5
6
|
import { add, lt, mul, sub } from "@thi.ng/shader-ast/ast/ops";
|
|
6
7
|
import { $, $x, $xy, $y, $z } from "@thi.ng/shader-ast/ast/swizzle";
|
|
@@ -10,19 +11,24 @@ import { permute3 } from "./permute.js";
|
|
|
10
11
|
export const worleyDist = defn("vec3", "worleyDist", ["vec3", "vec3"], (a, b) => [ret(add(mul(a, a), mul(b, b)))]);
|
|
11
12
|
export const worleyDistManhattan = defn("vec3", "worleyDistManhatten", ["vec3", "vec3"], (a, b) => [ret(add(abs(a), abs(b)))]);
|
|
12
13
|
/**
|
|
13
|
-
* Higher order function. Computes 2D Worley noise using provided
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* Higher order function. Computes 2D Worley noise using provided distance
|
|
15
|
+
* function. The returned function takes 2 args: position and jitter amount, the
|
|
16
|
+
* latter in [0..1] interval. Returns noise components as vec2, with the x
|
|
17
|
+
* component containing the distance from closest simplex center and y the noise
|
|
18
|
+
* value. The vector components can be used individually or combined (e.g.
|
|
19
|
+
* `noise.y - noise.x`)...
|
|
19
20
|
*
|
|
21
|
+
* THe optional `name` arg can be used to customize the name of the generated
|
|
22
|
+
* function.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
20
25
|
* Based on implementation by Stefan Gustavson:
|
|
21
26
|
* http://webstaff.itn.liu.se/~stegu/GLSL-cellular/GLSL-cellular-notes.pdf
|
|
22
27
|
*
|
|
23
28
|
* @param distFn -
|
|
29
|
+
* @param name -
|
|
24
30
|
*/
|
|
25
|
-
export const worley2 = (distFn) => defn("vec2",
|
|
31
|
+
export const worley2 = (distFn, name = gensym("worley2_")) => defn("vec2", name, ["vec2", "float"], (P, jitter) => {
|
|
26
32
|
const K = float(1 / 7);
|
|
27
33
|
const Ko = float(3 / 7);
|
|
28
34
|
const oI = sym(vec3(-1, 0, 1));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/shader-ast-stdlib",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.14",
|
|
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.0",
|
|
38
|
-
"@thi.ng/shader-ast": "^0.12.
|
|
38
|
+
"@thi.ng/shader-ast": "^0.12.51"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@microsoft/api-extractor": "^7.34.4",
|
|
@@ -330,5 +330,5 @@
|
|
|
330
330
|
],
|
|
331
331
|
"year": 2019
|
|
332
332
|
},
|
|
333
|
-
"gitHead": "
|
|
333
|
+
"gitHead": "81dcbba93e7230c2f400bee87878145d902e975b\n"
|
|
334
334
|
}
|
package/raymarch/ao.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { RaymarchScene } from "../api.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @param scene -
|
|
9
9
|
* @param numSamples -
|
|
10
|
+
* @param name -
|
|
10
11
|
*/
|
|
11
|
-
export declare const raymarchAO: (scene: RaymarchScene, numSamples?: number) => import("@thi.ng/shader-ast").TaggedFn2<"vec3", "vec3", "float">;
|
|
12
|
+
export declare const raymarchAO: (scene: RaymarchScene, numSamples?: number, name?: string) => import("@thi.ng/shader-ast").TaggedFn2<"vec3", "vec3", "float">;
|
|
12
13
|
//# sourceMappingURL=ao.d.ts.map
|
package/raymarch/ao.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { assign } from "@thi.ng/shader-ast/ast/assign";
|
|
2
2
|
import { forLoop } from "@thi.ng/shader-ast/ast/controlflow";
|
|
3
3
|
import { defn, ret } from "@thi.ng/shader-ast/ast/function";
|
|
4
|
-
import {
|
|
4
|
+
import { gensym } from "@thi.ng/shader-ast/ast/idgen";
|
|
5
|
+
import { FLOAT0, FLOAT05, FLOAT1, float } from "@thi.ng/shader-ast/ast/lit";
|
|
5
6
|
import { add, inc, lte, mul, sub } from "@thi.ng/shader-ast/ast/ops";
|
|
6
7
|
import { $x } from "@thi.ng/shader-ast/ast/swizzle";
|
|
7
8
|
import { sym } from "@thi.ng/shader-ast/ast/sym";
|
|
@@ -14,8 +15,9 @@ import { clamp01 } from "../math/clamp.js";
|
|
|
14
15
|
*
|
|
15
16
|
* @param scene -
|
|
16
17
|
* @param numSamples -
|
|
18
|
+
* @param name -
|
|
17
19
|
*/
|
|
18
|
-
export const raymarchAO = (scene, numSamples = 5) => defn("float",
|
|
20
|
+
export const raymarchAO = (scene, numSamples = 5, name = gensym("raymarchAO_")) => defn("float", name, ["vec3", "vec3"], (p, n) => {
|
|
19
21
|
let r;
|
|
20
22
|
let w;
|
|
21
23
|
let d0;
|
package/raymarch/normal.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defn, ret } from "@thi.ng/shader-ast/ast/function";
|
|
2
|
+
import { gensym } from "@thi.ng/shader-ast/ast/idgen";
|
|
2
3
|
import { vec2, vec3 } from "@thi.ng/shader-ast/ast/lit";
|
|
3
4
|
import { add, sub } from "@thi.ng/shader-ast/ast/ops";
|
|
4
5
|
import { $, $x } from "@thi.ng/shader-ast/ast/swizzle";
|
|
@@ -13,7 +14,7 @@ import { normalize } from "@thi.ng/shader-ast/builtin/math";
|
|
|
13
14
|
* @param scene -
|
|
14
15
|
* @param name -
|
|
15
16
|
*/
|
|
16
|
-
export const raymarchNormal = (scene, name = "
|
|
17
|
+
export const raymarchNormal = (scene, name = gensym("raymarchNormal_")) => defn("vec3", name, ["vec3", "float"], (p, smooth) => {
|
|
17
18
|
let dn;
|
|
18
19
|
const comp = (id) => sub($x(scene(add(p, $(dn, id)))), $x(scene(sub(p, $(dn, id)))));
|
|
19
20
|
return [
|
package/raymarch/scene.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { assign } from "@thi.ng/shader-ast/ast/assign";
|
|
2
2
|
import { brk, forLoop, ifThen } from "@thi.ng/shader-ast/ast/controlflow";
|
|
3
3
|
import { defn, ret } from "@thi.ng/shader-ast/ast/function";
|
|
4
|
-
import {
|
|
4
|
+
import { gensym } from "@thi.ng/shader-ast/ast/idgen";
|
|
5
|
+
import { INT0, float, int, vec2 } from "@thi.ng/shader-ast/ast/lit";
|
|
5
6
|
import { gt, inc, lt, madd } from "@thi.ng/shader-ast/ast/ops";
|
|
6
7
|
import { $x, $y } from "@thi.ng/shader-ast/ast/swizzle";
|
|
7
8
|
import { sym } from "@thi.ng/shader-ast/ast/sym";
|
|
@@ -25,7 +26,7 @@ import { rayPointAt } from "./point-at.js";
|
|
|
25
26
|
*/
|
|
26
27
|
export const raymarchScene = (scene, _opts) => {
|
|
27
28
|
const opts = {
|
|
28
|
-
name: "
|
|
29
|
+
name: gensym("raymarchScene_"),
|
|
29
30
|
near: 0.1,
|
|
30
31
|
far: 10,
|
|
31
32
|
steps: 100,
|
package/sdf/polygon.js
CHANGED
|
@@ -2,11 +2,11 @@ import { assign } from "@thi.ng/shader-ast/ast/assign";
|
|
|
2
2
|
import { forLoop, ifThen } from "@thi.ng/shader-ast/ast/controlflow";
|
|
3
3
|
import { defn, ret } from "@thi.ng/shader-ast/ast/function";
|
|
4
4
|
import { index } from "@thi.ng/shader-ast/ast/indexed";
|
|
5
|
-
import {
|
|
5
|
+
import { FLOAT1, INT0, bvec3, int } from "@thi.ng/shader-ast/ast/lit";
|
|
6
6
|
import { div, gt, gte, inc, lt, mul, neg, not, or, sub, } from "@thi.ng/shader-ast/ast/ops";
|
|
7
7
|
import { $x, $y } from "@thi.ng/shader-ast/ast/swizzle";
|
|
8
8
|
import { sym } from "@thi.ng/shader-ast/ast/sym";
|
|
9
|
-
import {
|
|
9
|
+
import { _any, all } from "@thi.ng/shader-ast/builtin/bvec";
|
|
10
10
|
import { dot, min, sqrt } from "@thi.ng/shader-ast/builtin/math";
|
|
11
11
|
import { clamp01 } from "../math/clamp.js";
|
|
12
12
|
/**
|