@uptimizr/dashboard 0.1.2 → 0.2.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 (240) hide show
  1. package/out/404.html +1 -1
  2. package/out/__next.__PAGE__.txt +4 -4
  3. package/out/__next._full.txt +11 -11
  4. package/out/__next._head.txt +4 -4
  5. package/out/__next._index.txt +4 -4
  6. package/out/__next._tree.txt +2 -2
  7. package/out/_next/static/chunks/002cjeoit6-up.js +1 -0
  8. package/out/_next/static/chunks/02n1uiltexy3w.js +1 -0
  9. package/out/_next/static/chunks/03ab2khhe8-x5.js +1 -0
  10. package/out/_next/static/chunks/04_yytpc2paxy.js +1 -0
  11. package/out/_next/static/chunks/06qot1qvlsqaz.js +1 -0
  12. package/out/_next/static/chunks/07eeopuufsqp-.js +1501 -0
  13. package/out/_next/static/chunks/08a5xek662n8n.js +1 -0
  14. package/out/_next/static/chunks/08wuc9--s8zn_.js +1 -0
  15. package/out/_next/static/chunks/0927l-ygd5c8d.js +1 -0
  16. package/out/_next/static/chunks/09510356f0lad.js +1 -0
  17. package/out/_next/static/chunks/0_eu72k69lxj7.js +1 -0
  18. package/out/_next/static/chunks/0beajlqy8p8b5.js +1 -0
  19. package/out/_next/static/chunks/0c83pe1mpx456.js +1 -0
  20. package/out/_next/static/chunks/0echnagbkyx79.js +1198 -0
  21. package/out/_next/static/chunks/0eh1ml86u8dh7.js +1 -0
  22. package/out/_next/static/chunks/0fh-9h9ylxskr.js +674 -0
  23. package/out/_next/static/chunks/0fzmc1up21g1i.js +1 -0
  24. package/out/_next/static/chunks/0g_v2zswo4l6f.js +1 -0
  25. package/out/_next/static/chunks/0grlb9lo8e502.js +1 -0
  26. package/out/_next/static/chunks/0h22pg-0xrxnm.js +1 -0
  27. package/out/_next/static/chunks/0j6p1pmc14t96.js +1 -0
  28. package/out/_next/static/chunks/0j_6dx-sttgsy.js +1 -0
  29. package/out/_next/static/chunks/0j__xaq_8_di1.js +1 -0
  30. package/out/_next/static/chunks/0kfd-cvj5fvtz.js +1 -0
  31. package/out/_next/static/chunks/0o_mp98xzqfyf.js +1 -0
  32. package/out/_next/static/chunks/0otsec99kdkt7.js +213 -0
  33. package/out/_next/static/chunks/0ql-s-tsmel_u.js +151 -0
  34. package/out/_next/static/chunks/0r47gs_e93cka.js +1 -0
  35. package/out/_next/static/chunks/0sqys6o2pbe1q.js +1328 -0
  36. package/out/_next/static/chunks/0titqrn1qmcsv.js +1 -0
  37. package/out/_next/static/chunks/0tnlbw78tgaxp.js +4 -0
  38. package/out/_next/static/chunks/0tw4dyl-cp-hd.js +1 -0
  39. package/out/_next/static/chunks/0vbce-8omgurc.js +1 -0
  40. package/out/_next/static/chunks/0vfsg5byzep_0.js +1 -0
  41. package/out/_next/static/chunks/{0gv7mblzv3dl3.js → 0w8_1yjvol1f0.js} +20 -20
  42. package/out/_next/static/chunks/0xh144a5fz58h.js +1 -0
  43. package/out/_next/static/chunks/0xjltg_pph0c8.js +1 -0
  44. package/out/_next/static/chunks/0yeqgh0dnas8d.js +1 -0
  45. package/out/_next/static/chunks/101-7e_7up7rk.js +1 -0
  46. package/out/_next/static/chunks/128e51hj_04r0.js +1 -0
  47. package/out/_next/static/chunks/{10fnxpln_5xfd.js → 12kv810lohbsx.js} +2 -2
  48. package/out/_next/static/chunks/137xbvd4nd41j.js +3 -0
  49. package/out/_next/static/chunks/14bws-suyy5zu.js +1 -0
  50. package/out/_next/static/chunks/14ggsmqwej_tt.js +1656 -0
  51. package/out/_next/static/chunks/17genz6pkmty_.js +1 -0
  52. package/out/_next/static/chunks/17xd8hnazzr0g.js +1454 -0
  53. package/out/_next/static/chunks/18dczy9ylt2s_.js +1 -0
  54. package/out/_next/static/chunks/18xs_kvsaolb0.js +1 -0
  55. package/out/_next/static/chunks/19016f8-ry0z6.js +1 -0
  56. package/out/_next/static/chunks/1_6oejyxj39li.js +1 -0
  57. package/out/_next/static/chunks/1_aon8nz9p1fr.js +1 -0
  58. package/out/_next/static/chunks/1_qzlkuxukhpq.js +779 -0
  59. package/out/_next/static/chunks/1akaj5rhgitn3.js +1 -0
  60. package/out/_next/static/chunks/1bvl1ws7b_3gn.js +1 -0
  61. package/out/_next/static/chunks/1cdbk6kxyr1c9.js +1 -0
  62. package/out/_next/static/chunks/1fbjkk55uu4_g.js +1 -0
  63. package/out/_next/static/chunks/1furcfsgrw_3g.js +1 -0
  64. package/out/_next/static/chunks/1g0-f1g3gn_rs.js +1 -0
  65. package/out/_next/static/chunks/1g7emwu85bifo.js +557 -0
  66. package/out/_next/static/chunks/{37vzwr3ciejf1.js → 1gs-5722l4u59.js} +1 -1
  67. package/out/_next/static/chunks/1gt4kh0_xmigy.js +1 -0
  68. package/out/_next/static/chunks/1h8xzuuhhglu9.js +1 -0
  69. package/out/_next/static/chunks/1hatz-jlztrn0.js +1 -0
  70. package/out/_next/static/chunks/1iioifo7i0t0_.js +1 -0
  71. package/out/_next/static/chunks/{0impkpmxx3ttp.js → 1iiz7jqgj20z0.js} +1 -1
  72. package/out/_next/static/chunks/1kujmd5n0j9nk.js +1 -0
  73. package/out/_next/static/chunks/{2kazjq29jeamx.js → 1ltux4lwz7muf.js} +160 -372
  74. package/out/_next/static/chunks/1m_buecgcq67j.js +740 -0
  75. package/out/_next/static/chunks/1n9sy0yt5d2vq.js +1 -0
  76. package/out/_next/static/chunks/1p1gz6dseck--.js +1 -0
  77. package/out/_next/static/chunks/1p1xtsfwvpuqo.js +1 -0
  78. package/out/_next/static/chunks/1p8f6okk2ewbz.js +1 -0
  79. package/out/_next/static/chunks/1qg_etglhvp9h.js +740 -0
  80. package/out/_next/static/chunks/1th_t5ujeqlkf.js +1 -0
  81. package/out/_next/static/chunks/1thr-mdzbu96v.js +1 -0
  82. package/out/_next/static/chunks/1tta1a064979p.js +1 -0
  83. package/out/_next/static/chunks/1u_riwm0nfww7.js +1 -0
  84. package/out/_next/static/chunks/1ua15kzid0_8p.js +2560 -0
  85. package/out/_next/static/chunks/1uu-rt_8p1edp.js +2712 -0
  86. package/out/_next/static/chunks/1uu93wuxigx4k.js +1 -0
  87. package/out/_next/static/chunks/{1flb8adpj6_2o.js → 1xpwp4m1tqugp.js} +1 -1
  88. package/out/_next/static/chunks/1ynju1jqfrcv0.js +1 -0
  89. package/out/_next/static/chunks/1zfojlgb15okk.js +1 -0
  90. package/out/_next/static/chunks/1zj8x5wbgnzz-.js +1 -0
  91. package/out/_next/static/chunks/1zl6t15gh34nn.js +1 -0
  92. package/out/_next/static/chunks/{1thjncpj7u6pq.js → 223vrr_4sfhsj.js} +1 -1
  93. package/out/_next/static/chunks/22cr2b04btguf.js +1 -0
  94. package/out/_next/static/chunks/242xhzxxetctz.js +1 -0
  95. package/out/_next/static/chunks/24essz5mmvx-6.js +1 -0
  96. package/out/_next/static/chunks/256k1jw1m--l7.js +146 -0
  97. package/out/_next/static/chunks/259obyrpxcv6r.js +1 -0
  98. package/out/_next/static/chunks/26v9yqicofqba.js +1 -0
  99. package/out/_next/static/chunks/290d93hmm_e8b.js +1 -0
  100. package/out/_next/static/chunks/2_2fk7iddrs43.js +1 -0
  101. package/out/_next/static/chunks/{00k_j_r7bv_eb.js → 2bjlls8-qe05r.js} +9 -9
  102. package/out/_next/static/chunks/2ckd7f1wbfod-.js +1 -0
  103. package/out/_next/static/chunks/{163fa70v4mgxj.js → 2d6hru4qo23tt.js} +1 -1
  104. package/out/_next/static/chunks/2ejvntxtvf5o9.js +1 -0
  105. package/out/_next/static/chunks/2f7_3tzf7xhps.js +1 -0
  106. package/out/_next/static/chunks/2gxd_o1g89_bv.js +1 -0
  107. package/out/_next/static/chunks/2hd2txb4-m9k1.js +1 -0
  108. package/out/_next/static/chunks/2hpxou_cnp4f_.js +1 -0
  109. package/out/_next/static/chunks/2izioctrfc0s5.js +1 -0
  110. package/out/_next/static/chunks/2jhnk4h4n0udv.js +1 -0
  111. package/out/_next/static/chunks/2jpkhkk9zi8-f.js +1 -0
  112. package/out/_next/static/chunks/2kpet_l1kq2sx.js +1 -0
  113. package/out/_next/static/chunks/2mdbvf1b5h00_.css +3 -0
  114. package/out/_next/static/chunks/2nck5w4c7leb7.js +1 -0
  115. package/out/_next/static/chunks/2our10fwtj87e.js +1 -0
  116. package/out/_next/static/chunks/2qq3uzsbiicw3.js +1194 -0
  117. package/out/_next/static/chunks/2qqqpu0ahfdda.js +1 -0
  118. package/out/_next/static/chunks/2u-f7mmxvk8wj.js +1 -0
  119. package/out/_next/static/chunks/2ue1wo4ryk87z.js +1 -0
  120. package/out/_next/static/chunks/2uk-vwlxe9-xr.js +1 -0
  121. package/out/_next/static/chunks/2ur5-lxdvv1jm.js +1 -0
  122. package/out/_next/static/chunks/2veqsohwfhfqc.js +1 -0
  123. package/out/_next/static/chunks/2vqlv9wnewhu9.js +1 -0
  124. package/out/_next/static/chunks/{1zvc1tv--w8nn.js → 2wzshintp5lf8.js} +1 -1
  125. package/out/_next/static/chunks/2x-00glogc485.js +1 -0
  126. package/out/_next/static/chunks/2yfxy0f5fqs4o.js +1 -0
  127. package/out/_next/static/chunks/2z88mt3ixktu3.js +1 -0
  128. package/out/_next/static/chunks/2z_jn9ud28fk7.js +1 -0
  129. package/out/_next/static/chunks/3-eswqjobiqk1.js +1 -0
  130. package/out/_next/static/chunks/30-tbi7pys6fp.js +4 -0
  131. package/out/_next/static/chunks/30c-nsedy_ce0.js +1 -0
  132. package/out/_next/static/chunks/31u5lbu1vxznh.js +1 -0
  133. package/out/_next/static/chunks/{2feca0xcipcyt.js → 32ahba5ezp467.js} +156 -156
  134. package/out/_next/static/chunks/337hn35kts7ud.js +1 -0
  135. package/out/_next/static/chunks/33dgpebv-tf73.js +1 -0
  136. package/out/_next/static/chunks/36jkdhq6kb-cf.js +1 -0
  137. package/out/_next/static/chunks/37epa8fz59vba.js +1166 -0
  138. package/out/_next/static/chunks/3833xfnz0a-ub.js +1 -0
  139. package/out/_next/static/chunks/38awrh_qxn22k.js +1 -0
  140. package/out/_next/static/chunks/{0wrm9jr-9bw0e.js → 38x3c1ra5slhe.js} +383 -913
  141. package/out/_next/static/chunks/39idqlqlcp5b9.js +1 -0
  142. package/out/_next/static/chunks/{2a3spdq-m8drh.js → 3_gku1pwluoo0.js} +1 -1
  143. package/out/_next/static/chunks/3_mu-4rdjajna.js +1450 -0
  144. package/out/_next/static/chunks/3coacc4-g-g5c.js +1 -0
  145. package/out/_next/static/chunks/3e00fzdfkclzq.js +1 -0
  146. package/out/_next/static/chunks/3e8fmlq0k5wkg.js +1 -0
  147. package/out/_next/static/chunks/3e9tzyrt4_98z.js +1 -0
  148. package/out/_next/static/chunks/3edelqkq92pil.js +1 -0
  149. package/out/_next/static/chunks/3figbil1t4ssj.js +593 -0
  150. package/out/_next/static/chunks/3gimb3z_mteou.js +1 -0
  151. package/out/_next/static/chunks/{2p2vv6cc9i-3q.js → 3idaz_s77e-j_.js} +9 -9
  152. package/out/_next/static/chunks/3j-4wuhs5weba.js +1 -0
  153. package/out/_next/static/chunks/3jjfnwvybayy7.js +1 -0
  154. package/out/_next/static/chunks/3jwm5dfk_78gc.js +1 -0
  155. package/out/_next/static/chunks/3k9d4ylc3li2t.js +1352 -0
  156. package/out/_next/static/chunks/3l3_0ack3gy4k.js +1 -0
  157. package/out/_next/static/chunks/3lwhs5ja7tun3.js +1 -0
  158. package/out/_next/static/chunks/3m6nmp2dca6un.js +1342 -0
  159. package/out/_next/static/chunks/3mbnfpufs2-7e.js +7 -0
  160. package/out/_next/static/chunks/3mcd08gmt038z.js +1 -0
  161. package/out/_next/static/chunks/3mt5th7b1i_u9.js +1 -0
  162. package/out/_next/static/chunks/3ne77mjdz2y7o.js +1 -0
  163. package/out/_next/static/chunks/3puhrqtujktyv.js +1 -0
  164. package/out/_next/static/chunks/3rdifucupcgkg.js +1 -0
  165. package/out/_next/static/chunks/3riekaxl3uxfb.js +1195 -0
  166. package/out/_next/static/chunks/3sdoskq_buttj.js +1 -0
  167. package/out/_next/static/chunks/3tg-ma9tv9xu4.js +1 -0
  168. package/out/_next/static/chunks/3tm-pqpmq_ppw.js +1 -0
  169. package/out/_next/static/chunks/3w9go565cjhq3.js +1636 -0
  170. package/out/_next/static/chunks/3wi9gzq2mtr_q.js +8 -0
  171. package/out/_next/static/chunks/3xagd_2_9zft2.js +1 -0
  172. package/out/_next/static/chunks/3xsq_anpad-fb.js +1 -0
  173. package/out/_next/static/chunks/3ycv2qq7vpbua.js +1 -0
  174. package/out/_next/static/chunks/3z84au-mitjjw.js +1 -0
  175. package/out/_next/static/chunks/4030dhur2h70-.js +1 -0
  176. package/out/_next/static/chunks/40ffffml4h_3r.js +4 -0
  177. package/out/_next/static/chunks/{3-shckrcpvbxu.js → 41wt50z9tx9cx.js} +108 -711
  178. package/out/_next/static/chunks/431slrqh0wa0g.js +1 -0
  179. package/out/_next/static/chunks/43s_lbd1i2krj.js +1 -0
  180. package/out/_next/static/chunks/{0-2y-_oomza2l.js → 44nxswtahaq4w.js} +18 -18
  181. package/out/_next/static/chunks/45bwefvdpztfs.js +1 -0
  182. package/out/_next/static/chunks/{turbopack-0sgd6pfbe1fy6.js → turbopack-19105pdhzxp1x.js} +1 -1
  183. package/out/_not-found/__next._full.txt +9 -9
  184. package/out/_not-found/__next._head.txt +4 -4
  185. package/out/_not-found/__next._index.txt +4 -4
  186. package/out/_not-found/__next._not-found.__PAGE__.txt +2 -2
  187. package/out/_not-found/__next._not-found.txt +3 -3
  188. package/out/_not-found/__next._tree.txt +2 -2
  189. package/out/_not-found.html +1 -1
  190. package/out/_not-found.txt +9 -9
  191. package/out/index.html +1 -1
  192. package/out/index.txt +11 -11
  193. package/package.json +5 -4
  194. package/out/_next/static/chunks/068j6934u8j16.js +0 -1
  195. package/out/_next/static/chunks/09e4adtr6w0xe.js +0 -1
  196. package/out/_next/static/chunks/0_rf76jneiwal.js +0 -176
  197. package/out/_next/static/chunks/0aznt7717miff.js +0 -1
  198. package/out/_next/static/chunks/0cu-q5q3a7uf3.js +0 -1
  199. package/out/_next/static/chunks/0fskcfh9vbhtv.js +0 -1
  200. package/out/_next/static/chunks/0gg-ii7i6d_p6.js +0 -1
  201. package/out/_next/static/chunks/0tx1j_ghpz7rc.css +0 -3
  202. package/out/_next/static/chunks/0ufbyo1x3qkmo.js +0 -1
  203. package/out/_next/static/chunks/0wwcfw8i3j_zx.js +0 -1
  204. package/out/_next/static/chunks/0wwkrsvxwi57d.js +0 -1
  205. package/out/_next/static/chunks/0ys9-ozuluawt.js +0 -1
  206. package/out/_next/static/chunks/1-61zh4waha61.js +0 -1
  207. package/out/_next/static/chunks/10r_824wzt8hj.js +0 -1
  208. package/out/_next/static/chunks/123xxske5c9na.js +0 -1
  209. package/out/_next/static/chunks/13isnf0--pmx1.js +0 -1
  210. package/out/_next/static/chunks/157d9euci08yu.js +0 -1
  211. package/out/_next/static/chunks/18u58lorfahxi.js +0 -4
  212. package/out/_next/static/chunks/1_aahautsz2v_.js +0 -1
  213. package/out/_next/static/chunks/1o1d0p-v1z8ty.js +0 -1
  214. package/out/_next/static/chunks/1vdjn0pkoyypn.js +0 -1
  215. package/out/_next/static/chunks/1yehxf-fmeicg.js +0 -1
  216. package/out/_next/static/chunks/1zx2q-r32thv1.js +0 -4
  217. package/out/_next/static/chunks/2-sjjedfr0kfq.js +0 -1
  218. package/out/_next/static/chunks/25b9x-li-tvk2.js +0 -1
  219. package/out/_next/static/chunks/2aelw3far6rii.js +0 -1
  220. package/out/_next/static/chunks/2aor7m-wbis85.js +0 -1
  221. package/out/_next/static/chunks/2clzipqap01hp.js +0 -1
  222. package/out/_next/static/chunks/2fh-_9b6tqhvb.js +0 -1
  223. package/out/_next/static/chunks/2g5gecypj0rqe.js +0 -1
  224. package/out/_next/static/chunks/2szdcpl41-kzv.js +0 -1
  225. package/out/_next/static/chunks/2u6shh3oeycm-.js +0 -1
  226. package/out/_next/static/chunks/2unhhuv0arlcv.js +0 -1
  227. package/out/_next/static/chunks/2z5eqx5do5std.js +0 -1
  228. package/out/_next/static/chunks/310uz81hnnzsu.js +0 -1
  229. package/out/_next/static/chunks/3aqbf_wkg2sih.js +0 -3
  230. package/out/_next/static/chunks/3i3gbhccmhu7j.js +0 -210
  231. package/out/_next/static/chunks/3mqy-84_ul3t2.js +0 -1
  232. package/out/_next/static/chunks/3nz-dh9d7cehk.js +0 -1
  233. package/out/_next/static/chunks/3pufs8g4ui943.js +0 -1
  234. package/out/_next/static/chunks/3t06schbtqonl.js +0 -1
  235. package/out/_next/static/chunks/3v3-7fio3nw_t.js +0 -1
  236. package/out/_next/static/chunks/3v5ha25nxo43j.js +0 -1
  237. package/out/_next/static/chunks/3zskk1hxu3-_o.js +0 -1
  238. /package/out/_next/static/{vHD3x58R_2B6QWAhZXCg7 → M9ZSIaKJeBgkjz1qktYio}/_buildManifest.js +0 -0
  239. /package/out/_next/static/{vHD3x58R_2B6QWAhZXCg7 → M9ZSIaKJeBgkjz1qktYio}/_clientMiddlewareManifest.js +0 -0
  240. /package/out/_next/static/{vHD3x58R_2B6QWAhZXCg7 → M9ZSIaKJeBgkjz1qktYio}/_ssgManifest.js +0 -0
@@ -0,0 +1,1636 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,4357,e=>{"use strict";var i=e.i(12423);let t="helperFunctions",r=`const PI: f32=3.1415926535897932384626433832795;const TWO_PI: f32=6.283185307179586;const HALF_PI: f32=1.5707963267948966;const RECIPROCAL_PI: f32=0.3183098861837907;const RECIPROCAL_PI2: f32=0.15915494309189535;const RECIPROCAL_PI4: f32=0.07957747154594767;const HALF_MIN: f32=5.96046448e-08;
2
+ const LinearEncodePowerApprox: f32=2.2;const GammaEncodePowerApprox: f32=1.0/LinearEncodePowerApprox;const LuminanceEncodeApprox: vec3f=vec3f(0.2126,0.7152,0.0722);const Epsilon:f32=0.0000001;fn square(x: f32)->f32 {return x*x;}
3
+ fn saturate(x: f32)->f32 {return clamp(x,0.0,1.0);}
4
+ fn saturateVec3(x: vec3f)->vec3f {return clamp(x,vec3f(),vec3f(1.0));}
5
+ fn saturateEps(x: f32)->f32 {return clamp(x,Epsilon,1.0);}
6
+ fn maxEps(x: f32)->f32 {return max(x,Epsilon);}
7
+ fn maxEpsVec3(x: vec3f)->vec3f {return max(x,vec3f(Epsilon));}
8
+ fn absEps(x: f32)->f32 {return abs(x)+Epsilon;}
9
+ fn transposeMat3(inMatrix: mat3x3f)->mat3x3f {let i0: vec3f=inMatrix[0];let i1: vec3f=inMatrix[1];let i2: vec3f=inMatrix[2];let outMatrix:mat3x3f=mat3x3f(
10
+ vec3(i0.x,i1.x,i2.x),
11
+ vec3(i0.y,i1.y,i2.y),
12
+ vec3(i0.z,i1.z,i2.z)
13
+ );return outMatrix;}
14
+ fn inverseMat3(inMatrix: mat3x3f)->mat3x3f {let a00: f32=inMatrix[0][0];let a01: f32=inMatrix[0][1];let a02: f32=inMatrix[0][2];let a10: f32=inMatrix[1][0];let a11: f32=inMatrix[1][1];let a12: f32=inMatrix[1][2];let a20: f32=inMatrix[2][0];let a21: f32=inMatrix[2][1];let a22: f32=inMatrix[2][2];let b01: f32=a22*a11-a12*a21;let b11: f32=-a22*a10+a12*a20;let b21: f32=a21*a10-a11*a20;let det: f32=a00*b01+a01*b11+a02*b21;return mat3x3f(b01/det,(-a22*a01+a02*a21)/det,(a12*a01-a02*a11)/det,
15
+ b11/det,(a22*a00-a02*a20)/det,(-a12*a00+a02*a10)/det,
16
+ b21/det,(-a21*a00+a01*a20)/det,(a11*a00-a01*a10)/det);}
17
+ #if USE_EXACT_SRGB_CONVERSIONS
18
+ fn toLinearSpaceExact(color: vec3f)->vec3f
19
+ {let nearZeroSection: vec3f=0.0773993808*color;let remainingSection: vec3f=pow(0.947867299*(color+vec3f(0.055)),vec3f(2.4));return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3f(0.04045)));}
20
+ fn toGammaSpaceExact(color: vec3f)->vec3f
21
+ {let nearZeroSection: vec3f=12.92*color;let remainingSection: vec3f=1.055*pow(color,vec3f(0.41666))-vec3f(0.055);return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3f(0.0031308)));}
22
+ #endif
23
+ fn toLinearSpace(color: f32)->f32
24
+ {
25
+ #if USE_EXACT_SRGB_CONVERSIONS
26
+ var nearZeroSection=0.0773993808*color;var remainingSection=pow(0.947867299*(color+0.055),2.4);return select(remainingSection,nearZeroSection,color<=0.04045);
27
+ #else
28
+ return pow(color,LinearEncodePowerApprox);
29
+ #endif
30
+ }
31
+ fn toLinearSpaceVec3(color: vec3f)->vec3f
32
+ {
33
+ #if USE_EXACT_SRGB_CONVERSIONS
34
+ return toLinearSpaceExact(color);
35
+ #else
36
+ return pow(color,vec3f(LinearEncodePowerApprox));
37
+ #endif
38
+ }
39
+ fn toLinearSpaceVec4(color: vec4<f32>)->vec4<f32>
40
+ {
41
+ #if USE_EXACT_SRGB_CONVERSIONS
42
+ return vec4f(toLinearSpaceExact(color.rgb),color.a);
43
+ #else
44
+ return vec4f(pow(color.rgb,vec3f(LinearEncodePowerApprox)),color.a);
45
+ #endif
46
+ }
47
+ fn toGammaSpace(color: vec4<f32>)->vec4<f32>
48
+ {
49
+ #if USE_EXACT_SRGB_CONVERSIONS
50
+ return vec4<f32>(toGammaSpaceExact(color.rgb),color.a);
51
+ #else
52
+ return vec4<f32>(pow(color.rgb,vec3f(GammaEncodePowerApprox)),color.a);
53
+ #endif
54
+ }
55
+ fn toGammaSpaceVec3(color: vec3f)->vec3f
56
+ {
57
+ #if USE_EXACT_SRGB_CONVERSIONS
58
+ return toGammaSpaceExact(color);
59
+ #else
60
+ return pow(color,vec3f(GammaEncodePowerApprox));
61
+ #endif
62
+ }
63
+ fn squareVec3(value: vec3f)->vec3f
64
+ {return value*value;}
65
+ fn pow5(value: f32)->f32 {let sq: f32=value*value;return sq*sq*value;}
66
+ fn double_refract(I: vec3f,N: vec3f,eta: f32)->vec3f {let Tfront: vec3f=refract(I,N,1.0/eta);let Nback: vec3f=normalize(reflect(N,Tfront));return refract(Tfront,-Nback,eta);}
67
+ fn getLuminanceUnclamped(color: vec3f)->f32
68
+ {return dot(color,LuminanceEncodeApprox);}
69
+ fn getLuminance(color: vec3f)->f32
70
+ {return saturate(getLuminanceUnclamped(color));}
71
+ fn getRand(seed: vec2<f32>)->f32 {return fract(sin(dot(seed.xy ,vec2<f32>(12.9898,78.233)))*43758.5453);}
72
+ fn dither(seed: vec2<f32>,varianceAmount: f32)->f32 {let rand: f32=getRand(seed);let normVariance: f32=varianceAmount/255.0;let dither: f32=mix(-normVariance,normVariance,rand);return dither;}
73
+ const rgbdMaxRange: f32=255.0;fn toRGBD(color: vec3f)->vec4<f32> {let maxRGB: f32=max(max(color.r,max(color.g,color.b)),Epsilon);var D: f32 =max(rgbdMaxRange/maxRGB,1.);D =clamp(floor(D)/255.0,0.,1.);var rgb: vec3f =color.rgb*D;rgb=toGammaSpaceVec3(rgb);return vec4<f32>(saturateVec3(rgb),D);}
74
+ fn fromRGBD(rgbd: vec4<f32>)->vec3f {let rgb=toLinearSpaceVec3(rgbd.rgb);return rgb/rgbd.a;}
75
+ fn parallaxCorrectNormal(vertexPos: vec3f,origVec: vec3f,cubeSize: vec3f,cubePos: vec3f)->vec3f {let invOrigVec: vec3f=vec3f(1.)/origVec;let halfSize: vec3f=cubeSize*0.5;let intersecAtMaxPlane: vec3f=(cubePos+halfSize-vertexPos)*invOrigVec;let intersecAtMinPlane: vec3f=(cubePos-halfSize-vertexPos)*invOrigVec;let largestIntersec: vec3f=max(intersecAtMaxPlane,intersecAtMinPlane);let distance: f32=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);let intersectPositionWS: vec3f=vertexPos+origVec*distance;return intersectPositionWS-cubePos;}
76
+ fn equirectangularToCubemapDirection(uv : vec2f)->vec3f {var longitude : f32=uv.x*TWO_PI-PI;var latitude : f32=HALF_PI-uv.y*PI;var direction : vec3f;direction.x=cos(latitude)*sin(longitude);direction.y=sin(latitude);direction.z=cos(latitude)*cos(longitude);return direction;}
77
+ fn sqrtClamped(value: f32)->f32 {return sqrt(max(value,0.));}
78
+ fn avg(value: vec3f)->f32 {return dot(value,vec3f(0.333333333));}
79
+ fn singleScatterToMultiScatterAlbedo(rho_ss: vec3f)->vec3f {let s: vec3f=sqrt(max(vec3f(1.0)-rho_ss,vec3f(0.0)));return (vec3f(1.0)-s)*(vec3f(1.0)-vec3f(0.139)*s)/(vec3f(1.0)+vec3f(1.17)*s);}
80
+ fn multiScatterToSingleScatterAlbedo(rho_ms: vec3f)->vec3f {let s: vec3f=4.09712f+4.20863f*rho_ms-sqrt(9.59217f+41.6808f*rho_ms+17.7126f*rho_ms*rho_ms);return 1.0f-s*s;}
81
+ fn multiScatterToSingleScatterAlbedoWithAniso(rho_ms: vec3f,aniso: f32)->vec3f {let s: vec3f=4.09712+4.20863f*rho_ms-sqrt(9.59217f+41.6808f*rho_ms+17.7126f*rho_ms*rho_ms);return (vec3f(1.0f)-s*s)/maxEpsVec3(vec3f(1.0f)-vec3f(aniso)*s*s);}
82
+ fn min3(v: vec3f)->f32 {return min(v.x,min(v.y,v.z));}
83
+ fn max3(v: vec3f)->f32 {return max(v.x,max(v.y,v.z));}
84
+ fn uint2float(i: u32)->f32 {return bitcast<f32>(0x3F800000u | (i>>9u))-1.0;}
85
+ fn plasticSequence(rstate: u32)->vec2f {return vec2f(uint2float(rstate*3242174889u),
86
+ uint2float(rstate*2447445414u));}
87
+ `;i.ShaderStore.IncludesShadersStoreWGSL[t]||(i.ShaderStore.IncludesShadersStoreWGSL[t]=r),e.s(["helperFunctionsWGSL",0,{name:t,shader:r}])},60106,e=>{"use strict";var i=e.i(12423);let t="sceneUboDeclaration",r=`struct Scene {viewProjection : mat4x4<f32>,
88
+ #ifdef MULTIVIEW
89
+ viewProjectionR : mat4x4<f32>,
90
+ #endif
91
+ view : mat4x4<f32>,
92
+ projection : mat4x4<f32>,
93
+ vEyePosition : vec4<f32>,
94
+ inverseProjection : mat4x4<f32>,};
95
+ #define SCENE_UBO
96
+ var<uniform> scene : Scene;
97
+ `;i.ShaderStore.IncludesShadersStoreWGSL[t]||(i.ShaderStore.IncludesShadersStoreWGSL[t]=r),e.s(["sceneUboDeclarationWGSL",0,{name:t,shader:r}])},50008,39780,54758,e=>{"use strict";var i=e.i(12423);let t="meshUboDeclaration",r=`struct Mesh {world : mat4x4<f32>,
98
+ visibility : f32,};var<uniform> mesh : Mesh;
99
+ #define WORLD_UBO
100
+ `;i.ShaderStore.IncludesShadersStoreWGSL[t]||(i.ShaderStore.IncludesShadersStoreWGSL[t]=r),e.s(["meshUboDeclarationWGSL",0,{name:t,shader:r}],50008);let f="mainUVVaryingDeclaration",a=`#ifdef MAINUV{X}
101
+ varying vMainUV{X}: vec2f;
102
+ #endif
103
+ `;i.ShaderStore.IncludesShadersStoreWGSL[f]||(i.ShaderStore.IncludesShadersStoreWGSL[f]=a),e.s(["mainUVVaryingDeclarationWGSL",0,{name:f,shader:a}],39780);let n="logDepthDeclaration",o=`#ifdef LOGARITHMICDEPTH
104
+ uniform logarithmicDepthConstant: f32;varying vFragmentDepth: f32;
105
+ #endif
106
+ `;i.ShaderStore.IncludesShadersStoreWGSL[n]||(i.ShaderStore.IncludesShadersStoreWGSL[n]=o),e.s(["logDepthDeclarationWGSL",0,{name:n,shader:o}],54758)},99452,e=>{"use strict";var i=e.i(12423);let t="harmonicsFunctions",r=`#ifdef USESPHERICALFROMREFLECTIONMAP
107
+ #ifdef SPHERICAL_HARMONICS
108
+ fn computeEnvironmentIrradiance(normal: vec3f)->vec3f {return uniforms.vSphericalL00
109
+ + uniforms.vSphericalL1_1*(normal.y)
110
+ + uniforms.vSphericalL10*(normal.z)
111
+ + uniforms.vSphericalL11*(normal.x)
112
+ + uniforms.vSphericalL2_2*(normal.y*normal.x)
113
+ + uniforms.vSphericalL2_1*(normal.y*normal.z)
114
+ + uniforms.vSphericalL20*((3.0*normal.z*normal.z)-1.0)
115
+ + uniforms.vSphericalL21*(normal.z*normal.x)
116
+ + uniforms.vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));}
117
+ #else
118
+ fn computeEnvironmentIrradiance(normal: vec3f)->vec3f {var Nx: f32=normal.x;var Ny: f32=normal.y;var Nz: f32=normal.z;var C1: vec3f=uniforms.vSphericalZZ.rgb;var Cx: vec3f=uniforms.vSphericalX.rgb;var Cy: vec3f=uniforms.vSphericalY.rgb;var Cz: vec3f=uniforms.vSphericalZ.rgb;var Cxx_zz: vec3f=uniforms.vSphericalXX_ZZ.rgb;var Cyy_zz: vec3f=uniforms.vSphericalYY_ZZ.rgb;var Cxy: vec3f=uniforms.vSphericalXY.rgb;var Cyz: vec3f=uniforms.vSphericalYZ.rgb;var Czx: vec3f=uniforms.vSphericalZX.rgb;var a1: vec3f=Cyy_zz*Ny+Cy;var a2: vec3f=Cyz*Nz+a1;var b1: vec3f=Czx*Nz+Cx;var b2: vec3f=Cxy*Ny+b1;var b3: vec3f=Cxx_zz*Nx+b2;var t1: vec3f=Cz *Nz+C1;var t2: vec3f=a2 *Ny+t1;var t3: vec3f=b3 *Nx+t2;return t3;}
119
+ #endif
120
+ #endif
121
+ `;i.ShaderStore.IncludesShadersStoreWGSL[t]||(i.ShaderStore.IncludesShadersStoreWGSL[t]=r),e.s(["harmonicsFunctionsWGSL",0,{name:t,shader:r}])},61202,e=>{"use strict";var i=e.i(12423);let t="pbrBRDFFunctions",r=`#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
122
+ #define BRDF_DIFFUSE_MODEL_EON 0
123
+ #define BRDF_DIFFUSE_MODEL_BURLEY 1
124
+ #define BRDF_DIFFUSE_MODEL_LAMBERT 2
125
+ #define BRDF_DIFFUSE_MODEL_LEGACY 3
126
+ #define DIELECTRIC_SPECULAR_MODEL_GLTF 0
127
+ #define DIELECTRIC_SPECULAR_MODEL_OPENPBR 1
128
+ #define CONDUCTOR_SPECULAR_MODEL_GLTF 0
129
+ #define CONDUCTOR_SPECULAR_MODEL_OPENPBR 1
130
+ #if !defined(PBR_VERTEX_SHADER) && !defined(OPENPBR_VERTEX_SHADER)
131
+ #ifdef MS_BRDF_ENERGY_CONSERVATION
132
+ fn getEnergyConservationFactor(specularEnvironmentR0: vec3f,environmentBrdf: vec3f)->vec3f {return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);}
133
+ #endif
134
+ #if CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR
135
+ const F82_COS_THETA_MAX: f32 =0.142857143;const F82_ONE_MINUS_CTM_POW5: f32 =0.462664366;const F82_ONE_MINUS_CTM_POW6: f32 =0.396569457;const F82_B_DENOMINATOR_RECIP: f32 =17.6512785;const BRDF_Z_SCALE: f32 =16.0;fn getF82Specular(NdotV: f32,F0: vec3f,edgeTint: vec3f,roughness: f32)->vec3f {let white_minus_F0: vec3f=vec3f(1.0f)-F0;let b_numerator: vec3f=(F0+white_minus_F0*F82_ONE_MINUS_CTM_POW5)*(vec3f(1.0)-edgeTint);let b: vec3f=b_numerator*F82_B_DENOMINATOR_RECIP;let cos_theta: f32=max(roughness,NdotV);let one_minus_cos_theta: f32=1.0-cos_theta;let offset_from_F0: vec3f=(white_minus_F0-b*cos_theta*one_minus_cos_theta)*pow(one_minus_cos_theta,5.0f);return clamp(F0+offset_from_F0,vec3f(0.0f),vec3f(1.0f));}
136
+ fn getF82B(F0: vec3f,edgeTint: vec3f)->vec3f {return (F0+(vec3f(1.0)-F0)*F82_ONE_MINUS_CTM_POW5)*(vec3f(1.0)-edgeTint)*F82_B_DENOMINATOR_RECIP;}
137
+ fn getF82DirectionalAlbedo(F0: vec3f,F90: vec3f,b: vec3f,environmentBrdf: vec3f)->vec3f {return (F90-F0)*environmentBrdf.x+F0*environmentBrdf.y-b*environmentBrdf.z;}
138
+ fn getF82AverageFresnel(F0: vec3f,b: vec3f)->vec3f {return F0+(vec3f(1.0)-F0)/21.0-b/126.0;}
139
+ #endif
140
+ #ifdef FUZZENVIRONMENTBRDF
141
+ fn getFuzzBRDFLookup(NdotV: f32,perceptualRoughness: f32)->vec3f {let UV: vec2f=vec2f(perceptualRoughness,NdotV);var brdfLookup: vec4f=textureSample(environmentFuzzBrdfSampler,environmentFuzzBrdfSamplerSampler,UV);const RiRange: vec2f=vec2f(0.0f,0.75f);const ARange: vec2f=vec2f(0.005f,0.88f);const BRange: vec2f=vec2f(-0.18f,0.002f);brdfLookup.r=mix(ARange.x, ARange.y, brdfLookup.r);brdfLookup.g=mix(BRange.x, BRange.y, brdfLookup.g);brdfLookup.b=mix(RiRange.x,RiRange.y,brdfLookup.b);return brdfLookup.rgb;}
142
+ #endif
143
+ #ifdef ENVIRONMENTBRDF
144
+ fn getBRDFLookup(NdotV: f32,perceptualRoughness: f32)->vec3f {var UV: vec2f= vec2f(NdotV,perceptualRoughness);var brdfLookup: vec4f= textureSample(environmentBrdfSampler,environmentBrdfSamplerSampler,UV);
145
+ #ifdef ENVIRONMENTBRDF_RGBD
146
+ brdfLookup=vec4f(fromRGBD(brdfLookup.rgba),brdfLookup.a);
147
+ #endif
148
+ return brdfLookup.rgb;}
149
+ fn getReflectanceFromBRDFWithEnvLookup(specularEnvironmentR0: vec3f,specularEnvironmentR90: vec3f,environmentBrdf: vec3f)->vec3f {
150
+ #ifdef BRDF_V_HEIGHT_CORRELATED
151
+ var reflectance: vec3f=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;
152
+ #else
153
+ var reflectance: vec3f=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;
154
+ #endif
155
+ return reflectance;}
156
+ fn getReflectanceFromBRDFLookup(specularEnvironmentR0: vec3f,environmentBrdf: vec3f)->vec3f {
157
+ #ifdef BRDF_V_HEIGHT_CORRELATED
158
+ var reflectance: vec3f=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);
159
+ #else
160
+ var reflectance: vec3f=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;
161
+ #endif
162
+ return reflectance;}
163
+ #endif
164
+ /* NOT USED
165
+ #if defined(SHEEN) && defined(SHEEN_SOFTER)
166
+ fn getBRDFLookupCharlieSheen(NdotV: f32,perceptualRoughness: f32)->f32
167
+ {var c: f32=1.0-NdotV;var c3: f32=c*c*c;return 0.65584461*c3+1.0/(4.16526551+exp(-7.97291361*perceptualRoughness+6.33516894));}
168
+ #endif
169
+ */
170
+ #if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)
171
+ fn getReflectanceFromAnalyticalBRDFLookup_Jones(VdotN: f32,reflectance0: vec3f,reflectance90: vec3f,smoothness: f32)->vec3f
172
+ {var weight: f32=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));}
173
+ #endif
174
+ #if defined(SHEEN) && defined(ENVIRONMENTBRDF)
175
+ /**
176
+ * The sheen BRDF not containing F can be easily stored in the blue channel of the BRDF texture.
177
+ * The blue channel contains DCharlie*VAshikhmin*NdotL as a lokkup table
178
+ */
179
+ fn getSheenReflectanceFromBRDFLookup(reflectance0: vec3f,environmentBrdf: vec3f)->vec3f {var sheenEnvironmentReflectance: vec3f=reflectance0*environmentBrdf.b;return sheenEnvironmentReflectance;}
180
+ #endif
181
+ fn fresnelSchlickGGXVec3(VdotH: f32,reflectance0: vec3f,reflectance90: vec3f)->vec3f
182
+ {return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}
183
+ fn fresnelSchlickGGX(VdotH: f32,reflectance0: f32,reflectance90: f32)->f32
184
+ {return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}
185
+ #ifdef CLEARCOAT
186
+ fn getR0RemappedForClearCoat(f0: vec3f)->vec3f {
187
+ #ifdef CLEARCOAT_DEFAULTIOR
188
+ #ifdef MOBILE
189
+ return saturateVec3(f0*(f0*0.526868+0.529324)-0.0482256);
190
+ #else
191
+ return saturateVec3(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);
192
+ #endif
193
+ #else
194
+ var s: vec3f=sqrt(f0);var t: vec3f=(uniforms.vClearCoatRefractionParams.z+uniforms.vClearCoatRefractionParams.w*s)/(uniforms.vClearCoatRefractionParams.w+uniforms.vClearCoatRefractionParams.z*s);return squareVec3(t);
195
+ #endif
196
+ }
197
+ #endif
198
+ #ifdef IRIDESCENCE
199
+ const XYZ_TO_REC709: mat3x3f= mat3x3f(
200
+ 3.2404542,-0.9692660, 0.0556434,
201
+ -1.5371385, 1.8760108,-0.2040259,
202
+ -0.4985314, 0.0415560, 1.0572252
203
+ );fn getIORTfromAirToSurfaceR0(f0: vec3f)->vec3f {var sqrtF0: vec3f=sqrt(f0);return (1.+sqrtF0)/(1.-sqrtF0);}
204
+ fn getR0fromIORsVec3(iorT: vec3f,iorI: f32)->vec3f {return squareVec3((iorT- vec3f(iorI))/(iorT+ vec3f(iorI)));}
205
+ fn getR0fromIORs(iorT: f32,iorI: f32)->f32 {return square((iorT-iorI)/(iorT+iorI));}
206
+ fn evalSensitivity(opd: f32,shift: vec3f)->vec3f {var phase: f32=2.0*PI*opd*1.0e-9;const val: vec3f= vec3f(5.4856e-13,4.4201e-13,5.2481e-13);const pos: vec3f= vec3f(1.6810e+06,1.7953e+06,2.2084e+06);const vr: vec3f= vec3f(4.3278e+09,9.3046e+09,6.6121e+09);var xyz: vec3f=val*sqrt(2.0*PI*vr)*cos(pos*phase+shift)*exp(-square(phase)*vr);xyz.x+=9.7470e-14*sqrt(2.0*PI*4.5282e+09)*cos(2.2399e+06*phase+shift[0])*exp(-4.5282e+09*square(phase));xyz/=1.0685e-7;var srgb: vec3f=XYZ_TO_REC709*xyz;return srgb;}
207
+ fn evalIridescence(outsideIOR: f32,eta2: f32,cosTheta1: f32,thinFilmThickness: f32,baseF0: vec3f)->vec3f {var I: vec3f= vec3f(1.0);var iridescenceIOR: f32=mix(outsideIOR,eta2,smoothstep(0.0,0.03,thinFilmThickness));var sinTheta2Sq: f32=square(outsideIOR/iridescenceIOR)*(1.0-square(cosTheta1));var cosTheta2Sq: f32=1.0-sinTheta2Sq;if (cosTheta2Sq<0.0) {return I;}
208
+ var cosTheta2: f32=sqrt(cosTheta2Sq);var R0: f32=getR0fromIORs(iridescenceIOR,outsideIOR);var R12: f32=fresnelSchlickGGX(cosTheta1,R0,1.);var R21: f32=R12;var T121: f32=1.0-R12;var phi12: f32=0.0;if (iridescenceIOR<outsideIOR) {phi12=PI;}
209
+ var phi21: f32=PI-phi12;var baseIOR: vec3f=getIORTfromAirToSurfaceR0(clamp(baseF0,vec3f(0.0),vec3f(0.9999)));
210
+ var R1: vec3f=getR0fromIORsVec3(baseIOR,iridescenceIOR);let maxR1: f32=max(R1.r,max(R1.g,R1.b));if (maxR1<1e-6) {return max(vec3f(R12),vec3f(0.0));}
211
+ var R23: vec3f=fresnelSchlickGGXVec3(cosTheta2,R1,vec3f(1.));var phi23: vec3f=vec3f(0.0);if (baseIOR[0]<iridescenceIOR) {phi23[0]=PI;}
212
+ if (baseIOR[1]<iridescenceIOR) {phi23[1]=PI;}
213
+ if (baseIOR[2]<iridescenceIOR) {phi23[2]=PI;}
214
+ var opd: f32=2.0*iridescenceIOR*thinFilmThickness*cosTheta2;var phi: vec3f=vec3f(phi21)+phi23;var R123: vec3f=clamp(R12*R23,vec3f(1e-5),vec3f(0.9999));var r123: vec3f=sqrt(R123);var Rs: vec3f=(T121*T121)*R23/(vec3f(1.0)-R123);var C0: vec3f=R12+Rs;I=C0;var Cm: vec3f=Rs-T121;for (var m: i32=1; m<=2; m++)
215
+ {Cm*=r123;var Sm: vec3f=2.0*evalSensitivity(f32(m)*opd,f32(m)*phi);I+=Cm*Sm;}
216
+ return max(I,vec3f(0.0));}
217
+ #endif
218
+ fn normalDistributionFunction_TrowbridgeReitzGGX(NdotH: f32,alphaG: f32)->f32
219
+ {var a2: f32=alphaG*alphaG;var d: f32=NdotH*NdotH*(a2-1.0)+1.0;return a2/(PI*d*d);}
220
+ #ifdef SHEEN
221
+ fn normalDistributionFunction_CharlieSheen(NdotH: f32,alphaG: f32)->f32
222
+ {var invR: f32=1./alphaG;var cos2h: f32=NdotH*NdotH;var sin2h: f32=1.-cos2h;return (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);}
223
+ #endif
224
+ #ifdef ANISOTROPIC
225
+ fn normalDistributionFunction_BurleyGGX_Anisotropic(NdotH: f32,TdotH: f32,BdotH: f32,alphaTB: vec2f)->f32 {var a2: f32=alphaTB.x*alphaTB.y;var v: vec3f= vec3f(alphaTB.y*TdotH,alphaTB.x *BdotH,a2*NdotH);var v2: f32=dot(v,v);var w2: f32=a2/v2;return a2*w2*w2*RECIPROCAL_PI;}
226
+ #endif
227
+ #ifdef BRDF_V_HEIGHT_CORRELATED
228
+ fn smithVisibility_GGXCorrelated(NdotL: f32,NdotV: f32,alphaG: f32)->f32 {
229
+ #ifdef MOBILE
230
+ var GGXV: f32=NdotL*(NdotV*(1.0-alphaG)+alphaG);var GGXL: f32=NdotV*(NdotL*(1.0-alphaG)+alphaG);return 0.5/(GGXV+GGXL);
231
+ #else
232
+ var a2: f32=alphaG*alphaG;var GGXV: f32=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);var GGXL: f32=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);return 0.5/(GGXV+GGXL);
233
+ #endif
234
+ }
235
+ #else
236
+ fn smithVisibilityG1_TrowbridgeReitzGGXFast(dot: f32,alphaG: f32)->f32
237
+ {
238
+ #ifdef MOBILE
239
+ return 1.0/(dot+alphaG+(1.0-alphaG)*dot ));
240
+ #else
241
+ var alphaSquared: f32=alphaG*alphaG;return 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));
242
+ #endif
243
+ }
244
+ fn smithVisibility_TrowbridgeReitzGGXFast(NdotL: f32,NdotV: f32,alphaG: f32)->f32
245
+ {var visibility: f32=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);return visibility;}
246
+ #endif
247
+ #ifdef ANISOTROPIC
248
+ fn smithVisibility_GGXCorrelated_Anisotropic(NdotL: f32,NdotV: f32,TdotV: f32,BdotV: f32,TdotL: f32,BdotL: f32,alphaTB: vec2f)->f32 {var lambdaV: f32=NdotL*length( vec3f(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));var lambdaL: f32=NdotV*length( vec3f(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));var v: f32=0.5/(lambdaV+lambdaL);return v;}
249
+ #endif
250
+ #ifdef CLEARCOAT
251
+ fn visibility_Kelemen(VdotH: f32)->f32 {return 0.25/(VdotH*VdotH); }
252
+ #endif
253
+ #ifdef SHEEN
254
+ fn visibility_Ashikhmin(NdotL: f32,NdotV: f32)->f32
255
+ {return 1./(4.*(NdotL+NdotV-NdotL*NdotV));}
256
+ /* NOT USED
257
+ #ifdef SHEEN_SOFTER
258
+ fn l(x: f32,alphaG: f32)->f32
259
+ {var oneMinusAlphaSq: f32=(1.0-alphaG)*(1.0-alphaG);var a: f32=mix(21.5473,25.3245,oneMinusAlphaSq);var b: f32=mix(3.82987,3.32435,oneMinusAlphaSq);var c: f32=mix(0.19823,0.16801,oneMinusAlphaSq);var d: f32=mix(-1.97760,-1.27393,oneMinusAlphaSq);var e: f32=mix(-4.32054,-4.85967,oneMinusAlphaSq);return a/(1.0+b*pow(x,c))+d*x+e;}
260
+ fn lambdaSheen(cosTheta: f32,alphaG: f32)->f32
261
+ {return abs(cosTheta)<0.5 ? exp(l(cosTheta,alphaG)) : exp(2.0*l(0.5,alphaG)-l(1.0-cosTheta,alphaG));}
262
+ fn visibility_CharlieSheen(NdotL: f32,NdotV: f32,alphaG: f32)->f32
263
+ {var G: f32=1.0/(1.0+lambdaSheen(NdotV,alphaG)+lambdaSheen(NdotL,alphaG));return G/(4.0*NdotV*NdotL);}
264
+ #endif
265
+ */
266
+ #endif
267
+ const constant1_FON: f32=0.5f-2.0f/(3.0f*PI);const constant2_FON: f32=2.0f/3.0f-28.0f/(15.0f*PI);fn E_FON_approx(mu: f32,roughness: f32)->f32
268
+ {var sigma: f32=roughness;
269
+ var mucomp: f32=1.0f-mu;var mucomp2: f32=mucomp*mucomp;const Gcoeffs: mat2x2f=mat2x2f(0.0571085289f,-0.332181442f,
270
+ 0.491881867f,0.0714429953f);var GoverPi: f32=dot(Gcoeffs*vec2f(mucomp,mucomp2),vec2f(1.0f,mucomp2));return (1.0f+sigma*GoverPi)/(1.0f+constant1_FON*sigma);}
271
+ fn diffuseBRDF_EON(albedo: vec3f,roughness: f32,NdotL: f32,NdotV: f32,LdotV: f32)->vec3f
272
+ {var rho: vec3f=albedo;var sigma: f32=roughness;
273
+ var mu_i: f32=NdotL;
274
+ var mu_o: f32=NdotV;
275
+ var s: f32=LdotV-mu_i*mu_o;
276
+ var sovertF: f32=select(s,s/max(mu_i,mu_o),s>0.0f);
277
+ var AF: f32=1.0f/(1.0f+constant1_FON*sigma);
278
+ var f_ss: vec3f=(rho*RECIPROCAL_PI)*AF*(1.0f+sigma*sovertF);
279
+ var EFo: f32=E_FON_approx(mu_o,sigma);
280
+ var EFi: f32=E_FON_approx(mu_i,sigma);
281
+ var avgEF: f32=AF*(1.0f+constant2_FON*sigma);
282
+ var rho_ms: vec3f=(rho*rho)*avgEF/(vec3f(1.0f)-rho*(1.0f-avgEF));const eps: f32=1.0e-7f;var f_ms: vec3f=(rho_ms*RECIPROCAL_PI)*max(eps,1.0f-EFo)
283
+ * max(eps,1.0f-EFi)
284
+ / max(eps,1.0f-avgEF);return (f_ss+f_ms);}
285
+ fn diffuseBRDF_Burley(NdotL: f32,NdotV: f32,VdotH: f32,roughness: f32)->f32 {var diffuseFresnelNV: f32=pow5(saturateEps(1.0-NdotL));var diffuseFresnelNL: f32=pow5(saturateEps(1.0-NdotV));var diffuseFresnel90: f32=0.5+2.0*VdotH*VdotH*roughness;var fresnel: f32 =
286
+ (1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *
287
+ (1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);return fresnel/PI;}
288
+ #ifdef SS_TRANSLUCENCY
289
+ fn transmittanceBRDF_Burley(tintColor: vec3f,diffusionDistance: vec3f,thickness: f32)->vec3f {var S: vec3f=1./maxEpsVec3(diffusionDistance);var temp: vec3f=exp((-0.333333333*thickness)*S);return tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);}
290
+ fn computeWrappedDiffuseNdotL(NdotL: f32,w: f32)->f32 {var t: f32=1.0+w;var invt2: f32=1.0/(t*t);return saturate((NdotL+w)*invt2);}
291
+ #endif
292
+ #endif
293
+ `;i.ShaderStore.IncludesShadersStoreWGSL[t]||(i.ShaderStore.IncludesShadersStoreWGSL[t]=r),e.s(["pbrBRDFFunctionsWGSL",0,{name:t,shader:r}])},66854,e=>{"use strict";var i=e.i(12423);e.i(60106),e.i(50008);let t="pbrUboDeclaration",r=`uniform vAlbedoInfos: vec2f;uniform vBaseWeightInfos: vec2f;uniform vBaseDiffuseRoughnessInfos: vec2f;uniform vAmbientInfos: vec4f;uniform vOpacityInfos: vec2f;uniform vEmissiveInfos: vec2f;uniform vLightmapInfos: vec2f;uniform vReflectivityInfos: vec3f;uniform vMicroSurfaceSamplerInfos: vec2f;uniform vBumpInfos: vec3f;uniform albedoMatrix: mat4x4f;uniform baseWeightMatrix: mat4x4f;uniform baseDiffuseRoughnessMatrix: mat4x4f;uniform ambientMatrix: mat4x4f;uniform opacityMatrix: mat4x4f;uniform emissiveMatrix: mat4x4f;uniform lightmapMatrix: mat4x4f;uniform reflectivityMatrix: mat4x4f;uniform microSurfaceSamplerMatrix: mat4x4f;uniform bumpMatrix: mat4x4f;uniform vTangentSpaceParams: vec2f;uniform vAlbedoColor: vec4f;uniform baseWeight: f32;uniform baseDiffuseRoughness: f32;uniform vLightingIntensity: vec4f;uniform pointSize: f32;uniform vReflectivityColor: vec4f;uniform vEmissiveColor: vec3f;uniform vAmbientColor: vec3f;uniform vDebugMode: vec2f;uniform vMetallicReflectanceFactors: vec4f;uniform vMetallicReflectanceInfos: vec2f;uniform metallicReflectanceMatrix: mat4x4f;uniform vReflectanceInfos: vec2f;uniform reflectanceMatrix: mat4x4f;uniform cameraInfo: vec4f;uniform vTextureRepetitionHexTilingParams: vec4f;uniform vReflectionInfos: vec2f;uniform reflectionMatrix: mat4x4f;uniform vReflectionMicrosurfaceInfos: vec3f;uniform vReflectionPosition: vec3f;uniform vReflectionSize: vec3f;uniform vReflectionFilteringInfo: vec2f;uniform vReflectionDominantDirection: vec3f;uniform vReflectionColor: vec3f;uniform vSphericalL00: vec3f;uniform vSphericalL1_1: vec3f;uniform vSphericalL10: vec3f;uniform vSphericalL11: vec3f;uniform vSphericalL2_2: vec3f;uniform vSphericalL2_1: vec3f;uniform vSphericalL20: vec3f;uniform vSphericalL21: vec3f;uniform vSphericalL22: vec3f;uniform vSphericalX: vec3f;uniform vSphericalY: vec3f;uniform vSphericalZ: vec3f;uniform vSphericalXX_ZZ: vec3f;uniform vSphericalYY_ZZ: vec3f;uniform vSphericalZZ: vec3f;uniform vSphericalXY: vec3f;uniform vSphericalYZ: vec3f;uniform vSphericalZX: vec3f;
294
+ #define ADDITIONAL_UBO_DECLARATION
295
+ #include<sceneUboDeclaration>
296
+ #include<meshUboDeclaration>
297
+ `;i.ShaderStore.IncludesShadersStoreWGSL[t]||(i.ShaderStore.IncludesShadersStoreWGSL[t]=r),e.s(["pbrUboDeclarationWGSL",0,{name:t,shader:r}])},28657,78875,23344,e=>{"use strict";var i=e.i(12423);let t="bumpFragmentMainFunctions",r=`#ifndef TEXRD_DEFINED
298
+ fn TEXRD(t: texture_2d<f32>,ts: sampler,uv: vec2f)->vec4f {return textureSample(t,ts,uv);}
299
+ #define TEXRD_DEFINED
300
+ #endif
301
+ #if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)
302
+ #if defined(TANGENT) && defined(NORMAL)
303
+ varying vTBN0: vec3f;varying vTBN1: vec3f;varying vTBN2: vec3f;
304
+ #endif
305
+ #ifdef OBJECTSPACE_NORMALMAP
306
+ uniform normalMatrix: mat4x4f;fn toNormalMatrix(m: mat4x4f)->mat4x4f
307
+ {var a00=m[0][0];var a01=m[0][1];var a02=m[0][2];var a03=m[0][3];var a10=m[1][0];var a11=m[1][1];var a12=m[1][2];var a13=m[1][3];var a20=m[2][0];
308
+ var a21=m[2][1];var a22=m[2][2];var a23=m[2][3];var a30=m[3][0];
309
+ var a31=m[3][1];var a32=m[3][2];var a33=m[3][3];var b00=a00*a11-a01*a10;var b01=a00*a12-a02*a10;var b02=a00*a13-a03*a10;var b03=a01*a12-a02*a11;var b04=a01*a13-a03*a11;var b05=a02*a13-a03*a12;var b06=a20*a31-a21*a30;var b07=a20*a32-a22*a30;var b08=a20*a33-a23*a30;var b09=a21*a32-a22*a31;var b10=a21*a33-a23*a31;var b11=a22*a33-a23*a32;var det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;var mi=mat4x4<f32>(
310
+ (a11*b11-a12*b10+a13*b09)/det,
311
+ (a02*b10-a01*b11-a03*b09)/det,
312
+ (a31*b05-a32*b04+a33*b03)/det,
313
+ (a22*b04-a21*b05-a23*b03)/det,
314
+ (a12*b08-a10*b11-a13*b07)/det,
315
+ (a00*b11-a02*b08+a03*b07)/det,
316
+ (a32*b02-a30*b05-a33*b01)/det,
317
+ (a20*b05-a22*b02+a23*b01)/det,
318
+ (a10*b10-a11*b08+a13*b06)/det,
319
+ (a01*b08-a00*b10-a03*b06)/det,
320
+ (a30*b04-a31*b02+a33*b00)/det,
321
+ (a21*b02-a20*b04-a23*b00)/det,
322
+ (a11*b07-a10*b09-a12*b06)/det,
323
+ (a00*b09-a01*b07+a02*b06)/det,
324
+ (a31*b01-a30*b03-a32*b00)/det,
325
+ (a20*b03-a21*b01+a22*b00)/det);return mat4x4<f32>(mi[0][0],mi[1][0],mi[2][0],mi[3][0],
326
+ mi[0][1],mi[1][1],mi[2][1],mi[3][1],
327
+ mi[0][2],mi[1][2],mi[2][2],mi[3][2],
328
+ mi[0][3],mi[1][3],mi[2][3],mi[3][3]);}
329
+ #endif
330
+ fn perturbNormalBase(cotangentFrame: mat3x3f,normal: vec3f,scale: f32)->vec3f
331
+ {var output=normal;
332
+ #ifdef NORMALXYSCALE
333
+ output=normalize(output* vec3f(scale,scale,1.0));
334
+ #endif
335
+ return normalize(cotangentFrame*output);}
336
+ fn perturbNormal(cotangentFrame: mat3x3f,textureSample: vec3f,scale: f32)->vec3f
337
+ {return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);}
338
+ fn cotangent_frame(normal: vec3f,p: vec3f,uv: vec2f,tangentSpaceParams: vec2f)->mat3x3f
339
+ {var dp1: vec3f=dpdx(p);var dp2: vec3f=dpdy(p);var duv1: vec2f=dpdx(uv);var duv2: vec2f=dpdy(uv);var dp2perp: vec3f=cross(dp2,normal);var dp1perp: vec3f=cross(normal,dp1);var tangent: vec3f=dp2perp*duv1.x+dp1perp*duv2.x;var bitangent: vec3f=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;var det: f32=max(dot(tangent,tangent),dot(bitangent,bitangent));var invmax: f32=select(inverseSqrt(det),0.0,det==0.0);return mat3x3f(tangent*invmax,bitangent*invmax,normal);}
340
+ #endif
341
+ `;i.ShaderStore.IncludesShadersStoreWGSL[t]||(i.ShaderStore.IncludesShadersStoreWGSL[t]=r),e.s(["bumpFragmentMainFunctionsWGSL",0,{name:t,shader:r}],28657),e.i(67367);let f="bumpFragmentFunctions",a=`#if defined(BUMP)
342
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)
343
+ #endif
344
+ #if defined(DETAIL)
345
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
346
+ #endif
347
+ #if defined(BUMP) && defined(PARALLAX)
348
+ const minSamples: f32=4.;const maxSamples: f32=15.;const iMaxSamples: i32=15;fn parallaxOcclusion(vViewDirCoT: vec3f,vNormalCoT: vec3f,texCoord: vec2f,parallaxScale: f32)->vec2f {var parallaxLimit: f32=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;var vOffsetDir: vec2f=normalize(vViewDirCoT.xy);var vMaxOffset: vec2f=vOffsetDir*parallaxLimit;var numSamples: f32=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));var stepSize: f32=1.0/numSamples;var currRayHeight: f32=1.0;var vCurrOffset: vec2f= vec2f(0,0);var vLastOffset: vec2f= vec2f(0,0);var lastSampledHeight: f32=1.0;var currSampledHeight: f32=1.0;var keepWorking: bool=true;for (var i: i32=0; i<iMaxSamples; i++)
349
+ {currSampledHeight=textureSample(bumpSampler,bumpSamplerSampler,texCoord+vCurrOffset).w;if (!keepWorking)
350
+ {}
351
+ else if (currSampledHeight>currRayHeight)
352
+ {var delta1: f32=currSampledHeight-currRayHeight;var delta2: f32=(currRayHeight+stepSize)-lastSampledHeight;var ratio: f32=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;}
353
+ else
354
+ {currRayHeight-=stepSize;vLastOffset=vCurrOffset;
355
+ #ifdef PARALLAX_RHS
356
+ vCurrOffset-=stepSize*vMaxOffset;
357
+ #else
358
+ vCurrOffset+=stepSize*vMaxOffset;
359
+ #endif
360
+ lastSampledHeight=currSampledHeight;}}
361
+ return vCurrOffset;}
362
+ fn parallaxOffset(viewDir: vec3f,heightScale: f32)->vec2f
363
+ {var height: f32=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).w;var texCoordOffset: vec2f=heightScale*viewDir.xy*height;
364
+ #ifdef PARALLAX_RHS
365
+ return texCoordOffset;
366
+ #else
367
+ return -texCoordOffset;
368
+ #endif
369
+ }
370
+ #endif
371
+ `;i.ShaderStore.IncludesShadersStoreWGSL[f]||(i.ShaderStore.IncludesShadersStoreWGSL[f]=a),e.s(["bumpFragmentFunctionsWGSL",0,{name:f,shader:a}],78875);let n="bumpFragment",o=`var uvOffset: vec2f= vec2f(0.0,0.0);
372
+ #if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)
373
+ #ifdef NORMALXYSCALE
374
+ var normalScale: f32=1.0;
375
+ #elif defined(BUMP)
376
+ var normalScale: f32=uniforms.vBumpInfos.y;
377
+ #else
378
+ var normalScale: f32=1.0;
379
+ #endif
380
+ #if defined(TANGENT) && defined(NORMAL)
381
+ var TBN: mat3x3f=mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2);
382
+ #elif defined(BUMP)
383
+ var TBNUV: vec2f=select(-fragmentInputs.vBumpUV,fragmentInputs.vBumpUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV,uniforms.vTangentSpaceParams);
384
+ #else
385
+ var TBNUV: vec2f=select(-fragmentInputs.vDetailUV,fragmentInputs.vDetailUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV, vec2f(1.,1.));
386
+ #endif
387
+ #elif defined(ANISOTROPIC)
388
+ #if defined(TANGENT) && defined(NORMAL)
389
+ var TBN: mat3x3f=mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2);
390
+ #else
391
+ var TBNUV: vec2f=select( -fragmentInputs.vMainUV1,fragmentInputs.vMainUV1,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW,input.vPositionW,TBNUV, vec2f(1.,1.));
392
+ #endif
393
+ #endif
394
+ #ifdef PARALLAX
395
+ var invTBN: mat3x3f=transposeMat3(TBN);
396
+ #ifdef PARALLAXOCCLUSION
397
+ uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,fragmentInputs.vBumpUV,uniforms.vBumpInfos.z);
398
+ #else
399
+ uvOffset=parallaxOffset(invTBN*viewDirectionW,uniforms.vBumpInfos.z);
400
+ #endif
401
+ #endif
402
+ #ifdef DETAIL
403
+ var detailColor: vec4f=textureSample(detailSampler,detailSamplerSampler,fragmentInputs.vDetailUV+uvOffset);var detailNormalRG: vec2f=detailColor.wy*2.0-1.0;var detailNormalB: f32=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));var detailNormal: vec3f= vec3f(detailNormalRG,detailNormalB);
404
+ #endif
405
+ #ifdef BUMP
406
+ #ifdef OBJECTSPACE_NORMALMAP
407
+ #define CUSTOM_FRAGMENT_BUMP_FRAGMENT
408
+ normalW=normalize(TEXRD(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).xyz *2.0-1.0);normalW=normalize(mat3x3f(uniforms.normalMatrix[0].xyz,uniforms.normalMatrix[1].xyz,uniforms.normalMatrix[2].xyz)*normalW);
409
+ #elif !defined(DETAIL)
410
+ normalW=perturbNormal(TBN,TEXRD(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV+uvOffset).xyz,uniforms.vBumpInfos.y);
411
+ #else
412
+ var bumpNormal: vec3f=TEXRD(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV+uvOffset).xyz*2.0-1.0;
413
+ #if DETAIL_NORMALBLENDMETHOD==0
414
+ detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);var blendedNormal: vec3f=normalize( vec3f(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));
415
+ #elif DETAIL_NORMALBLENDMETHOD==1
416
+ detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);bumpNormal+= vec3f(0.0,0.0,1.0);detailNormal*= vec3f(-1.0,-1.0,1.0);var blendedNormal: vec3f=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;
417
+ #endif
418
+ normalW=perturbNormalBase(TBN,blendedNormal,uniforms.vBumpInfos.y);
419
+ #endif
420
+ #elif defined(DETAIL)
421
+ detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);normalW=perturbNormalBase(TBN,detailNormal,uniforms.vDetailInfos.z);
422
+ #endif
423
+ `;i.ShaderStore.IncludesShadersStoreWGSL[n]||(i.ShaderStore.IncludesShadersStoreWGSL[n]=o),e.s(["bumpFragmentWGSL",0,{name:n,shader:o}],23344)},21439,49692,e=>{"use strict";var i=e.i(12423);let t="decalFragment",r=`#ifdef DECAL
424
+ var decalTempColor=decalColor.rgb;var decalTempAlpha=decalColor.a;
425
+ #ifdef GAMMADECAL
426
+ decalTempColor=toLinearSpaceVec3(decalColor.rgb);
427
+ #endif
428
+ #ifdef DECAL_SMOOTHALPHA
429
+ decalTempAlpha=decalColor.a*decalColor.a;
430
+ #endif
431
+ surfaceAlbedo=mix(surfaceAlbedo.rgb,decalTempColor,decalTempAlpha);
432
+ #endif
433
+ `;i.ShaderStore.IncludesShadersStoreWGSL[t]||(i.ShaderStore.IncludesShadersStoreWGSL[t]=r),e.s(["decalFragmentWGSL",0,{name:t,shader:r}],21439);let f="lightFragment",a=`#ifdef LIGHT{X}
434
+ #if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
435
+ #else
436
+ var diffuse{X}: vec4f=light{X}.vLightDiffuse;
437
+ #define CUSTOM_LIGHT{X}_COLOR
438
+ #if defined(PBR) && defined(CLUSTLIGHT{X})
439
+ {let sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,fragmentInputs.vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting(
440
+ lightDataTexture{X},
441
+ &tileMaskBuffer{X},
442
+ light{X}.vLightData,
443
+ vec2u(light{X}.vSliceRanges[sliceIndex].xy),
444
+ viewDirectionW,
445
+ normalW,
446
+ fragmentInputs.vPositionW,
447
+ surfaceAlbedo,
448
+ reflectivityOut,
449
+ #ifdef IRIDESCENCE
450
+ iridescenceIntensity,
451
+ #endif
452
+ #ifdef SS_TRANSLUCENCY
453
+ subSurfaceOut,
454
+ #endif
455
+ #ifdef SPECULARTERM
456
+ AARoughnessFactors.x,
457
+ #endif
458
+ #ifdef ANISOTROPIC
459
+ anisotropicOut,
460
+ #endif
461
+ #ifdef SHEEN
462
+ sheenOut,
463
+ #endif
464
+ #ifdef CLEARCOAT
465
+ clearcoatOut,
466
+ #endif
467
+ );}
468
+ #elif defined(PBR)
469
+ #ifdef SPOTLIGHT{X}
470
+ preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW);
471
+ #elif defined(POINTLIGHT{X})
472
+ preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW);
473
+ #elif defined(HEMILIGHT{X})
474
+ preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
475
+ #elif defined(DIRLIGHT{X})
476
+ preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
477
+ #elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
478
+ #if defined(RECTAREALIGHTEMISSIONTEXTURE{X})
479
+ preInfo=computeAreaPreLightingInfoWithTexture(areaLightsLTC1Sampler,areaLightsLTC1SamplerSampler,areaLightsLTC2Sampler,areaLightsLTC2SamplerSampler,rectAreaLightEmissionTexture{X},rectAreaLightEmissionTexture{X}Sampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,roughness);
480
+ #else
481
+ preInfo=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC1SamplerSampler,areaLightsLTC2Sampler,areaLightsLTC2SamplerSampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,roughness);
482
+ #endif
483
+ #endif
484
+ preInfo.NdotV=NdotV;
485
+ #ifdef SPOTLIGHT{X}
486
+ #ifdef LIGHT_FALLOFF_GLTF{X}
487
+ preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
488
+ #ifdef IESLIGHTTEXTURE{X}
489
+ preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X},iesLightTexture{X}Sampler);
490
+ #else
491
+ preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
492
+ #endif
493
+ #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
494
+ preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
495
+ #ifdef IESLIGHTTEXTURE{X}
496
+ preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X},iesLightTexture{X}Sampler);
497
+ #else
498
+ preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);
499
+ #endif
500
+ #elif defined(LIGHT_FALLOFF_STANDARD{X})
501
+ preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
502
+ #ifdef IESLIGHTTEXTURE{X}
503
+ preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X},iesLightTexture{X}Sampler);
504
+ #else
505
+ preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
506
+ #endif
507
+ #else
508
+ preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
509
+ #ifdef IESLIGHTTEXTURE{X}
510
+ preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X},iesLightTexture{X}Sampler);
511
+ #else
512
+ preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
513
+ #endif
514
+ #endif
515
+ #elif defined(POINTLIGHT{X})
516
+ #ifdef LIGHT_FALLOFF_GLTF{X}
517
+ preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
518
+ #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
519
+ preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
520
+ #elif defined(LIGHT_FALLOFF_STANDARD{X})
521
+ preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
522
+ #else
523
+ preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
524
+ #endif
525
+ #else
526
+ preInfo.attenuation=1.0;
527
+ #endif
528
+ #if defined(HEMILIGHT{X})
529
+ preInfo.roughness=roughness;
530
+ #elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
531
+ preInfo.roughness=roughness;
532
+ #else
533
+ preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
534
+ #endif
535
+ preInfo.diffuseRoughness=diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo;
536
+ #ifdef IRIDESCENCE
537
+ preInfo.iridescenceIntensity=iridescenceIntensity;
538
+ #endif
539
+ #ifdef SS_TRANSLUCENCY
540
+ info.diffuseTransmission=vec3f(0.0);
541
+ #endif
542
+ #ifdef HEMILIGHT{X}
543
+ info.diffuse=computeHemisphericDiffuseLighting(preInfo,diffuse{X}.rgb,light{X}.vLightGround);
544
+ #elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
545
+ info.diffuse=computeAreaDiffuseLighting(preInfo,diffuse{X}.rgb);
546
+ #elif defined(SS_TRANSLUCENCY)
547
+ #ifndef SS_TRANSLUCENCY_LEGACY
548
+ info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance);
549
+ #else
550
+ info.diffuse=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance);
551
+ #endif
552
+ #else
553
+ info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb);
554
+ #endif
555
+ #ifdef SPECULARTERM
556
+ #if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
557
+ info.specular=computeAreaSpecularLighting(preInfo,light{X}.vLightSpecular.rgb,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90);
558
+ #else
559
+ #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
560
+ {let metalFresnel: vec3f=vec3f(reflectivityOut.specularWeight)*getF82Specular(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);let dielectricFresnel: vec3f=fresnelSchlickGGXVec3(preInfo.VdotH,reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90);coloredFresnel=mix(dielectricFresnel,metalFresnel,reflectivityOut.metallic);}
561
+ #else
562
+ coloredFresnel=fresnelSchlickGGXVec3(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90);
563
+ #endif
564
+ #ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION
565
+ {let NdotH: f32=dot(normalW,preInfo.H);let fresnel: vec3f=fresnelSchlickGGXVec3(NdotH,vec3f(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3f(1.0)-fresnel);}
566
+ #endif
567
+ #ifdef ANISOTROPIC
568
+ info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
569
+ #else
570
+ info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,coloredFresnel,AARoughnessFactors.x,diffuse{X}.rgb);
571
+ #endif
572
+ #endif
573
+ #endif
574
+ #ifndef AREALIGHT{X}
575
+ #ifdef SHEEN
576
+ #ifdef SHEEN_LINKWITHALBEDO
577
+ preInfo.roughness=sheenOut.sheenIntensity;
578
+ #else
579
+ #ifdef HEMILIGHT{X}
580
+ preInfo.roughness=sheenOut.sheenRoughness;
581
+ #else
582
+ preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
583
+ #endif
584
+ #endif
585
+ info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb);
586
+ #endif
587
+ #ifdef CLEARCOAT
588
+ #ifdef HEMILIGHT{X}
589
+ preInfo.roughness=clearcoatOut.clearCoatRoughness;
590
+ #else
591
+ preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
592
+ #endif
593
+ info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,diffuse{X}.rgb);
594
+ #ifdef CLEARCOAT_TINT
595
+ absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;
596
+ #ifdef SS_TRANSLUCENCY
597
+ info.diffuseTransmission*=absorption;
598
+ #endif
599
+ #ifdef SPECULARTERM
600
+ info.specular*=absorption;
601
+ #endif
602
+ #endif
603
+ info.diffuse*=info.clearCoat.w;
604
+ #ifdef SS_TRANSLUCENCY
605
+ info.diffuseTransmission*=info.clearCoat.w;
606
+ #endif
607
+ #ifdef SPECULARTERM
608
+ info.specular*=info.clearCoat.w;
609
+ #endif
610
+ #ifdef SHEEN
611
+ info.sheen*=info.clearCoat.w;
612
+ #endif
613
+ #endif
614
+ #endif
615
+ #else
616
+ #ifdef SPOTLIGHT{X}
617
+ #ifdef IESLIGHTTEXTURE{X}
618
+ info=computeIESSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness,iesLightTexture{X},iesLightTexture{X}Sampler);
619
+ #else
620
+ info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness);
621
+ #endif
622
+ #elif defined(HEMILIGHT{X})
623
+ info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);
624
+ #elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
625
+ info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness);
626
+ #elif define(AREALIGHT{X}) && defined(AREALIGHTSUPPORTED)
627
+ #if defined(RECTAREALIGHTEMISSIONTEXTURE{X})
628
+ info=computeAreaLightingWithTexture(areaLightsLTC1Sampler,areaLightsLTC1SamplerSampler,areaLightsLTC2Sampler,areaLightsLTC2SamplerSampler,rectAreaLightEmissionTexture{X},rectAreaLightEmissionTexture{X}Sampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,
629
+ #ifdef AREALIGHTNOROUGHTNESS
630
+ 0.5
631
+ #else
632
+ uniforms.vReflectionInfos.y
633
+ #endif
634
+ );
635
+ #else
636
+ info=computeAreaLighting(areaLightsLTC1Sampler,areaLightsLTC1SamplerSampler,areaLightsLTC2Sampler,areaLightsLTC2SamplerSampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,
637
+ #ifdef AREALIGHTNOROUGHTNESS
638
+ 0.5
639
+ #else
640
+ uniforms.vReflectionInfos.y
641
+ #endif
642
+ );
643
+ #endif
644
+ #elif defined(CLUSTLIGHT{X})
645
+ {let sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,fragmentInputs.vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting(lightDataTexture{X},&tileMaskBuffer{X},viewDirectionW,normalW,light{X}.vLightData,vec2u(light{X}.vSliceRanges[sliceIndex].xy),glossiness);}
646
+ #endif
647
+ #endif
648
+ #ifdef PROJECTEDLIGHTTEXTURE{X}
649
+ info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},projectionLightTexture{X}Sampler,uniforms.textureProjectionMatrix{X},fragmentInputs.vPositionW);
650
+ #endif
651
+ #endif
652
+ #ifdef SHADOW{X}
653
+ #ifdef SHADOWCSMDEBUG{X}
654
+ var shadowDebug{X}: vec3f;
655
+ #endif
656
+ #ifdef SHADOWCSM{X}
657
+ #ifdef SHADOWCSMUSESHADOWMAXZ{X}
658
+ var index{X}: i32=-1;
659
+ #else
660
+ var index{X}: i32=SHADOWCSMNUM_CASCADES{X}-1;
661
+ #endif
662
+ var diff{X}: f32=0.;vPositionFromLight{X}[0]=fragmentInputs.vPositionFromLight{X}_0;vPositionFromLight{X}[1]=fragmentInputs.vPositionFromLight{X}_1;vPositionFromLight{X}[2]=fragmentInputs.vPositionFromLight{X}_2;vPositionFromLight{X}[3]=fragmentInputs.vPositionFromLight{X}_3;vDepthMetric{X}[0]=fragmentInputs.vDepthMetric{X}_0;vDepthMetric{X}[1]=fragmentInputs.vDepthMetric{X}_1;vDepthMetric{X}[2]=fragmentInputs.vDepthMetric{X}_2;vDepthMetric{X}[3]=fragmentInputs.vDepthMetric{X}_3;for (var i:i32=0; i<SHADOWCSMNUM_CASCADES{X}; i++)
663
+ {
664
+ #ifdef SHADOWCSM_RIGHTHANDED{X}
665
+ diff{X}=uniforms.viewFrustumZ{X}[i]+fragmentInputs.vPositionFromCamera{X}.z;
666
+ #else
667
+ diff{X}=uniforms.viewFrustumZ{X}[i]-fragmentInputs.vPositionFromCamera{X}.z;
668
+ #endif
669
+ if (diff{X}>=0.) {index{X}=i;break;}}
670
+ #ifdef SHADOWCSMUSESHADOWMAXZ{X}
671
+ if (index{X}>=0)
672
+ #endif
673
+ {
674
+ #if defined(SHADOWPCF{X})
675
+ #if defined(SHADOWLOWQUALITY{X})
676
+ shadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
677
+ #elif defined(SHADOWMEDIUMQUALITY{X})
678
+ shadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
679
+ #else
680
+ shadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
681
+ #endif
682
+ #elif defined(SHADOWPCSS{X})
683
+ #if defined(SHADOWLOWQUALITY{X})
684
+ shadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
685
+ #elif defined(SHADOWMEDIUMQUALITY{X})
686
+ shadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
687
+ #else
688
+ shadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
689
+ #endif
690
+ #else
691
+ shadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
692
+ #endif
693
+ #ifdef SHADOWCSMDEBUG{X}
694
+ shadowDebug{X}=vec3f(shadow)*vCascadeColorsMultiplier{X}[index{X}];
695
+ #endif
696
+ #ifndef SHADOWCSMNOBLEND{X}
697
+ var frustumLength:f32=uniforms.frustumLengths{X}[index{X}];var diffRatio:f32=clamp(diff{X}/frustumLength,0.,1.)*uniforms.cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
698
+ {index{X}+=1;var nextShadow: f32=0.;
699
+ #if defined(SHADOWPCF{X})
700
+ #if defined(SHADOWLOWQUALITY{X})
701
+ nextShadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],,shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
702
+ #elif defined(SHADOWMEDIUMQUALITY{X})
703
+ nextShadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
704
+ #else
705
+ nextShadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
706
+ #endif
707
+ #elif defined(SHADOWPCSS{X})
708
+ #if defined(SHADOWLOWQUALITY{X})
709
+ nextShadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
710
+ #elif defined(SHADOWMEDIUMQUALITY{X})
711
+ nextShadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
712
+ #else
713
+ nextShadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
714
+ #endif
715
+ #else
716
+ nextShadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
717
+ #endif
718
+ shadow=mix(nextShadow,shadow,diffRatio);
719
+ #ifdef SHADOWCSMDEBUG{X}
720
+ shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
721
+ #endif
722
+ }
723
+ #endif
724
+ }
725
+ #elif defined(SHADOWCLOSEESM{X})
726
+ #if defined(SHADOWCUBE{X})
727
+ shadow=computeShadowWithCloseESMCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
728
+ #else
729
+ shadow=computeShadowWithCloseESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
730
+ #endif
731
+ #elif defined(SHADOWESM{X})
732
+ #if defined(SHADOWCUBE{X})
733
+ shadow=computeShadowWithESMCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
734
+ #else
735
+ shadow=computeShadowWithESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
736
+ #endif
737
+ #elif defined(SHADOWPOISSON{X})
738
+ #if defined(SHADOWCUBE{X})
739
+ shadow=computeShadowWithPoissonSamplingCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
740
+ #else
741
+ shadow=computeShadowWithPoissonSampling(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
742
+ #endif
743
+ #elif defined(SHADOWPCF{X})
744
+ #if defined(SHADOWLOWQUALITY{X})
745
+ shadow=computeShadowWithPCF1(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
746
+ #elif defined(SHADOWMEDIUMQUALITY{X})
747
+ shadow=computeShadowWithPCF3(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
748
+ #else
749
+ shadow=computeShadowWithPCF5(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
750
+ #endif
751
+ #elif defined(SHADOWPCSS{X})
752
+ #if defined(SHADOWLOWQUALITY{X})
753
+ shadow=computeShadowWithPCSS16(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
754
+ #elif defined(SHADOWMEDIUMQUALITY{X})
755
+ shadow=computeShadowWithPCSS32(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
756
+ #else
757
+ shadow=computeShadowWithPCSS64(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
758
+ #endif
759
+ #else
760
+ #if defined(SHADOWCUBE{X})
761
+ shadow=computeShadowCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.depthValues);
762
+ #else
763
+ shadow=computeShadow(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
764
+ #endif
765
+ #endif
766
+ #ifdef SHADOWONLY
767
+ #ifndef SHADOWINUSE
768
+ #define SHADOWINUSE
769
+ #endif
770
+ globalShadow+=shadow;shadowLightCount+=1.0;
771
+ #endif
772
+ #else
773
+ shadow=1.;
774
+ #endif
775
+ aggShadow+=shadow;numLights+=1.0;
776
+ #ifndef SHADOWONLY
777
+ #ifdef CUSTOMUSERLIGHTING
778
+ diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);
779
+ #ifdef SPECULARTERM
780
+ specularBase+=computeCustomSpecularLighting(info,specularBase,shadow);
781
+ #endif
782
+ #elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
783
+ diffuseBase+=lightmapColor.rgb*shadow;
784
+ #ifdef SPECULARTERM
785
+ #ifndef LIGHTMAPNOSPECULAR{X}
786
+ specularBase+=info.specular*shadow*lightmapColor.rgb;
787
+ #endif
788
+ #endif
789
+ #ifdef CLEARCOAT
790
+ #ifndef LIGHTMAPNOSPECULAR{X}
791
+ clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;
792
+ #endif
793
+ #endif
794
+ #ifdef SHEEN
795
+ #ifndef LIGHTMAPNOSPECULAR{X}
796
+ sheenBase+=info.sheen.rgb*shadow;
797
+ #endif
798
+ #endif
799
+ #else
800
+ #ifdef SHADOWCSMDEBUG{X}
801
+ diffuseBase+=info.diffuse*shadowDebug{X};
802
+ #else
803
+ diffuseBase+=info.diffuse*shadow;
804
+ #endif
805
+ #ifdef SS_TRANSLUCENCY
806
+ diffuseTransmissionBase+=info.diffuseTransmission*shadow;
807
+ #endif
808
+ #ifdef SPECULARTERM
809
+ specularBase+=info.specular*shadow;
810
+ #endif
811
+ #ifdef CLEARCOAT
812
+ clearCoatBase+=info.clearCoat.rgb*shadow;
813
+ #endif
814
+ #ifdef SHEEN
815
+ sheenBase+=info.sheen.rgb*shadow;
816
+ #endif
817
+ #endif
818
+ #endif
819
+ #endif
820
+ `;i.ShaderStore.IncludesShadersStoreWGSL[f]||(i.ShaderStore.IncludesShadersStoreWGSL[f]=a),e.s(["lightFragmentWGSL",0,{name:f,shader:a}],49692)},67367,23356,e=>{"use strict";var i=e.i(12423);let t="samplerFragmentDeclaration",r=`#ifdef _DEFINENAME_
821
+ #if _DEFINENAME_DIRECTUV==1
822
+ #define v_VARYINGNAME_UV vMainUV1
823
+ #elif _DEFINENAME_DIRECTUV==2
824
+ #define v_VARYINGNAME_UV vMainUV2
825
+ #elif _DEFINENAME_DIRECTUV==3
826
+ #define v_VARYINGNAME_UV vMainUV3
827
+ #elif _DEFINENAME_DIRECTUV==4
828
+ #define v_VARYINGNAME_UV vMainUV4
829
+ #elif _DEFINENAME_DIRECTUV==5
830
+ #define v_VARYINGNAME_UV vMainUV5
831
+ #elif _DEFINENAME_DIRECTUV==6
832
+ #define v_VARYINGNAME_UV vMainUV6
833
+ #else
834
+ varying v_VARYINGNAME_UV: vec2f;
835
+ #endif
836
+ var _SAMPLERNAME_SamplerSampler: sampler;var _SAMPLERNAME_Sampler: texture_2d<f32>;
837
+ #endif
838
+ `;i.ShaderStore.IncludesShadersStoreWGSL[t]||(i.ShaderStore.IncludesShadersStoreWGSL[t]=r),e.s(["samplerFragmentDeclarationWGSL",0,{name:t,shader:r}],67367);let f="reflectionFunction",a=`fn computeFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f
839
+ {var lon: f32=atan2(direction.z,direction.x);var lat: f32=acos(direction.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(s,t,0); }
840
+ fn computeMirroredFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f
841
+ {var lon: f32=atan2(direction.z,direction.x);var lat: f32=acos(direction.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(1.0-s,t,0); }
842
+ fn computeEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
843
+ {var cameraToVertex: vec3f=normalize(worldPos.xyz-eyePosition);var r: vec3f=normalize(reflect(cameraToVertex,worldNormal));r= (reflectionMatrix* vec4f(r,0)).xyz;var lon: f32=atan2(r.z,r.x);var lat: f32=acos(r.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(s,t,0);}
844
+ fn computeSphericalCoords(worldPos: vec4f,worldNormal: vec3f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f
845
+ {var viewDir: vec3f=normalize((view*worldPos).xyz);var viewNormal: vec3f=normalize((view* vec4f(worldNormal,0.0)).xyz);var r: vec3f=reflect(viewDir,viewNormal);r= (reflectionMatrix* vec4f(r,0)).xyz;r.z=r.z-1.0;var m: f32=2.0*length(r);return vec3f(r.x/m+0.5,1.0-r.y/m-0.5,0);}
846
+ fn computePlanarCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
847
+ {var viewDir: vec3f=worldPos.xyz-eyePosition;var coords: vec3f=normalize(reflect(viewDir,worldNormal));return (reflectionMatrix* vec4f(coords,1)).xyz;}
848
+ fn computeCubicCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
849
+ {var viewDir: vec3f=normalize(worldPos.xyz-eyePosition);var coords: vec3f=reflect(viewDir,worldNormal);coords= (reflectionMatrix* vec4f(coords,0)).xyz;
850
+ #ifdef INVERTCUBICMAP
851
+ coords.y*=-1.0;
852
+ #endif
853
+ return coords;}
854
+ fn computeCubicLocalCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f,reflectionSize: vec3f,reflectionPosition: vec3f)->vec3f
855
+ {var viewDir: vec3f=normalize(worldPos.xyz-eyePosition);var coords: vec3f=reflect(viewDir,worldNormal);coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);coords=(reflectionMatrix* vec4f(coords,0)).xyz;
856
+ #ifdef INVERTCUBICMAP
857
+ coords.y*=-1.0;
858
+ #endif
859
+ return coords;}
860
+ fn computeProjectionCoords(worldPos: vec4f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f
861
+ {return (reflectionMatrix*(view*worldPos)).xyz;}
862
+ fn computeSkyBoxCoords(positionW: vec3f,reflectionMatrix: mat4x4f)->vec3f
863
+ {return (reflectionMatrix* vec4f(positionW,1.)).xyz;}
864
+ #ifdef REFLECTION
865
+ fn computeReflectionCoords(worldPos: vec4f,worldNormal: vec3f)->vec3f
866
+ {
867
+ #ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
868
+ var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);
869
+ #endif
870
+ #ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
871
+ var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeFixedEquirectangularCoords(worldPos,worldNormal,direction);
872
+ #endif
873
+ #ifdef REFLECTIONMAP_EQUIRECTANGULAR
874
+ return computeEquirectangularCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
875
+ #endif
876
+ #ifdef REFLECTIONMAP_SPHERICAL
877
+ return computeSphericalCoords(worldPos,worldNormal,scene.view,uniforms.reflectionMatrix);
878
+ #endif
879
+ #ifdef REFLECTIONMAP_PLANAR
880
+ return computePlanarCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
881
+ #endif
882
+ #ifdef REFLECTIONMAP_CUBIC
883
+ #ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
884
+ return computeCubicLocalCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix,uniforms.vReflectionSize,uniforms.vReflectionPosition);
885
+ #else
886
+ return computeCubicCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
887
+ #endif
888
+ #endif
889
+ #ifdef REFLECTIONMAP_PROJECTION
890
+ return computeProjectionCoords(worldPos,scene.view,uniforms.reflectionMatrix);
891
+ #endif
892
+ #ifndef REFLECTIONMAP_CUBIC
893
+ #ifdef REFLECTIONMAP_SKYBOX
894
+ return computeSkyBoxCoords(fragmentInputs.vPositionUVW,uniforms.reflectionMatrix);
895
+ #endif
896
+ #endif
897
+ #ifdef REFLECTIONMAP_EXPLICIT
898
+ return vec3f(0,0,0);
899
+ #endif
900
+ }
901
+ #endif
902
+ `;i.ShaderStore.IncludesShadersStoreWGSL[f]||(i.ShaderStore.IncludesShadersStoreWGSL[f]=a),e.s(["reflectionFunctionWGSL",0,{name:f,shader:a}],23356)},90780,82518,e=>{"use strict";var i=e.i(12423);let t="pbrFragmentReflectionDeclaration",r=`#ifdef REFLECTION
903
+ #ifdef REFLECTIONMAP_3D
904
+ var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube<f32>;
905
+ #ifdef LODBASEDMICROSFURACE
906
+ #else
907
+ var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_cube<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_cube<f32>;
908
+ #endif
909
+ #ifdef USEIRRADIANCEMAP
910
+ var irradianceSamplerSampler: sampler;var irradianceSampler: texture_cube<f32>;
911
+ #endif
912
+ #else
913
+ var reflectionSamplerSampler: sampler;var reflectionSampler: texture_2d<f32>;
914
+ #ifdef LODBASEDMICROSFURACE
915
+ #else
916
+ var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_2d<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_2d<f32>;
917
+ #endif
918
+ #ifdef USEIRRADIANCEMAP
919
+ var irradianceSamplerSampler: sampler;var irradianceSampler: texture_2d<f32>;
920
+ #endif
921
+ #endif
922
+ #ifdef REFLECTIONMAP_SKYBOX
923
+ varying vPositionUVW: vec3f;
924
+ #else
925
+ #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
926
+ varying vDirectionW: vec3f;
927
+ #endif
928
+ #endif
929
+ #endif
930
+ `;i.ShaderStore.IncludesShadersStoreWGSL[t]||(i.ShaderStore.IncludesShadersStoreWGSL[t]=r),e.s(["pbrFragmentReflectionDeclarationWGSL",0,{name:t,shader:r}],90780);let f="pbrIBLFunctions",a=`#if defined(REFLECTION) || defined(SS_REFRACTION)
931
+ fn getLodFromAlphaG(cubeMapDimensionPixels: f32,microsurfaceAverageSlope: f32)->f32 {var microsurfaceAverageSlopeTexels: f32=cubeMapDimensionPixels*microsurfaceAverageSlope;var lod: f32=log2(microsurfaceAverageSlopeTexels);return lod;}
932
+ fn getLinearLodFromRoughness(cubeMapDimensionPixels: f32,roughness: f32)->f32 {var lod: f32=log2(cubeMapDimensionPixels)*roughness;return lod;}
933
+ #endif
934
+ #if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)
935
+ fn environmentRadianceOcclusion(ambientOcclusion: f32,NdotVUnclamped: f32)->f32 {var temp: f32=NdotVUnclamped+ambientOcclusion;return saturate(temp*temp-1.0+ambientOcclusion);}
936
+ #endif
937
+ #if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)
938
+ fn environmentHorizonOcclusion(view: vec3f,normal: vec3f,geometricNormal: vec3f)->f32 {var reflection: vec3f=reflect(view,normal);var temp: f32=saturate(1.0+1.1*dot(reflection,geometricNormal));return temp*temp;}
939
+ #endif
940
+ #if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)
941
+ fn UNPACK_LOD(x: f32)->f32 {return (1.0-x)*255.0;}
942
+ fn getLodFromAlphaGNdotV(cubeMapDimensionPixels: f32,alphaG: f32,NdotV: f32)->f32 {var microsurfaceAverageSlope: f32=alphaG;microsurfaceAverageSlope*=sqrt(abs(NdotV));return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);}
943
+ #endif
944
+ `;i.ShaderStore.IncludesShadersStoreWGSL[f]||(i.ShaderStore.IncludesShadersStoreWGSL[f]=a),e.s(["pbrIBLFunctionsWGSL",0,{name:f,shader:a}],82518)},6320,95538,90507,62424,42221,48373,69075,62026,28285,74698,52640,87693,e=>{"use strict";var i=e.i(12423);e.i(39780);let t="pbrFragmentExtraDeclaration",r=`varying vPositionW: vec3f;
945
+ #if DEBUGMODE>0
946
+ varying vClipSpacePosition: vec4f;
947
+ #endif
948
+ #include<mainUVVaryingDeclaration>[1..7]
949
+ #ifdef NORMAL
950
+ varying vNormalW: vec3f;
951
+ #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
952
+ varying vEnvironmentIrradiance: vec3f;
953
+ #endif
954
+ #endif
955
+ #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
956
+ varying vColor: vec4f;
957
+ #endif
958
+ #if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
959
+ varying vViewDepth: f32;
960
+ #endif
961
+ `;i.ShaderStore.IncludesShadersStoreWGSL[t]||(i.ShaderStore.IncludesShadersStoreWGSL[t]=r),e.s(["pbrFragmentExtraDeclarationWGSL",0,{name:t,shader:r}],6320);let f="subSurfaceScatteringFunctions",a=`fn testLightingForSSS(diffusionProfile: f32)->bool
962
+ {return diffusionProfile<1.;}`;i.ShaderStore.IncludesShadersStoreWGSL[f]||(i.ShaderStore.IncludesShadersStoreWGSL[f]=a),e.s(["subSurfaceScatteringFunctionsWGSL",0,{name:f,shader:a}],95538);let n="importanceSampling",o=`fn hemisphereCosSample(u: vec2f)->vec3f {var phi: f32=2.*PI*u.x;var cosTheta2: f32=1.-u.y;var cosTheta: f32=sqrt(cosTheta2);var sinTheta: f32=sqrt(1.-cosTheta2);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}
963
+ fn hemisphereImportanceSampleDggx(u: vec2f,a: f32)->vec3f {var phi: f32=2.*PI*u.x;var cosTheta2: f32=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));var cosTheta: f32=sqrt(cosTheta2);var sinTheta: f32=sqrt(1.-cosTheta2);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}
964
+ fn hemisphereImportanceSampleDggxAnisotropic(Xi: vec2f,alphaTangent: f32,alphaBitangent: f32)->vec3f
965
+ {let alphaT: f32=max(alphaTangent,0.0001);let alphaB: f32=max(alphaBitangent,0.0001);var phi: f32=atan(alphaB/alphaT*tan(2.0f*PI*Xi.x));if (Xi.x>0.5) {phi+=PI; }
966
+ let cosPhi: f32=cos(phi);let sinPhi: f32=sin(phi);let alpha2: f32=(cosPhi*cosPhi)/(alphaT*alphaT) +
967
+ (sinPhi*sinPhi)/(alphaB*alphaB);let tanTheta2: f32=Xi.y/(1.0f-Xi.y)/alpha2;let cosTheta: f32=1.0f/sqrt(1.0f+tanTheta2);let sinTheta: f32=sqrt(max(0.0f,1.0f-cosTheta*cosTheta));return vec3f(sinTheta*cosPhi,sinTheta*sinPhi,cosTheta);}
968
+ fn hemisphereImportanceSampleDCharlie(u: vec2f,a: f32)->vec3f {
969
+ var phi: f32=2.*PI*u.x;var sinTheta: f32=pow(u.y,a/(2.*a+1.));var cosTheta: f32=sqrt(1.-sinTheta*sinTheta);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}`;i.ShaderStore.IncludesShadersStoreWGSL[n]||(i.ShaderStore.IncludesShadersStoreWGSL[n]=o),e.s(["importanceSamplingWGSL",0,{name:n,shader:o}],90507);let l="pbrHelperFunctions",s=`#define MINIMUMVARIANCE 0.0005
970
+ #ifndef TEXRD_DEFINED
971
+ fn TEXRD(t: texture_2d<f32>,ts: sampler,uv: vec2f)->vec4f {return textureSample(t,ts,uv);}
972
+ #define TEXRD_DEFINED
973
+ #endif
974
+ fn convertRoughnessToAverageSlope(roughness: f32)->f32
975
+ {return roughness*roughness+MINIMUMVARIANCE;}
976
+ fn fresnelGrazingReflectance(reflectance0: f32)->f32 {var reflectance90: f32=saturate(reflectance0*25.0);return reflectance90;}
977
+ fn getAARoughnessFactors(normalVector: vec3f)->vec2f {
978
+ #ifdef SPECULARAA
979
+ var nDfdx: vec3f=dpdx(normalVector.xyz);var nDfdy: vec3f=dpdy(normalVector.xyz);var slopeSquare: f32=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));var geometricRoughnessFactor: f32=pow(saturate(slopeSquare),0.333);var geometricAlphaGFactor: f32=sqrt(slopeSquare);geometricAlphaGFactor*=0.75;return vec2f(geometricRoughnessFactor,geometricAlphaGFactor);
980
+ #else
981
+ return vec2f(0.);
982
+ #endif
983
+ }
984
+ #ifdef ANISOTROPIC
985
+ #ifdef ANISOTROPIC_LEGACY
986
+ fn getAnisotropicRoughness(alphaG: f32,anisotropy: f32)->vec2f {var alphaT: f32=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);var alphaB: f32=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);return vec2f(alphaT,alphaB);}
987
+ fn getAnisotropicBentNormals(T: vec3f,B: vec3f,N: vec3f,V: vec3f,anisotropy: f32,roughness: f32)->vec3f {var anisotropicFrameDirection: vec3f=select(T,B,anisotropy>=0.0);var anisotropicFrameTangent: vec3f=cross(normalize(anisotropicFrameDirection),V);var anisotropicFrameNormal: vec3f=cross(anisotropicFrameTangent,anisotropicFrameDirection);var anisotropicNormal: vec3f=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));return anisotropicNormal;}
988
+ #elif ANISOTROPIC_OPENPBR
989
+ fn getAnisotropicRoughness(alphaG: f32,anisotropy: f32)->vec2f {var alphaT: f32=max(alphaG*alphaG*sqrt(2.0/(1.0+(1.0-anisotropy)*(1.0-anisotropy))),MINIMUMVARIANCE);var alphaB: f32=max(alphaT*(1.0-anisotropy),MINIMUMVARIANCE);return vec2f(alphaT,alphaB);}
990
+ #else
991
+ fn getAnisotropicRoughness(alphaG: f32,anisotropy: f32)->vec2f {var alphaT: f32=max(mix(alphaG,1.0,anisotropy*anisotropy),MINIMUMVARIANCE);var alphaB: f32=max(alphaG,MINIMUMVARIANCE);return vec2f(alphaT,alphaB);}
992
+ fn getAnisotropicBentNormals(T: vec3f,B: vec3f,N: vec3f,V: vec3f,anisotropy: f32,roughness: f32)->vec3f {var bentNormal: vec3f=cross(B,V);bentNormal=normalize(cross(bentNormal,B));var sq=1.0-anisotropy*(1.0-roughness);var a: f32=sq*sq*sq*sq;bentNormal=normalize(mix(bentNormal,N,a));return bentNormal;}
993
+ #endif
994
+ #endif
995
+ #if defined(CLEARCOAT) || defined(SS_REFRACTION)
996
+ fn cocaLambertVec3(alpha: vec3f,distance: f32)->vec3f {return exp(-alpha*distance);}
997
+ fn cocaLambert(NdotVRefract: f32,NdotLRefract: f32,alpha: vec3f,thickness: f32)->vec3f {return cocaLambertVec3(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));}
998
+ fn computeColorAtDistanceInMedia(color: vec3f,distance: f32)->vec3f {return -log(color)/distance;}
999
+ fn computeClearCoatAbsorption(NdotVRefract: f32,NdotLRefract: f32,clearCoatColor: vec3f,clearCoatThickness: f32,clearCoatIntensity: f32)->vec3f {var clearCoatAbsorption: vec3f=mix( vec3f(1.0),
1000
+ cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),
1001
+ clearCoatIntensity);return clearCoatAbsorption;}
1002
+ #endif
1003
+ #ifdef MICROSURFACEAUTOMATIC
1004
+ fn computeDefaultMicroSurface(microSurface: f32,reflectivityColor: vec3f)->f32
1005
+ {const kReflectivityNoAlphaWorkflow_SmoothnessMax: f32=0.95;var reflectivityLuminance: f32=getLuminance(reflectivityColor);var reflectivityLuma: f32=sqrt(reflectivityLuminance);var resultMicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;return resultMicroSurface;}
1006
+ #endif
1007
+ `;i.ShaderStore.IncludesShadersStoreWGSL[l]||(i.ShaderStore.IncludesShadersStoreWGSL[l]=s),e.s(["pbrHelperFunctionsWGSL",0,{name:l,shader:s}],62424),e.i(42420);let c="pbrDirectLightingSetupFunctions",d=`struct preLightingInfo
1008
+ {lightOffset: vec3f,
1009
+ lightDistanceSquared: f32,
1010
+ lightDistance: f32,
1011
+ attenuation: f32,
1012
+ L: vec3f,
1013
+ H: vec3f,
1014
+ NdotV: f32,
1015
+ NdotLUnclamped: f32,
1016
+ NdotL: f32,
1017
+ VdotH: f32,
1018
+ LdotV: f32,
1019
+ roughness: f32,
1020
+ diffuseRoughness: f32,
1021
+ surfaceAlbedo: vec3f,
1022
+ #ifdef IRIDESCENCE
1023
+ iridescenceIntensity: f32
1024
+ #endif
1025
+ #if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1026
+ areaLightDiffuse: vec3f,
1027
+ #ifdef SPECULARTERM
1028
+ areaLightSpecular: vec3f,
1029
+ areaLightFresnel: vec4f
1030
+ #endif
1031
+ #endif
1032
+ };fn computePointAndSpotPreLightingInfo(lightData: vec4f,V: vec3f,N: vec3f,posW: vec3f)->preLightingInfo {var result: preLightingInfo;result.lightOffset=lightData.xyz-posW;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);result.L=normalize(result.lightOffset);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);return result;}
1033
+ fn computeDirectionalPreLightingInfo(lightData: vec4f,V: vec3f,N: vec3f)->preLightingInfo {var result: preLightingInfo;result.lightDistance=length(-lightData.xyz);result.L=normalize(-lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);result.LdotV=dot(result.L,V);return result;}
1034
+ fn computeHemisphericPreLightingInfo(lightData: vec4f,V: vec3f,N: vec3f)->preLightingInfo {var result: preLightingInfo;result.NdotL=dot(N,lightData.xyz)*0.5+0.5;result.NdotL=saturateEps(result.NdotL);result.NdotLUnclamped=result.NdotL;
1035
+ #ifdef SPECULARTERM
1036
+ result.L=normalize(lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));
1037
+ #endif
1038
+ return result;}
1039
+ #if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1040
+ #include<ltcHelperFunctions>
1041
+ var areaLightsLTC1SamplerSampler: sampler;var areaLightsLTC1Sampler: texture_2d<f32>;var areaLightsLTC2SamplerSampler: sampler;var areaLightsLTC2Sampler: texture_2d<f32>;fn computeAreaPreLightingInfo(ltc1: texture_2d<f32>,ltc1Sampler:sampler,ltc2:texture_2d<f32>,ltc2Sampler:sampler,viewDirectionW: vec3f,vNormal:vec3f,vPosition:vec3f,lightCenter:vec3f,halfWidth:vec3f, halfHeight:vec3f,roughness:f32)->preLightingInfo {var result: preLightingInfo;var data: areaLightData=computeAreaLightSpecularDiffuseFresnel(ltc1,ltc1Sampler,ltc2,ltc2Sampler,viewDirectionW,vNormal,vPosition,lightCenter,halfWidth,halfHeight,roughness);
1042
+ #ifdef SPECULARTERM
1043
+ result.areaLightFresnel=data.Fresnel;result.areaLightSpecular=data.Specular;
1044
+ #endif
1045
+ result.areaLightDiffuse+=data.Diffuse;return result;}
1046
+ fn computeAreaPreLightingInfoWithTexture(ltc1: texture_2d<f32>,ltc1Sampler:sampler,ltc2:texture_2d<f32>,ltc2Sampler:sampler,emissionTexture:texture_2d<f32>,emissionTextureSampler:sampler,viewDirectionW: vec3f,vNormal:vec3f,vPosition:vec3f,lightCenter:vec3f,halfWidth:vec3f, halfHeight:vec3f,roughness:f32)->preLightingInfo {var result: preLightingInfo;result.lightOffset=lightCenter-vPosition;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);var data: areaLightData=computeAreaLightSpecularDiffuseFresnelWithEmission(ltc1,ltc1Sampler,ltc2,ltc2Sampler,emissionTexture,emissionTextureSampler,viewDirectionW,vNormal,vPosition,lightCenter,halfWidth,halfHeight,roughness);
1047
+ #ifdef SPECULARTERM
1048
+ result.areaLightFresnel=data.Fresnel;result.areaLightSpecular=data.Specular;
1049
+ #endif
1050
+ result.areaLightDiffuse=data.Diffuse;result.LdotV=0.;result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3f(0.);return result;}
1051
+ #endif
1052
+ `;i.ShaderStore.IncludesShadersStoreWGSL[c]||(i.ShaderStore.IncludesShadersStoreWGSL[c]=d),e.s(["pbrDirectLightingSetupFunctionsWGSL",0,{name:c,shader:d}],42221);let u="pbrDirectLightingFalloffFunctions",v=`fn computeDistanceLightFalloff_Standard(lightOffset: vec3f,range: f32)->f32
1053
+ {return max(0.,1.0-length(lightOffset)/range);}
1054
+ fn computeDistanceLightFalloff_Physical(lightDistanceSquared: f32)->f32
1055
+ {return 1.0/maxEps(lightDistanceSquared);}
1056
+ fn computeDistanceLightFalloff_GLTF(lightDistanceSquared: f32,inverseSquaredRange: f32)->f32
1057
+ {var lightDistanceFalloff: f32=1.0/maxEps(lightDistanceSquared);var factor: f32=lightDistanceSquared*inverseSquaredRange;var attenuation: f32=saturate(1.0-factor*factor);attenuation*=attenuation;lightDistanceFalloff*=attenuation;return lightDistanceFalloff;}
1058
+ fn computeDirectionalLightFalloff_IES(lightDirection: vec3f,directionToLightCenterW: vec3f,iesLightTexture: texture_2d<f32>,iesLightTextureSampler: sampler)->f32
1059
+ {var cosAngle: f32=dot(-lightDirection,directionToLightCenterW);var angle=acos(cosAngle)/PI;return textureSampleLevel(iesLightTexture,iesLightTextureSampler,vec2f(angle,0),0.).r;}
1060
+ fn computeDistanceLightFalloff(lightOffset: vec3f,lightDistanceSquared: f32,range: f32,inverseSquaredRange: f32)->f32
1061
+ {
1062
+ #ifdef USEPHYSICALLIGHTFALLOFF
1063
+ return computeDistanceLightFalloff_Physical(lightDistanceSquared);
1064
+ #elif defined(USEGLTFLIGHTFALLOFF)
1065
+ return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);
1066
+ #else
1067
+ return computeDistanceLightFalloff_Standard(lightOffset,range);
1068
+ #endif
1069
+ }
1070
+ fn computeDirectionalLightFalloff_Standard(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32,exponent: f32)->f32
1071
+ {var falloff: f32=0.0;var cosAngle: f32=maxEps(dot(-lightDirection,directionToLightCenterW));if (cosAngle>=cosHalfAngle)
1072
+ {falloff=max(0.,pow(cosAngle,exponent));}
1073
+ return falloff;}
1074
+ fn computeDirectionalLightFalloff_Physical(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32)->f32
1075
+ {const kMinusLog2ConeAngleIntensityRatio: f32=6.64385618977;
1076
+ var concentrationKappa: f32=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);var lightDirectionSpreadSG: vec4f= vec4f(-lightDirection*concentrationKappa,-concentrationKappa);var falloff: f32=exp2(dot( vec4f(directionToLightCenterW,1.0),lightDirectionSpreadSG));return falloff;}
1077
+ fn computeDirectionalLightFalloff_GLTF(lightDirection: vec3f,directionToLightCenterW: vec3f,lightAngleScale: f32,lightAngleOffset: f32)->f32
1078
+ {var cd: f32=dot(-lightDirection,directionToLightCenterW);var falloff: f32=saturate(cd*lightAngleScale+lightAngleOffset);falloff*=falloff;return falloff;}
1079
+ fn computeDirectionalLightFalloff(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32,exponent: f32,lightAngleScale: f32,lightAngleOffset: f32)->f32
1080
+ {
1081
+ #ifdef USEPHYSICALLIGHTFALLOFF
1082
+ return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);
1083
+ #elif defined(USEGLTFLIGHTFALLOFF)
1084
+ return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);
1085
+ #else
1086
+ return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);
1087
+ #endif
1088
+ }`;i.ShaderStore.IncludesShadersStoreWGSL[u]||(i.ShaderStore.IncludesShadersStoreWGSL[u]=v),e.s(["pbrDirectLightingFalloffFunctionsWGSL",0,{name:u,shader:v}],48373);let h="hdrFilteringFunctions",m=`#ifdef NUM_SAMPLES
1089
+ #if NUM_SAMPLES>0
1090
+ fn radicalInverse_VdC(value: u32)->f32
1091
+ {var bits=(value<<16u) | (value>>16u);bits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);bits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);bits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);bits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);return f32(bits)*2.3283064365386963e-10; }
1092
+ fn hammersley(i: u32,N: u32)->vec2f
1093
+ {return vec2f( f32(i)/ f32(N),radicalInverse_VdC(i));}
1094
+ fn log4(x: f32)->f32 {return log2(x)/2.;}
1095
+ fn uv_to_normal(uv: vec2f)->vec3f {var N: vec3f;var uvRange: vec2f=uv;var theta: f32=uvRange.x*2.0*PI;var phi: f32=uvRange.y*PI;N.x=cos(theta)*sin(phi);N.z=sin(theta)*sin(phi);N.y=cos(phi);return N;}
1096
+ const NUM_SAMPLES_FLOAT: f32= f32(NUM_SAMPLES);const NUM_SAMPLES_FLOAT_INVERSED: f32=1./NUM_SAMPLES_FLOAT;const K: f32=4.;fn irradiance(
1097
+ #ifdef CUSTOM_IRRADIANCE_FILTERING_INPUT
1098
+ CUSTOM_IRRADIANCE_FILTERING_INPUT
1099
+ #else
1100
+ inputTexture: texture_cube<f32>,inputSampler: sampler,
1101
+ #endif
1102
+ inputN: vec3f,
1103
+ filteringInfo: vec2f,
1104
+ diffuseRoughness: f32,
1105
+ surfaceAlbedo: vec3f,
1106
+ inputV: vec3f
1107
+ #ifdef IBL_CDF_FILTERING
1108
+ ,icdfSampler: texture_2d<f32>,icdfSamplerSampler: sampler
1109
+ #endif
1110
+ )->vec3f
1111
+ {var n: vec3f=normalize(inputN);var result: vec3f= vec3f(0.0);
1112
+ #ifndef IBL_CDF_FILTERING
1113
+ var tangent: vec3f=select(vec3f(1.,0.,0.),vec3f(0.,0.,1.),abs(n.z)<0.999);tangent=normalize(cross(tangent,n));var bitangent: vec3f=cross(n,tangent);var tbn: mat3x3f= mat3x3f(tangent,bitangent,n);var tbnInverse: mat3x3f=transpose(tbn);
1114
+ #endif
1115
+ var maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;var omegaP: f32=(4.*PI)/(6.*dim0*dim0);var clampedAlbedo: vec3f=clamp(surfaceAlbedo,vec3f(0.1),vec3f(1.0));for(var i: u32=0u; i<NUM_SAMPLES; i++)
1116
+ {var Xi: vec2f=hammersley(i,NUM_SAMPLES);
1117
+ #ifdef IBL_CDF_FILTERING
1118
+ var T: vec2f;T.x=textureSampleLevel(icdfSampler,icdfSamplerSampler,vec2(Xi.x,0.0),0.0).x;T.y=textureSampleLevel(icdfSampler,icdfSamplerSampler,vec2(T.x,Xi.y),0.0).y;var Ls: vec3f=uv_to_normal(vec2f(1.0-fract(T.x+0.25),T.y));var NoL: f32=dot(n,Ls);var NoV: f32=dot(n,inputV);
1119
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
1120
+ var LoV: f32=dot(Ls,inputV);
1121
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
1122
+ var H: vec3f=(inputV+Ls)*0.5;var VoH: f32=dot(inputV,H);
1123
+ #endif
1124
+ #else
1125
+ var Ls: vec3f=hemisphereCosSample(Xi);Ls=normalize(Ls);var Ns: vec3f= vec3f(0.,0.,1.);var NoL: f32=dot(Ns,Ls);var V: vec3f=tbnInverse*inputV;var NoV: f32=dot(Ns,V);
1126
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
1127
+ var LoV: f32=dot(Ls,V);
1128
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
1129
+ var H: vec3f=(V+Ls)*0.5;var VoH: f32=dot(V,H);
1130
+ #endif
1131
+ #endif
1132
+ if (NoL>0.) {
1133
+ #ifdef IBL_CDF_FILTERING
1134
+ var pdf: f32=textureSampleLevel(icdfSampler,icdfSamplerSampler,T,0.0).z;var c: vec3f=textureSampleLevel(inputTexture,inputSampler,Ls,0.0).rgb;
1135
+ #else
1136
+ var pdf_inversed: f32=PI/NoL;var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp(l,0.0,maxLevel);
1137
+ #ifdef CUSTOM_IRRADIANCE_FILTERING_FUNCTION
1138
+ CUSTOM_IRRADIANCE_FILTERING_FUNCTION
1139
+ #else
1140
+ var c: vec3f=textureSampleLevel(inputTexture,inputSampler,tbn*Ls,mipLevel).rgb;
1141
+ #endif
1142
+ #endif
1143
+ #ifdef GAMMA_INPUT
1144
+ c=toLinearSpaceVec3(c);
1145
+ #endif
1146
+ var diffuseRoughnessTerm: vec3f=vec3f(1.0);
1147
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
1148
+ diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;
1149
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
1150
+ diffuseRoughnessTerm=vec3f(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);
1151
+ #endif
1152
+ #ifdef IBL_CDF_FILTERING
1153
+ var light: vec3f=vec3f(0.0);if (pdf>1e-6) {light=vec3f(1.0)/vec3f(pdf)*c;}
1154
+ result+=NoL*diffuseRoughnessTerm*light;
1155
+ #else
1156
+ result+=c*diffuseRoughnessTerm;
1157
+ #endif
1158
+ }}
1159
+ result=result*NUM_SAMPLES_FLOAT_INVERSED;
1160
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
1161
+ result=result/clampedAlbedo;
1162
+ #endif
1163
+ return result;}
1164
+ fn radiance(alphaG: f32,inputTexture: texture_cube<f32>,inputSampler: sampler,inputN: vec3f,filteringInfo: vec2f)->vec3f
1165
+ {var n: vec3f=normalize(inputN);var c: vec3f=textureSampleLevel(inputTexture,inputSampler,n,0.0).rgb;
1166
+ if (alphaG==0.) {
1167
+ #ifdef GAMMA_INPUT
1168
+ c=toLinearSpaceVec3(c);
1169
+ #endif
1170
+ return c;} else {var result: vec3f= vec3f(0.);var tangent: vec3f=select(vec3f(1.,0.,0.),vec3f(0.,0.,1.),abs(n.z)<0.999);tangent=normalize(cross(tangent,n));var bitangent: vec3f=cross(n,tangent);var tbn: mat3x3f= mat3x3f(tangent,bitangent,n);var maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;var omegaP: f32=(4.*PI)/(6.*dim0*dim0);var weight: f32=0.;for(var i: u32=0u; i<NUM_SAMPLES; i++)
1171
+ {var Xi: vec2f=hammersley(i,NUM_SAMPLES);var H: vec3f=hemisphereImportanceSampleDggx(Xi,alphaG);var NoV: f32=1.;var NoH: f32=H.z;var NoH2: f32=H.z*H.z;var NoL: f32=2.*NoH2-1.;var L: vec3f= vec3f(2.*NoH*H.x,2.*NoH*H.y,NoL);L=normalize(L);if (NoL>0.) {var pdf_inversed: f32=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp( f32(l),0.0,maxLevel);weight+=NoL;var c: vec3f=textureSampleLevel(inputTexture,inputSampler,tbn*L,mipLevel).rgb;
1172
+ #ifdef GAMMA_INPUT
1173
+ c=toLinearSpaceVec3(c);
1174
+ #endif
1175
+ result+=c*NoL;}}
1176
+ result=result/weight;return result;}}
1177
+ #ifdef ANISOTROPIC
1178
+ fn radianceAnisotropic(
1179
+ alphaTangent: f32,
1180
+ alphaBitangent: f32,
1181
+ inputTexture: texture_cube<f32>,
1182
+ inputSampler: sampler,
1183
+ inputView: vec3f,
1184
+ inputTangent: vec3f,
1185
+ inputBitangent: vec3f,
1186
+ inputNormal: vec3f,
1187
+ filteringInfo: vec2f,
1188
+ noiseInput: vec2f,
1189
+ isRefraction: bool,
1190
+ ior: f32
1191
+ )->vec3f {var V: vec3f=inputView;var N: vec3f=inputNormal;var T: vec3f=inputTangent;var B: vec3f=inputBitangent;var result: vec3f=vec3f(0.f);var maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;let clampedAlphaT: f32=max(alphaTangent,MINIMUMVARIANCE);let clampedAlphaB: f32=max(alphaBitangent,MINIMUMVARIANCE);var effectiveDim: f32=dim0*sqrt(clampedAlphaT*clampedAlphaB);var omegaP: f32=(4.f*PI)/(6.f*effectiveDim*effectiveDim);let noiseScale: f32=clamp(log2(f32(NUM_SAMPLES))/12.0f,0.0f,1.0f);var weight: f32=0.f;for(var i: u32=0u; i<NUM_SAMPLES; i++)
1192
+ {var Xi: vec2f=hammersley(i,NUM_SAMPLES);Xi=fract(Xi+noiseInput*mix(0.5f,0.015f,noiseScale));
1193
+ var H_tangent: vec3f=hemisphereImportanceSampleDggxAnisotropic(Xi,clampedAlphaT,clampedAlphaB);var H: vec3f=normalize(H_tangent.x*T+H_tangent.y*B+H_tangent.z*N);var L: vec3f;if (isRefraction) {L=refract(-V,H,1.0/ior);} else {L=reflect(-V,H);}
1194
+ var NoH: f32=max(dot(N,H),0.001f);var VoH: f32=max(dot(V,H),0.001f);var NoL: f32=max(dot(N,L),0.001f);if (NoL>0.f) {var pdf_inversed: f32=4./normalDistributionFunction_BurleyGGX_Anisotropic(
1195
+ H_tangent.z,H_tangent.x,H_tangent.y,vec2f(clampedAlphaT,clampedAlphaB)
1196
+ );var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp(l,0.0f,maxLevel);weight+=NoL;var c: vec3f=textureSampleLevel(inputTexture,inputSampler,L,mipLevel).rgb;
1197
+ #if GAMMA_INPUT
1198
+ c=toLinearSpaceVec3(c);
1199
+ #endif
1200
+ result+=c*NoL;}}
1201
+ result=result/weight;return result;}
1202
+ #endif
1203
+ #endif
1204
+ #endif
1205
+ `;i.ShaderStore.IncludesShadersStoreWGSL[h]||(i.ShaderStore.IncludesShadersStoreWGSL[h]=m),e.s(["hdrFilteringFunctionsWGSL",0,{name:h,shader:m}],69075);let p="pbrBlockReflectance0",g=`var reflectanceF0: f32=reflectivityOut.reflectanceF0;var specularEnvironmentR0: vec3f=reflectivityOut.colorReflectanceF0;var specularEnvironmentR90: vec3f= reflectivityOut.reflectanceF90;
1206
+ #ifdef ALPHAFRESNEL
1207
+ var reflectance90: f32=fresnelGrazingReflectance(reflectanceF0);specularEnvironmentR90=specularEnvironmentR90*reflectance90;
1208
+ #endif
1209
+ `;i.ShaderStore.IncludesShadersStoreWGSL[p]||(i.ShaderStore.IncludesShadersStoreWGSL[p]=g),e.s(["pbrBlockReflectance0WGSL",0,{name:p,shader:g}],62026),e.i(87850);let S="pbrDirectLightingFunctions",L=`#define CLEARCOATREFLECTANCE90 1.0
1210
+ struct lightingInfo
1211
+ {diffuse: vec3f,
1212
+ #ifdef SS_TRANSLUCENCY
1213
+ diffuseTransmission: vec3f,
1214
+ #endif
1215
+ #ifdef SPECULARTERM
1216
+ specular: vec3f,
1217
+ #endif
1218
+ #ifdef CLEARCOAT
1219
+ clearCoat: vec4f,
1220
+ #endif
1221
+ #ifdef SHEEN
1222
+ sheen: vec3f
1223
+ #endif
1224
+ };fn adjustRoughnessFromLightProperties(roughness: f32,lightRadius: f32,lightDistance: f32)->f32 {
1225
+ #if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)
1226
+ var lightRoughness: f32=lightRadius/lightDistance;var totalRoughness: f32=saturate(lightRoughness+roughness);return totalRoughness;
1227
+ #else
1228
+ return roughness;
1229
+ #endif
1230
+ }
1231
+ fn computeHemisphericDiffuseLighting(info: preLightingInfo,lightColor: vec3f,groundColor: vec3f)->vec3f {return mix(groundColor,lightColor,info.NdotL);}
1232
+ #if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1233
+ fn computeAreaDiffuseLighting(info: preLightingInfo,lightColor: vec3f)->vec3f {return info.areaLightDiffuse*lightColor;}
1234
+ #endif
1235
+ fn computeDiffuseLighting(info: preLightingInfo,lightColor: vec3f)->vec3f {var diffuseTerm: vec3f=vec3f(1.0/PI);
1236
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_LEGACY
1237
+ diffuseTerm=vec3f(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness));
1238
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
1239
+ diffuseTerm=vec3f(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.diffuseRoughness));
1240
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
1241
+ var clampedAlbedo: vec3f=clamp(info.surfaceAlbedo,vec3f(0.1),vec3f(1.0));diffuseTerm=diffuseBRDF_EON(clampedAlbedo,info.diffuseRoughness,info.NdotL,info.NdotV,info.LdotV);diffuseTerm/=clampedAlbedo;
1242
+ #endif
1243
+ return diffuseTerm*info.attenuation*info.NdotL*lightColor;}
1244
+ fn computeProjectionTextureDiffuseLighting(projectionLightTexture: texture_2d<f32>,projectionLightSampler: sampler,textureProjectionMatrix: mat4x4f,posW: vec3f)->vec3f{var strq: vec4f=textureProjectionMatrix* vec4f(posW,1.0);strq/=strq.w;var textureColor: vec3f=textureSample(projectionLightTexture,projectionLightSampler,strq.xy).rgb;return toLinearSpaceVec3(textureColor);}
1245
+ #ifdef SS_TRANSLUCENCY
1246
+ fn computeDiffuseTransmittedLighting(info: preLightingInfo,lightColor: vec3f,transmittance: vec3f)->vec3f {var transmittanceNdotL=vec3f(0.0);var NdotL: f32=absEps(info.NdotLUnclamped);
1247
+ #ifndef SS_TRANSLUCENCY_LEGACY
1248
+ if (info.NdotLUnclamped<0.0) {
1249
+ #endif
1250
+ var wrapNdotL: f32=computeWrappedDiffuseNdotL(NdotL,0.02);var trAdapt: f32=step(0.,info.NdotLUnclamped);transmittanceNdotL=mix(transmittance*wrapNdotL, vec3f(wrapNdotL),trAdapt);
1251
+ #ifndef SS_TRANSLUCENCY_LEGACY
1252
+ }
1253
+ var diffuseTerm : vec3f=vec3f(1.0/PI);
1254
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_LEGACY
1255
+ diffuseTerm=vec3f(diffuseBRDF_Burley(
1256
+ info.NdotL,info.NdotV,info.VdotH,info.roughness));
1257
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
1258
+ diffuseTerm=vec3f(diffuseBRDF_Burley(
1259
+ info.NdotL,info.NdotV,info.VdotH,info.diffuseRoughness));
1260
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
1261
+ var clampedAlbedo: vec3f=clamp(info.surfaceAlbedo,vec3f(0.1),vec3f(1.0));diffuseTerm=diffuseBRDF_EON(clampedAlbedo,info.diffuseRoughness,
1262
+ info.NdotL,info.NdotV,info.LdotV);diffuseTerm/=clampedAlbedo;
1263
+ #endif
1264
+ return (transmittanceNdotL*diffuseTerm)*info.attenuation*lightColor;
1265
+ #else
1266
+ let diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;
1267
+ #endif
1268
+ }
1269
+ #endif
1270
+ #ifdef SPECULARTERM
1271
+ fn computeSpecularLighting(info: preLightingInfo,N: vec3f,reflectance0: vec3f,fresnel: vec3f,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var roughness: f32=max(info.roughness,geometricRoughnessFactor);var alphaG: f32=convertRoughnessToAverageSlope(roughness);var modifiedFresnel: vec3f=fresnel;
1272
+ #ifdef IRIDESCENCE
1273
+ modifiedFresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
1274
+ #endif
1275
+ var distribution: f32=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);
1276
+ #ifdef BRDF_V_HEIGHT_CORRELATED
1277
+ var smithVisibility: f32=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);
1278
+ #else
1279
+ var smithVisibility: f32=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);
1280
+ #endif
1281
+ var specTerm: vec3f=modifiedFresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;}
1282
+ #if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1283
+ fn computeAreaSpecularLighting(info: preLightingInfo,specularColor: vec3f,reflectance0: vec3f,reflectance90: vec3f)->vec3f {var fresnel:vec3f =reflectance0*specularColor*info.areaLightFresnel.x+( vec3f( 1.0 )-specularColor )*info.areaLightFresnel.y*reflectance90;return specularColor*fresnel*info.areaLightSpecular;}
1284
+ #endif
1285
+ #endif
1286
+ #ifdef FUZZ
1287
+ fn evalFuzz(L: vec3f,NdotL: f32,NdotV: f32,T: vec3f,B: vec3f,ltcLut: vec3f)->f32
1288
+ {if (NdotL<=0.0f || NdotV<=0.0f) {return 0.0f;}
1289
+ let M=mat3x3f(
1290
+ vec3f(ltcLut.r,0.0f,0.0f),
1291
+ vec3f(ltcLut.g,1.0f,0.0f),
1292
+ vec3f(0.0f,0.0f,1.0f)
1293
+ );let Llocal: vec3f=vec3f(dot(L,T),dot(L,B),NdotL);let Lwarp: vec3f=normalize(M*Llocal);let cosThetaWarp: f32=max(Lwarp.z,0.0f);return cosThetaWarp*NdotL;}
1294
+ #endif
1295
+ #if defined(ANISOTROPIC) && defined(ANISOTROPIC_OPENPBR)
1296
+ fn computeAnisotropicSpecularLighting(info: preLightingInfo,V: vec3f,N: vec3f,T: vec3f,B: vec3f,anisotropy: f32,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var TdotH: f32=dot(T,info.H);var BdotH: f32=dot(B,info.H);var TdotV: f32=dot(T,V);var BdotV: f32=dot(B,V);var TdotL: f32=dot(T,info.L);var BdotL: f32=dot(B,info.L);var alphaG: f32=convertRoughnessToAverageSlope(info.roughness);var alphaTB: vec2f=getAnisotropicRoughness(alphaG,anisotropy);var distribution: f32=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);var smithVisibility: f32=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);var specTerm: vec3f=vec3f(distribution*smithVisibility);return specTerm*info.attenuation*info.NdotL*lightColor;}
1297
+ #elif defined(ANISOTROPIC)
1298
+ fn computeAnisotropicSpecularLighting(info: preLightingInfo,V: vec3f,N: vec3f,T: vec3f,B: vec3f,anisotropy: f32,reflectance0: vec3f,reflectance90: vec3f,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var TdotH: f32=dot(T,info.H);var BdotH: f32=dot(B,info.H);var TdotV: f32=dot(T,V);var BdotV: f32=dot(B,V);var TdotL: f32=dot(T,info.L);var BdotL: f32=dot(B,info.L);var alphaG: f32=convertRoughnessToAverageSlope(info.roughness);var alphaTB: vec2f=getAnisotropicRoughness(alphaG,anisotropy);alphaTB=max(alphaTB,vec2f(geometricRoughnessFactor*geometricRoughnessFactor));var fresnel: vec3f=fresnelSchlickGGXVec3(info.VdotH,reflectance0,reflectance90);
1299
+ #ifdef IRIDESCENCE
1300
+ fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
1301
+ #endif
1302
+ var distribution: f32=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);var smithVisibility: f32=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);var specTerm: vec3f=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;}
1303
+ #endif
1304
+ #ifdef CLEARCOAT
1305
+ fn computeClearCoatLighting(info: preLightingInfo,Ncc: vec3f,geometricRoughnessFactor: f32,clearCoatIntensity: f32,lightColor: vec3f)->vec4f {var NccdotL: f32=saturateEps(dot(Ncc,info.L));var NccdotH: f32=saturateEps(dot(Ncc,info.H));var clearCoatRoughness: f32=max(info.roughness,geometricRoughnessFactor);var alphaG: f32=convertRoughnessToAverageSlope(clearCoatRoughness);var fresnel: f32=fresnelSchlickGGX(info.VdotH,uniforms.vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnel*=clearCoatIntensity;var distribution: f32=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);var kelemenVisibility: f32=visibility_Kelemen(info.VdotH);var clearCoatTerm: f32=fresnel*distribution*kelemenVisibility;return vec4f(
1306
+ clearCoatTerm*info.attenuation*NccdotL*lightColor,
1307
+ 1.0-fresnel
1308
+ );}
1309
+ fn computeClearCoatLightingAbsorption(NdotVRefract: f32,L: vec3f,Ncc: vec3f,clearCoatColor: vec3f,clearCoatThickness: f32,clearCoatIntensity: f32)->vec3f {var LRefract: vec3f=-refract(L,Ncc,uniforms.vClearCoatRefractionParams.y);var NdotLRefract: f32=saturateEps(dot(Ncc,LRefract));var absorption: vec3f=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);return absorption;}
1310
+ #endif
1311
+ #ifdef SHEEN
1312
+ fn computeSheenLighting(info: preLightingInfo,N: vec3f,reflectance0: vec3f,reflectance90: vec3f,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var roughness: f32=max(info.roughness,geometricRoughnessFactor);var alphaG: f32=convertRoughnessToAverageSlope(roughness);var fresnel: f32=1.;var distribution: f32=normalDistributionFunction_CharlieSheen(NdotH,alphaG);/*#ifdef SHEEN_SOFTER
1313
+ var visibility: f32=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG);
1314
+ #else */
1315
+ var visibility: f32=visibility_Ashikhmin(info.NdotL,info.NdotV);/* #endif */
1316
+ var sheenTerm: f32=fresnel*distribution*visibility;return sheenTerm*info.attenuation*info.NdotL*lightColor;}
1317
+ #endif
1318
+ #if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
1319
+ #include<clusteredLightingFunctions>
1320
+ fn computeClusteredLighting(
1321
+ lightDataTexture: texture_2d<f32>,
1322
+ tileMaskBuffer: ptr<storage,array<u32>>,
1323
+ lightData: vec4f,
1324
+ sliceRange: vec2u,
1325
+ V: vec3f,
1326
+ N: vec3f,
1327
+ posW: vec3f,
1328
+ surfaceAlbedo: vec3f,
1329
+ reflectivityOut: reflectivityOutParams,
1330
+ #ifdef IRIDESCENCE
1331
+ iridescenceIntensity: f32,
1332
+ #endif
1333
+ #ifdef SS_TRANSLUCENCY
1334
+ subSurfaceOut: subSurfaceOutParams,
1335
+ #endif
1336
+ #ifdef SPECULARTERM
1337
+ AARoughnessFactor: f32,
1338
+ #endif
1339
+ #ifdef ANISOTROPIC
1340
+ anisotropicOut: anisotropicOutParams,
1341
+ #endif
1342
+ #ifdef SHEEN
1343
+ sheenOut: sheenOutParams,
1344
+ #endif
1345
+ #ifdef CLEARCOAT
1346
+ clearcoatOut: clearcoatOutParams,
1347
+ #endif
1348
+ )->lightingInfo {let NdotV=absEps(dot(N,V));
1349
+ #include<pbrBlockReflectance0>
1350
+ #ifdef CLEARCOAT
1351
+ specularEnvironmentR0=clearcoatOut.specularEnvironmentR0;
1352
+ #endif
1353
+ var result: lightingInfo;let tilePosition=vec2u(fragmentInputs.position.xy*lightData.xy);let maskResolution=vec2u(lightData.zw);var tileIndex=(tilePosition.x*maskResolution.x+tilePosition.y)*maskResolution.y;let batchRange=sliceRange/CLUSTLIGHT_BATCH;var batchOffset=batchRange.x*CLUSTLIGHT_BATCH;tileIndex+=batchRange.x;for (var i=batchRange.x; i<=batchRange.y; i+=1) {var mask=tileMaskBuffer[tileIndex];tileIndex+=1;let maskOffset=max(sliceRange.x,batchOffset)-batchOffset;
1354
+ let maskWidth=min(sliceRange.y-batchOffset+1,CLUSTLIGHT_BATCH);mask=extractBits(mask,maskOffset,maskWidth);while mask != 0 {let trailing=firstTrailingBit(mask);mask ^= 1u<<trailing;let light=getClusteredLight(lightDataTexture,batchOffset+maskOffset+trailing);var preInfo=computePointAndSpotPreLightingInfo(light.vLightData,V,N,posW);preInfo.NdotV=NdotV;preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light.vLightFalloff.x,light.vLightFalloff.y);if light.vLightDirection.w>=0.0 {preInfo.attenuation*=computeDirectionalLightFalloff(light.vLightDirection.xyz,preInfo.L,light.vLightDirection.w,light.vLightData.w,light.vLightFalloff.z,light.vLightFalloff.w);}
1355
+ preInfo.roughness=adjustRoughnessFromLightProperties(reflectivityOut.roughness,light.vLightSpecular.a,preInfo.lightDistance);preInfo.diffuseRoughness=reflectivityOut.diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo;
1356
+ #ifdef IRIDESCENCE
1357
+ preInfo.iridescenceIntensity=iridescenceIntensity;
1358
+ #endif
1359
+ var info: lightingInfo;
1360
+ #ifdef SS_TRANSLUCENCY
1361
+ #ifdef SS_TRANSLUCENCY_LEGACY
1362
+ info.diffuse=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance);info.diffuseTransmission=vec3(0);
1363
+ #else
1364
+ info.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance);
1365
+ #endif
1366
+ #else
1367
+ info.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb);
1368
+ #endif
1369
+ #ifdef SPECULARTERM
1370
+ #if CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR
1371
+ let metalFresnel=reflectivityOut.specularWeight*getF82Specular(preInfo.VdotH,specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);let dielectricFresnel=fresnelSchlickGGXVec3(preInfo.VdotH,reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90);let coloredFresnel=mix(dielectricFresnel,metalFresnel,reflectivityOut.metallic);
1372
+ #else
1373
+ let coloredFresnel=fresnelSchlickGGXVec3(preInfo.VdotH,specularEnvironmentR0,reflectivityOut.colorReflectanceF90);
1374
+ #endif
1375
+ #ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION
1376
+ let NdotH=dot(N,preInfo.H);let fresnel=fresnelSchlickGGXVec3(NdotH,vec3(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3(1.0)-fresnel);
1377
+ #endif
1378
+ #ifdef ANISOTROPIC
1379
+ info.specular=computeAnisotropicSpecularLighting(preInfo,V,N,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb);
1380
+ #else
1381
+ info.specular=computeSpecularLighting(preInfo,N,specularEnvironmentR0,coloredFresnel,AARoughnessFactor,light.vLightDiffuse.rgb);
1382
+ #endif
1383
+ #endif
1384
+ #ifdef SHEEN
1385
+ #ifdef SHEEN_LINKWITHALBEDO
1386
+ preInfo.roughness=sheenOut.sheenIntensity;
1387
+ #else
1388
+ preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light.vLightSpecular.a,preInfo.lightDistance);
1389
+ #endif
1390
+ info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb);
1391
+ #endif
1392
+ #ifdef CLEARCOAT
1393
+ preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light.vLightSpecular.a,preInfo.lightDistance);info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light.vLightDiffuse.rgb);
1394
+ #ifdef CLEARCOAT_TINT
1395
+ let absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;
1396
+ #ifdef SS_TRANSLUCENCY
1397
+ info.diffuseTransmission*=absorption;
1398
+ #endif
1399
+ #ifdef SPECULARTERM
1400
+ info.specular*=absorption;
1401
+ #endif
1402
+ #endif
1403
+ info.diffuse*=info.clearCoat.w;
1404
+ #ifdef SS_TRANSLUCENCY
1405
+ info.diffuseTransmission*=info.clearCoat.w;
1406
+ #endif
1407
+ #ifdef SPECULARTERM
1408
+ info.specular*=info.clearCoat.w;
1409
+ #endif
1410
+ #ifdef SHEEN
1411
+ info.sheen*=info.clearCoat.w;
1412
+ #endif
1413
+ #endif
1414
+ result.diffuse+=info.diffuse;
1415
+ #ifdef SS_TRANSLUCENCY
1416
+ result.diffuseTransmission+=info.diffuseTransmission;
1417
+ #endif
1418
+ #ifdef SPECULARTERM
1419
+ result.specular+=info.specular;
1420
+ #endif
1421
+ #ifdef CLEARCOAT
1422
+ result.clearCoat+=info.clearCoat;
1423
+ #endif
1424
+ #ifdef SHEEN
1425
+ result.sheen+=info.sheen;
1426
+ #endif
1427
+ }
1428
+ batchOffset+=CLUSTLIGHT_BATCH;}
1429
+ return result;}
1430
+ #endif
1431
+ `;i.ShaderStore.IncludesShadersStoreWGSL[S]||(i.ShaderStore.IncludesShadersStoreWGSL[S]=L),e.s(["pbrDirectLightingFunctionsWGSL",0,{name:S,shader:L}],28285);let E="pbrBlockNormalGeometric",I=`var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-input.vPositionW);
1432
+ #ifdef NORMAL
1433
+ var normalW: vec3f=normalize(input.vNormalW);
1434
+ #else
1435
+ var normalW: vec3f=normalize(cross(dpdx(input.vPositionW),dpdy(input.vPositionW)))*scene.vEyePosition.w;
1436
+ #endif
1437
+ var geometricNormalW: vec3f=normalW;
1438
+ #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
1439
+ geometricNormalW=select(-geometricNormalW,geometricNormalW,fragmentInputs.frontFacing);
1440
+ #endif
1441
+ `;i.ShaderStore.IncludesShadersStoreWGSL[E]||(i.ShaderStore.IncludesShadersStoreWGSL[E]=I),e.s(["pbrBlockNormalGeometricWGSL",0,{name:E,shader:I}],74698);let T="pbrBlockImageProcessing",A=`#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING)
1442
+ #if !defined(SKIPFINALCOLORCLAMP)
1443
+ finalColor=vec4f(clamp(finalColor.rgb,vec3f(0.),vec3f(30.0)),finalColor.a);
1444
+ #endif
1445
+ #else
1446
+ finalColor=applyImageProcessing(finalColor);
1447
+ #endif
1448
+ finalColor=vec4f(finalColor.rgb,finalColor.a*mesh.visibility);
1449
+ #ifdef PREMULTIPLYALPHA
1450
+ finalColor=vec4f(finalColor.rgb*finalColor.a,finalColor.a);;
1451
+ #endif
1452
+ `;i.ShaderStore.IncludesShadersStoreWGSL[T]||(i.ShaderStore.IncludesShadersStoreWGSL[T]=A),e.s(["pbrBlockImageProcessingWGSL",0,{name:T,shader:A}],52640);let D="pbrDebug",R=`#if DEBUGMODE>0
1453
+ if (input.vClipSpacePosition.x/input.vClipSpacePosition.w>=uniforms.vDebugMode.x) {var color: vec3f;
1454
+ #if DEBUGMODE==1
1455
+ color=fragmentInputs.vPositionW.rgb;
1456
+ #define DEBUGMODE_NORMALIZE
1457
+ #elif DEBUGMODE==2 && defined(NORMAL)
1458
+ color=fragmentInputs.vNormalW.rgb;
1459
+ #define DEBUGMODE_NORMALIZE
1460
+ #elif DEBUGMODE==3 && defined(BUMP) || DEBUGMODE==3 && defined(PARALLAX) || DEBUGMODE==3 && defined(ANISOTROPIC)
1461
+ color=TBN[0];
1462
+ #define DEBUGMODE_NORMALIZE
1463
+ #elif DEBUGMODE==4 && defined(BUMP) || DEBUGMODE==4 && defined(PARALLAX) || DEBUGMODE==4 && defined(ANISOTROPIC)
1464
+ color=TBN[1];
1465
+ #define DEBUGMODE_NORMALIZE
1466
+ #elif DEBUGMODE==5
1467
+ color=normalW;
1468
+ #define DEBUGMODE_NORMALIZE
1469
+ #elif DEBUGMODE==6 && defined(MAINUV1)
1470
+ color= vec3f(input.vMainUV1,0.0);
1471
+ #elif DEBUGMODE==7 && defined(MAINUV2)
1472
+ color= vec3f(input.vMainUV2,0.0);
1473
+ #elif DEBUGMODE==8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
1474
+ color=clearcoatOut.TBNClearCoat[0];
1475
+ #define DEBUGMODE_NORMALIZE
1476
+ #elif DEBUGMODE==9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
1477
+ color=clearcoatOut.TBNClearCoat[1];
1478
+ #define DEBUGMODE_NORMALIZE
1479
+ #elif DEBUGMODE==10 && defined(CLEARCOAT)
1480
+ color=clearcoatOut.clearCoatNormalW;
1481
+ #define DEBUGMODE_NORMALIZE
1482
+ #elif DEBUGMODE==11 && defined(ANISOTROPIC)
1483
+ color=anisotropicOut.anisotropicNormal;
1484
+ #define DEBUGMODE_NORMALIZE
1485
+ #elif DEBUGMODE==12 && defined(ANISOTROPIC)
1486
+ color=anisotropicOut.anisotropicTangent;
1487
+ #define DEBUGMODE_NORMALIZE
1488
+ #elif DEBUGMODE==13 && defined(ANISOTROPIC)
1489
+ color=anisotropicOut.anisotropicBitangent;
1490
+ #define DEBUGMODE_NORMALIZE
1491
+ #elif DEBUGMODE==20 && defined(ALBEDO)
1492
+ color=albedoTexture.rgb;
1493
+ #ifndef GAMMAALBEDO
1494
+ #define DEBUGMODE_GAMMA
1495
+ #endif
1496
+ #elif DEBUGMODE==21 && defined(AMBIENT)
1497
+ color=aoOut.ambientOcclusionColorMap.rgb;
1498
+ #elif DEBUGMODE==22 && defined(OPACITY)
1499
+ color=opacityMap.rgb;
1500
+ #elif DEBUGMODE==23 && defined(EMISSIVE)
1501
+ color=emissiveColorTex.rgb;
1502
+ #ifndef GAMMAEMISSIVE
1503
+ #define DEBUGMODE_GAMMA
1504
+ #endif
1505
+ #elif DEBUGMODE==24 && defined(LIGHTMAP)
1506
+ color=lightmapColor;
1507
+ #ifndef GAMMALIGHTMAP
1508
+ #define DEBUGMODE_GAMMA
1509
+ #endif
1510
+ #elif DEBUGMODE==25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
1511
+ color=reflectivityOut.surfaceMetallicColorMap.rgb;
1512
+ #elif DEBUGMODE==26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
1513
+ color=reflectivityOut.surfaceReflectivityColorMap.rgb;
1514
+ #define DEBUGMODE_GAMMA
1515
+ #elif DEBUGMODE==27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
1516
+ color= vec3f(clearcoatOut.clearCoatMapData.rg,0.0);
1517
+ #elif DEBUGMODE==28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
1518
+ color=clearcoatOut.clearCoatTintMapData.rgb;
1519
+ #elif DEBUGMODE==29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
1520
+ color=sheenOut.sheenMapData.rgb;
1521
+ #elif DEBUGMODE==30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
1522
+ color=anisotropicOut.anisotropyMapData.rgb;
1523
+ #elif DEBUGMODE==31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
1524
+ color=subSurfaceOut.thicknessMap.rgb;
1525
+ #elif DEBUGMODE==32 && defined(BUMP)
1526
+ color=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).rgb;
1527
+ #elif DEBUGMODE==40 && defined(SS_REFRACTION)
1528
+ color=subSurfaceOut.environmentRefraction.rgb;
1529
+ #define DEBUGMODE_GAMMA
1530
+ #elif DEBUGMODE==41 && defined(REFLECTION)
1531
+ color=reflectionOut.environmentRadiance.rgb;
1532
+ #ifndef GAMMAREFLECTION
1533
+ #define DEBUGMODE_GAMMA
1534
+ #endif
1535
+ #elif DEBUGMODE==42 && defined(CLEARCOAT) && defined(REFLECTION)
1536
+ color=clearcoatOut.environmentClearCoatRadiance.rgb;
1537
+ #define DEBUGMODE_GAMMA
1538
+ #elif DEBUGMODE==50
1539
+ color=diffuseBase.rgb;
1540
+ #define DEBUGMODE_GAMMA
1541
+ #elif DEBUGMODE==51 && defined(SPECULARTERM)
1542
+ color=specularBase.rgb;
1543
+ #define DEBUGMODE_GAMMA
1544
+ #elif DEBUGMODE==52 && defined(CLEARCOAT)
1545
+ color=clearCoatBase.rgb;
1546
+ #define DEBUGMODE_GAMMA
1547
+ #elif DEBUGMODE==53 && defined(SHEEN)
1548
+ color=sheenBase.rgb;
1549
+ #define DEBUGMODE_GAMMA
1550
+ #elif DEBUGMODE==54 && defined(REFLECTION)
1551
+ color=reflectionOut.environmentIrradiance.rgb;
1552
+ #ifndef GAMMAREFLECTION
1553
+ #define DEBUGMODE_GAMMA
1554
+ #endif
1555
+ #elif DEBUGMODE==60
1556
+ color=surfaceAlbedo.rgb;
1557
+ #define DEBUGMODE_GAMMA
1558
+ #elif DEBUGMODE==61
1559
+ color=clearcoatOut.specularEnvironmentR0;
1560
+ #define DEBUGMODE_GAMMA
1561
+ #elif DEBUGMODE==62 && defined(METALLICWORKFLOW)
1562
+ color= vec3f(reflectivityOut.metallic);
1563
+ #elif DEBUGMODE==71 && defined(METALLICWORKFLOW)
1564
+ color=reflectivityOut.metallicF0;
1565
+ #elif DEBUGMODE==63
1566
+ color= vec3f(roughness);
1567
+ #elif DEBUGMODE==64
1568
+ color= vec3f(alphaG);
1569
+ #elif DEBUGMODE==65
1570
+ color= vec3f(NdotV);
1571
+ #elif DEBUGMODE==66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
1572
+ color=clearcoatOut.clearCoatColor;
1573
+ #define DEBUGMODE_GAMMA
1574
+ #elif DEBUGMODE==67 && defined(CLEARCOAT)
1575
+ color= vec3f(clearcoatOut.clearCoatRoughness);
1576
+ #elif DEBUGMODE==68 && defined(CLEARCOAT)
1577
+ color= vec3f(clearcoatOut.clearCoatNdotV);
1578
+ #elif DEBUGMODE==69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
1579
+ color=subSurfaceOut.transmittance;
1580
+ #elif DEBUGMODE==70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
1581
+ color=subSurfaceOut.refractionTransmittance;
1582
+ #elif DEBUGMODE==72
1583
+ color= vec3f(microSurface);
1584
+ #elif DEBUGMODE==73
1585
+ color=uniforms.vAlbedoColor.rgb;
1586
+ #define DEBUGMODE_GAMMA
1587
+ #elif DEBUGMODE==74 && !defined(METALLICWORKFLOW)
1588
+ color=uniforms.vReflectivityColor.rgb;
1589
+ #define DEBUGMODE_GAMMA
1590
+ #elif DEBUGMODE==75
1591
+ color=uniforms.vEmissiveColor;
1592
+ #define DEBUGMODE_GAMMA
1593
+ #elif DEBUGMODE==80 && defined(RADIANCEOCCLUSION)
1594
+ color= vec3f(seo);
1595
+ #elif DEBUGMODE==81 && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
1596
+ color= vec3f(eho);
1597
+ #elif DEBUGMODE==82 && defined(MS_BRDF_ENERGY_CONSERVATION)
1598
+ color= vec3f(energyConservationFactor);
1599
+ #elif DEBUGMODE==83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
1600
+ color=baseSpecularEnvironmentReflectance;
1601
+ #define DEBUGMODE_GAMMA
1602
+ #elif DEBUGMODE==84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
1603
+ color=clearcoatOut.clearCoatEnvironmentReflectance;
1604
+ #define DEBUGMODE_GAMMA
1605
+ #elif DEBUGMODE==85 && defined(SHEEN) && defined(REFLECTION)
1606
+ color=sheenOut.sheenEnvironmentReflectance;
1607
+ #define DEBUGMODE_GAMMA
1608
+ #elif DEBUGMODE==86 && defined(ALPHABLEND)
1609
+ color= vec3f(luminanceOverAlpha);
1610
+ #elif DEBUGMODE==87
1611
+ color= vec3f(alpha);
1612
+ #elif DEBUGMODE==88 && defined(ALBEDO)
1613
+ color= vec3f(albedoTexture.a);
1614
+ #elif DEBUGMODE==89
1615
+ color=aoOut.ambientOcclusionColor;
1616
+ #else
1617
+ var stripeWidth: f32=30.;var stripePos: f32=abs(floor(input.position.x/stripeWidth));var whichColor: f32=((stripePos)%(2.));var color1: vec3f= vec3f(.6,.2,.2);var color2: vec3f= vec3f(.3,.1,.1);color=mix(color1,color2,whichColor);
1618
+ #endif
1619
+ color*=uniforms.vDebugMode.y;
1620
+ #ifdef DEBUGMODE_NORMALIZE
1621
+ color=normalize(color)*0.5+0.5;
1622
+ #endif
1623
+ #ifdef DEBUGMODE_GAMMA
1624
+ color=toGammaSpaceVec3(color);
1625
+ #endif
1626
+ fragmentOutputs.color=vec4f(color,1.0);
1627
+ #ifdef PREPASS
1628
+ fragmentOutputs.fragData0=toLinearSpaceVec3(color);
1629
+ fragmentOutputs.fragData1=vec4f(0.,0.,0.,0.);
1630
+ #endif
1631
+ #ifdef DEBUGMODE_FORCERETURN
1632
+ return fragmentOutputs;
1633
+ #endif
1634
+ }
1635
+ #endif
1636
+ `;i.ShaderStore.IncludesShadersStoreWGSL[D]||(i.ShaderStore.IncludesShadersStoreWGSL[D]=R),e.s(["pbrDebugWGSL",0,{name:D,shader:R}],87693)}]);