@roomle/web-sdk 4.3.0-alpha.4 → 5.0.0-alpha.1

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 (59) hide show
  1. package/lib/ConfiguratorKernel.wasm +0 -0
  2. package/lib/{GaussianBlurNode-Bjszve7N.mjs → GaussianBlurNode-BMH03PYf.mjs} +11 -11
  3. package/lib/{GaussianBlurNode-Bjszve7N.mjs.map → GaussianBlurNode-BMH03PYf.mjs.map} +1 -1
  4. package/lib/RoomleCore.wasm +0 -0
  5. package/lib/RoomleToolsCore.wasm +0 -0
  6. package/lib/{api-C-enDIJZ.mjs → api-hQ0uOklW.mjs} +2 -2
  7. package/lib/{api-C-enDIJZ.mjs.map → api-hQ0uOklW.mjs.map} +1 -1
  8. package/lib/asset-loader.worker-eqHzNAwa.mjs.map +1 -1
  9. package/lib/budgeteer.sw-BUMElkO1.mjs.map +1 -1
  10. package/lib/configurator-BM0nny5l.mjs +2 -0
  11. package/lib/{configurator-D8Bfu2_w.mjs → configurator-CVg8_f9w.mjs} +3 -3
  12. package/lib/{configurator-D8Bfu2_w.mjs.map → configurator-CVg8_f9w.mjs.map} +1 -1
  13. package/lib/{glb-viewer-DMg1tKfk.mjs → glb-viewer-Csx9GwVi.mjs} +3 -3
  14. package/lib/{glb-viewer-DMg1tKfk.mjs.map → glb-viewer-Csx9GwVi.mjs.map} +1 -1
  15. package/lib/glb-viewer-gEdln_PJ.mjs +2 -0
  16. package/lib/{highlight-coordinator-JwAVkMeS.mjs → highlight-coordinator-C-PxNb40.mjs} +12 -12
  17. package/lib/highlight-coordinator-C-PxNb40.mjs.map +1 -0
  18. package/lib/{homag-intelligence-CbzWp4pY.mjs → homag-intelligence-Dh4VWYH6.mjs} +3 -3
  19. package/lib/{homag-intelligence-CbzWp4pY.mjs.map → homag-intelligence-Dh4VWYH6.mjs.map} +1 -1
  20. package/lib/{material-viewer-C4oV4F7e.mjs → material-viewer-DqUJzRXN.mjs} +3 -3
  21. package/lib/{material-viewer-C4oV4F7e.mjs.map → material-viewer-DqUJzRXN.mjs.map} +1 -1
  22. package/lib/{packages-Pc3dsyed.mjs → packages-Bz8iWtUY.mjs} +5 -5
  23. package/lib/{packages-Pc3dsyed.mjs.map → packages-Bz8iWtUY.mjs.map} +1 -1
  24. package/lib/{planner-B3IWgziF.mjs → planner-CpcR6z07.mjs} +3 -3
  25. package/lib/{planner-B3IWgziF.mjs.map → planner-CpcR6z07.mjs.map} +1 -1
  26. package/lib/planner-g06Phdjc.mjs +2 -0
  27. package/lib/roomle-headless.d.ts +4 -0
  28. package/lib/roomle-headless.js +9 -9
  29. package/lib/{roomle-sdk-Be4K-H8u.mjs → roomle-sdk-BCmaueGp.mjs} +1218 -1162
  30. package/lib/roomle-sdk-BCmaueGp.mjs.map +1 -0
  31. package/lib/roomle-sdk.d.ts +4 -0
  32. package/lib/roomle-sdk.js +6 -6
  33. package/lib/{roomle-webgpu-renderer-Lt55gNj5.mjs → roomle-webgpu-renderer-CS0lYZJ4.mjs} +351 -348
  34. package/lib/{roomle-webgpu-renderer-Lt55gNj5.mjs.map → roomle-webgpu-renderer-CS0lYZJ4.mjs.map} +1 -1
  35. package/lib/{scene-renderer-C8Lh-lff.mjs → scene-renderer--WNt8myk.mjs} +27 -23
  36. package/lib/scene-renderer--WNt8myk.mjs.map +1 -0
  37. package/lib/{script-loader-CzikXnNg.mjs → script-loader-Dmcvx-Qu.mjs} +2 -2
  38. package/lib/{script-loader-CzikXnNg.mjs.map → script-loader-Dmcvx-Qu.mjs.map} +1 -1
  39. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/package.json +1 -1
  40. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
  41. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
  42. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
  43. package/lib/{stats-helper-Ddg1O4fO.mjs → stats-helper-B1_lK1E8.mjs} +2 -2
  44. package/lib/{stats-helper-Ddg1O4fO.mjs.map → stats-helper-B1_lK1E8.mjs.map} +1 -1
  45. package/lib/three.tsl-BZfU6fFt.mjs +2 -0
  46. package/lib/{three.tsl-Dew9p5yF.mjs → three.tsl-DO_HZZuJ.mjs} +58 -56
  47. package/lib/{three.tsl-Dew9p5yF.mjs.map → three.tsl-DO_HZZuJ.mjs.map} +1 -1
  48. package/lib/{tools-core-CVdBXX3L.mjs → tools-core-CRWZtE-S.mjs} +3 -3
  49. package/lib/{tools-core-CVdBXX3L.mjs.map → tools-core-CRWZtE-S.mjs.map} +1 -1
  50. package/lib/{webgpu-B0rxiqW-.mjs → webgpu-C14yfIYy.mjs} +86 -86
  51. package/lib/{webgpu-B0rxiqW-.mjs.map → webgpu-C14yfIYy.mjs.map} +1 -1
  52. package/package.json +2 -2
  53. package/lib/configurator-BfdyDYqe.mjs +0 -2
  54. package/lib/glb-viewer-BFYG-bD2.mjs +0 -2
  55. package/lib/highlight-coordinator-JwAVkMeS.mjs.map +0 -1
  56. package/lib/planner-BhnBEaPV.mjs +0 -2
  57. package/lib/roomle-sdk-Be4K-H8u.mjs.map +0 -1
  58. package/lib/scene-renderer-C8Lh-lff.mjs.map +0 -1
  59. package/lib/three.tsl-BnL9nfJa.mjs +0 -2
@@ -1,7 +1,7 @@
1
1
  import { Ar as e, Bt as t, Ci as n, Di as r, E as i, Er as a, Gn as o, Hr as s, Mr as c, On as l, Qr as u, S as d, Si as f, U as p, Ur as m, V as h, Xr as g, Yt as _, Zr as v, ci as y, cn as b, ct as x, f as S, h as C, ht as w, jr as ee, kn as te, kr as ne, ln as re, m as ie, on as ae, qt as T, si as oe, sn as E, ui as D, vi as se, w as ce, wi as le, yn as ue } from "./three.core-0KaTx8dm.mjs";
2
2
  import { t as de } from "./Pass-DLiMLT5k.mjs";
3
3
  import { C as fe, Dt as pe, Fn as me, Gn as he, H as ge, Hn as O, Rn as k, Vn as _e, X as A, ln as ve, vt as ye } from "./three.webgpu-ylONY593.mjs";
4
- import { At as be, Ct as j, Dt as xe, Et as M, I as Se, L as Ce, Pt as we, Rt as Te, Tt as Ee, jt as De, k as Oe, lt as ke, vt as N, w as Ae, wt as je, xt as Me, zt as P } from "./three.tsl-Dew9p5yF.mjs";
4
+ import { A as be, Bt as j, Dt as M, Et as xe, Ft as Se, L as Ce, Mt as we, Ot as Te, R as Ee, St as De, T as Oe, Tt as ke, jt as Ae, ut as je, wt as N, yt as P, zt as Me } from "./three.tsl-DO_HZZuJ.mjs";
5
5
  var Ne = 1.25, Pe = 65535;
6
6
  Pe << 16;
7
7
  var Fe = 2 ** -24, Ie = Symbol("SKIP_GENERATION"), Le = {
@@ -2214,7 +2214,7 @@ var yi = class extends ge {
2214
2214
  for (let t in e) typeof e[t] == "string" && (e[t] = new fi(e[t]));
2215
2215
  }
2216
2216
  return e.call(...t);
2217
- }, e), $ = (e, ...t) => xi(new yi(e, t)), Si = (e, ...t) => new bi(e, t), Ci = Ee(60);
2217
+ }, e), $ = (e, ...t) => xi(new yi(e, t)), Si = (e, ...t) => new bi(e, t), Ci = xe(60);
2218
2218
  //#endregion
2219
2219
  //#region ../../node_modules/three-gpu-pathtracer/src/webgpu/lib/three-mesh-bvh/shapecastFns/getShapecastFn.js
2220
2220
  function wi(e, t) {
@@ -2462,7 +2462,7 @@ var Ti = $`
2462
2462
  //#endregion
2463
2463
  //#region ../../node_modules/three-gpu-pathtracer/src/webgpu/lib/three-mesh-bvh/shapecastFns/getRaycastFirstHitFn.js
2464
2464
  function Oi(e) {
2465
- let { index: t, attributes: n, transforms: r } = e.storage, i = Ae(1).toVar(`bvh_rayScalar_${Math.random().toString(36).substring(2, 7)}`);
2465
+ let { index: t, attributes: n, transforms: r } = e.storage, i = Oe(1).toVar(`bvh_rayScalar_${Math.random().toString(36).substring(2, 7)}`);
2466
2466
  return e.getShapecastFn({
2467
2467
  name: "bvh_RaycastFirstHit",
2468
2468
  shapeStruct: Q,
@@ -2604,7 +2604,7 @@ function ki(e) {
2604
2604
  //#endregion
2605
2605
  //#region ../../node_modules/three-gpu-pathtracer/src/webgpu/lib/three-mesh-bvh/shapecastFns/getClosestPointToPointFn.js
2606
2606
  function Ai(e) {
2607
- let { index: t, attributes: n, transforms: r } = e.storage, i = Ce().toVar("bvh_toWorldMat");
2607
+ let { index: t, attributes: n, transforms: r } = e.storage, i = Ee().toVar("bvh_toWorldMat");
2608
2608
  return e.getShapecastFn({
2609
2609
  name: "bvh_ClosestPointToPoint",
2610
2610
  shapeStruct: "vec3f",
@@ -2786,7 +2786,7 @@ var Fi = class {
2786
2786
  i.forEach((e, t) => {
2787
2787
  Mi.copy(n.matrixWorld).invert(), this.writeTransformData(e, Mi, t, g);
2788
2788
  });
2789
- let _ = N(new me(new Uint32Array(h), 1), Yr).toReadOnly().setName("bvh_nodes"), v = N(new me(new Uint32Array(g), 1), t.transform).toReadOnly().setName("bvh_transforms"), y = N(new me(p, 1), "uint").toReadOnly().setName("bvh_index"), b = N(new me(new Uint32Array(m), l.getLength()), l).toReadOnly().setName("bvh_attributes");
2789
+ let _ = P(new me(new Uint32Array(h), 1), Yr).toReadOnly().setName("bvh_nodes"), v = P(new me(new Uint32Array(g), 1), t.transform).toReadOnly().setName("bvh_transforms"), y = P(new me(p, 1), "uint").toReadOnly().setName("bvh_index"), b = P(new me(new Uint32Array(m), l.getLength()), l).toReadOnly().setName("bvh_attributes");
2790
2790
  this.storage.transforms = v, this.storage.nodes = _, this.storage.index = y, this.storage.attributes = b, this.structs.attributes = l, this.fns.sampleTrianglePoint = ki(this), this._bvhCache.clear();
2791
2791
  }
2792
2792
  writeTransformData(e, t, n, r) {
@@ -2844,7 +2844,7 @@ var Fi = class {
2844
2844
  }
2845
2845
  });
2846
2846
  }
2847
- }, Li = P("\n fn sampleTexel( tex: texture_2d<f32>, coord: vec2f ) -> vec4f {\n\n // Manual bilinear filtering using textureLoad to support filterable float32 textures\n // on all devices\n let size = vec2f( textureDimensions( tex, 0 ) );\n let pxCoord = coord * size - 0.5;\n let px = vec2i( floor( pxCoord ) );\n let fr = fract( pxCoord );\n\n // get the four sibling samples\n let s00 = textureLoad( tex, clamp( px, vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n let s10 = textureLoad( tex, clamp( px + vec2i( 1, 0 ), vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n let s01 = textureLoad( tex, clamp( px + vec2i( 0, 1 ), vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n let s11 = textureLoad( tex, clamp( px + vec2i( 1, 1 ), vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n\n // interpolate on the x axis\n let y0 = mix( s00, s10, fr.x );\n let y1 = mix( s01, s11, fr.x );\n\n // then y\n return mix( y0, y1, fr.y );\n\n }\n"), Ri = class extends ye {
2847
+ }, Li = j("\n fn sampleTexel( tex: texture_2d<f32>, coord: vec2f ) -> vec4f {\n\n // Manual bilinear filtering using textureLoad to support filterable float32 textures\n // on all devices\n let size = vec2f( textureDimensions( tex, 0 ) );\n let pxCoord = coord * size - 0.5;\n let px = vec2i( floor( pxCoord ) );\n let fr = fract( pxCoord );\n\n // get the four sibling samples\n let s00 = textureLoad( tex, clamp( px, vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n let s10 = textureLoad( tex, clamp( px + vec2i( 1, 0 ), vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n let s01 = textureLoad( tex, clamp( px + vec2i( 0, 1 ), vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n let s11 = textureLoad( tex, clamp( px + vec2i( 1, 1 ), vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n\n // interpolate on the x axis\n let y0 = mix( s00, s10, fr.x );\n let y1 = mix( s01, s11, fr.x );\n\n // then y\n return mix( y0, y1, fr.y );\n\n }\n"), Ri = class extends ye {
2848
2848
  get texture() {
2849
2849
  return this._texNode.value;
2850
2850
  }
@@ -2877,13 +2877,13 @@ var Fi = class {
2877
2877
  }
2878
2878
  constructor(e) {
2879
2879
  super();
2880
- let t = Me(new k());
2880
+ let t = De(new k());
2881
2881
  this._texNode = t;
2882
- let n = Me(new k());
2882
+ let n = De(new k());
2883
2883
  this._fromTexNode = n;
2884
- let r = De(be()), i = M(1);
2884
+ let r = we(Ae()), i = M(1);
2885
2885
  this._transitionUniform = i;
2886
- let a = je(0, 1, $`
2886
+ let a = ke(0, 1, $`
2887
2887
  fn fade( uv: vec2f ) -> vec4f {
2888
2888
 
2889
2889
  if ( ${i} <= 0.0 ) {
@@ -2904,7 +2904,7 @@ var Fi = class {
2904
2904
 
2905
2905
  }
2906
2906
  `(r));
2907
- this._toneMapping = a, this.transparent = !0, this.colorNode = we(a.rgb, a.a), this.setValues(e);
2907
+ this._toneMapping = a, this.transparent = !0, this.colorNode = Se(a.rgb, a.a), this.setValues(e);
2908
2908
  }
2909
2909
  }, zi = class {
2910
2910
  get computeNode() {
@@ -2944,13 +2944,13 @@ var Fi = class {
2944
2944
  let [i, a, o] = this.workgroupSize;
2945
2945
  return r.length = 3, r[0] = Math.ceil(e / i), r[1] = Math.ceil(t / a), r[2] = Math.ceil(n / o), r;
2946
2946
  }
2947
- }, Bi = Te("\n\n struct PcgState {\n s0: vec4u,\n s1: vec4u,\n };\n\n var<private> g_state: PcgState;\n");
2948
- P("\n fn pcgInitialize( pixelIndex: u32, pathIndex: u32, bounceIndex: u32 ) -> void {\n let pixel = vec2( ( pixelIndex >> 16 ) & 0xFF, pixelIndex & 0xFF );\n\n //white noise seed\n g_state.s0 = vec4u( pixel | vec2( bounceIndex << 16 ), pathIndex, pixel.x + pixel.y);\n\n //blue noise seed\n g_state.s1 = vec4u(pathIndex, pathIndex*15843, pathIndex*31 + 4566, pathIndex*2345 + 58585);\n\n }\n", [Bi]);
2949
- var Vi = P("\n fn pcg4d(v: ptr<private, vec4u>) -> void {\n *v = *v * 1664525u + 1013904223u;\n *v = *v + v.yzxy * v.wxyz;\n *v = *v ^ (*v >> vec4u(16u));\n *v = *v + v.yzxy * v.wxyz;\n }\n");
2950
- P("\n fn pcgRand( _id: u32 ) -> f32 {\n pcg4d(&g_state.s0);\n return abs( f32( g_state.s0.x ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), P("\n fn pcgRand2( _id: u32 ) -> vec2f {\n pcg4d(&g_state.s0);\n return abs( vec2f( g_state.s0.xy ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), P("\n fn pcgRand3( _id: u32 ) -> vec3f {\n pcg4d(&g_state.s0);\n return abs( vec3f( g_state.s0.xyz ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), P("\n fn pcgRand4( _id: u32 ) -> vec4f {\n pcg4d(&g_state.s0);\n return abs( vec4f( g_state.s0 ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), P("fn noop() -> void {}");
2951
- var Hi = Ee(256 * 256), Ui = Ae(1 / 16777216), Wi = Te("\n\n const SOBOL_DIRECTIONS_1 = array<u32, 32>(\n 0x80000000u, 0xc0000000u, 0xa0000000u, 0xf0000000u,\n 0x88000000u, 0xcc000000u, 0xaa000000u, 0xff000000u,\n 0x80800000u, 0xc0c00000u, 0xa0a00000u, 0xf0f00000u,\n 0x88880000u, 0xcccc0000u, 0xaaaa0000u, 0xffff0000u,\n 0x80008000u, 0xc000c000u, 0xa000a000u, 0xf000f000u,\n 0x88008800u, 0xcc00cc00u, 0xaa00aa00u, 0xff00ff00u,\n 0x80808080u, 0xc0c0c0c0u, 0xa0a0a0a0u, 0xf0f0f0f0u,\n 0x88888888u, 0xccccccccu, 0xaaaaaaaau, 0xffffffffu\n );\n\n const SOBOL_DIRECTIONS_2 = array<u32, 32>(\n 0x80000000u, 0xc0000000u, 0x60000000u, 0x90000000u,\n 0xe8000000u, 0x5c000000u, 0x8e000000u, 0xc5000000u,\n 0x68800000u, 0x9cc00000u, 0xee600000u, 0x55900000u,\n 0x80680000u, 0xc09c0000u, 0x60ee0000u, 0x90550000u,\n 0xe8808000u, 0x5cc0c000u, 0x8e606000u, 0xc5909000u,\n 0x6868e800u, 0x9c9c5c00u, 0xeeee8e00u, 0x5555c500u,\n 0x8000e880u, 0xc0005cc0u, 0x60008e60u, 0x9000c590u,\n 0xe8006868u, 0x5c009c9cu, 0x8e00eeeeu, 0xc5005555u\n );\n\n const SOBOL_DIRECTIONS_3 = array<u32, 32>(\n 0x80000000u, 0xc0000000u, 0x20000000u, 0x50000000u,\n 0xf8000000u, 0x74000000u, 0xa2000000u, 0x93000000u,\n 0xd8800000u, 0x25400000u, 0x59e00000u, 0xe6d00000u,\n 0x78080000u, 0xb40c0000u, 0x82020000u, 0xc3050000u,\n 0x208f8000u, 0x51474000u, 0xfbea2000u, 0x75d93000u,\n 0xa0858800u, 0x914e5400u, 0xdbe79e00u, 0x25db6d00u,\n 0x58800080u, 0xe54000c0u, 0x79e00020u, 0xb6d00050u,\n 0x800800f8u, 0xc00c0074u, 0x200200a2u, 0x50050093u\n );\n\n const SOBOL_DIRECTIONS_4 = array<u32, 32>(\n 0x80000000u, 0x40000000u, 0x20000000u, 0xb0000000u,\n 0xf8000000u, 0xdc000000u, 0x7a000000u, 0x9d000000u,\n 0x5a800000u, 0x2fc00000u, 0xa1600000u, 0xf0b00000u,\n 0xda880000u, 0x6fc40000u, 0x81620000u, 0x40bb0000u,\n 0x22878000u, 0xb3c9c000u, 0xfb65a000u, 0xddb2d000u,\n 0x78022800u, 0x9c0b3c00u, 0x5a0fb600u, 0x2d0ddb00u,\n 0xa2878080u, 0xf3c9c040u, 0xdb65a020u, 0x6db2d0b0u,\n 0x800228f8u, 0x400b3cdcu, 0x200fb67au, 0xb00ddb9du\n );\n\n"), Gi = Ee(0).toVar("sobolPixelIndex"), Ki = Ee(0).toVar("sobolPathIndex"), qi = Ee(0).toVar("sobolBounceIndex"), Ji = P("\n\n fn getMaskedSobol( index: u32, directions: array<u32, 32> ) -> u32 {\n\n var X = 0u;\n for ( var bit = 0u; bit < 32u; bit ++ ) {\n\n let mask = ( index >> bit ) & 1u;\n X ^= mask * directions[ bit ];\n\n }\n return X;\n\n }\n\n"), Yi = (e = 1) => {
2947
+ }, Bi = Me("\n\n struct PcgState {\n s0: vec4u,\n s1: vec4u,\n };\n\n var<private> g_state: PcgState;\n");
2948
+ j("\n fn pcgInitialize( pixelIndex: u32, pathIndex: u32, bounceIndex: u32 ) -> void {\n let pixel = vec2( ( pixelIndex >> 16 ) & 0xFF, pixelIndex & 0xFF );\n\n //white noise seed\n g_state.s0 = vec4u( pixel | vec2( bounceIndex << 16 ), pathIndex, pixel.x + pixel.y);\n\n //blue noise seed\n g_state.s1 = vec4u(pathIndex, pathIndex*15843, pathIndex*31 + 4566, pathIndex*2345 + 58585);\n\n }\n", [Bi]);
2949
+ var Vi = j("\n fn pcg4d(v: ptr<private, vec4u>) -> void {\n *v = *v * 1664525u + 1013904223u;\n *v = *v + v.yzxy * v.wxyz;\n *v = *v ^ (*v >> vec4u(16u));\n *v = *v + v.yzxy * v.wxyz;\n }\n");
2950
+ j("\n fn pcgRand( _id: u32 ) -> f32 {\n pcg4d(&g_state.s0);\n return abs( f32( g_state.s0.x ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), j("\n fn pcgRand2( _id: u32 ) -> vec2f {\n pcg4d(&g_state.s0);\n return abs( vec2f( g_state.s0.xy ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), j("\n fn pcgRand3( _id: u32 ) -> vec3f {\n pcg4d(&g_state.s0);\n return abs( vec3f( g_state.s0.xyz ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), j("\n fn pcgRand4( _id: u32 ) -> vec4f {\n pcg4d(&g_state.s0);\n return abs( vec4f( g_state.s0 ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), j("fn noop() -> void {}");
2951
+ var Hi = xe(256 * 256), Ui = Oe(1 / 16777216), Wi = Me("\n\n const SOBOL_DIRECTIONS_1 = array<u32, 32>(\n 0x80000000u, 0xc0000000u, 0xa0000000u, 0xf0000000u,\n 0x88000000u, 0xcc000000u, 0xaa000000u, 0xff000000u,\n 0x80800000u, 0xc0c00000u, 0xa0a00000u, 0xf0f00000u,\n 0x88880000u, 0xcccc0000u, 0xaaaa0000u, 0xffff0000u,\n 0x80008000u, 0xc000c000u, 0xa000a000u, 0xf000f000u,\n 0x88008800u, 0xcc00cc00u, 0xaa00aa00u, 0xff00ff00u,\n 0x80808080u, 0xc0c0c0c0u, 0xa0a0a0a0u, 0xf0f0f0f0u,\n 0x88888888u, 0xccccccccu, 0xaaaaaaaau, 0xffffffffu\n );\n\n const SOBOL_DIRECTIONS_2 = array<u32, 32>(\n 0x80000000u, 0xc0000000u, 0x60000000u, 0x90000000u,\n 0xe8000000u, 0x5c000000u, 0x8e000000u, 0xc5000000u,\n 0x68800000u, 0x9cc00000u, 0xee600000u, 0x55900000u,\n 0x80680000u, 0xc09c0000u, 0x60ee0000u, 0x90550000u,\n 0xe8808000u, 0x5cc0c000u, 0x8e606000u, 0xc5909000u,\n 0x6868e800u, 0x9c9c5c00u, 0xeeee8e00u, 0x5555c500u,\n 0x8000e880u, 0xc0005cc0u, 0x60008e60u, 0x9000c590u,\n 0xe8006868u, 0x5c009c9cu, 0x8e00eeeeu, 0xc5005555u\n );\n\n const SOBOL_DIRECTIONS_3 = array<u32, 32>(\n 0x80000000u, 0xc0000000u, 0x20000000u, 0x50000000u,\n 0xf8000000u, 0x74000000u, 0xa2000000u, 0x93000000u,\n 0xd8800000u, 0x25400000u, 0x59e00000u, 0xe6d00000u,\n 0x78080000u, 0xb40c0000u, 0x82020000u, 0xc3050000u,\n 0x208f8000u, 0x51474000u, 0xfbea2000u, 0x75d93000u,\n 0xa0858800u, 0x914e5400u, 0xdbe79e00u, 0x25db6d00u,\n 0x58800080u, 0xe54000c0u, 0x79e00020u, 0xb6d00050u,\n 0x800800f8u, 0xc00c0074u, 0x200200a2u, 0x50050093u\n );\n\n const SOBOL_DIRECTIONS_4 = array<u32, 32>(\n 0x80000000u, 0x40000000u, 0x20000000u, 0xb0000000u,\n 0xf8000000u, 0xdc000000u, 0x7a000000u, 0x9d000000u,\n 0x5a800000u, 0x2fc00000u, 0xa1600000u, 0xf0b00000u,\n 0xda880000u, 0x6fc40000u, 0x81620000u, 0x40bb0000u,\n 0x22878000u, 0xb3c9c000u, 0xfb65a000u, 0xddb2d000u,\n 0x78022800u, 0x9c0b3c00u, 0x5a0fb600u, 0x2d0ddb00u,\n 0xa2878080u, 0xf3c9c040u, 0xdb65a020u, 0x6db2d0b0u,\n 0x800228f8u, 0x400b3cdcu, 0x200fb67au, 0xb00ddb9du\n );\n\n"), Gi = xe(0).toVar("sobolPixelIndex"), Ki = xe(0).toVar("sobolPathIndex"), qi = xe(0).toVar("sobolBounceIndex"), Ji = j("\n\n fn getMaskedSobol( index: u32, directions: array<u32, 32> ) -> u32 {\n\n var X = 0u;\n for ( var bit = 0u; bit < 32u; bit ++ ) {\n\n let mask = ( index >> bit ) & 1u;\n X ^= mask * directions[ bit ];\n\n }\n return X;\n\n }\n\n"), Yi = (e = 1) => {
2952
2952
  if (e <= 0) return;
2953
- let t = e > 1 ? `vec${e}u` : "u32", n = P(`
2953
+ let t = e > 1 ? `vec${e}u` : "u32", n = j(`
2954
2954
 
2955
2955
  fn sobolReverseBits_${t}( in: ${t} ) -> ${t} {
2956
2956
 
@@ -2963,7 +2963,7 @@ var Hi = Ee(256 * 256), Ui = Ae(1 / 16777216), Wi = Te("\n\n const SOBOL_DIRECTI
2963
2963
 
2964
2964
  }
2965
2965
 
2966
- `), r = P(`
2966
+ `), r = j(`
2967
2967
 
2968
2968
  fn sobolHashCombine_${t}( seed: u32, v: ${t} ) -> ${t} {
2969
2969
 
@@ -2971,7 +2971,7 @@ var Hi = Ee(256 * 256), Ui = Ae(1 / 16777216), Wi = Te("\n\n const SOBOL_DIRECTI
2971
2971
 
2972
2972
  }
2973
2973
 
2974
- `), i = P(`
2974
+ `), i = j(`
2975
2975
 
2976
2976
  fn sobolLaineKarrasPermutation_${t}( in: ${t}, seed: ${t} ) -> ${t} {
2977
2977
 
@@ -3026,7 +3026,7 @@ var Hi = Ee(256 * 256), Ui = Ae(1 / 16777216), Wi = Te("\n\n const SOBOL_DIRECTI
3026
3026
 
3027
3027
  }
3028
3028
 
3029
- `, Qi = P("\n\n fn sobolHash( in: u32 ) -> u32 {\n\n var x = in;\n // finalizer from murmurhash3\n x ^= x >> 16;\n x *= 0x85ebca6bu;\n x ^= x >> 13;\n x *= 0xc2b2ae35u;\n x ^= x >> 16;\n return x;\n\n }\n\n"), $i = $`
3029
+ `, Qi = j("\n\n fn sobolHash( in: u32 ) -> u32 {\n\n var x = in;\n // finalizer from murmurhash3\n x ^= x >> 16;\n x *= 0x85ebca6bu;\n x ^= x >> 13;\n x *= 0xc2b2ae35u;\n x ^= x >> 16;\n return x;\n\n }\n\n"), $i = $`
3030
3030
 
3031
3031
  fn sobolGetSeed( effect: u32 ) -> u32 {
3032
3032
 
@@ -3085,7 +3085,7 @@ var ra = $`
3085
3085
 
3086
3086
  }
3087
3087
 
3088
- `, aa = Te("\n\n const PI: f32 = 3.141592653589793;\n const EPSILON: f32 = 1e-5;\n const MIN_ROUGHNESS: f32 = 1e-3;\n\n"), oa = new O({
3088
+ `, aa = Me("\n\n const PI: f32 = 3.141592653589793;\n const EPSILON: f32 = 1e-5;\n const MIN_ROUGHNESS: f32 = 1e-3;\n\n"), oa = new O({
3089
3089
  color: "vec3f",
3090
3090
  specularPdf: "float",
3091
3091
  direction: "vec3f",
@@ -3203,7 +3203,7 @@ var ra = $`
3203
3203
  VdotNc: "float",
3204
3204
  LdotNc: "float",
3205
3205
  HdotNc: "float"
3206
- }, "BxDFContext"), fa = P("\n\n fn inverse(m: mat3x3f) -> mat3x3f {\n var adj: mat3x3f;\n adj[0][0] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]);\n adj[1][0] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]);\n adj[2][0] = (m[1][0] * m[2][1] - m[2][0] * m[1][1]);\n adj[0][1] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]);\n adj[1][1] = (m[0][0] * m[2][2] - m[2][0] * m[0][2]);\n adj[2][1] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]);\n adj[0][2] = (m[0][1] * m[1][2] - m[1][1] * m[0][2]);\n adj[1][2] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]);\n adj[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]);\n\n let det = ( m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])\n - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])\n + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]));\n\n return adj * ( 1.0 / det );\n }\n\n"), pa = P("\n\n fn getBasisFromNormal( normal: vec3f ) -> mat3x3f {\n\n var other: vec3f;\n if ( abs( normal.x ) > 0.5 ) {\n\n other = vec3f( 0.0, 1.0, 0.0 );\n\n } else {\n\n other = vec3f( 1.0, 0.0, 0.0 );\n\n }\n\n let ortho = normalize( cross( normal, other ) );\n let ortho2 = normalize( cross( normal, ortho ) );\n return mat3x3f( ortho2, ortho, normal );\n\n }\n\n"), ma = P("\n\n fn iorToF0( ior: f32 ) -> f32 {\n return pow( ( 1 - ior ) / ( 1 + ior ), 2 );\n }\n\n"), ha = P("\n\n fn iorToF0General( transmittedIor: f32, incidentIor: f32 ) -> f32 {\n\n return pow( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ), 2 );\n\n }\n\n"), ga = P("\n\n fn iorToF0GeneralVec( transmittedIor: vec3f, incidentIor: vec3f ) -> vec3f {\n\n let v = ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor );\n return v * v;\n\n }\n\n"), _a = P("\n\n fn fresnel0ToIor( f0: vec3f ) -> vec3f {\n\n let sqrtF0 = sqrt( f0 );\n return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\n }\n\n"), va = P("\n\n fn schlickFresnel( cosine: f32, f0: f32 ) -> f32 {\n\n return f0 + ( 1.0 - f0 ) * pow( 1.0 - cosine, 5.0 );\n\n }\n\n"), ya = P("\n\n fn schlickFresnelVec( cosine: f32, f0: vec3f, f90: vec3f ) -> vec3f {\n\n return f0 + ( f90 - f0 ) * pow( 1.0 - cosine, 5.0 );\n\n }\n\n"), ba = P("\n\n fn evaluateFresnel( cosine: f32, eta: f32, f0: vec3f, f90: vec3f ) -> vec3f {\n\n if ( totalInternalReflection( cosine, eta ) ) {\n\n return f90;\n\n }\n\n return f0 + ( f90 - f0 ) * pow( 1.0 - cosine, 5.0 );\n }\n\n", [P("\n\n fn totalInternalReflection( cosTheta: f32, eta: f32 ) -> bool {\n\n let sinTheta = sqrt( 1.0 - cosTheta * cosTheta );\n return eta * sinTheta > 1.0;\n\n }\n\n")]), xa = P("\n\n fn isTerminatingScatter( scatterRec: ScatterRecord ) -> bool {\n return scatterRec.pdf <= 0;\n }\n\n", [oa]), Sa = P("\n\n fn applyWrap( v: f32, wrapMode: i32 ) -> f32 {\n\n var res = v;\n if ( wrapMode == 1 ) {\n\n // ClampToEdge\n res = clamp( res, 0.0, 1.0 );\n\n } else if ( wrapMode == 2 ) {\n\n // MirroredRepeat\n res = 1.0 - abs( 2.0 * fract( res * 0.5 ) - 1.0 );\n\n } else {\n\n // Repeat\n res = fract( res );\n\n }\n\n return res;\n\n }\n\n"), Ca = (e, t, n) => $`
3206
+ }, "BxDFContext"), fa = j("\n\n fn inverse(m: mat3x3f) -> mat3x3f {\n var adj: mat3x3f;\n adj[0][0] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]);\n adj[1][0] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]);\n adj[2][0] = (m[1][0] * m[2][1] - m[2][0] * m[1][1]);\n adj[0][1] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]);\n adj[1][1] = (m[0][0] * m[2][2] - m[2][0] * m[0][2]);\n adj[2][1] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]);\n adj[0][2] = (m[0][1] * m[1][2] - m[1][1] * m[0][2]);\n adj[1][2] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]);\n adj[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]);\n\n let det = ( m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])\n - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])\n + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]));\n\n return adj * ( 1.0 / det );\n }\n\n"), pa = j("\n\n fn getBasisFromNormal( normal: vec3f ) -> mat3x3f {\n\n var other: vec3f;\n if ( abs( normal.x ) > 0.5 ) {\n\n other = vec3f( 0.0, 1.0, 0.0 );\n\n } else {\n\n other = vec3f( 1.0, 0.0, 0.0 );\n\n }\n\n let ortho = normalize( cross( normal, other ) );\n let ortho2 = normalize( cross( normal, ortho ) );\n return mat3x3f( ortho2, ortho, normal );\n\n }\n\n"), ma = j("\n\n fn iorToF0( ior: f32 ) -> f32 {\n return pow( ( 1 - ior ) / ( 1 + ior ), 2 );\n }\n\n"), ha = j("\n\n fn iorToF0General( transmittedIor: f32, incidentIor: f32 ) -> f32 {\n\n return pow( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ), 2 );\n\n }\n\n"), ga = j("\n\n fn iorToF0GeneralVec( transmittedIor: vec3f, incidentIor: vec3f ) -> vec3f {\n\n let v = ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor );\n return v * v;\n\n }\n\n"), _a = j("\n\n fn fresnel0ToIor( f0: vec3f ) -> vec3f {\n\n let sqrtF0 = sqrt( f0 );\n return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\n }\n\n"), va = j("\n\n fn schlickFresnel( cosine: f32, f0: f32 ) -> f32 {\n\n return f0 + ( 1.0 - f0 ) * pow( 1.0 - cosine, 5.0 );\n\n }\n\n"), ya = j("\n\n fn schlickFresnelVec( cosine: f32, f0: vec3f, f90: vec3f ) -> vec3f {\n\n return f0 + ( f90 - f0 ) * pow( 1.0 - cosine, 5.0 );\n\n }\n\n"), ba = j("\n\n fn evaluateFresnel( cosine: f32, eta: f32, f0: vec3f, f90: vec3f ) -> vec3f {\n\n if ( totalInternalReflection( cosine, eta ) ) {\n\n return f90;\n\n }\n\n return f0 + ( f90 - f0 ) * pow( 1.0 - cosine, 5.0 );\n }\n\n", [j("\n\n fn totalInternalReflection( cosTheta: f32, eta: f32 ) -> bool {\n\n let sinTheta = sqrt( 1.0 - cosTheta * cosTheta );\n return eta * sinTheta > 1.0;\n\n }\n\n")]), xa = j("\n\n fn isTerminatingScatter( scatterRec: ScatterRecord ) -> bool {\n return scatterRec.pdf <= 0;\n }\n\n", [oa]), Sa = j("\n\n fn applyWrap( v: f32, wrapMode: i32 ) -> f32 {\n\n var res = v;\n if ( wrapMode == 1 ) {\n\n // ClampToEdge\n res = clamp( res, 0.0, 1.0 );\n\n } else if ( wrapMode == 2 ) {\n\n // MirroredRepeat\n res = 1.0 - abs( 2.0 * fract( res * 0.5 ) - 1.0 );\n\n } else {\n\n // Repeat\n res = fract( res );\n\n }\n\n return res;\n\n }\n\n"), Ca = (e, t, n) => $`
3207
3207
 
3208
3208
  fn sampleTexel( uv: vec2f, packed: i32, lod: f32 ) -> vec4f {
3209
3209
 
@@ -3247,42 +3247,42 @@ var ra = $`
3247
3247
  }
3248
3248
 
3249
3249
  }
3250
- `, wa = P("\n\n fn diffuseDirection( wo: vec3f, uv: vec2f ) -> vec3f {\n\n var lightDirection = sampleSphere( uv );\n lightDirection.z += 1.0;\n lightDirection = normalize( lightDirection );\n\n return lightDirection;\n\n }\n\n", [P("\n\n fn sampleSphere( uv: vec2f ) -> vec3f {\n\n let u = ( uv.x - 0.5 ) * 2.0;\n let t = uv.y * PI * 2.0;\n let f = sqrt( 1.0 - u * u );\n\n return vec3f( f * cos( t ), f * sin( t ), u );\n\n }\n\n", [aa])]), Ta = P("\n\n fn getLobeWeights(wo: vec3f, woClearcoat: vec3f, wh: vec3f, clearcoatIor: f32, surf: SurfaceRecord) -> LobeWeights {\n\n // TODO: experiment with this; I don't see any usage of normal?\n let metalness = surf.metalness;\n let transmission = surf.transmission;\n let HdotL = dot( wh, wo );\n let fEstimate = evaluateFresnel( HdotL, surf.eta, vec3f( surf.f0 ), vec3f( 1.0 ) ).x;\n\n let transSpecularProb = mix( max( 0.25, fEstimate ), 1.0, metalness );\n let diffSpecularProb = 0.5 + 0.5 * metalness;\n\n var weights: LobeWeights;\n weights.diffuse = ( 1.0 - transmission ) * ( 1.0 - diffSpecularProb );\n weights.specular = transmission * transSpecularProb + ( 1.0 - transmission ) * diffSpecularProb;\n\n let clearcoatF0 = iorToF0( clearcoatIor );\n let clearcoatFresnel = schlickFresnel( saturate( woClearcoat.z ), clearcoatF0 );\n weights.clearcoat = surf.clearcoat * clearcoatFresnel;\n\n weights.transmission = transmission * ( 1.0 - transSpecularProb );\n\n let totalWeight = weights.diffuse + weights.specular;\n if ( totalWeight > 0 ) {\n weights.diffuse = ( weights.diffuse / totalWeight ) * ( 1 - weights.clearcoat );\n weights.specular = ( weights.specular / totalWeight ) * ( 1 - weights.clearcoat );\n }\n // weights.transmission /= totalWeight;\n\n return weights;\n\n }\n\n", [
3250
+ `, wa = j("\n\n fn diffuseDirection( wo: vec3f, uv: vec2f ) -> vec3f {\n\n var lightDirection = sampleSphere( uv );\n lightDirection.z += 1.0;\n lightDirection = normalize( lightDirection );\n\n return lightDirection;\n\n }\n\n", [j("\n\n fn sampleSphere( uv: vec2f ) -> vec3f {\n\n let u = ( uv.x - 0.5 ) * 2.0;\n let t = uv.y * PI * 2.0;\n let f = sqrt( 1.0 - u * u );\n\n return vec3f( f * cos( t ), f * sin( t ), u );\n\n }\n\n", [aa])]), Ta = j("\n\n fn getLobeWeights(wo: vec3f, woClearcoat: vec3f, wh: vec3f, clearcoatIor: f32, surf: SurfaceRecord) -> LobeWeights {\n\n // TODO: experiment with this; I don't see any usage of normal?\n let metalness = surf.metalness;\n let transmission = surf.transmission;\n let HdotL = dot( wh, wo );\n let fEstimate = evaluateFresnel( HdotL, surf.eta, vec3f( surf.f0 ), vec3f( 1.0 ) ).x;\n\n let transSpecularProb = mix( max( 0.25, fEstimate ), 1.0, metalness );\n let diffSpecularProb = 0.5 + 0.5 * metalness;\n\n var weights: LobeWeights;\n weights.diffuse = ( 1.0 - transmission ) * ( 1.0 - diffSpecularProb );\n weights.specular = transmission * transSpecularProb + ( 1.0 - transmission ) * diffSpecularProb;\n\n let clearcoatF0 = iorToF0( clearcoatIor );\n let clearcoatFresnel = schlickFresnel( saturate( woClearcoat.z ), clearcoatF0 );\n weights.clearcoat = surf.clearcoat * clearcoatFresnel;\n\n weights.transmission = transmission * ( 1.0 - transSpecularProb );\n\n let totalWeight = weights.diffuse + weights.specular;\n if ( totalWeight > 0 ) {\n weights.diffuse = ( weights.diffuse / totalWeight ) * ( 1 - weights.clearcoat );\n weights.specular = ( weights.specular / totalWeight ) * ( 1 - weights.clearcoat );\n }\n // weights.transmission /= totalWeight;\n\n return weights;\n\n }\n\n", [
3251
3251
  va,
3252
3252
  ma,
3253
3253
  ba,
3254
3254
  ua,
3255
3255
  aa
3256
- ]), Ea = P("\n\n fn sampleEnvironment(\n envMap: texture_2d<f32>,\n envMapSampler: sampler,\n env: EnvironmentInfo,\n direction: vec3f,\n uv: vec2f,\n ) -> vec4f {\n\n let offsetDir = sampleHemisphere( direction, uv ) * 0.5 * env.blur;\n let sampleDir = normalize( env.rotation * direction + offsetDir );\n let col = sampleEquirectColor( envMap, envMapSampler, sampleDir );\n\n return vec4f( env.intensity * col.rgb, col.a );\n\n }\n\n", [
3257
- P("\n\n fn sampleEquirectColor( envMap: texture_2d<f32>, envMapSampler: sampler, direction: vec3f ) -> vec4f {\n\n return textureSampleLevel( envMap, envMapSampler, equirectDirectionToUv( direction ), 0 );\n\n }\n\n", [P("\n\n fn equirectDirectionToUv(direction: vec3f) -> vec2f {\n\n // from Spherical.setFromCartesianCoords\n var uv = vec2f( atan2( direction.z, direction.x ), acos( direction.y ) );\n uv /= vec2f( 2.0 * PI, PI );\n\n // apply adjustments to get values in range [0, 1] and y right side up\n uv.x += 0.5;\n uv.y = 1.0 - uv.y;\n return uv;\n\n }\n\n")]),
3258
- P("\n\n fn sampleHemisphere( n: vec3f, uv: vec2f ) -> vec3f {\n\n // https://www.rorydriscoll.com/2009/01/07/better-sampling/\n // https://graphics.pixar.com/library/OrthonormalB/paper.pdf\n let sign = select( sign( n.z ), 1.0, n.z == 0.0 );\n let a = - 1.0 / ( sign + n.z );\n let b = n.x * n.y * a;\n let b1 = vec3( 1.0 + sign * n.x * n.x * a, sign * b, - sign * n.x );\n let b2 = vec3( b, sign + n.y * n.y * a, - n.y );\n\n let r = sqrt( uv.x );\n let theta = 2.0 * PI * uv.y;\n let x = r * cos( theta );\n let y = r * sin( theta );\n return x * b1 + y * b2 + sqrt( 1.0 - uv.x ) * n;\n\n }\n\n", [aa]),
3256
+ ]), Ea = j("\n\n fn sampleEnvironment(\n envMap: texture_2d<f32>,\n envMapSampler: sampler,\n env: EnvironmentInfo,\n direction: vec3f,\n uv: vec2f,\n ) -> vec4f {\n\n let offsetDir = sampleHemisphere( direction, uv ) * 0.5 * env.blur;\n let sampleDir = normalize( env.rotation * direction + offsetDir );\n let col = sampleEquirectColor( envMap, envMapSampler, sampleDir );\n\n return vec4f( env.intensity * col.rgb, col.a );\n\n }\n\n", [
3257
+ j("\n\n fn sampleEquirectColor( envMap: texture_2d<f32>, envMapSampler: sampler, direction: vec3f ) -> vec4f {\n\n return textureSampleLevel( envMap, envMapSampler, equirectDirectionToUv( direction ), 0 );\n\n }\n\n", [j("\n\n fn equirectDirectionToUv(direction: vec3f) -> vec2f {\n\n // from Spherical.setFromCartesianCoords\n var uv = vec2f( atan2( direction.z, direction.x ), acos( direction.y ) );\n uv /= vec2f( 2.0 * PI, PI );\n\n // apply adjustments to get values in range [0, 1] and y right side up\n uv.x += 0.5;\n uv.y = 1.0 - uv.y;\n return uv;\n\n }\n\n")]),
3258
+ j("\n\n fn sampleHemisphere( n: vec3f, uv: vec2f ) -> vec3f {\n\n // https://www.rorydriscoll.com/2009/01/07/better-sampling/\n // https://graphics.pixar.com/library/OrthonormalB/paper.pdf\n let sign = select( sign( n.z ), 1.0, n.z == 0.0 );\n let a = - 1.0 / ( sign + n.z );\n let b = n.x * n.y * a;\n let b1 = vec3( 1.0 + sign * n.x * n.x * a, sign * b, - sign * n.x );\n let b2 = vec3( b, sign + n.y * n.y * a, - n.y );\n\n let r = sqrt( uv.x );\n let theta = 2.0 * PI * uv.y;\n let x = r * cos( theta );\n let y = r * sin( theta );\n return x * b1 + y * b2 + sqrt( 1.0 - uv.x ) * n;\n\n }\n\n", [aa]),
3259
3259
  la
3260
- ]), Da = P("\n\n fn weightedAlphaBlend( prevColor: vec4f, newColor: vec4f, weight: f32 ) -> vec4f {\n\n let invWeight = 1.0 - weight;\n let totalAlpha = prevColor.a * invWeight + newColor.a * weight;\n var blendedColor = vec4f( 0 );\n if ( totalAlpha != 0.0 ) {\n\n let prevContrib = prevColor.rgb * invWeight * prevColor.a / totalAlpha;\n let resContrib = newColor.rgb * weight * newColor.a / totalAlpha;\n blendedColor = vec4f( prevContrib + resContrib, totalAlpha );\n\n }\n\n return blendedColor;\n\n }\n\n"), Oa = class extends zi {
3260
+ ]), Da = j("\n\n fn weightedAlphaBlend( prevColor: vec4f, newColor: vec4f, weight: f32 ) -> vec4f {\n\n let invWeight = 1.0 - weight;\n let totalAlpha = prevColor.a * invWeight + newColor.a * weight;\n var blendedColor = vec4f( 0 );\n if ( totalAlpha != 0.0 ) {\n\n let prevContrib = prevColor.rgb * invWeight * prevColor.a / totalAlpha;\n let resContrib = newColor.rgb * weight * newColor.a / totalAlpha;\n blendedColor = vec4f( prevContrib + resContrib, totalAlpha );\n\n }\n\n return blendedColor;\n\n }\n\n"), Oa = class extends zi {
3261
3261
  constructor() {
3262
3262
  let e = {
3263
3263
  bvhData: { value: null },
3264
3264
  material: { value: null },
3265
- prevOutputTarget: j(new k(1, 1)).toReadOnly(),
3266
- outputTarget: j(new k(1, 1)).toWriteOnly(),
3267
- sampleCountTarget: j(new k(1, 1)).toReadWrite(),
3265
+ prevOutputTarget: N(new k(1, 1)).toReadOnly(),
3266
+ outputTarget: N(new k(1, 1)).toWriteOnly(),
3267
+ sampleCountTarget: N(new k(1, 1)).toReadWrite(),
3268
3268
  offset: M(new f()),
3269
3269
  tileSize: M(new f()),
3270
3270
  seed: M(0),
3271
3271
  bounces: M(5),
3272
3272
  inverseProjectionMatrix: M(new E()),
3273
3273
  cameraToModelMatrix: M(new E()),
3274
- envMap: Me(new h()),
3275
- envMapSampler: ke(new h()),
3274
+ envMap: De(new h()),
3275
+ envMapSampler: je(new h()),
3276
3276
  envMapRotation: M(new ae()),
3277
3277
  envMapIntensity: M(1),
3278
- background: Me(new h()),
3279
- backgroundSampler: ke(new h()),
3278
+ background: De(new h()),
3279
+ backgroundSampler: je(new h()),
3280
3280
  backgroundRotation: M(new ae()),
3281
3281
  backgroundIntensity: M(1),
3282
3282
  backgroundBlurriness: M(0),
3283
- textures: Me(new h()),
3284
- textureSampler: ke(new h()),
3285
- globalId: Oe
3283
+ textures: De(new h()),
3284
+ textureSampler: je(new h()),
3285
+ globalId: be
3286
3286
  }, t = ni("bvhData.value.fns.raycastFirstHit.outputType", e), n = ri("bvhData.value.fns.raycastFirstHit", e), r = ri("bvhData.value.fns.sampleTrianglePoint", e), i = ri("bvhData.value.fns.getSurfaceRecord", e), a = ri("material.value.bsdfSample", e), o = $`
3287
3287
 
3288
3288
  fn compute(
@@ -3532,8 +3532,8 @@ var Na = class {
3532
3532
  }, Pa = class extends zi {
3533
3533
  constructor() {
3534
3534
  let e = {
3535
- globalId: Oe,
3536
- outputTarget: j(new k(1, 1)).toWriteOnly()
3535
+ globalId: be,
3536
+ outputTarget: N(new k(1, 1)).toWriteOnly()
3537
3537
  }, t = $`
3538
3538
  fn compute( globalId: vec3u ) -> void {
3539
3539
 
@@ -3639,10 +3639,10 @@ var Na = class {
3639
3639
  tileSize: M(new f()),
3640
3640
  tileCount: M(new f()),
3641
3641
  tileOffset: M(1),
3642
- rayQueue: N(new A(1, La.getLength()), La).toReadOnly(),
3643
- queueSizes: N(new A(4, 1), "u32"),
3644
- outputTileIndex: N(new A(2, 1), "u32").setName("outputTileIndex"),
3645
- outputDispatch: N(new A(3, 1), "u32").setName("outputDispatch")
3642
+ rayQueue: P(new A(1, La.getLength()), La).toReadOnly(),
3643
+ queueSizes: P(new A(4, 1), "u32"),
3644
+ outputTileIndex: P(new A(2, 1), "u32").setName("outputTileIndex"),
3645
+ outputDispatch: P(new A(3, 1), "u32").setName("outputDispatch")
3646
3646
  }, t = $`
3647
3647
  fn compute(
3648
3648
  rayWorkGroupSize: vec3u,
@@ -3713,12 +3713,12 @@ var Na = class {
3713
3713
  cameraToModelMatrix: M(new E()),
3714
3714
  inverseProjectionMatrix: M(new E()),
3715
3715
  seed: M(0),
3716
- tileIndexBuffer: N(new A(2, 1), "u32"),
3716
+ tileIndexBuffer: P(new A(2, 1), "u32"),
3717
3717
  tileSize: M(new f()),
3718
- rayQueue: N(new A(1, La.getLength()), La),
3719
- queueSizes: N(new A(4, 1), "u32").toAtomic(),
3720
- sampleCountTarget: j(new k()).toReadWrite(),
3721
- globalId: Oe
3718
+ rayQueue: P(new A(1, La.getLength()), La),
3719
+ queueSizes: P(new A(4, 1), "u32").toAtomic(),
3720
+ sampleCountTarget: N(new k()).toReadWrite(),
3721
+ globalId: be
3722
3722
  }, t = $`
3723
3723
  fn compute(
3724
3724
  cameraToModelMatrix: mat4x4f,
@@ -3798,22 +3798,22 @@ var Na = class {
3798
3798
  constructor() {
3799
3799
  let e = {
3800
3800
  bvhData: { value: null },
3801
- prevOutputTarget: j(new k(1, 1)).toReadOnly(),
3802
- outputTarget: j(new k(1, 1)).toWriteOnly(),
3803
- sampleCountTarget: j(new k(1, 1)).toReadWrite(),
3804
- rayQueue: N(new A(1, La.getLength()), La).toReadOnly(),
3805
- hitQueue: N(new A(1, Ra.getLength()), Ra),
3806
- queueSizes: N(new A(4, 1), "u32").toAtomic(),
3807
- envMap: Me(new h()),
3808
- envMapSampler: ke(new h()),
3801
+ prevOutputTarget: N(new k(1, 1)).toReadOnly(),
3802
+ outputTarget: N(new k(1, 1)).toWriteOnly(),
3803
+ sampleCountTarget: N(new k(1, 1)).toReadWrite(),
3804
+ rayQueue: P(new A(1, La.getLength()), La).toReadOnly(),
3805
+ hitQueue: P(new A(1, Ra.getLength()), Ra),
3806
+ queueSizes: P(new A(4, 1), "u32").toAtomic(),
3807
+ envMap: De(new h()),
3808
+ envMapSampler: je(new h()),
3809
3809
  envMapRotation: M(new ae()),
3810
3810
  envMapIntensity: M(1),
3811
- background: Me(new h()),
3812
- backgroundSampler: ke(new h()),
3811
+ background: De(new h()),
3812
+ backgroundSampler: je(new h()),
3813
3813
  backgroundRotation: M(new ae()),
3814
3814
  backgroundIntensity: M(1),
3815
3815
  backgroundBlurriness: M(0),
3816
- globalId: Oe
3816
+ globalId: be
3817
3817
  }, t = ni("bvhData.value.fns.raycastFirstHit.outputType", e), n = ni("bvhData.value.fns.raycastFirstHit", e), r = $`
3818
3818
 
3819
3819
  fn compute(
@@ -3915,7 +3915,7 @@ var Na = class {
3915
3915
  constructor() {
3916
3916
  let e = {
3917
3917
  processed: M(0),
3918
- queueSizes: N(new A(4, 1), "u32")
3918
+ queueSizes: P(new A(4, 1), "u32")
3919
3919
  }, t = $`
3920
3920
  fn compute( processed: u32 ) -> void {
3921
3921
 
@@ -3938,8 +3938,8 @@ var Na = class {
3938
3938
  }, Ua = class extends zi {
3939
3939
  constructor(e = {}) {
3940
3940
  let { type: t = "u32" } = e, n = {
3941
- globalId: Oe,
3942
- outputTarget: N(new A(1, 1), t)
3941
+ globalId: be,
3942
+ outputTarget: P(new A(1, 1), t)
3943
3943
  }, r = $`
3944
3944
  fn compute( globalId: vec3u ) -> void {
3945
3945
 
@@ -3954,17 +3954,17 @@ var Na = class {
3954
3954
  let e = {
3955
3955
  bvhData: { value: null },
3956
3956
  material: { value: null },
3957
- prevOutputTarget: j(new k(1, 1)).toReadOnly(),
3958
- outputTarget: j(new k(1, 1)).toWriteOnly(),
3959
- sampleCountTarget: j(new k(1, 1)).toReadWrite(),
3957
+ prevOutputTarget: N(new k(1, 1)).toReadOnly(),
3958
+ outputTarget: N(new k(1, 1)).toWriteOnly(),
3959
+ sampleCountTarget: N(new k(1, 1)).toReadWrite(),
3960
3960
  smoothNormals: M(1),
3961
3961
  bounces: M(1),
3962
- rayQueue: N(new A(1, La.getLength()), La),
3963
- hitQueue: N(new A(1, Ra.getLength()), Ra),
3964
- queueSizes: N(new A(4, 1), "u32").toAtomic(),
3965
- textures: Me(new h()),
3966
- textureSampler: ke(new h()),
3967
- globalId: Oe
3962
+ rayQueue: P(new A(1, La.getLength()), La),
3963
+ hitQueue: P(new A(1, Ra.getLength()), Ra),
3964
+ queueSizes: P(new A(4, 1), "u32").toAtomic(),
3965
+ textures: De(new h()),
3966
+ textureSampler: je(new h()),
3967
+ globalId: be
3968
3968
  }, t = ri("bvhData.value.fns.sampleTrianglePoint", e), n = ri("bvhData.value.fns.getSurfaceRecord", e), r = ri("material.value.bsdfSample", e), i = $`
3969
3969
 
3970
3970
  fn compute(
@@ -4162,18 +4162,18 @@ function $a(e) {
4162
4162
  }
4163
4163
  //#endregion
4164
4164
  //#region ../../node_modules/three-gpu-pathtracer/src/webgpu/nodes/ggx.wgsl.js
4165
- var eo = P("\n\n fn ggxDirection( incidentDir: vec3f, alpha: vec2f, uv: vec2f ) -> vec3f {\n\n // Implementation from reference [1]\n // stretch view\n let V = normalize( vec3f( alpha * incidentDir.xy, incidentDir.z ) );\n\n // orthonormal basis\n var T1: vec3f;\n if ( V.z < 0.9999 ) {\n T1 = normalize( cross( V, vec3( 0.0, 0.0, 1.0 ) ) );\n } else {\n T1 = vec3( 1.0, 0.0, 0.0 );\n }\n\n let T2 = cross( T1, V );\n\n // sample point with polar coordinates (r, phi)\n let a = 1.0 / ( 1.0 + V.z );\n let r = sqrt( uv.x );\n var phi: f32;\n if ( uv.y < a ) {\n phi = uv.y / a * PI;\n } else {\n phi = PI + ( uv.y - a ) / ( 1.0 - a ) * PI;\n }\n let P1 = r * cos( phi );\n var P2 = r * sin( phi );\n if ( uv.y >= a ) {\n P2 *= V.z;\n }\n\n // compute normal\n var N = P1 * T1 + P2 * T2 + V * sqrt( max( 0.0, 1.0 - P1 * P1 - P2 * P2 ) );\n\n // unstretch\n N = normalize( vec3( alpha * N.xy, max( 0.0, N.z ) ) );\n\n return N;\n\n }\n\n", [aa]), to = P("\n\n fn ggxLamda( theta: f32, alpha: f32 ) -> f32 {\n\n let tanTheta = tan( theta );\n let tanTheta2 = tanTheta * tanTheta;\n let alpha2 = alpha * alpha;\n\n let numerator = - 1.0 + sqrt( 1.0 + alpha2 * tanTheta2 );\n return numerator / 2.0;\n\n }\n\n"), no = P("\n\n fn ggxShadowMaskG1( cosTheta: f32, alpha: f32 ) -> f32 {\n\n let a2 = alpha * alpha;\n let cosTheta2 = cosTheta * cosTheta;\n let denom = cosTheta + sqrt( cosTheta2 * ( 1 - a2 ) + a2 );\n return 2.0 * cosTheta / denom;\n\n }\n\n", [to]), ro = P("\n\n fn ggxSmithVisibility( NdotV: f32, NdotL: f32, alpha: f32 ) -> f32 {\n\n // Original formulation of G_SmithGGX Correlated\n // lambda_v = ( -1 + sqrt ( alphaG2 * (1 - NdotL2 ) / NdotL2 + 1)) * 0.5 f;\n // lambda_l = ( -1 + sqrt ( alphaG2 * (1 - NdotV2 ) / NdotV2 + 1)) * 0.5 f;\n // G_SmithGGXCorrelated = 1 / (1 + lambda_v + lambda_l );\n // V_SmithGGXCorrelated = G_SmithGGXCorrelated / (4.0 f * NdotL * NdotV );\n\n // This is an optimized version\n let alpha2 = alpha * alpha;\n // Caution: the \"NdotL *\" and \"NdotV *\" are explicitely inversed , this is not a mistake.\n let Lambda_GGXV = NdotL * sqrt (( - NdotV * alpha2 + NdotV ) * NdotV + alpha2 );\n let Lambda_GGXL = NdotV * sqrt (( - NdotL * alpha2 + NdotL ) * NdotL + alpha2 );\n\n return 0.5 / ( Lambda_GGXV + Lambda_GGXL );\n\n }\n\n", [to]), io = P("\n fn ggxDistribution( NdotH: f32, alpha: f32 ) -> f32 {\n\n let a2 = max( alpha * alpha, EPSILON );\n let denom = NdotH * NdotH * ( a2 - 1 ) + 1;\n\n return ( a2 / ( PI * denom * denom ) );\n\n }\n"), ao = P("\n fn ggxReflectionAdjustedPDF( NdotV: f32, NdotH: f32, alpha: f32 ) -> f32 {\n\n let D = ggxDistribution( NdotH, alpha );\n let G1 = ggxShadowMaskG1( NdotV, alpha );\n\n return D * G1 / ( 4 * NdotV );\n\n }\n", [io, no]), oo = (e) => P("\n\n fn getSurfaceRecord(\n material: Material,\n vertexData: bvh_GeometryStruct,\n side: f32,\n faceNormal: vec3f,\n ) -> SurfaceRecord {\n let uv = vertexData.uv.xy;\n\n var normal = faceNormal * side;\n if ( material.flatShading == 0 ) {\n\n normal = vertexData.normal.xyz;\n\n }\n normal = normalize( normal );\n let baseNormal = normal;\n\n if ( material.normalMap != -1 ) {\n\n // some provided tangents can be malformed (0, 0, 0) causing the normal to be degenerate\n // resulting in NaNs and slow path tracing.\n if ( length( vertexData.tangent.xyz ) > 0.0 && vertexData.tangent.w != 0.0 ) {\n\n let tangent = normalize( vertexData.tangent.xyz );\n let bitangent = normalize( cross( baseNormal, tangent ) * vertexData.tangent.w );\n let vTBN = mat3x3f( tangent, bitangent, baseNormal );\n\n let uvPrime = material.normalMapTransform * vec3( uv, 1.0 );\n var texNormal = sampleTexel( uvPrime.xy, material.normalMap, 0 ).xyz;\n texNormal = texNormal * 2.0 - 1.0;\n texNormal = texNormal * vec3f( material.normalScale, 1.0 );\n normal = normalize( vTBN * texNormal );\n\n }\n\n }\n\n normal *= side;\n\n var albedo = vec4( material.color, material.opacity );\n\n if ( material.vertexColors == 1 ) {\n\n let vertexColor = vertexData.color.xyz;\n albedo *= vec4f( vertexColor, 1.0 );\n\n }\n\n if ( material.map != -1 ) {\n\n let uvPrime = material.mapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.map, 0 );\n albedo *= vec4f( texColor.rgb, 1.0 );\n\n }\n\n var roughness = material.roughness;\n if ( material.roughnessMap != -1 ) {\n\n let uvPrime = material.roughnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.roughnessMap, 0 );\n roughness *= texColor.g;\n\n }\n\n var metalness = material.metalness;\n if ( material.metalnessMap != -1 ) {\n\n let uvPrime = material.metalnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.metalnessMap, 0 );\n metalness *= texColor.b;\n\n }\n\n var emission = material.emissiveIntensity * material.emissive;\n if ( material.emissiveMap != -1 ) {\n\n let uvPrime = material.emissiveMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.emissiveMap, 0 );\n emission *= texColor.rgb;\n\n }\n\n var transmission = material.transmission;\n if ( material.transmissionMap != -1 ) {\n\n let uvPrime = material.transmissionMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.transmissionMap, 0 );\n transmission *= texColor.r;\n\n }\n\n var clearcoat = material.clearcoat;\n if ( material.clearcoatMap != -1 ) {\n\n let uvPrime = material.clearcoatMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.clearcoatMap, 0 );\n clearcoat *= texColor.r;\n\n }\n\n var clearcoatRoughness = material.clearcoatRoughness;\n if ( material.clearcoatRoughnessMap != -1 ) {\n\n let uvPrime = material.clearcoatRoughnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.clearcoatRoughnessMap, 0 );\n clearcoatRoughness *= texColor.g;\n\n }\n\n var clearcoatNormal = baseNormal;\n if ( material.clearcoatNormalMap != -1 ) {\n\n // some provided tangents can be malformed (0, 0, 0) causing the normal to be degenerate\n // resulting in NaNs and slow path tracing.\n if ( length( vertexData.tangent.xyz ) > 0.0 && vertexData.tangent.w != 0.0 ) {\n\n let tangent = normalize( vertexData.tangent.xyz );\n let bitangent = normalize( cross( baseNormal, tangent ) * vertexData.tangent.w );\n let vTBN = mat3x3f( tangent, bitangent, baseNormal );\n\n let uvPrime = material.clearcoatNormalMapTransform * vec3( uv, 1.0 );\n var texNormal = sampleTexel( uvPrime.xy, material.clearcoatNormalMap, 0 ).xyz;\n texNormal = texNormal * 2.0 - 1.0;\n texNormal = texNormal * vec3f( material.clearcoatNormalScale, 1.0 );\n clearcoatNormal = normalize( vTBN * texNormal );\n\n }\n\n }\n clearcoatNormal *= side;\n\n var sheenColor = material.sheenColor;\n if ( material.sheenColorMap != -1 ) {\n\n let uvPrime = material.sheenColorMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.sheenColorMap, 0 );\n sheenColor *= texColor.rgb;\n\n }\n\n var sheenRoughness = material.sheenRoughness;\n if ( material.sheenRoughnessMap != -1 ) {\n\n let uvPrime = material.sheenRoughnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.sheenRoughnessMap, 0 );\n sheenRoughness *= texColor.r;\n\n }\n\n var iridescence = material.iridescence;\n if ( material.iridescenceMap != -1 ) {\n\n let uvPrime = material.iridescenceMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.iridescenceMap, 0 );\n iridescence *= texColor.r;\n\n }\n\n var iridescenceThickness = material.iridescenceThicknessMaximum;\n if ( material.iridescenceThicknessMap != -1 ) {\n\n let uvPrime = material.iridescenceThicknessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.iridescenceThicknessMap, 0 );\n\n iridescenceThickness = mix(\n material.iridescenceThicknessMinimum,\n material.iridescenceThicknessMaximum,\n texColor.g,\n );\n\n }\n\n var specularColor = material.specularColor;\n if ( material.specularColorMap != -1 ) {\n\n let uvPrime = material.specularColorMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.specularColorMap, 0 );\n specularColor *= texColor.rgb;\n\n }\n\n var specularIntensity = material.specularIntensity;\n if ( material.specularIntensityMap != -1 ) {\n\n let uvPrime = material.specularIntensityMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.specularIntensityMap, 0 );\n specularIntensity *= texColor.r;\n\n }\n\n var surf: SurfaceRecord;\n\n surf.volumeParticle = false;\n surf.faceNormal = faceNormal;\n surf.normal = normal;\n\n surf.metalness = metalness;\n surf.color = albedo.rgb;\n surf.emission = emission;\n\n surf.ior = material.ior;\n surf.transmission = transmission;\n surf.thinFilm = material.thinFilm == 1;\n surf.attenuationColor = material.attenuationColor;\n surf.attenuationDistance = material.attenuationDistance;\n\n surf.clearcoatNormal = clearcoatNormal;\n surf.clearcoat = clearcoat;\n\n surf.iridescence = iridescence;\n surf.iridescenceIor = material.iridescenceIor;\n surf.iridescenceThickness = iridescenceThickness;\n\n surf.specularColor = specularColor;\n surf.specularIntensity = specularIntensity;\n\n surf.roughness = clamp( roughness, MIN_ROUGHNESS, 1.0 );\n surf.clearcoatRoughness = clamp( clearcoatRoughness, MIN_ROUGHNESS, 1.0 );\n surf.sheenRoughness = clamp( sheenRoughness, MIN_ROUGHNESS, 1.0 );\n\n // frontFace is used to determine transmissive properties and PDF. If no transmission is used\n // then we can just always assume this is a front face.\n surf.frontFace = side == 1.0 || transmission == 0.0;\n if ( material.thinFilm == 1 || surf.frontFace ) {\n surf.eta = 1.0 / material.ior;\n } else {\n surf.eta = material.ior;\n }\n surf.f0 = iorToF0( surf.eta );\n\n // get the normal frames\n surf.normalBasis = getBasisFromNormal( surf.normal );\n surf.normalInvBasis = inverse( surf.normalBasis );\n\n surf.clearcoatBasis = getBasisFromNormal( surf.clearcoatNormal );\n surf.clearcoatInvBasis = inverse( surf.clearcoatBasis );\n\n return surf;\n }\n\n", [
4165
+ var eo = j("\n\n fn ggxDirection( incidentDir: vec3f, alpha: vec2f, uv: vec2f ) -> vec3f {\n\n // Implementation from reference [1]\n // stretch view\n let V = normalize( vec3f( alpha * incidentDir.xy, incidentDir.z ) );\n\n // orthonormal basis\n var T1: vec3f;\n if ( V.z < 0.9999 ) {\n T1 = normalize( cross( V, vec3( 0.0, 0.0, 1.0 ) ) );\n } else {\n T1 = vec3( 1.0, 0.0, 0.0 );\n }\n\n let T2 = cross( T1, V );\n\n // sample point with polar coordinates (r, phi)\n let a = 1.0 / ( 1.0 + V.z );\n let r = sqrt( uv.x );\n var phi: f32;\n if ( uv.y < a ) {\n phi = uv.y / a * PI;\n } else {\n phi = PI + ( uv.y - a ) / ( 1.0 - a ) * PI;\n }\n let P1 = r * cos( phi );\n var P2 = r * sin( phi );\n if ( uv.y >= a ) {\n P2 *= V.z;\n }\n\n // compute normal\n var N = P1 * T1 + P2 * T2 + V * sqrt( max( 0.0, 1.0 - P1 * P1 - P2 * P2 ) );\n\n // unstretch\n N = normalize( vec3( alpha * N.xy, max( 0.0, N.z ) ) );\n\n return N;\n\n }\n\n", [aa]), to = j("\n\n fn ggxLamda( theta: f32, alpha: f32 ) -> f32 {\n\n let tanTheta = tan( theta );\n let tanTheta2 = tanTheta * tanTheta;\n let alpha2 = alpha * alpha;\n\n let numerator = - 1.0 + sqrt( 1.0 + alpha2 * tanTheta2 );\n return numerator / 2.0;\n\n }\n\n"), no = j("\n\n fn ggxShadowMaskG1( cosTheta: f32, alpha: f32 ) -> f32 {\n\n let a2 = alpha * alpha;\n let cosTheta2 = cosTheta * cosTheta;\n let denom = cosTheta + sqrt( cosTheta2 * ( 1 - a2 ) + a2 );\n return 2.0 * cosTheta / denom;\n\n }\n\n", [to]), ro = j("\n\n fn ggxSmithVisibility( NdotV: f32, NdotL: f32, alpha: f32 ) -> f32 {\n\n // Original formulation of G_SmithGGX Correlated\n // lambda_v = ( -1 + sqrt ( alphaG2 * (1 - NdotL2 ) / NdotL2 + 1)) * 0.5 f;\n // lambda_l = ( -1 + sqrt ( alphaG2 * (1 - NdotV2 ) / NdotV2 + 1)) * 0.5 f;\n // G_SmithGGXCorrelated = 1 / (1 + lambda_v + lambda_l );\n // V_SmithGGXCorrelated = G_SmithGGXCorrelated / (4.0 f * NdotL * NdotV );\n\n // This is an optimized version\n let alpha2 = alpha * alpha;\n // Caution: the \"NdotL *\" and \"NdotV *\" are explicitely inversed , this is not a mistake.\n let Lambda_GGXV = NdotL * sqrt (( - NdotV * alpha2 + NdotV ) * NdotV + alpha2 );\n let Lambda_GGXL = NdotV * sqrt (( - NdotL * alpha2 + NdotL ) * NdotL + alpha2 );\n\n return 0.5 / ( Lambda_GGXV + Lambda_GGXL );\n\n }\n\n", [to]), io = j("\n fn ggxDistribution( NdotH: f32, alpha: f32 ) -> f32 {\n\n let a2 = max( alpha * alpha, EPSILON );\n let denom = NdotH * NdotH * ( a2 - 1 ) + 1;\n\n return ( a2 / ( PI * denom * denom ) );\n\n }\n"), ao = j("\n fn ggxReflectionAdjustedPDF( NdotV: f32, NdotH: f32, alpha: f32 ) -> f32 {\n\n let D = ggxDistribution( NdotH, alpha );\n let G1 = ggxShadowMaskG1( NdotV, alpha );\n\n return D * G1 / ( 4 * NdotV );\n\n }\n", [io, no]), oo = (e) => j("\n\n fn getSurfaceRecord(\n material: Material,\n vertexData: bvh_GeometryStruct,\n side: f32,\n faceNormal: vec3f,\n ) -> SurfaceRecord {\n let uv = vertexData.uv.xy;\n\n var normal = faceNormal * side;\n if ( material.flatShading == 0 ) {\n\n normal = vertexData.normal.xyz;\n\n }\n normal = normalize( normal );\n let baseNormal = normal;\n\n if ( material.normalMap != -1 ) {\n\n // some provided tangents can be malformed (0, 0, 0) causing the normal to be degenerate\n // resulting in NaNs and slow path tracing.\n if ( length( vertexData.tangent.xyz ) > 0.0 && vertexData.tangent.w != 0.0 ) {\n\n let tangent = normalize( vertexData.tangent.xyz );\n let bitangent = normalize( cross( baseNormal, tangent ) * vertexData.tangent.w );\n let vTBN = mat3x3f( tangent, bitangent, baseNormal );\n\n let uvPrime = material.normalMapTransform * vec3( uv, 1.0 );\n var texNormal = sampleTexel( uvPrime.xy, material.normalMap, 0 ).xyz;\n texNormal = texNormal * 2.0 - 1.0;\n texNormal = texNormal * vec3f( material.normalScale, 1.0 );\n normal = normalize( vTBN * texNormal );\n\n }\n\n }\n\n normal *= side;\n\n var albedo = vec4( material.color, material.opacity );\n\n if ( material.vertexColors == 1 ) {\n\n let vertexColor = vertexData.color.xyz;\n albedo *= vec4f( vertexColor, 1.0 );\n\n }\n\n if ( material.map != -1 ) {\n\n let uvPrime = material.mapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.map, 0 );\n albedo *= vec4f( texColor.rgb, 1.0 );\n\n }\n\n var roughness = material.roughness;\n if ( material.roughnessMap != -1 ) {\n\n let uvPrime = material.roughnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.roughnessMap, 0 );\n roughness *= texColor.g;\n\n }\n\n var metalness = material.metalness;\n if ( material.metalnessMap != -1 ) {\n\n let uvPrime = material.metalnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.metalnessMap, 0 );\n metalness *= texColor.b;\n\n }\n\n var emission = material.emissiveIntensity * material.emissive;\n if ( material.emissiveMap != -1 ) {\n\n let uvPrime = material.emissiveMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.emissiveMap, 0 );\n emission *= texColor.rgb;\n\n }\n\n var transmission = material.transmission;\n if ( material.transmissionMap != -1 ) {\n\n let uvPrime = material.transmissionMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.transmissionMap, 0 );\n transmission *= texColor.r;\n\n }\n\n var clearcoat = material.clearcoat;\n if ( material.clearcoatMap != -1 ) {\n\n let uvPrime = material.clearcoatMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.clearcoatMap, 0 );\n clearcoat *= texColor.r;\n\n }\n\n var clearcoatRoughness = material.clearcoatRoughness;\n if ( material.clearcoatRoughnessMap != -1 ) {\n\n let uvPrime = material.clearcoatRoughnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.clearcoatRoughnessMap, 0 );\n clearcoatRoughness *= texColor.g;\n\n }\n\n var clearcoatNormal = baseNormal;\n if ( material.clearcoatNormalMap != -1 ) {\n\n // some provided tangents can be malformed (0, 0, 0) causing the normal to be degenerate\n // resulting in NaNs and slow path tracing.\n if ( length( vertexData.tangent.xyz ) > 0.0 && vertexData.tangent.w != 0.0 ) {\n\n let tangent = normalize( vertexData.tangent.xyz );\n let bitangent = normalize( cross( baseNormal, tangent ) * vertexData.tangent.w );\n let vTBN = mat3x3f( tangent, bitangent, baseNormal );\n\n let uvPrime = material.clearcoatNormalMapTransform * vec3( uv, 1.0 );\n var texNormal = sampleTexel( uvPrime.xy, material.clearcoatNormalMap, 0 ).xyz;\n texNormal = texNormal * 2.0 - 1.0;\n texNormal = texNormal * vec3f( material.clearcoatNormalScale, 1.0 );\n clearcoatNormal = normalize( vTBN * texNormal );\n\n }\n\n }\n clearcoatNormal *= side;\n\n var sheenColor = material.sheenColor;\n if ( material.sheenColorMap != -1 ) {\n\n let uvPrime = material.sheenColorMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.sheenColorMap, 0 );\n sheenColor *= texColor.rgb;\n\n }\n\n var sheenRoughness = material.sheenRoughness;\n if ( material.sheenRoughnessMap != -1 ) {\n\n let uvPrime = material.sheenRoughnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.sheenRoughnessMap, 0 );\n sheenRoughness *= texColor.r;\n\n }\n\n var iridescence = material.iridescence;\n if ( material.iridescenceMap != -1 ) {\n\n let uvPrime = material.iridescenceMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.iridescenceMap, 0 );\n iridescence *= texColor.r;\n\n }\n\n var iridescenceThickness = material.iridescenceThicknessMaximum;\n if ( material.iridescenceThicknessMap != -1 ) {\n\n let uvPrime = material.iridescenceThicknessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.iridescenceThicknessMap, 0 );\n\n iridescenceThickness = mix(\n material.iridescenceThicknessMinimum,\n material.iridescenceThicknessMaximum,\n texColor.g,\n );\n\n }\n\n var specularColor = material.specularColor;\n if ( material.specularColorMap != -1 ) {\n\n let uvPrime = material.specularColorMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.specularColorMap, 0 );\n specularColor *= texColor.rgb;\n\n }\n\n var specularIntensity = material.specularIntensity;\n if ( material.specularIntensityMap != -1 ) {\n\n let uvPrime = material.specularIntensityMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.specularIntensityMap, 0 );\n specularIntensity *= texColor.r;\n\n }\n\n var surf: SurfaceRecord;\n\n surf.volumeParticle = false;\n surf.faceNormal = faceNormal;\n surf.normal = normal;\n\n surf.metalness = metalness;\n surf.color = albedo.rgb;\n surf.emission = emission;\n\n surf.ior = material.ior;\n surf.transmission = transmission;\n surf.thinFilm = material.thinFilm == 1;\n surf.attenuationColor = material.attenuationColor;\n surf.attenuationDistance = material.attenuationDistance;\n\n surf.clearcoatNormal = clearcoatNormal;\n surf.clearcoat = clearcoat;\n\n surf.iridescence = iridescence;\n surf.iridescenceIor = material.iridescenceIor;\n surf.iridescenceThickness = iridescenceThickness;\n\n surf.specularColor = specularColor;\n surf.specularIntensity = specularIntensity;\n\n surf.roughness = clamp( roughness, MIN_ROUGHNESS, 1.0 );\n surf.clearcoatRoughness = clamp( clearcoatRoughness, MIN_ROUGHNESS, 1.0 );\n surf.sheenRoughness = clamp( sheenRoughness, MIN_ROUGHNESS, 1.0 );\n\n // frontFace is used to determine transmissive properties and PDF. If no transmission is used\n // then we can just always assume this is a front face.\n surf.frontFace = side == 1.0 || transmission == 0.0;\n if ( material.thinFilm == 1 || surf.frontFace ) {\n surf.eta = 1.0 / material.ior;\n } else {\n surf.eta = material.ior;\n }\n surf.f0 = iorToF0( surf.eta );\n\n // get the normal frames\n surf.normalBasis = getBasisFromNormal( surf.normal );\n surf.normalInvBasis = inverse( surf.normalBasis );\n\n surf.clearcoatBasis = getBasisFromNormal( surf.clearcoatNormal );\n surf.clearcoatInvBasis = inverse( surf.clearcoatBasis );\n\n return surf;\n }\n\n", [
4166
4166
  fa,
4167
4167
  ma,
4168
4168
  pa,
4169
4169
  e,
4170
4170
  ca,
4171
4171
  aa
4172
- ]), so = P("\n\n fn diffuseBrdf( NdotV: f32, NdotL: f32, VdotH: f32, surf: SurfaceRecord ) -> vec3f {\n\n // https://blog.selfshadow.com/publications/s2015-shading-course/burley/s2015_pbs_disney_bsdf_notes.pdf\n // See equation (4)\n\n let fl = schlickFresnel( NdotL, 0.0 );\n let fv = schlickFresnel( NdotV, 0.0 );\n\n let alpha = surf.roughness * surf.roughness;\n let bias = mix( 0.0, 0.5, alpha ) - 1;\n let energyFactor = mix( 1.0, 1.0 / 1.51, alpha );\n\n let rr = 2.0 * alpha * VdotH * VdotH;\n let retro = rr * ( fl + fv + fl * fv * ( rr + 2.0 * bias ) );\n let fresnel = ( 1.0 + bias * fl ) * ( 1.0f + bias * fv );\n\n // TODO: subsurface approx?\n\n return energyFactor * ( surf.color / PI ) * ( retro + fresnel );\n\n }\n\n", [
4172
+ ]), so = j("\n\n fn diffuseBrdf( NdotV: f32, NdotL: f32, VdotH: f32, surf: SurfaceRecord ) -> vec3f {\n\n // https://blog.selfshadow.com/publications/s2015-shading-course/burley/s2015_pbs_disney_bsdf_notes.pdf\n // See equation (4)\n\n let fl = schlickFresnel( NdotL, 0.0 );\n let fv = schlickFresnel( NdotV, 0.0 );\n\n let alpha = surf.roughness * surf.roughness;\n let bias = mix( 0.0, 0.5, alpha ) - 1;\n let energyFactor = mix( 1.0, 1.0 / 1.51, alpha );\n\n let rr = 2.0 * alpha * VdotH * VdotH;\n let retro = rr * ( fl + fv + fl * fv * ( rr + 2.0 * bias ) );\n let fresnel = ( 1.0 + bias * fl ) * ( 1.0f + bias * fv );\n\n // TODO: subsurface approx?\n\n return energyFactor * ( surf.color / PI ) * ( retro + fresnel );\n\n }\n\n", [
4173
4173
  aa,
4174
4174
  va,
4175
4175
  ca
4176
- ]), co = P("\n\n fn specularBrdf( NdotL: f32, NdotV: f32, NdotH: f32, alpha: f32 ) -> vec3f {\n\n let Vis = ggxSmithVisibility( NdotV, NdotL, alpha );\n let D = ggxDistribution( NdotH, alpha );\n\n return vec3f( D * Vis );\n\n }\n\n", [ro, io]), lo = P("\n\n fn fresnelMix( VdotH: f32, ior: f32, base: vec3f, layer: vec3f ) -> vec3f {\n\n let f0 = iorToF0( ior );\n let F = schlickFresnel( abs( VdotH ), f0 );\n\n return base + F * layer;\n\n }\n\n", [va, ma]), uo = Se(3.2404542, -.969266, .0556434, -1.5371385, 1.8760108, -.2040259, -.4985314, .041556, 1.0572252), fo = P("\n\n fn iridescentFresnel(\n cosTheta1: f32, baseF0: vec3f, iridescenceIor: f32,\n outsideIor: f32, iridescenceThickness: f32,\n ) -> vec3f {\n\n let sinTheta2Sq = pow( outsideIor / iridescenceIor, 2.0 ) * ( 1.0 - pow( cosTheta1, 2.0 ) );\n let cosTheta2Sq = 1.0 - sinTheta2Sq;\n\n // Handle total internal reflection\n if ( cosTheta2Sq < 0.0 ) {\n\n return vec3( 1.0 );\n\n }\n\n let cosTheta2 = sqrt( cosTheta2Sq );\n\n // First interface: air -> iridescent thin film\n let R0 = iorToF0General( iridescenceIor, outsideIor );\n let R12 = schlickFresnel( cosTheta1, R0 );\n let R21 = R12;\n let T121 = 1.0 - R12;\n let phi12 = select( 0.0, PI, iridescenceIor < outsideIor );\n let phi21 = PI - phi12;\n\n // Second interface: iridescent thin film -> base material\n let baseIor = fresnel0ToIor( baseF0 + 0.0001 ); // guard against 1.0\n let R1 = iorToF0GeneralVec( baseIor, vec3( iridescenceIor ) );\n let R23 = schlickFresnelVec( cosTheta2, R1, vec3( 1.0 ) );\n let phi23 = select( vec3( 0.0 ), vec3( PI ), baseIor < vec3( iridescenceIor ) );\n\n // Phase shift\n let OPD = 2.0 * iridescenceIor * iridescenceThickness * cosTheta2;\n let phi = vec3( phi21 ) + phi23;\n\n // Analytical integration\n // Compound terms\n let R123 = clamp( R12 * R23, vec3( 1e-5 ), vec3( 0.9999 ) );\n let r123 = sqrt( R123 );\n let Rs = T121 * T121 * R23 / ( vec3( 1.0 ) - R123 );\n\n // Reflectance term for m = 0 (DC term amplitude)\n let C0 = R12 + Rs;\n var I = C0;\n\n // Reflectance term for m > 0 (pairs of diracs)\n var Cm = Rs - T121;\n for (var m = 1; m <= 2; m += 1) {\n\n Cm *= r123;\n let Sm = 2.0 * evalSensitivity( f32( m ) * OPD, f32( m ) * phi );\n I += Cm * Sm;\n\n }\n\n return max( I, vec3(0.0) );\n\n }\n\n", [
4176
+ ]), co = j("\n\n fn specularBrdf( NdotL: f32, NdotV: f32, NdotH: f32, alpha: f32 ) -> vec3f {\n\n let Vis = ggxSmithVisibility( NdotV, NdotL, alpha );\n let D = ggxDistribution( NdotH, alpha );\n\n return vec3f( D * Vis );\n\n }\n\n", [ro, io]), lo = j("\n\n fn fresnelMix( VdotH: f32, ior: f32, base: vec3f, layer: vec3f ) -> vec3f {\n\n let f0 = iorToF0( ior );\n let F = schlickFresnel( abs( VdotH ), f0 );\n\n return base + F * layer;\n\n }\n\n", [va, ma]), uo = Ce(3.2404542, -.969266, .0556434, -1.5371385, 1.8760108, -.2040259, -.4985314, .041556, 1.0572252), fo = j("\n\n fn iridescentFresnel(\n cosTheta1: f32, baseF0: vec3f, iridescenceIor: f32,\n outsideIor: f32, iridescenceThickness: f32,\n ) -> vec3f {\n\n let sinTheta2Sq = pow( outsideIor / iridescenceIor, 2.0 ) * ( 1.0 - pow( cosTheta1, 2.0 ) );\n let cosTheta2Sq = 1.0 - sinTheta2Sq;\n\n // Handle total internal reflection\n if ( cosTheta2Sq < 0.0 ) {\n\n return vec3( 1.0 );\n\n }\n\n let cosTheta2 = sqrt( cosTheta2Sq );\n\n // First interface: air -> iridescent thin film\n let R0 = iorToF0General( iridescenceIor, outsideIor );\n let R12 = schlickFresnel( cosTheta1, R0 );\n let R21 = R12;\n let T121 = 1.0 - R12;\n let phi12 = select( 0.0, PI, iridescenceIor < outsideIor );\n let phi21 = PI - phi12;\n\n // Second interface: iridescent thin film -> base material\n let baseIor = fresnel0ToIor( baseF0 + 0.0001 ); // guard against 1.0\n let R1 = iorToF0GeneralVec( baseIor, vec3( iridescenceIor ) );\n let R23 = schlickFresnelVec( cosTheta2, R1, vec3( 1.0 ) );\n let phi23 = select( vec3( 0.0 ), vec3( PI ), baseIor < vec3( iridescenceIor ) );\n\n // Phase shift\n let OPD = 2.0 * iridescenceIor * iridescenceThickness * cosTheta2;\n let phi = vec3( phi21 ) + phi23;\n\n // Analytical integration\n // Compound terms\n let R123 = clamp( R12 * R23, vec3( 1e-5 ), vec3( 0.9999 ) );\n let r123 = sqrt( R123 );\n let Rs = T121 * T121 * R23 / ( vec3( 1.0 ) - R123 );\n\n // Reflectance term for m = 0 (DC term amplitude)\n let C0 = R12 + Rs;\n var I = C0;\n\n // Reflectance term for m > 0 (pairs of diracs)\n var Cm = Rs - T121;\n for (var m = 1; m <= 2; m += 1) {\n\n Cm *= r123;\n let Sm = 2.0 * evalSensitivity( f32( m ) * OPD, f32( m ) * phi );\n I += Cm * Sm;\n\n }\n\n return max( I, vec3(0.0) );\n\n }\n\n", [
4177
4177
  ha,
4178
4178
  ga,
4179
4179
  va,
@@ -4197,11 +4197,11 @@ var eo = P("\n\n fn ggxDirection( incidentDir: vec3f, alpha: vec2f, uv: vec2f )
4197
4197
  }
4198
4198
 
4199
4199
  `
4200
- ]), po = P("\n\n fn iridescentDielectricLayer(\n dielectricBase: vec3f, base: vec3f, specular: vec3f, HdotL: f32,\n outsideIor: f32, baseIor: f32, iridescenceIor: f32, thickness: f32, strength: f32,\n ) -> vec3f {\n\n let baseF0 = vec3( iorToF0( baseIor ) );\n\n let iridescentF = iridescentFresnel( HdotL, baseF0, iridescenceIor, outsideIor, thickness );\n\n return mix( dielectricBase, rgbMix( base, specular, iridescentF ), strength );\n\n }\n\n", [
4200
+ ]), po = j("\n\n fn iridescentDielectricLayer(\n dielectricBase: vec3f, base: vec3f, specular: vec3f, HdotL: f32,\n outsideIor: f32, baseIor: f32, iridescenceIor: f32, thickness: f32, strength: f32,\n ) -> vec3f {\n\n let baseF0 = vec3( iorToF0( baseIor ) );\n\n let iridescentF = iridescentFresnel( HdotL, baseF0, iridescenceIor, outsideIor, thickness );\n\n return mix( dielectricBase, rgbMix( base, specular, iridescentF ), strength );\n\n }\n\n", [
4201
4201
  ma,
4202
4202
  fo,
4203
- P("\n\n fn rgbMix( base: vec3f, specular: vec3f, rgbAlpha: vec3f ) -> vec3f {\n\n let alphaMax = max( max( rgbAlpha.x, rgbAlpha.y ), rgbAlpha.z );\n return ( 1 - alphaMax ) * base + rgbAlpha * specular;\n\n }\n\n")
4204
- ]), mo = P("\n\n fn iridescentConductorLayer(\n metalBase: vec3f, specular: vec3f, baseF0: vec3f, HdotL: f32,\n outsideIor: f32, iridescenceIor: f32, thickness: f32, strength: f32,\n ) -> vec3f {\n\n let iridescenceF = iridescentFresnel( HdotL, baseF0, iridescenceIor, outsideIor, thickness );\n\n return mix( metalBase, specular * iridescenceF, strength );\n\n }\n\n", [fo]), ho = (e) => P("\n\n fn conductorFresnel( NdotV: f32, VdotH: f32, f0: vec3f, bsdf: vec3f, alpha: f32 ) -> vec3f {\n\n let ss = bsdf * schlickFresnelVec( abs( VdotH ), f0, vec3f( 1 ) );\n\n let uv = vec2( NdotV, sqrt( alpha ) );\n let energySs = max( textureSampleLevel( turquinTexture, turquinTexture_sampler, uv, 0 ).r, 1e-5 );\n\n return ss * ( 1.0 + f0 * ( 1.0 - energySs ) / energySs );\n\n }\n\n", [ya, e]), go = P("\n\n fn fresnelCoat( VdotNc: f32, ior: f32, base: vec3f, layer: vec3f, weight: f32 ) -> vec3f {\n\n let f0 = iorToF0( ior );\n let F = schlickFresnel( abs( VdotNc ), f0 );\n\n return mix( base, layer, weight * F );\n\n }\n\n", [ma, va]), _o = $`
4203
+ j("\n\n fn rgbMix( base: vec3f, specular: vec3f, rgbAlpha: vec3f ) -> vec3f {\n\n let alphaMax = max( max( rgbAlpha.x, rgbAlpha.y ), rgbAlpha.z );\n return ( 1 - alphaMax ) * base + rgbAlpha * specular;\n\n }\n\n")
4204
+ ]), mo = j("\n\n fn iridescentConductorLayer(\n metalBase: vec3f, specular: vec3f, baseF0: vec3f, HdotL: f32,\n outsideIor: f32, iridescenceIor: f32, thickness: f32, strength: f32,\n ) -> vec3f {\n\n let iridescenceF = iridescentFresnel( HdotL, baseF0, iridescenceIor, outsideIor, thickness );\n\n return mix( metalBase, specular * iridescenceF, strength );\n\n }\n\n", [fo]), ho = (e) => j("\n\n fn conductorFresnel( NdotV: f32, VdotH: f32, f0: vec3f, bsdf: vec3f, alpha: f32 ) -> vec3f {\n\n let ss = bsdf * schlickFresnelVec( abs( VdotH ), f0, vec3f( 1 ) );\n\n let uv = vec2( NdotV, sqrt( alpha ) );\n let energySs = max( textureSampleLevel( turquinTexture, turquinTexture_sampler, uv, 0 ).r, 1e-5 );\n\n return ss * ( 1.0 + f0 * ( 1.0 - energySs ) / energySs );\n\n }\n\n", [ya, e]), go = j("\n\n fn fresnelCoat( VdotNc: f32, ior: f32, base: vec3f, layer: vec3f, weight: f32 ) -> vec3f {\n\n let f0 = iorToF0( ior );\n let F = schlickFresnel( abs( VdotNc ), f0 );\n\n return mix( base, layer, weight * F );\n\n }\n\n", [ma, va]), _o = $`
4205
4205
 
4206
4206
  fn albedo(
4207
4207
  texture: texture_storage_2d<r16float, write>,
@@ -4421,9 +4421,9 @@ var wo = class {
4421
4421
  }), this.structs.transform = Eo, this.structs.material = sa, this.storage.materials = null, this.materials = [], this.bvhMap = /* @__PURE__ */ new Map(), this.textureAtlas = new wo();
4422
4422
  }
4423
4423
  useTransparencyRaycastFn() {
4424
- let { textureAtlas: e, storage: t, structs: n, fns: r } = this, i = e.texture, a = Ca(xe(e.textureInfo, "uvec4"), Me(i), ke(i));
4424
+ let { textureAtlas: e, storage: t, structs: n, fns: r } = this, i = e.texture, a = Ca(Te(e.textureInfo, "uvec4"), De(i), je(i));
4425
4425
  r.getSurfaceRecord = oo(a);
4426
- let o = new _e(n.material).toVar("bvh_material"), s = Ae(1).toVar("bvh_rayScalar"), c = Ae(1).toVar("bvh_baseOpacity");
4426
+ let o = new _e(n.material).toVar("bvh_material"), s = Oe(1).toVar("bvh_rayScalar"), c = Oe(1).toVar("bvh_baseOpacity");
4427
4427
  r.raycastFirstHit = this.getShapecastFn({
4428
4428
  name: "raycastFirstHit",
4429
4429
  shapeStruct: Q,
@@ -4606,7 +4606,7 @@ var wo = class {
4606
4606
  super.update();
4607
4607
  let { materials: e, structs: t } = this, { materialData: n, textures: r } = this.writeMaterialsBuffer(e);
4608
4608
  this.textures = r;
4609
- let i = N(new me(n, t.material.getLength()), t.material).toReadOnly().setName("bvh_materials");
4609
+ let i = P(new me(n, t.material.getLength()), t.material).toReadOnly().setName("bvh_materials");
4610
4610
  this.storage.materials = i, this.bvhMap.clear(), this.materials.length = 0, this.useTransparencyRaycastFn();
4611
4611
  }
4612
4612
  writeMaterialsBuffer(e) {
@@ -4723,7 +4723,7 @@ var wo = class {
4723
4723
  this._layerUniform.value = e;
4724
4724
  }
4725
4725
  constructor() {
4726
- super(), this.blending = 0, this._texNode = Me(new h()), this._layerUniform = M(0), this.colorNode = P("\n fn atlasDebug( tex: texture_2d_array<f32>, coord: vec2f, layer: f32 ) -> vec4f {\n\n // flip y so texel origin shows at the top-left\n let dims = vec2f( textureDimensions( tex, 0 ).xy );\n let texel = vec2i( vec2f( coord.x, 1.0 - coord.y ) * dims );\n return textureLoad( tex, texel, i32( layer ), 0 );\n\n }\n ")(this._texNode, De(be()), this._layerUniform);
4726
+ super(), this.blending = 0, this._texNode = De(new h()), this._layerUniform = M(0), this.colorNode = j("\n fn atlasDebug( tex: texture_2d_array<f32>, coord: vec2f, layer: f32 ) -> vec4f {\n\n // flip y so texel origin shows at the top-left\n let dims = vec2f( textureDimensions( tex, 0 ).xy );\n let texel = vec2i( vec2f( coord.x, 1.0 - coord.y ) * dims );\n return textureLoad( tex, texel, i32( layer ), 0 );\n\n }\n ")(this._texNode, we(Ae()), this._layerUniform);
4727
4727
  }
4728
4728
  };
4729
4729
  //#endregion
@@ -4778,19 +4778,19 @@ var Ao = class {
4778
4778
  getData() {
4779
4779
  return { bsdfSample: this.getBsdfNode() };
4780
4780
  }
4781
- }, jo = new URL("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACsUlEQVR4AcTWjXISMRiF4WTb3v+1dqblH5QnzsGPdUF0tDDzepLdJe9JEGX69uTXdDqd2jNf0/v7e1PifBBP6TGtVqu22+0uJb66yNR7b0rs9/t2PB6bAnP+59FMb29vbbvdts1m01KiFiGfFzJ3/V8wvb6+jp0rAR/H4XAY1/zdAGGINPO/yawhR4HeeyMlh5OAkwgpkqxiC/0J9b3T+dXgIqkCMIZiKSEVCN4Dc/kI86Jn9zQKuGEhQmIlYAzXFQieDcR1bP4o41vw8vLSeu/jG0BABmIYVzwzJwVcz1jOi7gW3BsFeu+jgFNw0SIRKlBPwjx4xrMVi5vLW3DA/VHg/DmMAr3/OAU3LUIAQiVgjFw3hnnw3iUI4Z7EZNe9/zwBczfgwSwqiaAIjCueCa5nbJ1bjAKkvXcxcAIp4I0WyoIyKAFzGczn1DWMw6XAMJ//IIcCUADeUBetsoxr1meN3ZNzfilw7jC+DSkRuQKoC1h0Cf+izll6zlqXAoQVu4cCqPIsZoG56JG59+c5v4jGjrNz0kBcUQLEFqlkwZr+g7uF59xbPIEUkAqQBvKQAhYLFr3Her1uwXOjgKMnSxoTVxSIWN6SK2JhkqQx/O6QMMblI6hyBZAC5IE83CpBDKIkmbmsjAJklYjlI2JFsvMIyVBln5+f49eXDFcfgRKkiLhmdi5JQ+RJJaBASJGIk+MEcvzElcgJQ6TJSJOES3LXU0Iq8PHx0UYBO0fkESeX5IQVUrhGFsgqxJXxEZCHeYnIa2b3kjAoEFIgeavEOIH6EWTX8p50LleCnFDCONQCGTuJUcDus3NJHmoJY2IQBjLM566lQDJyeVUgJX4nJg8RJgmXiDxJDvOrEyCvJ2DHIdIkqbEEcdI4kNRx5hJXBe7JFalCsntE6pmMk8TG8jsAAAD//yGAaM0AAAAGSURBVAMAifCfleVLEBEAAAAASUVORK5CYII=", "" + import.meta.url).toString(), Mo = await new oe().loadAsync(jo), No = Ae(1.5), Po = Ae(.001), Fo = class extends Ao {
4781
+ }, jo = new URL("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACsUlEQVR4AcTWjXISMRiF4WTb3v+1dqblH5QnzsGPdUF0tDDzepLdJe9JEGX69uTXdDqd2jNf0/v7e1PifBBP6TGtVqu22+0uJb66yNR7b0rs9/t2PB6bAnP+59FMb29vbbvdts1m01KiFiGfFzJ3/V8wvb6+jp0rAR/H4XAY1/zdAGGINPO/yawhR4HeeyMlh5OAkwgpkqxiC/0J9b3T+dXgIqkCMIZiKSEVCN4Dc/kI86Jn9zQKuGEhQmIlYAzXFQieDcR1bP4o41vw8vLSeu/jG0BABmIYVzwzJwVcz1jOi7gW3BsFeu+jgFNw0SIRKlBPwjx4xrMVi5vLW3DA/VHg/DmMAr3/OAU3LUIAQiVgjFw3hnnw3iUI4Z7EZNe9/zwBczfgwSwqiaAIjCueCa5nbJ1bjAKkvXcxcAIp4I0WyoIyKAFzGczn1DWMw6XAMJ//IIcCUADeUBetsoxr1meN3ZNzfilw7jC+DSkRuQKoC1h0Cf+izll6zlqXAoQVu4cCqPIsZoG56JG59+c5v4jGjrNz0kBcUQLEFqlkwZr+g7uF59xbPIEUkAqQBvKQAhYLFr3Her1uwXOjgKMnSxoTVxSIWN6SK2JhkqQx/O6QMMblI6hyBZAC5IE83CpBDKIkmbmsjAJklYjlI2JFsvMIyVBln5+f49eXDFcfgRKkiLhmdi5JQ+RJJaBASJGIk+MEcvzElcgJQ6TJSJOES3LXU0Iq8PHx0UYBO0fkESeX5IQVUrhGFsgqxJXxEZCHeYnIa2b3kjAoEFIgeavEOIH6EWTX8p50LleCnFDCONQCGTuJUcDus3NJHmoJY2IQBjLM566lQDJyeVUgJX4nJg8RJgmXiDxJDvOrEyCvJ2DHIdIkqbEEcdI4kNRx5hJXBe7JFalCsntE6pmMk8TG8jsAAAD//yGAaM0AAAAGSURBVAMAifCfleVLEBEAAAAASUVORK5CYII=", "" + import.meta.url).toString(), Mo = await new oe().loadAsync(jo), No = Oe(1.5), Po = Oe(.001), Fo = class extends Ao {
4782
4782
  constructor(e = {}) {
4783
4783
  super();
4784
4784
  let { specularBrdf: t = co, diffuseBrdf: n = so, fresnelMix: r = lo, conductorFresnel: i = ho, fresnelCoat: a = go, iridescentDielectricLayer: o = po, iridescentConductorLayer: s = mo, calculateTurquinTexture: c = !1 } = e;
4785
4785
  c ? (this.turquinTexture = new k(32, 32), this.turquinTexture.type = w) : (this.turquinTexture = Mo, this.turquinTexture.flipY = !1), this.turquinTexture.format = ne, this.turquinTexture.minFilter = T, this.turquinTexture.magFilter = T;
4786
- let l = Me(this.turquinTexture).setName("turquinTexture");
4786
+ let l = De(this.turquinTexture).setName("turquinTexture");
4787
4787
  this.specularBrdf = t, this.diffuseBrdf = n, this.fresnelMix = r, this.conductorFresnel = i(l), this.fresnelCoat = a, this.iridescentDielectricLayer = o, this.iridescentConductorLayer = s, this.calculateTurquinTexture = c;
4788
4788
  }
4789
4789
  init(e) {
4790
4790
  if (!this.calculateTurquinTexture) return;
4791
4791
  let t = new zi(_o({
4792
- texture: j(this.turquinTexture).toWriteOnly(),
4793
- globalId: Oe
4792
+ texture: N(this.turquinTexture).toWriteOnly(),
4793
+ globalId: be
4794
4794
  }), { workgroupSize: [
4795
4795
  16,
4796
4796
  16,
@@ -5081,4 +5081,4 @@ function zo(e, t, n) {
5081
5081
  //#endregion
5082
5082
  export { Ro as WebGPUPathTracer };
5083
5083
 
5084
- //# sourceMappingURL=webgpu-B0rxiqW-.mjs.map
5084
+ //# sourceMappingURL=webgpu-C14yfIYy.mjs.map