@thi.ng/shader-ast-stdlib 1.0.63 → 1.0.65
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/README.md +48 -47
- package/color/cosine-gradient.d.ts +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
|
-
<!-- Please see: https://
|
|
3
|
-
# 
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@thi.ng/shader-ast-stdlib)
|
|
6
6
|

|
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
10
|
> This is one of 214 standalone projects, maintained as part
|
|
11
|
-
> of the [@thi.ng/umbrella](https://
|
|
11
|
+
> of the [@thi.ng/umbrella](https://codeberg.org/thi.ng/umbrella/) ecosystem
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
14
|
-
> 🚀 Please help me to work full-time on these projects by [sponsoring
|
|
15
|
-
>
|
|
14
|
+
> 🚀 Please help me to work full-time on these projects by [sponsoring
|
|
15
|
+
> me](https://codeberg.org/thi.ng/umbrella/src/branch/develop/CONTRIBUTING.md#donations).
|
|
16
|
+
> Thank you! ❤️
|
|
16
17
|
|
|
17
18
|
- [About](#about)
|
|
18
19
|
- [Status](#status)
|
|
@@ -49,12 +50,12 @@
|
|
|
49
50
|
|
|
50
51
|
## About
|
|
51
52
|
|
|
52
|
-
Function collection for modular GPGPU / shader programming with [@thi.ng/shader-ast](https://
|
|
53
|
+
Function collection for modular GPGPU / shader programming with [@thi.ng/shader-ast](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast).
|
|
53
54
|
|
|
54
55
|
A growing collection (currently ~230) of useful functions & higher order
|
|
55
56
|
constructs (incl. meta programming approaches) for GPU / shader programming,
|
|
56
57
|
acting as optional standard library for
|
|
57
|
-
[@thi.ng/shader-ast](https://
|
|
58
|
+
[@thi.ng/shader-ast](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast)
|
|
58
59
|
based workflows.
|
|
59
60
|
|
|
60
61
|
These functions can be imported like normal TS/JS functions and (in TS) are
|
|
@@ -81,13 +82,13 @@ Reference:
|
|
|
81
82
|
|
|
82
83
|
**STABLE** - used in production
|
|
83
84
|
|
|
84
|
-
[Search or submit any issues for this package](https://
|
|
85
|
+
[Search or submit any issues for this package](https://codeberg.org/thi.ng/umbrella/issues?q=%5Bshader-ast-stdlib%5D)
|
|
85
86
|
|
|
86
87
|
## Related packages
|
|
87
88
|
|
|
88
|
-
- [@thi.ng/shader-ast-glsl](https://
|
|
89
|
-
- [@thi.ng/shader-ast-js](https://
|
|
90
|
-
- [@thi.ng/webgl](https://
|
|
89
|
+
- [@thi.ng/shader-ast-glsl](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-glsl) - Customizable GLSL codegen for [@thi.ng/shader-ast](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast)
|
|
90
|
+
- [@thi.ng/shader-ast-js](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-js) - Customizable JS codegen, compiler & runtime for [@thi.ng/shader-ast](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast)
|
|
91
|
+
- [@thi.ng/webgl](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/webgl) - WebGL & GLSL abstraction layer
|
|
91
92
|
|
|
92
93
|
## Installation
|
|
93
94
|
|
|
@@ -119,33 +120,33 @@ Package sizes (brotli'd, pre-treeshake): ESM: 13.98 KB
|
|
|
119
120
|
|
|
120
121
|
## Dependencies
|
|
121
122
|
|
|
122
|
-
- [@thi.ng/api](https://
|
|
123
|
-
- [@thi.ng/shader-ast](https://
|
|
123
|
+
- [@thi.ng/api](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/api)
|
|
124
|
+
- [@thi.ng/shader-ast](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast)
|
|
124
125
|
|
|
125
126
|
Note: @thi.ng/api is in _most_ cases a type-only import (not used at runtime)
|
|
126
127
|
|
|
127
128
|
## Usage examples
|
|
128
129
|
|
|
129
130
|
14 projects in this repo's
|
|
130
|
-
[/examples](https://
|
|
131
|
+
[/examples](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples)
|
|
131
132
|
directory are using this package:
|
|
132
133
|
|
|
133
|
-
| Screenshot | Description | Live demo | Source
|
|
134
|
-
|
|
135
|
-
| <img src="https://
|
|
136
|
-
| <img src="https://
|
|
137
|
-
| <img src="https://
|
|
138
|
-
| <img src="https://
|
|
139
|
-
| <img src="https://
|
|
140
|
-
| <img src="https://
|
|
141
|
-
| <img src="https://
|
|
142
|
-
| <img src="https://
|
|
143
|
-
| <img src="https://
|
|
144
|
-
| <img src="https://
|
|
145
|
-
| | Minimal multi-pass / GPGPU example | [Demo](https://demo.thi.ng/umbrella/webgl-multipass/) | [Source](https://
|
|
146
|
-
| <img src="https://
|
|
147
|
-
| <img src="https://
|
|
148
|
-
| <img src="https://
|
|
134
|
+
| Screenshot | Description | Live demo | Source |
|
|
135
|
+
|:-----------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------|:----------------------------------------------------------|:-----------------------------------------------------------------------------------------------|
|
|
136
|
+
| <img src="https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/examples/ascii-raymarch.jpg" width="240"/> | ASCII art raymarching with thi.ng/shader-ast & thi.ng/text-canvas | [Demo](https://demo.thi.ng/umbrella/ascii-raymarch/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/ascii-raymarch) |
|
|
137
|
+
| <img src="https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/shader-ast/shader-ast-01.jpg" width="240"/> | 2D canvas shader emulation | [Demo](https://demo.thi.ng/umbrella/shader-ast-canvas2d/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/shader-ast-canvas2d) |
|
|
138
|
+
| <img src="https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/examples/shader-ast-easings.png" width="240"/> | Shader-AST meta-programming techniques for animated function plots | [Demo](https://demo.thi.ng/umbrella/shader-ast-easings/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/shader-ast-easings) |
|
|
139
|
+
| <img src="https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/examples/shader-ast-evo.jpg" width="240"/> | Evolutionary shader generation using genetic programming | [Demo](https://demo.thi.ng/umbrella/shader-ast-evo/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/shader-ast-evo) |
|
|
140
|
+
| <img src="https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/examples/shader-ast-noise.jpg" width="240"/> | HOF shader procedural noise function composition | [Demo](https://demo.thi.ng/umbrella/shader-ast-noise/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/shader-ast-noise) |
|
|
141
|
+
| <img src="https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/shader-ast/shader-ast-raymarch.jpg" width="240"/> | WebGL & JS canvas2D raymarch shader cross-compilation | [Demo](https://demo.thi.ng/umbrella/shader-ast-raymarch/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/shader-ast-raymarch) |
|
|
142
|
+
| <img src="https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/examples/shader-ast-sdf2d.jpg" width="240"/> | WebGL & JS canvas 2D SDF | [Demo](https://demo.thi.ng/umbrella/shader-ast-sdf2d/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/shader-ast-sdf2d) |
|
|
143
|
+
| <img src="https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/examples/shader-ast-tunnel.jpg" width="240"/> | WebGL & Canvas2D textured tunnel shader | [Demo](https://demo.thi.ng/umbrella/shader-ast-tunnel/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/shader-ast-tunnel) |
|
|
144
|
+
| <img src="https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/examples/shader-ast-workers.jpg" width="240"/> | Fork-join worker-based raymarch renderer (JS/CPU only) | [Demo](https://demo.thi.ng/umbrella/shader-ast-workers/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/shader-ast-workers) |
|
|
145
|
+
| <img src="https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/examples/viz-ridge-lines.avif" width="240"/> | Interactive ridge-line plot | [Demo](https://demo.thi.ng/umbrella/viz-ridge-lines/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/viz-ridge-lines) |
|
|
146
|
+
| | Minimal multi-pass / GPGPU example | [Demo](https://demo.thi.ng/umbrella/webgl-multipass/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/webgl-multipass) |
|
|
147
|
+
| <img src="https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/examples/webgl-shadertoy.jpg" width="240"/> | Shadertoy-like WebGL setup | [Demo](https://demo.thi.ng/umbrella/webgl-shadertoy/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/webgl-shadertoy) |
|
|
148
|
+
| <img src="https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/examples/webgl-ssao.jpg" width="240"/> | WebGL screenspace ambient occlusion | [Demo](https://demo.thi.ng/umbrella/webgl-ssao/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/webgl-ssao) |
|
|
149
|
+
| <img src="https://codeberg.org/thi.ng/umbrella/media/branch/develop/assets/examples/webgl-texture-paint.jpg" width="240"/> | Interactively drawing to & reading from a WebGL offscreen render texture | [Demo](https://demo.thi.ng/umbrella/webgl-texture-paint/) | [Source](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/webgl-texture-paint) |
|
|
149
150
|
|
|
150
151
|
## API
|
|
151
152
|
|
|
@@ -258,7 +259,7 @@ gl_Position = ((proj * (view * model)) * vec4(position, 1.0));
|
|
|
258
259
|
### Generated fragment shader
|
|
259
260
|
|
|
260
261
|
The `fragColor` output variable is auto-created by
|
|
261
|
-
[@thi.ng/webgl](https://
|
|
262
|
+
[@thi.ng/webgl](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/webgl)
|
|
262
263
|
if no other output vars are defined. For WebGL v1 this is defined as an
|
|
263
264
|
alias for `gl_FragColor`...
|
|
264
265
|
|
|
@@ -303,7 +304,7 @@ dependencies are resolved and emitted in the correct topological order
|
|
|
303
304
|
during later code generation.
|
|
304
305
|
|
|
305
306
|
Below is the main shader code of the [Simplex noise
|
|
306
|
-
example](https://
|
|
307
|
+
example](https://codeberg.org/thi.ng/umbrella/src/branch/develop/examples/shader-ast-noise).
|
|
307
308
|
|
|
308
309
|
```ts
|
|
309
310
|
import { add, defn, float, ret, sym, vec2, vec3, vec4 } from "@thi.ng/shader-ast";
|
|
@@ -342,7 +343,7 @@ several other HOFs from this library to drastically simplify user code.
|
|
|
342
343
|
|
|
343
344
|
### Color
|
|
344
345
|
|
|
345
|
-
[/src/color](https://
|
|
346
|
+
[/src/color](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/color/)
|
|
346
347
|
|
|
347
348
|
- `ACESFilm` (tone mapping)
|
|
348
349
|
- `cosineGradient`
|
|
@@ -358,7 +359,7 @@ several other HOFs from this library to drastically simplify user code.
|
|
|
358
359
|
|
|
359
360
|
Use the `porterDuff` higher order function to define new blend modes.
|
|
360
361
|
See
|
|
361
|
-
[@thi.ng/porter-duff](https://
|
|
362
|
+
[@thi.ng/porter-duff](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/porter-duff)
|
|
362
363
|
for reference.
|
|
363
364
|
|
|
364
365
|
12 standard PD operators for `vec4` RGBA colors:
|
|
@@ -380,7 +381,7 @@ Related:
|
|
|
380
381
|
|
|
381
382
|
### Fog
|
|
382
383
|
|
|
383
|
-
[/src/fog](https://
|
|
384
|
+
[/src/fog](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/fog/)
|
|
384
385
|
|
|
385
386
|
- `fogLinear`
|
|
386
387
|
- `fogExp`
|
|
@@ -388,14 +389,14 @@ Related:
|
|
|
388
389
|
|
|
389
390
|
### Intersection tests
|
|
390
391
|
|
|
391
|
-
[/src/isec](https://
|
|
392
|
+
[/src/isec](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/isec/)
|
|
392
393
|
|
|
393
394
|
- `isPointInCircle`
|
|
394
395
|
- `isPointInRect`
|
|
395
396
|
|
|
396
397
|
### Lighting
|
|
397
398
|
|
|
398
|
-
[/src/light](https://
|
|
399
|
+
[/src/light](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/light/)
|
|
399
400
|
|
|
400
401
|
- `lambert`
|
|
401
402
|
- `halfLambert`
|
|
@@ -404,7 +405,7 @@ Related:
|
|
|
404
405
|
|
|
405
406
|
### Math
|
|
406
407
|
|
|
407
|
-
[/src/math](https://
|
|
408
|
+
[/src/math](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/math/)
|
|
408
409
|
|
|
409
410
|
- `additive`
|
|
410
411
|
- `cartesian2` / `cartesian3`
|
|
@@ -426,7 +427,7 @@ Related:
|
|
|
426
427
|
|
|
427
428
|
### Easing functions
|
|
428
429
|
|
|
429
|
-
[/src/math/easing.ts](https://
|
|
430
|
+
[/src/math/easing.ts](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/math/easing.ts)
|
|
430
431
|
|
|
431
432
|
- `easeInBack` / `easeOutBack` / `easeInOutBack`
|
|
432
433
|
- `easeInBounce` / `easeOutBounce` / `easeInOutBounce`
|
|
@@ -441,13 +442,13 @@ Related:
|
|
|
441
442
|
|
|
442
443
|
### Oscillators
|
|
443
444
|
|
|
444
|
-
[/src/math](https://
|
|
445
|
+
[/src/math](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/math/osc.ts)
|
|
445
446
|
|
|
446
447
|
- `sinOsc` / `sawOsc` / `triOsc` / `rectOsc`
|
|
447
448
|
|
|
448
449
|
### Matrix operations
|
|
449
450
|
|
|
450
|
-
[/src/matrix](https://
|
|
451
|
+
[/src/matrix](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/matrix/)
|
|
451
452
|
|
|
452
453
|
- `lookat`
|
|
453
454
|
- `transformMVP`
|
|
@@ -458,7 +459,7 @@ Related:
|
|
|
458
459
|
|
|
459
460
|
### Noise / randomness
|
|
460
461
|
|
|
461
|
-
[/src/noise](https://
|
|
462
|
+
[/src/noise](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/noise/)
|
|
462
463
|
|
|
463
464
|
- `fbmNoiseVec34`
|
|
464
465
|
- `hash2` / `hash3`
|
|
@@ -474,7 +475,7 @@ Related:
|
|
|
474
475
|
|
|
475
476
|
### Raymarching
|
|
476
477
|
|
|
477
|
-
[/src/raymarch](https://
|
|
478
|
+
[/src/raymarch](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/raymarch/)
|
|
478
479
|
|
|
479
480
|
- `raymarchAO`
|
|
480
481
|
- `raymarchDir`
|
|
@@ -484,13 +485,13 @@ Related:
|
|
|
484
485
|
|
|
485
486
|
### Screen coordinates
|
|
486
487
|
|
|
487
|
-
[/src/screen](https://
|
|
488
|
+
[/src/screen](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/screen/)
|
|
488
489
|
|
|
489
490
|
- `aspectCorrectedUV`
|
|
490
491
|
|
|
491
492
|
### Signed Distance Fields
|
|
492
493
|
|
|
493
|
-
[/src/sdf](https://
|
|
494
|
+
[/src/sdf](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/sdf/)
|
|
494
495
|
|
|
495
496
|
#### Primitives
|
|
496
497
|
|
|
@@ -535,7 +536,7 @@ Related:
|
|
|
535
536
|
|
|
536
537
|
### Texture lookups
|
|
537
538
|
|
|
538
|
-
[/src/tex](https://
|
|
539
|
+
[/src/tex](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/tex/)
|
|
539
540
|
|
|
540
541
|
- `indexToCoord` / `coordToIndex`
|
|
541
542
|
- `indexToUV` / `uvToIndex`
|
|
@@ -544,7 +545,7 @@ Related:
|
|
|
544
545
|
|
|
545
546
|
### Visualization
|
|
546
547
|
|
|
547
|
-
[/src/viz](https://
|
|
548
|
+
[/src/viz](https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/shader-ast-stdlib/src/viz/)
|
|
548
549
|
|
|
549
550
|
- `functionDomainMapper`
|
|
550
551
|
- `functionSampler`
|
|
@@ -10,7 +10,7 @@ import { type FloatTerm, type Vec3Term } from "@thi.ng/shader-ast";
|
|
|
10
10
|
* References:
|
|
11
11
|
*
|
|
12
12
|
* - https://iquilezles.org/articles/palettes/
|
|
13
|
-
* - https://
|
|
13
|
+
* - https://codeberg.org/thi.ng/umbrella/src/branch/develop/packages/color#cosine-gradients
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```ts
|
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.65",
|
|
4
4
|
"description": "Function collection for modular GPGPU / shader programming with @thi.ng/shader-ast",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://
|
|
11
|
+
"url": "git+https://codeberg.org/thi.ng/umbrella.git",
|
|
12
12
|
"directory": "packages/shader-ast-stdlib"
|
|
13
13
|
},
|
|
14
14
|
"homepage": "https://thi.ng/shader-ast-stdlib",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@thi.ng/api": "^8.12.
|
|
47
|
-
"@thi.ng/shader-ast": "^1.1.
|
|
46
|
+
"@thi.ng/api": "^8.12.19",
|
|
47
|
+
"@thi.ng/shader-ast": "^1.1.46"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"esbuild": "^0.
|
|
51
|
-
"typedoc": "^0.28.
|
|
50
|
+
"esbuild": "^0.28.0",
|
|
51
|
+
"typedoc": "^0.28.18",
|
|
52
52
|
"typescript": "^5.9.3"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|
|
@@ -376,5 +376,5 @@
|
|
|
376
376
|
],
|
|
377
377
|
"year": 2019
|
|
378
378
|
},
|
|
379
|
-
"gitHead": "
|
|
379
|
+
"gitHead": "a780d4a5f6f5fc595c9d28527686f63534927d32"
|
|
380
380
|
}
|