@thi.ng/shader-ast-stdlib 0.12.26 → 0.12.28
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/README.md +1 -1
- package/color/porter-duff.d.ts +6 -7
- package/color/porter-duff.js +6 -7
- package/fog/exp2.d.ts +4 -3
- package/fog/exp2.js +4 -3
- package/light/lambert.d.ts +3 -3
- package/light/lambert.js +3 -3
- package/math/orthogonal.d.ts +5 -5
- package/math/orthogonal.js +5 -5
- package/noise/simplex2.d.ts +3 -3
- package/noise/simplex2.js +3 -3
- package/noise/voronoi2.d.ts +1 -1
- package/noise/voronoi2.js +1 -1
- package/noise/worley2.d.ts +1 -1
- package/noise/worley2.js +1 -1
- package/package.json +5 -5
- package/tex/blur.d.ts +6 -6
- package/tex/blur.js +6 -6
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ This project is part of the
|
|
|
41
41
|
|
|
42
42
|
## About
|
|
43
43
|
|
|
44
|
-
Function collection for modular GPGPU / shader programming with @thi.ng/shader-ast
|
|
44
|
+
Function collection for modular GPGPU / shader programming with [@thi.ng/shader-ast](https://github.com/thi-ng/umbrella/tree/develop/packages/shader-ast).
|
|
45
45
|
|
|
46
46
|
A growing collection (currently ~170) of useful functions & higher order
|
|
47
47
|
constructs (incl. meta programming approaches) for GPU / shader programming,
|
package/color/porter-duff.d.ts
CHANGED
|
@@ -2,14 +2,13 @@ import type { Fn2 } from "@thi.ng/api";
|
|
|
2
2
|
import type { FloatTerm } from "@thi.ng/shader-ast";
|
|
3
3
|
/**
|
|
4
4
|
* Higher-order Porter-Duff alpha compositing operator. See
|
|
5
|
-
*
|
|
6
|
-
* function which accepts 2 RGBA colors (vec4) and returns blended
|
|
7
|
-
* clamped result (also a vec4). All built-in PD operators are defined
|
|
8
|
-
*
|
|
5
|
+
* [thi.ng/porter-duff](https://thi.ng/porter-duff) for reference. Returns an
|
|
6
|
+
* optimized AST function which accepts 2 RGBA colors (vec4) and returns blended
|
|
7
|
+
* & clamped result (also a vec4). All built-in PD operators are defined via
|
|
8
|
+
* this HOF.
|
|
9
9
|
*
|
|
10
|
-
* The two given JS functions are used to extract blending coefficients
|
|
11
|
-
*
|
|
12
|
-
* colors.
|
|
10
|
+
* The two given JS functions are used to extract blending coefficients for
|
|
11
|
+
* src/dest colors and are called with the alpha components of both colors.
|
|
13
12
|
*
|
|
14
13
|
* Optimization only happens for cases where either `fa` and/or `fb` are
|
|
15
14
|
* {@link ZERO}.
|
package/color/porter-duff.js
CHANGED
|
@@ -6,14 +6,13 @@ import { clamp01 } from "../math/clamp.js";
|
|
|
6
6
|
const coeff = (f, a, b) => (f === ZERO ? FLOAT0 : f === ONE ? a : mul(a, f($w(a), $w(b))));
|
|
7
7
|
/**
|
|
8
8
|
* Higher-order Porter-Duff alpha compositing operator. See
|
|
9
|
-
*
|
|
10
|
-
* function which accepts 2 RGBA colors (vec4) and returns blended
|
|
11
|
-
* clamped result (also a vec4). All built-in PD operators are defined
|
|
12
|
-
*
|
|
9
|
+
* [thi.ng/porter-duff](https://thi.ng/porter-duff) for reference. Returns an
|
|
10
|
+
* optimized AST function which accepts 2 RGBA colors (vec4) and returns blended
|
|
11
|
+
* & clamped result (also a vec4). All built-in PD operators are defined via
|
|
12
|
+
* this HOF.
|
|
13
13
|
*
|
|
14
|
-
* The two given JS functions are used to extract blending coefficients
|
|
15
|
-
*
|
|
16
|
-
* colors.
|
|
14
|
+
* The two given JS functions are used to extract blending coefficients for
|
|
15
|
+
* src/dest colors and are called with the alpha components of both colors.
|
|
17
16
|
*
|
|
18
17
|
* Optimization only happens for cases where either `fa` and/or `fb` are
|
|
19
18
|
* {@link ZERO}.
|
package/fog/exp2.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Similar to {@link fogExp}. Computes exponential fog factor [0..1],
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Similar to {@link fogExp}. Computes exponential fog factor [0..1], based on
|
|
3
|
+
* given fully saturated fog distance and density. Uses
|
|
4
|
+
* [`exp2()`](https://docs.thi.ng/umbrella/shader-ast/functions/exp2.html)
|
|
5
|
+
* internally.
|
|
5
6
|
*
|
|
6
7
|
* @param dist - float
|
|
7
8
|
* @param density - float
|
package/fog/exp2.js
CHANGED
|
@@ -5,9 +5,10 @@ import { mul, sub } from "@thi.ng/shader-ast/ast/ops";
|
|
|
5
5
|
import { exp2 } from "@thi.ng/shader-ast/builtin/math";
|
|
6
6
|
import { clamp01 } from "../math/clamp.js";
|
|
7
7
|
/**
|
|
8
|
-
* Similar to {@link fogExp}. Computes exponential fog factor [0..1],
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Similar to {@link fogExp}. Computes exponential fog factor [0..1], based on
|
|
9
|
+
* given fully saturated fog distance and density. Uses
|
|
10
|
+
* [`exp2()`](https://docs.thi.ng/umbrella/shader-ast/functions/exp2.html)
|
|
11
|
+
* internally.
|
|
11
12
|
*
|
|
12
13
|
* @param dist - float
|
|
13
14
|
* @param density - float
|
package/light/lambert.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FloatTerm, Vec3Term } from "@thi.ng/shader-ast";
|
|
2
2
|
/**
|
|
3
|
-
* Inline function. Computes Lambert term, i.e. `max(dot(n, l), 0)`.
|
|
4
|
-
*
|
|
3
|
+
* Inline function. Computes Lambert term, i.e. `max(dot(n, l), 0)`. Both
|
|
4
|
+
* vectors must be pre-normalized.
|
|
5
5
|
*
|
|
6
6
|
* @param surfNormal - vec3
|
|
7
7
|
* @param lightDir - vec3
|
|
@@ -11,7 +11,7 @@ export declare const lambert: (n: Vec3Term, ldir: Vec3Term) => import("@thi.ng/s
|
|
|
11
11
|
* Inline function. Computes Half-Lambertian term. Both vectors must be
|
|
12
12
|
* pre-normalized.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* https://developer.valvesoftware.com/wiki/Half_Lambert
|
|
15
15
|
*
|
|
16
16
|
* @param n -
|
|
17
17
|
* @param ldir -
|
package/light/lambert.js
CHANGED
|
@@ -3,8 +3,8 @@ import { madd, mul } from "@thi.ng/shader-ast/ast/ops";
|
|
|
3
3
|
import { dot, max } from "@thi.ng/shader-ast/builtin/math";
|
|
4
4
|
import { fit1101 } from "../math/fit.js";
|
|
5
5
|
/**
|
|
6
|
-
* Inline function. Computes Lambert term, i.e. `max(dot(n, l), 0)`.
|
|
7
|
-
*
|
|
6
|
+
* Inline function. Computes Lambert term, i.e. `max(dot(n, l), 0)`. Both
|
|
7
|
+
* vectors must be pre-normalized.
|
|
8
8
|
*
|
|
9
9
|
* @param surfNormal - vec3
|
|
10
10
|
* @param lightDir - vec3
|
|
@@ -14,7 +14,7 @@ export const lambert = (n, ldir) => max(dot(n, ldir), FLOAT0);
|
|
|
14
14
|
* Inline function. Computes Half-Lambertian term. Both vectors must be
|
|
15
15
|
* pre-normalized.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* https://developer.valvesoftware.com/wiki/Half_Lambert
|
|
18
18
|
*
|
|
19
19
|
* @param n -
|
|
20
20
|
* @param ldir -
|
package/math/orthogonal.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Vec2Term } from "@thi.ng/shader-ast";
|
|
2
2
|
/**
|
|
3
|
-
* Inline function. Returns counter-clockwise perpendicular vector
|
|
4
|
-
*
|
|
3
|
+
* Inline function. Returns counter-clockwise perpendicular vector (assuming
|
|
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
|
-
* Inline function. Returns clockwise perpendicular vector (assuming
|
|
11
|
-
*
|
|
10
|
+
* Inline function. Returns clockwise perpendicular vector (assuming Y-up).
|
|
11
|
+
* [y,-x]
|
|
12
12
|
*
|
|
13
13
|
* @param v -
|
|
14
14
|
*/
|
|
@@ -16,7 +16,7 @@ export declare const perpendicularCW: (v: Vec2Term) => import("@thi.ng/shader-as
|
|
|
16
16
|
/**
|
|
17
17
|
* Returns an orthogonal vector to `v`.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
19
|
+
* http://lolengine.net/blog/2013/09/21/picking-orthogonal-vector-combing-coconuts
|
|
20
20
|
*/
|
|
21
21
|
export declare const orthogonal3: import("@thi.ng/shader-ast").TaggedFn1<"vec3", "vec3">;
|
|
22
22
|
//# sourceMappingURL=orthogonal.d.ts.map
|
package/math/orthogonal.js
CHANGED
|
@@ -5,15 +5,15 @@ import { gt, neg } from "@thi.ng/shader-ast/ast/ops";
|
|
|
5
5
|
import { $x, $y, $z } from "@thi.ng/shader-ast/ast/swizzle";
|
|
6
6
|
import { abs } from "@thi.ng/shader-ast/builtin/math";
|
|
7
7
|
/**
|
|
8
|
-
* Inline function. Returns counter-clockwise perpendicular vector
|
|
9
|
-
*
|
|
8
|
+
* Inline function. Returns counter-clockwise perpendicular vector (assuming
|
|
9
|
+
* Y-up). [-y, x]
|
|
10
10
|
*
|
|
11
11
|
* @param v -
|
|
12
12
|
*/
|
|
13
13
|
export const perpendicularCCW = (v) => vec2(neg($y(v)), $x(v));
|
|
14
14
|
/**
|
|
15
|
-
* Inline function. Returns clockwise perpendicular vector (assuming
|
|
16
|
-
*
|
|
15
|
+
* Inline function. Returns clockwise perpendicular vector (assuming Y-up).
|
|
16
|
+
* [y,-x]
|
|
17
17
|
*
|
|
18
18
|
* @param v -
|
|
19
19
|
*/
|
|
@@ -21,7 +21,7 @@ export const perpendicularCW = (v) => vec2($y(v), neg($x(v)));
|
|
|
21
21
|
/**
|
|
22
22
|
* Returns an orthogonal vector to `v`.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
24
|
+
* http://lolengine.net/blog/2013/09/21/picking-orthogonal-vector-combing-coconuts
|
|
25
25
|
*/
|
|
26
26
|
export const orthogonal3 = defn("vec3", "orthogonal3", ["vec3"], (v) => [
|
|
27
27
|
ret(ternary(gt(abs($x(v)), abs($z(v))), vec3(neg($y(v)), $x(v), 0), vec3(0, neg($z(v)), $y(v)))),
|
package/noise/simplex2.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Array and textureless GLSL 2D simplex noise function. Ported from
|
|
3
|
-
*
|
|
2
|
+
* Array and textureless GLSL 2D simplex noise function. Ported from original
|
|
3
|
+
* GLSL implementation by Ian McEwan & Ashima Arts.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* https://github.com/ashima/webgl-noise
|
|
6
6
|
*/
|
|
7
7
|
export declare const snoise2: import("@thi.ng/shader-ast").TaggedFn1<"vec2", "float">;
|
|
8
8
|
//# sourceMappingURL=simplex2.d.ts.map
|
package/noise/simplex2.js
CHANGED
|
@@ -9,10 +9,10 @@ import { abs, dot, floor, fract, max, mod, } from "@thi.ng/shader-ast/builtin/ma
|
|
|
9
9
|
import { magSq2 } from "../math/magsq.js";
|
|
10
10
|
import { permute3 } from "./permute.js";
|
|
11
11
|
/**
|
|
12
|
-
* Array and textureless GLSL 2D simplex noise function. Ported from
|
|
13
|
-
*
|
|
12
|
+
* Array and textureless GLSL 2D simplex noise function. Ported from original
|
|
13
|
+
* GLSL implementation by Ian McEwan & Ashima Arts.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* https://github.com/ashima/webgl-noise
|
|
16
16
|
*/
|
|
17
17
|
export const snoise2 = defn("float", "snoise2", ["vec2"], (v) => {
|
|
18
18
|
let C;
|
package/noise/voronoi2.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - perlin noise (0,1)
|
|
8
8
|
* - voronoise (1,1)
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* http://www.iquilezles.org/www/articles/voronoise/voronoise.htm
|
|
11
11
|
*
|
|
12
12
|
* Note: This implementation uses the improved {@link hash32} by Dave Hoskins
|
|
13
13
|
* instead of iq's original {@link hash3}.
|
package/noise/voronoi2.js
CHANGED
|
@@ -16,7 +16,7 @@ import { hash32 } from "./hash.js";
|
|
|
16
16
|
* - perlin noise (0,1)
|
|
17
17
|
* - voronoise (1,1)
|
|
18
18
|
*
|
|
19
|
-
*
|
|
19
|
+
* http://www.iquilezles.org/www/articles/voronoise/voronoise.htm
|
|
20
20
|
*
|
|
21
21
|
* Note: This implementation uses the improved {@link hash32} by Dave Hoskins
|
|
22
22
|
* instead of iq's original {@link hash3}.
|
package/noise/worley2.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const worleyDistManhattan: import("@thi.ng/shader-ast").TaggedFn2
|
|
|
10
10
|
* can be used individually or combined (e.g. `noise.y - noise.x`)...
|
|
11
11
|
*
|
|
12
12
|
* Based on implementation by Stefan Gustavson:
|
|
13
|
-
*
|
|
13
|
+
* http://webstaff.itn.liu.se/~stegu/GLSL-cellular/GLSL-cellular-notes.pdf
|
|
14
14
|
*
|
|
15
15
|
* @param distFn -
|
|
16
16
|
*/
|
package/noise/worley2.js
CHANGED
|
@@ -18,7 +18,7 @@ export const worleyDistManhattan = defn("vec3", "worleyDistManhatten", ["vec3",
|
|
|
18
18
|
* can be used individually or combined (e.g. `noise.y - noise.x`)...
|
|
19
19
|
*
|
|
20
20
|
* Based on implementation by Stefan Gustavson:
|
|
21
|
-
*
|
|
21
|
+
* http://webstaff.itn.liu.se/~stegu/GLSL-cellular/GLSL-cellular-notes.pdf
|
|
22
22
|
*
|
|
23
23
|
* @param distFn -
|
|
24
24
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/shader-ast-stdlib",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.28",
|
|
4
4
|
"description": "Function collection for modular GPGPU / shader programming with @thi.ng/shader-ast",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.6.
|
|
38
|
-
"@thi.ng/shader-ast": "^0.12.
|
|
37
|
+
"@thi.ng/api": "^8.6.2",
|
|
38
|
+
"@thi.ng/shader-ast": "^0.12.35"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@microsoft/api-extractor": "^7.33.7",
|
|
42
|
-
"@thi.ng/testament": "^0.3.
|
|
42
|
+
"@thi.ng/testament": "^0.3.8",
|
|
43
43
|
"rimraf": "^3.0.2",
|
|
44
44
|
"tools": "^0.0.1",
|
|
45
45
|
"typedoc": "^0.23.22",
|
|
@@ -330,5 +330,5 @@
|
|
|
330
330
|
],
|
|
331
331
|
"year": 2019
|
|
332
332
|
},
|
|
333
|
-
"gitHead": "
|
|
333
|
+
"gitHead": "bc6f7f5e2765bb96fe64db804eaf4b2443b47fc6\n"
|
|
334
334
|
}
|
package/tex/blur.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 5x5 gaussian blur texture lookup, optimized, but based on:
|
|
3
3
|
*
|
|
4
|
-
* -
|
|
5
|
-
* -
|
|
4
|
+
* - http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
|
|
5
|
+
* - https://github.com/Jam3/glsl-fast-gaussian-blur
|
|
6
6
|
*
|
|
7
7
|
* @param tex - sampler2D
|
|
8
8
|
* @param res - resolution
|
|
@@ -13,8 +13,8 @@ export declare const blur5: import("@thi.ng/shader-ast").TaggedFn4<"sampler2D",
|
|
|
13
13
|
/**
|
|
14
14
|
* 9x9 gaussian blur texture lookup, optimized, but based on:
|
|
15
15
|
*
|
|
16
|
-
* -
|
|
17
|
-
* -
|
|
16
|
+
* - http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
|
|
17
|
+
* - https://github.com/Jam3/glsl-fast-gaussian-blur
|
|
18
18
|
*
|
|
19
19
|
* @param tex - sampler2D
|
|
20
20
|
* @param res - resolution
|
|
@@ -25,8 +25,8 @@ export declare const blur9: import("@thi.ng/shader-ast").TaggedFn4<"sampler2D",
|
|
|
25
25
|
/**
|
|
26
26
|
* 13x13 gaussian blur texture lookup, optimized, but based on:
|
|
27
27
|
*
|
|
28
|
-
* -
|
|
29
|
-
* -
|
|
28
|
+
* - http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
|
|
29
|
+
* - https://github.com/Jam3/glsl-fast-gaussian-blur
|
|
30
30
|
*
|
|
31
31
|
* @param tex - sampler2D
|
|
32
32
|
* @param res - resolution
|
package/tex/blur.js
CHANGED
|
@@ -18,8 +18,8 @@ const singlePass = (col, tex, uv, off, k) => assign(col, add(col, mul(add(textur
|
|
|
18
18
|
/**
|
|
19
19
|
* 5x5 gaussian blur texture lookup, optimized, but based on:
|
|
20
20
|
*
|
|
21
|
-
* -
|
|
22
|
-
* -
|
|
21
|
+
* - http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
|
|
22
|
+
* - https://github.com/Jam3/glsl-fast-gaussian-blur
|
|
23
23
|
*
|
|
24
24
|
* @param tex - sampler2D
|
|
25
25
|
* @param res - resolution
|
|
@@ -41,8 +41,8 @@ export const blur5 = defn("vec4", "blur5", ["sampler2D", "vec2", "vec2", "vec2"]
|
|
|
41
41
|
/**
|
|
42
42
|
* 9x9 gaussian blur texture lookup, optimized, but based on:
|
|
43
43
|
*
|
|
44
|
-
* -
|
|
45
|
-
* -
|
|
44
|
+
* - http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
|
|
45
|
+
* - https://github.com/Jam3/glsl-fast-gaussian-blur
|
|
46
46
|
*
|
|
47
47
|
* @param tex - sampler2D
|
|
48
48
|
* @param res - resolution
|
|
@@ -69,8 +69,8 @@ export const blur9 = defn("vec4", "blur9", ["sampler2D", "vec2", "vec2", "vec2"]
|
|
|
69
69
|
/**
|
|
70
70
|
* 13x13 gaussian blur texture lookup, optimized, but based on:
|
|
71
71
|
*
|
|
72
|
-
* -
|
|
73
|
-
* -
|
|
72
|
+
* - http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
|
|
73
|
+
* - https://github.com/Jam3/glsl-fast-gaussian-blur
|
|
74
74
|
*
|
|
75
75
|
* @param tex - sampler2D
|
|
76
76
|
* @param res - resolution
|