@margoengine/shader 0.1.0 → 1.0.0
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/LICENSE +201 -201
- package/NOTICE +4 -4
- package/README.md +1920 -1771
- package/dist/attribute.d.ts +28 -0
- package/dist/black-hole.js +3 -3
- package/dist/clock-BLGNexlt.js +3 -3
- package/dist/{compute-D-BghbXj.js → compute-CXGG9qvI.js} +76 -70
- package/dist/compute-texture.js +3 -3
- package/dist/compute-volume.js +3 -3
- package/dist/compute.d.ts +8 -2
- package/dist/{control-DvjfV7R0.js → control-CFjkGPBk.js} +1 -1
- package/dist/deform.js +2 -2
- package/dist/editor-pass.js +17 -17
- package/dist/effects.js +2 -2
- package/dist/glsl-material.js +2 -2
- package/dist/glsl-pass.js +5 -5
- package/dist/glsl.js +18 -18
- package/dist/gpu-DQJk2xAv.js +55 -0
- package/dist/graph.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +103 -8
- package/dist/{lighting-Dx8_RsBz.js → lighting-JU9yQPfM.js} +2 -2
- package/dist/lighting.js +1 -1
- package/dist/{material-CU7p-Q8u.js → material-C6bpqlnE.js} +1 -1
- package/dist/{material-REzUrXtu.js → material-CZ8V1FeA.js} +95 -71
- package/dist/material.d.ts +9 -4
- package/dist/{node-DzKv9CF2.js → node-B6yoIC9V.js} +126 -126
- package/dist/node.d.ts +7 -1
- package/dist/noise.js +1 -1
- package/dist/pass.d.ts +1 -0
- package/dist/pass.js +24 -21
- package/dist/{post-DC62ZleD.js → post-DLpZ110L.js} +17 -17
- package/dist/{raw-D0W8U3Qa.js → raw-0AYej3Ak.js} +422 -273
- package/dist/raw.d.ts +125 -15
- package/dist/raw.js +1 -1
- package/dist/readback.js +13 -12
- package/dist/serialization.js +12 -12
- package/dist/shadertoy.js +6 -6
- package/dist/shared/caster.d.ts +159 -152
- package/dist/shared/fog.d.ts +33 -33
- package/dist/shared/fractal.d.ts +9 -9
- package/dist/shared/msaa.d.ts +30 -25
- package/dist/shared/stack.d.ts +22 -22
- package/dist/subgroups.js +4 -4
- package/dist/{texture-D6vy0bam.js → texture-BawKO_h9.js} +1 -1
- package/dist/texture-array.js +2 -2
- package/dist/utils.js +32 -32
- package/package.json +151 -151
- package/dist/gpu-DQ5Jmggz.js +0 -31
package/dist/utils.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { A as e, D as t, Et as n, Gt as r, I as i, Kt as a, L as o, R as s, T as c, Tt as l, Vt as u, W as d, Wt as f, Yt as p, Zt as m, _ as h, b as ee, bt as g, cn as _, dt as v, ft as y, ht as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { A as e, D as t, Et as n, Gt as r, I as i, Kt as a, L as o, R as s, T as c, Tt as l, Vt as u, W as d, Wt as f, Yt as p, Zt as m, _ as h, b as ee, bt as g, cn as _, dt as v, ft as y, ht as b, j as x, m as te, nn as S, o as C, p as w, pn as T, sn as E, ut as D, v as O, xt as k, yt as A, z as j, zt as M } from "./node-B6yoIC9V.js";
|
|
2
|
+
import { a as ne, i as re, r as ie, s as N, t as ae, u as oe } from "./control-CFjkGPBk.js";
|
|
3
|
+
import { n as P } from "./texture-BawKO_h9.js";
|
|
4
4
|
//#region ../shared/tangent-frame.js
|
|
5
|
-
var F = "fn margoCotangentFrame(n:vec3f,dp1:vec3f,dp2:vec3f,duv1:vec2f,duv2:vec2f)->mat3x3f {\n let ps=max(max(max(abs(dp1.x),abs(dp1.y)),max(abs(dp1.z),abs(dp2.x))),max(abs(dp2.y),abs(dp2.z)));\n let us=max(max(abs(duv1.x),abs(duv1.y)),max(abs(duv2.x),abs(duv2.y)));\n if(ps>0.0&&us>0.0){\n let q1=dp1/ps;let q2=dp2/ps;let w1=duv1/us;let w2=duv2/us;\n let r1=cross(q2,n);let r2=cross(n,q1);let side=select(-1.0,1.0,dot(q1,r1)>=0.0);\n let gu=(r1*w1.x+r2*w2.x)*side;let gv=(r1*w1.y+r2*w2.y)*(-side);\n let longest=max(dot(gu,gu),dot(gv,gv));\n if(longest>1e-30){let k=inverseSqrt(longest);return mat3x3f(gu*k,gv*k,n);}\n }\n let axis=select(vec3f(1,0,0),vec3f(0,0,1),abs(n.x)>0.5);let t=normalize(axis-n*dot(n,axis));\n return mat3x3f(t,cross(n,t),n);\n}\n", I = () =>
|
|
5
|
+
var F = "fn margoCotangentFrame(n:vec3f,dp1:vec3f,dp2:vec3f,duv1:vec2f,duv2:vec2f)->mat3x3f {\n let ps=max(max(max(abs(dp1.x),abs(dp1.y)),max(abs(dp1.z),abs(dp2.x))),max(abs(dp2.y),abs(dp2.z)));\n let us=max(max(abs(duv1.x),abs(duv1.y)),max(abs(duv2.x),abs(duv2.y)));\n if(ps>0.0&&us>0.0){\n let q1=dp1/ps;let q2=dp2/ps;let w1=duv1/us;let w2=duv2/us;\n let r1=cross(q2,n);let r2=cross(n,q1);let side=select(-1.0,1.0,dot(q1,r1)>=0.0);\n let gu=(r1*w1.x+r2*w2.x)*side;let gv=(r1*w1.y+r2*w2.y)*(-side);\n let longest=max(dot(gu,gu),dot(gv,gv));\n if(longest>1e-30){let k=inverseSqrt(longest);return mat3x3f(gu*k,gv*k,n);}\n }\n let axis=select(vec3f(1,0,0),vec3f(0,0,1),abs(n.x)>0.5);let t=normalize(axis-n*dot(n,axis));\n return mat3x3f(t,cross(n,t),n);\n}\n", I = () => M(ee("frontFacing", "bool"), g, g.negate());
|
|
6
6
|
function L(e, t) {
|
|
7
7
|
let r = n;
|
|
8
|
-
return new
|
|
8
|
+
return new C("mat3x3f", "zcotangent", [
|
|
9
9
|
e,
|
|
10
10
|
s(r),
|
|
11
|
-
|
|
11
|
+
j(r),
|
|
12
12
|
s(t),
|
|
13
|
-
|
|
13
|
+
j(t)
|
|
14
14
|
], (e, t) => (e.declare("utils:cotangent", F.replace("margoCotangentFrame", "nodeCotangentFrame")), `nodeCotangentFrame(${t.args.map((t) => e.expr(t)).join(", ")})`));
|
|
15
15
|
}
|
|
16
16
|
function R(e, t, n) {
|
|
@@ -18,7 +18,7 @@ function R(e, t, n) {
|
|
|
18
18
|
let r = I();
|
|
19
19
|
if (e === "tangents") return [
|
|
20
20
|
p,
|
|
21
|
-
|
|
21
|
+
O,
|
|
22
22
|
r
|
|
23
23
|
];
|
|
24
24
|
let i = L(r, t), a = i.element(1);
|
|
@@ -29,56 +29,56 @@ function R(e, t, n) {
|
|
|
29
29
|
];
|
|
30
30
|
}
|
|
31
31
|
function z(e, t = {}) {
|
|
32
|
-
let { strength: n = 1, frame: r, coord: i =
|
|
33
|
-
return
|
|
32
|
+
let { strength: n = 1, frame: r, coord: i = S(), flipY: a = !0 } = t, [o, s, l] = R(r, c(i, "vec2f", "normalMap coord"), a), u = c(e, "vec3f", "normalMap value").mul(2).sub(1), d = u.xy.mul(c(n, "f32", "normalMap strength"));
|
|
33
|
+
return k(o.mul(d.x).add(s.mul(d.y)).add(l.mul(u.z)));
|
|
34
34
|
}
|
|
35
35
|
function B(e, t = {}) {
|
|
36
|
-
let { strength: r = 1, normal: i = I() } = t, a = c(e, "f32", "bumpNormal height").mul(c(r, "f32", "bumpNormal strength")), l = s(n), u =
|
|
37
|
-
return
|
|
36
|
+
let { strength: r = 1, normal: i = I() } = t, a = c(e, "f32", "bumpNormal height").mul(c(r, "f32", "bumpNormal strength")), l = s(n), u = j(n), d = x(u, i), f = x(i, l), p = o(l, d), m = M(p.lessThan(0), -1, 1), h = d.mul(s(a)).add(f.mul(j(a))).mul(m);
|
|
37
|
+
return k(i.mul(p.abs()).sub(h));
|
|
38
38
|
}
|
|
39
39
|
function V(e, t = {}) {
|
|
40
|
-
let { position: r = n, normal: i = g, scale: a = 1, sharpness: o = 4 } = t, s = typeof e == "function" ? e : (t) =>
|
|
40
|
+
let { position: r = n, normal: i = g, scale: a = 1, sharpness: o = 4 } = t, s = typeof e == "function" ? e : (t) => P(e, t), l = c(r, "vec3f", "triplanar position").mul(c(a, "f32", "triplanar scale")), u = c(i, "vec3f", "triplanar normal").abs().pow(c(o, "f32", "triplanar sharpness")), d = u.div(u.x.add(u.y).add(u.z));
|
|
41
41
|
return s(l.zy).mul(d.x).add(s(l.xz).mul(d.y)).add(s(l.xy).mul(d.z));
|
|
42
42
|
}
|
|
43
43
|
function H(e, t = {}) {
|
|
44
|
-
let { coord: n =
|
|
44
|
+
let { coord: n = S(), scale: r = .05, steps: i = 16, frame: a } = t;
|
|
45
45
|
if (!Number.isInteger(i) || i < 1 || i > 256) throw RangeError(`parallaxUV steps must be a whole number from 1 to 256, got ${String(i)}`);
|
|
46
|
-
let s = c(n, "vec2f", "parallaxUV coord"), l = typeof e == "function" ? e : (t) =>
|
|
47
|
-
return i === 1 ? s.sub(p.mul(l(s).oneMinus())) :
|
|
48
|
-
let e =
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
let s = c(n, "vec2f", "parallaxUV coord"), l = typeof e == "function" ? e : (t) => P(e, t, 0).r, [u, d, f] = R(a, s, !0), p = E(o(T, u), o(T, d)).div(D(o(T, f), .1)).mul(c(r, "f32", "parallaxUV scale"));
|
|
47
|
+
return i === 1 ? s.sub(p.mul(l(s).oneMinus())) : oe(() => {
|
|
48
|
+
let e = re(p), t = N(0), n = N(0), r = N(s), a = N(s), o = N(l(s).oneMinus()), c = N(o);
|
|
49
|
+
ne(i, () => {
|
|
50
|
+
ie(t.greaterThanEqual(o), () => ae()), a.assign(r), n.assign(t), c.assign(o), t.addAssign(1 / i), r.assign(s.sub(e.mul(t))), o.assign(l(r).oneMinus());
|
|
51
51
|
});
|
|
52
52
|
let u = c.sub(n), d = u.add(t.sub(o));
|
|
53
|
-
return y(a, r,
|
|
53
|
+
return y(a, r, M(d.lessThan(1e-6), 1, u.div(d).saturate()));
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
function U(t, n, r = .5) {
|
|
57
57
|
let i = c(n, "f32", "rotateUV angle"), a = c(r, "vec2f", "rotateUV center"), o = c(t, "vec2f", "rotateUV coord").sub(a), s = u(i), l = e(i);
|
|
58
|
-
return
|
|
58
|
+
return E(o.x.mul(l).sub(o.y.mul(s)), o.x.mul(s).add(o.y.mul(l))).add(a);
|
|
59
59
|
}
|
|
60
60
|
function W(t, n, r) {
|
|
61
61
|
let i = c(r, "f32", "rotateAxis angle"), a = c(n, "vec3f", "rotateAxis axis"), s = c(t, "vec3f", "rotateAxis value"), l = e(i);
|
|
62
|
-
return s.mul(l).add(
|
|
62
|
+
return s.mul(l).add(x(a, s).mul(u(i))).add(a.mul(o(a, s)).mul(l.oneMinus()));
|
|
63
63
|
}
|
|
64
|
-
function G(e =
|
|
65
|
-
let n =
|
|
66
|
-
return
|
|
64
|
+
function G(e = A, t = l) {
|
|
65
|
+
let n = k(c(t, "vec3f", "matcapUV position").negate()), r = c(e, "vec3f", "matcapUV normal"), i = _(n.z, 0, n.x.negate()), a = o(i, i), s = a.greaterThan(1e-10), u = M(s, i.mul(D(a, 1e-10).inverseSqrt()), _(1, 0, 0)), d = M(s, x(n, u), _(0, 1, 0));
|
|
66
|
+
return E(o(r, u), o(r, d)).mul(.49).add(.5);
|
|
67
67
|
}
|
|
68
68
|
function K(e, n = {}) {
|
|
69
|
-
let r = c(e, "vec3f", "equirectUV direction"), i =
|
|
70
|
-
return
|
|
69
|
+
let r = c(e, "vec3f", "equirectUV direction"), i = M(r.x.equal(0), 0, r.x), a = M(r.z.equal(0), M(r.x.equal(0), 1, 0), r.z.negate()), o = w(t(r.y, -1, 1)).div(Math.PI);
|
|
70
|
+
return E(h(i, a).div(Math.PI * 2).add(.5), n.flipY ?? !0 ? o.oneMinus() : o);
|
|
71
71
|
}
|
|
72
72
|
var q = (e) => o(e, _(.2126, .7152, .0722)), se = (e, t) => y(q(e).xxx, e, c(t, "f32", "saturation amount").xxx), ce = (e, t) => W(e, _(Math.sqrt(1 / 3)), t), J = (e) => (t, n, r = 1) => {
|
|
73
73
|
let i = c(t, "vec3f", "blend base"), a = e(i, c(n, "vec3f", "blend top"));
|
|
74
74
|
return r === 1 ? a : y(i, a, c(r, "f32", "blend opacity").xxx);
|
|
75
75
|
}, Y = (e, t) => {
|
|
76
76
|
let n = t.mul(2).sub(1);
|
|
77
|
-
return
|
|
78
|
-
}, le = /*@__PURE__*/ J((e, t) => v(e.add(t), 1)), ue = /*@__PURE__*/ J((e, t) =>
|
|
79
|
-
let n =
|
|
80
|
-
return
|
|
81
|
-
}), Se =
|
|
77
|
+
return M(t.lessThanEqual(.5), t.mul(2).mul(e), e.add(n).sub(e.mul(n)));
|
|
78
|
+
}, le = /*@__PURE__*/ J((e, t) => v(e.add(t), 1)), ue = /*@__PURE__*/ J((e, t) => D(e.sub(t), 0)), de = /*@__PURE__*/ J((e, t) => e.mul(t)), fe = /*@__PURE__*/ J((e, t) => e.add(t).sub(e.mul(t))), pe = /*@__PURE__*/ J((e, t) => Y(t, e)), me = /*@__PURE__*/ J(Y), he = /*@__PURE__*/ J((e, t) => v(e, t)), ge = /*@__PURE__*/ J((e, t) => D(e, t)), _e = /*@__PURE__*/ J((e, t) => e.sub(t).abs()), ve = /*@__PURE__*/ J((e, t) => e.add(t).sub(e.mul(t).mul(2))), ye = /*@__PURE__*/ J((e, t) => M(e.lessThanEqual(0), _(0), M(t.greaterThanEqual(1), _(1), v(e.div(D(t.oneMinus(), 1e-6)), 1)))), be = /*@__PURE__*/ J((e, t) => M(e.greaterThanEqual(1), _(1), M(t.lessThanEqual(0), _(0), v(e.oneMinus().div(D(t, 1e-6)), 1).oneMinus()))), xe = /*@__PURE__*/ J((e, t) => {
|
|
79
|
+
let n = M(e.lessThanEqual(.25), e.mul(16).sub(12).mul(e).add(4).mul(e), f(e)), r = e.sub(t.mul(-2).add(1).mul(e).mul(e.oneMinus())), i = e.add(t.mul(2).sub(1).mul(n.sub(e)));
|
|
80
|
+
return M(t.lessThanEqual(.5), r, i);
|
|
81
|
+
}), Se = te, X = a, Z = b, Ce = i, Q = (e, t, n) => Ce(X(e, t), X(n, t)), $ = (e, t, n) => Se(Z(e, X(n, t)), t);
|
|
82
82
|
function we(e, t, n, r = 0, i = 1) {
|
|
83
83
|
return $(Q(e, t, n), r, i);
|
|
84
84
|
}
|
package/package.json
CHANGED
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@margoengine/shader",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Typed shader nodes that compile to readable WGSL: node materials, node post effects and node compute passes, with a visual node editor.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"margoengine",
|
|
7
|
-
"webgpu",
|
|
8
|
-
"3d",
|
|
9
|
-
"wgsl",
|
|
10
|
-
"node-material"
|
|
11
|
-
],
|
|
12
|
-
"homepage": "https://margoengine.com",
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/scottcampbelldata/margoengine/issues"
|
|
15
|
-
},
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/scottcampbelldata/margoengine.git",
|
|
19
|
-
"directory": "packages/shader"
|
|
20
|
-
},
|
|
21
|
-
"license": "Apache-2.0",
|
|
22
|
-
"author": "Scott Campbell",
|
|
23
|
-
"type": "module",
|
|
24
|
-
"sideEffects": false,
|
|
25
|
-
"exports": {
|
|
26
|
-
".": {
|
|
27
|
-
"types": "./dist/index.d.ts",
|
|
28
|
-
"import": "./dist/index.js"
|
|
29
|
-
},
|
|
30
|
-
"./noise": {
|
|
31
|
-
"types": "./dist/noise.d.ts",
|
|
32
|
-
"import": "./dist/noise.js"
|
|
33
|
-
},
|
|
34
|
-
"./graph": {
|
|
35
|
-
"types": "./dist/graph.d.ts",
|
|
36
|
-
"import": "./dist/graph.js"
|
|
37
|
-
},
|
|
38
|
-
"./readback": {
|
|
39
|
-
"types": "./dist/readback.d.ts",
|
|
40
|
-
"import": "./dist/readback.js"
|
|
41
|
-
},
|
|
42
|
-
"./raw": {
|
|
43
|
-
"types": "./dist/raw.d.ts",
|
|
44
|
-
"import": "./dist/raw.js"
|
|
45
|
-
},
|
|
46
|
-
"./black-hole": {
|
|
47
|
-
"types": "./dist/black-hole.d.ts",
|
|
48
|
-
"import": "./dist/black-hole.js"
|
|
49
|
-
},
|
|
50
|
-
"./effects": {
|
|
51
|
-
"types": "./dist/effects.d.ts",
|
|
52
|
-
"import": "./dist/effects.js"
|
|
53
|
-
},
|
|
54
|
-
"./editor": {
|
|
55
|
-
"types": "./dist/editor.d.ts",
|
|
56
|
-
"import": "./dist/editor.js"
|
|
57
|
-
},
|
|
58
|
-
"./compute-texture": {
|
|
59
|
-
"types": "./dist/compute-texture.d.ts",
|
|
60
|
-
"import": "./dist/compute-texture.js"
|
|
61
|
-
},
|
|
62
|
-
"./lighting": {
|
|
63
|
-
"types": "./dist/lighting.d.ts",
|
|
64
|
-
"import": "./dist/lighting.js"
|
|
65
|
-
},
|
|
66
|
-
"./deform": {
|
|
67
|
-
"types": "./dist/deform.d.ts",
|
|
68
|
-
"import": "./dist/deform.js"
|
|
69
|
-
},
|
|
70
|
-
"./pass": {
|
|
71
|
-
"types": "./dist/pass.d.ts",
|
|
72
|
-
"import": "./dist/pass.js"
|
|
73
|
-
},
|
|
74
|
-
"./utils": {
|
|
75
|
-
"types": "./dist/utils.d.ts",
|
|
76
|
-
"import": "./dist/utils.js"
|
|
77
|
-
},
|
|
78
|
-
"./subgroups": {
|
|
79
|
-
"types": "./dist/subgroups.d.ts",
|
|
80
|
-
"import": "./dist/subgroups.js"
|
|
81
|
-
},
|
|
82
|
-
"./serialization": {
|
|
83
|
-
"types": "./dist/serialization.d.ts",
|
|
84
|
-
"import": "./dist/serialization.js"
|
|
85
|
-
},
|
|
86
|
-
"./compute-volume": {
|
|
87
|
-
"types": "./dist/compute-volume.d.ts",
|
|
88
|
-
"import": "./dist/compute-volume.js"
|
|
89
|
-
},
|
|
90
|
-
"./editor-pass": {
|
|
91
|
-
"types": "./dist/editor-pass.d.ts",
|
|
92
|
-
"import": "./dist/editor-pass.js"
|
|
93
|
-
},
|
|
94
|
-
"./texture-array": {
|
|
95
|
-
"types": "./dist/texture-array.d.ts",
|
|
96
|
-
"import": "./dist/texture-array.js"
|
|
97
|
-
},
|
|
98
|
-
"./glsl": {
|
|
99
|
-
"types": "./dist/glsl.d.ts",
|
|
100
|
-
"import": "./dist/glsl.js"
|
|
101
|
-
},
|
|
102
|
-
"./glsl-material": {
|
|
103
|
-
"types": "./dist/glsl-material.d.ts",
|
|
104
|
-
"import": "./dist/glsl-material.js"
|
|
105
|
-
},
|
|
106
|
-
"./glsl-pass": {
|
|
107
|
-
"types": "./dist/glsl-pass.d.ts",
|
|
108
|
-
"import": "./dist/glsl-pass.js"
|
|
109
|
-
},
|
|
110
|
-
"./shadertoy": {
|
|
111
|
-
"types": "./dist/shadertoy.d.ts",
|
|
112
|
-
"import": "./dist/shadertoy.js"
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
"files": [
|
|
116
|
-
"dist",
|
|
117
|
-
"LICENSE",
|
|
118
|
-
"NOTICE"
|
|
119
|
-
],
|
|
120
|
-
"publishConfig": {
|
|
121
|
-
"access": "public"
|
|
122
|
-
},
|
|
123
|
-
"peerDependencies": {
|
|
124
|
-
"@margoengine/core": "^
|
|
125
|
-
"@margoengine/materials": "^
|
|
126
|
-
"@margoengine/gltf": "^
|
|
127
|
-
"@margoengine/post": "^
|
|
128
|
-
},
|
|
129
|
-
"peerDependenciesMeta": {
|
|
130
|
-
"@margoengine/post": {
|
|
131
|
-
"optional": true
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
"dependencies": {
|
|
135
|
-
"@margoengine/math": "^
|
|
136
|
-
},
|
|
137
|
-
"scripts": {
|
|
138
|
-
"build": "node ../../scripts/build-optional.js shader",
|
|
139
|
-
"test": "npm run build && node --test test/*.test.js",
|
|
140
|
-
"prepack": "npm run build",
|
|
141
|
-
"test:gpu": "cd ../.. && node packages/shader/test/browser-check.mjs && node packages/shader/test/noise-check.mjs && node packages/shader/test/readback-check.mjs && node packages/shader/test/editor-check.mjs && node packages/shader/test/compute-texture-check.mjs && node packages/shader/test/compute-model-check.mjs && node packages/shader/test/lighting-check.mjs && node packages/shader/test/passes-check.mjs && node packages/shader/test/inputs-check.mjs && node packages/shader/test/deform-check.mjs && node packages/shader/test/pass-check.mjs && node packages/shader/test/utils-check.mjs && node packages/shader/test/raw-check.mjs && node packages/shader/test/subgroups-check.mjs && node packages/shader/test/scene-owner-browser.mjs && node packages/shader/test/scene-owner-browser.mjs --compat && node packages/shader/test/compute-volume-check.mjs && node packages/shader/test/editor-pass-check.mjs && node packages/shader/test/texture-array-check.mjs && node packages/shader/test/black-hole-check.mjs && node packages/shader/test/negated-division-check.mjs && node packages/shader/test/glsl-check.mjs && node packages/shader/test/glsl-check.mjs --compat && node packages/shader/test/glsl-material-check.mjs && node packages/shader/test/glsl-material-check.mjs --compat && node packages/shader/test/glsl-velocity-check.mjs && node packages/shader/test/glsl-velocity-check.mjs --compat && node packages/shader/test/glsl-pass-check.mjs && node packages/shader/test/glsl-pass-check.mjs --compat && node packages/shader/test/shadertoy-check.mjs && node packages/shader/test/shadertoy-check.mjs --compat && node packages/shader/test/raw-restore-browser-check.mjs && node packages/shader/test/raw-restore-browser-check.mjs --compat && node packages/shader/test/shadertoy-restore-browser-check.mjs && node packages/shader/test/shadertoy-restore-browser-check.mjs --compat",
|
|
142
|
-
"test:gpu:raw": "cd ../.. && node scripts/shader-raw-gpu-check.js",
|
|
143
|
-
"test:gpu:volume": "cd ../.. && node packages/shader/test/compute-volume-check.mjs",
|
|
144
|
-
"test:gpu:editor-pass": "cd ../.. && node packages/shader/test/editor-pass-check.mjs",
|
|
145
|
-
"test:gpu:texture-array": "cd ../.. && node packages/shader/test/texture-array-check.mjs",
|
|
146
|
-
"test:gpu:glsl": "cd ../.. && node packages/shader/test/glsl-check.mjs && node packages/shader/test/glsl-check.mjs --compat",
|
|
147
|
-
"test:gpu:glsl-material": "cd ../.. && node packages/shader/test/glsl-material-check.mjs && node packages/shader/test/glsl-material-check.mjs --compat && node packages/shader/test/glsl-velocity-check.mjs && node packages/shader/test/glsl-velocity-check.mjs --compat",
|
|
148
|
-
"test:gpu:glsl-pass": "cd ../.. && node packages/shader/test/glsl-pass-check.mjs && node packages/shader/test/glsl-pass-check.mjs --compat",
|
|
149
|
-
"test:gpu:shadertoy": "cd ../.. && node packages/shader/test/shadertoy-check.mjs && node packages/shader/test/shadertoy-check.mjs --compat"
|
|
150
|
-
}
|
|
151
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@margoengine/shader",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Typed shader nodes that compile to readable WGSL: node materials, node post effects and node compute passes, with a visual node editor.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"margoengine",
|
|
7
|
+
"webgpu",
|
|
8
|
+
"3d",
|
|
9
|
+
"wgsl",
|
|
10
|
+
"node-material"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://margoengine.com",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/scottcampbelldata/margoengine/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/scottcampbelldata/margoengine.git",
|
|
19
|
+
"directory": "packages/shader"
|
|
20
|
+
},
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"author": "Scott Campbell",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./noise": {
|
|
31
|
+
"types": "./dist/noise.d.ts",
|
|
32
|
+
"import": "./dist/noise.js"
|
|
33
|
+
},
|
|
34
|
+
"./graph": {
|
|
35
|
+
"types": "./dist/graph.d.ts",
|
|
36
|
+
"import": "./dist/graph.js"
|
|
37
|
+
},
|
|
38
|
+
"./readback": {
|
|
39
|
+
"types": "./dist/readback.d.ts",
|
|
40
|
+
"import": "./dist/readback.js"
|
|
41
|
+
},
|
|
42
|
+
"./raw": {
|
|
43
|
+
"types": "./dist/raw.d.ts",
|
|
44
|
+
"import": "./dist/raw.js"
|
|
45
|
+
},
|
|
46
|
+
"./black-hole": {
|
|
47
|
+
"types": "./dist/black-hole.d.ts",
|
|
48
|
+
"import": "./dist/black-hole.js"
|
|
49
|
+
},
|
|
50
|
+
"./effects": {
|
|
51
|
+
"types": "./dist/effects.d.ts",
|
|
52
|
+
"import": "./dist/effects.js"
|
|
53
|
+
},
|
|
54
|
+
"./editor": {
|
|
55
|
+
"types": "./dist/editor.d.ts",
|
|
56
|
+
"import": "./dist/editor.js"
|
|
57
|
+
},
|
|
58
|
+
"./compute-texture": {
|
|
59
|
+
"types": "./dist/compute-texture.d.ts",
|
|
60
|
+
"import": "./dist/compute-texture.js"
|
|
61
|
+
},
|
|
62
|
+
"./lighting": {
|
|
63
|
+
"types": "./dist/lighting.d.ts",
|
|
64
|
+
"import": "./dist/lighting.js"
|
|
65
|
+
},
|
|
66
|
+
"./deform": {
|
|
67
|
+
"types": "./dist/deform.d.ts",
|
|
68
|
+
"import": "./dist/deform.js"
|
|
69
|
+
},
|
|
70
|
+
"./pass": {
|
|
71
|
+
"types": "./dist/pass.d.ts",
|
|
72
|
+
"import": "./dist/pass.js"
|
|
73
|
+
},
|
|
74
|
+
"./utils": {
|
|
75
|
+
"types": "./dist/utils.d.ts",
|
|
76
|
+
"import": "./dist/utils.js"
|
|
77
|
+
},
|
|
78
|
+
"./subgroups": {
|
|
79
|
+
"types": "./dist/subgroups.d.ts",
|
|
80
|
+
"import": "./dist/subgroups.js"
|
|
81
|
+
},
|
|
82
|
+
"./serialization": {
|
|
83
|
+
"types": "./dist/serialization.d.ts",
|
|
84
|
+
"import": "./dist/serialization.js"
|
|
85
|
+
},
|
|
86
|
+
"./compute-volume": {
|
|
87
|
+
"types": "./dist/compute-volume.d.ts",
|
|
88
|
+
"import": "./dist/compute-volume.js"
|
|
89
|
+
},
|
|
90
|
+
"./editor-pass": {
|
|
91
|
+
"types": "./dist/editor-pass.d.ts",
|
|
92
|
+
"import": "./dist/editor-pass.js"
|
|
93
|
+
},
|
|
94
|
+
"./texture-array": {
|
|
95
|
+
"types": "./dist/texture-array.d.ts",
|
|
96
|
+
"import": "./dist/texture-array.js"
|
|
97
|
+
},
|
|
98
|
+
"./glsl": {
|
|
99
|
+
"types": "./dist/glsl.d.ts",
|
|
100
|
+
"import": "./dist/glsl.js"
|
|
101
|
+
},
|
|
102
|
+
"./glsl-material": {
|
|
103
|
+
"types": "./dist/glsl-material.d.ts",
|
|
104
|
+
"import": "./dist/glsl-material.js"
|
|
105
|
+
},
|
|
106
|
+
"./glsl-pass": {
|
|
107
|
+
"types": "./dist/glsl-pass.d.ts",
|
|
108
|
+
"import": "./dist/glsl-pass.js"
|
|
109
|
+
},
|
|
110
|
+
"./shadertoy": {
|
|
111
|
+
"types": "./dist/shadertoy.d.ts",
|
|
112
|
+
"import": "./dist/shadertoy.js"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"files": [
|
|
116
|
+
"dist",
|
|
117
|
+
"LICENSE",
|
|
118
|
+
"NOTICE"
|
|
119
|
+
],
|
|
120
|
+
"publishConfig": {
|
|
121
|
+
"access": "public"
|
|
122
|
+
},
|
|
123
|
+
"peerDependencies": {
|
|
124
|
+
"@margoengine/core": "^1.0.0",
|
|
125
|
+
"@margoengine/materials": "^1.0.0",
|
|
126
|
+
"@margoengine/gltf": "^1.0.0",
|
|
127
|
+
"@margoengine/post": "^1.0.0"
|
|
128
|
+
},
|
|
129
|
+
"peerDependenciesMeta": {
|
|
130
|
+
"@margoengine/post": {
|
|
131
|
+
"optional": true
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"dependencies": {
|
|
135
|
+
"@margoengine/math": "^1.0.0"
|
|
136
|
+
},
|
|
137
|
+
"scripts": {
|
|
138
|
+
"build": "node ../../scripts/build-optional.js shader",
|
|
139
|
+
"test": "npm run build && node --test test/*.test.js",
|
|
140
|
+
"prepack": "npm run build",
|
|
141
|
+
"test:gpu": "cd ../.. && node packages/shader/test/browser-check.mjs && node packages/shader/test/noise-check.mjs && node packages/shader/test/readback-check.mjs && node packages/shader/test/editor-check.mjs && node packages/shader/test/compute-texture-check.mjs && node packages/shader/test/compute-model-check.mjs && node packages/shader/test/lighting-check.mjs && node packages/shader/test/passes-check.mjs && node packages/shader/test/inputs-check.mjs && node packages/shader/test/deform-check.mjs && node packages/shader/test/attribute-check.mjs && node packages/shader/test/attribute-check.mjs --compat && node packages/shader/test/pass-check.mjs && node packages/shader/test/utils-check.mjs && node packages/shader/test/raw-check.mjs && node packages/shader/test/subgroups-check.mjs && node packages/shader/test/scene-owner-browser.mjs && node packages/shader/test/scene-owner-browser.mjs --compat && node packages/shader/test/compute-volume-check.mjs && node packages/shader/test/editor-pass-check.mjs && node packages/shader/test/texture-array-check.mjs && node packages/shader/test/black-hole-check.mjs && node packages/shader/test/negated-division-check.mjs && node packages/shader/test/glsl-check.mjs && node packages/shader/test/glsl-check.mjs --compat && node packages/shader/test/glsl-material-check.mjs && node packages/shader/test/glsl-material-check.mjs --compat && node packages/shader/test/glsl-velocity-check.mjs && node packages/shader/test/glsl-velocity-check.mjs --compat && node packages/shader/test/glsl-pass-check.mjs && node packages/shader/test/glsl-pass-check.mjs --compat && node packages/shader/test/shadertoy-check.mjs && node packages/shader/test/shadertoy-check.mjs --compat && node packages/shader/test/raw-restore-browser-check.mjs && node packages/shader/test/raw-restore-browser-check.mjs --compat && node packages/shader/test/shadertoy-restore-browser-check.mjs && node packages/shader/test/shadertoy-restore-browser-check.mjs --compat",
|
|
142
|
+
"test:gpu:raw": "cd ../.. && node scripts/shader-raw-gpu-check.js",
|
|
143
|
+
"test:gpu:volume": "cd ../.. && node packages/shader/test/compute-volume-check.mjs",
|
|
144
|
+
"test:gpu:editor-pass": "cd ../.. && node packages/shader/test/editor-pass-check.mjs",
|
|
145
|
+
"test:gpu:texture-array": "cd ../.. && node packages/shader/test/texture-array-check.mjs",
|
|
146
|
+
"test:gpu:glsl": "cd ../.. && node packages/shader/test/glsl-check.mjs && node packages/shader/test/glsl-check.mjs --compat",
|
|
147
|
+
"test:gpu:glsl-material": "cd ../.. && node packages/shader/test/glsl-material-check.mjs && node packages/shader/test/glsl-material-check.mjs --compat && node packages/shader/test/glsl-velocity-check.mjs && node packages/shader/test/glsl-velocity-check.mjs --compat",
|
|
148
|
+
"test:gpu:glsl-pass": "cd ../.. && node packages/shader/test/glsl-pass-check.mjs && node packages/shader/test/glsl-pass-check.mjs --compat",
|
|
149
|
+
"test:gpu:shadertoy": "cd ../.. && node packages/shader/test/shadertoy-check.mjs && node packages/shader/test/shadertoy-check.mjs --compat"
|
|
150
|
+
}
|
|
151
|
+
}
|
package/dist/gpu-DQ5Jmggz.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
(globalThis[Symbol.for("margoengine.frame-resources")] ??= { devices: /* @__PURE__ */ new WeakMap() }).devices;
|
|
2
|
-
//#endregion
|
|
3
|
-
//#region ../shared/gpu.js
|
|
4
|
-
var e = "\nstruct Vertex { @builtin(position) position:vec4f,@location(0) uv:vec2f }\n@vertex fn vertex(@builtin(vertex_index) index:u32)->Vertex {\n let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[index];\n return Vertex(vec4f(p,0,1),vec2f(p.x*0.5+0.5,0.5-p.y*0.5));\n}";
|
|
5
|
-
function t(e, t, n, r = {}) {
|
|
6
|
-
let i = e.createShaderModule({ code: t });
|
|
7
|
-
return e.createRenderPipeline({
|
|
8
|
-
layout: "auto",
|
|
9
|
-
vertex: {
|
|
10
|
-
module: i,
|
|
11
|
-
entryPoint: "vertex"
|
|
12
|
-
},
|
|
13
|
-
fragment: {
|
|
14
|
-
module: i,
|
|
15
|
-
entryPoint: "fragment",
|
|
16
|
-
targets: [{ format: n }]
|
|
17
|
-
},
|
|
18
|
-
...r
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
function n(e, t, n = "main") {
|
|
22
|
-
return e.createComputePipeline({
|
|
23
|
-
layout: "auto",
|
|
24
|
-
compute: {
|
|
25
|
-
module: e.createShaderModule({ code: t }),
|
|
26
|
-
entryPoint: n
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { e as n, t as r, n as t };
|