@margoengine/shader 0.0.0-stage → 0.1.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.
Files changed (91) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +1771 -3
  4. package/dist/black-hole.d.ts +246 -0
  5. package/dist/black-hole.js +445 -0
  6. package/dist/clock-BLGNexlt.js +52 -0
  7. package/dist/clock.d.ts +42 -0
  8. package/dist/compute-D-BghbXj.js +354 -0
  9. package/dist/compute-texture.d.ts +100 -0
  10. package/dist/compute-texture.js +131 -0
  11. package/dist/compute-volume.d.ts +57 -0
  12. package/dist/compute-volume.js +130 -0
  13. package/dist/compute.d.ts +194 -0
  14. package/dist/control-DvjfV7R0.js +201 -0
  15. package/dist/control.d.ts +93 -0
  16. package/dist/deform.d.ts +111 -0
  17. package/dist/deform.js +89 -0
  18. package/dist/display-BrJM_Qkd.js +5 -0
  19. package/dist/editor-model.d.ts +192 -0
  20. package/dist/editor-pass.d.ts +71 -0
  21. package/dist/editor-pass.js +216 -0
  22. package/dist/editor.d.ts +150 -0
  23. package/dist/editor.js +1071 -0
  24. package/dist/effects.d.ts +150 -0
  25. package/dist/effects.js +87 -0
  26. package/dist/errors-CsQwshHA.js +7 -0
  27. package/dist/glsl/emit.d.ts +43 -0
  28. package/dist/glsl/host.d.ts +55 -0
  29. package/dist/glsl/material.d.ts +173 -0
  30. package/dist/glsl/parser.d.ts +76 -0
  31. package/dist/glsl/preprocess.d.ts +9 -0
  32. package/dist/glsl/presets.d.ts +33 -0
  33. package/dist/glsl/program.d.ts +210 -0
  34. package/dist/glsl/scene.d.ts +9 -0
  35. package/dist/glsl-material.d.ts +82 -0
  36. package/dist/glsl-material.js +288 -0
  37. package/dist/glsl-pass.d.ts +93 -0
  38. package/dist/glsl-pass.js +186 -0
  39. package/dist/glsl.d.ts +94 -0
  40. package/dist/glsl.js +170 -0
  41. package/dist/gpu-DQ5Jmggz.js +31 -0
  42. package/dist/graph.d.ts +82 -0
  43. package/dist/graph.js +365 -0
  44. package/dist/index.d.ts +7 -0
  45. package/dist/index.js +8 -0
  46. package/dist/lighting-Dx8_RsBz.js +77 -0
  47. package/dist/lighting.d.ts +62 -0
  48. package/dist/lighting.js +1 -0
  49. package/dist/material-CU7p-Q8u.js +1184 -0
  50. package/dist/material-REzUrXtu.js +275 -0
  51. package/dist/material.d.ts +74 -0
  52. package/dist/node-DzKv9CF2.js +590 -0
  53. package/dist/node.d.ts +427 -0
  54. package/dist/noise.d.ts +38 -0
  55. package/dist/noise.js +107 -0
  56. package/dist/own-stack-D1XnXrrz.js +11 -0
  57. package/dist/own-stack.d.ts +12 -0
  58. package/dist/pass.d.ts +108 -0
  59. package/dist/pass.js +236 -0
  60. package/dist/post-DC62ZleD.js +113 -0
  61. package/dist/post.d.ts +69 -0
  62. package/dist/preprocess-CWGWlBWQ.js +1195 -0
  63. package/dist/raw-D0W8U3Qa.js +1351 -0
  64. package/dist/raw.d.ts +634 -0
  65. package/dist/raw.js +1 -0
  66. package/dist/readback.d.ts +42 -0
  67. package/dist/readback.js +84 -0
  68. package/dist/scope.d.ts +21 -0
  69. package/dist/serialization.d.ts +11 -0
  70. package/dist/serialization.js +192 -0
  71. package/dist/shadertoy/sound.d.ts +48 -0
  72. package/dist/shadertoy.d.ts +249 -0
  73. package/dist/shadertoy.js +909 -0
  74. package/dist/shared/caster.d.ts +152 -0
  75. package/dist/shared/fog.d.ts +33 -0
  76. package/dist/shared/fractal.d.ts +9 -0
  77. package/dist/shared/msaa.d.ts +25 -0
  78. package/dist/shared/stack.d.ts +22 -0
  79. package/dist/sound-CF_dzP41.js +78 -0
  80. package/dist/storage-format-DWaiSxmq.js +25 -0
  81. package/dist/storage-format.d.ts +7 -0
  82. package/dist/subgroups.d.ts +97 -0
  83. package/dist/subgroups.js +95 -0
  84. package/dist/texture-D6vy0bam.js +62 -0
  85. package/dist/texture-array.d.ts +7 -0
  86. package/dist/texture-array.js +11 -0
  87. package/dist/texture.d.ts +16 -0
  88. package/dist/utils.d.ts +106 -0
  89. package/dist/utils.js +90 -0
  90. package/dist/view-rect-Bm1ac-TK.js +16 -0
  91. package/package.json +151 -6
@@ -0,0 +1,106 @@
1
+ import { Node, type NodeInput, type ScalarOf, type Type } from './node.js';
2
+ import { type BindableTexture } from './texture.js';
3
+ /** Where a tangent frame comes from: the surface's screen derivatives, or the mesh's own tangents. */
4
+ export type TangentFrame = 'derivatives' | 'tangents';
5
+ /** Options of {@link normalMap}. */
6
+ export interface NormalMapOptions {
7
+ /** Scales the map's x and y, as glTF's normal scale does (default 1). */
8
+ strength?: NodeInput<'f32'>;
9
+ /**
10
+ * `'derivatives'` (default) works on any mesh and follows `coord`. `'tangents'` reads the mesh's tangents, which
11
+ * `computeTangents` from `@margoengine/geometry` makes; a mesh without them gets a fixed frame.
12
+ */
13
+ frame?: TangentFrame;
14
+ /** The UV the map is read with, for the `'derivatives'` frame (default `uv()`). */
15
+ coord?: NodeInput<'vec2f'>;
16
+ /**
17
+ * True (default) for a `Texture` on a mesh with its UV origin at the bottom left, which is what `@margoengine/geometry`
18
+ * makes. False for UVs from a glTF file, with the origin at the top left. The `'tangents'` frame ignores it.
19
+ */
20
+ flipY?: boolean;
21
+ }
22
+ /** Options of {@link bumpNormal}. */
23
+ export interface BumpOptions {
24
+ /** Scales the height (default 1). */
25
+ strength?: NodeInput<'f32'>;
26
+ /** The normal to tilt, in world space (default the surface's, facing the viewer). */
27
+ normal?: Node<'vec3f'>;
28
+ }
29
+ /** Options of {@link triplanar}. */
30
+ export interface TriplanarOptions {
31
+ /** Where to project from (default `positionWorld`; `positionLocal` sticks the pattern to the object). */
32
+ position?: Node<'vec3f'>;
33
+ /** The normal that picks the projections, in the same space as `position` (default `normalWorld`). */
34
+ normal?: Node<'vec3f'>;
35
+ /** Tiles per unit of `position` (default 1). */
36
+ scale?: NodeInput<'f32'>;
37
+ /** Higher values narrow the seams between projections (default 4). */
38
+ sharpness?: NodeInput<'f32'>;
39
+ }
40
+ /** Options of {@link parallaxUV}. */
41
+ export interface ParallaxOptions {
42
+ /** The UV to start from (default `uv()`). */
43
+ coord?: NodeInput<'vec2f'>;
44
+ /** How deep height 0 lies under height 1, in UV units (default 0.05). */
45
+ scale?: NodeInput<'f32'>;
46
+ /** Layers to march. 1 is a single offset with no search; more finds the true surface (default 16). */
47
+ steps?: number;
48
+ /** As in {@link NormalMapOptions.frame}. */
49
+ frame?: TangentFrame;
50
+ }
51
+ /** Options of {@link equirectUV}. */
52
+ export interface EquirectOptions {
53
+ /** True (default) for a `Texture`, whose rows are stored flipped: the top of the image is v = 1. */
54
+ flipY?: boolean;
55
+ }
56
+ /**
57
+ * A `normalNode` from a tangent-space normal map: `normalNode: normalMap(texture(map).rgb)`. The value is the map's colour,
58
+ * 0 to 1, so load the map with `{colorSpace: 'linear'}`.
59
+ */
60
+ export declare function normalMap(value: Node<'vec3f'>, options?: NormalMapOptions): Node<'vec3f'>;
61
+ /** A `normalNode` that tilts the surface along a height in world units, from its screen derivatives. Works on any mesh. */
62
+ export declare function bumpNormal(height: NodeInput<'f32'>, options?: BumpOptions): Node<'vec3f'>;
63
+ /**
64
+ * Three planar projections blended by the normal, for surfaces with no usable UVs: rock, terrain, anything sculpted. `map`
65
+ * is a `Texture` or a function of the UV, so noise works too.
66
+ */
67
+ export declare function triplanar(map: BindableTexture | ((coord: Node<'vec2f'>) => Node<'vec4f'>), options?: TriplanarOptions): Node<'vec4f'>;
68
+ /**
69
+ * The UV where a line of sight meets a height field under the surface, so a flat mesh looks carved: read every map of the
70
+ * surface with it. `height` is a `Texture` (red channel) or a function of the UV giving 1 at the surface and 0 at the
71
+ * deepest; a function must read textures with an explicit level, because the search branches per pixel.
72
+ */
73
+ export declare function parallaxUV(height: BindableTexture | ((coord: Node<'vec2f'>) => Node<'f32'>), options?: ParallaxOptions): Node<'vec2f'>;
74
+ /** `coord` turned by `angle` radians, anticlockwise, around `center` (default the middle of the texture). */
75
+ export declare function rotateUV(coord: NodeInput<'vec2f'>, angle: NodeInput<'f32'>, center?: NodeInput<'vec2f'>): Node<'vec2f'>;
76
+ /** `v` turned by `angle` radians around the unit vector `axis`, by the right-hand rule (Rodrigues' formula). */
77
+ export declare function rotateAxis(v: Node<'vec3f'>, axis: NodeInput<'vec3f'>, angle: NodeInput<'f32'>): Node<'vec3f'>;
78
+ /** Where a matcap image is read for this surface, as `MatcapMaterial` reads it: `texture(matcap, matcapUV())`. */
79
+ export declare function matcapUV(normal?: Node<'vec3f'>, position?: Node<'vec3f'>): Node<'vec2f'>;
80
+ /**
81
+ * Where a unit direction falls in a panorama, as `@margoengine/environment` lays one out: the middle of the image faces -z
82
+ * and +x is to its right. The image's left and right edges meet at +z, so read it with an explicit level or no mipmaps.
83
+ */
84
+ export declare function equirectUV(direction: NodeInput<'vec3f'>, options?: EquirectOptions): Node<'vec2f'>;
85
+ /** Brightness of a linear colour, by the Rec. 709 weights. */
86
+ export declare const luminance: (rgb: Node<'vec3f'>) => Node<'f32'>;
87
+ /** A colour with its saturation scaled: 0 is grey of the same luminance, 1 leaves it, more strengthens it. */
88
+ export declare const saturation: (rgb: Node<'vec3f'>, amount: NodeInput<'f32'>) => Node<'vec3f'>;
89
+ /** A colour with its hue turned by `angle` radians around the grey axis; red moves towards green. */
90
+ export declare const hue: (rgb: Node<'vec3f'>, angle: NodeInput<'f32'>) => Node<'vec3f'>;
91
+ /** A blend of `top` over `base`, both colours 0 to 1; `opacity` fades the result back to `base` (default 1). */
92
+ export type BlendMode = (base: Node<'vec3f'>, top: NodeInput<'vec3f'>, opacity?: NodeInput<'f32'>) => Node<'vec3f'>;
93
+ /** The W3C separable blend modes and plain add and subtract, each a {@link BlendMode}. */
94
+ export declare const blendAdd: BlendMode, blendSubtract: BlendMode, blendMultiply: BlendMode, blendScreen: BlendMode, blendOverlay: BlendMode, blendHardLight: BlendMode, blendDarken: BlendMode, blendLighten: BlendMode, blendDifference: BlendMode, blendExclusion: BlendMode, blendDodge: BlendMode, blendBurn: BlendMode, blendSoftLight: BlendMode;
95
+ /** `value` taken from the range `inLow..inHigh` to `outLow..outHigh`, unclamped. `inLow` and `inHigh` must differ. */
96
+ export declare function remap<T extends Type>(value: Node<T>, inLow: NodeInput<T> | NodeInput<ScalarOf<T>>, inHigh: NodeInput<T> | NodeInput<ScalarOf<T>>, outLow?: NodeInput<T> | NodeInput<ScalarOf<T>>, outHigh?: NodeInput<T> | NodeInput<ScalarOf<T>>): Node<T>;
97
+ /** {@link remap}, with the result held between `outLow` and `outHigh`. */
98
+ export declare function remapClamp<T extends Type>(value: Node<T>, inLow: NodeInput<T> | NodeInput<ScalarOf<T>>, inHigh: NodeInput<T> | NodeInput<ScalarOf<T>>, outLow?: NodeInput<T> | NodeInput<ScalarOf<T>>, outHigh?: NodeInput<T> | NodeInput<ScalarOf<T>>): Node<T>;
99
+ /** A wave from 0 to 1 and back, one period per unit of `t`, rising through 0.5 at t = 0 (default `time`, so one per second). */
100
+ export declare const oscSine: (t?: NodeInput<'f32'>) => Node<'f32'>;
101
+ /** 1 for the first half of each period, then 0. */
102
+ export declare const oscSquare: (t?: NodeInput<'f32'>) => Node<'f32'>;
103
+ /** 0 at the start of each period, 1 half way, 0 at the end. */
104
+ export declare const oscTriangle: (t?: NodeInput<'f32'>) => Node<'f32'>;
105
+ /** Climbs from 0 to 1 over each period, then drops. */
106
+ export declare const oscSawtooth: (t?: NodeInput<'f32'>) => Node<'f32'>;
package/dist/utils.js ADDED
@@ -0,0 +1,90 @@
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 te, j as b, m as ne, nn as x, o as S, p as C, pn as w, sn as T, ut as E, v as D, xt as O, yt as k, z as A, zt as j } from "./node-DzKv9CF2.js";
2
+ import { n as M } from "./texture-D6vy0bam.js";
3
+ import { a as re, i as ie, r as ae, s as N, t as oe, u as P } from "./control-DvjfV7R0.js";
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 = () => j(ee("frontFacing", "bool"), g, g.negate());
6
+ function L(e, t) {
7
+ let r = n;
8
+ return new S("mat3x3f", "zcotangent", [
9
+ e,
10
+ s(r),
11
+ A(r),
12
+ s(t),
13
+ A(t)
14
+ ], (e, t) => (e.declare("utils:cotangent", F.replace("margoCotangentFrame", "nodeCotangentFrame")), `nodeCotangentFrame(${t.args.map((t) => e.expr(t)).join(", ")})`));
15
+ }
16
+ function R(e, t, n) {
17
+ if (e !== void 0 && e !== "derivatives" && e !== "tangents") throw TypeError(`Tangent frame must be 'derivatives' or 'tangents', got ${String(e)}`);
18
+ let r = I();
19
+ if (e === "tangents") return [
20
+ p,
21
+ D,
22
+ r
23
+ ];
24
+ let i = L(r, t), a = i.element(1);
25
+ return [
26
+ i.element(0),
27
+ n ? a.negate() : a,
28
+ r
29
+ ];
30
+ }
31
+ function z(e, t = {}) {
32
+ let { strength: n = 1, frame: r, coord: i = x(), 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 O(o.mul(d.x).add(s.mul(d.y)).add(l.mul(u.z)));
34
+ }
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 = A(n), d = b(u, i), f = b(i, l), p = o(l, d), m = j(p.lessThan(0), -1, 1), h = d.mul(s(a)).add(f.mul(A(a))).mul(m);
37
+ return O(i.mul(p.abs()).sub(h));
38
+ }
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) => M(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
+ return s(l.zy).mul(d.x).add(s(l.xz).mul(d.y)).add(s(l.xy).mul(d.z));
42
+ }
43
+ function H(e, t = {}) {
44
+ let { coord: n = x(), scale: r = .05, steps: i = 16, frame: a } = t;
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) => M(e, t, 0).r, [u, d, f] = R(a, s, !0), p = T(o(w, u), o(w, d)).div(E(o(w, f), .1)).mul(c(r, "f32", "parallaxUV scale"));
47
+ return i === 1 ? s.sub(p.mul(l(s).oneMinus())) : P(() => {
48
+ let e = ie(p), t = N(0), n = N(0), r = N(s), a = N(s), o = N(l(s).oneMinus()), c = N(o);
49
+ re(i, () => {
50
+ ae(t.greaterThanEqual(o), () => oe()), 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
+ });
52
+ let u = c.sub(n), d = u.add(t.sub(o));
53
+ return y(a, r, j(d.lessThan(1e-6), 1, u.div(d).saturate()));
54
+ });
55
+ }
56
+ function U(t, n, r = .5) {
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 T(o.x.mul(l).sub(o.y.mul(s)), o.x.mul(s).add(o.y.mul(l))).add(a);
59
+ }
60
+ function W(t, n, r) {
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(b(a, s).mul(u(i))).add(a.mul(o(a, s)).mul(l.oneMinus()));
63
+ }
64
+ function G(e = k, t = l) {
65
+ let n = O(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 = j(s, i.mul(E(a, 1e-10).inverseSqrt()), _(1, 0, 0)), d = j(s, b(n, u), _(0, 1, 0));
66
+ return T(o(r, u), o(r, d)).mul(.49).add(.5);
67
+ }
68
+ function K(e, n = {}) {
69
+ let r = c(e, "vec3f", "equirectUV direction"), i = j(r.x.equal(0), 0, r.x), a = j(r.z.equal(0), j(r.x.equal(0), 1, 0), r.z.negate()), o = C(t(r.y, -1, 1)).div(Math.PI);
70
+ return T(h(i, a).div(Math.PI * 2).add(.5), n.flipY ?? !0 ? o.oneMinus() : o);
71
+ }
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
+ let i = c(t, "vec3f", "blend base"), a = e(i, c(n, "vec3f", "blend top"));
74
+ return r === 1 ? a : y(i, a, c(r, "f32", "blend opacity").xxx);
75
+ }, Y = (e, t) => {
76
+ let n = t.mul(2).sub(1);
77
+ return j(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) => E(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) => E(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) => j(e.lessThanEqual(0), _(0), j(t.greaterThanEqual(1), _(1), v(e.div(E(t.oneMinus(), 1e-6)), 1)))), be = /*@__PURE__*/ J((e, t) => j(e.greaterThanEqual(1), _(1), j(t.lessThanEqual(0), _(0), v(e.oneMinus().div(E(t, 1e-6)), 1).oneMinus()))), xe = /*@__PURE__*/ J((e, t) => {
79
+ let n = j(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 j(t.lessThanEqual(.5), r, i);
81
+ }), Se = ne, X = a, Z = te, Ce = i, Q = (e, t, n) => Ce(X(e, t), X(n, t)), $ = (e, t, n) => Se(Z(e, X(n, t)), t);
82
+ function we(e, t, n, r = 0, i = 1) {
83
+ return $(Q(e, t, n), r, i);
84
+ }
85
+ function Te(e, t, n, r = 0, i = 1) {
86
+ return $(Q(e, t, n).saturate(), r, i);
87
+ }
88
+ var Ee = (e = m) => u(c(e, "f32", "oscSine time").mul(Math.PI * 2)).mul(.5).add(.5), De = (e = m) => r(.5, d(c(e, "f32", "oscSquare time"))).oneMinus(), Oe = (e = m) => d(c(e, "f32", "oscTriangle time")).mul(2).sub(1).abs().oneMinus(), ke = (e = m) => d(c(e, "f32", "oscSawtooth time"));
89
+ //#endregion
90
+ export { le as blendAdd, be as blendBurn, he as blendDarken, _e as blendDifference, ye as blendDodge, ve as blendExclusion, me as blendHardLight, ge as blendLighten, de as blendMultiply, pe as blendOverlay, fe as blendScreen, xe as blendSoftLight, ue as blendSubtract, B as bumpNormal, K as equirectUV, ce as hue, q as luminance, G as matcapUV, z as normalMap, ke as oscSawtooth, Ee as oscSine, De as oscSquare, Oe as oscTriangle, H as parallaxUV, we as remap, Te as remapClamp, W as rotateAxis, U as rotateUV, se as saturation, V as triplanar };
@@ -0,0 +1,16 @@
1
+ //#region ../shared/view-rect.js
2
+ function e(e) {
3
+ return e?.view?.viewport;
4
+ }
5
+ function t(t, n) {
6
+ let r = e(n);
7
+ if (!r) return;
8
+ t.setViewport(r[0], r[1], r[2], r[3], 0, 1);
9
+ let i = n.view.scissor ?? r;
10
+ t.setScissorRect(i[0], i[1], i[2], i[3]);
11
+ }
12
+ function n(e, t = "clear") {
13
+ return e?.view?.index ? "load" : t;
14
+ }
15
+ //#endregion
16
+ export { n, e as r, t };
package/package.json CHANGED
@@ -1,6 +1,151 @@
1
- {
2
- "name": "@margoengine/shader",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "@margoengine/shader",
3
+ "version": "0.1.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": "^0.1.0",
125
+ "@margoengine/materials": "^0.1.0",
126
+ "@margoengine/gltf": "^0.1.0",
127
+ "@margoengine/post": "^0.1.0"
128
+ },
129
+ "peerDependenciesMeta": {
130
+ "@margoengine/post": {
131
+ "optional": true
132
+ }
133
+ },
134
+ "dependencies": {
135
+ "@margoengine/math": "^0.1.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/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
+ }