@thi.ng/shader-ast-stdlib 1.0.6 → 1.0.8
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 +1 -1
- package/color/cosine-gradient.d.ts +2 -1
- package/color/levels.d.ts +1 -1
- package/color/porter-duff.d.ts +1 -1
- package/controlflow/branches.d.ts +1 -1
- package/fog/exp.d.ts +2 -2
- package/fog/exp2.d.ts +2 -2
- package/fog/linear.d.ts +1 -2
- package/math/additive.d.ts +5 -6
- package/math/fit.d.ts +11 -11
- package/math/interval.d.ts +4 -2
- package/math/orthogonal.d.ts +2 -2
- package/math/pack-float.d.ts +2 -2
- package/math/smoother-step.d.ts +1 -1
- package/noise/voronoi2.d.ts +4 -4
- package/noise/worley2.d.ts +1 -1
- package/package.json +6 -6
- package/raymarch/ao.d.ts +4 -4
- package/screen/uv.d.ts +4 -3
- package/sdf/arc.d.ts +1 -1
- package/sdf/box-rounded.d.ts +1 -1
- package/sdf/cross.d.ts +3 -2
- package/sdf/hex.d.ts +1 -1
- package/sdf/polygon.d.ts +1 -1
- package/viz/function.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,12 +2,13 @@ import { type FloatTerm, type Vec3Term } from "@thi.ng/shader-ast";
|
|
|
2
2
|
/**
|
|
3
3
|
* Inline function. Computes the unclamped cosine-based color gradient value:
|
|
4
4
|
* `a+b*cos(2π*(c*t+d))`, where `a`..`d` are the gradient coefficients and `t`
|
|
5
|
-
* the gradient position in the [0,1] interval.
|
|
5
|
+
* the gradient position in the `[0,1]` interval.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
8
|
* Based on technique by Inigo Quilez
|
|
9
9
|
*
|
|
10
10
|
* References:
|
|
11
|
+
*
|
|
11
12
|
* - https://iquilezles.org/articles/palettes/
|
|
12
13
|
* - https://github.com/thi-ng/umbrella/tree/develop/packages/color#cosine-gradients
|
|
13
14
|
*
|
package/color/levels.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare const midLevelGamma: import("@thi.ng/shader-ast").TaggedFn1<"floa
|
|
|
17
17
|
export declare const midLevelGammaRGB: (mid: Vec3Term) => import("@thi.ng/shader-ast").Lit<"vec3">;
|
|
18
18
|
/**
|
|
19
19
|
* Applies level remapping from `input` to `output` (each given as
|
|
20
|
-
* `vec2(min,max)`) with `gamma` correction. Results will be clamped to [0
|
|
20
|
+
* `vec2(min,max)`) with `gamma` correction. Results will be clamped to `[0,1]`
|
|
21
21
|
* range.
|
|
22
22
|
*/
|
|
23
23
|
export declare const levelAdjustGamma: import("@thi.ng/shader-ast").TaggedFn4<"float", "float", "vec2", "vec2", "float">;
|
package/color/porter-duff.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { FloatTerm, Vec4Sym } from "@thi.ng/shader-ast";
|
|
|
6
6
|
* optimized AST function which accepts 2 RGBA colors (vec4) and returns blended
|
|
7
7
|
* & clamped result (also a vec4).
|
|
8
8
|
*
|
|
9
|
-
* @
|
|
9
|
+
* @remarks
|
|
10
10
|
* All built-in PD operators are defined via this HOF. The two given coefficient
|
|
11
11
|
* functions are used to extract blending coefficients for src/dest colors and
|
|
12
12
|
* are called with the alpha components of both colors.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FloatTerm, Term, Type } from "@thi.ng/shader-ast";
|
|
2
2
|
/**
|
|
3
3
|
* Utility function to create an n-ary conditional based on given float value
|
|
4
|
-
* `x` in [0,1] range and any number of branch terms (at least 1). Returns a
|
|
4
|
+
* `x` in `[0,1]` range and any number of branch terms (at least 1). Returns a
|
|
5
5
|
* nested ternary expression.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
package/fog/exp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Computes exponential fog factor [0
|
|
3
|
-
*
|
|
2
|
+
* Computes exponential fog factor `[0,1]`, based on given fully saturated fog
|
|
3
|
+
* distance and density.
|
|
4
4
|
*
|
|
5
5
|
* @param dist - float
|
|
6
6
|
* @param density - float
|
package/fog/exp2.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Similar to {@link fogExp}. Computes exponential fog factor [0
|
|
2
|
+
* Similar to {@link fogExp}. Computes exponential fog factor `[0,1]`, based on
|
|
3
3
|
* given fully saturated fog distance and density. Uses
|
|
4
|
-
* [`exp2
|
|
4
|
+
* [`exp2`](https://docs.thi.ng/umbrella/shader-ast/functions/exp2.html)
|
|
5
5
|
* internally.
|
|
6
6
|
*
|
|
7
7
|
* @param dist - float
|
package/fog/linear.d.ts
CHANGED
package/math/additive.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import type { Fn } from "@thi.ng/api";
|
|
2
2
|
import type { FloatTerm, Prim, Term } from "@thi.ng/shader-ast";
|
|
3
3
|
/**
|
|
4
|
-
* Higher order function. Takes an AST type ID, a single-arg scalar
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Higher order function. Takes an AST type ID, a single-arg scalar function
|
|
5
|
+
* `fn`, number of octaves (default: 4) and an optional function name. Returns a
|
|
6
|
+
* new function which computes the summed value of `fn` over the given number
|
|
7
|
+
* octaves and accepts 3 args:
|
|
8
8
|
*
|
|
9
9
|
* - position (float)
|
|
10
10
|
* - octave shift (float)
|
|
11
11
|
* - octave decay (usually 0.5)
|
|
12
12
|
*
|
|
13
|
-
* For each octave `i` [0
|
|
14
|
-
* evaluated as:
|
|
13
|
+
* For each octave `i` `[0,oct)`, the function is (in principle) evaluated as:
|
|
15
14
|
*
|
|
16
15
|
* n += decay / exp2(i) * fn(pos * exp2(i) + i * shift)
|
|
17
16
|
*
|
package/math/fit.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Prim, PrimTerm, Term, TermType } from "@thi.ng/shader-ast";
|
|
2
2
|
/**
|
|
3
|
-
* Returns normalized value of `x` WRT to interval [a,b]
|
|
4
|
-
*
|
|
3
|
+
* Returns normalized value of `x` WRT to interval `[a,b]`. Returns 0, if `a`
|
|
4
|
+
* equals `b`.
|
|
5
5
|
*
|
|
6
6
|
* @param x -
|
|
7
7
|
* @param a -
|
|
@@ -10,7 +10,7 @@ import type { Prim, PrimTerm, Term, TermType } from "@thi.ng/shader-ast";
|
|
|
10
10
|
export declare const fitNorm1: import("@thi.ng/shader-ast").TaggedFn3<"float", "float", "float", "float">;
|
|
11
11
|
/**
|
|
12
12
|
* Similar to {@link fitNorm1} but also for vector types and without checking if
|
|
13
|
-
* `a == b`. Scales value `x` from closed interval [a,b] to closed [0,1]
|
|
13
|
+
* `a == b`. Scales value `x` from closed interval `[a,b]` to closed `[0,1]`
|
|
14
14
|
* interval. No clamping performed.
|
|
15
15
|
*
|
|
16
16
|
* @param x
|
|
@@ -19,7 +19,7 @@ export declare const fitNorm1: import("@thi.ng/shader-ast").TaggedFn3<"float", "
|
|
|
19
19
|
*/
|
|
20
20
|
export declare const fitNorm: <T extends Prim>(x: Term<T>, a: Term<T>, b: Term<T>) => import("@thi.ng/shader-ast").Op2<T>;
|
|
21
21
|
/**
|
|
22
|
-
* Fits value `x` from closed interval [a,b] to closed interval [c,d]
|
|
22
|
+
* Fits value `x` from closed interval `[a,b]` to closed interval `[c,d]`. No
|
|
23
23
|
* clamping performed.
|
|
24
24
|
*
|
|
25
25
|
* @param x -
|
|
@@ -30,7 +30,7 @@ export declare const fitNorm: <T extends Prim>(x: Term<T>, a: Term<T>, b: Term<T
|
|
|
30
30
|
*/
|
|
31
31
|
export declare const fit: <T extends Prim>(x: Term<T>, a: Term<T>, b: Term<T>, c: Term<T>, d: Term<T>) => import("@thi.ng/shader-ast").FnCall<T>;
|
|
32
32
|
/**
|
|
33
|
-
* Same as {@link fit}, but first clamps `x` to closed [a,b] interval.
|
|
33
|
+
* Same as {@link fit}, but first clamps `x` to closed `[a,b]` interval.
|
|
34
34
|
*
|
|
35
35
|
* @param x -
|
|
36
36
|
* @param a -
|
|
@@ -40,8 +40,8 @@ export declare const fit: <T extends Prim>(x: Term<T>, a: Term<T>, b: Term<T>, c
|
|
|
40
40
|
*/
|
|
41
41
|
export declare const fitClamped: <T extends Prim>(x: Term<T>, a: Term<T>, b: Term<T>, c: Term<T>, d: Term<T>) => import("@thi.ng/shader-ast").FnCall<T>;
|
|
42
42
|
/**
|
|
43
|
-
* Inline function. Fits value `a` in [0
|
|
44
|
-
*
|
|
43
|
+
* Inline function. Fits value `a` in `[0,1]` interval to new interval `[b,c]`.
|
|
44
|
+
* No clamping performed. Same as `mix(b, c, a)`
|
|
45
45
|
*
|
|
46
46
|
* @param a -
|
|
47
47
|
* @param b -
|
|
@@ -49,15 +49,15 @@ export declare const fitClamped: <T extends Prim>(x: Term<T>, a: Term<T>, b: Ter
|
|
|
49
49
|
*/
|
|
50
50
|
export declare const fit01: <T extends Prim>(a: Term<T>, b: Term<T>, c: Term<T>) => Term<T>;
|
|
51
51
|
/**
|
|
52
|
-
* Inline function. Fits value `x` in [-1
|
|
53
|
-
*
|
|
52
|
+
* Inline function. Fits value `x` in `[-1,1]` interval to `[0,1]` interval. No
|
|
53
|
+
* clamping performed.
|
|
54
54
|
*
|
|
55
55
|
* @param x -
|
|
56
56
|
*/
|
|
57
57
|
export declare const fit1101: <T extends PrimTerm>(x: T) => Term<TermType<T>>;
|
|
58
58
|
/**
|
|
59
|
-
* Inline function. Fits value `x` in [0
|
|
60
|
-
*
|
|
59
|
+
* Inline function. Fits value `x` in `[0,1]` interval to `[-1,1]` interval. No
|
|
60
|
+
* clamping performed.
|
|
61
61
|
*
|
|
62
62
|
* @param x -
|
|
63
63
|
*/
|
package/math/interval.d.ts
CHANGED
|
@@ -8,8 +8,10 @@ export declare const trunc: import("@thi.ng/shader-ast").TaggedFn1<"float", "flo
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const modulo: import("@thi.ng/shader-ast").TaggedFn2<"float", "float", "float">;
|
|
10
10
|
/**
|
|
11
|
-
* Same as
|
|
12
|
-
*
|
|
11
|
+
* Same as
|
|
12
|
+
* [`foldback01`](https://docs.thi.ng/umbrella/math/functions/foldback01.html).
|
|
13
|
+
* Folds `x` into the closed `[0,1]` interval, using infinite internal
|
|
14
|
+
* reflection on either side of the interval.
|
|
13
15
|
*
|
|
14
16
|
* @param x
|
|
15
17
|
*/
|
package/math/orthogonal.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Vec2Term } from "@thi.ng/shader-ast";
|
|
2
2
|
/**
|
|
3
3
|
* Inline function. Returns counter-clockwise perpendicular vector (assuming
|
|
4
|
-
* Y-up). [-y,
|
|
4
|
+
* Y-up). `[-y,x]`
|
|
5
5
|
*
|
|
6
6
|
* @param v -
|
|
7
7
|
*/
|
|
8
8
|
export declare const perpendicularCCW: (v: Vec2Term) => import("@thi.ng/shader-ast").Lit<"vec2">;
|
|
9
9
|
/**
|
|
10
10
|
* Inline function. Returns clockwise perpendicular vector (assuming Y-up).
|
|
11
|
-
* [y,-x]
|
|
11
|
+
* `[y,-x]`
|
|
12
12
|
*
|
|
13
13
|
* @param v -
|
|
14
14
|
*/
|
package/math/pack-float.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Encodes a float value in [0,1) interval to a vec4 suitable for a
|
|
3
|
-
* render texture. Use {@link unpackFloat} for reverse op.
|
|
2
|
+
* Encodes a float value in `[0,1)` interval to a vec4 suitable for a
|
|
3
|
+
* 8bit/channel render texture. Use {@link unpackFloat} for reverse op.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
6
|
* Reference:
|
package/math/smoother-step.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TaggedFn1 } from "@thi.ng/shader-ast";
|
|
2
2
|
/**
|
|
3
3
|
* Specialized version of {@link smootherStep}, assuming edges are 0/1
|
|
4
|
-
* respectively and `x` is in [0
|
|
4
|
+
* respectively and `x` is in `[0,1]`. No clamping performed.
|
|
5
5
|
*
|
|
6
6
|
* @param x
|
|
7
7
|
*/
|
package/noise/voronoi2.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* IQ's parametric 2D voronoise. Depending on `u` and `v`, this function
|
|
3
3
|
* produces 4 different noise types
|
|
4
4
|
*
|
|
5
|
-
* - cell noise (0,0)
|
|
6
|
-
* - voronoi (1,0)
|
|
7
|
-
* - perlin noise (0,1)
|
|
8
|
-
* - voronoise (1,1)
|
|
5
|
+
* - cell noise `(0,0)`
|
|
6
|
+
* - voronoi `(1,0)`
|
|
7
|
+
* - perlin noise `(0,1)`
|
|
8
|
+
* - voronoise `(1,1)`
|
|
9
9
|
*
|
|
10
10
|
* http://www.iquilezles.org/www/articles/voronoise/voronoise.htm
|
|
11
11
|
*
|
package/noise/worley2.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const worleyDistManhattan: import("@thi.ng/shader-ast").TaggedFn2
|
|
|
4
4
|
/**
|
|
5
5
|
* Higher order function. Computes 2D Worley noise using provided distance
|
|
6
6
|
* function. The returned function takes 2 args: position and jitter amount, the
|
|
7
|
-
* latter in [0
|
|
7
|
+
* latter in `[0,1]` interval. Returns noise components as vec2, with the x
|
|
8
8
|
* component containing the distance from closest simplex center and y the noise
|
|
9
9
|
* value. The vector components can be used individually or combined (e.g.
|
|
10
10
|
* `noise.y - noise.x`)...
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/shader-ast-stdlib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Function collection for modular GPGPU / shader programming with @thi.ng/shader-ast",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@thi.ng/api": "^8.11.
|
|
46
|
-
"@thi.ng/shader-ast": "^1.0.
|
|
45
|
+
"@thi.ng/api": "^8.11.20",
|
|
46
|
+
"@thi.ng/shader-ast": "^1.0.8"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"esbuild": "^0.
|
|
50
|
-
"typedoc": "^0.27.
|
|
49
|
+
"esbuild": "^0.25.0",
|
|
50
|
+
"typedoc": "^0.27.7",
|
|
51
51
|
"typescript": "^5.7.3"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
@@ -375,5 +375,5 @@
|
|
|
375
375
|
],
|
|
376
376
|
"year": 2019
|
|
377
377
|
},
|
|
378
|
-
"gitHead": "
|
|
378
|
+
"gitHead": "9a0b33253fef092aaf301decf6ecd54317874d4c\n"
|
|
379
379
|
}
|
package/raymarch/ao.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { RaymarchScene } from "../api.js";
|
|
2
2
|
/**
|
|
3
|
-
* Higher order function returning an function to compute the Ambient
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Higher order function returning an function to compute the Ambient Occlusion
|
|
4
|
+
* term / shadow factor for given SDF scene function. The returned function
|
|
5
|
+
* takes 2 arguments: surface pos and normal. It returns a float in `[0,1]`
|
|
6
|
+
* interval (zero = fully occluded).
|
|
7
7
|
*
|
|
8
8
|
* @param scene -
|
|
9
9
|
* @param numSamples -
|
package/screen/uv.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Vec2Term, Vec4Term } from "@thi.ng/shader-ast";
|
|
2
2
|
/**
|
|
3
|
-
* Computes UV coord in [0
|
|
3
|
+
* Computes UV coord in `[0,1]` interval from given `fragCoord` and screen
|
|
4
|
+
* `res`.
|
|
4
5
|
*
|
|
5
6
|
* @param fragCoord -
|
|
6
7
|
* @param res -
|
|
@@ -8,7 +9,7 @@ import type { Vec2Term, Vec4Term } from "@thi.ng/shader-ast";
|
|
|
8
9
|
export declare const fragUV: (fragCoord: Vec4Term, res: Vec2Term) => import("@thi.ng/shader-ast").Op2<"vec2">;
|
|
9
10
|
/**
|
|
10
11
|
* Takes `pos`, a screen coord (e.g. gl_FragCoord) and viewport resolution
|
|
11
|
-
* `res`, returns aspect corrected uv, with uv.y in [-1
|
|
12
|
+
* `res`, returns aspect corrected uv, with uv.y in `[-1,1]` interval and uv.x
|
|
12
13
|
* scaled by the aspect ratio `resx / resy`.
|
|
13
14
|
*
|
|
14
15
|
* @param fragCoord - vec2
|
|
@@ -17,7 +18,7 @@ export declare const fragUV: (fragCoord: Vec4Term, res: Vec2Term) => import("@th
|
|
|
17
18
|
export declare const aspectCorrectedUV: import("@thi.ng/shader-ast").TaggedFn2<"vec2", "vec2", "vec2">;
|
|
18
19
|
/**
|
|
19
20
|
* Returns true if at least one coordinate of the given point is within the
|
|
20
|
-
* `width` internal border region of UV rect ([0,0]
|
|
21
|
+
* `width` internal border region of UV rect (`[0,0]`..`[1,1]`).
|
|
21
22
|
*
|
|
22
23
|
* ```c
|
|
23
24
|
* borderMask(vec2(0.91, 0.5), 0.1) // true
|
package/sdf/arc.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns signed distance from `p` to 2D circular arc with `aperture` (in
|
|
3
|
-
* [0
|
|
3
|
+
* `[0,π]` interval), radius `ra` and `thickness`.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
6
|
* Slightly modified version (easier to use aperture control) of original GLSL
|
package/sdf/box-rounded.d.ts
CHANGED
package/sdf/cross.d.ts
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* radius `r`.
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
|
+
*
|
|
6
7
|
* - `size` consist of overall width/size (in x) and thickness (in y component)
|
|
7
8
|
* - corner radius can also be negative
|
|
8
9
|
*
|
|
9
10
|
* Ported from original GLSL impl by Inigo Quilez:
|
|
10
|
-
*
|
|
11
|
+
* https://iquilezles.org/articles/distfunctions2d/
|
|
11
12
|
*
|
|
12
13
|
* @param p -
|
|
13
14
|
* @param size -
|
|
@@ -20,7 +21,7 @@ export declare const sdfCross2: import("@thi.ng/shader-ast").TaggedFn3<"vec2", "
|
|
|
20
21
|
*
|
|
21
22
|
* @remarks
|
|
22
23
|
* Ported from original GLSL impl by Inigo Quilez:
|
|
23
|
-
*
|
|
24
|
+
* https://iquilezles.org/articles/distfunctions2d/
|
|
24
25
|
*
|
|
25
26
|
* @param p -
|
|
26
27
|
* @param size -
|
package/sdf/hex.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @remarks
|
|
5
5
|
* Ported from original GLSL impl by Inigo Quilez:
|
|
6
|
-
*
|
|
6
|
+
* https://iquilezles.org/articles/distfunctions2d/
|
|
7
7
|
*/
|
|
8
8
|
export declare const sdfHexagon2: import("@thi.ng/shader-ast").TaggedFn2<"vec2", "float", "float">;
|
|
9
9
|
//# sourceMappingURL=hex.d.ts.map
|
package/sdf/polygon.d.ts
CHANGED
package/viz/function.d.ts
CHANGED
|
@@ -24,14 +24,14 @@ export interface FnSampleOpts {
|
|
|
24
24
|
area: boolean;
|
|
25
25
|
/**
|
|
26
26
|
* Min X position (in function domain). The function will only be evaluated
|
|
27
|
-
* within the [min
|
|
27
|
+
* within the `[min,max]` domain.
|
|
28
28
|
*
|
|
29
29
|
* @defaultValue 0
|
|
30
30
|
*/
|
|
31
31
|
min: number;
|
|
32
32
|
/**
|
|
33
33
|
* Max X position (in function domain). The function will only be evaluated
|
|
34
|
-
* within the [min
|
|
34
|
+
* within the `[min,max]` domain.
|
|
35
35
|
*
|
|
36
36
|
* @defaultValue 1
|
|
37
37
|
*/
|