@uptimizr/dashboard 0.1.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/README.md +1 -1
  2. package/out/404.html +1 -1
  3. package/out/__next.__PAGE__.txt +4 -4
  4. package/out/__next._full.txt +11 -11
  5. package/out/__next._head.txt +4 -4
  6. package/out/__next._index.txt +4 -4
  7. package/out/__next._tree.txt +2 -2
  8. package/out/_next/static/chunks/002cjeoit6-up.js +1 -0
  9. package/out/_next/static/chunks/02n1uiltexy3w.js +1 -0
  10. package/out/_next/static/chunks/03ab2khhe8-x5.js +1 -0
  11. package/out/_next/static/chunks/04_yytpc2paxy.js +1 -0
  12. package/out/_next/static/chunks/06qot1qvlsqaz.js +1 -0
  13. package/out/_next/static/chunks/07eeopuufsqp-.js +1501 -0
  14. package/out/_next/static/chunks/08a5xek662n8n.js +1 -0
  15. package/out/_next/static/chunks/08wuc9--s8zn_.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/0grlb9lo8e502.js +1 -0
  25. package/out/_next/static/chunks/0h22pg-0xrxnm.js +1 -0
  26. package/out/_next/static/chunks/0j6p1pmc14t96.js +1 -0
  27. package/out/_next/static/chunks/0j_6dx-sttgsy.js +1 -0
  28. package/out/_next/static/chunks/0j__xaq_8_di1.js +1 -0
  29. package/out/_next/static/chunks/0kfd-cvj5fvtz.js +1 -0
  30. package/out/_next/static/chunks/0o_mp98xzqfyf.js +1 -0
  31. package/out/_next/static/chunks/0otsec99kdkt7.js +213 -0
  32. package/out/_next/static/chunks/0ql-s-tsmel_u.js +151 -0
  33. package/out/_next/static/chunks/0r47gs_e93cka.js +1 -0
  34. package/out/_next/static/chunks/0sqys6o2pbe1q.js +1328 -0
  35. package/out/_next/static/chunks/0titqrn1qmcsv.js +1 -0
  36. package/out/_next/static/chunks/0tnlbw78tgaxp.js +4 -0
  37. package/out/_next/static/chunks/0tw4dyl-cp-hd.js +1 -0
  38. package/out/_next/static/chunks/0vbce-8omgurc.js +1 -0
  39. package/out/_next/static/chunks/0vfsg5byzep_0.js +1 -0
  40. package/out/_next/static/chunks/{0gv7mblzv3dl3.js → 0w8_1yjvol1f0.js} +20 -20
  41. package/out/_next/static/chunks/0xh144a5fz58h.js +1 -0
  42. package/out/_next/static/chunks/0xjltg_pph0c8.js +1 -0
  43. package/out/_next/static/chunks/0yeqgh0dnas8d.js +1 -0
  44. package/out/_next/static/chunks/101-7e_7up7rk.js +1 -0
  45. package/out/_next/static/chunks/128e51hj_04r0.js +1 -0
  46. package/out/_next/static/chunks/{10fnxpln_5xfd.js → 12kv810lohbsx.js} +2 -2
  47. package/out/_next/static/chunks/14bws-suyy5zu.js +1 -0
  48. package/out/_next/static/chunks/14ggsmqwej_tt.js +1656 -0
  49. package/out/_next/static/chunks/17genz6pkmty_.js +1 -0
  50. package/out/_next/static/chunks/17xd8hnazzr0g.js +1454 -0
  51. package/out/_next/static/chunks/18dczy9ylt2s_.js +1 -0
  52. package/out/_next/static/chunks/18xs_kvsaolb0.js +1 -0
  53. package/out/_next/static/chunks/19016f8-ry0z6.js +1 -0
  54. package/out/_next/static/chunks/1_6oejyxj39li.js +1 -0
  55. package/out/_next/static/chunks/1_aon8nz9p1fr.js +1 -0
  56. package/out/_next/static/chunks/1_qzlkuxukhpq.js +779 -0
  57. package/out/_next/static/chunks/1akaj5rhgitn3.js +1 -0
  58. package/out/_next/static/chunks/1bvl1ws7b_3gn.js +1 -0
  59. package/out/_next/static/chunks/1cdbk6kxyr1c9.js +1 -0
  60. package/out/_next/static/chunks/1fbjkk55uu4_g.js +1 -0
  61. package/out/_next/static/chunks/1furcfsgrw_3g.js +1 -0
  62. package/out/_next/static/chunks/1g0-f1g3gn_rs.js +1 -0
  63. package/out/_next/static/chunks/1g7emwu85bifo.js +557 -0
  64. package/out/_next/static/chunks/{37vzwr3ciejf1.js → 1gs-5722l4u59.js} +1 -1
  65. package/out/_next/static/chunks/1gt4kh0_xmigy.js +1 -0
  66. package/out/_next/static/chunks/1h8xzuuhhglu9.js +1 -0
  67. package/out/_next/static/chunks/1hatz-jlztrn0.js +1 -0
  68. package/out/_next/static/chunks/1iioifo7i0t0_.js +1 -0
  69. package/out/_next/static/chunks/{0impkpmxx3ttp.js → 1iiz7jqgj20z0.js} +1 -1
  70. package/out/_next/static/chunks/1kujmd5n0j9nk.js +1 -0
  71. package/out/_next/static/chunks/{2kazjq29jeamx.js → 1ltux4lwz7muf.js} +160 -372
  72. package/out/_next/static/chunks/1m_buecgcq67j.js +740 -0
  73. package/out/_next/static/chunks/1n9sy0yt5d2vq.js +1 -0
  74. package/out/_next/static/chunks/1p1gz6dseck--.js +1 -0
  75. package/out/_next/static/chunks/1p1xtsfwvpuqo.js +1 -0
  76. package/out/_next/static/chunks/1p8f6okk2ewbz.js +1 -0
  77. package/out/_next/static/chunks/1qg_etglhvp9h.js +740 -0
  78. package/out/_next/static/chunks/1th_t5ujeqlkf.js +1 -0
  79. package/out/_next/static/chunks/1thr-mdzbu96v.js +1 -0
  80. package/out/_next/static/chunks/1tta1a064979p.js +1 -0
  81. package/out/_next/static/chunks/1u_riwm0nfww7.js +1 -0
  82. package/out/_next/static/chunks/1ua15kzid0_8p.js +2560 -0
  83. package/out/_next/static/chunks/1uu-rt_8p1edp.js +2712 -0
  84. package/out/_next/static/chunks/1uu93wuxigx4k.js +1 -0
  85. package/out/_next/static/chunks/1vuq3dos1406d.css +3 -0
  86. package/out/_next/static/chunks/1ynju1jqfrcv0.js +1 -0
  87. package/out/_next/static/chunks/1zfojlgb15okk.js +1 -0
  88. package/out/_next/static/chunks/1zj8x5wbgnzz-.js +1 -0
  89. package/out/_next/static/chunks/1zl6t15gh34nn.js +1 -0
  90. package/out/_next/static/chunks/2-qo2o1_fmpy-.js +3 -0
  91. package/out/_next/static/chunks/{1thjncpj7u6pq.js → 223vrr_4sfhsj.js} +1 -1
  92. package/out/_next/static/chunks/22cr2b04btguf.js +1 -0
  93. package/out/_next/static/chunks/242xhzxxetctz.js +1 -0
  94. package/out/_next/static/chunks/24essz5mmvx-6.js +1 -0
  95. package/out/_next/static/chunks/256k1jw1m--l7.js +146 -0
  96. package/out/_next/static/chunks/259obyrpxcv6r.js +1 -0
  97. package/out/_next/static/chunks/26v9yqicofqba.js +1 -0
  98. package/out/_next/static/chunks/290d93hmm_e8b.js +1 -0
  99. package/out/_next/static/chunks/2_2fk7iddrs43.js +1 -0
  100. package/out/_next/static/chunks/{00k_j_r7bv_eb.js → 2bjlls8-qe05r.js} +9 -9
  101. package/out/_next/static/chunks/2ckd7f1wbfod-.js +1 -0
  102. package/out/_next/static/chunks/{163fa70v4mgxj.js → 2d6hru4qo23tt.js} +1 -1
  103. package/out/_next/static/chunks/2ejvntxtvf5o9.js +1 -0
  104. package/out/_next/static/chunks/2f7_3tzf7xhps.js +1 -0
  105. package/out/_next/static/chunks/2gxd_o1g89_bv.js +1 -0
  106. package/out/_next/static/chunks/2hd2txb4-m9k1.js +1 -0
  107. package/out/_next/static/chunks/2hpxou_cnp4f_.js +1 -0
  108. package/out/_next/static/chunks/2izioctrfc0s5.js +1 -0
  109. package/out/_next/static/chunks/2jhnk4h4n0udv.js +1 -0
  110. package/out/_next/static/chunks/2jpkhkk9zi8-f.js +1 -0
  111. package/out/_next/static/chunks/2kpet_l1kq2sx.js +1 -0
  112. package/out/_next/static/chunks/2nck5w4c7leb7.js +1 -0
  113. package/out/_next/static/chunks/2qq3uzsbiicw3.js +1194 -0
  114. package/out/_next/static/chunks/2qqqpu0ahfdda.js +1 -0
  115. package/out/_next/static/chunks/2r3ct6se2qn8z.js +1 -0
  116. package/out/_next/static/chunks/2u-f7mmxvk8wj.js +1 -0
  117. package/out/_next/static/chunks/2ue1wo4ryk87z.js +1 -0
  118. package/out/_next/static/chunks/2uk-vwlxe9-xr.js +1 -0
  119. package/out/_next/static/chunks/2ur5-lxdvv1jm.js +1 -0
  120. package/out/_next/static/chunks/2veqsohwfhfqc.js +1 -0
  121. package/out/_next/static/chunks/2vqlv9wnewhu9.js +1 -0
  122. package/out/_next/static/chunks/{1zvc1tv--w8nn.js → 2wzshintp5lf8.js} +1 -1
  123. package/out/_next/static/chunks/2x-00glogc485.js +1 -0
  124. package/out/_next/static/chunks/2yfxy0f5fqs4o.js +1 -0
  125. package/out/_next/static/chunks/2z88mt3ixktu3.js +1 -0
  126. package/out/_next/static/chunks/2z_jn9ud28fk7.js +1 -0
  127. package/out/_next/static/chunks/3-eswqjobiqk1.js +1 -0
  128. package/out/_next/static/chunks/30-tbi7pys6fp.js +4 -0
  129. package/out/_next/static/chunks/30c-nsedy_ce0.js +1 -0
  130. package/out/_next/static/chunks/31u5lbu1vxznh.js +1 -0
  131. package/out/_next/static/chunks/{2feca0xcipcyt.js → 32ahba5ezp467.js} +156 -156
  132. package/out/_next/static/chunks/337hn35kts7ud.js +1 -0
  133. package/out/_next/static/chunks/33dgpebv-tf73.js +1 -0
  134. package/out/_next/static/chunks/36jkdhq6kb-cf.js +1 -0
  135. package/out/_next/static/chunks/37epa8fz59vba.js +1166 -0
  136. package/out/_next/static/chunks/3833xfnz0a-ub.js +1 -0
  137. package/out/_next/static/chunks/38awrh_qxn22k.js +1 -0
  138. package/out/_next/static/chunks/{0wrm9jr-9bw0e.js → 38x3c1ra5slhe.js} +383 -913
  139. package/out/_next/static/chunks/39idqlqlcp5b9.js +1 -0
  140. package/out/_next/static/chunks/{2a3spdq-m8drh.js → 3_gku1pwluoo0.js} +1 -1
  141. package/out/_next/static/chunks/3_mu-4rdjajna.js +1450 -0
  142. package/out/_next/static/chunks/3coacc4-g-g5c.js +1 -0
  143. package/out/_next/static/chunks/3e00fzdfkclzq.js +1 -0
  144. package/out/_next/static/chunks/3e8fmlq0k5wkg.js +1 -0
  145. package/out/_next/static/chunks/3e9tzyrt4_98z.js +1 -0
  146. package/out/_next/static/chunks/3edelqkq92pil.js +1 -0
  147. package/out/_next/static/chunks/3figbil1t4ssj.js +593 -0
  148. package/out/_next/static/chunks/3gimb3z_mteou.js +1 -0
  149. package/out/_next/static/chunks/{2p2vv6cc9i-3q.js → 3idaz_s77e-j_.js} +9 -9
  150. package/out/_next/static/chunks/3j-4wuhs5weba.js +1 -0
  151. package/out/_next/static/chunks/3jjfnwvybayy7.js +1 -0
  152. package/out/_next/static/chunks/3jwm5dfk_78gc.js +1 -0
  153. package/out/_next/static/chunks/3k9d4ylc3li2t.js +1352 -0
  154. package/out/_next/static/chunks/3l3_0ack3gy4k.js +1 -0
  155. package/out/_next/static/chunks/3lwhs5ja7tun3.js +1 -0
  156. package/out/_next/static/chunks/3m6nmp2dca6un.js +1342 -0
  157. package/out/_next/static/chunks/3mbnfpufs2-7e.js +7 -0
  158. package/out/_next/static/chunks/3mcd08gmt038z.js +1 -0
  159. package/out/_next/static/chunks/3mt5th7b1i_u9.js +1 -0
  160. package/out/_next/static/chunks/3ne77mjdz2y7o.js +1 -0
  161. package/out/_next/static/chunks/3puhrqtujktyv.js +1 -0
  162. package/out/_next/static/chunks/3rdifucupcgkg.js +1 -0
  163. package/out/_next/static/chunks/3riekaxl3uxfb.js +1195 -0
  164. package/out/_next/static/chunks/3sdoskq_buttj.js +1 -0
  165. package/out/_next/static/chunks/3tg-ma9tv9xu4.js +1 -0
  166. package/out/_next/static/chunks/3tm-pqpmq_ppw.js +1 -0
  167. package/out/_next/static/chunks/3w9go565cjhq3.js +1636 -0
  168. package/out/_next/static/chunks/3wi9gzq2mtr_q.js +8 -0
  169. package/out/_next/static/chunks/3xagd_2_9zft2.js +1 -0
  170. package/out/_next/static/chunks/3xsq_anpad-fb.js +1 -0
  171. package/out/_next/static/chunks/3ycv2qq7vpbua.js +1 -0
  172. package/out/_next/static/chunks/3z84au-mitjjw.js +1 -0
  173. package/out/_next/static/chunks/4030dhur2h70-.js +1 -0
  174. package/out/_next/static/chunks/40ffffml4h_3r.js +4 -0
  175. package/out/_next/static/chunks/{3-shckrcpvbxu.js → 41wt50z9tx9cx.js} +108 -711
  176. package/out/_next/static/chunks/{1flb8adpj6_2o.js → 42k2-4_2hrg6u.js} +1 -1
  177. package/out/_next/static/chunks/431slrqh0wa0g.js +1 -0
  178. package/out/_next/static/chunks/43s_lbd1i2krj.js +1 -0
  179. package/out/_next/static/chunks/{0-2y-_oomza2l.js → 44nxswtahaq4w.js} +18 -18
  180. package/out/_next/static/chunks/45bwefvdpztfs.js +1 -0
  181. package/out/_next/static/chunks/{turbopack-0sgd6pfbe1fy6.js → turbopack-19105pdhzxp1x.js} +1 -1
  182. package/out/_not-found/__next._full.txt +9 -9
  183. package/out/_not-found/__next._head.txt +4 -4
  184. package/out/_not-found/__next._index.txt +4 -4
  185. package/out/_not-found/__next._not-found.__PAGE__.txt +2 -2
  186. package/out/_not-found/__next._not-found.txt +3 -3
  187. package/out/_not-found/__next._tree.txt +2 -2
  188. package/out/_not-found.html +1 -1
  189. package/out/_not-found.txt +9 -9
  190. package/out/index.html +1 -1
  191. package/out/index.txt +11 -11
  192. package/package.json +5 -4
  193. package/out/_next/static/chunks/068j6934u8j16.js +0 -1
  194. package/out/_next/static/chunks/09e4adtr6w0xe.js +0 -1
  195. package/out/_next/static/chunks/0_rf76jneiwal.js +0 -176
  196. package/out/_next/static/chunks/0aznt7717miff.js +0 -1
  197. package/out/_next/static/chunks/0cu-q5q3a7uf3.js +0 -1
  198. package/out/_next/static/chunks/0fskcfh9vbhtv.js +0 -1
  199. package/out/_next/static/chunks/0o_tpe5tlugtr.js +0 -3
  200. package/out/_next/static/chunks/0pj9pajm2xz97.css +0 -3
  201. package/out/_next/static/chunks/0ufbyo1x3qkmo.js +0 -1
  202. package/out/_next/static/chunks/0wwcfw8i3j_zx.js +0 -1
  203. package/out/_next/static/chunks/0ys9-ozuluawt.js +0 -1
  204. package/out/_next/static/chunks/1-61zh4waha61.js +0 -1
  205. package/out/_next/static/chunks/10r_824wzt8hj.js +0 -1
  206. package/out/_next/static/chunks/11v6j6q59u-f_.js +0 -1
  207. package/out/_next/static/chunks/123xxske5c9na.js +0 -1
  208. package/out/_next/static/chunks/13isnf0--pmx1.js +0 -1
  209. package/out/_next/static/chunks/157d9euci08yu.js +0 -1
  210. package/out/_next/static/chunks/18u58lorfahxi.js +0 -4
  211. package/out/_next/static/chunks/1_aahautsz2v_.js +0 -1
  212. package/out/_next/static/chunks/1o1d0p-v1z8ty.js +0 -1
  213. package/out/_next/static/chunks/1vdjn0pkoyypn.js +0 -1
  214. package/out/_next/static/chunks/1yehxf-fmeicg.js +0 -1
  215. package/out/_next/static/chunks/1zx2q-r32thv1.js +0 -4
  216. package/out/_next/static/chunks/2-sjjedfr0kfq.js +0 -1
  217. package/out/_next/static/chunks/25b9x-li-tvk2.js +0 -1
  218. package/out/_next/static/chunks/2aelw3far6rii.js +0 -1
  219. package/out/_next/static/chunks/2aor7m-wbis85.js +0 -1
  220. package/out/_next/static/chunks/2fh-_9b6tqhvb.js +0 -1
  221. package/out/_next/static/chunks/2g5gecypj0rqe.js +0 -1
  222. package/out/_next/static/chunks/2szdcpl41-kzv.js +0 -1
  223. package/out/_next/static/chunks/2u6shh3oeycm-.js +0 -1
  224. package/out/_next/static/chunks/2unhhuv0arlcv.js +0 -1
  225. package/out/_next/static/chunks/310uz81hnnzsu.js +0 -1
  226. package/out/_next/static/chunks/3i3gbhccmhu7j.js +0 -210
  227. package/out/_next/static/chunks/3mqy-84_ul3t2.js +0 -1
  228. package/out/_next/static/chunks/3nz-dh9d7cehk.js +0 -1
  229. package/out/_next/static/chunks/3pufs8g4ui943.js +0 -1
  230. package/out/_next/static/chunks/3t06schbtqonl.js +0 -1
  231. package/out/_next/static/chunks/3v3-7fio3nw_t.js +0 -1
  232. package/out/_next/static/chunks/3v5ha25nxo43j.js +0 -1
  233. package/out/_next/static/chunks/3zskk1hxu3-_o.js +0 -1
  234. /package/out/_next/static/{yttuijl-0Cn9k8uTCfhIM → 1NTbwHeIsn3AW-SeH9aP0}/_buildManifest.js +0 -0
  235. /package/out/_next/static/{yttuijl-0Cn9k8uTCfhIM → 1NTbwHeIsn3AW-SeH9aP0}/_clientMiddlewareManifest.js +0 -0
  236. /package/out/_next/static/{yttuijl-0Cn9k8uTCfhIM → 1NTbwHeIsn3AW-SeH9aP0}/_ssgManifest.js +0 -0
@@ -0,0 +1,1454 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,4357,e=>{"use strict";var r=e.i(12423);let i="helperFunctions",f=`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
+ `;r.ShaderStore.IncludesShadersStoreWGSL[i]||(r.ShaderStore.IncludesShadersStoreWGSL[i]=f),e.s(["helperFunctionsWGSL",0,{name:i,shader:f}])},60106,e=>{"use strict";var r=e.i(12423);let i="sceneUboDeclaration",f=`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
+ `;r.ShaderStore.IncludesShadersStoreWGSL[i]||(r.ShaderStore.IncludesShadersStoreWGSL[i]=f),e.s(["sceneUboDeclarationWGSL",0,{name:i,shader:f}])},50008,39780,54758,e=>{"use strict";var r=e.i(12423);let i="meshUboDeclaration",f=`struct Mesh {world : mat4x4<f32>,
98
+ visibility : f32,};var<uniform> mesh : Mesh;
99
+ #define WORLD_UBO
100
+ `;r.ShaderStore.IncludesShadersStoreWGSL[i]||(r.ShaderStore.IncludesShadersStoreWGSL[i]=f),e.s(["meshUboDeclarationWGSL",0,{name:i,shader:f}],50008);let t="mainUVVaryingDeclaration",n=`#ifdef MAINUV{X}
101
+ varying vMainUV{X}: vec2f;
102
+ #endif
103
+ `;r.ShaderStore.IncludesShadersStoreWGSL[t]||(r.ShaderStore.IncludesShadersStoreWGSL[t]=n),e.s(["mainUVVaryingDeclarationWGSL",0,{name:t,shader:n}],39780);let o="logDepthDeclaration",a=`#ifdef LOGARITHMICDEPTH
104
+ uniform logarithmicDepthConstant: f32;varying vFragmentDepth: f32;
105
+ #endif
106
+ `;r.ShaderStore.IncludesShadersStoreWGSL[o]||(r.ShaderStore.IncludesShadersStoreWGSL[o]=a),e.s(["logDepthDeclarationWGSL",0,{name:o,shader:a}],54758)},99452,e=>{"use strict";var r=e.i(12423);let i="harmonicsFunctions",f=`#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
+ `;r.ShaderStore.IncludesShadersStoreWGSL[i]||(r.ShaderStore.IncludesShadersStoreWGSL[i]=f),e.s(["harmonicsFunctionsWGSL",0,{name:i,shader:f}])},61202,e=>{"use strict";var r=e.i(12423);let i="pbrBRDFFunctions",f=`#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
+ `;r.ShaderStore.IncludesShadersStoreWGSL[i]||(r.ShaderStore.IncludesShadersStoreWGSL[i]=f),e.s(["pbrBRDFFunctionsWGSL",0,{name:i,shader:f}])},40664,e=>{"use strict";var r=e.i(12423);e.i(60106),e.i(50008);let i="openpbrUboDeclaration",f=`uniform vTangentSpaceParams: vec2f;uniform vLightingIntensity: vec4f;uniform pointSize: f32;uniform vDebugMode: vec2f;uniform renderTargetSize: vec2f;uniform cameraInfo: vec4f;uniform vTextureRepetitionHexTilingParams: vec4f;uniform backgroundRefractionMatrix: mat4x4f;uniform vBackgroundRefractionInfos: vec3f;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;uniform vBaseWeight: f32;uniform vBaseColor: vec4f;uniform vBaseDiffuseRoughness: f32;uniform vReflectanceInfo: vec4f;uniform vSpecularColor: vec4f;uniform vSpecularAnisotropy: vec3f;uniform vTransmissionWeight : f32;uniform vTransmissionColor : vec3f;uniform vTransmissionDepth : f32;uniform vTransmissionScatter : vec3f;uniform vTransmissionScatterAnisotropy : f32;uniform vTransmissionDispersionScale : f32;uniform vTransmissionDispersionAbbeNumber : f32;uniform vSubsurfaceWeight: f32;uniform vSubsurfaceColor: vec3f;uniform vSubsurfaceRadius: f32;uniform vSubsurfaceRadiusScale: vec3f;uniform vSubsurfaceScatterAnisotropy: f32;uniform vCoatWeight: f32;uniform vCoatColor: vec3f;uniform vCoatRoughness: f32;uniform vCoatRoughnessAnisotropy: f32;uniform vCoatIor: f32;uniform vCoatDarkening : f32;uniform vFuzzWeight: f32;uniform vFuzzColor: vec3f;uniform vFuzzRoughness: f32;uniform vGeometryThinWalled: f32;uniform vGeometryCoatTangent: vec2f;uniform vGeometryThickness: f32;uniform vEmissionColor: vec3f;uniform vThinFilmWeight: f32;uniform vThinFilmThickness: vec2f;uniform vThinFilmIor: f32;uniform vBaseWeightInfos: vec2f;uniform baseWeightMatrix: mat4x4f;uniform vBaseColorInfos: vec2f;uniform baseColorMatrix: mat4x4f;uniform vBaseDiffuseRoughnessInfos: vec2f;uniform baseDiffuseRoughnessMatrix: mat4x4f;uniform vBaseMetalnessInfos: vec2f;uniform baseMetalnessMatrix: mat4x4f;uniform vSpecularWeightInfos: vec2f;uniform specularWeightMatrix: mat4x4f;uniform vSpecularColorInfos: vec2f;uniform specularColorMatrix: mat4x4f;uniform vSpecularRoughnessInfos: vec2f;uniform specularRoughnessMatrix: mat4x4f;uniform vSpecularRoughnessAnisotropyInfos: vec2f;uniform specularRoughnessAnisotropyMatrix: mat4x4f;uniform vTransmissionWeightInfos : vec2f;uniform transmissionWeightMatrix : mat4x4f;uniform vTransmissionColorInfos : vec2f;uniform transmissionColorMatrix : mat4x4f;uniform vTransmissionDepthInfos : vec2f;uniform transmissionDepthMatrix : mat4x4f;uniform vTransmissionScatterInfos : vec2f;uniform transmissionScatterMatrix : mat4x4f;uniform vTransmissionDispersionScaleInfos : vec2f;uniform transmissionDispersionScaleMatrix : mat4x4f;uniform vSubsurfaceWeightInfos: vec2f;uniform subsurfaceWeightMatrix: mat4x4f;uniform vSubsurfaceColorInfos: vec2f;uniform subsurfaceColorMatrix: mat4x4f;uniform vSubsurfaceRadiusScaleInfos: vec2f;uniform subsurfaceRadiusScaleMatrix: mat4x4f;uniform vCoatWeightInfos: vec2f;uniform coatWeightMatrix: mat4x4f;uniform vCoatColorInfos: vec2f;uniform coatColorMatrix: mat4x4f;uniform vCoatRoughnessInfos: vec2f;uniform coatRoughnessMatrix: mat4x4f;uniform vCoatRoughnessAnisotropyInfos: vec2f;uniform coatRoughnessAnisotropyMatrix: mat4x4f;uniform vCoatDarkeningInfos : vec2f;uniform coatDarkeningMatrix : mat4x4f;uniform vFuzzWeightInfos: vec2f;uniform fuzzWeightMatrix: mat4x4f;uniform vFuzzColorInfos: vec2f;uniform fuzzColorMatrix: mat4x4f;uniform vFuzzRoughnessInfos: vec2f;uniform fuzzRoughnessMatrix: mat4x4f;uniform vGeometryNormalInfos: vec2f;uniform geometryNormalMatrix: mat4x4f;uniform vGeometryTangentInfos: vec2f;uniform geometryTangentMatrix: mat4x4f;uniform vGeometryCoatNormalInfos: vec2f;uniform geometryCoatNormalMatrix: mat4x4f;uniform vGeometryCoatTangentInfos: vec2f;uniform geometryCoatTangentMatrix: mat4x4f;uniform vGeometryOpacityInfos: vec2f;uniform geometryOpacityMatrix: mat4x4f;uniform vGeometryThicknessInfos: vec2f;uniform geometryThicknessMatrix: mat4x4f;uniform vEmissionColorInfos: vec2f;uniform emissionColorMatrix: mat4x4f;uniform vThinFilmWeightInfos: vec2f;uniform thinFilmWeightMatrix: mat4x4f;uniform vThinFilmThicknessInfos: vec2f;uniform thinFilmThicknessMatrix: mat4x4f;uniform vAmbientOcclusionInfos: vec2f;uniform ambientOcclusionMatrix: mat4x4f;
294
+ #define ADDITIONAL_UBO_DECLARATION
295
+ #include<sceneUboDeclaration>
296
+ #include<meshUboDeclaration>
297
+ `;r.ShaderStore.IncludesShadersStoreWGSL[i]||(r.ShaderStore.IncludesShadersStoreWGSL[i]=f),e.s(["openpbrUboDeclarationWGSL",0,{name:i,shader:f}])},67367,23356,e=>{"use strict";var r=e.i(12423);let i="samplerFragmentDeclaration",f=`#ifdef _DEFINENAME_
298
+ #if _DEFINENAME_DIRECTUV==1
299
+ #define v_VARYINGNAME_UV vMainUV1
300
+ #elif _DEFINENAME_DIRECTUV==2
301
+ #define v_VARYINGNAME_UV vMainUV2
302
+ #elif _DEFINENAME_DIRECTUV==3
303
+ #define v_VARYINGNAME_UV vMainUV3
304
+ #elif _DEFINENAME_DIRECTUV==4
305
+ #define v_VARYINGNAME_UV vMainUV4
306
+ #elif _DEFINENAME_DIRECTUV==5
307
+ #define v_VARYINGNAME_UV vMainUV5
308
+ #elif _DEFINENAME_DIRECTUV==6
309
+ #define v_VARYINGNAME_UV vMainUV6
310
+ #else
311
+ varying v_VARYINGNAME_UV: vec2f;
312
+ #endif
313
+ var _SAMPLERNAME_SamplerSampler: sampler;var _SAMPLERNAME_Sampler: texture_2d<f32>;
314
+ #endif
315
+ `;r.ShaderStore.IncludesShadersStoreWGSL[i]||(r.ShaderStore.IncludesShadersStoreWGSL[i]=f),e.s(["samplerFragmentDeclarationWGSL",0,{name:i,shader:f}],67367);let t="reflectionFunction",n=`fn computeFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f
316
+ {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); }
317
+ fn computeMirroredFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f
318
+ {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); }
319
+ fn computeEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
320
+ {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);}
321
+ fn computeSphericalCoords(worldPos: vec4f,worldNormal: vec3f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f
322
+ {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);}
323
+ fn computePlanarCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
324
+ {var viewDir: vec3f=worldPos.xyz-eyePosition;var coords: vec3f=normalize(reflect(viewDir,worldNormal));return (reflectionMatrix* vec4f(coords,1)).xyz;}
325
+ fn computeCubicCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
326
+ {var viewDir: vec3f=normalize(worldPos.xyz-eyePosition);var coords: vec3f=reflect(viewDir,worldNormal);coords= (reflectionMatrix* vec4f(coords,0)).xyz;
327
+ #ifdef INVERTCUBICMAP
328
+ coords.y*=-1.0;
329
+ #endif
330
+ return coords;}
331
+ fn computeCubicLocalCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f,reflectionSize: vec3f,reflectionPosition: vec3f)->vec3f
332
+ {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;
333
+ #ifdef INVERTCUBICMAP
334
+ coords.y*=-1.0;
335
+ #endif
336
+ return coords;}
337
+ fn computeProjectionCoords(worldPos: vec4f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f
338
+ {return (reflectionMatrix*(view*worldPos)).xyz;}
339
+ fn computeSkyBoxCoords(positionW: vec3f,reflectionMatrix: mat4x4f)->vec3f
340
+ {return (reflectionMatrix* vec4f(positionW,1.)).xyz;}
341
+ #ifdef REFLECTION
342
+ fn computeReflectionCoords(worldPos: vec4f,worldNormal: vec3f)->vec3f
343
+ {
344
+ #ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
345
+ var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);
346
+ #endif
347
+ #ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
348
+ var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeFixedEquirectangularCoords(worldPos,worldNormal,direction);
349
+ #endif
350
+ #ifdef REFLECTIONMAP_EQUIRECTANGULAR
351
+ return computeEquirectangularCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
352
+ #endif
353
+ #ifdef REFLECTIONMAP_SPHERICAL
354
+ return computeSphericalCoords(worldPos,worldNormal,scene.view,uniforms.reflectionMatrix);
355
+ #endif
356
+ #ifdef REFLECTIONMAP_PLANAR
357
+ return computePlanarCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
358
+ #endif
359
+ #ifdef REFLECTIONMAP_CUBIC
360
+ #ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
361
+ return computeCubicLocalCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix,uniforms.vReflectionSize,uniforms.vReflectionPosition);
362
+ #else
363
+ return computeCubicCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
364
+ #endif
365
+ #endif
366
+ #ifdef REFLECTIONMAP_PROJECTION
367
+ return computeProjectionCoords(worldPos,scene.view,uniforms.reflectionMatrix);
368
+ #endif
369
+ #ifndef REFLECTIONMAP_CUBIC
370
+ #ifdef REFLECTIONMAP_SKYBOX
371
+ return computeSkyBoxCoords(fragmentInputs.vPositionUVW,uniforms.reflectionMatrix);
372
+ #endif
373
+ #endif
374
+ #ifdef REFLECTIONMAP_EXPLICIT
375
+ return vec3f(0,0,0);
376
+ #endif
377
+ }
378
+ #endif
379
+ `;r.ShaderStore.IncludesShadersStoreWGSL[t]||(r.ShaderStore.IncludesShadersStoreWGSL[t]=n),e.s(["reflectionFunctionWGSL",0,{name:t,shader:n}],23356)},90780,82518,e=>{"use strict";var r=e.i(12423);let i="pbrFragmentReflectionDeclaration",f=`#ifdef REFLECTION
380
+ #ifdef REFLECTIONMAP_3D
381
+ var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube<f32>;
382
+ #ifdef LODBASEDMICROSFURACE
383
+ #else
384
+ var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_cube<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_cube<f32>;
385
+ #endif
386
+ #ifdef USEIRRADIANCEMAP
387
+ var irradianceSamplerSampler: sampler;var irradianceSampler: texture_cube<f32>;
388
+ #endif
389
+ #else
390
+ var reflectionSamplerSampler: sampler;var reflectionSampler: texture_2d<f32>;
391
+ #ifdef LODBASEDMICROSFURACE
392
+ #else
393
+ var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_2d<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_2d<f32>;
394
+ #endif
395
+ #ifdef USEIRRADIANCEMAP
396
+ var irradianceSamplerSampler: sampler;var irradianceSampler: texture_2d<f32>;
397
+ #endif
398
+ #endif
399
+ #ifdef REFLECTIONMAP_SKYBOX
400
+ varying vPositionUVW: vec3f;
401
+ #else
402
+ #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
403
+ varying vDirectionW: vec3f;
404
+ #endif
405
+ #endif
406
+ #endif
407
+ `;r.ShaderStore.IncludesShadersStoreWGSL[i]||(r.ShaderStore.IncludesShadersStoreWGSL[i]=f),e.s(["pbrFragmentReflectionDeclarationWGSL",0,{name:i,shader:f}],90780);let t="pbrIBLFunctions",n=`#if defined(REFLECTION) || defined(SS_REFRACTION)
408
+ fn getLodFromAlphaG(cubeMapDimensionPixels: f32,microsurfaceAverageSlope: f32)->f32 {var microsurfaceAverageSlopeTexels: f32=cubeMapDimensionPixels*microsurfaceAverageSlope;var lod: f32=log2(microsurfaceAverageSlopeTexels);return lod;}
409
+ fn getLinearLodFromRoughness(cubeMapDimensionPixels: f32,roughness: f32)->f32 {var lod: f32=log2(cubeMapDimensionPixels)*roughness;return lod;}
410
+ #endif
411
+ #if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)
412
+ fn environmentRadianceOcclusion(ambientOcclusion: f32,NdotVUnclamped: f32)->f32 {var temp: f32=NdotVUnclamped+ambientOcclusion;return saturate(temp*temp-1.0+ambientOcclusion);}
413
+ #endif
414
+ #if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)
415
+ 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;}
416
+ #endif
417
+ #if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)
418
+ fn UNPACK_LOD(x: f32)->f32 {return (1.0-x)*255.0;}
419
+ fn getLodFromAlphaGNdotV(cubeMapDimensionPixels: f32,alphaG: f32,NdotV: f32)->f32 {var microsurfaceAverageSlope: f32=alphaG;microsurfaceAverageSlope*=sqrt(abs(NdotV));return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);}
420
+ #endif
421
+ `;r.ShaderStore.IncludesShadersStoreWGSL[t]||(r.ShaderStore.IncludesShadersStoreWGSL[t]=n),e.s(["pbrIBLFunctionsWGSL",0,{name:t,shader:n}],82518)},30420,22389,63189,e=>{"use strict";var r=e.i(12423);let i="openpbrDielectricReflectance",f=`struct ReflectanceParams
422
+ {F0: f32,
423
+ F90: f32,
424
+ coloredF0: vec3f,
425
+ coloredF90: vec3f,};
426
+ #define pbr_inline
427
+ fn dielectricReflectance(
428
+ insideIOR: f32,outsideIOR: f32,specularColor: vec3f,specularWeight: f32
429
+ )->ReflectanceParams
430
+ {var outParams: ReflectanceParams;let dielectricF0=pow((insideIOR-outsideIOR)/(insideIOR+outsideIOR),2.0);
431
+ #if DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_GLTF
432
+ let maxF0=max(specularColor.r,max(specularColor.g,specularColor.b));outParams.F0=dielectricF0*maxF0*specularWeight;
433
+ #else
434
+ outParams.F0=dielectricF0*specularWeight;
435
+ #endif
436
+ let f90Scale=clamp(2.0f*abs(insideIOR-outsideIOR),0.0f,1.0f);outParams.F90=f90Scale*specularWeight;outParams.coloredF0=vec3f(dielectricF0*specularWeight)*specularColor.rgb;
437
+ #if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR)
438
+ let dielectricColorF90: vec3f=specularColor.rgb*vec3f(f90Scale)*specularWeight;
439
+ #else
440
+ let dielectricColorF90: vec3f=vec3f(f90Scale)*specularWeight;
441
+ #endif
442
+ outParams.coloredF90=dielectricColorF90;return outParams;}
443
+ `;r.ShaderStore.IncludesShadersStoreWGSL[i]||(r.ShaderStore.IncludesShadersStoreWGSL[i]=f),e.s(["openpbrDielectricReflectanceWGSL",0,{name:i,shader:f}],30420);let t="openpbrGeometryInfo",n=`struct geometryInfoOutParams
444
+ {NdotV: f32,
445
+ NdotVUnclamped: f32,
446
+ environmentBrdf: vec3f,
447
+ horizonOcclusion: f32};struct geometryInfoAnisoOutParams
448
+ {NdotV: f32,
449
+ NdotVUnclamped: f32,
450
+ environmentBrdf: vec3f,
451
+ horizonOcclusion: f32,
452
+ anisotropy: f32,
453
+ anisotropicTangent: vec3f,
454
+ anisotropicBitangent: vec3f,
455
+ TBN: mat3x3<f32>};fn geometryInfo(
456
+ normalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f
457
+ )->geometryInfoOutParams
458
+ {var outParams: geometryInfoOutParams;outParams.NdotVUnclamped=dot(normalW,viewDirectionW);outParams.NdotV=absEps(outParams.NdotVUnclamped);
459
+ #if defined(ENVIRONMENTBRDF)
460
+ outParams.environmentBrdf=getBRDFLookup(outParams.NdotV,roughness);
461
+ #else
462
+ outParams.environmentBrdf=vec3f(0.0);
463
+ #endif
464
+ outParams.horizonOcclusion=1.0f;
465
+ #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
466
+ #ifdef HORIZONOCCLUSION
467
+ #if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL)
468
+ #ifdef REFLECTIONMAP_3D
469
+ outParams.horizonOcclusion=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
470
+ #endif
471
+ #endif
472
+ #endif
473
+ #endif
474
+ return outParams;}
475
+ fn geometryInfoAniso(
476
+ normalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f
477
+ ,vAnisotropy: vec3f,TBN: mat3x3<f32>
478
+ )->geometryInfoAnisoOutParams
479
+ {let geoInfo: geometryInfoOutParams=geometryInfo(normalW,viewDirectionW,roughness,geometricNormalW);var outParams: geometryInfoAnisoOutParams;outParams.NdotV=geoInfo.NdotV;outParams.NdotVUnclamped=geoInfo.NdotVUnclamped;outParams.environmentBrdf=geoInfo.environmentBrdf;outParams.horizonOcclusion=geoInfo.horizonOcclusion;outParams.anisotropy=vAnisotropy.b;let anisotropyDirection: vec3f=vec3f(vAnisotropy.xy,0.);let anisoTBN: mat3x3<f32>=mat3x3<f32>(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));outParams.anisotropicTangent=normalize(anisoTBN*anisotropyDirection);outParams.anisotropicBitangent=normalize(cross(anisoTBN[2],outParams.anisotropicTangent));outParams.TBN=TBN;return outParams;}
480
+ `;r.ShaderStore.IncludesShadersStoreWGSL[t]||(r.ShaderStore.IncludesShadersStoreWGSL[t]=n),e.s(["openpbrGeometryInfoWGSL",0,{name:t,shader:n}],22389);let o="openpbrIblFunctions",a=`#ifdef REFLECTION
481
+ fn sampleIrradiance(
482
+ surfaceNormal: vec3f
483
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
484
+ ,vEnvironmentIrradianceSH: vec3f
485
+ #endif
486
+ #if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
487
+ ,iblMatrix: mat4x4f
488
+ #endif
489
+ #ifdef USEIRRADIANCEMAP
490
+ #ifdef REFLECTIONMAP_3D
491
+ ,irradianceSampler: texture_cube<f32>
492
+ ,irradianceSamplerSampler: sampler
493
+ #else
494
+ ,irradianceSampler: texture_2d<f32>
495
+ ,irradianceSamplerSampler: sampler
496
+ #endif
497
+ #ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
498
+ ,reflectionDominantDirection: vec3f
499
+ #endif
500
+ #endif
501
+ #ifdef REALTIME_FILTERING
502
+ ,reflectionFilteringInfo: vec2f
503
+ #ifdef IBL_CDF_FILTERING
504
+ ,icdfSampler: texture_2d<f32>
505
+ ,icdfSamplerSampler: sampler
506
+ #endif
507
+ #endif
508
+ ,reflectionInfos: vec2f
509
+ ,viewDirectionW: vec3f
510
+ ,diffuseRoughness: f32
511
+ ,surfaceAlbedo: vec3f
512
+ )->vec3f {var environmentIrradiance=vec3f(0.,0.,0.);
513
+ #if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
514
+ var irradianceVector=(iblMatrix*vec4f(surfaceNormal,0.0f)).xyz;var irradianceView=(iblMatrix*vec4f(viewDirectionW,0.0f)).xyz;
515
+ #if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING)
516
+ #if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY
517
+ {let NdotV=max(dot(surfaceNormal,viewDirectionW),0.0f);irradianceVector=mix(irradianceVector,irradianceView,(0.5f*(1.0f-NdotV))*diffuseRoughness);}
518
+ #endif
519
+ #endif
520
+ #ifdef REFLECTIONMAP_OPPOSITEZ
521
+ irradianceVector.z*=-1.0;irradianceView.z*=-1.0;
522
+ #endif
523
+ #ifdef INVERTCUBICMAP
524
+ irradianceVector.y*=-1.0;irradianceView.y*=-1.0;
525
+ #endif
526
+ #endif
527
+ #ifdef USESPHERICALFROMREFLECTIONMAP
528
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
529
+ environmentIrradiance=vEnvironmentIrradianceSH;
530
+ #else
531
+ #if defined(REALTIME_FILTERING)
532
+ environmentIrradiance=irradiance(reflectionSampler,reflectionSamplerSampler,irradianceVector,reflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView
533
+ #ifdef IBL_CDF_FILTERING
534
+ ,icdfSampler
535
+ ,icdfSamplerSampler
536
+ #endif
537
+ );
538
+ #else
539
+ environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
540
+ #endif
541
+ #endif
542
+ #elif defined(USEIRRADIANCEMAP)
543
+ #ifdef REFLECTIONMAP_3D
544
+ let environmentIrradianceFromTexture: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,irradianceVector);
545
+ #else
546
+ let environmentIrradianceFromTexture: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,reflectionCoords);
547
+ #endif
548
+ environmentIrradiance=environmentIrradianceFromTexture.rgb;
549
+ #ifdef RGBDREFLECTION
550
+ environmentIrradiance.rgb=fromRGBD(environmentIrradianceFromTexture);
551
+ #endif
552
+ #ifdef GAMMAREFLECTION
553
+ environmentIrradiance.rgb=toLinearSpaceVec3(environmentIrradiance.rgb);
554
+ #endif
555
+ #ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
556
+ let Ls: vec3f=normalize(reflectionDominantDirection);let NoL: f32=dot(irradianceVector,Ls);let NoV: f32=dot(irradianceVector,irradianceView);var diffuseRoughnessTerm=vec3f(1.0f);
557
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
558
+ let LoV: f32=dot (Ls,irradianceView);let mag: f32=length(reflectionDominantDirection)*2.0f;let clampedAlbedo: vec3f=clamp(surfaceAlbedo,vec3f(0.1f),vec3f(1.0f));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3f(1.0f),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0f,1.0f)));
559
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
560
+ let H: vec3f=(irradianceView+Ls)*0.5f;let VoH: f32=dot(irradianceView,H);diffuseRoughnessTerm=vec3f(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);
561
+ #endif
562
+ environmentIrradiance=environmentIrradiance.rgb*diffuseRoughnessTerm;
563
+ #endif
564
+ #endif
565
+ environmentIrradiance*=reflectionInfos.x;return environmentIrradiance;}
566
+ #ifdef REFLECTIONMAP_3D
567
+ fn createReflectionCoords(vPositionW: vec3f,normalW: vec3f)->vec3f
568
+ #else
569
+ fn createReflectionCoords(vPositionW: vec3f,normalW: vec3f)->vec2f
570
+ #endif
571
+ {var reflectionVector: vec3f=computeReflectionCoords(vec4f(vPositionW,1.0f),normalW);
572
+ #ifdef REFLECTIONMAP_OPPOSITEZ
573
+ reflectionVector.z*=-1.0;
574
+ #endif
575
+ #ifdef REFLECTIONMAP_3D
576
+ var reflectionCoords: vec3f=reflectionVector;
577
+ #else
578
+ var reflectionCoords: vec2f=reflectionVector.xy;
579
+ #ifdef REFLECTIONMAP_PROJECTION
580
+ reflectionCoords/=reflectionVector.z;
581
+ #endif
582
+ reflectionCoords.y=1.0f-reflectionCoords.y;
583
+ #endif
584
+ return reflectionCoords;}
585
+ fn sampleRadiance(
586
+ alphaG: f32
587
+ ,reflectionMicrosurfaceInfos: vec3f
588
+ ,reflectionInfos: vec2f
589
+ ,geoInfo: geometryInfoOutParams
590
+ #ifdef REFLECTIONMAP_3D
591
+ ,reflectionSampler: texture_cube<f32>
592
+ ,reflectionSamplerSampler: sampler
593
+ ,reflectionCoords: vec3f
594
+ #else
595
+ ,reflectionSampler: texture_2d<f32>
596
+ ,reflectionSamplerSampler: sampler
597
+ ,reflectionCoords: vec2f
598
+ #endif
599
+ #ifdef REALTIME_FILTERING
600
+ ,reflectionFilteringInfo: vec2f
601
+ #endif
602
+ )->vec3f {var environmentRadiance: vec4f=vec4f(0.f,0.f,0.f,0.f);
603
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
604
+ var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,alphaG,geoInfo.NdotVUnclamped);
605
+ #elif defined(LINEARSPECULARREFLECTION)
606
+ var reflectionLOD: f32=getLinearLodFromRoughness(reflectionMicrosurfaceInfos.x,roughness);
607
+ #else
608
+ var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,alphaG);
609
+ #endif
610
+ reflectionLOD=reflectionLOD*reflectionMicrosurfaceInfos.y+reflectionMicrosurfaceInfos.z;
611
+ #ifdef REALTIME_FILTERING
612
+ environmentRadiance=vec4f(radiance(alphaG,reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionFilteringInfo),1.0f);
613
+ #else
614
+ environmentRadiance=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD);
615
+ #endif
616
+ #ifdef RGBDREFLECTION
617
+ environmentRadiance.rgb=fromRGBD(environmentRadiance);
618
+ #endif
619
+ #ifdef GAMMAREFLECTION
620
+ environmentRadiance.rgb=toLinearSpaceVec3(environmentRadiance.rgb);
621
+ #endif
622
+ environmentRadiance=vec4f(environmentRadiance.rgb*reflectionInfos.x,environmentRadiance.a);return environmentRadiance.rgb;}
623
+ #if defined(ANISOTROPIC)
624
+ fn sampleRadianceAnisotropic(
625
+ alphaG: f32
626
+ ,reflectionMicrosurfaceInfos: vec3f
627
+ ,reflectionInfos: vec2f
628
+ ,geoInfo: geometryInfoAnisoOutParams
629
+ ,normalW: vec3f
630
+ ,viewDirectionW: vec3f
631
+ ,positionW: vec3f
632
+ ,noise: vec3f
633
+ ,isRefraction: bool
634
+ ,ior: f32
635
+ #ifdef REFLECTIONMAP_3D
636
+ ,reflectionSampler: texture_cube<f32>
637
+ ,reflectionSamplerSampler: sampler
638
+ #else
639
+ ,reflectionSampler: texture_2d<f32>
640
+ ,reflectionSamplerSampler: sampler
641
+ #endif
642
+ #ifdef REALTIME_FILTERING
643
+ ,reflectionFilteringInfo: vec2f
644
+ #endif
645
+ )->vec3f {var environmentRadiance: vec4f=vec4f(0.f,0.f,0.f,0.f);let alphaT=alphaG*sqrt(2.0f/(1.0f+(1.0f-geoInfo.anisotropy)*(1.0f-geoInfo.anisotropy)));let alphaB=(1.0f-geoInfo.anisotropy)*alphaT;let modifiedAlphaG=alphaB;
646
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
647
+ var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,modifiedAlphaG,geoInfo.NdotVUnclamped);
648
+ #elif defined(LINEARSPECULARREFLECTION)
649
+ var reflectionLOD: f32=getLinearLodFromRoughness(reflectionMicrosurfaceInfos.x,roughness);
650
+ #else
651
+ var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,modifiedAlphaG);
652
+ #endif
653
+ reflectionLOD=reflectionLOD*reflectionMicrosurfaceInfos.y+reflectionMicrosurfaceInfos.z;
654
+ #ifdef REALTIME_FILTERING
655
+ var view=(uniforms.reflectionMatrix*vec4f(viewDirectionW,0.0f)).xyz;var tangent=(uniforms.reflectionMatrix*vec4f(geoInfo.anisotropicTangent,0.0f)).xyz;var bitangent=(uniforms.reflectionMatrix*vec4f(geoInfo.anisotropicBitangent,0.0f)).xyz;var normal=(uniforms.reflectionMatrix*vec4f(normalW,0.0f)).xyz;
656
+ #ifdef REFLECTIONMAP_OPPOSITEZ
657
+ view.z*=-1.0f;tangent.z*=-1.0f;bitangent.z*=-1.0f;normal.z*=-1.0f;
658
+ #endif
659
+ environmentRadiance =
660
+ vec4f(radianceAnisotropic(alphaT,alphaB,reflectionSampler,reflectionSamplerSampler,
661
+ view,tangent,
662
+ bitangent,normal,
663
+ reflectionFilteringInfo,noise.xy,isRefraction,ior),
664
+ 1.0f);
665
+ #else
666
+ const samples: i32=16;var radianceSample=vec4f(0.0);var accumulatedRadiance=vec3f(0.0);var reflectionCoords=vec3f(0.0);var sample_weight=0.0f;var total_weight=0.0f;let step=1.0f/f32(max(samples-1,1));for (var i: i32=0; i<samples; i++) {var t: f32=mix(-1.0,1.0,f32(i)*step);t+=step*2.0*noise.x;sample_weight=max(1.0-abs(t),0.001);sample_weight*=sample_weight;t*=min(4.0*alphaT*geoInfo.anisotropy,1.0);var bentNormal: vec3f;if (t<0.0) {let blend: f32=t+1.0;bentNormal=normalize(mix(-geoInfo.anisotropicTangent,normalW,blend));} else if (t>0.0) {let blend: f32=t;bentNormal=normalize(mix(normalW,geoInfo.anisotropicTangent,blend));} else {bentNormal=normalW;}
667
+ if (isRefraction) {reflectionCoords=double_refract(-viewDirectionW,bentNormal,ior);} else {reflectionCoords=reflect(-viewDirectionW,bentNormal);}
668
+ reflectionCoords=(uniforms.reflectionMatrix*vec4f(reflectionCoords,0.f)).xyz;
669
+ #ifdef REFLECTIONMAP_OPPOSITEZ
670
+ reflectionCoords.z*=-1.0f;
671
+ #endif
672
+ radianceSample=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD);
673
+ #ifdef RGBDREFLECTION
674
+ accumulatedRadiance+=vec3f(sample_weight)*fromRGBD(radianceSample);
675
+ #elif defined(GAMMAREFLECTION)
676
+ accumulatedRadiance+=vec3f(sample_weight)*toLinearSpaceVec3(radianceSample.rgb);
677
+ #else
678
+ accumulatedRadiance+=vec3f(sample_weight)*radianceSample.rgb;
679
+ #endif
680
+ total_weight+=sample_weight;}
681
+ environmentRadiance=vec4f(accumulatedRadiance/vec3f(total_weight),1.0f);
682
+ #endif
683
+ environmentRadiance=vec4f(environmentRadiance.rgb*reflectionInfos.xxx,environmentRadiance.a);return environmentRadiance.rgb;}
684
+ #endif
685
+ #endif
686
+ #ifdef ENVIRONMENTBRDF
687
+ fn computeDielectricIblFresnel(reflectance: ReflectanceParams,environmentBrdf: vec3f)->f32
688
+ {let dielectricIblFresnel: f32=getReflectanceFromBRDFWithEnvLookup(vec3f(reflectance.F0),vec3f(reflectance.F90),environmentBrdf).r;let dielectricECF: f32=1.0+reflectance.F0*(1.0/environmentBrdf.y-1.0);return clamp(dielectricIblFresnel*dielectricECF,0.0,1.0);}
689
+ fn computeConductorIblFresnel(reflectance: ReflectanceParams,environmentBrdf: vec3f)->vec3f
690
+ {
691
+ #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
692
+ let openPBRBrdf: vec3f=vec3f(environmentBrdf.xy,environmentBrdf.z/BRDF_Z_SCALE);let b: vec3f =getF82B(reflectance.coloredF0,reflectance.coloredF90);let E_F82: vec3f=getF82DirectionalAlbedo(reflectance.coloredF0,vec3f(1.0),b,openPBRBrdf);let F_avg: vec3f=getF82AverageFresnel(reflectance.coloredF0,b);let ECF: vec3f =vec3f(1.0)+F_avg*(vec3f(1.0)/openPBRBrdf.y-vec3f(1.0));return clamp(E_F82*ECF,vec3f(0.0),vec3f(1.0));
693
+ #else
694
+ return getReflectanceFromBRDFLookup(reflectance.coloredF0,reflectance.coloredF90,environmentBrdf);
695
+ #endif
696
+ }
697
+ #endif
698
+ `;r.ShaderStore.IncludesShadersStoreWGSL[o]||(r.ShaderStore.IncludesShadersStoreWGSL[o]=a),e.s(["openpbrIblFunctionsWGSL",0,{name:o,shader:a}],63189)},4558,e=>{"use strict";var r=e.i(12423);let i="openpbrTransmissionLayerData",f=`var transmission_weight: f32=uniforms.vTransmissionWeight;var transmission_color: vec3f=uniforms.vTransmissionColor.rgb;var transmission_depth: f32=uniforms.vTransmissionDepth;var transmission_scatter: vec3f=uniforms.vTransmissionScatter.rgb;var transmission_scatter_anisotropy: f32=clamp(uniforms.vTransmissionScatterAnisotropy,-0.9999f,0.9999f);var transmission_dispersion_scale: f32=uniforms.vTransmissionDispersionScale;var transmission_dispersion_abbe_number: f32=uniforms.vTransmissionDispersionAbbeNumber;
699
+ #ifdef TRANSMISSION_WEIGHT
700
+ let transmissionWeightFromTexture: vec4f=TEXRD(transmissionWeightSampler,transmissionWeightSamplerSampler,fragmentInputs.vTransmissionWeightUV+uvOffset);
701
+ #endif
702
+ #ifdef TRANSMISSION_COLOR
703
+ let transmissionColorFromTexture: vec4f=TEXRD(transmissionColorSampler,transmissionColorSamplerSampler,fragmentInputs.vTransmissionColorUV+uvOffset);
704
+ #endif
705
+ #ifdef TRANSMISSION_DEPTH
706
+ let transmissionDepthFromTexture: vec4f=TEXRD(transmissionDepthSampler,transmissionDepthSamplerSampler,fragmentInputs.vTransmissionDepthUV+uvOffset);
707
+ #endif
708
+ #ifdef TRANSMISSION_SCATTER
709
+ let transmissionScatterFromTexture: vec4f=TEXRD(transmissionScatterSampler,transmissionScatterSamplerSampler,fragmentInputs.vTransmissionScatterUV+uvOffset);
710
+ #endif
711
+ #ifdef TRANSMISSION_DISPERSION_SCALE
712
+ let transmissionDispersionScaleFromTexture: vec4f=TEXRD(transmissionDispersionScaleSampler,transmissionDispersionScaleSamplerSampler,fragmentInputs.vTransmissionDispersionScaleUV+uvOffset);
713
+ #endif
714
+ #ifdef TRANSMISSION_WEIGHT
715
+ transmission_weight*=transmissionWeightFromTexture.r;
716
+ #endif
717
+ #ifdef TRANSMISSION_COLOR
718
+ #ifdef TRANSMISSION_COLOR_GAMMA
719
+ transmission_color*=toLinearSpaceVec3(transmissionColorFromTexture.rgb);
720
+ #else
721
+ transmission_color*=transmissionColorFromTexture.rgb;
722
+ #endif
723
+ transmission_color*=uniforms.vTransmissionColorInfos.y;
724
+ #endif
725
+ #ifdef TRANSMISSION_DEPTH
726
+ transmission_depth*=transmissionDepthFromTexture.r;
727
+ #endif
728
+ #ifdef TRANSMISSION_SCATTER
729
+ transmission_scatter*=transmissionScatterFromTexture.rgb;
730
+ #endif
731
+ #ifdef TRANSMISSION_DISPERSION_SCALE
732
+ transmission_dispersion_scale*=transmissionDispersionScaleFromTexture.r;
733
+ #endif
734
+ `;r.ShaderStore.IncludesShadersStoreWGSL[i]||(r.ShaderStore.IncludesShadersStoreWGSL[i]=f),e.s(["openpbrTransmissionLayerDataWGSL",0,{name:i,shader:f}])},80899,e=>{"use strict";var r=e.i(12423);let i="openpbrSubsurfaceLayerData",f=`var subsurface_weight: f32=uniforms.vSubsurfaceWeight;var subsurface_color: vec3f=uniforms.vSubsurfaceColor.rgb;var subsurface_radius: f32=uniforms.vSubsurfaceRadius;var subsurface_radius_scale: vec3f=uniforms.vSubsurfaceRadiusScale;var subsurface_scatter_anisotropy: f32=clamp(uniforms.vSubsurfaceScatterAnisotropy,-0.9999f,0.9999f);
735
+ #ifdef SUBSURFACE_WEIGHT
736
+ let subsurfaceWeightFromTexture: vec4f=TEXRD(subsurfaceWeightSampler,subsurfaceWeightSamplerSampler,fragmentInputs.vSubsurfaceWeightUV+uvOffset);
737
+ #endif
738
+ #ifdef SUBSURFACE_COLOR
739
+ let subsurfaceColorFromTexture: vec4f=TEXRD(subsurfaceColorSampler,subsurfaceColorSamplerSampler,fragmentInputs.vSubsurfaceColorUV+uvOffset);
740
+ #endif
741
+ #ifdef SUBSURFACE_RADIUS_SCALE
742
+ let subsurfaceRadiusScaleFromTexture: vec4f=TEXRD(subsurfaceRadiusScaleSampler,subsurfaceRadiusScaleSamplerSampler,fragmentInputs.vSubsurfaceRadiusScaleUV+uvOffset);
743
+ #endif
744
+ #ifdef SUBSURFACE_WEIGHT
745
+ #ifdef SUBSURFACE_WEIGHT_FROM_TEXTURE_ALPHA
746
+ subsurface_weight*=subsurfaceWeightFromTexture.a;
747
+ #else
748
+ subsurface_weight*=subsurfaceWeightFromTexture.r;
749
+ #endif
750
+ #endif
751
+ #ifdef SUBSURFACE_COLOR
752
+ #ifdef SUBSURFACE_COLOR_GAMMA
753
+ subsurface_color*=toLinearSpaceVec3(subsurfaceColorFromTexture.rgb);
754
+ #else
755
+ subsurface_color*=subsurfaceColorFromTexture.rgb;
756
+ #endif
757
+ subsurface_color*=uniforms.vSubsurfaceColorInfos.y;
758
+ #endif
759
+ #ifdef SUBSURFACE_RADIUS_SCALE
760
+ subsurface_radius_scale*=subsurfaceRadiusScaleFromTexture.rgb;
761
+ #endif
762
+ `;r.ShaderStore.IncludesShadersStoreWGSL[i]||(r.ShaderStore.IncludesShadersStoreWGSL[i]=f),e.s(["openpbrSubsurfaceLayerDataWGSL",0,{name:i,shader:f}])},6320,95538,90507,62424,42221,48373,69075,62026,28285,74698,52640,87693,e=>{"use strict";var r=e.i(12423);e.i(39780);let i="pbrFragmentExtraDeclaration",f=`varying vPositionW: vec3f;
763
+ #if DEBUGMODE>0
764
+ varying vClipSpacePosition: vec4f;
765
+ #endif
766
+ #include<mainUVVaryingDeclaration>[1..7]
767
+ #ifdef NORMAL
768
+ varying vNormalW: vec3f;
769
+ #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
770
+ varying vEnvironmentIrradiance: vec3f;
771
+ #endif
772
+ #endif
773
+ #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
774
+ varying vColor: vec4f;
775
+ #endif
776
+ #if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
777
+ varying vViewDepth: f32;
778
+ #endif
779
+ `;r.ShaderStore.IncludesShadersStoreWGSL[i]||(r.ShaderStore.IncludesShadersStoreWGSL[i]=f),e.s(["pbrFragmentExtraDeclarationWGSL",0,{name:i,shader:f}],6320);let t="subSurfaceScatteringFunctions",n=`fn testLightingForSSS(diffusionProfile: f32)->bool
780
+ {return diffusionProfile<1.;}`;r.ShaderStore.IncludesShadersStoreWGSL[t]||(r.ShaderStore.IncludesShadersStoreWGSL[t]=n),e.s(["subSurfaceScatteringFunctionsWGSL",0,{name:t,shader:n}],95538);let o="importanceSampling",a=`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);}
781
+ 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);}
782
+ fn hemisphereImportanceSampleDggxAnisotropic(Xi: vec2f,alphaTangent: f32,alphaBitangent: f32)->vec3f
783
+ {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; }
784
+ let cosPhi: f32=cos(phi);let sinPhi: f32=sin(phi);let alpha2: f32=(cosPhi*cosPhi)/(alphaT*alphaT) +
785
+ (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);}
786
+ fn hemisphereImportanceSampleDCharlie(u: vec2f,a: f32)->vec3f {
787
+ 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);}`;r.ShaderStore.IncludesShadersStoreWGSL[o]||(r.ShaderStore.IncludesShadersStoreWGSL[o]=a),e.s(["importanceSamplingWGSL",0,{name:o,shader:a}],90507);let c="pbrHelperFunctions",s=`#define MINIMUMVARIANCE 0.0005
788
+ #ifndef TEXRD_DEFINED
789
+ fn TEXRD(t: texture_2d<f32>,ts: sampler,uv: vec2f)->vec4f {return textureSample(t,ts,uv);}
790
+ #define TEXRD_DEFINED
791
+ #endif
792
+ fn convertRoughnessToAverageSlope(roughness: f32)->f32
793
+ {return roughness*roughness+MINIMUMVARIANCE;}
794
+ fn fresnelGrazingReflectance(reflectance0: f32)->f32 {var reflectance90: f32=saturate(reflectance0*25.0);return reflectance90;}
795
+ fn getAARoughnessFactors(normalVector: vec3f)->vec2f {
796
+ #ifdef SPECULARAA
797
+ 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);
798
+ #else
799
+ return vec2f(0.);
800
+ #endif
801
+ }
802
+ #ifdef ANISOTROPIC
803
+ #ifdef ANISOTROPIC_LEGACY
804
+ 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);}
805
+ 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;}
806
+ #elif ANISOTROPIC_OPENPBR
807
+ 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);}
808
+ #else
809
+ 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);}
810
+ 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;}
811
+ #endif
812
+ #endif
813
+ #if defined(CLEARCOAT) || defined(SS_REFRACTION)
814
+ fn cocaLambertVec3(alpha: vec3f,distance: f32)->vec3f {return exp(-alpha*distance);}
815
+ fn cocaLambert(NdotVRefract: f32,NdotLRefract: f32,alpha: vec3f,thickness: f32)->vec3f {return cocaLambertVec3(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));}
816
+ fn computeColorAtDistanceInMedia(color: vec3f,distance: f32)->vec3f {return -log(color)/distance;}
817
+ fn computeClearCoatAbsorption(NdotVRefract: f32,NdotLRefract: f32,clearCoatColor: vec3f,clearCoatThickness: f32,clearCoatIntensity: f32)->vec3f {var clearCoatAbsorption: vec3f=mix( vec3f(1.0),
818
+ cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),
819
+ clearCoatIntensity);return clearCoatAbsorption;}
820
+ #endif
821
+ #ifdef MICROSURFACEAUTOMATIC
822
+ fn computeDefaultMicroSurface(microSurface: f32,reflectivityColor: vec3f)->f32
823
+ {const kReflectivityNoAlphaWorkflow_SmoothnessMax: f32=0.95;var reflectivityLuminance: f32=getLuminance(reflectivityColor);var reflectivityLuma: f32=sqrt(reflectivityLuminance);var resultMicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;return resultMicroSurface;}
824
+ #endif
825
+ `;r.ShaderStore.IncludesShadersStoreWGSL[c]||(r.ShaderStore.IncludesShadersStoreWGSL[c]=s),e.s(["pbrHelperFunctionsWGSL",0,{name:c,shader:s}],62424),e.i(42420);let l="pbrDirectLightingSetupFunctions",d=`struct preLightingInfo
826
+ {lightOffset: vec3f,
827
+ lightDistanceSquared: f32,
828
+ lightDistance: f32,
829
+ attenuation: f32,
830
+ L: vec3f,
831
+ H: vec3f,
832
+ NdotV: f32,
833
+ NdotLUnclamped: f32,
834
+ NdotL: f32,
835
+ VdotH: f32,
836
+ LdotV: f32,
837
+ roughness: f32,
838
+ diffuseRoughness: f32,
839
+ surfaceAlbedo: vec3f,
840
+ #ifdef IRIDESCENCE
841
+ iridescenceIntensity: f32
842
+ #endif
843
+ #if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
844
+ areaLightDiffuse: vec3f,
845
+ #ifdef SPECULARTERM
846
+ areaLightSpecular: vec3f,
847
+ areaLightFresnel: vec4f
848
+ #endif
849
+ #endif
850
+ };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;}
851
+ 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;}
852
+ 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;
853
+ #ifdef SPECULARTERM
854
+ result.L=normalize(lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));
855
+ #endif
856
+ return result;}
857
+ #if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
858
+ #include<ltcHelperFunctions>
859
+ 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);
860
+ #ifdef SPECULARTERM
861
+ result.areaLightFresnel=data.Fresnel;result.areaLightSpecular=data.Specular;
862
+ #endif
863
+ result.areaLightDiffuse+=data.Diffuse;return result;}
864
+ 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);
865
+ #ifdef SPECULARTERM
866
+ result.areaLightFresnel=data.Fresnel;result.areaLightSpecular=data.Specular;
867
+ #endif
868
+ result.areaLightDiffuse=data.Diffuse;result.LdotV=0.;result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3f(0.);return result;}
869
+ #endif
870
+ `;r.ShaderStore.IncludesShadersStoreWGSL[l]||(r.ShaderStore.IncludesShadersStoreWGSL[l]=d),e.s(["pbrDirectLightingSetupFunctionsWGSL",0,{name:l,shader:d}],42221);let v="pbrDirectLightingFalloffFunctions",u=`fn computeDistanceLightFalloff_Standard(lightOffset: vec3f,range: f32)->f32
871
+ {return max(0.,1.0-length(lightOffset)/range);}
872
+ fn computeDistanceLightFalloff_Physical(lightDistanceSquared: f32)->f32
873
+ {return 1.0/maxEps(lightDistanceSquared);}
874
+ fn computeDistanceLightFalloff_GLTF(lightDistanceSquared: f32,inverseSquaredRange: f32)->f32
875
+ {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;}
876
+ fn computeDirectionalLightFalloff_IES(lightDirection: vec3f,directionToLightCenterW: vec3f,iesLightTexture: texture_2d<f32>,iesLightTextureSampler: sampler)->f32
877
+ {var cosAngle: f32=dot(-lightDirection,directionToLightCenterW);var angle=acos(cosAngle)/PI;return textureSampleLevel(iesLightTexture,iesLightTextureSampler,vec2f(angle,0),0.).r;}
878
+ fn computeDistanceLightFalloff(lightOffset: vec3f,lightDistanceSquared: f32,range: f32,inverseSquaredRange: f32)->f32
879
+ {
880
+ #ifdef USEPHYSICALLIGHTFALLOFF
881
+ return computeDistanceLightFalloff_Physical(lightDistanceSquared);
882
+ #elif defined(USEGLTFLIGHTFALLOFF)
883
+ return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);
884
+ #else
885
+ return computeDistanceLightFalloff_Standard(lightOffset,range);
886
+ #endif
887
+ }
888
+ fn computeDirectionalLightFalloff_Standard(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32,exponent: f32)->f32
889
+ {var falloff: f32=0.0;var cosAngle: f32=maxEps(dot(-lightDirection,directionToLightCenterW));if (cosAngle>=cosHalfAngle)
890
+ {falloff=max(0.,pow(cosAngle,exponent));}
891
+ return falloff;}
892
+ fn computeDirectionalLightFalloff_Physical(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32)->f32
893
+ {const kMinusLog2ConeAngleIntensityRatio: f32=6.64385618977;
894
+ 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;}
895
+ fn computeDirectionalLightFalloff_GLTF(lightDirection: vec3f,directionToLightCenterW: vec3f,lightAngleScale: f32,lightAngleOffset: f32)->f32
896
+ {var cd: f32=dot(-lightDirection,directionToLightCenterW);var falloff: f32=saturate(cd*lightAngleScale+lightAngleOffset);falloff*=falloff;return falloff;}
897
+ fn computeDirectionalLightFalloff(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32,exponent: f32,lightAngleScale: f32,lightAngleOffset: f32)->f32
898
+ {
899
+ #ifdef USEPHYSICALLIGHTFALLOFF
900
+ return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);
901
+ #elif defined(USEGLTFLIGHTFALLOFF)
902
+ return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);
903
+ #else
904
+ return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);
905
+ #endif
906
+ }`;r.ShaderStore.IncludesShadersStoreWGSL[v]||(r.ShaderStore.IncludesShadersStoreWGSL[v]=u),e.s(["pbrDirectLightingFalloffFunctionsWGSL",0,{name:v,shader:u}],48373);let m="hdrFilteringFunctions",p=`#ifdef NUM_SAMPLES
907
+ #if NUM_SAMPLES>0
908
+ fn radicalInverse_VdC(value: u32)->f32
909
+ {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; }
910
+ fn hammersley(i: u32,N: u32)->vec2f
911
+ {return vec2f( f32(i)/ f32(N),radicalInverse_VdC(i));}
912
+ fn log4(x: f32)->f32 {return log2(x)/2.;}
913
+ 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;}
914
+ const NUM_SAMPLES_FLOAT: f32= f32(NUM_SAMPLES);const NUM_SAMPLES_FLOAT_INVERSED: f32=1./NUM_SAMPLES_FLOAT;const K: f32=4.;fn irradiance(
915
+ #ifdef CUSTOM_IRRADIANCE_FILTERING_INPUT
916
+ CUSTOM_IRRADIANCE_FILTERING_INPUT
917
+ #else
918
+ inputTexture: texture_cube<f32>,inputSampler: sampler,
919
+ #endif
920
+ inputN: vec3f,
921
+ filteringInfo: vec2f,
922
+ diffuseRoughness: f32,
923
+ surfaceAlbedo: vec3f,
924
+ inputV: vec3f
925
+ #ifdef IBL_CDF_FILTERING
926
+ ,icdfSampler: texture_2d<f32>,icdfSamplerSampler: sampler
927
+ #endif
928
+ )->vec3f
929
+ {var n: vec3f=normalize(inputN);var result: vec3f= vec3f(0.0);
930
+ #ifndef IBL_CDF_FILTERING
931
+ 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);
932
+ #endif
933
+ 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++)
934
+ {var Xi: vec2f=hammersley(i,NUM_SAMPLES);
935
+ #ifdef IBL_CDF_FILTERING
936
+ 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);
937
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
938
+ var LoV: f32=dot(Ls,inputV);
939
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
940
+ var H: vec3f=(inputV+Ls)*0.5;var VoH: f32=dot(inputV,H);
941
+ #endif
942
+ #else
943
+ 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);
944
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
945
+ var LoV: f32=dot(Ls,V);
946
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
947
+ var H: vec3f=(V+Ls)*0.5;var VoH: f32=dot(V,H);
948
+ #endif
949
+ #endif
950
+ if (NoL>0.) {
951
+ #ifdef IBL_CDF_FILTERING
952
+ var pdf: f32=textureSampleLevel(icdfSampler,icdfSamplerSampler,T,0.0).z;var c: vec3f=textureSampleLevel(inputTexture,inputSampler,Ls,0.0).rgb;
953
+ #else
954
+ 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);
955
+ #ifdef CUSTOM_IRRADIANCE_FILTERING_FUNCTION
956
+ CUSTOM_IRRADIANCE_FILTERING_FUNCTION
957
+ #else
958
+ var c: vec3f=textureSampleLevel(inputTexture,inputSampler,tbn*Ls,mipLevel).rgb;
959
+ #endif
960
+ #endif
961
+ #ifdef GAMMA_INPUT
962
+ c=toLinearSpaceVec3(c);
963
+ #endif
964
+ var diffuseRoughnessTerm: vec3f=vec3f(1.0);
965
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
966
+ diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;
967
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
968
+ diffuseRoughnessTerm=vec3f(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);
969
+ #endif
970
+ #ifdef IBL_CDF_FILTERING
971
+ var light: vec3f=vec3f(0.0);if (pdf>1e-6) {light=vec3f(1.0)/vec3f(pdf)*c;}
972
+ result+=NoL*diffuseRoughnessTerm*light;
973
+ #else
974
+ result+=c*diffuseRoughnessTerm;
975
+ #endif
976
+ }}
977
+ result=result*NUM_SAMPLES_FLOAT_INVERSED;
978
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
979
+ result=result/clampedAlbedo;
980
+ #endif
981
+ return result;}
982
+ fn radiance(alphaG: f32,inputTexture: texture_cube<f32>,inputSampler: sampler,inputN: vec3f,filteringInfo: vec2f)->vec3f
983
+ {var n: vec3f=normalize(inputN);var c: vec3f=textureSampleLevel(inputTexture,inputSampler,n,0.0).rgb;
984
+ if (alphaG==0.) {
985
+ #ifdef GAMMA_INPUT
986
+ c=toLinearSpaceVec3(c);
987
+ #endif
988
+ 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++)
989
+ {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;
990
+ #ifdef GAMMA_INPUT
991
+ c=toLinearSpaceVec3(c);
992
+ #endif
993
+ result+=c*NoL;}}
994
+ result=result/weight;return result;}}
995
+ #ifdef ANISOTROPIC
996
+ fn radianceAnisotropic(
997
+ alphaTangent: f32,
998
+ alphaBitangent: f32,
999
+ inputTexture: texture_cube<f32>,
1000
+ inputSampler: sampler,
1001
+ inputView: vec3f,
1002
+ inputTangent: vec3f,
1003
+ inputBitangent: vec3f,
1004
+ inputNormal: vec3f,
1005
+ filteringInfo: vec2f,
1006
+ noiseInput: vec2f,
1007
+ isRefraction: bool,
1008
+ ior: f32
1009
+ )->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++)
1010
+ {var Xi: vec2f=hammersley(i,NUM_SAMPLES);Xi=fract(Xi+noiseInput*mix(0.5f,0.015f,noiseScale));
1011
+ 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);}
1012
+ 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(
1013
+ H_tangent.z,H_tangent.x,H_tangent.y,vec2f(clampedAlphaT,clampedAlphaB)
1014
+ );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;
1015
+ #if GAMMA_INPUT
1016
+ c=toLinearSpaceVec3(c);
1017
+ #endif
1018
+ result+=c*NoL;}}
1019
+ result=result/weight;return result;}
1020
+ #endif
1021
+ #endif
1022
+ #endif
1023
+ `;r.ShaderStore.IncludesShadersStoreWGSL[m]||(r.ShaderStore.IncludesShadersStoreWGSL[m]=p),e.s(["hdrFilteringFunctionsWGSL",0,{name:m,shader:p}],69075);let S="pbrBlockReflectance0",E=`var reflectanceF0: f32=reflectivityOut.reflectanceF0;var specularEnvironmentR0: vec3f=reflectivityOut.colorReflectanceF0;var specularEnvironmentR90: vec3f= reflectivityOut.reflectanceF90;
1024
+ #ifdef ALPHAFRESNEL
1025
+ var reflectance90: f32=fresnelGrazingReflectance(reflectanceF0);specularEnvironmentR90=specularEnvironmentR90*reflectance90;
1026
+ #endif
1027
+ `;r.ShaderStore.IncludesShadersStoreWGSL[S]||(r.ShaderStore.IncludesShadersStoreWGSL[S]=E),e.s(["pbrBlockReflectance0WGSL",0,{name:S,shader:E}],62026),e.i(87850);let h="pbrDirectLightingFunctions",g=`#define CLEARCOATREFLECTANCE90 1.0
1028
+ struct lightingInfo
1029
+ {diffuse: vec3f,
1030
+ #ifdef SS_TRANSLUCENCY
1031
+ diffuseTransmission: vec3f,
1032
+ #endif
1033
+ #ifdef SPECULARTERM
1034
+ specular: vec3f,
1035
+ #endif
1036
+ #ifdef CLEARCOAT
1037
+ clearCoat: vec4f,
1038
+ #endif
1039
+ #ifdef SHEEN
1040
+ sheen: vec3f
1041
+ #endif
1042
+ };fn adjustRoughnessFromLightProperties(roughness: f32,lightRadius: f32,lightDistance: f32)->f32 {
1043
+ #if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)
1044
+ var lightRoughness: f32=lightRadius/lightDistance;var totalRoughness: f32=saturate(lightRoughness+roughness);return totalRoughness;
1045
+ #else
1046
+ return roughness;
1047
+ #endif
1048
+ }
1049
+ fn computeHemisphericDiffuseLighting(info: preLightingInfo,lightColor: vec3f,groundColor: vec3f)->vec3f {return mix(groundColor,lightColor,info.NdotL);}
1050
+ #if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1051
+ fn computeAreaDiffuseLighting(info: preLightingInfo,lightColor: vec3f)->vec3f {return info.areaLightDiffuse*lightColor;}
1052
+ #endif
1053
+ fn computeDiffuseLighting(info: preLightingInfo,lightColor: vec3f)->vec3f {var diffuseTerm: vec3f=vec3f(1.0/PI);
1054
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_LEGACY
1055
+ diffuseTerm=vec3f(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness));
1056
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
1057
+ diffuseTerm=vec3f(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.diffuseRoughness));
1058
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
1059
+ 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;
1060
+ #endif
1061
+ return diffuseTerm*info.attenuation*info.NdotL*lightColor;}
1062
+ 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);}
1063
+ #ifdef SS_TRANSLUCENCY
1064
+ fn computeDiffuseTransmittedLighting(info: preLightingInfo,lightColor: vec3f,transmittance: vec3f)->vec3f {var transmittanceNdotL=vec3f(0.0);var NdotL: f32=absEps(info.NdotLUnclamped);
1065
+ #ifndef SS_TRANSLUCENCY_LEGACY
1066
+ if (info.NdotLUnclamped<0.0) {
1067
+ #endif
1068
+ var wrapNdotL: f32=computeWrappedDiffuseNdotL(NdotL,0.02);var trAdapt: f32=step(0.,info.NdotLUnclamped);transmittanceNdotL=mix(transmittance*wrapNdotL, vec3f(wrapNdotL),trAdapt);
1069
+ #ifndef SS_TRANSLUCENCY_LEGACY
1070
+ }
1071
+ var diffuseTerm : vec3f=vec3f(1.0/PI);
1072
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_LEGACY
1073
+ diffuseTerm=vec3f(diffuseBRDF_Burley(
1074
+ info.NdotL,info.NdotV,info.VdotH,info.roughness));
1075
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
1076
+ diffuseTerm=vec3f(diffuseBRDF_Burley(
1077
+ info.NdotL,info.NdotV,info.VdotH,info.diffuseRoughness));
1078
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
1079
+ var clampedAlbedo: vec3f=clamp(info.surfaceAlbedo,vec3f(0.1),vec3f(1.0));diffuseTerm=diffuseBRDF_EON(clampedAlbedo,info.diffuseRoughness,
1080
+ info.NdotL,info.NdotV,info.LdotV);diffuseTerm/=clampedAlbedo;
1081
+ #endif
1082
+ return (transmittanceNdotL*diffuseTerm)*info.attenuation*lightColor;
1083
+ #else
1084
+ let diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;
1085
+ #endif
1086
+ }
1087
+ #endif
1088
+ #ifdef SPECULARTERM
1089
+ 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;
1090
+ #ifdef IRIDESCENCE
1091
+ modifiedFresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
1092
+ #endif
1093
+ var distribution: f32=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);
1094
+ #ifdef BRDF_V_HEIGHT_CORRELATED
1095
+ var smithVisibility: f32=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);
1096
+ #else
1097
+ var smithVisibility: f32=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);
1098
+ #endif
1099
+ var specTerm: vec3f=modifiedFresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;}
1100
+ #if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1101
+ 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;}
1102
+ #endif
1103
+ #endif
1104
+ #ifdef FUZZ
1105
+ fn evalFuzz(L: vec3f,NdotL: f32,NdotV: f32,T: vec3f,B: vec3f,ltcLut: vec3f)->f32
1106
+ {if (NdotL<=0.0f || NdotV<=0.0f) {return 0.0f;}
1107
+ let M=mat3x3f(
1108
+ vec3f(ltcLut.r,0.0f,0.0f),
1109
+ vec3f(ltcLut.g,1.0f,0.0f),
1110
+ vec3f(0.0f,0.0f,1.0f)
1111
+ );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;}
1112
+ #endif
1113
+ #if defined(ANISOTROPIC) && defined(ANISOTROPIC_OPENPBR)
1114
+ 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;}
1115
+ #elif defined(ANISOTROPIC)
1116
+ 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);
1117
+ #ifdef IRIDESCENCE
1118
+ fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
1119
+ #endif
1120
+ 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;}
1121
+ #endif
1122
+ #ifdef CLEARCOAT
1123
+ 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(
1124
+ clearCoatTerm*info.attenuation*NccdotL*lightColor,
1125
+ 1.0-fresnel
1126
+ );}
1127
+ 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;}
1128
+ #endif
1129
+ #ifdef SHEEN
1130
+ 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
1131
+ var visibility: f32=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG);
1132
+ #else */
1133
+ var visibility: f32=visibility_Ashikhmin(info.NdotL,info.NdotV);/* #endif */
1134
+ var sheenTerm: f32=fresnel*distribution*visibility;return sheenTerm*info.attenuation*info.NdotL*lightColor;}
1135
+ #endif
1136
+ #if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
1137
+ #include<clusteredLightingFunctions>
1138
+ fn computeClusteredLighting(
1139
+ lightDataTexture: texture_2d<f32>,
1140
+ tileMaskBuffer: ptr<storage,array<u32>>,
1141
+ lightData: vec4f,
1142
+ sliceRange: vec2u,
1143
+ V: vec3f,
1144
+ N: vec3f,
1145
+ posW: vec3f,
1146
+ surfaceAlbedo: vec3f,
1147
+ reflectivityOut: reflectivityOutParams,
1148
+ #ifdef IRIDESCENCE
1149
+ iridescenceIntensity: f32,
1150
+ #endif
1151
+ #ifdef SS_TRANSLUCENCY
1152
+ subSurfaceOut: subSurfaceOutParams,
1153
+ #endif
1154
+ #ifdef SPECULARTERM
1155
+ AARoughnessFactor: f32,
1156
+ #endif
1157
+ #ifdef ANISOTROPIC
1158
+ anisotropicOut: anisotropicOutParams,
1159
+ #endif
1160
+ #ifdef SHEEN
1161
+ sheenOut: sheenOutParams,
1162
+ #endif
1163
+ #ifdef CLEARCOAT
1164
+ clearcoatOut: clearcoatOutParams,
1165
+ #endif
1166
+ )->lightingInfo {let NdotV=absEps(dot(N,V));
1167
+ #include<pbrBlockReflectance0>
1168
+ #ifdef CLEARCOAT
1169
+ specularEnvironmentR0=clearcoatOut.specularEnvironmentR0;
1170
+ #endif
1171
+ 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;
1172
+ 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);}
1173
+ preInfo.roughness=adjustRoughnessFromLightProperties(reflectivityOut.roughness,light.vLightSpecular.a,preInfo.lightDistance);preInfo.diffuseRoughness=reflectivityOut.diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo;
1174
+ #ifdef IRIDESCENCE
1175
+ preInfo.iridescenceIntensity=iridescenceIntensity;
1176
+ #endif
1177
+ var info: lightingInfo;
1178
+ #ifdef SS_TRANSLUCENCY
1179
+ #ifdef SS_TRANSLUCENCY_LEGACY
1180
+ info.diffuse=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance);info.diffuseTransmission=vec3(0);
1181
+ #else
1182
+ info.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance);
1183
+ #endif
1184
+ #else
1185
+ info.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb);
1186
+ #endif
1187
+ #ifdef SPECULARTERM
1188
+ #if CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR
1189
+ 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);
1190
+ #else
1191
+ let coloredFresnel=fresnelSchlickGGXVec3(preInfo.VdotH,specularEnvironmentR0,reflectivityOut.colorReflectanceF90);
1192
+ #endif
1193
+ #ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION
1194
+ let NdotH=dot(N,preInfo.H);let fresnel=fresnelSchlickGGXVec3(NdotH,vec3(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3(1.0)-fresnel);
1195
+ #endif
1196
+ #ifdef ANISOTROPIC
1197
+ info.specular=computeAnisotropicSpecularLighting(preInfo,V,N,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb);
1198
+ #else
1199
+ info.specular=computeSpecularLighting(preInfo,N,specularEnvironmentR0,coloredFresnel,AARoughnessFactor,light.vLightDiffuse.rgb);
1200
+ #endif
1201
+ #endif
1202
+ #ifdef SHEEN
1203
+ #ifdef SHEEN_LINKWITHALBEDO
1204
+ preInfo.roughness=sheenOut.sheenIntensity;
1205
+ #else
1206
+ preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light.vLightSpecular.a,preInfo.lightDistance);
1207
+ #endif
1208
+ info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb);
1209
+ #endif
1210
+ #ifdef CLEARCOAT
1211
+ preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light.vLightSpecular.a,preInfo.lightDistance);info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light.vLightDiffuse.rgb);
1212
+ #ifdef CLEARCOAT_TINT
1213
+ let absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;
1214
+ #ifdef SS_TRANSLUCENCY
1215
+ info.diffuseTransmission*=absorption;
1216
+ #endif
1217
+ #ifdef SPECULARTERM
1218
+ info.specular*=absorption;
1219
+ #endif
1220
+ #endif
1221
+ info.diffuse*=info.clearCoat.w;
1222
+ #ifdef SS_TRANSLUCENCY
1223
+ info.diffuseTransmission*=info.clearCoat.w;
1224
+ #endif
1225
+ #ifdef SPECULARTERM
1226
+ info.specular*=info.clearCoat.w;
1227
+ #endif
1228
+ #ifdef SHEEN
1229
+ info.sheen*=info.clearCoat.w;
1230
+ #endif
1231
+ #endif
1232
+ result.diffuse+=info.diffuse;
1233
+ #ifdef SS_TRANSLUCENCY
1234
+ result.diffuseTransmission+=info.diffuseTransmission;
1235
+ #endif
1236
+ #ifdef SPECULARTERM
1237
+ result.specular+=info.specular;
1238
+ #endif
1239
+ #ifdef CLEARCOAT
1240
+ result.clearCoat+=info.clearCoat;
1241
+ #endif
1242
+ #ifdef SHEEN
1243
+ result.sheen+=info.sheen;
1244
+ #endif
1245
+ }
1246
+ batchOffset+=CLUSTLIGHT_BATCH;}
1247
+ return result;}
1248
+ #endif
1249
+ `;r.ShaderStore.IncludesShadersStoreWGSL[h]||(r.ShaderStore.IncludesShadersStoreWGSL[h]=g),e.s(["pbrDirectLightingFunctionsWGSL",0,{name:h,shader:g}],28285);let L="pbrBlockNormalGeometric",R=`var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-input.vPositionW);
1250
+ #ifdef NORMAL
1251
+ var normalW: vec3f=normalize(input.vNormalW);
1252
+ #else
1253
+ var normalW: vec3f=normalize(cross(dpdx(input.vPositionW),dpdy(input.vPositionW)))*scene.vEyePosition.w;
1254
+ #endif
1255
+ var geometricNormalW: vec3f=normalW;
1256
+ #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
1257
+ geometricNormalW=select(-geometricNormalW,geometricNormalW,fragmentInputs.frontFacing);
1258
+ #endif
1259
+ `;r.ShaderStore.IncludesShadersStoreWGSL[L]||(r.ShaderStore.IncludesShadersStoreWGSL[L]=R),e.s(["pbrBlockNormalGeometricWGSL",0,{name:L,shader:R}],74698);let I="pbrBlockImageProcessing",N=`#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING)
1260
+ #if !defined(SKIPFINALCOLORCLAMP)
1261
+ finalColor=vec4f(clamp(finalColor.rgb,vec3f(0.),vec3f(30.0)),finalColor.a);
1262
+ #endif
1263
+ #else
1264
+ finalColor=applyImageProcessing(finalColor);
1265
+ #endif
1266
+ finalColor=vec4f(finalColor.rgb,finalColor.a*mesh.visibility);
1267
+ #ifdef PREMULTIPLYALPHA
1268
+ finalColor=vec4f(finalColor.rgb*finalColor.a,finalColor.a);;
1269
+ #endif
1270
+ `;r.ShaderStore.IncludesShadersStoreWGSL[I]||(r.ShaderStore.IncludesShadersStoreWGSL[I]=N),e.s(["pbrBlockImageProcessingWGSL",0,{name:I,shader:N}],52640);let C="pbrDebug",A=`#if DEBUGMODE>0
1271
+ if (input.vClipSpacePosition.x/input.vClipSpacePosition.w>=uniforms.vDebugMode.x) {var color: vec3f;
1272
+ #if DEBUGMODE==1
1273
+ color=fragmentInputs.vPositionW.rgb;
1274
+ #define DEBUGMODE_NORMALIZE
1275
+ #elif DEBUGMODE==2 && defined(NORMAL)
1276
+ color=fragmentInputs.vNormalW.rgb;
1277
+ #define DEBUGMODE_NORMALIZE
1278
+ #elif DEBUGMODE==3 && defined(BUMP) || DEBUGMODE==3 && defined(PARALLAX) || DEBUGMODE==3 && defined(ANISOTROPIC)
1279
+ color=TBN[0];
1280
+ #define DEBUGMODE_NORMALIZE
1281
+ #elif DEBUGMODE==4 && defined(BUMP) || DEBUGMODE==4 && defined(PARALLAX) || DEBUGMODE==4 && defined(ANISOTROPIC)
1282
+ color=TBN[1];
1283
+ #define DEBUGMODE_NORMALIZE
1284
+ #elif DEBUGMODE==5
1285
+ color=normalW;
1286
+ #define DEBUGMODE_NORMALIZE
1287
+ #elif DEBUGMODE==6 && defined(MAINUV1)
1288
+ color= vec3f(input.vMainUV1,0.0);
1289
+ #elif DEBUGMODE==7 && defined(MAINUV2)
1290
+ color= vec3f(input.vMainUV2,0.0);
1291
+ #elif DEBUGMODE==8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
1292
+ color=clearcoatOut.TBNClearCoat[0];
1293
+ #define DEBUGMODE_NORMALIZE
1294
+ #elif DEBUGMODE==9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
1295
+ color=clearcoatOut.TBNClearCoat[1];
1296
+ #define DEBUGMODE_NORMALIZE
1297
+ #elif DEBUGMODE==10 && defined(CLEARCOAT)
1298
+ color=clearcoatOut.clearCoatNormalW;
1299
+ #define DEBUGMODE_NORMALIZE
1300
+ #elif DEBUGMODE==11 && defined(ANISOTROPIC)
1301
+ color=anisotropicOut.anisotropicNormal;
1302
+ #define DEBUGMODE_NORMALIZE
1303
+ #elif DEBUGMODE==12 && defined(ANISOTROPIC)
1304
+ color=anisotropicOut.anisotropicTangent;
1305
+ #define DEBUGMODE_NORMALIZE
1306
+ #elif DEBUGMODE==13 && defined(ANISOTROPIC)
1307
+ color=anisotropicOut.anisotropicBitangent;
1308
+ #define DEBUGMODE_NORMALIZE
1309
+ #elif DEBUGMODE==20 && defined(ALBEDO)
1310
+ color=albedoTexture.rgb;
1311
+ #ifndef GAMMAALBEDO
1312
+ #define DEBUGMODE_GAMMA
1313
+ #endif
1314
+ #elif DEBUGMODE==21 && defined(AMBIENT)
1315
+ color=aoOut.ambientOcclusionColorMap.rgb;
1316
+ #elif DEBUGMODE==22 && defined(OPACITY)
1317
+ color=opacityMap.rgb;
1318
+ #elif DEBUGMODE==23 && defined(EMISSIVE)
1319
+ color=emissiveColorTex.rgb;
1320
+ #ifndef GAMMAEMISSIVE
1321
+ #define DEBUGMODE_GAMMA
1322
+ #endif
1323
+ #elif DEBUGMODE==24 && defined(LIGHTMAP)
1324
+ color=lightmapColor;
1325
+ #ifndef GAMMALIGHTMAP
1326
+ #define DEBUGMODE_GAMMA
1327
+ #endif
1328
+ #elif DEBUGMODE==25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
1329
+ color=reflectivityOut.surfaceMetallicColorMap.rgb;
1330
+ #elif DEBUGMODE==26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
1331
+ color=reflectivityOut.surfaceReflectivityColorMap.rgb;
1332
+ #define DEBUGMODE_GAMMA
1333
+ #elif DEBUGMODE==27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
1334
+ color= vec3f(clearcoatOut.clearCoatMapData.rg,0.0);
1335
+ #elif DEBUGMODE==28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
1336
+ color=clearcoatOut.clearCoatTintMapData.rgb;
1337
+ #elif DEBUGMODE==29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
1338
+ color=sheenOut.sheenMapData.rgb;
1339
+ #elif DEBUGMODE==30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
1340
+ color=anisotropicOut.anisotropyMapData.rgb;
1341
+ #elif DEBUGMODE==31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
1342
+ color=subSurfaceOut.thicknessMap.rgb;
1343
+ #elif DEBUGMODE==32 && defined(BUMP)
1344
+ color=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).rgb;
1345
+ #elif DEBUGMODE==40 && defined(SS_REFRACTION)
1346
+ color=subSurfaceOut.environmentRefraction.rgb;
1347
+ #define DEBUGMODE_GAMMA
1348
+ #elif DEBUGMODE==41 && defined(REFLECTION)
1349
+ color=reflectionOut.environmentRadiance.rgb;
1350
+ #ifndef GAMMAREFLECTION
1351
+ #define DEBUGMODE_GAMMA
1352
+ #endif
1353
+ #elif DEBUGMODE==42 && defined(CLEARCOAT) && defined(REFLECTION)
1354
+ color=clearcoatOut.environmentClearCoatRadiance.rgb;
1355
+ #define DEBUGMODE_GAMMA
1356
+ #elif DEBUGMODE==50
1357
+ color=diffuseBase.rgb;
1358
+ #define DEBUGMODE_GAMMA
1359
+ #elif DEBUGMODE==51 && defined(SPECULARTERM)
1360
+ color=specularBase.rgb;
1361
+ #define DEBUGMODE_GAMMA
1362
+ #elif DEBUGMODE==52 && defined(CLEARCOAT)
1363
+ color=clearCoatBase.rgb;
1364
+ #define DEBUGMODE_GAMMA
1365
+ #elif DEBUGMODE==53 && defined(SHEEN)
1366
+ color=sheenBase.rgb;
1367
+ #define DEBUGMODE_GAMMA
1368
+ #elif DEBUGMODE==54 && defined(REFLECTION)
1369
+ color=reflectionOut.environmentIrradiance.rgb;
1370
+ #ifndef GAMMAREFLECTION
1371
+ #define DEBUGMODE_GAMMA
1372
+ #endif
1373
+ #elif DEBUGMODE==60
1374
+ color=surfaceAlbedo.rgb;
1375
+ #define DEBUGMODE_GAMMA
1376
+ #elif DEBUGMODE==61
1377
+ color=clearcoatOut.specularEnvironmentR0;
1378
+ #define DEBUGMODE_GAMMA
1379
+ #elif DEBUGMODE==62 && defined(METALLICWORKFLOW)
1380
+ color= vec3f(reflectivityOut.metallic);
1381
+ #elif DEBUGMODE==71 && defined(METALLICWORKFLOW)
1382
+ color=reflectivityOut.metallicF0;
1383
+ #elif DEBUGMODE==63
1384
+ color= vec3f(roughness);
1385
+ #elif DEBUGMODE==64
1386
+ color= vec3f(alphaG);
1387
+ #elif DEBUGMODE==65
1388
+ color= vec3f(NdotV);
1389
+ #elif DEBUGMODE==66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
1390
+ color=clearcoatOut.clearCoatColor;
1391
+ #define DEBUGMODE_GAMMA
1392
+ #elif DEBUGMODE==67 && defined(CLEARCOAT)
1393
+ color= vec3f(clearcoatOut.clearCoatRoughness);
1394
+ #elif DEBUGMODE==68 && defined(CLEARCOAT)
1395
+ color= vec3f(clearcoatOut.clearCoatNdotV);
1396
+ #elif DEBUGMODE==69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
1397
+ color=subSurfaceOut.transmittance;
1398
+ #elif DEBUGMODE==70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
1399
+ color=subSurfaceOut.refractionTransmittance;
1400
+ #elif DEBUGMODE==72
1401
+ color= vec3f(microSurface);
1402
+ #elif DEBUGMODE==73
1403
+ color=uniforms.vAlbedoColor.rgb;
1404
+ #define DEBUGMODE_GAMMA
1405
+ #elif DEBUGMODE==74 && !defined(METALLICWORKFLOW)
1406
+ color=uniforms.vReflectivityColor.rgb;
1407
+ #define DEBUGMODE_GAMMA
1408
+ #elif DEBUGMODE==75
1409
+ color=uniforms.vEmissiveColor;
1410
+ #define DEBUGMODE_GAMMA
1411
+ #elif DEBUGMODE==80 && defined(RADIANCEOCCLUSION)
1412
+ color= vec3f(seo);
1413
+ #elif DEBUGMODE==81 && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
1414
+ color= vec3f(eho);
1415
+ #elif DEBUGMODE==82 && defined(MS_BRDF_ENERGY_CONSERVATION)
1416
+ color= vec3f(energyConservationFactor);
1417
+ #elif DEBUGMODE==83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
1418
+ color=baseSpecularEnvironmentReflectance;
1419
+ #define DEBUGMODE_GAMMA
1420
+ #elif DEBUGMODE==84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
1421
+ color=clearcoatOut.clearCoatEnvironmentReflectance;
1422
+ #define DEBUGMODE_GAMMA
1423
+ #elif DEBUGMODE==85 && defined(SHEEN) && defined(REFLECTION)
1424
+ color=sheenOut.sheenEnvironmentReflectance;
1425
+ #define DEBUGMODE_GAMMA
1426
+ #elif DEBUGMODE==86 && defined(ALPHABLEND)
1427
+ color= vec3f(luminanceOverAlpha);
1428
+ #elif DEBUGMODE==87
1429
+ color= vec3f(alpha);
1430
+ #elif DEBUGMODE==88 && defined(ALBEDO)
1431
+ color= vec3f(albedoTexture.a);
1432
+ #elif DEBUGMODE==89
1433
+ color=aoOut.ambientOcclusionColor;
1434
+ #else
1435
+ 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);
1436
+ #endif
1437
+ color*=uniforms.vDebugMode.y;
1438
+ #ifdef DEBUGMODE_NORMALIZE
1439
+ color=normalize(color)*0.5+0.5;
1440
+ #endif
1441
+ #ifdef DEBUGMODE_GAMMA
1442
+ color=toGammaSpaceVec3(color);
1443
+ #endif
1444
+ fragmentOutputs.color=vec4f(color,1.0);
1445
+ #ifdef PREPASS
1446
+ fragmentOutputs.fragData0=toLinearSpaceVec3(color);
1447
+ fragmentOutputs.fragData1=vec4f(0.,0.,0.,0.);
1448
+ #endif
1449
+ #ifdef DEBUGMODE_FORCERETURN
1450
+ return fragmentOutputs;
1451
+ #endif
1452
+ }
1453
+ #endif
1454
+ `;r.ShaderStore.IncludesShadersStoreWGSL[C]||(r.ShaderStore.IncludesShadersStoreWGSL[C]=A),e.s(["pbrDebugWGSL",0,{name:C,shader:A}],87693)}]);