rayzee 11.2.1 → 11.3.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 (62) hide show
  1. package/README.md +58 -29
  2. package/dist/ArchiveImporter-D735xX-4.js +7860 -0
  3. package/dist/BidirectionalIntegrator-M89c0AlP.js +954 -0
  4. package/dist/{BufferLayout-D_IBo2ci.js → BufferLayout-xPRH9jYD.js} +41 -5
  5. package/dist/{NeuralRetouch-Cr-otSW8.js → NeuralRetouch-DiBH63kz.js} +1 -1
  6. package/dist/{NeuralSuperRes-B7E3_M0t.js → NeuralSuperRes-CZNQP13W.js} +1 -1
  7. package/dist/{PathTracer-D6nbknj5.js → PathTracer-BXCCVrPK.js} +4371 -4612
  8. package/dist/{PhysicalSky-Dq5VSiCQ.js → PhysicalSky-DqmaS0lb.js} +2 -2
  9. package/dist/{RayzeeRenderer-DbjqO6v-.js → RayzeeRenderer-DUSMFhmc.js} +426 -363
  10. package/dist/SolarLimb-bZE6y63S.js +762 -0
  11. package/dist/addons/archives.es.js +1 -1
  12. package/dist/addons/bidirectional.es.js +1 -1
  13. package/dist/addons/physical-sky.es.js +1 -1
  14. package/dist/rayzee-core.es.js +7 -7
  15. package/dist/rayzee.es.js +472 -468
  16. package/dist/rayzee.umd.js +106 -105
  17. package/dist/sceneCachePolicy-BAib5fCp.js +1602 -0
  18. package/package.json +1 -1
  19. package/src/PathTracerApp.js +4 -3
  20. package/src/Processor/ArchiveImporter.js +173 -94
  21. package/src/Processor/ArchiveReader.js +20 -23
  22. package/src/Processor/AssetLoader.js +48 -1
  23. package/src/Processor/BVHRefitter.js +109 -13
  24. package/src/Processor/BufferLayout.js +115 -0
  25. package/src/Processor/ChunkedRecords.js +3 -2
  26. package/src/Processor/EmissiveTriangleBuilder.js +6 -6
  27. package/src/Processor/GeometryExtractor.js +189 -79
  28. package/src/Processor/HostMemory.js +39 -9
  29. package/src/Processor/InstanceTable.js +714 -42
  30. package/src/Processor/PBRT/PBRTCurves.js +224 -6
  31. package/src/Processor/PBRT/PBRTMaterials.js +3 -0
  32. package/src/Processor/PBRT/PBRTSceneBuilder.js +82 -25
  33. package/src/Processor/PackedRayBuffer.js +5 -2
  34. package/src/Processor/SceneProcessor.js +747 -141
  35. package/src/Processor/TLASBuilder.js +32 -17
  36. package/src/Processor/USD/USDLayer.js +1149 -0
  37. package/src/Processor/USD/USDScene.js +1655 -0
  38. package/src/Processor/USD/USDStage.js +682 -0
  39. package/src/Processor/USD/USDText.js +674 -0
  40. package/src/Processor/USD/index.js +138 -0
  41. package/src/Processor/Workers/BVHRefitWorker.js +3 -3
  42. package/src/RayzeeRenderer.js +167 -26
  43. package/src/Stages/NormalDepth.js +7 -12
  44. package/src/Stages/PathTracer.js +12 -17
  45. package/src/Stages/PathTracerStage.js +273 -96
  46. package/src/Storage/GeometrySpill.js +46 -14
  47. package/src/Storage/SceneGraphCodec.js +17 -3
  48. package/src/Storage/SpillStore.js +9 -0
  49. package/src/TSL/BVHTraversal.js +183 -7
  50. package/src/TSL/Common.js +57 -13
  51. package/src/TSL/ShadeKernel.js +3 -2
  52. package/src/TSL/TextureSampling.js +11 -8
  53. package/src/TSL/patches.js +84 -0
  54. package/src/integrators/BidirectionalIntegrator.js +20 -2
  55. package/src/managers/DenoisingManager.js +4 -4
  56. package/src/managers/InteractionManager.js +19 -6
  57. package/src/managers/MaterialDataManager.js +22 -5
  58. package/src/managers/UniformManager.js +3 -0
  59. package/dist/ArchiveImporter-D_x863yu.js +0 -5198
  60. package/dist/BidirectionalIntegrator-DmkxxEOR.js +0 -946
  61. package/dist/SolarLimb-CPaeZVwz.js +0 -721
  62. package/dist/sceneCachePolicy-C4-4qwt6.js +0 -485
@@ -0,0 +1,762 @@
1
+ import { i as e, r as t } from "./Logger-dDDGj9Av.js";
2
+ import { l as n } from "./BufferLayout-xPRH9jYD.js";
3
+ import { ContextNode as r, StorageInstancedBufferAttribute as i, WebGPUBackend as a } from "three/webgpu";
4
+ import { Fn as o, If as s, bool as c, clamp as l, dot as u, exp2 as d, float as f, floatBitsToUint as p, floor as m, int as h, log2 as g, mat3 as _, max as v, packSnorm2x16 as y, packUnorm2x16 as b, select as x, storage as S, struct as ee, uint as C, uintBitsToFloat as w, unpackSnorm2x16 as T, unpackUnorm2x16 as E, uvec2 as te, uvec4 as D, vec2 as O, vec3 as k, vec4 as A, wgslFn as j } from "three/tsl";
5
+ //#region src/TSL/patches.js
6
+ var M = a.prototype.createNodeBuilder;
7
+ a.prototype.createNodeBuilder = function(e, t) {
8
+ let n = M.call(this, e, t);
9
+ return Object.defineProperty(n, "allowGlobalVariables", {
10
+ get() {
11
+ return this.material !== null;
12
+ },
13
+ set() {},
14
+ configurable: !0
15
+ }), n;
16
+ };
17
+ function N(e, t, n = Float32Array) {
18
+ let r = new i(new n(0), t);
19
+ return r.count = e, r.gpuByteLength = e * t * n.BYTES_PER_ELEMENT, r.isGPUOnly = !0, r;
20
+ }
21
+ var P = a.prototype.createStorageAttribute;
22
+ a.prototype.createStorageAttribute = function(e) {
23
+ let t = this.attributeUtils._getBufferAttribute(e);
24
+ if (!t.isGPUOnly) return P.call(this, e);
25
+ let n = this.get(t);
26
+ n.buffer === void 0 && (n.buffer = this.device.createBuffer({
27
+ label: t.name,
28
+ size: t.gpuByteLength,
29
+ usage: GPUBufferUsage.STORAGE | GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST
30
+ }));
31
+ };
32
+ var F = class {
33
+ constructor(e, t, n, r = Float32Array, i = 4) {
34
+ this.LaneType = r, this.itemSize = i, this.lanesPerPart = Math.max(1, Math.floor(n / (t * r.BYTES_PER_ELEMENT))) * t, this.totalLanes = e, this.attrs = [];
35
+ for (let n = 0; n < e || this.attrs.length === 0; n += this.lanesPerPart) {
36
+ let a = Math.max(t, Math.min(this.lanesPerPart, e - n));
37
+ this.attrs.push(N(a / i, i, r));
38
+ }
39
+ }
40
+ get elementsPerPart() {
41
+ return this.lanesPerPart / this.itemSize;
42
+ }
43
+ create(e) {
44
+ for (let t of this.attrs) e.createStorageAttribute(t);
45
+ }
46
+ write(e, t, n, r, i) {
47
+ let a = this.LaneType.BYTES_PER_ELEMENT;
48
+ for (; i > 0;) {
49
+ let o = Math.floor(t / this.lanesPerPart), s = t - o * this.lanesPerPart, c = Math.min(i, this.lanesPerPart - s), l = this.attrs[o];
50
+ e.createStorageAttribute(l), e.device.queue.writeBuffer(e.get(l).buffer, s * a, n, r, c), t += c, r += c, i -= c;
51
+ }
52
+ }
53
+ writeRecords(e, t, n, r) {
54
+ let i = t.recordsPerChunk * t.lanesPerRecord;
55
+ for (let a = n, o = n + r; a < o;) {
56
+ let n = Math.floor(a / i), r = t.chunks[n];
57
+ if (!r) throw Error(`chunk ${n} is on disk and was never uploaded`);
58
+ let s = a - n * i, c = Math.min(r.length - s, o - a);
59
+ this.write(e, a, r, s, c), a += c;
60
+ }
61
+ }
62
+ }, I = a.prototype.updateAttribute;
63
+ a.prototype.updateAttribute = function(e) {
64
+ if (!this.attributeUtils._getBufferAttribute(e).isGPUOnly) return I.call(this, e);
65
+ };
66
+ var L = 4096;
67
+ function ne(e) {
68
+ if (!this.trackTimestamp || this.isDisposed || this.currentQueryIndex + 2 > this.maxQueries) return null;
69
+ let t = this.currentQueryIndex;
70
+ return this.currentQueryIndex += 2, this.queryOffsets.set(e, t), t;
71
+ }
72
+ var re = a.prototype.initTimestampQuery;
73
+ a.prototype.initTimestampQuery = function(e, t, n) {
74
+ let r = this.trackTimestamp && !this.timestampQueryPool[e];
75
+ if (re.call(this, e, t, n), r) {
76
+ let r = this.timestampQueryPool[e];
77
+ if (r && r.maxQueries < L && n.timestampWrites) {
78
+ let i = r.constructor, a = new i(this.device, e, L);
79
+ a.allocateQueriesForContext = ne, a.allocateQueriesForContext(t), this.timestampQueryPool[e] = a, n.timestampWrites.querySet = a.querySet, r.dispose();
80
+ }
81
+ }
82
+ let i = n.timestampWrites;
83
+ i && i.beginningOfPassWriteIndex == null && (n.timestampWrites = void 0);
84
+ };
85
+ function ie(e, t) {
86
+ return new Proxy(e, { get(e, n, r) {
87
+ if (typeof n == "string" && t.has(n)) return e.get(n);
88
+ let i = Reflect.get(e, n, r);
89
+ return n === "toVar" && typeof i == "function" ? (...n) => ie(i.apply(e, n), t) : i;
90
+ } });
91
+ }
92
+ function R(e, t = null) {
93
+ let n = ee(e, t), r = new Set(Object.keys(e)), i = (...e) => ie(n(...e), r);
94
+ return i.layout = n.layout, i.isStruct = !0, i.wrap = (e) => ie(e, r), i;
95
+ }
96
+ r.prototype.setup = function(e) {
97
+ let t = e.addContext(this.value);
98
+ this.node.build(e), e.setContext(t);
99
+ };
100
+ //#endregion
101
+ //#region src/TSL/Struct.js
102
+ var ae = R({
103
+ origin: "vec3",
104
+ direction: "vec3"
105
+ }), z = R({
106
+ color: "vec4",
107
+ emissive: "vec3",
108
+ emissiveIntensity: "float",
109
+ roughness: "float",
110
+ metalness: "float",
111
+ ior: "float",
112
+ transmission: "float",
113
+ thickness: "float",
114
+ clearcoat: "float",
115
+ clearcoatRoughness: "float",
116
+ opacity: "float",
117
+ transparent: "bool",
118
+ attenuationColor: "vec3",
119
+ attenuationDistance: "float",
120
+ dispersion: "float",
121
+ sheen: "float",
122
+ sheenRoughness: "float",
123
+ sheenColor: "vec3",
124
+ specularIntensity: "float",
125
+ specularColor: "vec3",
126
+ alphaTest: "float",
127
+ alphaMode: "int",
128
+ side: "int",
129
+ depthWrite: "int",
130
+ albedoMapIndex: "int",
131
+ emissiveMapIndex: "int",
132
+ normalMapIndex: "int",
133
+ bumpMapIndex: "int",
134
+ bumpScale: "float",
135
+ displacementScale: "float",
136
+ metalnessMapIndex: "int",
137
+ roughnessMapIndex: "int",
138
+ displacementMapIndex: "int",
139
+ normalScale: "vec2",
140
+ albedoTransform: "mat3",
141
+ emissiveTransform: "mat3",
142
+ normalTransform: "mat3",
143
+ bumpTransform: "mat3",
144
+ metalnessTransform: "mat3",
145
+ roughnessTransform: "mat3",
146
+ displacementTransform: "mat3",
147
+ iridescence: "float",
148
+ iridescenceIOR: "float",
149
+ iridescenceThicknessRange: "vec2",
150
+ subsurface: "float",
151
+ subsurfaceColor: "vec3",
152
+ subsurfaceRadius: "vec3",
153
+ subsurfaceRadiusScale: "float",
154
+ subsurfaceAnisotropy: "float",
155
+ anisotropy: "float",
156
+ anisotropyRotation: "float",
157
+ anisotropyMapIndex: "int",
158
+ transmissionMapIndex: "int",
159
+ clearcoatMapIndex: "int",
160
+ clearcoatRoughnessMapIndex: "int",
161
+ sheenColorMapIndex: "int",
162
+ sheenRoughnessMapIndex: "int",
163
+ iridescenceMapIndex: "int",
164
+ iridescenceThicknessMapIndex: "int",
165
+ specularIntensityMapIndex: "int",
166
+ specularColorMapIndex: "int",
167
+ diffuseTransmission: "float",
168
+ diffuseTransmissionColor: "vec3",
169
+ diffuseTransmissionMapIndex: "int",
170
+ diffuseTransmissionColorMapIndex: "int"
171
+ }), oe = R({
172
+ transmission: "float",
173
+ clearcoat: "float",
174
+ clearcoatRoughness: "float",
175
+ sheenColor: "vec3",
176
+ sheenRoughness: "float",
177
+ iridescence: "float",
178
+ iridescenceThickness: "float",
179
+ specularIntensity: "float",
180
+ specularColor: "vec3",
181
+ diffuseTransmission: "float",
182
+ diffuseTransmissionColor: "vec3"
183
+ }), se = R({
184
+ color: "vec4",
185
+ ior: "float",
186
+ transmission: "float",
187
+ attenuationColor: "vec3",
188
+ attenuationDistance: "float",
189
+ albedoMapIndex: "int",
190
+ opacity: "float",
191
+ transparent: "bool",
192
+ alphaTest: "float",
193
+ alphaMode: "int",
194
+ albedoTransform: "mat3"
195
+ }), ce = R({
196
+ shadowed: "vec3",
197
+ unoccluded: "vec3"
198
+ });
199
+ R({
200
+ position: "vec3",
201
+ radius: "float",
202
+ material: z
203
+ });
204
+ var le = R({
205
+ didHit: "bool",
206
+ dst: "float",
207
+ hitPoint: "vec3",
208
+ normal: "vec3",
209
+ uv: "vec2",
210
+ materialIndex: "int",
211
+ meshIndex: "int",
212
+ instanceLeaf: "int",
213
+ triangleIndex: "int",
214
+ boxTests: "int",
215
+ triTests: "int"
216
+ });
217
+ R({
218
+ posA: "vec3",
219
+ posB: "vec3",
220
+ posC: "vec3",
221
+ uvA: "vec2",
222
+ uvB: "vec2",
223
+ uvC: "vec2",
224
+ normalA: "vec3",
225
+ normalB: "vec3",
226
+ normalC: "vec3",
227
+ material: z,
228
+ materialIndex: "int",
229
+ meshIndex: "int"
230
+ }), R({
231
+ color: "vec4",
232
+ samples: "int"
233
+ });
234
+ var ue = R({
235
+ direction: "vec3",
236
+ value: "vec3",
237
+ pdf: "float",
238
+ isTransmission: "bool",
239
+ colorWeight: "vec3",
240
+ isDiffuseTransmission: "bool"
241
+ }), de = R({
242
+ specular: "float",
243
+ diffuse: "float",
244
+ sheen: "float",
245
+ clearcoat: "float",
246
+ transmission: "float",
247
+ iridescence: "float",
248
+ diffuseTransmission: "float"
249
+ }), B = R({
250
+ Ta: "vec3",
251
+ Ba: "vec3"
252
+ }), V = R({
253
+ NoL: "float",
254
+ NoV: "float",
255
+ NoH: "float",
256
+ VoH: "float",
257
+ LoH: "float",
258
+ ToH: "float",
259
+ BoH: "float",
260
+ ToV: "float",
261
+ BoV: "float",
262
+ ToL: "float",
263
+ BoL: "float"
264
+ }), fe = R({
265
+ compensation: "vec3",
266
+ E_total: "vec3"
267
+ }), pe = R({
268
+ f0: "vec3",
269
+ f90: "float",
270
+ eta: "float",
271
+ F0m: "vec3",
272
+ F0: "vec3"
273
+ }), me = R({
274
+ albedo: "vec4",
275
+ emissive: "vec3",
276
+ metalness: "float",
277
+ roughness: "float",
278
+ normal: "vec3",
279
+ hasTextures: "bool"
280
+ }), he = R({
281
+ isMetallic: "bool",
282
+ isRough: "bool",
283
+ isSmooth: "bool",
284
+ isTransmissive: "bool",
285
+ hasClearcoat: "bool",
286
+ isEmissive: "bool",
287
+ complexityScore: "float"
288
+ }), ge = R({
289
+ albedoUV: "vec2",
290
+ normalUV: "vec2",
291
+ metalnessUV: "vec2",
292
+ emissiveUV: "vec2",
293
+ bumpUV: "vec2",
294
+ roughnessUV: "vec2",
295
+ normalBumpSameUV: "bool",
296
+ metalRoughSameUV: "bool",
297
+ albedoEmissiveSameUV: "bool",
298
+ allSameUV: "bool"
299
+ }), _e = R({
300
+ invRoughness: "float",
301
+ metalFactor: "float",
302
+ iorFactor: "float",
303
+ maxSheenColor: "float"
304
+ });
305
+ R({
306
+ traversals: "int",
307
+ transmissiveTraversals: "int",
308
+ rayType: "int",
309
+ isPrimaryRay: "bool",
310
+ actualBounceDepth: "int"
311
+ });
312
+ //#endregion
313
+ //#region src/TSL/Common.js
314
+ var ve = /* @__PURE__ */ j("\n fn offsetRayOrigin( p: vec3f, n: vec3f ) -> vec3f {\n let step = select( vec3<i32>( 32 ), vec3<i32>( -32 ), ( p < vec3f( 0.0 ) ) != ( n < vec3f( 0.0 ) ) );\n let far = bitcast<vec3f>( bitcast<vec3<i32>>( p ) + step );\n return select( far, p + n * 1e-5, abs( p ) < vec3f( 1.0 ) );\n }\n"), ye = .9999, be = 3.14159, xe = 1 / be, Se = 2 * be, H = 1e-6, Ce = .05, we = .089, Te = .001, Ee = k(.2126, .7152, .0722), De = 65504, U = (e, t = 1e7) => x(e.equal(e), e, f(0)).clamp(0, t), Oe = (e, t = 1e7) => k(U(e.x, t), U(e.y, t), U(e.z, t)), W = n.SLOTS_PER_MATERIAL, ke = n.SLOT, G = ke, Ae = _(3.2404542, -.969266, .0556434, -1.5371385, 1.8760108, -.2040259, -.4985314, .041556, 1.0572252);
315
+ j("\n fn sRGBToLinear( srgbColor: vec3f ) -> vec3f {\n\n return pow( srgbColor, vec3f( 2.2 ) );\n\n }\n"), j("\n fn gammaCorrection( color: vec3f ) -> vec3f {\n\n return pow( color, vec3f( 1.0 / 2.2 ) );\n\n }\n");
316
+ var je = j("\n fn square( x: f32 ) -> f32 {\n\n return x * x;\n\n }\n");
317
+ j("\n fn squareVec3( x: vec3f ) -> vec3f {\n\n return x * x;\n\n }\n"), j("\n fn maxComponent( v: vec3f ) -> f32 {\n\n return max( max( v.r, v.g ), v.b );\n\n }\n"), j("\n fn minComponent( v: vec3f ) -> f32 {\n\n return min( min( v.r, v.g ), v.b );\n\n }\n");
318
+ var Me = j("\n fn luminance( color: vec3f ) -> f32 {\n\n return dot( color, vec3f( 0.2126, 0.7152, 0.0722 ) );\n\n }\n"), Ne = j(`
319
+ fn powerHeuristic( pdf1: f32, pdf2: f32 ) -> f32 {
320
+
321
+ let p1 = pdf1 * pdf1;
322
+ let p2 = pdf2 * pdf2;
323
+ return p1 / max( p1 + p2, ${Te} );
324
+
325
+ }
326
+ `), Pe = j(`
327
+ fn balanceHeuristic( pdf1: f32, pdf2: f32 ) -> f32 {
328
+
329
+ return pdf1 / max( pdf1 + pdf2, ${Te} );
330
+
331
+ }
332
+ `);
333
+ j("\n fn applyDithering( color: vec3f, uv: vec2f, ditheringAmount: f32, resolution: vec2f ) -> vec3f {\n\n let bayerRow0 = vec4f( 0.0 / 16.0, 8.0 / 16.0, 2.0 / 16.0, 10.0 / 16.0 );\n let bayerRow1 = vec4f( 12.0 / 16.0, 4.0 / 16.0, 14.0 / 16.0, 6.0 / 16.0 );\n let bayerRow2 = vec4f( 3.0 / 16.0, 11.0 / 16.0, 1.0 / 16.0, 9.0 / 16.0 );\n let bayerRow3 = vec4f( 15.0 / 16.0, 7.0 / 16.0, 13.0 / 16.0, 5.0 / 16.0 );\n let bayer = mat4x4f( bayerRow0, bayerRow1, bayerRow2, bayerRow3 );\n\n let pixelCoord = vec2i( uv * resolution );\n let dither = bayer[ pixelCoord.x % 4 ][ pixelCoord.y % 4 ];\n\n return color + ( dither - 0.5 ) * ditheringAmount / 255.0;\n\n }\n");
334
+ var Fe = j("\n fn constructTBN( N: vec3f ) -> mat3x3f {\n\n var majorAxis: vec3f;\n if ( abs( N.x ) < 0.999 ) {\n majorAxis = vec3f( 1.0, 0.0, 0.0 );\n } else {\n majorAxis = vec3f( 0.0, 1.0, 0.0 );\n }\n let T = normalize( cross( N, majorAxis ) );\n let B = normalize( cross( N, T ) );\n return mat3x3f( T, B, N );\n\n }\n");
335
+ o(([e, t, n]) => {
336
+ let r = t.add(n).toVar(), i = u(r, r).toVar();
337
+ return r.assign(i.greaterThan(H).select(r.div(i.sqrt()), k(0, 0, 1))), V({
338
+ NoL: v(u(e, n), .001),
339
+ NoV: v(u(e, t), .001),
340
+ NoH: v(u(e, r), .001),
341
+ VoH: v(u(t, r), .001),
342
+ LoH: v(u(n, r), .001),
343
+ ToH: f(0),
344
+ BoH: f(0),
345
+ ToV: f(0),
346
+ BoV: f(0),
347
+ ToL: f(0),
348
+ BoL: f(0)
349
+ });
350
+ });
351
+ var Ie = o(([e, t]) => {
352
+ let n = e.x.abs().lessThan(.999).select(k(1, 0, 0), k(0, 1, 0)), r = e.cross(n).normalize(), i = e.cross(r).normalize(), a = t.cos(), o = t.sin();
353
+ return B({
354
+ Ta: r.mul(a).add(i.mul(o)),
355
+ Ba: i.mul(a).sub(r.mul(o))
356
+ });
357
+ }), Le = o(([e, t, n, r]) => {
358
+ let i = t.add(n).toVar(), a = u(i, i).toVar();
359
+ i.assign(a.greaterThan(H).select(i.div(a.sqrt()), k(0, 0, 1)));
360
+ let o = f(0).toVar(), c = f(0).toVar(), l = f(0).toVar(), d = f(0).toVar(), p = f(0).toVar(), m = f(0).toVar();
361
+ return s(r.anisotropy.greaterThan(0), () => {
362
+ let a = B.wrap(Ie(e, r.anisotropyRotation));
363
+ o.assign(u(a.Ta, i)), c.assign(u(a.Ba, i)), l.assign(u(a.Ta, t)), d.assign(u(a.Ba, t)), p.assign(u(a.Ta, n)), m.assign(u(a.Ba, n));
364
+ }), V({
365
+ NoL: v(u(e, n), .001),
366
+ NoV: v(u(e, t), .001),
367
+ NoH: v(u(e, i), .001),
368
+ VoH: v(u(t, i), .001),
369
+ LoH: v(u(n, i), .001),
370
+ ToH: o,
371
+ BoH: c,
372
+ ToV: l,
373
+ BoV: d,
374
+ ToL: p,
375
+ BoL: m
376
+ });
377
+ }), Re = j("\n fn calculateFireflyThreshold( baseThreshold: f32, bounceIndex: i32, frame: i32 ) -> f32 {\n\n let depthFactor = 1.0 / ( 1.0 + f32( bounceIndex ) * 0.1 );\n let relaxation = sqrt( f32( frame + 1 ) );\n return baseThreshold * depthFactor * relaxation;\n\n }\n"), ze = j("\n fn applySoftSuppression( value: f32, threshold: f32, dampingFactor: f32 ) -> f32 {\n\n if ( value <= threshold ) {\n return value;\n }\n let excess = value - threshold;\n let suppressionFactor = threshold / ( threshold + excess * dampingFactor );\n return value * suppressionFactor;\n\n }\n"), Be = j(`
378
+ fn applySoftSuppressionRGB( color: vec3f, threshold: f32, dampingFactor: f32 ) -> vec3f {
379
+
380
+ let lum = dot( color, vec3f( 0.2126, 0.7152, 0.0722 ) );
381
+ if ( lum <= threshold ) {
382
+ return color;
383
+ }
384
+ let suppressedLum = applySoftSuppression( lum, threshold, dampingFactor );
385
+ if ( lum > ${H} ) {
386
+ return color * ( suppressedLum / lum );
387
+ }
388
+ return color;
389
+
390
+ }
391
+ `, [ze]), Ve = o(([e, t, n, r, i, a]) => {
392
+ let o = e.greaterThan(.7).toVar(), c = t.greaterThan(.8), u = t.lessThan(.3).toVar(), d = n.greaterThan(.5).toVar(), p = r.greaterThan(.5).toVar(), m = a.greaterThan(0), h = i.x.add(i.y).add(i.z).greaterThan(0).toVar(), g = f(.15).mul(f(o)).add(f(.25).mul(f(u))).add(f(.45).mul(f(d))).add(f(.35).mul(f(p))).add(f(.3).mul(f(h))).add(f(.4).mul(f(m))), _ = f(0).toVar();
393
+ return s(o.and(u), () => {
394
+ _.addAssign(.15);
395
+ }), s(d.and(p), () => {
396
+ _.addAssign(.2);
397
+ }), s(h.and(d.or(o)), () => {
398
+ _.addAssign(.1);
399
+ }), he({
400
+ isMetallic: o,
401
+ isRough: c,
402
+ isSmooth: u,
403
+ isTransmissive: d,
404
+ hasClearcoat: p,
405
+ isEmissive: h,
406
+ complexityScore: l(g.add(_), 0, 1)
407
+ });
408
+ });
409
+ function He(e, t, n) {
410
+ return e.length === 1 ? e[0] : {
411
+ isSplitStorage: !0,
412
+ parts: e,
413
+ perPart: t,
414
+ type: n,
415
+ value: e[0].value
416
+ };
417
+ }
418
+ function Ue(e, t) {
419
+ if (!e.isSplitStorage) return e.element(t);
420
+ let { parts: n, perPart: r } = e, i = h(t).toVar(), a = ({
421
+ uvec4: D,
422
+ uvec2: te
423
+ }[e.type] ?? A)(0).toVar(), o = (e) => () => a.assign(n[e].element(e === 0 ? i : i.sub(h(r * e)))), c = s(i.lessThan(h(r)), o(0));
424
+ for (let e = 1; e < n.length - 1; e++) c = c.ElseIf(i.lessThan(h(r * (e + 1))), o(e));
425
+ return c.Else(o(n.length - 1)), a;
426
+ }
427
+ var K = (e) => e?.isNode ? e : h(e), q = (e, t, n, r) => Ue(e, K(r).mul(K(t)).add(K(n))), We = (e, t, n) => {
428
+ if (n < 3) return q(e.geo, t, h(n), h(3));
429
+ if (!e.withoutUV) return q(e.shade, t, h(n - 3), h(2));
430
+ if (n === 3) return D(0);
431
+ let r = Ue(e.shade, K(t));
432
+ return D(0, 0, r.x, r.y);
433
+ }, J = /* @__PURE__ */ j("\n fn packNormalOct( n: vec3f ) -> u32 {\n\n let s = abs( n.x ) + abs( n.y ) + abs( n.z );\n var p = n.xy / max( s, 1e-20 );\n\n if ( n.z < 0.0 ) {\n\n let px = ( 1.0 - abs( p.y ) ) * select( -1.0, 1.0, p.x >= 0.0 );\n let py = ( 1.0 - abs( p.x ) ) * select( -1.0, 1.0, p.y >= 0.0 );\n p = vec2f( px, py );\n\n }\n\n return pack2x16snorm( p );\n\n }\n"), Y = /* @__PURE__ */ j("\n fn unpackTriangleNormal( packed: u32 ) -> vec3f {\n\n let e = unpack2x16snorm( packed );\n var nx = e.x;\n var ny = e.y;\n let nz = 1.0 - abs( e.x ) - abs( e.y );\n\n if ( nz < 0.0 ) {\n\n let tx = ( 1.0 - abs( ny ) ) * select( -1.0, 1.0, nx >= 0.0 );\n let ty = ( 1.0 - abs( nx ) ) * select( -1.0, 1.0, ny >= 0.0 );\n nx = tx;\n ny = ty;\n\n }\n\n return normalize( vec3f( nx, ny, nz ) );\n\n }\n"), X = j("\n fn arrayToMat3( data1: vec4f, data2: vec4f ) -> mat3x3f {\n\n return mat3x3f(\n data1.xyz,\n vec3f( data1.w, data2.xy ),\n vec3f( data2.zw, 1.0 )\n );\n\n }\n"), Ge = o(([e, t]) => {
434
+ let n = q(t, e, h(G.COLOR_METALNESS), h(W)).toVar(), r = q(t, e, h(G.EMISSIVE_ROUGHNESS), h(W)).toVar(), i = q(t, e, h(G.IOR_TRANSMISSION), h(W)).toVar(), a = q(t, e, h(G.ATTENUATION), h(W)).toVar(), o = q(t, e, h(G.DISPERSION_SHEEN), h(W)).toVar(), c = q(t, e, h(G.SHEEN_COLOR), h(W)).toVar(), l = q(t, e, h(G.SPECULAR), h(W)).toVar(), u = q(t, e, h(G.IRIDESCENCE), h(W)).toVar(), d = q(t, e, h(G.MAP_INDICES_A), h(W)).toVar(), f = q(t, e, h(G.MAP_INDICES_B), h(W)).toVar(), p = q(t, e, h(G.OPACITY_ALPHA), h(W)).toVar(), m = q(t, e, h(G.ALPHA_MODE), h(W)).toVar(), g = q(t, e, h(G.BUMP_DISPLACEMENT), h(W)).toVar(), _ = q(t, e, h(G.ALBEDO_TRANSFORM_A), h(W)).toVar(), v = q(t, e, h(G.ALBEDO_TRANSFORM_B), h(W)).toVar(), y = q(t, e, h(G.NORMAL_TRANSFORM_A), h(W)).toVar(), b = q(t, e, h(G.NORMAL_TRANSFORM_B), h(W)).toVar(), x = q(t, e, h(G.ROUGHNESS_TRANSFORM_A), h(W)).toVar(), S = q(t, e, h(G.ROUGHNESS_TRANSFORM_B), h(W)).toVar(), ee = q(t, e, h(G.METALNESS_TRANSFORM_A), h(W)).toVar(), C = q(t, e, h(G.METALNESS_TRANSFORM_B), h(W)).toVar(), w = q(t, e, h(G.EMISSIVE_TRANSFORM_A), h(W)).toVar(), T = q(t, e, h(G.EMISSIVE_TRANSFORM_B), h(W)).toVar(), E = q(t, e, h(G.BUMP_TRANSFORM_A), h(W)).toVar(), te = q(t, e, h(G.BUMP_TRANSFORM_B), h(W)).toVar(), D = q(t, e, h(G.DISPLACEMENT_TRANSFORM_A), h(W)).toVar(), k = q(t, e, h(G.DISPLACEMENT_TRANSFORM_B), h(W)).toVar(), j = q(t, e, h(G.SUBSURFACE_A), h(W)).toVar(), M = q(t, e, h(G.SUBSURFACE_B), h(W)).toVar(), N = q(t, e, h(G.SUBSURFACE_C), h(W)).toVar(), P = q(t, e, h(G.EXT_MAP_INDICES_A), h(W)).toVar(), F = q(t, e, h(G.EXT_MAP_INDICES_B), h(W)).toVar(), I = q(t, e, h(G.EXT_MAP_INDICES_C), h(W)).toVar(), L = A(-1, -1, 0, 0).toVar();
435
+ return s(c.a.greaterThan(0), () => {
436
+ L.assign(q(t, e, h(G.EXT_MAP_INDICES_D), h(W)));
437
+ }), z({
438
+ color: A(n.rgb, 1),
439
+ metalness: n.a,
440
+ emissive: r.rgb,
441
+ roughness: r.a,
442
+ ior: i.r,
443
+ transmission: i.g,
444
+ thickness: i.b,
445
+ emissiveIntensity: i.a,
446
+ attenuationColor: a.rgb,
447
+ attenuationDistance: a.a,
448
+ dispersion: o.r,
449
+ sheen: o.b,
450
+ sheenRoughness: o.a,
451
+ sheenColor: c.rgb,
452
+ specularIntensity: l.r,
453
+ specularColor: l.gba,
454
+ iridescence: u.r,
455
+ iridescenceIOR: u.g,
456
+ iridescenceThicknessRange: u.ba,
457
+ subsurfaceColor: j.rgb,
458
+ subsurface: j.a,
459
+ subsurfaceRadius: M.rgb,
460
+ subsurfaceRadiusScale: M.a,
461
+ subsurfaceAnisotropy: N.r,
462
+ anisotropy: N.g,
463
+ anisotropyRotation: N.b,
464
+ anisotropyMapIndex: h(N.a),
465
+ transmissionMapIndex: h(P.r),
466
+ clearcoatMapIndex: h(P.g),
467
+ clearcoatRoughnessMapIndex: h(P.b),
468
+ sheenColorMapIndex: h(P.a),
469
+ sheenRoughnessMapIndex: h(F.r),
470
+ iridescenceMapIndex: h(F.g),
471
+ iridescenceThicknessMapIndex: h(F.b),
472
+ specularIntensityMapIndex: h(F.a),
473
+ specularColorMapIndex: h(I.r),
474
+ diffuseTransmission: c.a,
475
+ diffuseTransmissionColor: I.gba,
476
+ diffuseTransmissionMapIndex: h(L.r),
477
+ diffuseTransmissionColorMapIndex: h(L.g),
478
+ albedoMapIndex: h(d.r),
479
+ normalMapIndex: h(d.g),
480
+ roughnessMapIndex: h(d.b),
481
+ metalnessMapIndex: h(d.a),
482
+ emissiveMapIndex: h(f.r),
483
+ bumpMapIndex: h(f.g),
484
+ clearcoat: f.b,
485
+ clearcoatRoughness: f.a,
486
+ opacity: p.r,
487
+ side: h(p.g),
488
+ transparent: p.b,
489
+ alphaTest: p.a,
490
+ alphaMode: h(m.r),
491
+ depthWrite: h(m.g),
492
+ normalScale: O(m.b, m.b),
493
+ bumpScale: g.r,
494
+ displacementScale: g.g,
495
+ displacementMapIndex: h(g.b),
496
+ albedoTransform: X({
497
+ data1: _,
498
+ data2: v
499
+ }),
500
+ normalTransform: X({
501
+ data1: y,
502
+ data2: b
503
+ }),
504
+ roughnessTransform: X({
505
+ data1: x,
506
+ data2: S
507
+ }),
508
+ metalnessTransform: X({
509
+ data1: ee,
510
+ data2: C
511
+ }),
512
+ emissiveTransform: X({
513
+ data1: w,
514
+ data2: T
515
+ }),
516
+ bumpTransform: X({
517
+ data1: E,
518
+ data2: te
519
+ }),
520
+ displacementTransform: X({
521
+ data1: D,
522
+ data2: k
523
+ })
524
+ });
525
+ }), Ke = o(() => {
526
+ let e = _(1, 0, 0, 0, 1, 0, 0, 0, 1);
527
+ return z({
528
+ color: A(1, 1, 1, 1),
529
+ emissive: k(0),
530
+ emissiveIntensity: f(0),
531
+ roughness: f(1),
532
+ metalness: f(0),
533
+ ior: f(1.5),
534
+ transmission: f(0),
535
+ thickness: f(0),
536
+ clearcoat: f(0),
537
+ clearcoatRoughness: f(0),
538
+ opacity: f(1),
539
+ transparent: f(0),
540
+ attenuationColor: k(1),
541
+ attenuationDistance: f(0),
542
+ dispersion: f(0),
543
+ sheen: f(0),
544
+ sheenRoughness: f(1),
545
+ sheenColor: k(0),
546
+ specularIntensity: f(1),
547
+ specularColor: k(1),
548
+ alphaTest: f(0),
549
+ alphaMode: h(0),
550
+ side: h(0),
551
+ depthWrite: h(1),
552
+ albedoMapIndex: h(-1),
553
+ emissiveMapIndex: h(-1),
554
+ normalMapIndex: h(-1),
555
+ bumpMapIndex: h(-1),
556
+ bumpScale: f(1),
557
+ displacementScale: f(0),
558
+ metalnessMapIndex: h(-1),
559
+ roughnessMapIndex: h(-1),
560
+ displacementMapIndex: h(-1),
561
+ normalScale: O(1, 1),
562
+ albedoTransform: e,
563
+ emissiveTransform: e,
564
+ normalTransform: e,
565
+ bumpTransform: e,
566
+ metalnessTransform: e,
567
+ roughnessTransform: e,
568
+ displacementTransform: e,
569
+ iridescence: f(0),
570
+ iridescenceIOR: f(1.3),
571
+ iridescenceThicknessRange: O(100, 400),
572
+ subsurface: f(0),
573
+ subsurfaceColor: k(1),
574
+ subsurfaceRadius: k(1, .2, .1),
575
+ subsurfaceRadiusScale: f(1),
576
+ subsurfaceAnisotropy: f(0),
577
+ anisotropy: f(0),
578
+ anisotropyRotation: f(0),
579
+ anisotropyMapIndex: h(-1),
580
+ transmissionMapIndex: h(-1),
581
+ clearcoatMapIndex: h(-1),
582
+ clearcoatRoughnessMapIndex: h(-1),
583
+ sheenColorMapIndex: h(-1),
584
+ sheenRoughnessMapIndex: h(-1),
585
+ iridescenceMapIndex: h(-1),
586
+ iridescenceThicknessMapIndex: h(-1),
587
+ specularIntensityMapIndex: h(-1),
588
+ specularColorMapIndex: h(-1),
589
+ diffuseTransmission: f(0),
590
+ diffuseTransmissionColor: k(1),
591
+ diffuseTransmissionMapIndex: h(-1),
592
+ diffuseTransmissionColorMapIndex: h(-1)
593
+ });
594
+ }), qe = o(([e, t]) => {
595
+ let n = q(t, e, h(G.IOR_TRANSMISSION), h(W)).toVar(), r = q(t, e, h(G.ATTENUATION), h(W)).toVar(), i = q(t, e, h(G.MAP_INDICES_A), h(W)).toVar(), a = q(t, e, h(G.OPACITY_ALPHA), h(W)).toVar(), o = q(t, e, h(G.ALPHA_MODE), h(W)).toVar(), s = q(t, e, h(G.ALBEDO_TRANSFORM_A), h(W)).toVar(), c = q(t, e, h(G.ALBEDO_TRANSFORM_B), h(W)).toVar();
596
+ return se({
597
+ color: A(1),
598
+ ior: n.r,
599
+ transmission: n.g,
600
+ attenuationColor: r.rgb,
601
+ attenuationDistance: r.a,
602
+ albedoMapIndex: h(i.r),
603
+ opacity: a.r,
604
+ transparent: a.b,
605
+ alphaTest: a.a,
606
+ alphaMode: h(o.r),
607
+ albedoTransform: X({
608
+ data1: s,
609
+ data2: c
610
+ })
611
+ });
612
+ }), Je = (e, t) => {
613
+ let n = (t) => e.shiftRight(C(t)).bitAnd(C(1)).equal(C(1)), r = t ? t.equal(h(0)) : c(!0);
614
+ return n(26).or(n(27).and(r));
615
+ }, Ye = (e, t) => {
616
+ let n = e.value?.copyRecordBase;
617
+ return n === void 0 ? [
618
+ q(e, t, h(1), h(4)),
619
+ q(e, t, h(2), h(4)),
620
+ q(e, t, h(3), h(4))
621
+ ] : [
622
+ 0,
623
+ 1,
624
+ 2
625
+ ].map((r) => q(e, t, h(n + r), h(3)));
626
+ }, Xe = (e, t) => k(k(e[0].x, e[1].x, e[2].x).dot(t), k(e[0].y, e[1].y, e[2].y).dot(t), k(e[0].z, e[1].z, e[2].z).dot(t)), Ze = (e, t) => {
627
+ let n = e[0].xyz.dot(e[1].xyz.cross(e[2].xyz));
628
+ return Xe(e, t).mul(n.sign());
629
+ }, Qe = /* @__PURE__ */ j("\n fn instanceDirToWorld( r0: vec3f, r1: vec3f, r2: vec3f, v: vec3f ) -> vec3f {\n\n // Rows of world-to-object; its inverse has columns cross(r1,r2), cross(r2,r0), cross(r0,r1).\n let c0 = cross( r1, r2 );\n let det = dot( r0, c0 );\n // Relative: for a uniform scale s this determinant is s⁻³, so a fixed floor would call a\n // heavily scaled-up instance singular and leave the direction untransformed.\n let magnitude = length( r0 ) * length( r1 ) * length( r2 );\n if ( abs( det ) <= 1e-12f * magnitude ) { return v; }\n\n let inv = 1.0f / det;\n return ( c0 * v.x + cross( r2, r0 ) * v.y + cross( r0, r1 ) * v.z ) * inv;\n\n }\n"), $e = (e, t) => Qe({
630
+ r0: e[0].xyz,
631
+ r1: e[1].xyz,
632
+ r2: e[2].xyz,
633
+ v: t.sub(k(e[0].w, e[1].w, e[2].w))
634
+ }), et = t("gpu"), Z = {
635
+ ORIGIN_META: 0,
636
+ DIR_FLAGS: 1,
637
+ THROUGHPUT_PDF: 2,
638
+ RADIANCE_ALPHA: 3,
639
+ MEDIUM_STACK: 4,
640
+ MEDIUM_SIGMA_A: 5,
641
+ SSS_SIGMA_S: 6
642
+ }, Q = {
643
+ DIST_TRI_BARY: 0,
644
+ NORMAL_MAT: 1,
645
+ RNG: 2,
646
+ VERTEX: 3
647
+ }, tt = 0, nt = 0, rt = 0, $ = (e, t) => t === 0 ? e : e.add(t * tt);
648
+ function it(e, t) {
649
+ t && e?._attributes?.delete?.(t);
650
+ }
651
+ var at = class {
652
+ constructor(e = 0, t = null, n = 0) {
653
+ this.capacity = 0, this.lightVertices = 0, this._renderer = t, this._attrs = {}, this.rayBuffer = null, this.hitBuffer = null, e > 0 && this.allocate(e, n);
654
+ }
655
+ allocate(t, n = 0) {
656
+ this.dispose(), this.capacity = t, this.lightVertices = n, tt = t, nt = t * (n > 0 ? 7 : 3), rt = nt + n * 4;
657
+ let r = t * 7, i = N(r, 4);
658
+ this._attrs.ray = i, this.rayBuffer = {
659
+ rw: S(i, "vec4"),
660
+ ro: S(i, "vec4").toReadOnly()
661
+ };
662
+ let a = rt + t * 1, o = N(a, 4, Uint32Array);
663
+ this._attrs.hit = o, this.hitBuffer = {
664
+ rw: S(o, "uvec4"),
665
+ ro: S(o, "uvec4").toReadOnly()
666
+ }, this.rayBytes = r * 16, this.hitBytes = a * 16, this.totalBytes = this.rayBytes + this.hitBytes, et.debug(`ray pool capacity ${e.n(t)} · ${e.mb(this.totalBytes)} (rays ${e.mb(this.rayBytes)} · hits ${e.mb(this.hitBytes)})`);
667
+ }
668
+ resize(e, t = 0) {
669
+ return e <= this.capacity && this.capacity > 0 && t === this.lightVertices ? !1 : (this.allocate(e, t), !0);
670
+ }
671
+ dispose() {
672
+ it(this._renderer, this._attrs.ray), it(this._renderer, this._attrs.hit), this._attrs = {}, this.rayBuffer = null, this.hitBuffer = null, this.capacity = 0, this.lightVertices = 0;
673
+ }
674
+ }, ot = (e, t) => e.element($(t, Z.ORIGIN_META)).xyz, st = (e, t) => e.element($(t, Z.DIR_FLAGS)).xyz, ct = (e, t) => p(e.element($(t, Z.DIR_FLAGS)).w), lt = (e, t) => e.element($(t, Z.THROUGHPUT_PDF)).xyz, ut = (e, t) => e.element($(t, Z.THROUGHPUT_PDF)).w, dt = (e, t) => e.element($(t, Z.RADIANCE_ALPHA)), ft = (e) => C(e).mul(1).add(rt), pt = (e, t, n, r, i, a = null) => {
675
+ let o = ft(t), s = a === null ? E(e.element(o).w).y : f(a);
676
+ return e.element(o).assign(D(y(O(n.x, n.y)), y(O(n.z, r)), b(O(i.x, i.y)), b(O(i.z, s))));
677
+ }, mt = (e, t, n) => {
678
+ let r = ft(t), i = e.element(r).toVar();
679
+ return e.element(r).assign(D(i.x, i.y, i.z, b(O(E(i.w).x, n))));
680
+ }, ht = (e, t) => e.element(ft(t)), gt = (e) => E(e.w).y, _t = (e) => {
681
+ let t = T(e.x), n = T(e.y);
682
+ return A(k(t.x, t.y, n.x).mul(.5).add(.5), n.y);
683
+ }, vt = (e) => k(E(e.z), E(e.w).x), yt = (e) => {
684
+ let t = l(m(g(v(e, 1e-6))), -8, 7), n = l(f(e).mul(d(t.negate())).sub(1).mul(64), 0, 63);
685
+ return x(f(e).lessThan(.004), C(0), C(t.add(8)).shiftLeft(6).bitOr(C(n)));
686
+ }, bt = (e, t) => {
687
+ let n = p(e.element($(t, Z.ORIGIN_META)).w).shiftRight(22), r = f(n.shiftRight(6).bitAnd(C(15))).sub(8), i = f(n.bitAnd(C(63))).div(64).add(1);
688
+ return x(n.equal(C(0)), f(0), i.mul(d(r)));
689
+ }, xt = (e, t, n, r, i, a = C(0), o = null) => {
690
+ let s = C(r).bitAnd(C(255)).bitOr(C(i).bitAnd(C(255)).shiftLeft(8)).bitOr(C(a).bitAnd(C(63)).shiftLeft(16));
691
+ return o !== null && (s = s.bitOr(yt(o).shiftLeft(22))), e.element($(t, Z.ORIGIN_META)).assign(A(n, w(s)));
692
+ }, St = (e, t, n, r) => e.element($(t, Z.DIR_FLAGS)).assign(A(n, w(r))), Ct = (e, t, n, r) => e.element($(t, Z.THROUGHPUT_PDF)).assign(A(n, r)), wt = (e, t, n) => e.element($(t, Z.RADIANCE_ALPHA)).assign(n), Tt = (e, t) => w(e.element($(t, Q.DIST_TRI_BARY)).x), Et = (e, t) => e.element($(t, Q.DIST_TRI_BARY)).y, Dt = (e, t) => w(e.element($(t, Q.DIST_TRI_BARY)).zw), Ot = (e, t) => Y(e.element($(t, Q.NORMAL_MAT)).x), kt = (e, t) => C(e.element($(t, Q.NORMAL_MAT)).y), At = (e, t) => h(e.element($(t, Q.NORMAL_MAT)).z).sub(h(1)), jt = (e, t) => e.element($(t, Q.NORMAL_MAT)).w, Mt = (e, t) => e.element($(t, Q.RNG)).x, Nt = (e, t, n) => e.element($(t, Q.RNG)).assign(D(n, 0, 0, 0)), Pt = (e, t) => {
693
+ let n = e.element($(t, Q.RNG));
694
+ return {
695
+ dVCM: w(n.y),
696
+ dVC: w(n.z)
697
+ };
698
+ }, Ft = (e, t, n, r, i) => e.element($(t, Q.RNG)).assign(D(n, p(r), p(i), C(0))), It = (e) => (t) => $(e, Q.VERTEX + t), Lt = (e) => (t) => C(e).mul(4).add(nt + t), Rt = (e, t, n) => {
699
+ e.element(t(0)).assign(D(p(n.position), n.tag)), e.element(t(1)).assign(D(p(n.throughput), J(n.V))), e.element(t(2)).assign(D(J(n.N), J(n.facetN), C(n.materialIndex).bitOr(C(n.extra).bitAnd(C(255)).shiftLeft(C(24))), p(n.uv.x))), e.element(t(3)).assign(D(p(n.uv.y), p(n.dVCM), p(n.dVC), C(0)));
700
+ }, zt = (e, t) => e.element(t(0)).w, Bt = (e, t) => w(e.element(t(0)).xyz), Vt = (e, t) => e.element(t(3)).w, Ht = (e, t, n) => e.element(t(3)).w.assign(n), Ut = (e, t) => {
701
+ let n = e.element(t(0)).toVar(), r = e.element(t(1)).toVar(), i = e.element(t(2)).toVar(), a = e.element(t(3)).toVar();
702
+ return {
703
+ position: w(n.xyz),
704
+ tag: n.w,
705
+ throughput: w(r.xyz),
706
+ V: Y(r.w),
707
+ N: Y(i.x),
708
+ facetN: Y(i.y),
709
+ materialIndex: i.z.bitAnd(C(16777215)),
710
+ uv: O(w(i.w), w(a.x)),
711
+ dVCM: w(a.y),
712
+ dVC: w(a.z),
713
+ extra: i.z.shiftRight(C(24))
714
+ };
715
+ }, Wt = (e, t, n) => {
716
+ let r = e.element(t(0)).w;
717
+ return x(r.shiftRight(C(8)).equal(n), r.bitAnd(C(255)), C(0));
718
+ }, Gt = (e, t, n, r) => {
719
+ let i = e.element(t(0)).xyz.toVar();
720
+ e.element(t(0)).assign(D(i, n.shiftLeft(C(8)).bitOr(C(r))));
721
+ }, Kt = (e, t, n, r, i, a) => e.element($(t, Q.VERTEX)).assign(D(C(n), C(h(r).add(h(1))), p(i), p(a))), qt = (e, t) => {
722
+ let n = e.element($(t, Q.VERTEX)).toVar();
723
+ return {
724
+ triangle: h(n.x),
725
+ instanceLeaf: h(n.y).sub(h(1)),
726
+ cosLight: w(n.z),
727
+ scale: w(n.w)
728
+ };
729
+ }, Jt = (e, t, n, r, i, a, o, s, c, l = C(0)) => {
730
+ e.element($(t, Q.DIST_TRI_BARY)).assign(D(p(n), r, p(i), p(a))), e.element($(t, Q.NORMAL_MAT)).assign(D(J(o), s, c, l));
731
+ }, Yt = (e, t) => {
732
+ let n = e.element($(t, Z.MEDIUM_STACK)), r = p(n.x);
733
+ return {
734
+ stackDepth: r.bitAnd(255),
735
+ transTraversals: r.shiftRight(8).bitAnd(255),
736
+ wavelength: r.shiftRight(16).bitAnd(65535),
737
+ ior1: n.y,
738
+ ior2: n.z,
739
+ ior3: n.w
740
+ };
741
+ }, Xt = (e, t, n, r, i, a, o, s = C(0)) => e.element($(t, Z.MEDIUM_STACK)).assign(A(w(n.bitOr(r.shiftLeft(8)).bitOr(s.shiftLeft(16))), i, a, o)), Zt = (e, t) => e.element($(t, Z.MEDIUM_SIGMA_A)).xyz, Qt = (e, t, n) => {
742
+ let r = e.element($(t, Z.MEDIUM_SIGMA_A)).w.toVar();
743
+ e.element($(t, Z.MEDIUM_SIGMA_A)).assign(A(n, r));
744
+ }, $t = (e) => {
745
+ let t = l(e, k(0), k(1)).mul(1023).add(.5);
746
+ return C(t.x).bitOr(C(t.y).shiftLeft(10)).bitOr(C(t.z).shiftLeft(20));
747
+ }, en = (e) => k(f(e.bitAnd(C(1023))), f(e.shiftRight(10).bitAnd(C(1023))), f(e.shiftRight(20).bitAnd(C(1023)))).div(1023), tn = (e, t) => en(p(e.element($(t, Z.MEDIUM_SIGMA_A)).w)), nn = (e, t, n) => {
748
+ let r = e.element($(t, Z.MEDIUM_SIGMA_A)).xyz.toVar();
749
+ e.element($(t, Z.MEDIUM_SIGMA_A)).assign(A(r, w($t(n))));
750
+ }, rn = (e, t) => h(p(e.element($(t, Z.ORIGIN_META)).w).bitAnd(255)), an = (e, t) => h(p(e.element($(t, Z.ORIGIN_META)).w).shiftRight(8).bitAnd(255)), on = (e, t) => h(p(e.element($(t, Z.ORIGIN_META)).w).shiftRight(16).bitAnd(C(63))), sn = (e, t) => {
751
+ let n = e.element($(t, Z.SSS_SIGMA_S));
752
+ return {
753
+ sigmaS: n.xyz,
754
+ g: n.w
755
+ };
756
+ }, cn = (e, t, n, r) => e.element($(t, Z.SSS_SIGMA_S)).assign(A(n, r)), ln = [
757
+ 610,
758
+ 550,
759
+ 465
760
+ ].map((e) => -.023 + .292 / (e / 1e3));
761
+ //#endregion
762
+ export { cn as $, ae as $t, lt as A, Ye as At, pt as B, Y as Bt, Pt as C, q as Ct, ot as D, Ze as Dt, st as E, Qe as Et, Vt as F, Oe as Ft, Qt as G, ce as Gt, Jt as H, de as Ht, Bt as I, Je as It, xt as J, oe as Jt, Xt as K, ue as Kt, Ut as L, He as Lt, sn as M, ve as Mt, an as N, Ne as Nt, ut as O, Xe as Ot, on as P, U as Pt, Nt as Q, me as Qt, zt as R, je as Rt, bt as S, Ke as St, ct as T, qe as Tt, Kt as U, pe as Ut, mt as V, B as Vt, Gt as W, fe as Wt, Ct as X, _e as Xt, wt as Y, le as Yt, Ft as Z, he as Zt, Et as _, Pe as _t, vt as a, R as an, W as at, Zt as b, Le as bt, It as c, Ce as ct, Dt as d, Ee as dt, z as en, Ht as et, Tt as f, ye as ft, Ot as g, Be as gt, kt as h, Ie as ht, it as i, N as in, ke as it, Mt as j, Me as jt, dt as k, $e as kt, tn as l, be as lt, At as m, Ae as mt, at as n, ge as nn, H as nt, gt as o, we as ot, jt as p, Se as pt, St as q, V as qt, Lt as r, F as rn, De as rt, _t as s, Te as st, ln as t, se as tn, Rt as tt, ht as u, xe as ut, qt as v, Re as vt, rn as w, Ge as wt, Yt as x, Fe as xt, Wt as y, Ve as yt, nn as z, We as zt };