rayzee 11.9.0 → 11.11.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 (43) hide show
  1. package/dist/{ArchiveImporter-BJxszU_k.js → ArchiveImporter-D5XOC3tN.js} +27 -12
  2. package/dist/{BidirectionalIntegrator-DWg66vAd.js → BidirectionalIntegrator-DqG0BEIz.js} +295 -295
  3. package/dist/{BufferLayout-Bzgccg1o.js → BufferLayout-BROyMqO1.js} +3 -1
  4. package/dist/{NeuralRetouch-BD9E-Yht.js → NeuralRetouch-BkxZPOYq.js} +1 -1
  5. package/dist/{NeuralSuperRes-C8Mf3tJX.js → NeuralSuperRes-a8xDtvXM.js} +1 -1
  6. package/dist/{PathTracer-DeE9UJ1n.js → PathTracer-C_gliSWI.js} +3037 -3002
  7. package/dist/{PhysicalSky-cKy75-oR.js → PhysicalSky-DWK8pS0U.js} +45 -45
  8. package/dist/{RayzeeRenderer-CzLyBA3G.js → RayzeeRenderer-B4ZehMg_.js} +40 -40
  9. package/dist/{SceneMetadata-C17UfOEp.js → SceneMetadata-Bb3iwWhh.js} +1 -1
  10. package/dist/SolarLimb-ZYl-Pwl0.js +821 -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 +6 -6
  15. package/dist/rayzee.es.js +95 -95
  16. package/dist/rayzee.umd.js +110 -110
  17. package/dist/{sceneCachePolicy-ywbGKHD3.js → sceneCachePolicy-BHNKvrHR.js} +12 -5
  18. package/package.json +1 -1
  19. package/src/EngineDefaults.js +3 -0
  20. package/src/Processor/BufferLayout.js +7 -6
  21. package/src/Processor/GeometryExtractor.js +8 -1
  22. package/src/Processor/MaterialPacking.js +5 -8
  23. package/src/Processor/PBRT/PBRTMaterials.js +2 -0
  24. package/src/Processor/PBRT/PBRTSceneBuilder.js +4 -3
  25. package/src/Processor/SceneProcessor.js +6 -2
  26. package/src/Processor/USD/USDScene.js +17 -1
  27. package/src/Processor/utils.js +1 -156
  28. package/src/Stages/PathTracer.js +9 -0
  29. package/src/Storage/SceneGraphCodec.js +2 -0
  30. package/src/TSL/Clearcoat.js +4 -4
  31. package/src/TSL/Common.js +36 -25
  32. package/src/TSL/EmissiveSampling.js +1 -1
  33. package/src/TSL/LightsSampling.js +1 -1
  34. package/src/TSL/MaterialEvaluation.js +34 -14
  35. package/src/TSL/MaterialProperties.js +37 -1
  36. package/src/TSL/MaterialTransmission.js +3 -9
  37. package/src/TSL/PathTracerCore.js +3 -2
  38. package/src/TSL/SceneResources.js +12 -1
  39. package/src/TSL/ShadeKernel.js +63 -14
  40. package/src/TSL/Struct.js +6 -0
  41. package/src/TSL/TextureSampling.js +29 -23
  42. package/src/managers/MaterialDataManager.js +21 -1
  43. package/dist/SolarLimb-DRYy8tln.js +0 -774
@@ -0,0 +1,821 @@
1
+ import { i as e, r as t } from "./Logger-dDDGj9Av.js";
2
+ import { l as n } from "./BufferLayout-BROyMqO1.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, context as u, dot as d, exp2 as f, float as p, floatBitsToUint as m, floor as h, int as g, log2 as _, mat3 as v, max as y, packSnorm2x16 as b, packUnorm2x16 as x, select as S, storage as C, struct as ee, uint as w, uintBitsToFloat as T, unpackSnorm2x16 as te, unpackUnorm2x16 as E, uvec2 as ne, 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 re = a.prototype.createNodeBuilder;
7
+ a.prototype.createNodeBuilder = function(e, t) {
8
+ let n = re.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 M(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 N = a.prototype.createStorageAttribute;
22
+ a.prototype.createStorageAttribute = function(e) {
23
+ let t = this.attributeUtils._getBufferAttribute(e);
24
+ if (!t.isGPUOnly) return N.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 P = 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(M(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
+ }, F = a.prototype.updateAttribute;
63
+ a.prototype.updateAttribute = function(e) {
64
+ if (!this.attributeUtils._getBufferAttribute(e).isGPUOnly) return F.call(this, e);
65
+ };
66
+ var I = 4096;
67
+ function L(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 ie = a.prototype.initTimestampQuery;
73
+ a.prototype.initTimestampQuery = function(e, t, n) {
74
+ let r = this.trackTimestamp && !this.timestampQueryPool[e];
75
+ if (ie.call(this, e, t, n), r) {
76
+ let r = this.timestampQueryPool[e];
77
+ if (r && r.maxQueries < I && n.timestampWrites) {
78
+ let i = r.constructor, a = new i(this.device, e, I);
79
+ a.allocateQueriesForContext = L, 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 ae(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) => ae(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) => ae(n(...e), r);
94
+ return i.layout = n.layout, i.isStruct = !0, i.wrap = (e) => ae(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/SceneResources.js
102
+ var z = "rayzeeScene", oe = (e, t) => u(e, { [z]: t });
103
+ function se(e) {
104
+ let t = e.context[z];
105
+ if (!t) throw Error("this kernel samples scene resources: build its root with withSceneResources()");
106
+ return t;
107
+ }
108
+ var ce = Object.freeze([
109
+ "clearcoat",
110
+ "sheen",
111
+ "iridescence",
112
+ "anisotropy",
113
+ "subsurface",
114
+ "dispersion",
115
+ "diffuseTransmission",
116
+ "diffuseRoughness"
117
+ ]), le = Object.freeze(Object.fromEntries(ce.map((e) => [e, !0])));
118
+ function ue(e) {
119
+ return e.context[z]?.materialLayers ?? le;
120
+ }
121
+ function de(e) {
122
+ return e.context[z]?.lightRadius ?? !0;
123
+ }
124
+ function fe(e) {
125
+ return e.context[z]?.transmissionMaps ?? !0;
126
+ }
127
+ function B(e) {
128
+ return e.context[z]?.clearcoatNormals ?? !0;
129
+ }
130
+ //#endregion
131
+ //#region src/TSL/Struct.js
132
+ var pe = R({
133
+ origin: "vec3",
134
+ direction: "vec3"
135
+ }), V = R({
136
+ color: "vec4",
137
+ emissive: "vec3",
138
+ emissiveIntensity: "float",
139
+ roughness: "float",
140
+ metalness: "float",
141
+ ior: "float",
142
+ transmission: "float",
143
+ thickness: "float",
144
+ clearcoat: "float",
145
+ clearcoatRoughness: "float",
146
+ clearcoatNormalMapIndex: "int",
147
+ clearcoatNormalScale: "float",
148
+ clearcoatNormal: "vec3",
149
+ opacity: "float",
150
+ transparent: "bool",
151
+ attenuationColor: "vec3",
152
+ attenuationDistance: "float",
153
+ dispersion: "float",
154
+ sheen: "float",
155
+ sheenRoughness: "float",
156
+ sheenColor: "vec3",
157
+ specularIntensity: "float",
158
+ specularColor: "vec3",
159
+ alphaTest: "float",
160
+ alphaMode: "int",
161
+ side: "int",
162
+ depthWrite: "int",
163
+ albedoMapIndex: "int",
164
+ emissiveMapIndex: "int",
165
+ normalMapIndex: "int",
166
+ bumpMapIndex: "int",
167
+ bumpScale: "float",
168
+ displacementScale: "float",
169
+ displacementBias: "float",
170
+ metalnessMapIndex: "int",
171
+ roughnessMapIndex: "int",
172
+ displacementMapIndex: "int",
173
+ normalScale: "vec2",
174
+ albedoTransform: "mat3",
175
+ emissiveTransform: "mat3",
176
+ normalTransform: "mat3",
177
+ bumpTransform: "mat3",
178
+ metalnessTransform: "mat3",
179
+ roughnessTransform: "mat3",
180
+ displacementTransform: "mat3",
181
+ iridescence: "float",
182
+ iridescenceIOR: "float",
183
+ iridescenceThicknessRange: "vec2",
184
+ subsurface: "float",
185
+ subsurfaceColor: "vec3",
186
+ subsurfaceRadius: "vec3",
187
+ subsurfaceRadiusScale: "float",
188
+ subsurfaceAnisotropy: "float",
189
+ anisotropy: "float",
190
+ anisotropyRotation: "float",
191
+ anisotropyMapIndex: "int",
192
+ transmissionMapIndex: "int",
193
+ clearcoatMapIndex: "int",
194
+ clearcoatRoughnessMapIndex: "int",
195
+ sheenColorMapIndex: "int",
196
+ sheenRoughnessMapIndex: "int",
197
+ iridescenceMapIndex: "int",
198
+ iridescenceThicknessMapIndex: "int",
199
+ specularIntensityMapIndex: "int",
200
+ specularColorMapIndex: "int",
201
+ diffuseTransmission: "float",
202
+ diffuseTransmissionColor: "vec3",
203
+ diffuseTransmissionMapIndex: "int",
204
+ diffuseTransmissionColorMapIndex: "int",
205
+ diffuseRoughness: "float"
206
+ }), me = R({
207
+ transmission: "float",
208
+ clearcoat: "float",
209
+ clearcoatRoughness: "float",
210
+ sheenColor: "vec3",
211
+ sheenRoughness: "float",
212
+ iridescence: "float",
213
+ iridescenceThickness: "float",
214
+ specularIntensity: "float",
215
+ specularColor: "vec3",
216
+ diffuseTransmission: "float",
217
+ diffuseTransmissionColor: "vec3"
218
+ }), he = R({
219
+ color: "vec4",
220
+ ior: "float",
221
+ transmission: "float",
222
+ attenuationColor: "vec3",
223
+ attenuationDistance: "float",
224
+ albedoMapIndex: "int",
225
+ opacity: "float",
226
+ transparent: "bool",
227
+ alphaTest: "float",
228
+ alphaMode: "int",
229
+ albedoTransform: "mat3"
230
+ }), ge = R({
231
+ shadowed: "vec3",
232
+ unoccluded: "vec3"
233
+ });
234
+ R({
235
+ position: "vec3",
236
+ radius: "float",
237
+ material: V
238
+ });
239
+ var _e = R({
240
+ didHit: "bool",
241
+ dst: "float",
242
+ hitPoint: "vec3",
243
+ normal: "vec3",
244
+ uv: "vec2",
245
+ materialIndex: "int",
246
+ meshIndex: "int",
247
+ instanceLeaf: "int",
248
+ triangleIndex: "int",
249
+ boxTests: "int",
250
+ triTests: "int"
251
+ });
252
+ R({
253
+ posA: "vec3",
254
+ posB: "vec3",
255
+ posC: "vec3",
256
+ uvA: "vec2",
257
+ uvB: "vec2",
258
+ uvC: "vec2",
259
+ normalA: "vec3",
260
+ normalB: "vec3",
261
+ normalC: "vec3",
262
+ material: V,
263
+ materialIndex: "int",
264
+ meshIndex: "int"
265
+ }), R({
266
+ color: "vec4",
267
+ samples: "int"
268
+ });
269
+ var ve = R({
270
+ direction: "vec3",
271
+ value: "vec3",
272
+ pdf: "float",
273
+ isTransmission: "bool",
274
+ colorWeight: "vec3",
275
+ isDiffuseTransmission: "bool"
276
+ }), ye = R({
277
+ specular: "float",
278
+ diffuse: "float",
279
+ sheen: "float",
280
+ clearcoat: "float",
281
+ transmission: "float",
282
+ iridescence: "float",
283
+ diffuseTransmission: "float"
284
+ }), be = R({
285
+ Ta: "vec3",
286
+ Ba: "vec3"
287
+ }), xe = R({
288
+ NoL: "float",
289
+ NoV: "float",
290
+ NoH: "float",
291
+ VoH: "float",
292
+ LoH: "float",
293
+ ToH: "float",
294
+ BoH: "float",
295
+ ToV: "float",
296
+ BoV: "float",
297
+ ToL: "float",
298
+ BoL: "float",
299
+ coatNoL: "float",
300
+ coatNoV: "float",
301
+ coatNoH: "float"
302
+ }), Se = R({
303
+ compensation: "vec3",
304
+ E_total: "vec3"
305
+ }), Ce = R({
306
+ f0: "vec3",
307
+ f90: "float",
308
+ eta: "float",
309
+ F0m: "vec3",
310
+ F0: "vec3"
311
+ }), we = R({
312
+ albedo: "vec4",
313
+ emissive: "vec3",
314
+ metalness: "float",
315
+ roughness: "float",
316
+ normal: "vec3",
317
+ hasTextures: "bool"
318
+ }), Te = R({
319
+ isMetallic: "bool",
320
+ isRough: "bool",
321
+ isSmooth: "bool",
322
+ isTransmissive: "bool",
323
+ hasClearcoat: "bool",
324
+ isEmissive: "bool",
325
+ complexityScore: "float"
326
+ }), Ee = R({
327
+ albedoUV: "vec2",
328
+ normalUV: "vec2",
329
+ metalnessUV: "vec2",
330
+ emissiveUV: "vec2",
331
+ bumpUV: "vec2",
332
+ roughnessUV: "vec2",
333
+ normalBumpSameUV: "bool",
334
+ metalRoughSameUV: "bool",
335
+ albedoEmissiveSameUV: "bool",
336
+ allSameUV: "bool"
337
+ }), De = R({
338
+ invRoughness: "float",
339
+ metalFactor: "float",
340
+ iorFactor: "float",
341
+ maxSheenColor: "float"
342
+ });
343
+ R({
344
+ traversals: "int",
345
+ transmissiveTraversals: "int",
346
+ rayType: "int",
347
+ isPrimaryRay: "bool",
348
+ actualBounceDepth: "int"
349
+ });
350
+ //#endregion
351
+ //#region src/TSL/Common.js
352
+ var Oe = /* @__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"), ke = .9999, Ae = 3.14159, je = 1 / Ae, Me = 2 * Ae, Ne = 1e-6, Pe = .05, Fe = .089, Ie = .001, Le = k(.2126, .7152, .0722), Re = 65504, H = (e, t = 1e7) => S(e.equal(e), e, p(0)).clamp(0, t), ze = (e, t = 1e7) => k(H(e.x, t), H(e.y, t), H(e.z, t)), U = n.SLOTS_PER_MATERIAL, Be = n.SLOT, W = Be, Ve = v(3.2404542, -.969266, .0556434, -1.5371385, 1.8760108, -.2040259, -.4985314, .041556, 1.0572252);
353
+ 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");
354
+ var He = j("\n fn square( x: f32 ) -> f32 {\n\n return x * x;\n\n }\n");
355
+ 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");
356
+ var Ue = j("\n fn luminance( color: vec3f ) -> f32 {\n\n return dot( color, vec3f( 0.2126, 0.7152, 0.0722 ) );\n\n }\n"), We = j(`
357
+ fn powerHeuristic( pdf1: f32, pdf2: f32 ) -> f32 {
358
+
359
+ let p1 = pdf1 * pdf1;
360
+ let p2 = pdf2 * pdf2;
361
+ return p1 / max( p1 + p2, ${Ie} );
362
+
363
+ }
364
+ `), Ge = j(`
365
+ fn balanceHeuristic( pdf1: f32, pdf2: f32 ) -> f32 {
366
+
367
+ return pdf1 / max( pdf1 + pdf2, ${Ie} );
368
+
369
+ }
370
+ `);
371
+ 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");
372
+ var Ke = 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"), qe = (e, t, n) => {
373
+ if (!B(n)) return e;
374
+ let r = t.clearcoatNormal;
375
+ return S(d(r, r).equal(0), e, S(d(e, r).lessThan(0), r.negate(), r));
376
+ }, Je = o(([e, t]) => {
377
+ 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();
378
+ return be({
379
+ Ta: r.mul(a).add(i.mul(o)),
380
+ Ba: i.mul(a).sub(r.mul(o))
381
+ });
382
+ }), Ye = o(([e, t, n, r], i) => {
383
+ let a = t.add(n).toVar(), o = d(a, a).toVar();
384
+ a.assign(o.greaterThan(Ne).select(a.div(o.sqrt()), k(0, 0, 1)));
385
+ let c = p(0).toVar(), l = p(0).toVar(), u = p(0).toVar(), f = p(0).toVar(), m = p(0).toVar(), h = p(0).toVar();
386
+ s(r.anisotropy.greaterThan(0), () => {
387
+ let i = be.wrap(Je(e, r.anisotropyRotation));
388
+ c.assign(d(i.Ta, a)), l.assign(d(i.Ba, a)), u.assign(d(i.Ta, t)), f.assign(d(i.Ba, t)), m.assign(d(i.Ta, n)), h.assign(d(i.Ba, n));
389
+ });
390
+ let g = y(d(e, n), .001), _ = y(d(e, t), .001), v = y(d(e, a), .001), b = {
391
+ coatNoL: g,
392
+ coatNoV: _,
393
+ coatNoH: v
394
+ };
395
+ if (B(i)) {
396
+ let o = qe(e, r, i).toVar();
397
+ b = {
398
+ coatNoL: y(d(o, n), .001),
399
+ coatNoV: y(d(o, t), .001),
400
+ coatNoH: y(d(o, a), .001)
401
+ };
402
+ }
403
+ return xe({
404
+ NoL: g,
405
+ NoV: _,
406
+ NoH: v,
407
+ VoH: y(d(t, a), .001),
408
+ LoH: y(d(n, a), .001),
409
+ ToH: c,
410
+ BoH: l,
411
+ ToV: u,
412
+ BoV: f,
413
+ ToL: m,
414
+ BoL: h,
415
+ ...b
416
+ });
417
+ }), Xe = 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"), Qe = j(`
418
+ fn applySoftSuppressionRGB( color: vec3f, threshold: f32, dampingFactor: f32 ) -> vec3f {
419
+
420
+ let lum = dot( color, vec3f( 0.2126, 0.7152, 0.0722 ) );
421
+ if ( lum <= threshold ) {
422
+ return color;
423
+ }
424
+ let suppressedLum = applySoftSuppression( lum, threshold, dampingFactor );
425
+ if ( lum > ${Ne} ) {
426
+ return color * ( suppressedLum / lum );
427
+ }
428
+ return color;
429
+
430
+ }
431
+ `, [Ze]), $e = o(([e, t, n, r, i, a]) => {
432
+ let o = e.greaterThan(.7).toVar(), c = t.greaterThan(.8), u = t.lessThan(.3).toVar(), d = n.greaterThan(.5).toVar(), f = r.greaterThan(.5).toVar(), m = a.greaterThan(0), h = i.x.add(i.y).add(i.z).greaterThan(0).toVar(), g = p(.15).mul(p(o)).add(p(.25).mul(p(u))).add(p(.45).mul(p(d))).add(p(.35).mul(p(f))).add(p(.3).mul(p(h))).add(p(.4).mul(p(m))), _ = p(0).toVar();
433
+ return s(o.and(u), () => {
434
+ _.addAssign(.15);
435
+ }), s(d.and(f), () => {
436
+ _.addAssign(.2);
437
+ }), s(h.and(d.or(o)), () => {
438
+ _.addAssign(.1);
439
+ }), Te({
440
+ isMetallic: o,
441
+ isRough: c,
442
+ isSmooth: u,
443
+ isTransmissive: d,
444
+ hasClearcoat: f,
445
+ isEmissive: h,
446
+ complexityScore: l(g.add(_), 0, 1)
447
+ });
448
+ });
449
+ function et(e, t, n) {
450
+ return e.length === 1 ? e[0] : {
451
+ isSplitStorage: !0,
452
+ parts: e,
453
+ perPart: t,
454
+ type: n,
455
+ value: e[0].value
456
+ };
457
+ }
458
+ function tt(e, t, n) {
459
+ let { parts: r, perPart: i } = e, a = g(t).toVar(), o = n.map(() => ({
460
+ uvec4: D,
461
+ uvec2: ne
462
+ }[e.type] ?? A)(0).toVar()), c = (e) => () => {
463
+ let t = e === 0 ? a : a.sub(g(i * e));
464
+ n.forEach((n, i) => o[i].assign(r[e].element(n === 0 ? t : t.add(g(n)))));
465
+ }, l = s(a.lessThan(g(i)), c(0));
466
+ for (let e = 1; e < r.length - 1; e++) l = l.ElseIf(a.lessThan(g(i * (e + 1))), c(e));
467
+ return l.Else(c(r.length - 1)), o;
468
+ }
469
+ function nt(e, t) {
470
+ return e.isSplitStorage ? tt(e, t, [0])[0] : e.element(t);
471
+ }
472
+ var G = (e) => e?.isNode ? e : g(e), K = (e, t, n, r) => nt(e, G(r).mul(G(t)).add(G(n))), rt = (e, t, n) => {
473
+ if (n < 3) return K(e.geo, t, g(n), g(3));
474
+ if (!e.withoutUV) return K(e.shade, t, g(n - 3), g(2));
475
+ if (n === 3) return D(0);
476
+ let r = nt(e.shade, G(t));
477
+ return D(0, 0, r.x, r.y);
478
+ }, q = /* @__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"), J = /* @__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"), Y = 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"), it = o(([e, t], n) => {
479
+ let r = K(t, e, g(W.COLOR_METALNESS), g(U)).toVar(), i = K(t, e, g(W.EMISSIVE_ROUGHNESS), g(U)).toVar(), a = K(t, e, g(W.IOR_TRANSMISSION), g(U)).toVar(), o = K(t, e, g(W.ATTENUATION), g(U)).toVar(), c = K(t, e, g(W.DISPERSION_SHEEN), g(U)).toVar(), l = K(t, e, g(W.SHEEN_COLOR), g(U)).toVar(), u = K(t, e, g(W.SPECULAR), g(U)).toVar(), d = K(t, e, g(W.IRIDESCENCE), g(U)).toVar(), f = K(t, e, g(W.MAP_INDICES_A), g(U)).toVar(), p = K(t, e, g(W.MAP_INDICES_B), g(U)).toVar(), m = K(t, e, g(W.OPACITY_ALPHA), g(U)).toVar(), h = K(t, e, g(W.ALPHA_MODE), g(U)).toVar(), _ = K(t, e, g(W.BUMP_DISPLACEMENT), g(U)).toVar(), v = K(t, e, g(W.ALBEDO_TRANSFORM_A), g(U)).toVar(), y = K(t, e, g(W.ALBEDO_TRANSFORM_B), g(U)).toVar(), b = K(t, e, g(W.NORMAL_TRANSFORM_A), g(U)).toVar(), x = K(t, e, g(W.NORMAL_TRANSFORM_B), g(U)).toVar(), S = K(t, e, g(W.ROUGHNESS_TRANSFORM_A), g(U)).toVar(), C = K(t, e, g(W.ROUGHNESS_TRANSFORM_B), g(U)).toVar(), ee = K(t, e, g(W.METALNESS_TRANSFORM_A), g(U)).toVar(), w = K(t, e, g(W.METALNESS_TRANSFORM_B), g(U)).toVar(), T = K(t, e, g(W.EMISSIVE_TRANSFORM_A), g(U)).toVar(), te = K(t, e, g(W.EMISSIVE_TRANSFORM_B), g(U)).toVar(), E = K(t, e, g(W.BUMP_TRANSFORM_A), g(U)).toVar(), ne = K(t, e, g(W.BUMP_TRANSFORM_B), g(U)).toVar(), D = K(t, e, g(W.DISPLACEMENT_TRANSFORM_A), g(U)).toVar(), j = K(t, e, g(W.DISPLACEMENT_TRANSFORM_B), g(U)).toVar(), re = K(t, e, g(W.SUBSURFACE_A), g(U)).toVar(), M = K(t, e, g(W.SUBSURFACE_B), g(U)).toVar(), N = K(t, e, g(W.SUBSURFACE_C), g(U)).toVar(), P = K(t, e, g(W.EXT_MAP_INDICES_A), g(U)).toVar(), F = K(t, e, g(W.EXT_MAP_INDICES_B), g(U)).toVar(), I = K(t, e, g(W.EXT_MAP_INDICES_C), g(U)).toVar(), L = A(-1, -1, -1, 1).toVar(), ie = l.a.greaterThan(0);
480
+ return s(B(n) ? ie.or(p.b.greaterThan(0)) : ie, () => {
481
+ L.assign(K(t, e, g(W.EXT_MAP_INDICES_D), g(U)));
482
+ }), V({
483
+ color: A(r.rgb, 1),
484
+ metalness: r.a,
485
+ emissive: i.rgb,
486
+ roughness: i.a,
487
+ ior: a.r,
488
+ transmission: a.g,
489
+ thickness: a.b,
490
+ emissiveIntensity: a.a,
491
+ attenuationColor: o.rgb,
492
+ attenuationDistance: o.a,
493
+ dispersion: c.r,
494
+ sheen: c.b,
495
+ sheenRoughness: c.a,
496
+ sheenColor: l.rgb,
497
+ specularIntensity: u.r,
498
+ specularColor: u.gba,
499
+ iridescence: d.r,
500
+ iridescenceIOR: d.g,
501
+ iridescenceThicknessRange: d.ba,
502
+ subsurfaceColor: re.rgb,
503
+ subsurface: re.a,
504
+ subsurfaceRadius: M.rgb,
505
+ subsurfaceRadiusScale: M.a,
506
+ subsurfaceAnisotropy: N.r,
507
+ anisotropy: N.g,
508
+ anisotropyRotation: N.b,
509
+ anisotropyMapIndex: g(N.a),
510
+ transmissionMapIndex: g(P.r),
511
+ clearcoatMapIndex: g(P.g),
512
+ clearcoatRoughnessMapIndex: g(P.b),
513
+ sheenColorMapIndex: g(P.a),
514
+ sheenRoughnessMapIndex: g(F.r),
515
+ iridescenceMapIndex: g(F.g),
516
+ iridescenceThicknessMapIndex: g(F.b),
517
+ specularIntensityMapIndex: g(F.a),
518
+ specularColorMapIndex: g(I.r),
519
+ diffuseTransmission: l.a,
520
+ diffuseTransmissionColor: I.gba,
521
+ diffuseTransmissionMapIndex: g(L.r),
522
+ diffuseTransmissionColorMapIndex: g(L.g),
523
+ diffuseRoughness: c.g,
524
+ albedoMapIndex: g(f.r),
525
+ normalMapIndex: g(f.g),
526
+ roughnessMapIndex: g(f.b),
527
+ metalnessMapIndex: g(f.a),
528
+ emissiveMapIndex: g(p.r),
529
+ bumpMapIndex: g(p.g),
530
+ clearcoat: p.b,
531
+ clearcoatRoughness: p.a,
532
+ clearcoatNormalMapIndex: g(L.b),
533
+ clearcoatNormalScale: L.a,
534
+ clearcoatNormal: k(0),
535
+ opacity: m.r,
536
+ side: g(m.g),
537
+ transparent: m.b,
538
+ alphaTest: m.a,
539
+ alphaMode: g(h.r),
540
+ depthWrite: g(h.g),
541
+ normalScale: O(h.b, h.b),
542
+ bumpScale: _.r,
543
+ displacementScale: _.g,
544
+ displacementMapIndex: g(_.b),
545
+ displacementBias: _.a,
546
+ albedoTransform: Y({
547
+ data1: v,
548
+ data2: y
549
+ }),
550
+ normalTransform: Y({
551
+ data1: b,
552
+ data2: x
553
+ }),
554
+ roughnessTransform: Y({
555
+ data1: S,
556
+ data2: C
557
+ }),
558
+ metalnessTransform: Y({
559
+ data1: ee,
560
+ data2: w
561
+ }),
562
+ emissiveTransform: Y({
563
+ data1: T,
564
+ data2: te
565
+ }),
566
+ bumpTransform: Y({
567
+ data1: E,
568
+ data2: ne
569
+ }),
570
+ displacementTransform: Y({
571
+ data1: D,
572
+ data2: j
573
+ })
574
+ });
575
+ }), at = o(() => {
576
+ let e = v(1, 0, 0, 0, 1, 0, 0, 0, 1);
577
+ return V({
578
+ color: A(1, 1, 1, 1),
579
+ emissive: k(0),
580
+ emissiveIntensity: p(0),
581
+ roughness: p(1),
582
+ metalness: p(0),
583
+ ior: p(1.5),
584
+ transmission: p(0),
585
+ thickness: p(0),
586
+ clearcoat: p(0),
587
+ clearcoatRoughness: p(0),
588
+ clearcoatNormalMapIndex: g(-1),
589
+ clearcoatNormalScale: p(1),
590
+ clearcoatNormal: k(0),
591
+ opacity: p(1),
592
+ transparent: p(0),
593
+ attenuationColor: k(1),
594
+ attenuationDistance: p(0),
595
+ dispersion: p(0),
596
+ sheen: p(0),
597
+ sheenRoughness: p(1),
598
+ sheenColor: k(0),
599
+ specularIntensity: p(1),
600
+ specularColor: k(1),
601
+ alphaTest: p(0),
602
+ alphaMode: g(0),
603
+ side: g(0),
604
+ depthWrite: g(1),
605
+ albedoMapIndex: g(-1),
606
+ emissiveMapIndex: g(-1),
607
+ normalMapIndex: g(-1),
608
+ bumpMapIndex: g(-1),
609
+ bumpScale: p(1),
610
+ displacementScale: p(0),
611
+ displacementBias: p(0),
612
+ metalnessMapIndex: g(-1),
613
+ roughnessMapIndex: g(-1),
614
+ displacementMapIndex: g(-1),
615
+ normalScale: O(1, 1),
616
+ albedoTransform: e,
617
+ emissiveTransform: e,
618
+ normalTransform: e,
619
+ bumpTransform: e,
620
+ metalnessTransform: e,
621
+ roughnessTransform: e,
622
+ displacementTransform: e,
623
+ iridescence: p(0),
624
+ iridescenceIOR: p(1.3),
625
+ iridescenceThicknessRange: O(100, 400),
626
+ subsurface: p(0),
627
+ subsurfaceColor: k(1),
628
+ subsurfaceRadius: k(1, .2, .1),
629
+ subsurfaceRadiusScale: p(1),
630
+ subsurfaceAnisotropy: p(0),
631
+ anisotropy: p(0),
632
+ anisotropyRotation: p(0),
633
+ anisotropyMapIndex: g(-1),
634
+ transmissionMapIndex: g(-1),
635
+ clearcoatMapIndex: g(-1),
636
+ clearcoatRoughnessMapIndex: g(-1),
637
+ sheenColorMapIndex: g(-1),
638
+ sheenRoughnessMapIndex: g(-1),
639
+ iridescenceMapIndex: g(-1),
640
+ iridescenceThicknessMapIndex: g(-1),
641
+ specularIntensityMapIndex: g(-1),
642
+ specularColorMapIndex: g(-1),
643
+ diffuseTransmission: p(0),
644
+ diffuseTransmissionColor: k(1),
645
+ diffuseTransmissionMapIndex: g(-1),
646
+ diffuseTransmissionColorMapIndex: g(-1),
647
+ diffuseRoughness: p(0)
648
+ });
649
+ }), ot = o(([e, t]) => {
650
+ let n = K(t, e, g(W.IOR_TRANSMISSION), g(U)).toVar(), r = K(t, e, g(W.ATTENUATION), g(U)).toVar(), i = K(t, e, g(W.MAP_INDICES_A), g(U)).toVar(), a = K(t, e, g(W.OPACITY_ALPHA), g(U)).toVar(), o = K(t, e, g(W.ALPHA_MODE), g(U)).toVar(), s = K(t, e, g(W.ALBEDO_TRANSFORM_A), g(U)).toVar(), c = K(t, e, g(W.ALBEDO_TRANSFORM_B), g(U)).toVar();
651
+ return he({
652
+ color: A(1),
653
+ ior: n.r,
654
+ transmission: n.g,
655
+ attenuationColor: r.rgb,
656
+ attenuationDistance: r.a,
657
+ albedoMapIndex: g(i.r),
658
+ opacity: a.r,
659
+ transparent: a.b,
660
+ alphaTest: a.a,
661
+ alphaMode: g(o.r),
662
+ albedoTransform: Y({
663
+ data1: s,
664
+ data2: c
665
+ })
666
+ });
667
+ }), st = (e, t) => {
668
+ let n = (t) => e.shiftRight(w(t)).bitAnd(w(1)).equal(w(1)), r = t ? t.equal(g(0)) : c(!0);
669
+ return n(26).or(n(27).and(r));
670
+ }, ct = (e, t) => {
671
+ let n = e.value?.copyRecordBase;
672
+ return n === void 0 ? e.isSplitStorage ? tt(e, g(t).mul(4), [
673
+ 1,
674
+ 2,
675
+ 3
676
+ ]) : [
677
+ K(e, t, g(1), g(4)),
678
+ K(e, t, g(2), g(4)),
679
+ K(e, t, g(3), g(4))
680
+ ] : [
681
+ 0,
682
+ 1,
683
+ 2
684
+ ].map((r) => K(e, t, g(n + r), g(3)));
685
+ }, lt = (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)), ut = (e, t) => {
686
+ let n = e[0].xyz.dot(e[1].xyz.cross(e[2].xyz));
687
+ return lt(e, t).mul(n.sign());
688
+ }, dt = /* @__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"), ft = (e, t) => dt({
689
+ r0: e[0].xyz,
690
+ r1: e[1].xyz,
691
+ r2: e[2].xyz,
692
+ v: t.sub(k(e[0].w, e[1].w, e[2].w))
693
+ }), pt = t("gpu"), X = {
694
+ ORIGIN_META: 0,
695
+ DIR_FLAGS: 1,
696
+ THROUGHPUT_PDF: 2,
697
+ RADIANCE_ALPHA: 3,
698
+ MEDIUM_STACK: 4,
699
+ MEDIUM_SIGMA_A: 5,
700
+ SSS_SIGMA_S: 6
701
+ }, Z = {
702
+ DIST_TRI_BARY: 0,
703
+ NORMAL_MAT: 1,
704
+ RNG: 2,
705
+ VERTEX: 3
706
+ }, mt = 0, ht = 0, Q = 0, $ = (e, t) => t === 0 ? e : e.add(t * mt);
707
+ function gt(e, t) {
708
+ t && e?._attributes?.delete?.(t);
709
+ }
710
+ var _t = class {
711
+ constructor(e = 0, t = null, n = 0) {
712
+ this.capacity = 0, this.lightVertices = 0, this._renderer = t, this._attrs = {}, this.rayBuffer = null, this.hitBuffer = null, e > 0 && this.allocate(e, n);
713
+ }
714
+ allocate(t, n = 0) {
715
+ this.dispose(), this.capacity = t, this.lightVertices = n, mt = t, ht = t * (n > 0 ? 7 : 3), Q = ht + n * 4;
716
+ let r = t * 7, i = M(r, 4);
717
+ this._attrs.ray = i, this.rayBuffer = {
718
+ rw: C(i, "vec4"),
719
+ ro: C(i, "vec4").toReadOnly()
720
+ };
721
+ let a = Q + t * 1, o = M(a, 4, Uint32Array);
722
+ this._attrs.hit = o, this.hitBuffer = {
723
+ rw: C(o, "uvec4"),
724
+ ro: C(o, "uvec4").toReadOnly()
725
+ }, this.rayBytes = r * 16, this.hitBytes = a * 16, this.totalBytes = this.rayBytes + this.hitBytes, pt.debug(`ray pool capacity ${e.n(t)} · ${e.mb(this.totalBytes)} (rays ${e.mb(this.rayBytes)} · hits ${e.mb(this.hitBytes)})`);
726
+ }
727
+ resize(e, t = 0) {
728
+ return e <= this.capacity && this.capacity > 0 && t === this.lightVertices ? !1 : (this.allocate(e, t), !0);
729
+ }
730
+ dispose() {
731
+ gt(this._renderer, this._attrs.ray), gt(this._renderer, this._attrs.hit), this._attrs = {}, this.rayBuffer = null, this.hitBuffer = null, this.capacity = 0, this.lightVertices = 0;
732
+ }
733
+ }, vt = (e, t) => e.element($(t, X.ORIGIN_META)).xyz, yt = (e, t) => e.element($(t, X.DIR_FLAGS)).xyz, bt = (e, t) => m(e.element($(t, X.DIR_FLAGS)).w), xt = (e, t) => e.element($(t, X.THROUGHPUT_PDF)).xyz, St = (e, t) => e.element($(t, X.THROUGHPUT_PDF)).w, Ct = (e, t) => e.element($(t, X.RADIANCE_ALPHA)), wt = (e) => w(e).mul(1).add(Q), Tt = (e, t, n, r, i, a = null) => {
734
+ let o = wt(t), s = a === null ? E(e.element(o).w).y : p(a);
735
+ return e.element(o).assign(D(b(O(n.x, n.y)), b(O(n.z, r)), x(O(i.x, i.y)), x(O(i.z, s))));
736
+ }, Et = (e, t, n) => {
737
+ let r = wt(t), i = e.element(r).toVar();
738
+ return e.element(r).assign(D(i.x, i.y, i.z, x(O(E(i.w).x, n))));
739
+ }, Dt = (e, t) => e.element(wt(t)), Ot = (e) => E(e.w).y, kt = (e) => {
740
+ let t = te(e.x), n = te(e.y);
741
+ return A(k(t.x, t.y, n.x).mul(.5).add(.5), n.y);
742
+ }, At = (e) => k(E(e.z), E(e.w).x), jt = (e) => {
743
+ let t = l(h(_(y(e, 1e-6))), -8, 7), n = l(p(e).mul(f(t.negate())).sub(1).mul(64), 0, 63);
744
+ return S(p(e).lessThan(.004), w(0), w(t.add(8)).shiftLeft(6).bitOr(w(n)));
745
+ }, Mt = (e, t) => {
746
+ let n = m(e.element($(t, X.ORIGIN_META)).w).shiftRight(22), r = p(n.shiftRight(6).bitAnd(w(15))).sub(8), i = p(n.bitAnd(w(63))).div(64).add(1);
747
+ return S(n.equal(w(0)), p(0), i.mul(f(r)));
748
+ }, Nt = (e, t, n, r, i, a = w(0), o = null) => {
749
+ let s = w(r).bitAnd(w(255)).bitOr(w(i).bitAnd(w(255)).shiftLeft(8)).bitOr(w(a).bitAnd(w(63)).shiftLeft(16));
750
+ return o !== null && (s = s.bitOr(jt(o).shiftLeft(22))), e.element($(t, X.ORIGIN_META)).assign(A(n, T(s)));
751
+ }, Pt = (e, t, n, r) => e.element($(t, X.DIR_FLAGS)).assign(A(n, T(r))), Ft = (e, t, n, r) => e.element($(t, X.THROUGHPUT_PDF)).assign(A(n, r)), It = (e, t, n) => e.element($(t, X.RADIANCE_ALPHA)).assign(n), Lt = (e, t) => T(e.element($(t, Z.DIST_TRI_BARY)).x), Rt = (e, t) => e.element($(t, Z.DIST_TRI_BARY)).y, zt = (e, t) => T(e.element($(t, Z.DIST_TRI_BARY)).zw), Bt = (e, t) => J(e.element($(t, Z.NORMAL_MAT)).x), Vt = (e, t) => w(e.element($(t, Z.NORMAL_MAT)).y), Ht = (e, t) => g(e.element($(t, Z.NORMAL_MAT)).z).sub(g(1)), Ut = (e, t) => e.element($(t, Z.NORMAL_MAT)).w, Wt = (e, t) => e.element($(t, Z.RNG)).x, Gt = (e, t, n) => e.element($(t, Z.RNG)).assign(D(n, 0, 0, 0)), Kt = (e, t) => {
752
+ let n = e.element($(t, Z.RNG));
753
+ return {
754
+ dVCM: T(n.y),
755
+ dVC: T(n.z)
756
+ };
757
+ }, qt = (e, t, n, r, i) => e.element($(t, Z.RNG)).assign(D(n, m(r), m(i), w(0))), Jt = (e) => (t) => $(e, Z.VERTEX + t), Yt = (e) => (t) => w(e).mul(4).add(ht + t), Xt = (e, t, n) => {
758
+ e.element(t(0)).assign(D(m(n.position), n.tag)), e.element(t(1)).assign(D(m(n.throughput), q(n.V))), e.element(t(2)).assign(D(q(n.N), q(n.facetN), w(n.materialIndex).bitOr(w(n.extra).bitAnd(w(255)).shiftLeft(w(24))), m(n.uv.x))), e.element(t(3)).assign(D(m(n.uv.y), m(n.dVCM), m(n.dVC), w(0)));
759
+ }, Zt = (e, t) => e.element(t(0)).w, Qt = (e, t) => T(e.element(t(0)).xyz), $t = (e, t) => e.element(t(3)).w, en = (e, t, n) => e.element(t(3)).w.assign(n), tn = (e, t) => {
760
+ 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();
761
+ return {
762
+ position: T(n.xyz),
763
+ tag: n.w,
764
+ throughput: T(r.xyz),
765
+ V: J(r.w),
766
+ N: J(i.x),
767
+ facetN: J(i.y),
768
+ materialIndex: i.z.bitAnd(w(16777215)),
769
+ uv: O(T(i.w), T(a.x)),
770
+ dVCM: T(a.y),
771
+ dVC: T(a.z),
772
+ extra: i.z.shiftRight(w(24))
773
+ };
774
+ }, nn = (e, t, n) => {
775
+ let r = e.element(t(0)).w;
776
+ return S(r.shiftRight(w(8)).equal(n), r.bitAnd(w(255)), w(0));
777
+ }, rn = (e, t, n, r) => {
778
+ let i = e.element(t(0)).xyz.toVar();
779
+ e.element(t(0)).assign(D(i, n.shiftLeft(w(8)).bitOr(w(r))));
780
+ }, an = (e, t, n, r, i, a) => e.element($(t, Z.VERTEX)).assign(D(w(n), w(g(r).add(g(1))), m(i), m(a))), on = (e, t) => {
781
+ let n = e.element($(t, Z.VERTEX)).toVar();
782
+ return {
783
+ triangle: g(n.x),
784
+ instanceLeaf: g(n.y).sub(g(1)),
785
+ cosLight: T(n.z),
786
+ scale: T(n.w)
787
+ };
788
+ }, sn = (e, t, n, r, i, a, o, s, c, l = w(0)) => {
789
+ e.element($(t, Z.DIST_TRI_BARY)).assign(D(m(n), r, m(i), m(a))), e.element($(t, Z.NORMAL_MAT)).assign(D(q(o), s, c, l));
790
+ }, cn = (e, t) => {
791
+ let n = e.element($(t, X.MEDIUM_STACK)), r = m(n.x);
792
+ return {
793
+ stackDepth: r.bitAnd(255),
794
+ transTraversals: r.shiftRight(8).bitAnd(255),
795
+ wavelength: r.shiftRight(16).bitAnd(65535),
796
+ ior1: n.y,
797
+ ior2: n.z,
798
+ ior3: n.w
799
+ };
800
+ }, ln = (e, t, n, r, i, a, o, s = w(0)) => e.element($(t, X.MEDIUM_STACK)).assign(A(T(n.bitOr(r.shiftLeft(8)).bitOr(s.shiftLeft(16))), i, a, o)), un = (e, t) => e.element($(t, X.MEDIUM_SIGMA_A)).xyz, dn = (e, t, n) => {
801
+ let r = e.element($(t, X.MEDIUM_SIGMA_A)).w.toVar();
802
+ e.element($(t, X.MEDIUM_SIGMA_A)).assign(A(n, r));
803
+ }, fn = (e) => {
804
+ let t = l(e, k(0), k(1)).mul(1023).add(.5);
805
+ return w(t.x).bitOr(w(t.y).shiftLeft(10)).bitOr(w(t.z).shiftLeft(20));
806
+ }, pn = (e) => k(p(e.bitAnd(w(1023))), p(e.shiftRight(10).bitAnd(w(1023))), p(e.shiftRight(20).bitAnd(w(1023)))).div(1023), mn = (e, t) => pn(m(e.element($(t, X.MEDIUM_SIGMA_A)).w)), hn = (e, t, n) => {
807
+ let r = e.element($(t, X.MEDIUM_SIGMA_A)).xyz.toVar();
808
+ e.element($(t, X.MEDIUM_SIGMA_A)).assign(A(r, T(fn(n))));
809
+ }, gn = (e, t) => g(m(e.element($(t, X.ORIGIN_META)).w).bitAnd(255)), _n = (e, t) => g(m(e.element($(t, X.ORIGIN_META)).w).shiftRight(8).bitAnd(255)), vn = (e, t) => g(m(e.element($(t, X.ORIGIN_META)).w).shiftRight(16).bitAnd(w(63))), yn = (e, t) => {
810
+ let n = e.element($(t, X.SSS_SIGMA_S));
811
+ return {
812
+ sigmaS: n.xyz,
813
+ g: n.w
814
+ };
815
+ }, bn = (e, t, n, r) => e.element($(t, X.SSS_SIGMA_S)).assign(A(n, r)), xn = [
816
+ 610,
817
+ 550,
818
+ 465
819
+ ].map((e) => -.023 + .292 / (e / 1e3));
820
+ //#endregion
821
+ export { bn as $, Te as $t, xt as A, ft as At, Tt as B, tt as Bt, Kt as C, at as Ct, vt as D, dt as Dt, yt as E, ot as Et, $t as F, H as Ft, dn as G, Ce as Gt, sn as H, J as Ht, Qt as I, ze as It, Nt as J, ve as Jt, ln as K, Se as Kt, tn as L, st as Lt, yn as M, Ue as Mt, _n as N, Oe as Nt, St as O, ut as Ot, vn as P, We as Pt, Gt as Q, De as Qt, Zt as R, et as Rt, Mt as S, Ke as St, bt as T, it as Tt, an as U, be as Ut, Et as V, rt as Vt, rn as W, ye as Wt, Ft as X, me as Xt, It as Y, xe as Yt, qt as Z, _e as Zt, Rt as _, Ge as _t, At as a, le as an, U as at, un as b, qe as bt, Jt as c, se as cn, Pe as ct, zt as d, fe as dn, Le as dt, we as en, en as et, Lt as f, oe as fn, ke as ft, Bt as g, Qe as gt, Vt as h, R as hn, Je as ht, gt as i, Ee as in, Be as it, Wt as j, ct as jt, Ct as k, lt as kt, mn as l, B as ln, Ae as lt, Ht as m, M as mn, Ve as mt, _t as n, V as nn, Ne as nt, Ot as o, ce as on, Fe as ot, Ut as p, P as pn, Me as pt, Pt as q, ge as qt, Yt as r, he as rn, Re as rt, kt as s, ue as sn, Ie as st, xn as t, pe as tn, Xt as tt, Dt as u, de as un, je as ut, on as v, Xe as vt, gn as w, K as wt, cn as x, Ye as xt, nn as y, $e as yt, hn as z, He as zt };