@thi.ng/webgl 6.6.25 → 6.6.27
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 +7 -1
- package/README.md +11 -1
- package/material.js +4 -3
- package/multipass.js +4 -8
- package/package.json +21 -21
- package/shaders/lambert.js +17 -16
- package/shaders/phong.js +18 -17
- package/shaders/pipeline.js +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-02-10T08:59:57Z
|
|
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
|
+
### [6.6.26](https://github.com/thi-ng/umbrella/tree/@thi.ng/webgl@6.6.26) (2024-02-06)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- use shader type consts ([e9f8c4c](https://github.com/thi-ng/umbrella/commit/e9f8c4c))
|
|
17
|
+
|
|
12
18
|
### [6.6.6](https://github.com/thi-ng/umbrella/tree/@thi.ng/webgl@6.6.6) (2023-11-09)
|
|
13
19
|
|
|
14
20
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
<!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> ‼️ Announcing the thi.ng user survey 2024 📋
|
|
5
|
+
>
|
|
6
|
+
> [Please participate in the survey here!](https://forms.gle/XacbSDEmQMPZg8197)\
|
|
7
|
+
> (open until end of February)
|
|
8
|
+
>
|
|
9
|
+
> **To achieve a better sample size, I'd highly appreciate if you could
|
|
10
|
+
> circulate the link to this survey in your own networks.**
|
|
11
|
+
>
|
|
12
|
+
> [Discussion](https://github.com/thi-ng/umbrella/discussions/447)
|
|
3
13
|
|
|
4
14
|
# 
|
|
5
15
|
|
|
@@ -101,7 +111,7 @@ For Node.js REPL:
|
|
|
101
111
|
const webgl = await import("@thi.ng/webgl");
|
|
102
112
|
```
|
|
103
113
|
|
|
104
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 11.
|
|
114
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 11.53 KB
|
|
105
115
|
|
|
106
116
|
## Dependencies
|
|
107
117
|
|
package/material.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { V3 } from "@thi.ng/shader-ast/api/types";
|
|
1
2
|
const DEFAULT_MATERIAL = {
|
|
2
3
|
ambientCol: [0.1, 0.1, 0.1],
|
|
3
4
|
diffuseCol: [0.8, 0.8, 0.8],
|
|
4
5
|
specularCol: [1, 1, 1]
|
|
5
6
|
};
|
|
6
7
|
const TYPES = {
|
|
7
|
-
ambientCol:
|
|
8
|
-
diffuseCol:
|
|
9
|
-
specularCol:
|
|
8
|
+
ambientCol: V3,
|
|
9
|
+
diffuseCol: V3,
|
|
10
|
+
specularCol: V3
|
|
10
11
|
};
|
|
11
12
|
const defMaterial = (mat = {}, flags = {}, base = DEFAULT_MATERIAL) => Object.keys(base).reduce((acc, id) => {
|
|
12
13
|
flags[id] !== false && (acc[id] = [TYPES[id], mat[id] || base[id]]);
|
package/multipass.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assert } from "@thi.ng/errors/assert";
|
|
2
|
+
import { S2D, V2, V4 } from "@thi.ng/shader-ast/api/types";
|
|
2
3
|
import { assign } from "@thi.ng/shader-ast/ast/assign";
|
|
3
4
|
import { defMain } from "@thi.ng/shader-ast/ast/function";
|
|
4
5
|
import { INT0, ivec2 } from "@thi.ng/shader-ast/ast/lit";
|
|
@@ -95,25 +96,20 @@ const initShader = (gl, pass, textures) => {
|
|
|
95
96
|
vs: pass.vs || PASSTHROUGH_VS,
|
|
96
97
|
fs: pass.fs,
|
|
97
98
|
attribs: pass.attribs || {
|
|
98
|
-
position:
|
|
99
|
+
position: V2
|
|
99
100
|
},
|
|
100
101
|
varying: pass.varying,
|
|
101
102
|
uniforms: {
|
|
102
103
|
...pass.uniforms,
|
|
103
104
|
...transduce(
|
|
104
|
-
map(
|
|
105
|
-
(i) => [`input${i}`, ["sampler2D", i]]
|
|
106
|
-
),
|
|
105
|
+
map((i) => [`input${i}`, [S2D, i]]),
|
|
107
106
|
assocObj(),
|
|
108
107
|
range(numIns)
|
|
109
108
|
)
|
|
110
109
|
},
|
|
111
110
|
outputs: numOuts ? transduce(
|
|
112
111
|
map(
|
|
113
|
-
(i) => [
|
|
114
|
-
`output${i}`,
|
|
115
|
-
["vec4", i]
|
|
116
|
-
]
|
|
112
|
+
(i) => [`output${i}`, [V4, i]]
|
|
117
113
|
),
|
|
118
114
|
assocObj(),
|
|
119
115
|
range(numOuts)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/webgl",
|
|
3
|
-
"version": "6.6.
|
|
3
|
+
"version": "6.6.27",
|
|
4
4
|
"description": "WebGL & GLSL abstraction layer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -39,28 +39,28 @@
|
|
|
39
39
|
"test": "bun test"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@thi.ng/api": "^8.9.
|
|
43
|
-
"@thi.ng/associative": "^6.3.
|
|
44
|
-
"@thi.ng/canvas": "^0.2.
|
|
45
|
-
"@thi.ng/checks": "^3.4.
|
|
46
|
-
"@thi.ng/equiv": "^2.1.
|
|
47
|
-
"@thi.ng/errors": "^2.4.
|
|
48
|
-
"@thi.ng/logger": "^2.1.
|
|
49
|
-
"@thi.ng/matrices": "^2.3.
|
|
50
|
-
"@thi.ng/memoize": "^3.1.
|
|
51
|
-
"@thi.ng/pixel": "^6.1.
|
|
52
|
-
"@thi.ng/shader-ast": "^0.13.
|
|
53
|
-
"@thi.ng/shader-ast-glsl": "^0.4.
|
|
54
|
-
"@thi.ng/shader-ast-stdlib": "^0.16.
|
|
55
|
-
"@thi.ng/transducers": "^8.
|
|
56
|
-
"@thi.ng/vector-pools": "^3.1.
|
|
57
|
-
"@thi.ng/vectors": "^7.10.
|
|
42
|
+
"@thi.ng/api": "^8.9.23",
|
|
43
|
+
"@thi.ng/associative": "^6.3.37",
|
|
44
|
+
"@thi.ng/canvas": "^0.2.5",
|
|
45
|
+
"@thi.ng/checks": "^3.4.23",
|
|
46
|
+
"@thi.ng/equiv": "^2.1.47",
|
|
47
|
+
"@thi.ng/errors": "^2.4.16",
|
|
48
|
+
"@thi.ng/logger": "^2.1.10",
|
|
49
|
+
"@thi.ng/matrices": "^2.3.12",
|
|
50
|
+
"@thi.ng/memoize": "^3.1.57",
|
|
51
|
+
"@thi.ng/pixel": "^6.1.6",
|
|
52
|
+
"@thi.ng/shader-ast": "^0.13.8",
|
|
53
|
+
"@thi.ng/shader-ast-glsl": "^0.4.98",
|
|
54
|
+
"@thi.ng/shader-ast-stdlib": "^0.16.23",
|
|
55
|
+
"@thi.ng/transducers": "^8.9.1",
|
|
56
|
+
"@thi.ng/vector-pools": "^3.1.104",
|
|
57
|
+
"@thi.ng/vectors": "^7.10.6"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@microsoft/api-extractor": "^7.
|
|
61
|
-
"esbuild": "^0.
|
|
60
|
+
"@microsoft/api-extractor": "^7.40.1",
|
|
61
|
+
"esbuild": "^0.20.0",
|
|
62
62
|
"rimraf": "^5.0.5",
|
|
63
|
-
"typedoc": "^0.25.
|
|
63
|
+
"typedoc": "^0.25.7",
|
|
64
64
|
"typescript": "^5.3.3"
|
|
65
65
|
},
|
|
66
66
|
"keywords": [
|
|
@@ -219,5 +219,5 @@
|
|
|
219
219
|
],
|
|
220
220
|
"year": 2014
|
|
221
221
|
},
|
|
222
|
-
"gitHead": "
|
|
222
|
+
"gitHead": "e5e7d5c6ed2eadee7a91d59cbd0c86ce880ab1c5\n"
|
|
223
223
|
}
|
package/shaders/lambert.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from "@thi.ng/shader-ast-stdlib/light/lambert";
|
|
6
6
|
import { transformMVP } from "@thi.ng/shader-ast-stdlib/matrix/mvp";
|
|
7
7
|
import { surfaceNormal } from "@thi.ng/shader-ast-stdlib/matrix/normal";
|
|
8
|
+
import { M4, S2D, V2, V3 } from "@thi.ng/shader-ast/api/types";
|
|
8
9
|
import { assign } from "@thi.ng/shader-ast/ast/assign";
|
|
9
10
|
import { defMain } from "@thi.ng/shader-ast/ast/function";
|
|
10
11
|
import { vec4 } from "@thi.ng/shader-ast/ast/lit";
|
|
@@ -56,30 +57,30 @@ const LAMBERT = (opts = {}) => ({
|
|
|
56
57
|
],
|
|
57
58
|
// pre: ALIAS_TEXTURE,
|
|
58
59
|
attribs: {
|
|
59
|
-
position:
|
|
60
|
-
normal:
|
|
61
|
-
...opts.uv ? { [opts.uv]:
|
|
62
|
-
...opts.color && !opts.instanceColor ? { [opts.color]:
|
|
63
|
-
...opts.instancePos ? { [opts.instancePos]:
|
|
64
|
-
...opts.instanceColor ? { [opts.instanceColor]:
|
|
60
|
+
position: V3,
|
|
61
|
+
normal: V3,
|
|
62
|
+
...opts.uv ? { [opts.uv]: V2 } : null,
|
|
63
|
+
...opts.color && !opts.instanceColor ? { [opts.color]: V3 } : null,
|
|
64
|
+
...opts.instancePos ? { [opts.instancePos]: V3 } : null,
|
|
65
|
+
...opts.instanceColor ? { [opts.instanceColor]: V3 } : null
|
|
65
66
|
},
|
|
66
67
|
varying: {
|
|
67
|
-
vcolor:
|
|
68
|
-
vnormal:
|
|
69
|
-
...opts.uv ? { vuv:
|
|
68
|
+
vcolor: V3,
|
|
69
|
+
vnormal: V3,
|
|
70
|
+
...opts.uv ? { vuv: V2 } : null
|
|
70
71
|
},
|
|
71
72
|
uniforms: {
|
|
72
|
-
model:
|
|
73
|
-
view:
|
|
74
|
-
proj:
|
|
75
|
-
normalMat: [
|
|
76
|
-
lightDir: [
|
|
77
|
-
lightCol: [
|
|
73
|
+
model: M4,
|
|
74
|
+
view: M4,
|
|
75
|
+
proj: M4,
|
|
76
|
+
normalMat: [M4, autoNormalMatrix2()],
|
|
77
|
+
lightDir: [V3, [0, 1, 0]],
|
|
78
|
+
lightCol: [V3, [1, 1, 1]],
|
|
78
79
|
...defMaterial(
|
|
79
80
|
{ diffuseCol: [1, 1, 1], ...opts.material },
|
|
80
81
|
{ specularCol: false }
|
|
81
82
|
),
|
|
82
|
-
...opts.uv ? { tex:
|
|
83
|
+
...opts.uv ? { tex: S2D } : null
|
|
83
84
|
},
|
|
84
85
|
state: {
|
|
85
86
|
depth: true,
|
package/shaders/phong.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { F, M4, V3 } from "@thi.ng/shader-ast/api/types";
|
|
1
2
|
import { diffuseLighting } from "@thi.ng/shader-ast-stdlib/light/lambert";
|
|
2
3
|
import { surfaceNormal } from "@thi.ng/shader-ast-stdlib/matrix/normal";
|
|
3
4
|
import { assign } from "@thi.ng/shader-ast/ast/assign";
|
|
@@ -72,27 +73,27 @@ const PHONG = (opts = {}) => ({
|
|
|
72
73
|
})
|
|
73
74
|
],
|
|
74
75
|
attribs: {
|
|
75
|
-
position:
|
|
76
|
-
normal:
|
|
77
|
-
...opts.color && !opts.instanceColor ? { [opts.color]:
|
|
78
|
-
...opts.instancePos ? { [opts.instancePos]:
|
|
79
|
-
...opts.instanceColor ? { [opts.instanceColor]:
|
|
76
|
+
position: V3,
|
|
77
|
+
normal: V3,
|
|
78
|
+
...opts.color && !opts.instanceColor ? { [opts.color]: V3 } : null,
|
|
79
|
+
...opts.instancePos ? { [opts.instancePos]: V3 } : null,
|
|
80
|
+
...opts.instanceColor ? { [opts.instanceColor]: V3 } : null
|
|
80
81
|
},
|
|
81
82
|
varying: {
|
|
82
|
-
vnormal:
|
|
83
|
-
veye:
|
|
84
|
-
vlight:
|
|
85
|
-
vcolor:
|
|
83
|
+
vnormal: V3,
|
|
84
|
+
veye: V3,
|
|
85
|
+
vlight: V3,
|
|
86
|
+
vcolor: V3
|
|
86
87
|
},
|
|
87
88
|
uniforms: {
|
|
88
|
-
model:
|
|
89
|
-
normalMat: [
|
|
90
|
-
view:
|
|
91
|
-
proj:
|
|
92
|
-
shininess: [
|
|
93
|
-
eyePos:
|
|
94
|
-
lightPos: [
|
|
95
|
-
lightCol: [
|
|
89
|
+
model: M4,
|
|
90
|
+
normalMat: [M4, autoNormalMatrix1()],
|
|
91
|
+
view: M4,
|
|
92
|
+
proj: M4,
|
|
93
|
+
shininess: [F, 32],
|
|
94
|
+
eyePos: V3,
|
|
95
|
+
lightPos: [V3, [0, 0, 2]],
|
|
96
|
+
lightCol: [V3, [1, 1, 1]],
|
|
96
97
|
...defMaterial(opts.material)
|
|
97
98
|
},
|
|
98
99
|
state: {
|
package/shaders/pipeline.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { S2D, V2 } from "@thi.ng/shader-ast/api/types";
|
|
1
2
|
import { assign } from "@thi.ng/shader-ast/ast/assign";
|
|
2
3
|
import { defMain } from "@thi.ng/shader-ast/ast/function";
|
|
3
4
|
import { FLOAT0, FLOAT1, vec4 } from "@thi.ng/shader-ast/ast/lit";
|
|
@@ -21,7 +22,7 @@ const PASSTHROUGH_FS_UV = (_, unis, ins, outs) => [
|
|
|
21
22
|
const FX_SHADER_SPEC = {
|
|
22
23
|
vs: PASSTHROUGH_VS,
|
|
23
24
|
fs: PASSTHROUGH_FS,
|
|
24
|
-
attribs: { position:
|
|
25
|
+
attribs: { position: V2 },
|
|
25
26
|
varying: {},
|
|
26
27
|
uniforms: {},
|
|
27
28
|
state: { depth: false },
|
|
@@ -30,9 +31,9 @@ const FX_SHADER_SPEC = {
|
|
|
30
31
|
const FX_SHADER_SPEC_UV = {
|
|
31
32
|
vs: PASSTHROUGH_VS_UV,
|
|
32
33
|
fs: PASSTHROUGH_FS_UV,
|
|
33
|
-
attribs: { position:
|
|
34
|
-
varying: { v_uv:
|
|
35
|
-
uniforms: { tex:
|
|
34
|
+
attribs: { position: V2, uv: V2 },
|
|
35
|
+
varying: { v_uv: V2 },
|
|
36
|
+
uniforms: { tex: S2D },
|
|
36
37
|
state: { depth: false },
|
|
37
38
|
ext: {}
|
|
38
39
|
};
|