@ignifx/core 0.6.1 → 0.8.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 (36) hide show
  1. package/dist/{color-CpvebMIh.js → color-DrR6GFTd.js} +3 -276
  2. package/dist/color-DrR6GFTd.js.map +1 -0
  3. package/dist/{environment-CvVC1lPa.js → environment-mr5wp69e.js} +5 -4
  4. package/dist/{environment-CvVC1lPa.js.map → environment-mr5wp69e.js.map} +1 -1
  5. package/dist/{ignifx-error-R1ma_Lzv.js → ignifx-error-CRh89KUJ.js} +4 -1
  6. package/dist/ignifx-error-CRh89KUJ.js.map +1 -0
  7. package/dist/index.d.ts +41 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +210 -1664
  10. package/dist/index.js.map +1 -1
  11. package/dist/{instanced-mesh-instance-Cgx1H87p.js → instanced-mesh-instance-gguMoIeZ.js} +74 -10
  12. package/dist/instanced-mesh-instance-gguMoIeZ.js.map +1 -0
  13. package/dist/{material-plugin-CTaWZXEk.js → material-plugin-Cfw_h_Mg.js} +2 -2
  14. package/dist/{material-plugin-CTaWZXEk.js.map → material-plugin-Cfw_h_Mg.js.map} +1 -1
  15. package/dist/math-utils-BcDnL-gi.js +277 -0
  16. package/dist/math-utils-BcDnL-gi.js.map +1 -0
  17. package/dist/{post-effect-compiler-Cq6cshjL.js → post-effect-compiler-Rce26Eue.js} +2 -2
  18. package/dist/{post-effect-compiler-Cq6cshjL.js.map → post-effect-compiler-Rce26Eue.js.map} +1 -1
  19. package/dist/shader-declaration-5q__jycG.js.map +1 -1
  20. package/dist/{shader-material-fOI9Upt3.js → shader-material-BIG3UDyu.js} +4 -4
  21. package/dist/{shader-material-fOI9Upt3.js.map → shader-material-BIG3UDyu.js.map} +1 -1
  22. package/dist/{shader-material-BzVY0ySR.js → shader-material-U6BKZ8D1.js} +2 -2
  23. package/dist/{shader-material-BzVY0ySR.js.map → shader-material-U6BKZ8D1.js.map} +1 -1
  24. package/dist/{shader-pragma-CNAK4SIb.js → shader-pragma-tw6AKaQD.js} +25 -4
  25. package/dist/shader-pragma-tw6AKaQD.js.map +1 -0
  26. package/dist/{surface-shader-fJ2MOez0.js → surface-shader-DAWIDdaa.js} +8 -6
  27. package/dist/{surface-shader-fJ2MOez0.js.map → surface-shader-DAWIDdaa.js.map} +1 -1
  28. package/dist/vec3-B31o_KF_.js +2458 -0
  29. package/dist/vec3-B31o_KF_.js.map +1 -0
  30. package/package.json +1 -1
  31. package/dist/color-CpvebMIh.js.map +0 -1
  32. package/dist/ignifx-error-R1ma_Lzv.js.map +0 -1
  33. package/dist/instanced-mesh-instance-Cgx1H87p.js.map +0 -1
  34. package/dist/mesh-CnK_PX46.js +0 -811
  35. package/dist/mesh-CnK_PX46.js.map +0 -1
  36. package/dist/shader-pragma-CNAK4SIb.js.map +0 -1
@@ -0,0 +1,277 @@
1
+ //#region src/math/math-utils.ts
2
+ /**
3
+ * Scalar helpers shared by the vector, quaternion and matrix types and by game code.
4
+ *
5
+ * Angles are **degrees** in every public API unless the name ends in `Rad`/`Radians`
6
+ * (coding standards §5.1, ADR-0011). Every function here is a pure scalar function: none of them
7
+ * allocate, so they are safe in per-frame code (coding standards §7).
8
+ */
9
+ /**
10
+ * The default tolerance for approximate float comparisons. Chosen for single-precision positions in
11
+ * metres: `Float32Array` round-tripping loses roughly 1e-7 of relative precision, so 1e-6 is the
12
+ * smallest value that does not report false differences on data that has been through the GPU.
13
+ *
14
+ * @public
15
+ */
16
+ const EPSILON = 1e-6;
17
+ /**
18
+ * Multiplier that converts degrees to radians.
19
+ *
20
+ * @public
21
+ */
22
+ const DEG_TO_RAD = Math.PI / 180;
23
+ /**
24
+ * Multiplier that converts radians to degrees.
25
+ *
26
+ * @public
27
+ */
28
+ const RAD_TO_DEG = 180 / Math.PI;
29
+ /**
30
+ * Converts an angle from degrees to radians.
31
+ *
32
+ * @param degrees - The angle in degrees.
33
+ * @returns The same angle in radians.
34
+ *
35
+ * @public
36
+ */
37
+ function degToRad(degrees) {
38
+ return degrees * DEG_TO_RAD;
39
+ }
40
+ /**
41
+ * Converts an angle from radians to degrees.
42
+ *
43
+ * @param radians - The angle in radians.
44
+ * @returns The same angle in degrees.
45
+ *
46
+ * @public
47
+ */
48
+ function radToDeg(radians) {
49
+ return radians * RAD_TO_DEG;
50
+ }
51
+ /**
52
+ * Constrains a value to an inclusive range.
53
+ *
54
+ * @param value - The value to constrain.
55
+ * @param min - The lower bound.
56
+ * @param max - The upper bound.
57
+ * @returns `min` when `value` is smaller, `max` when it is larger, otherwise `value` unchanged.
58
+ * `NaN` propagates.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * clamp(12, 0, 10); // 10
63
+ * ```
64
+ *
65
+ * @public
66
+ */
67
+ function clamp(value, min, max) {
68
+ if (value < min) return min;
69
+ if (value > max) return max;
70
+ return value;
71
+ }
72
+ /**
73
+ * Constrains a value to the 0–1 range.
74
+ *
75
+ * @param value - The value to constrain.
76
+ * @returns The value clamped into `[0, 1]`.
77
+ *
78
+ * @public
79
+ */
80
+ function clamp01(value) {
81
+ return clamp(value, 0, 1);
82
+ }
83
+ /**
84
+ * Linearly interpolates between two values. The interpolant is **not** clamped, so values outside
85
+ * `[0, 1]` extrapolate; wrap `t` in {@link clamp01} when that is not wanted.
86
+ *
87
+ * @param a - The value returned at `t === 0`.
88
+ * @param b - The value returned at `t === 1`.
89
+ * @param t - The interpolant.
90
+ * @returns The interpolated value.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * lerp(0, 10, 0.25); // 2.5
95
+ * ```
96
+ *
97
+ * @public
98
+ */
99
+ function lerp(a, b, t) {
100
+ return a + (b - a) * t;
101
+ }
102
+ /**
103
+ * The inverse of {@link lerp}: finds the interpolant that maps `a`–`b` onto `value`.
104
+ *
105
+ * @param a - The value that maps to 0.
106
+ * @param b - The value that maps to 1.
107
+ * @param value - The value to locate.
108
+ * @returns The interpolant, clamped into `[0, 1]`. Returns 0 when `a` and `b` are equal.
109
+ *
110
+ * @public
111
+ */
112
+ function inverseLerp(a, b, value) {
113
+ if (a === b) return 0;
114
+ return clamp01((value - a) / (b - a));
115
+ }
116
+ /**
117
+ * Smoothly interpolates between two edges with a Hermite curve (the GLSL `smoothstep`), easing in
118
+ * and out instead of the straight ramp of {@link lerp}.
119
+ *
120
+ * @param edge0 - The value below which the result is 0.
121
+ * @param edge1 - The value above which the result is 1.
122
+ * @param x - The value to map.
123
+ * @returns A value in `[0, 1]`. Degenerate edges (`edge0 === edge1`) step from 0 to 1 at the edge.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * smoothStep(0, 1, 0.5); // 0.5, but with zero slope at 0 and 1
128
+ * ```
129
+ *
130
+ * @public
131
+ */
132
+ function smoothStep(edge0, edge1, x) {
133
+ if (edge0 === edge1) return x < edge0 ? 0 : 1;
134
+ const t = clamp01((x - edge0) / (edge1 - edge0));
135
+ return t * t * (3 - 2 * t);
136
+ }
137
+ /**
138
+ * Moves a value towards a target without overshooting it.
139
+ *
140
+ * @param current - The value to move.
141
+ * @param target - The value to move towards.
142
+ * @param maxDelta - The largest step allowed this call; negative values move away from the target.
143
+ * @returns The stepped value, exactly `target` once the remaining distance fits in `maxDelta`.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * // frame-rate independent approach at 2 units per second
148
+ * health = moveTowards(health, 100, 2 * time.deltaTime);
149
+ * ```
150
+ *
151
+ * @public
152
+ */
153
+ function moveTowards(current, target, maxDelta) {
154
+ const delta = target - current;
155
+ if (Math.abs(delta) <= maxDelta) return target;
156
+ return current + (delta < 0 ? -maxDelta : maxDelta);
157
+ }
158
+ /**
159
+ * Wraps a value into `[0, length)`, the way a looping animation time behaves. Unlike `%` the result
160
+ * is never negative.
161
+ *
162
+ * @param t - The value to wrap.
163
+ * @param length - The positive period to wrap into.
164
+ * @returns The wrapped value, clamped into `[0, length]` so float error cannot escape the range.
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * repeat(-1, 4); // 3
169
+ * ```
170
+ *
171
+ * @public
172
+ */
173
+ function repeat(t, length) {
174
+ return clamp(t - Math.floor(t / length) * length, 0, length);
175
+ }
176
+ /**
177
+ * Bounces a value back and forth between 0 and `length`, the way a ping-pong animation behaves.
178
+ *
179
+ * @param t - The value to fold.
180
+ * @param length - The positive half-period to fold into.
181
+ * @returns A value in `[0, length]` that rises then falls as `t` increases.
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * pingPong(5, 4); // 3
186
+ * ```
187
+ *
188
+ * @public
189
+ */
190
+ function pingPong(t, length) {
191
+ return length - Math.abs(repeat(t, length * 2) - length);
192
+ }
193
+ /**
194
+ * Compares two numbers with an absolute tolerance. Use this instead of `===` on anything that has
195
+ * been through a matrix, a quaternion or a `Float32Array`.
196
+ *
197
+ * @param a - The first value.
198
+ * @param b - The second value.
199
+ * @param epsilon - The largest difference still considered equal. Defaults to {@link EPSILON}.
200
+ * @returns `true` when the values differ by no more than `epsilon`. `NaN` is never approximately
201
+ * equal to anything, including itself.
202
+ *
203
+ * @public
204
+ */
205
+ function approximately(a, b, epsilon = EPSILON) {
206
+ return Math.abs(a - b) <= epsilon;
207
+ }
208
+ /**
209
+ * The sign of a value, with zero treated as positive (matching Unity's `Mathf.Sign`, and unlike
210
+ * `Math.sign`, which returns 0 and `-0`).
211
+ *
212
+ * @param value - The value to inspect.
213
+ * @returns `-1` for negative values, `1` for positive values and for both `0` and `-0`, and `NaN`
214
+ * for `NaN`.
215
+ *
216
+ * @public
217
+ */
218
+ function sign(value) {
219
+ if (Number.isNaN(value)) return NaN;
220
+ return value < 0 ? -1 : 1;
221
+ }
222
+ /**
223
+ * Wraps an angle in degrees into `[-180, 180)`, the range rotations are most readable in.
224
+ *
225
+ * @param degrees - The angle to wrap.
226
+ * @returns The equivalent angle in `[-180, 180)`; exactly `180` wraps to `-180`.
227
+ *
228
+ * @example
229
+ * ```ts
230
+ * wrapAngleDegrees(370); // 10
231
+ * wrapAngleDegrees(-190); // 170
232
+ * ```
233
+ *
234
+ * @public
235
+ */
236
+ function wrapAngleDegrees(degrees) {
237
+ return repeat(degrees + 180, 360) - 180;
238
+ }
239
+ /**
240
+ * The shortest signed rotation from one angle to another, in degrees.
241
+ *
242
+ * @param fromDegrees - The starting angle.
243
+ * @param toDegrees - The target angle.
244
+ * @returns The signed difference in `[-180, 180)`.
245
+ *
246
+ * @example
247
+ * ```ts
248
+ * deltaAngleDegrees(350, 10); // 20, not -340
249
+ * ```
250
+ *
251
+ * @public
252
+ */
253
+ function deltaAngleDegrees(fromDegrees, toDegrees) {
254
+ return wrapAngleDegrees(toDegrees - fromDegrees);
255
+ }
256
+ /**
257
+ * Interpolates between two angles in degrees the short way around the circle.
258
+ *
259
+ * @param fromDegrees - The angle returned at `t === 0`.
260
+ * @param toDegrees - The angle approached at `t === 1`.
261
+ * @param t - The interpolant; not clamped, matching {@link lerp}.
262
+ * @returns The interpolated angle. It is not wrapped, so feeding the result back in is stable.
263
+ *
264
+ * @example
265
+ * ```ts
266
+ * lerpAngleDegrees(350, 10, 0.5); // 360
267
+ * ```
268
+ *
269
+ * @public
270
+ */
271
+ function lerpAngleDegrees(fromDegrees, toDegrees, t) {
272
+ return fromDegrees + deltaAngleDegrees(fromDegrees, toDegrees) * t;
273
+ }
274
+ //#endregion
275
+ export { smoothStep as _, clamp as a, deltaAngleDegrees as c, lerpAngleDegrees as d, moveTowards as f, sign as g, repeat as h, approximately as i, inverseLerp as l, radToDeg as m, EPSILON as n, clamp01 as o, pingPong as p, RAD_TO_DEG as r, degToRad as s, DEG_TO_RAD as t, lerp as u, wrapAngleDegrees as v };
276
+
277
+ //# sourceMappingURL=math-utils-BcDnL-gi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math-utils-BcDnL-gi.js","names":[],"sources":["../src/math/math-utils.ts"],"sourcesContent":["/**\n * Scalar helpers shared by the vector, quaternion and matrix types and by game code.\n *\n * Angles are **degrees** in every public API unless the name ends in `Rad`/`Radians`\n * (coding standards §5.1, ADR-0011). Every function here is a pure scalar function: none of them\n * allocate, so they are safe in per-frame code (coding standards §7).\n */\n\n/**\n * The default tolerance for approximate float comparisons. Chosen for single-precision positions in\n * metres: `Float32Array` round-tripping loses roughly 1e-7 of relative precision, so 1e-6 is the\n * smallest value that does not report false differences on data that has been through the GPU.\n *\n * @public\n */\nexport const EPSILON: number = 1e-6;\n\n/**\n * Multiplier that converts degrees to radians.\n *\n * @public\n */\nexport const DEG_TO_RAD: number = Math.PI / 180;\n\n/**\n * Multiplier that converts radians to degrees.\n *\n * @public\n */\nexport const RAD_TO_DEG: number = 180 / Math.PI;\n\n/**\n * Converts an angle from degrees to radians.\n *\n * @param degrees - The angle in degrees.\n * @returns The same angle in radians.\n *\n * @public\n */\nexport function degToRad(degrees: number): number {\n return degrees * DEG_TO_RAD;\n}\n\n/**\n * Converts an angle from radians to degrees.\n *\n * @param radians - The angle in radians.\n * @returns The same angle in degrees.\n *\n * @public\n */\nexport function radToDeg(radians: number): number {\n return radians * RAD_TO_DEG;\n}\n\n/**\n * Constrains a value to an inclusive range.\n *\n * @param value - The value to constrain.\n * @param min - The lower bound.\n * @param max - The upper bound.\n * @returns `min` when `value` is smaller, `max` when it is larger, otherwise `value` unchanged.\n * `NaN` propagates.\n *\n * @example\n * ```ts\n * clamp(12, 0, 10); // 10\n * ```\n *\n * @public\n */\nexport function clamp(value: number, min: number, max: number): number {\n if (value < min) {\n return min;\n }\n if (value > max) {\n return max;\n }\n return value;\n}\n\n/**\n * Constrains a value to the 0–1 range.\n *\n * @param value - The value to constrain.\n * @returns The value clamped into `[0, 1]`.\n *\n * @public\n */\nexport function clamp01(value: number): number {\n return clamp(value, 0, 1);\n}\n\n/**\n * Linearly interpolates between two values. The interpolant is **not** clamped, so values outside\n * `[0, 1]` extrapolate; wrap `t` in {@link clamp01} when that is not wanted.\n *\n * @param a - The value returned at `t === 0`.\n * @param b - The value returned at `t === 1`.\n * @param t - The interpolant.\n * @returns The interpolated value.\n *\n * @example\n * ```ts\n * lerp(0, 10, 0.25); // 2.5\n * ```\n *\n * @public\n */\nexport function lerp(a: number, b: number, t: number): number {\n return a + (b - a) * t;\n}\n\n/**\n * The inverse of {@link lerp}: finds the interpolant that maps `a`–`b` onto `value`.\n *\n * @param a - The value that maps to 0.\n * @param b - The value that maps to 1.\n * @param value - The value to locate.\n * @returns The interpolant, clamped into `[0, 1]`. Returns 0 when `a` and `b` are equal.\n *\n * @public\n */\nexport function inverseLerp(a: number, b: number, value: number): number {\n if (a === b) {\n return 0;\n }\n return clamp01((value - a) / (b - a));\n}\n\n/**\n * Smoothly interpolates between two edges with a Hermite curve (the GLSL `smoothstep`), easing in\n * and out instead of the straight ramp of {@link lerp}.\n *\n * @param edge0 - The value below which the result is 0.\n * @param edge1 - The value above which the result is 1.\n * @param x - The value to map.\n * @returns A value in `[0, 1]`. Degenerate edges (`edge0 === edge1`) step from 0 to 1 at the edge.\n *\n * @example\n * ```ts\n * smoothStep(0, 1, 0.5); // 0.5, but with zero slope at 0 and 1\n * ```\n *\n * @public\n */\nexport function smoothStep(edge0: number, edge1: number, x: number): number {\n if (edge0 === edge1) {\n return x < edge0 ? 0 : 1;\n }\n const t = clamp01((x - edge0) / (edge1 - edge0));\n return t * t * (3 - 2 * t);\n}\n\n/**\n * Moves a value towards a target without overshooting it.\n *\n * @param current - The value to move.\n * @param target - The value to move towards.\n * @param maxDelta - The largest step allowed this call; negative values move away from the target.\n * @returns The stepped value, exactly `target` once the remaining distance fits in `maxDelta`.\n *\n * @example\n * ```ts\n * // frame-rate independent approach at 2 units per second\n * health = moveTowards(health, 100, 2 * time.deltaTime);\n * ```\n *\n * @public\n */\nexport function moveTowards(current: number, target: number, maxDelta: number): number {\n const delta = target - current;\n if (Math.abs(delta) <= maxDelta) {\n return target;\n }\n return current + (delta < 0 ? -maxDelta : maxDelta);\n}\n\n/**\n * Wraps a value into `[0, length)`, the way a looping animation time behaves. Unlike `%` the result\n * is never negative.\n *\n * @param t - The value to wrap.\n * @param length - The positive period to wrap into.\n * @returns The wrapped value, clamped into `[0, length]` so float error cannot escape the range.\n *\n * @example\n * ```ts\n * repeat(-1, 4); // 3\n * ```\n *\n * @public\n */\nexport function repeat(t: number, length: number): number {\n return clamp(t - Math.floor(t / length) * length, 0, length);\n}\n\n/**\n * Bounces a value back and forth between 0 and `length`, the way a ping-pong animation behaves.\n *\n * @param t - The value to fold.\n * @param length - The positive half-period to fold into.\n * @returns A value in `[0, length]` that rises then falls as `t` increases.\n *\n * @example\n * ```ts\n * pingPong(5, 4); // 3\n * ```\n *\n * @public\n */\nexport function pingPong(t: number, length: number): number {\n return length - Math.abs(repeat(t, length * 2) - length);\n}\n\n/**\n * Compares two numbers with an absolute tolerance. Use this instead of `===` on anything that has\n * been through a matrix, a quaternion or a `Float32Array`.\n *\n * @param a - The first value.\n * @param b - The second value.\n * @param epsilon - The largest difference still considered equal. Defaults to {@link EPSILON}.\n * @returns `true` when the values differ by no more than `epsilon`. `NaN` is never approximately\n * equal to anything, including itself.\n *\n * @public\n */\nexport function approximately(a: number, b: number, epsilon: number = EPSILON): boolean {\n return Math.abs(a - b) <= epsilon;\n}\n\n/**\n * The sign of a value, with zero treated as positive (matching Unity's `Mathf.Sign`, and unlike\n * `Math.sign`, which returns 0 and `-0`).\n *\n * @param value - The value to inspect.\n * @returns `-1` for negative values, `1` for positive values and for both `0` and `-0`, and `NaN`\n * for `NaN`.\n *\n * @public\n */\nexport function sign(value: number): number {\n if (Number.isNaN(value)) {\n return Number.NaN;\n }\n return value < 0 ? -1 : 1;\n}\n\n/**\n * Wraps an angle in degrees into `[-180, 180)`, the range rotations are most readable in.\n *\n * @param degrees - The angle to wrap.\n * @returns The equivalent angle in `[-180, 180)`; exactly `180` wraps to `-180`.\n *\n * @example\n * ```ts\n * wrapAngleDegrees(370); // 10\n * wrapAngleDegrees(-190); // 170\n * ```\n *\n * @public\n */\nexport function wrapAngleDegrees(degrees: number): number {\n return repeat(degrees + 180, 360) - 180;\n}\n\n/**\n * The shortest signed rotation from one angle to another, in degrees.\n *\n * @param fromDegrees - The starting angle.\n * @param toDegrees - The target angle.\n * @returns The signed difference in `[-180, 180)`.\n *\n * @example\n * ```ts\n * deltaAngleDegrees(350, 10); // 20, not -340\n * ```\n *\n * @public\n */\nexport function deltaAngleDegrees(fromDegrees: number, toDegrees: number): number {\n return wrapAngleDegrees(toDegrees - fromDegrees);\n}\n\n/**\n * Interpolates between two angles in degrees the short way around the circle.\n *\n * @param fromDegrees - The angle returned at `t === 0`.\n * @param toDegrees - The angle approached at `t === 1`.\n * @param t - The interpolant; not clamped, matching {@link lerp}.\n * @returns The interpolated angle. It is not wrapped, so feeding the result back in is stable.\n *\n * @example\n * ```ts\n * lerpAngleDegrees(350, 10, 0.5); // 360\n * ```\n *\n * @public\n */\nexport function lerpAngleDegrees(fromDegrees: number, toDegrees: number, t: number): number {\n return fromDegrees + deltaAngleDegrees(fromDegrees, toDegrees) * t;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,UAAkB;;;;;;AAO/B,MAAa,aAAqB,KAAK,KAAK;;;;;;AAO5C,MAAa,aAAqB,MAAM,KAAK;;;;;;;;;AAU7C,SAAgB,SAAS,SAAyB;CAChD,OAAO,UAAU;AACnB;;;;;;;;;AAUA,SAAgB,SAAS,SAAyB;CAChD,OAAO,UAAU;AACnB;;;;;;;;;;;;;;;;;AAkBA,SAAgB,MAAM,OAAe,KAAa,KAAqB;CACrE,IAAI,QAAQ,KACV,OAAO;CAET,IAAI,QAAQ,KACV,OAAO;CAET,OAAO;AACT;;;;;;;;;AAUA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,MAAM,OAAO,GAAG,CAAC;AAC1B;;;;;;;;;;;;;;;;;AAkBA,SAAgB,KAAK,GAAW,GAAW,GAAmB;CAC5D,OAAO,KAAK,IAAI,KAAK;AACvB;;;;;;;;;;;AAYA,SAAgB,YAAY,GAAW,GAAW,OAAuB;CACvE,IAAI,MAAM,GACR,OAAO;CAET,OAAO,SAAS,QAAQ,MAAM,IAAI,EAAE;AACtC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ifxError } from "./ignifx-error-R1ma_Lzv.js";
1
+ import { n as assertNever, o as CoreErrorCode, t as IgnifxError } from "./ignifx-error-CRh89KUJ.js";
2
2
  import { i as declaredTextureBinding, n as POST_EFFECT_FUNCTION, t as POST_EFFECT_BUILTIN_UNIFORMS } from "./post-effect-C42XJFmo.js";
3
3
  //#region src/render/post-effect-compiler.ts
4
4
  /**
@@ -308,4 +308,4 @@ function isBuiltinUniformName(name) {
308
308
  //#endregion
309
309
  export { compilePostEffect, compiledPostEffect, writePostEffectValues };
310
310
 
311
- //# sourceMappingURL=post-effect-compiler-Cq6cshjL.js.map
311
+ //# sourceMappingURL=post-effect-compiler-Rce26Eue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"post-effect-compiler-Cq6cshjL.js","names":[],"sources":["../src/render/post-effect-compiler.ts"],"sourcesContent":["import { CoreErrorCode } from \"../errors/error-codes.js\";\nimport { assertNever, IgnifxError } from \"../errors/ignifx-error.js\";\nimport {\n declaredTextureBinding,\n INPUT_SAMPLER_BINDING,\n INPUT_TEXTURE_BINDING,\n POST_EFFECT_BUILTIN_UNIFORMS,\n POST_EFFECT_FUNCTION,\n} from \"./post-effect.js\";\nimport type { CompiledPostEffect, PostEffectUniformField } from \"./post-effect.js\";\nimport type { ShaderAsset } from \"./shader-asset.js\";\nimport type { ShaderUniformType } from \"./shader-declaration.js\";\n\n/**\n * Turns a `// @ignifx post` file into the fragment module and uniform layout Babylon Lite's\n * fullscreen-effect path needs (`docs/plan/2026-09-terrain-particles-shaders.md` §3.3).\n *\n * `mainFragment` is a plain function, not an entry point: Lite hard-codes the entry-point names\n * `effectFullscreenVertex` and `effectFragment` (`lib/effect/effect-renderer.js` 7, 258-260), so the\n * entry point is generated here and forwards to it. `createEffectWrapper` takes a byte length and a\n * raw writer and computes no offsets, so the struct's member offsets are worked out here from WGSL's\n * own alignment rules and kept in step with the generated struct.\n *\n * Everything in this module is device-free and deterministic, so it is asserted in Node. It is\n * reached through `./post-effect-support.ts` so a game with no custom post effect never loads it.\n */\n\n/**\n * Compiles a `// @ignifx post` file into a full fragment module and a uniform layout.\n *\n * @remarks\n * Device-free and deterministic, so the whole thing is unit-testable: the result is a WGSL string\n * and a set of byte offsets. It is memoised per shader asset by {@link compiledPostEffect}, because\n * the chain asks for it on every rebuild.\n *\n * @param shader - The loaded shader asset.\n * @returns The compiled effect.\n * @throws IgnifxError with code `IGX-0709` when the file is not a `post` one, or `IGX-0723` when it\n * declares no `mainFragment` function.\n *\n * @example\n * ```ts\n * const compiled = compilePostEffect(vignette.value);\n * compiled.byName.get(\"amount\")?.byteOffset; // 20, right after the four built-ins\n * ```\n *\n * @internal\n */\nexport function compilePostEffect(shader: ShaderAsset): CompiledPostEffect {\n if (shader.declaration.kind !== \"post\") {\n throw new IgnifxError(\n CoreErrorCode.invalidAssetFile,\n `${shader.address} declares @ignifx ${shader.declaration.kind}, not @ignifx post.`,\n {\n context: { file: shader.address, format: \"@ignifx post\", kind: shader.declaration.kind },\n hint: \"A PostProcessStack custom effect takes a .post.wgsl file whose pragma is @ignifx post.\",\n },\n );\n }\n if (!new RegExp(`\\\\bfn\\\\s+${POST_EFFECT_FUNCTION}\\\\s*\\\\(`, \"u\").test(shader.source)) {\n throw new IgnifxError(\n CoreErrorCode.surfaceHookMissing,\n `${shader.address} declares no ${POST_EFFECT_FUNCTION} function.`,\n {\n context: { asset: shader.address, hook: POST_EFFECT_FUNCTION },\n hint: `Add fn ${POST_EFFECT_FUNCTION}(in: PostInput) -> vec4<f32>; the @fragment entry point is generated.`,\n },\n );\n }\n const declared = shader.declaration.uniforms.filter((uniform) => !isBuiltinUniformName(uniform.name));\n const layout = layOutUniforms([\n ...POST_EFFECT_BUILTIN_UNIFORMS,\n ...declared.map((uniform) => ({ name: uniform.name, type: uniform.type })),\n ]);\n const byName = new Map<string, PostEffectUniformField>();\n for (const field of layout.fields) {\n byName.set(field.name, field);\n }\n return {\n address: shader.address,\n fragmentWGSL: buildFragmentModule(shader, layout.fields),\n uniforms: layout.fields,\n byName,\n uniformByteLength: layout.byteLength,\n textures: shader.declaration.textures,\n };\n}\n\n/** The compiled form of each shader asset, so a chain rebuild recompiles nothing. */\nlet compiled: WeakMap<ShaderAsset, CompiledPostEffect> | null = null;\n\n/**\n * The compiled form of a post-effect shader, compiled once per asset.\n *\n * @remarks\n * Keyed on the `ShaderAsset` itself, so a hot reload — which replaces the asset object — recompiles\n * for free.\n *\n * @param shader - The loaded shader asset.\n * @returns The compiled effect.\n * @throws IgnifxError as {@link compilePostEffect} documents.\n *\n * @internal\n */\nexport function compiledPostEffect(shader: ShaderAsset): CompiledPostEffect {\n const cache = (compiled ??= new WeakMap<ShaderAsset, CompiledPostEffect>());\n const hit = cache.get(shader);\n if (hit !== undefined) {\n return hit;\n }\n const built = compilePostEffect(shader);\n cache.set(shader, built);\n return built;\n}\n\n/**\n * Writes an effect's current values into the bytes its uniform buffer takes.\n *\n * @remarks\n * The built-in clocks and `screenSize` are written by the caller through the same `out` buffer, so\n * this only fills in the declared members: the declaration's default first, then the settings'\n * override. Unknown names are refused, which is what makes a typo in a `.scene.json` visible.\n *\n * @param effect - The compiled effect.\n * @param shader - The shader, for its declared defaults.\n * @param values - The overrides.\n * @param out - The uniform bytes, at least `effect.uniformByteLength` long.\n * @throws IgnifxError with code `IGX-0712` for an undeclared name, or `IGX-0713` for a wrongly\n * shaped value.\n *\n * @internal\n */\nexport function writePostEffectValues(\n effect: CompiledPostEffect,\n shader: ShaderAsset,\n values: Readonly<Record<string, number | readonly number[]>>,\n out: Float32Array,\n): void {\n for (const uniform of shader.declaration.uniforms) {\n const field = effect.byName.get(uniform.name);\n if (field === undefined) {\n continue;\n }\n writeField(field, uniform.defaultValue, effect.address, out);\n }\n // `for…in` rather than `Object.keys`: the chain calls this every frame for every recorded effect\n // and a key array per effect per frame is per-frame allocation (coding standards §7).\n for (const name in values) {\n if (!Object.hasOwn(values, name)) {\n continue;\n }\n const field = effect.byName.get(name);\n const value = values[name];\n if (value === undefined) {\n continue;\n }\n if (field === undefined || isBuiltinUniformName(name)) {\n throw new IgnifxError(\n CoreErrorCode.unknownShaderBinding,\n `${effect.address} declares no uniform named ${name}.`,\n {\n context: { material: effect.address, asset: effect.address, name },\n hint: `It declares ${[...effect.byName.keys()].join(\", \")}.`,\n },\n );\n }\n writeField(field, value, effect.address, out);\n }\n}\n\n/** The result of laying out a uniform struct. */\ninterface UniformLayout {\n /** The members, in struct order. */\n readonly fields: readonly PostEffectUniformField[];\n /** The struct's size, in bytes. */\n readonly byteLength: number;\n}\n\n/**\n * Computes the byte offsets WGSL gives a struct of these members, in this order.\n *\n * @remarks\n * The rules are the WGSL specification's: a member's offset is its predecessor's end rounded up to\n * the member's alignment, and the struct's size is the last member's end rounded up to the struct's\n * alignment — the largest member alignment, and in the **uniform** address space never less than\n * 16. `vec3<f32>` is the one that catches people out: 16-aligned, 12 wide (plan §3.4).\n *\n * @param members - The members, in declaration order.\n * @returns The layout.\n */\nfunction layOutUniforms(\n members: readonly { readonly name: string; readonly type: ShaderUniformType }[],\n): UniformLayout {\n const fields: PostEffectUniformField[] = [];\n let offset = 0;\n // WGSL's uniform address space rounds a struct's alignment up to a multiple of 16, so the block's\n // size is always a multiple of 16 whatever its members are.\n let structAlignment = 16;\n for (const member of members) {\n const alignment = typeAlignment(member.type);\n const size = typeSize(member.type);\n structAlignment = Math.max(structAlignment, alignment);\n offset = roundUp(offset, alignment);\n fields.push({\n name: member.name,\n type: member.type,\n components: componentCount(member.type),\n byteOffset: offset,\n });\n offset += size;\n }\n return { fields, byteLength: roundUp(offset, structAlignment) };\n}\n\n/**\n * A WGSL type's alignment in the uniform address space, in bytes.\n *\n * @param type - The type.\n * @returns The alignment.\n */\nfunction typeAlignment(type: ShaderUniformType): number {\n switch (type) {\n case \"vec2<f32>\": {\n return 8;\n }\n case \"vec3<f32>\":\n case \"vec4<f32>\":\n case \"mat4x4<f32>\": {\n return 16;\n }\n case \"f32\":\n case \"u32\":\n case \"i32\": {\n return 4;\n }\n default: {\n return assertNever(type, \"shader uniform type\");\n }\n }\n}\n\n/**\n * A WGSL type's size, in bytes.\n *\n * @param type - The type.\n * @returns The size.\n */\nfunction typeSize(type: ShaderUniformType): number {\n switch (type) {\n case \"vec2<f32>\": {\n return 8;\n }\n case \"vec3<f32>\": {\n return 12;\n }\n case \"vec4<f32>\": {\n return 16;\n }\n case \"mat4x4<f32>\": {\n return 64;\n }\n case \"f32\":\n case \"u32\":\n case \"i32\": {\n return 4;\n }\n default: {\n return assertNever(type, \"shader uniform type\");\n }\n }\n}\n\n/**\n * How many floats one uniform of a declared type occupies.\n *\n * @remarks\n * A private copy of `material-plugin.ts`'s `uniformComponentCount`. `PostProcessStack` is in every\n * game's static graph, and importing it from there would drag `defineMaterialPlugin` and the\n * reserved-name table into a bundle that draws no custom shader at all.\n *\n * @param type - The declared WGSL type.\n * @returns The component count: 1, 2, 3, 4, or 16.\n */\nfunction componentCount(type: ShaderUniformType): number {\n switch (type) {\n case \"vec2<f32>\": {\n return 2;\n }\n case \"vec3<f32>\": {\n return 3;\n }\n case \"vec4<f32>\": {\n return 4;\n }\n case \"mat4x4<f32>\": {\n return 16;\n }\n case \"f32\":\n case \"u32\":\n case \"i32\": {\n return 1;\n }\n default: {\n return assertNever(type, \"shader uniform type\");\n }\n }\n}\n\n/**\n * Rounds a value up to a multiple of an alignment.\n *\n * @param value - The value.\n * @param alignment - The alignment, a power of two.\n * @returns The rounded value.\n */\nfunction roundUp(value: number, alignment: number): number {\n return Math.ceil(value / alignment) * alignment;\n}\n\n/**\n * The whole fragment module: bindings, generated structs, the author's file, and the entry point\n * Lite's pipeline looks for.\n *\n * @param shader - The shader asset.\n * @param fields - The uniform members, in struct order.\n * @returns The WGSL.\n */\nfunction buildFragmentModule(shader: ShaderAsset, fields: readonly PostEffectUniformField[]): string {\n const members = fields.map((field) => `${field.name}:${field.type},`).join(\"\");\n const lines: string[] = [\n `struct PostUniforms{${members}}`,\n \"@group(0)@binding(0)var<uniform>shaderUniforms:PostUniforms;\",\n `@group(0)@binding(${String(INPUT_TEXTURE_BINDING)})var inputTexture:texture_2d<f32>;`,\n `@group(0)@binding(${String(INPUT_SAMPLER_BINDING)})var inputTextureSampler:sampler;`,\n ];\n // `for…of` with an index: the iterator yields the element type rather than `T | undefined`, and\n // this runs once per compiled shader rather than per frame.\n let index = -1;\n for (const declaration of shader.declaration.textures) {\n index += 1;\n const binding = declaredTextureBinding(index);\n const type = declaration.array ? \"texture_2d_array<f32>\" : \"texture_2d<f32>\";\n lines.push(\n `@group(0)@binding(${String(binding)})var ${declaration.name}:${type};`,\n `@group(0)@binding(${String(binding + 1)})var ${declaration.name}Sampler:sampler;`,\n );\n }\n lines.push(\n \"struct PostInput{uv:vec2<f32>,position:vec2<f32>,}\",\n shader.source,\n \"@fragment fn effectFragment(fragment:EffectVertexOutput)->@location(0)vec4<f32>{\",\n \"var ignifxPostInput:PostInput;\",\n // Lite's effect vertex puts uv (0, 0) at the bottom-left, but a texture's origin is the top-left,\n // so an unflipped uv mirrors the frame on every pass (`lib/effect/effect-renderer.js` 7).\n \"ignifxPostInput.uv=vec2<f32>(fragment.uv.x,1.0-fragment.uv.y);\",\n \"ignifxPostInput.position=fragment.position.xy;\",\n `return ${POST_EFFECT_FUNCTION}(ignifxPostInput);`,\n \"}\",\n );\n return lines.join(\"\\n\");\n}\n\n/**\n * Writes one member's value into the uniform bytes.\n *\n * @param field - The member.\n * @param value - The value.\n * @param asset - The shader's address, for diagnostics.\n * @param out - The uniform floats.\n * @throws IgnifxError with code `IGX-0713` when the shape does not match.\n */\nfunction writeField(\n field: PostEffectUniformField,\n value: number | readonly number[],\n asset: string,\n out: Float32Array,\n): void {\n const index = field.byteOffset / 4;\n if (typeof value === \"number\") {\n if (field.components !== 1) {\n throw mismatch(field, asset, \"a single number\");\n }\n out[index] = value;\n return;\n }\n if (value.length !== field.components) {\n throw mismatch(field, asset, `${String(value.length)} floats`);\n }\n out.set(value instanceof Float32Array ? value : Float32Array.from(value), index);\n}\n\n/**\n * The `IGX-0713` failure a wrongly shaped value produces.\n *\n * @param field - The member.\n * @param asset - The shader's address.\n * @param actual - What the caller passed.\n * @returns The error to throw.\n */\nfunction mismatch(field: PostEffectUniformField, asset: string, actual: string): IgnifxError {\n return new IgnifxError(\n CoreErrorCode.shaderValueMismatch,\n `${field.name} on ${asset} expects ${field.type} (${String(field.components)} floats), not ${actual}.`,\n {\n context: { name: field.name, material: asset, expected: field.type, actual },\n hint: \"A post effect's values are numbers and numeric arrays; a colour takes its three or four components.\",\n },\n );\n}\n\n/**\n * Whether a name is one of the four uniforms every post effect gets for free.\n *\n * @param name - The candidate.\n * @returns `true` when the engine writes it.\n */\nfunction isBuiltinUniformName(name: string): boolean {\n for (const builtin of POST_EFFECT_BUILTIN_UNIFORMS) {\n if (builtin.name === name) {\n return true;\n }\n }\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,kBAAkB,QAAyC;CACzE,IAAI,OAAO,YAAY,SAAS,QAC9B,MAAM,IAAI,YACR,cAAc,kBACd,GAAG,OAAO,QAAQ,oBAAoB,OAAO,YAAY,KAAK,sBAC9D;EACE,SAAS;GAAE,MAAM,OAAO;GAAS,QAAQ;GAAgB,MAAM,OAAO,YAAY;EAAK;EACvF,MAAM;CACR,CACF;CAEF,IAAI,CAAC,IAAI,OAAO,gCAA2C,GAAG,CAAC,CAAC,KAAK,OAAO,MAAM,GAChF,MAAM,IAAI,YACR,cAAc,oBACd,GAAG,OAAO,QAAQ,eAAe,qBAAqB,aACtD;EACE,SAAS;GAAE,OAAO,OAAO;GAAS,MAAM;EAAqB;EAC7D,MAAM,UAAU,qBAAqB;CACvC,CACF;CAEF,MAAM,WAAW,OAAO,YAAY,SAAS,QAAQ,YAAY,CAAC,qBAAqB,QAAQ,IAAI,CAAC;CACpG,MAAM,SAAS,eAAe,CAC5B,GAAG,8BACH,GAAG,SAAS,KAAK,aAAa;EAAE,MAAM,QAAQ;EAAM,MAAM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AAU,EAAE,gBAAgB,OAAO,IACpG;EACE,SAAS;GAAE,MAAM,MAAM;GAAM,UAAU;GAAO,UAAU,MAAM;GAAM;EAAO;EAC3E,MAAM;CACR,CACF;AACF;;;;;;;AAQA,SAAS,qBAAqB,MAAuB;CACnD,KAAK,MAAM,WAAW,8BACpB,IAAI,QAAQ,SAAS,MACnB,OAAO;CAGX,OAAO;AACT"}
1
+ {"version":3,"file":"post-effect-compiler-Rce26Eue.js","names":[],"sources":["../src/render/post-effect-compiler.ts"],"sourcesContent":["import { CoreErrorCode } from \"../errors/error-codes.js\";\nimport { assertNever, IgnifxError } from \"../errors/ignifx-error.js\";\nimport {\n declaredTextureBinding,\n INPUT_SAMPLER_BINDING,\n INPUT_TEXTURE_BINDING,\n POST_EFFECT_BUILTIN_UNIFORMS,\n POST_EFFECT_FUNCTION,\n} from \"./post-effect.js\";\nimport type { CompiledPostEffect, PostEffectUniformField } from \"./post-effect.js\";\nimport type { ShaderAsset } from \"./shader-asset.js\";\nimport type { ShaderUniformType } from \"./shader-declaration.js\";\n\n/**\n * Turns a `// @ignifx post` file into the fragment module and uniform layout Babylon Lite's\n * fullscreen-effect path needs (`docs/plan/2026-09-terrain-particles-shaders.md` §3.3).\n *\n * `mainFragment` is a plain function, not an entry point: Lite hard-codes the entry-point names\n * `effectFullscreenVertex` and `effectFragment` (`lib/effect/effect-renderer.js` 7, 258-260), so the\n * entry point is generated here and forwards to it. `createEffectWrapper` takes a byte length and a\n * raw writer and computes no offsets, so the struct's member offsets are worked out here from WGSL's\n * own alignment rules and kept in step with the generated struct.\n *\n * Everything in this module is device-free and deterministic, so it is asserted in Node. It is\n * reached through `./post-effect-support.ts` so a game with no custom post effect never loads it.\n */\n\n/**\n * Compiles a `// @ignifx post` file into a full fragment module and a uniform layout.\n *\n * @remarks\n * Device-free and deterministic, so the whole thing is unit-testable: the result is a WGSL string\n * and a set of byte offsets. It is memoised per shader asset by {@link compiledPostEffect}, because\n * the chain asks for it on every rebuild.\n *\n * @param shader - The loaded shader asset.\n * @returns The compiled effect.\n * @throws IgnifxError with code `IGX-0709` when the file is not a `post` one, or `IGX-0723` when it\n * declares no `mainFragment` function.\n *\n * @example\n * ```ts\n * const compiled = compilePostEffect(vignette.value);\n * compiled.byName.get(\"amount\")?.byteOffset; // 20, right after the four built-ins\n * ```\n *\n * @internal\n */\nexport function compilePostEffect(shader: ShaderAsset): CompiledPostEffect {\n if (shader.declaration.kind !== \"post\") {\n throw new IgnifxError(\n CoreErrorCode.invalidAssetFile,\n `${shader.address} declares @ignifx ${shader.declaration.kind}, not @ignifx post.`,\n {\n context: { file: shader.address, format: \"@ignifx post\", kind: shader.declaration.kind },\n hint: \"A PostProcessStack custom effect takes a .post.wgsl file whose pragma is @ignifx post.\",\n },\n );\n }\n if (!new RegExp(`\\\\bfn\\\\s+${POST_EFFECT_FUNCTION}\\\\s*\\\\(`, \"u\").test(shader.source)) {\n throw new IgnifxError(\n CoreErrorCode.surfaceHookMissing,\n `${shader.address} declares no ${POST_EFFECT_FUNCTION} function.`,\n {\n context: { asset: shader.address, hook: POST_EFFECT_FUNCTION },\n hint: `Add fn ${POST_EFFECT_FUNCTION}(in: PostInput) -> vec4<f32>; the @fragment entry point is generated.`,\n },\n );\n }\n const declared = shader.declaration.uniforms.filter((uniform) => !isBuiltinUniformName(uniform.name));\n const layout = layOutUniforms([\n ...POST_EFFECT_BUILTIN_UNIFORMS,\n ...declared.map((uniform) => ({ name: uniform.name, type: uniform.type })),\n ]);\n const byName = new Map<string, PostEffectUniformField>();\n for (const field of layout.fields) {\n byName.set(field.name, field);\n }\n return {\n address: shader.address,\n fragmentWGSL: buildFragmentModule(shader, layout.fields),\n uniforms: layout.fields,\n byName,\n uniformByteLength: layout.byteLength,\n textures: shader.declaration.textures,\n };\n}\n\n/** The compiled form of each shader asset, so a chain rebuild recompiles nothing. */\nlet compiled: WeakMap<ShaderAsset, CompiledPostEffect> | null = null;\n\n/**\n * The compiled form of a post-effect shader, compiled once per asset.\n *\n * @remarks\n * Keyed on the `ShaderAsset` itself, so a hot reload — which replaces the asset object — recompiles\n * for free.\n *\n * @param shader - The loaded shader asset.\n * @returns The compiled effect.\n * @throws IgnifxError as {@link compilePostEffect} documents.\n *\n * @internal\n */\nexport function compiledPostEffect(shader: ShaderAsset): CompiledPostEffect {\n const cache = (compiled ??= new WeakMap<ShaderAsset, CompiledPostEffect>());\n const hit = cache.get(shader);\n if (hit !== undefined) {\n return hit;\n }\n const built = compilePostEffect(shader);\n cache.set(shader, built);\n return built;\n}\n\n/**\n * Writes an effect's current values into the bytes its uniform buffer takes.\n *\n * @remarks\n * The built-in clocks and `screenSize` are written by the caller through the same `out` buffer, so\n * this only fills in the declared members: the declaration's default first, then the settings'\n * override. Unknown names are refused, which is what makes a typo in a `.scene.json` visible.\n *\n * @param effect - The compiled effect.\n * @param shader - The shader, for its declared defaults.\n * @param values - The overrides.\n * @param out - The uniform bytes, at least `effect.uniformByteLength` long.\n * @throws IgnifxError with code `IGX-0712` for an undeclared name, or `IGX-0713` for a wrongly\n * shaped value.\n *\n * @internal\n */\nexport function writePostEffectValues(\n effect: CompiledPostEffect,\n shader: ShaderAsset,\n values: Readonly<Record<string, number | readonly number[]>>,\n out: Float32Array,\n): void {\n for (const uniform of shader.declaration.uniforms) {\n const field = effect.byName.get(uniform.name);\n if (field === undefined) {\n continue;\n }\n writeField(field, uniform.defaultValue, effect.address, out);\n }\n // `for…in` rather than `Object.keys`: the chain calls this every frame for every recorded effect\n // and a key array per effect per frame is per-frame allocation (coding standards §7).\n for (const name in values) {\n if (!Object.hasOwn(values, name)) {\n continue;\n }\n const field = effect.byName.get(name);\n const value = values[name];\n if (value === undefined) {\n continue;\n }\n if (field === undefined || isBuiltinUniformName(name)) {\n throw new IgnifxError(\n CoreErrorCode.unknownShaderBinding,\n `${effect.address} declares no uniform named ${name}.`,\n {\n context: { material: effect.address, asset: effect.address, name },\n hint: `It declares ${[...effect.byName.keys()].join(\", \")}.`,\n },\n );\n }\n writeField(field, value, effect.address, out);\n }\n}\n\n/** The result of laying out a uniform struct. */\ninterface UniformLayout {\n /** The members, in struct order. */\n readonly fields: readonly PostEffectUniformField[];\n /** The struct's size, in bytes. */\n readonly byteLength: number;\n}\n\n/**\n * Computes the byte offsets WGSL gives a struct of these members, in this order.\n *\n * @remarks\n * The rules are the WGSL specification's: a member's offset is its predecessor's end rounded up to\n * the member's alignment, and the struct's size is the last member's end rounded up to the struct's\n * alignment — the largest member alignment, and in the **uniform** address space never less than\n * 16. `vec3<f32>` is the one that catches people out: 16-aligned, 12 wide (plan §3.4).\n *\n * @param members - The members, in declaration order.\n * @returns The layout.\n */\nfunction layOutUniforms(\n members: readonly { readonly name: string; readonly type: ShaderUniformType }[],\n): UniformLayout {\n const fields: PostEffectUniformField[] = [];\n let offset = 0;\n // WGSL's uniform address space rounds a struct's alignment up to a multiple of 16, so the block's\n // size is always a multiple of 16 whatever its members are.\n let structAlignment = 16;\n for (const member of members) {\n const alignment = typeAlignment(member.type);\n const size = typeSize(member.type);\n structAlignment = Math.max(structAlignment, alignment);\n offset = roundUp(offset, alignment);\n fields.push({\n name: member.name,\n type: member.type,\n components: componentCount(member.type),\n byteOffset: offset,\n });\n offset += size;\n }\n return { fields, byteLength: roundUp(offset, structAlignment) };\n}\n\n/**\n * A WGSL type's alignment in the uniform address space, in bytes.\n *\n * @param type - The type.\n * @returns The alignment.\n */\nfunction typeAlignment(type: ShaderUniformType): number {\n switch (type) {\n case \"vec2<f32>\": {\n return 8;\n }\n case \"vec3<f32>\":\n case \"vec4<f32>\":\n case \"mat4x4<f32>\": {\n return 16;\n }\n case \"f32\":\n case \"u32\":\n case \"i32\": {\n return 4;\n }\n default: {\n return assertNever(type, \"shader uniform type\");\n }\n }\n}\n\n/**\n * A WGSL type's size, in bytes.\n *\n * @param type - The type.\n * @returns The size.\n */\nfunction typeSize(type: ShaderUniformType): number {\n switch (type) {\n case \"vec2<f32>\": {\n return 8;\n }\n case \"vec3<f32>\": {\n return 12;\n }\n case \"vec4<f32>\": {\n return 16;\n }\n case \"mat4x4<f32>\": {\n return 64;\n }\n case \"f32\":\n case \"u32\":\n case \"i32\": {\n return 4;\n }\n default: {\n return assertNever(type, \"shader uniform type\");\n }\n }\n}\n\n/**\n * How many floats one uniform of a declared type occupies.\n *\n * @remarks\n * A private copy of `material-plugin.ts`'s `uniformComponentCount`. `PostProcessStack` is in every\n * game's static graph, and importing it from there would drag `defineMaterialPlugin` and the\n * reserved-name table into a bundle that draws no custom shader at all.\n *\n * @param type - The declared WGSL type.\n * @returns The component count: 1, 2, 3, 4, or 16.\n */\nfunction componentCount(type: ShaderUniformType): number {\n switch (type) {\n case \"vec2<f32>\": {\n return 2;\n }\n case \"vec3<f32>\": {\n return 3;\n }\n case \"vec4<f32>\": {\n return 4;\n }\n case \"mat4x4<f32>\": {\n return 16;\n }\n case \"f32\":\n case \"u32\":\n case \"i32\": {\n return 1;\n }\n default: {\n return assertNever(type, \"shader uniform type\");\n }\n }\n}\n\n/**\n * Rounds a value up to a multiple of an alignment.\n *\n * @param value - The value.\n * @param alignment - The alignment, a power of two.\n * @returns The rounded value.\n */\nfunction roundUp(value: number, alignment: number): number {\n return Math.ceil(value / alignment) * alignment;\n}\n\n/**\n * The whole fragment module: bindings, generated structs, the author's file, and the entry point\n * Lite's pipeline looks for.\n *\n * @param shader - The shader asset.\n * @param fields - The uniform members, in struct order.\n * @returns The WGSL.\n */\nfunction buildFragmentModule(shader: ShaderAsset, fields: readonly PostEffectUniformField[]): string {\n const members = fields.map((field) => `${field.name}:${field.type},`).join(\"\");\n const lines: string[] = [\n `struct PostUniforms{${members}}`,\n \"@group(0)@binding(0)var<uniform>shaderUniforms:PostUniforms;\",\n `@group(0)@binding(${String(INPUT_TEXTURE_BINDING)})var inputTexture:texture_2d<f32>;`,\n `@group(0)@binding(${String(INPUT_SAMPLER_BINDING)})var inputTextureSampler:sampler;`,\n ];\n // `for…of` with an index: the iterator yields the element type rather than `T | undefined`, and\n // this runs once per compiled shader rather than per frame.\n let index = -1;\n for (const declaration of shader.declaration.textures) {\n index += 1;\n const binding = declaredTextureBinding(index);\n const type = declaration.array ? \"texture_2d_array<f32>\" : \"texture_2d<f32>\";\n lines.push(\n `@group(0)@binding(${String(binding)})var ${declaration.name}:${type};`,\n `@group(0)@binding(${String(binding + 1)})var ${declaration.name}Sampler:sampler;`,\n );\n }\n lines.push(\n \"struct PostInput{uv:vec2<f32>,position:vec2<f32>,}\",\n shader.source,\n \"@fragment fn effectFragment(fragment:EffectVertexOutput)->@location(0)vec4<f32>{\",\n \"var ignifxPostInput:PostInput;\",\n // Lite's effect vertex puts uv (0, 0) at the bottom-left, but a texture's origin is the top-left,\n // so an unflipped uv mirrors the frame on every pass (`lib/effect/effect-renderer.js` 7).\n \"ignifxPostInput.uv=vec2<f32>(fragment.uv.x,1.0-fragment.uv.y);\",\n \"ignifxPostInput.position=fragment.position.xy;\",\n `return ${POST_EFFECT_FUNCTION}(ignifxPostInput);`,\n \"}\",\n );\n return lines.join(\"\\n\");\n}\n\n/**\n * Writes one member's value into the uniform bytes.\n *\n * @param field - The member.\n * @param value - The value.\n * @param asset - The shader's address, for diagnostics.\n * @param out - The uniform floats.\n * @throws IgnifxError with code `IGX-0713` when the shape does not match.\n */\nfunction writeField(\n field: PostEffectUniformField,\n value: number | readonly number[],\n asset: string,\n out: Float32Array,\n): void {\n const index = field.byteOffset / 4;\n if (typeof value === \"number\") {\n if (field.components !== 1) {\n throw mismatch(field, asset, \"a single number\");\n }\n out[index] = value;\n return;\n }\n if (value.length !== field.components) {\n throw mismatch(field, asset, `${String(value.length)} floats`);\n }\n out.set(value instanceof Float32Array ? value : Float32Array.from(value), index);\n}\n\n/**\n * The `IGX-0713` failure a wrongly shaped value produces.\n *\n * @param field - The member.\n * @param asset - The shader's address.\n * @param actual - What the caller passed.\n * @returns The error to throw.\n */\nfunction mismatch(field: PostEffectUniformField, asset: string, actual: string): IgnifxError {\n return new IgnifxError(\n CoreErrorCode.shaderValueMismatch,\n `${field.name} on ${asset} expects ${field.type} (${String(field.components)} floats), not ${actual}.`,\n {\n context: { name: field.name, material: asset, expected: field.type, actual },\n hint: \"A post effect's values are numbers and numeric arrays; a colour takes its three or four components.\",\n },\n );\n}\n\n/**\n * Whether a name is one of the four uniforms every post effect gets for free.\n *\n * @param name - The candidate.\n * @returns `true` when the engine writes it.\n */\nfunction isBuiltinUniformName(name: string): boolean {\n for (const builtin of POST_EFFECT_BUILTIN_UNIFORMS) {\n if (builtin.name === name) {\n return true;\n }\n }\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,kBAAkB,QAAyC;CACzE,IAAI,OAAO,YAAY,SAAS,QAC9B,MAAM,IAAI,YACR,cAAc,kBACd,GAAG,OAAO,QAAQ,oBAAoB,OAAO,YAAY,KAAK,sBAC9D;EACE,SAAS;GAAE,MAAM,OAAO;GAAS,QAAQ;GAAgB,MAAM,OAAO,YAAY;EAAK;EACvF,MAAM;CACR,CACF;CAEF,IAAI,CAAC,IAAI,OAAO,gCAA2C,GAAG,CAAC,CAAC,KAAK,OAAO,MAAM,GAChF,MAAM,IAAI,YACR,cAAc,oBACd,GAAG,OAAO,QAAQ,eAAe,qBAAqB,aACtD;EACE,SAAS;GAAE,OAAO,OAAO;GAAS,MAAM;EAAqB;EAC7D,MAAM,UAAU,qBAAqB;CACvC,CACF;CAEF,MAAM,WAAW,OAAO,YAAY,SAAS,QAAQ,YAAY,CAAC,qBAAqB,QAAQ,IAAI,CAAC;CACpG,MAAM,SAAS,eAAe,CAC5B,GAAG,8BACH,GAAG,SAAS,KAAK,aAAa;EAAE,MAAM,QAAQ;EAAM,MAAM,QAAQ;CAAK,EAAE,CAC3E,CAAC;CACD,MAAM,yBAAS,IAAI,IAAoC;CACvD,KAAK,MAAM,SAAS,OAAO,QACzB,OAAO,IAAI,MAAM,MAAM,KAAK;CAE9B,OAAO;EACL,SAAS,OAAO;EAChB,cAAc,oBAAoB,QAAQ,O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BACpB,IAAI,QAAQ,SAAS,MACnB,OAAO;CAGX,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"shader-declaration-5q__jycG.js","names":[],"sources":["../src/render/shader-declaration.ts"],"sourcesContent":["/**\n * The vocabulary a `// @ignifx` pragma declares: the three authoring forms, the WGSL types and\n * attribute names Babylon Lite accepts, the uniforms ignifx supplies, and the parsed declaration\n * itself (`docs/plan/2026-09-terrain-particles-shaders.md` §3.1).\n *\n * Split from `./shader-pragma.ts` so these few hundred bytes can stay in the barrel while the parser\n * lives in a chunk only the `.wgsl` loader fetches (`./shader-support.ts`).\n */\n\n/**\n * The three authoring forms the form directive names, in the order the documentation lists them.\n *\n * @public\n */\nexport const SHADER_KINDS = [\"shader\", \"surface\", \"post\"] as const;\n\n/**\n * Which of the three authoring forms a `.wgsl` file is: a full custom material, a surface shader\n * that hooks into the engine's lit materials, or a full-screen post effect.\n *\n * @public\n */\nexport type ShaderKind = (typeof SHADER_KINDS)[number];\n\n/**\n * The WGSL types a declared uniform may have — Babylon Lite's set (`index.d.ts` 11445).\n *\n * @public\n */\nexport const SHADER_UNIFORM_TYPES = [\n \"f32\",\n \"u32\",\n \"i32\",\n \"vec2<f32>\",\n \"vec3<f32>\",\n \"vec4<f32>\",\n \"mat4x4<f32>\",\n] as const;\n\n/**\n * The union of the uniform types a declaration may name.\n *\n * @public\n */\nexport type ShaderUniformType = (typeof SHADER_UNIFORM_TYPES)[number];\n\n/**\n * The vertex attributes a shader material can bind — Babylon Lite's fixed set\n * (`index.d.ts` 11295). A name outside this list is reported with its line.\n *\n * @public\n */\nexport const SHADER_ATTRIBUTE_NAMES = [\n \"position\",\n \"normal\",\n \"uv\",\n \"uv2\",\n \"tangent\",\n \"color\",\n \"joints\",\n \"weights\",\n \"joints1\",\n \"weights1\",\n] as const;\n\n/**\n * The union of the attribute names a declaration may name.\n *\n * @public\n */\nexport type ShaderAttributeName = (typeof SHADER_ATTRIBUTE_NAMES)[number];\n\n/**\n * The uniforms Babylon Lite fills in itself every frame, read in WGSL as `shaderSystem.<name>`\n * (`index.d.ts` 11432).\n *\n * @remarks\n * Two of them lie under `rendering.useFloatingOrigin`: `cameraPosition` reads `(0, 0, 0)` and the\n * world matrices are camera-relative. With instancing on, `world`, `worldView`, and\n * `worldViewProjection` are **not** instance-aware — the shader composes\n * `shaderSystem.world * mat4x4(input.world0, input.world1, input.world2, input.world3)`.\n *\n * @public\n */\nexport const LITE_SYSTEM_UNIFORM_NAMES = [\n \"world\",\n \"view\",\n \"projection\",\n \"viewProjection\",\n \"worldView\",\n \"worldViewProjection\",\n \"cameraPosition\",\n \"screenSize\",\n \"alphaCutoff\",\n] as const;\n\n/**\n * The union of the Babylon Lite system uniform names.\n *\n * @public\n */\nexport type LiteSystemUniformName = (typeof LITE_SYSTEM_UNIFORM_NAMES)[number];\n\n/**\n * The uniforms **ignifx** fills in every frame, read in WGSL as `shaderUniforms.<name>`\n * (`docs/plan/2026-09-terrain-particles-shaders.md` §3.1). Babylon Lite has no clock and no light\n * bindings for a shader material, so these are the engine's own addition.\n *\n * @public\n */\nexport const IGNIFX_UNIFORM_NAMES = [\n \"time\",\n \"unscaledTime\",\n \"deltaTime\",\n \"mainLightDirection\",\n \"mainLightColor\",\n \"ambientColor\",\n] as const;\n\n/**\n * The union of the ignifx-provided uniform names.\n *\n * @public\n */\nexport type IgnifxUniformName = (typeof IGNIFX_UNIFORM_NAMES)[number];\n\n/**\n * The WGSL type of each ignifx-provided uniform, which is what the custom uniform block is laid out\n * from.\n *\n * @internal\n */\nexport const IGNIFX_UNIFORM_TYPES: Readonly<Record<IgnifxUniformName, ShaderUniformType>> = Object.freeze({\n time: \"f32\",\n unscaledTime: \"f32\",\n deltaTime: \"f32\",\n mainLightDirection: \"vec3<f32>\",\n mainLightColor: \"vec3<f32>\",\n ambientColor: \"vec3<f32>\",\n});\n\n/**\n * The 1x1 fallback textures a declaration can bind when nothing else is.\n *\n * @public\n */\nexport const SHADER_TEXTURE_FALLBACKS = [\"white\", \"black\", \"transparent\"] as const;\n\n/**\n * Which 1x1 texture is bound to a declared sampler that nothing has filled in\n * (Godot's `hint_default_*`).\n *\n * @public\n */\nexport type ShaderTextureFallback = (typeof SHADER_TEXTURE_FALLBACKS)[number];\n\n/**\n * How a shader material composites its fragments.\n *\n * @public\n */\nexport const SHADER_BLEND_MODES = [\"opaque\", \"alpha\", \"additive\", \"premultiplied\"] as const;\n\n/**\n * The blend modes a declaration may ask for.\n *\n * @public\n */\nexport type ShaderBlendMode = (typeof SHADER_BLEND_MODES)[number];\n\n/**\n * Which faces are drawn. `\"front\"` is accepted by the grammar and refused by the parser, because\n * Babylon Lite 1.27.0 exposes only `backFaceCulling`.\n *\n * @public\n */\nexport const SHADER_CULL_MODES = [\"back\", \"front\", \"none\"] as const;\n\n/**\n * The face-culling modes a declaration may ask for. `\"front\"` is refused: Babylon Lite 1.27.0\n * exposes only `backFaceCulling`.\n *\n * @public\n */\nexport type ShaderCullMode = (typeof SHADER_CULL_MODES)[number];\n\n/**\n * Which instance streams the vertex stage reads.\n *\n * @public\n */\nexport const SHADER_INSTANCING_MODES = [\"none\", \"matrices\", \"matrices-colors\"] as const;\n\n/**\n * How a declaration expects to be drawn: one mesh at a time, or thin-instanced with a matrix slab\n * and optionally a per-instance colour.\n *\n * @public\n */\nexport type ShaderInstancingMode = (typeof SHADER_INSTANCING_MODES)[number];\n\n/**\n * One `// @ignifx uniform …` line: a value a material sets and the vertex or fragment stage reads\n * as `shaderUniforms.<name>`.\n *\n * @public\n */\nexport interface ShaderUniformDeclaration {\n /** The WGSL identifier. */\n readonly name: string;\n /** The WGSL type. */\n readonly type: ShaderUniformType;\n /**\n * The value a material starts with. A colour default is the **sRGB** value the file wrote; the\n * material layer decodes it to linear on the way to the GPU.\n */\n readonly defaultValue: number | readonly number[];\n /** Whether the value is a colour, declared with `color(…)` or the bare `color` modifier. */\n readonly color: boolean;\n /** The inclusive slider bounds an inspector should offer, or `null`. */\n readonly range: readonly [number, number] | null;\n /** The slider increment an inspector should use, or `null`. */\n readonly step: number | null;\n /** One sentence describing the uniform, or `null`. */\n readonly tooltip: string | null;\n}\n\n/**\n * One `// @ignifx texture …` line: a `texture_2d<f32>` (or `texture_2d_array<f32>`) plus the\n * `<name>Sampler` Babylon Lite generates beside it.\n *\n * @public\n */\nexport interface ShaderTextureDeclaration {\n /** The WGSL identifier; the sampler is `<name>Sampler`. */\n readonly name: string;\n /** Whether the texture holds sRGB-encoded colour, which the texture import needs to know. */\n readonly srgb: boolean;\n /** Whether the texture is a tangent-space normal map. */\n readonly normal: boolean;\n /**\n * Which 1x1 texture is bound when a material binds nothing, or `null` for the implicit `\"white\"`.\n *\n * @remarks\n * A declared sampler that nothing fills in cannot be left unbound: Babylon Lite refuses to build\n * a bind group for it (error 309), so *something* is always bound.\n */\n readonly fallback: ShaderTextureFallback | null;\n /** Whether the binding is a `texture_2d_array<f32>` rather than a `texture_2d<f32>`. */\n readonly array: boolean;\n}\n\n/**\n * One `// @ignifx storage …` line: a read-only storage buffer the shader indexes.\n *\n * @public\n */\nexport interface ShaderStorageDeclaration {\n /** The WGSL identifier. */\n readonly name: string;\n /** The WGSL variable type, verbatim, for example `array<Particle>`. */\n readonly type: string;\n}\n\n/**\n * One `// @ignifx define …` line: a WGSL `const` a material may override.\n *\n * @public\n */\nexport interface ShaderDefineDeclaration {\n /** The WGSL identifier. */\n readonly name: string;\n /** The value; a boolean compiles to `bool`, a number to `f32`. */\n readonly value: boolean | number;\n}\n\n/**\n * The three hooks a `.surface.wgsl` file may provide.\n *\n * @public\n */\nexport const SURFACE_HOOK_NAMES = [\"displace\", \"surface\", \"composite\"] as const;\n\n/**\n * One of the three surface-shader hooks.\n *\n * @public\n */\nexport type SurfaceHookName = (typeof SURFACE_HOOK_NAMES)[number];\n\n/**\n * The uniform block name a surface shader reads its declared uniforms from.\n *\n * @public\n */\nexport const SURFACE_UNIFORM_BLOCK = \"surfaceUniforms\";\n\n/**\n * The pipeline state a `// @ignifx blend …` line declares.\n *\n * @public\n */\nexport interface ShaderPipelineState {\n /** How fragments are composited. */\n readonly blend: ShaderBlendMode;\n /** Which faces are drawn. */\n readonly cull: ShaderCullMode;\n /**\n * Whether the draw writes depth. Defaults to `true` for an opaque surface and `false` for a\n * blended one — Babylon Lite's own rule — unless the file says `depthWrite on` explicitly.\n */\n readonly depthWrite: boolean;\n /** Whether the draw depth-tests at all; `false` compiles `depthCompare: \"always\"`. */\n readonly depthTest: boolean;\n /** Whether the surface samples the opaque scene colour behind it. Requires a blended surface. */\n readonly transmissive: boolean;\n /** Which instance streams the vertex stage reads. */\n readonly instancing: ShaderInstancingMode;\n}\n\n/**\n * Everything a `.wgsl` file declares about itself — the parsed pragmas, with defaults filled in.\n *\n * @public\n */\nexport interface ShaderDeclaration {\n /** Which of the three authoring forms the file is. */\n readonly kind: ShaderKind;\n /** The vertex attributes the vertex stage reads. A `\"shader\"` file always includes `position`. */\n readonly attributes: readonly ShaderAttributeName[];\n /** The Babylon Lite system uniforms, read as `shaderSystem.<name>`. */\n readonly system: readonly LiteSystemUniformName[];\n /** The ignifx-provided uniforms, read as `shaderUniforms.<name>` and written every frame. */\n readonly ignifx: readonly IgnifxUniformName[];\n /** The custom uniforms, read as `shaderUniforms.<name>`. */\n readonly uniforms: readonly ShaderUniformDeclaration[];\n /** The samplers, each generating `<name>` and `<name>Sampler`. */\n readonly textures: readonly ShaderTextureDeclaration[];\n /** The read-only storage buffers. */\n readonly storage: readonly ShaderStorageDeclaration[];\n /** The WGSL `const` declarations a material may override. */\n readonly defines: readonly ShaderDefineDeclaration[];\n /** The pipeline state. */\n readonly pipeline: ShaderPipelineState;\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,eAAe;CAAC;CAAU;CAAW;AAAM;;;;;;AAexD,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAeA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;AAqBA,MAAa,4BAA4B;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;AAgBA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAeA,MAAa,uBAA+E,OAAO,OAAO;CACxG,MAAM;CACN,cAAc;CACd,WAAW;CACX,oBAAoB;CACpB,gBAAgB;CAChB,cAAc;AAChB,CAAC;;;;;;AAOD,MAAa,2BAA2B;CAAC;CAAS;CAAS;AAAa;;;;;;AAexE,MAAa,qBAAqB;CAAC;CAAU;CAAS;CAAY;AAAe;;;;;;;AAejF,MAAa,oBAAoB;CAAC;CAAQ;CAAS;AAAM;;;;;;AAezD,MAAa,0BAA0B;CAAC;CAAQ;CAAY;AAAiB;;;;;;AA0F7E,MAAa,qBAAqB;CAAC;CAAY;CAAW;AAAW;;;;;;AAcrE,MAAa,wBAAwB"}
1
+ {"version":3,"file":"shader-declaration-5q__jycG.js","names":[],"sources":["../src/render/shader-declaration.ts"],"sourcesContent":["/**\n * The vocabulary a `// @ignifx` pragma declares: the three authoring forms, the WGSL types and\n * attribute names Babylon Lite accepts, the uniforms ignifx supplies, and the parsed declaration\n * itself (`docs/plan/2026-09-terrain-particles-shaders.md` §3.1).\n *\n * Split from `./shader-pragma.ts` so these few hundred bytes can stay in the barrel while the parser\n * lives in a chunk only the `.wgsl` loader fetches (`./shader-support.ts`).\n */\n\n/**\n * The three authoring forms the form directive names, in the order the documentation lists them.\n *\n * @public\n */\nexport const SHADER_KINDS = [\"shader\", \"surface\", \"post\"] as const;\n\n/**\n * Which of the three authoring forms a `.wgsl` file is: a full custom material, a surface shader\n * that hooks into the engine's lit materials, or a full-screen post effect.\n *\n * @public\n */\nexport type ShaderKind = (typeof SHADER_KINDS)[number];\n\n/**\n * The WGSL types a declared uniform may have — Babylon Lite's set (`index.d.ts` 11445).\n *\n * @public\n */\nexport const SHADER_UNIFORM_TYPES = [\n \"f32\",\n \"u32\",\n \"i32\",\n \"vec2<f32>\",\n \"vec3<f32>\",\n \"vec4<f32>\",\n \"mat4x4<f32>\",\n] as const;\n\n/**\n * The union of the uniform types a declaration may name.\n *\n * @public\n */\nexport type ShaderUniformType = (typeof SHADER_UNIFORM_TYPES)[number];\n\n/**\n * The vertex attributes a shader material can bind — Babylon Lite's fixed set\n * (`index.d.ts` 11295). A name outside this list is reported with its line.\n *\n * @public\n */\nexport const SHADER_ATTRIBUTE_NAMES = [\n \"position\",\n \"normal\",\n \"uv\",\n \"uv2\",\n \"tangent\",\n \"color\",\n \"joints\",\n \"weights\",\n \"joints1\",\n \"weights1\",\n] as const;\n\n/**\n * The union of the attribute names a declaration may name.\n *\n * @public\n */\nexport type ShaderAttributeName = (typeof SHADER_ATTRIBUTE_NAMES)[number];\n\n/**\n * The uniforms Babylon Lite fills in itself every frame, read in WGSL as `shaderSystem.<name>`\n * (`index.d.ts` 11432).\n *\n * @remarks\n * Two of them lie under `rendering.useFloatingOrigin`: `cameraPosition` reads `(0, 0, 0)` and the\n * world matrices are camera-relative. With instancing on, `world`, `worldView`, and\n * `worldViewProjection` are **not** instance-aware — the shader composes\n * `shaderSystem.world * mat4x4(input.world0, input.world1, input.world2, input.world3)`.\n *\n * @public\n */\nexport const LITE_SYSTEM_UNIFORM_NAMES = [\n \"world\",\n \"view\",\n \"projection\",\n \"viewProjection\",\n \"worldView\",\n \"worldViewProjection\",\n \"cameraPosition\",\n \"screenSize\",\n \"alphaCutoff\",\n] as const;\n\n/**\n * The union of the Babylon Lite system uniform names.\n *\n * @public\n */\nexport type LiteSystemUniformName = (typeof LITE_SYSTEM_UNIFORM_NAMES)[number];\n\n/**\n * The uniforms **ignifx** fills in every frame, read in WGSL as `shaderUniforms.<name>`\n * (`docs/plan/2026-09-terrain-particles-shaders.md` §3.1). Babylon Lite has no clock and no light\n * bindings for a shader material, so these are the engine's own addition.\n *\n * @public\n */\nexport const IGNIFX_UNIFORM_NAMES = [\n \"time\",\n \"unscaledTime\",\n \"deltaTime\",\n \"mainLightDirection\",\n \"mainLightColor\",\n \"ambientColor\",\n] as const;\n\n/**\n * The union of the ignifx-provided uniform names.\n *\n * @public\n */\nexport type IgnifxUniformName = (typeof IGNIFX_UNIFORM_NAMES)[number];\n\n/**\n * The WGSL type of each ignifx-provided uniform, which is what the custom uniform block is laid out\n * from.\n *\n * @internal\n */\nexport const IGNIFX_UNIFORM_TYPES: Readonly<Record<IgnifxUniformName, ShaderUniformType>> = Object.freeze({\n time: \"f32\",\n unscaledTime: \"f32\",\n deltaTime: \"f32\",\n mainLightDirection: \"vec3<f32>\",\n mainLightColor: \"vec3<f32>\",\n ambientColor: \"vec3<f32>\",\n});\n\n/**\n * The 1x1 fallback textures a declaration can bind when nothing else is.\n *\n * @public\n */\nexport const SHADER_TEXTURE_FALLBACKS = [\"white\", \"black\", \"transparent\"] as const;\n\n/**\n * Which 1x1 texture is bound to a declared sampler that nothing has filled in\n * (Godot's `hint_default_*`).\n *\n * @public\n */\nexport type ShaderTextureFallback = (typeof SHADER_TEXTURE_FALLBACKS)[number];\n\n/**\n * How a shader material composites its fragments.\n *\n * @public\n */\nexport const SHADER_BLEND_MODES = [\"opaque\", \"alpha\", \"additive\", \"premultiplied\"] as const;\n\n/**\n * The blend modes a declaration may ask for.\n *\n * @public\n */\nexport type ShaderBlendMode = (typeof SHADER_BLEND_MODES)[number];\n\n/**\n * Which faces are drawn. `\"front\"` is accepted by the grammar and refused by the parser, because\n * Babylon Lite 1.27.0 exposes only `backFaceCulling`.\n *\n * @public\n */\nexport const SHADER_CULL_MODES = [\"back\", \"front\", \"none\"] as const;\n\n/**\n * The face-culling modes a declaration may ask for. `\"front\"` is refused: Babylon Lite 1.27.0\n * exposes only `backFaceCulling`.\n *\n * @public\n */\nexport type ShaderCullMode = (typeof SHADER_CULL_MODES)[number];\n\n/**\n * Which instance streams the vertex stage reads.\n *\n * @public\n */\nexport const SHADER_INSTANCING_MODES = [\"none\", \"matrices\", \"matrices-colors\"] as const;\n\n/**\n * How a declaration expects to be drawn: one mesh at a time, or thin-instanced with a matrix slab\n * and optionally a per-instance colour.\n *\n * @public\n */\nexport type ShaderInstancingMode = (typeof SHADER_INSTANCING_MODES)[number];\n\n/**\n * One `// @ignifx uniform …` line: a value a material sets and the vertex or fragment stage reads\n * as `shaderUniforms.<name>`.\n *\n * @public\n */\nexport interface ShaderUniformDeclaration {\n /** The WGSL identifier. */\n readonly name: string;\n /** The WGSL type. */\n readonly type: ShaderUniformType;\n /**\n * The value a material starts with. A colour default is the **sRGB** value the file wrote; the\n * material layer decodes it to linear on the way to the GPU.\n */\n readonly defaultValue: number | readonly number[];\n /** Whether the value is a colour, declared with `color(…)` or the bare `color` modifier. */\n readonly color: boolean;\n /** The inclusive slider bounds an inspector should offer, or `null`. */\n readonly range: readonly [number, number] | null;\n /** The slider increment an inspector should use, or `null`. */\n readonly step: number | null;\n /** One sentence describing the uniform, or `null`. */\n readonly tooltip: string | null;\n}\n\n/**\n * One `// @ignifx texture …` line: a `texture_2d<f32>` (or `texture_2d_array<f32>`) plus the\n * `<name>Sampler` Babylon Lite generates beside it.\n *\n * @public\n */\nexport interface ShaderTextureDeclaration {\n /** The WGSL identifier; the sampler is `<name>Sampler`. */\n readonly name: string;\n /** Whether the texture holds sRGB-encoded colour, which the texture import needs to know. */\n readonly srgb: boolean;\n /** Whether the texture is a tangent-space normal map. */\n readonly normal: boolean;\n /**\n * Which 1x1 texture is bound when a material binds nothing, or `null` for the implicit `\"white\"`.\n *\n * @remarks\n * A declared sampler that nothing fills in cannot be left unbound: Babylon Lite refuses to build\n * a bind group for it (error 309), so *something* is always bound.\n */\n readonly fallback: ShaderTextureFallback | null;\n /** Whether the binding is a `texture_2d_array<f32>` rather than a `texture_2d<f32>`. */\n readonly array: boolean;\n}\n\n/**\n * One `// @ignifx storage …` line: a read-only storage buffer the shader indexes.\n *\n * @public\n */\nexport interface ShaderStorageDeclaration {\n /** The WGSL identifier. */\n readonly name: string;\n /** The WGSL variable type, verbatim, for example `array<Particle>`. */\n readonly type: string;\n}\n\n/**\n * One `// @ignifx define …` line: a WGSL `const` a material may override.\n *\n * @public\n */\nexport interface ShaderDefineDeclaration {\n /** The WGSL identifier. */\n readonly name: string;\n /** The value; a boolean compiles to `bool`, a number to `f32`. */\n readonly value: boolean | number;\n}\n\n/**\n * The three hooks a `.surface.wgsl` file may provide.\n *\n * @public\n */\nexport const SURFACE_HOOK_NAMES = [\"displace\", \"surface\", \"composite\"] as const;\n\n/**\n * One of the three surface-shader hooks.\n *\n * @public\n */\nexport type SurfaceHookName = (typeof SURFACE_HOOK_NAMES)[number];\n\n/**\n * The uniform block name a surface shader reads its declared uniforms from.\n *\n * @public\n */\nexport const SURFACE_UNIFORM_BLOCK = \"surfaceUniforms\";\n\n/**\n * The pipeline state a `// @ignifx blend …` line declares.\n *\n * @public\n */\nexport interface ShaderPipelineState {\n /** How fragments are composited. */\n readonly blend: ShaderBlendMode;\n /** Which faces are drawn. */\n readonly cull: ShaderCullMode;\n /**\n * Whether the draw writes depth. Defaults to `true` for an opaque surface and `false` for a\n * blended one — Babylon Lite's own rule — unless the file says `depthWrite on` explicitly.\n */\n readonly depthWrite: boolean;\n /** Whether the draw depth-tests at all; `false` compiles `depthCompare: \"always\"`. */\n readonly depthTest: boolean;\n /** Whether the surface samples the opaque scene colour behind it. Requires a blended surface. */\n readonly transmissive: boolean;\n /** Which instance streams the vertex stage reads. */\n readonly instancing: ShaderInstancingMode;\n}\n\n/**\n * Everything a `.wgsl` file declares about itself — the parsed pragmas, with defaults filled in.\n *\n * @public\n */\nexport interface ShaderDeclaration {\n /** Which of the three authoring forms the file is. */\n readonly kind: ShaderKind;\n /** The vertex attributes the vertex stage reads. A `\"shader\"` file always includes `position`. */\n readonly attributes: readonly ShaderAttributeName[];\n /** The Babylon Lite system uniforms, read as `shaderSystem.<name>`. */\n readonly system: readonly LiteSystemUniformName[];\n /** The ignifx-provided uniforms, read as `shaderUniforms.<name>` and written every frame. */\n readonly ignifx: readonly IgnifxUniformName[];\n /** The custom uniforms, read as `shaderUniforms.<name>`. */\n readonly uniforms: readonly ShaderUniformDeclaration[];\n /** The samplers, each generating `<name>` and `<name>Sampler`. */\n readonly textures: readonly ShaderTextureDeclaration[];\n /** The read-only storage buffers. */\n readonly storage: readonly ShaderStorageDeclaration[];\n /** The WGSL `const` declarations a material may override. */\n readonly defines: readonly ShaderDefineDeclaration[];\n /** The pipeline state. */\n readonly pipeline: ShaderPipelineState;\n /**\n * The furthest, in world metres, the vertex stage moves a vertex from where the mesh puts it: the\n * `// @ignifx displace <metres>` line, or `0` when the file has none. Every mesh drawn with the\n * material gets bounds this much larger, so a directional shadow map and GPU instance culling\n * still cover the moved shape.\n */\n readonly displace: number;\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,eAAe;CAAC;CAAU;CAAW;AAAM;;;;;;AAexD,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAeA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;AAqBA,MAAa,4BAA4B;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;AAgBA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAeA,MAAa,uBAA+E,OAAO,OAAO;CACxG,MAAM;CACN,cAAc;CACd,WAAW;CACX,oBAAoB;CACpB,gBAAgB;CAChB,cAAc;AAChB,CAAC;;;;;;AAOD,MAAa,2BAA2B;CAAC;CAAS;CAAS;AAAa;;;;;;AAexE,MAAa,qBAAqB;CAAC;CAAU;CAAS;CAAY;AAAe;;;;;;;AAejF,MAAa,oBAAoB;CAAC;CAAQ;CAAS;AAAM;;;;;;AAezD,MAAa,0BAA0B;CAAC;CAAQ;CAAY;AAAiB;;;;;;AA0F7E,MAAa,qBAAqB;CAAC;CAAY;CAAW;AAAW;;;;;;AAcrE,MAAa,wBAAwB"}
@@ -1,5 +1,5 @@
1
- import { o as CoreErrorCode, t as IgnifxError } from "./ignifx-error-R1ma_Lzv.js";
2
- import { t as Color } from "./color-CpvebMIh.js";
1
+ import { o as CoreErrorCode, t as IgnifxError } from "./ignifx-error-CRh89KUJ.js";
2
+ import { t as Color } from "./color-DrR6GFTd.js";
3
3
  import { n as IGNIFX_UNIFORM_TYPES, r as LITE_SYSTEM_UNIFORM_NAMES, t as IGNIFX_UNIFORM_NAMES } from "./shader-declaration-5q__jycG.js";
4
4
  //#region \0rolldown/runtime.js
5
5
  var __defProp = Object.defineProperty;
@@ -172,7 +172,7 @@ let adapter = null;
172
172
  */
173
173
  async function loadShaderMaterialAdapter() {
174
174
  if (adapter !== null) return;
175
- const loaded = await import("./shader-material-BzVY0ySR.js");
175
+ const loaded = await import("./shader-material-U6BKZ8D1.js");
176
176
  loaded.enableShaderUniformCaching();
177
177
  adapter = loaded;
178
178
  }
@@ -1006,4 +1006,4 @@ function shapeMismatch(declaration, material, expected, actual) {
1006
1006
  //#endregion
1007
1007
  export { shader_material_exports as n, shaderMaterialsOf as t };
1008
1008
 
1009
- //# sourceMappingURL=shader-material-fOI9Upt3.js.map
1009
+ //# sourceMappingURL=shader-material-BIG3UDyu.js.map