@uptimizr/dashboard 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/404.html +1 -1
- package/out/__next.__PAGE__.txt +4 -4
- package/out/__next._full.txt +11 -11
- package/out/__next._head.txt +4 -4
- package/out/__next._index.txt +4 -4
- package/out/__next._tree.txt +2 -2
- package/out/_next/static/chunks/002cjeoit6-up.js +1 -0
- package/out/_next/static/chunks/02n1uiltexy3w.js +1 -0
- package/out/_next/static/chunks/03ab2khhe8-x5.js +1 -0
- package/out/_next/static/chunks/04_yytpc2paxy.js +1 -0
- package/out/_next/static/chunks/06qot1qvlsqaz.js +1 -0
- package/out/_next/static/chunks/07eeopuufsqp-.js +1501 -0
- package/out/_next/static/chunks/08a5xek662n8n.js +1 -0
- package/out/_next/static/chunks/08wuc9--s8zn_.js +1 -0
- package/out/_next/static/chunks/0927l-ygd5c8d.js +1 -0
- package/out/_next/static/chunks/09510356f0lad.js +1 -0
- package/out/_next/static/chunks/0_eu72k69lxj7.js +1 -0
- package/out/_next/static/chunks/0beajlqy8p8b5.js +1 -0
- package/out/_next/static/chunks/0c83pe1mpx456.js +1 -0
- package/out/_next/static/chunks/0echnagbkyx79.js +1198 -0
- package/out/_next/static/chunks/0eh1ml86u8dh7.js +1 -0
- package/out/_next/static/chunks/0fh-9h9ylxskr.js +674 -0
- package/out/_next/static/chunks/0fzmc1up21g1i.js +1 -0
- package/out/_next/static/chunks/0g_v2zswo4l6f.js +1 -0
- package/out/_next/static/chunks/0grlb9lo8e502.js +1 -0
- package/out/_next/static/chunks/0h22pg-0xrxnm.js +1 -0
- package/out/_next/static/chunks/0j6p1pmc14t96.js +1 -0
- package/out/_next/static/chunks/0j_6dx-sttgsy.js +1 -0
- package/out/_next/static/chunks/0j__xaq_8_di1.js +1 -0
- package/out/_next/static/chunks/0kfd-cvj5fvtz.js +1 -0
- package/out/_next/static/chunks/0o_mp98xzqfyf.js +1 -0
- package/out/_next/static/chunks/0otsec99kdkt7.js +213 -0
- package/out/_next/static/chunks/0ql-s-tsmel_u.js +151 -0
- package/out/_next/static/chunks/0r47gs_e93cka.js +1 -0
- package/out/_next/static/chunks/0sqys6o2pbe1q.js +1328 -0
- package/out/_next/static/chunks/0titqrn1qmcsv.js +1 -0
- package/out/_next/static/chunks/0tnlbw78tgaxp.js +4 -0
- package/out/_next/static/chunks/0tw4dyl-cp-hd.js +1 -0
- package/out/_next/static/chunks/0vbce-8omgurc.js +1 -0
- package/out/_next/static/chunks/0vfsg5byzep_0.js +1 -0
- package/out/_next/static/chunks/{0gv7mblzv3dl3.js → 0w8_1yjvol1f0.js} +20 -20
- package/out/_next/static/chunks/0xh144a5fz58h.js +1 -0
- package/out/_next/static/chunks/0xjltg_pph0c8.js +1 -0
- package/out/_next/static/chunks/0yeqgh0dnas8d.js +1 -0
- package/out/_next/static/chunks/101-7e_7up7rk.js +1 -0
- package/out/_next/static/chunks/128e51hj_04r0.js +1 -0
- package/out/_next/static/chunks/{10fnxpln_5xfd.js → 12kv810lohbsx.js} +2 -2
- package/out/_next/static/chunks/137xbvd4nd41j.js +3 -0
- package/out/_next/static/chunks/14bws-suyy5zu.js +1 -0
- package/out/_next/static/chunks/14ggsmqwej_tt.js +1656 -0
- package/out/_next/static/chunks/17genz6pkmty_.js +1 -0
- package/out/_next/static/chunks/17xd8hnazzr0g.js +1454 -0
- package/out/_next/static/chunks/18dczy9ylt2s_.js +1 -0
- package/out/_next/static/chunks/18xs_kvsaolb0.js +1 -0
- package/out/_next/static/chunks/19016f8-ry0z6.js +1 -0
- package/out/_next/static/chunks/1_6oejyxj39li.js +1 -0
- package/out/_next/static/chunks/1_aon8nz9p1fr.js +1 -0
- package/out/_next/static/chunks/1_qzlkuxukhpq.js +779 -0
- package/out/_next/static/chunks/1akaj5rhgitn3.js +1 -0
- package/out/_next/static/chunks/1bvl1ws7b_3gn.js +1 -0
- package/out/_next/static/chunks/1cdbk6kxyr1c9.js +1 -0
- package/out/_next/static/chunks/1fbjkk55uu4_g.js +1 -0
- package/out/_next/static/chunks/1furcfsgrw_3g.js +1 -0
- package/out/_next/static/chunks/1g0-f1g3gn_rs.js +1 -0
- package/out/_next/static/chunks/1g7emwu85bifo.js +557 -0
- package/out/_next/static/chunks/{37vzwr3ciejf1.js → 1gs-5722l4u59.js} +1 -1
- package/out/_next/static/chunks/1gt4kh0_xmigy.js +1 -0
- package/out/_next/static/chunks/1h8xzuuhhglu9.js +1 -0
- package/out/_next/static/chunks/1hatz-jlztrn0.js +1 -0
- package/out/_next/static/chunks/1iioifo7i0t0_.js +1 -0
- package/out/_next/static/chunks/{0impkpmxx3ttp.js → 1iiz7jqgj20z0.js} +1 -1
- package/out/_next/static/chunks/1kujmd5n0j9nk.js +1 -0
- package/out/_next/static/chunks/{2kazjq29jeamx.js → 1ltux4lwz7muf.js} +160 -372
- package/out/_next/static/chunks/1m_buecgcq67j.js +740 -0
- package/out/_next/static/chunks/1n9sy0yt5d2vq.js +1 -0
- package/out/_next/static/chunks/1p1gz6dseck--.js +1 -0
- package/out/_next/static/chunks/1p1xtsfwvpuqo.js +1 -0
- package/out/_next/static/chunks/1p8f6okk2ewbz.js +1 -0
- package/out/_next/static/chunks/1qg_etglhvp9h.js +740 -0
- package/out/_next/static/chunks/1th_t5ujeqlkf.js +1 -0
- package/out/_next/static/chunks/1thr-mdzbu96v.js +1 -0
- package/out/_next/static/chunks/1tta1a064979p.js +1 -0
- package/out/_next/static/chunks/1u_riwm0nfww7.js +1 -0
- package/out/_next/static/chunks/1ua15kzid0_8p.js +2560 -0
- package/out/_next/static/chunks/1uu-rt_8p1edp.js +2712 -0
- package/out/_next/static/chunks/1uu93wuxigx4k.js +1 -0
- package/out/_next/static/chunks/{1flb8adpj6_2o.js → 1xpwp4m1tqugp.js} +1 -1
- package/out/_next/static/chunks/1ynju1jqfrcv0.js +1 -0
- package/out/_next/static/chunks/1zfojlgb15okk.js +1 -0
- package/out/_next/static/chunks/1zj8x5wbgnzz-.js +1 -0
- package/out/_next/static/chunks/1zl6t15gh34nn.js +1 -0
- package/out/_next/static/chunks/{1thjncpj7u6pq.js → 223vrr_4sfhsj.js} +1 -1
- package/out/_next/static/chunks/22cr2b04btguf.js +1 -0
- package/out/_next/static/chunks/242xhzxxetctz.js +1 -0
- package/out/_next/static/chunks/24essz5mmvx-6.js +1 -0
- package/out/_next/static/chunks/256k1jw1m--l7.js +146 -0
- package/out/_next/static/chunks/259obyrpxcv6r.js +1 -0
- package/out/_next/static/chunks/26v9yqicofqba.js +1 -0
- package/out/_next/static/chunks/290d93hmm_e8b.js +1 -0
- package/out/_next/static/chunks/2_2fk7iddrs43.js +1 -0
- package/out/_next/static/chunks/{00k_j_r7bv_eb.js → 2bjlls8-qe05r.js} +9 -9
- package/out/_next/static/chunks/2ckd7f1wbfod-.js +1 -0
- package/out/_next/static/chunks/{163fa70v4mgxj.js → 2d6hru4qo23tt.js} +1 -1
- package/out/_next/static/chunks/2ejvntxtvf5o9.js +1 -0
- package/out/_next/static/chunks/2f7_3tzf7xhps.js +1 -0
- package/out/_next/static/chunks/2gxd_o1g89_bv.js +1 -0
- package/out/_next/static/chunks/2hd2txb4-m9k1.js +1 -0
- package/out/_next/static/chunks/2hpxou_cnp4f_.js +1 -0
- package/out/_next/static/chunks/2izioctrfc0s5.js +1 -0
- package/out/_next/static/chunks/2jhnk4h4n0udv.js +1 -0
- package/out/_next/static/chunks/2jpkhkk9zi8-f.js +1 -0
- package/out/_next/static/chunks/2kpet_l1kq2sx.js +1 -0
- package/out/_next/static/chunks/2mdbvf1b5h00_.css +3 -0
- package/out/_next/static/chunks/2nck5w4c7leb7.js +1 -0
- package/out/_next/static/chunks/2our10fwtj87e.js +1 -0
- package/out/_next/static/chunks/2qq3uzsbiicw3.js +1194 -0
- package/out/_next/static/chunks/2qqqpu0ahfdda.js +1 -0
- package/out/_next/static/chunks/2u-f7mmxvk8wj.js +1 -0
- package/out/_next/static/chunks/2ue1wo4ryk87z.js +1 -0
- package/out/_next/static/chunks/2uk-vwlxe9-xr.js +1 -0
- package/out/_next/static/chunks/2ur5-lxdvv1jm.js +1 -0
- package/out/_next/static/chunks/2veqsohwfhfqc.js +1 -0
- package/out/_next/static/chunks/2vqlv9wnewhu9.js +1 -0
- package/out/_next/static/chunks/{1zvc1tv--w8nn.js → 2wzshintp5lf8.js} +1 -1
- package/out/_next/static/chunks/2x-00glogc485.js +1 -0
- package/out/_next/static/chunks/2yfxy0f5fqs4o.js +1 -0
- package/out/_next/static/chunks/2z88mt3ixktu3.js +1 -0
- package/out/_next/static/chunks/2z_jn9ud28fk7.js +1 -0
- package/out/_next/static/chunks/3-eswqjobiqk1.js +1 -0
- package/out/_next/static/chunks/30-tbi7pys6fp.js +4 -0
- package/out/_next/static/chunks/30c-nsedy_ce0.js +1 -0
- package/out/_next/static/chunks/31u5lbu1vxznh.js +1 -0
- package/out/_next/static/chunks/{2feca0xcipcyt.js → 32ahba5ezp467.js} +156 -156
- package/out/_next/static/chunks/337hn35kts7ud.js +1 -0
- package/out/_next/static/chunks/33dgpebv-tf73.js +1 -0
- package/out/_next/static/chunks/36jkdhq6kb-cf.js +1 -0
- package/out/_next/static/chunks/37epa8fz59vba.js +1166 -0
- package/out/_next/static/chunks/3833xfnz0a-ub.js +1 -0
- package/out/_next/static/chunks/38awrh_qxn22k.js +1 -0
- package/out/_next/static/chunks/{0wrm9jr-9bw0e.js → 38x3c1ra5slhe.js} +383 -913
- package/out/_next/static/chunks/39idqlqlcp5b9.js +1 -0
- package/out/_next/static/chunks/{2a3spdq-m8drh.js → 3_gku1pwluoo0.js} +1 -1
- package/out/_next/static/chunks/3_mu-4rdjajna.js +1450 -0
- package/out/_next/static/chunks/3coacc4-g-g5c.js +1 -0
- package/out/_next/static/chunks/3e00fzdfkclzq.js +1 -0
- package/out/_next/static/chunks/3e8fmlq0k5wkg.js +1 -0
- package/out/_next/static/chunks/3e9tzyrt4_98z.js +1 -0
- package/out/_next/static/chunks/3edelqkq92pil.js +1 -0
- package/out/_next/static/chunks/3figbil1t4ssj.js +593 -0
- package/out/_next/static/chunks/3gimb3z_mteou.js +1 -0
- package/out/_next/static/chunks/{2p2vv6cc9i-3q.js → 3idaz_s77e-j_.js} +9 -9
- package/out/_next/static/chunks/3j-4wuhs5weba.js +1 -0
- package/out/_next/static/chunks/3jjfnwvybayy7.js +1 -0
- package/out/_next/static/chunks/3jwm5dfk_78gc.js +1 -0
- package/out/_next/static/chunks/3k9d4ylc3li2t.js +1352 -0
- package/out/_next/static/chunks/3l3_0ack3gy4k.js +1 -0
- package/out/_next/static/chunks/3lwhs5ja7tun3.js +1 -0
- package/out/_next/static/chunks/3m6nmp2dca6un.js +1342 -0
- package/out/_next/static/chunks/3mbnfpufs2-7e.js +7 -0
- package/out/_next/static/chunks/3mcd08gmt038z.js +1 -0
- package/out/_next/static/chunks/3mt5th7b1i_u9.js +1 -0
- package/out/_next/static/chunks/3ne77mjdz2y7o.js +1 -0
- package/out/_next/static/chunks/3puhrqtujktyv.js +1 -0
- package/out/_next/static/chunks/3rdifucupcgkg.js +1 -0
- package/out/_next/static/chunks/3riekaxl3uxfb.js +1195 -0
- package/out/_next/static/chunks/3sdoskq_buttj.js +1 -0
- package/out/_next/static/chunks/3tg-ma9tv9xu4.js +1 -0
- package/out/_next/static/chunks/3tm-pqpmq_ppw.js +1 -0
- package/out/_next/static/chunks/3w9go565cjhq3.js +1636 -0
- package/out/_next/static/chunks/3wi9gzq2mtr_q.js +8 -0
- package/out/_next/static/chunks/3xagd_2_9zft2.js +1 -0
- package/out/_next/static/chunks/3xsq_anpad-fb.js +1 -0
- package/out/_next/static/chunks/3ycv2qq7vpbua.js +1 -0
- package/out/_next/static/chunks/3z84au-mitjjw.js +1 -0
- package/out/_next/static/chunks/4030dhur2h70-.js +1 -0
- package/out/_next/static/chunks/40ffffml4h_3r.js +4 -0
- package/out/_next/static/chunks/{3-shckrcpvbxu.js → 41wt50z9tx9cx.js} +108 -711
- package/out/_next/static/chunks/431slrqh0wa0g.js +1 -0
- package/out/_next/static/chunks/43s_lbd1i2krj.js +1 -0
- package/out/_next/static/chunks/{0-2y-_oomza2l.js → 44nxswtahaq4w.js} +18 -18
- package/out/_next/static/chunks/45bwefvdpztfs.js +1 -0
- package/out/_next/static/chunks/{turbopack-0sgd6pfbe1fy6.js → turbopack-19105pdhzxp1x.js} +1 -1
- package/out/_not-found/__next._full.txt +9 -9
- package/out/_not-found/__next._head.txt +4 -4
- package/out/_not-found/__next._index.txt +4 -4
- package/out/_not-found/__next._not-found.__PAGE__.txt +2 -2
- package/out/_not-found/__next._not-found.txt +3 -3
- package/out/_not-found/__next._tree.txt +2 -2
- package/out/_not-found.html +1 -1
- package/out/_not-found.txt +9 -9
- package/out/index.html +1 -1
- package/out/index.txt +11 -11
- package/package.json +5 -4
- package/out/_next/static/chunks/068j6934u8j16.js +0 -1
- package/out/_next/static/chunks/09e4adtr6w0xe.js +0 -1
- package/out/_next/static/chunks/0_rf76jneiwal.js +0 -176
- package/out/_next/static/chunks/0aznt7717miff.js +0 -1
- package/out/_next/static/chunks/0cu-q5q3a7uf3.js +0 -1
- package/out/_next/static/chunks/0fskcfh9vbhtv.js +0 -1
- package/out/_next/static/chunks/0gg-ii7i6d_p6.js +0 -1
- package/out/_next/static/chunks/0tx1j_ghpz7rc.css +0 -3
- package/out/_next/static/chunks/0ufbyo1x3qkmo.js +0 -1
- package/out/_next/static/chunks/0wwcfw8i3j_zx.js +0 -1
- package/out/_next/static/chunks/0wwkrsvxwi57d.js +0 -1
- package/out/_next/static/chunks/0ys9-ozuluawt.js +0 -1
- package/out/_next/static/chunks/1-61zh4waha61.js +0 -1
- package/out/_next/static/chunks/10r_824wzt8hj.js +0 -1
- package/out/_next/static/chunks/123xxske5c9na.js +0 -1
- package/out/_next/static/chunks/13isnf0--pmx1.js +0 -1
- package/out/_next/static/chunks/157d9euci08yu.js +0 -1
- package/out/_next/static/chunks/18u58lorfahxi.js +0 -4
- package/out/_next/static/chunks/1_aahautsz2v_.js +0 -1
- package/out/_next/static/chunks/1o1d0p-v1z8ty.js +0 -1
- package/out/_next/static/chunks/1vdjn0pkoyypn.js +0 -1
- package/out/_next/static/chunks/1yehxf-fmeicg.js +0 -1
- package/out/_next/static/chunks/1zx2q-r32thv1.js +0 -4
- package/out/_next/static/chunks/2-sjjedfr0kfq.js +0 -1
- package/out/_next/static/chunks/25b9x-li-tvk2.js +0 -1
- package/out/_next/static/chunks/2aelw3far6rii.js +0 -1
- package/out/_next/static/chunks/2aor7m-wbis85.js +0 -1
- package/out/_next/static/chunks/2clzipqap01hp.js +0 -1
- package/out/_next/static/chunks/2fh-_9b6tqhvb.js +0 -1
- package/out/_next/static/chunks/2g5gecypj0rqe.js +0 -1
- package/out/_next/static/chunks/2szdcpl41-kzv.js +0 -1
- package/out/_next/static/chunks/2u6shh3oeycm-.js +0 -1
- package/out/_next/static/chunks/2unhhuv0arlcv.js +0 -1
- package/out/_next/static/chunks/2z5eqx5do5std.js +0 -1
- package/out/_next/static/chunks/310uz81hnnzsu.js +0 -1
- package/out/_next/static/chunks/3aqbf_wkg2sih.js +0 -3
- package/out/_next/static/chunks/3i3gbhccmhu7j.js +0 -210
- package/out/_next/static/chunks/3mqy-84_ul3t2.js +0 -1
- package/out/_next/static/chunks/3nz-dh9d7cehk.js +0 -1
- package/out/_next/static/chunks/3pufs8g4ui943.js +0 -1
- package/out/_next/static/chunks/3t06schbtqonl.js +0 -1
- package/out/_next/static/chunks/3v3-7fio3nw_t.js +0 -1
- package/out/_next/static/chunks/3v5ha25nxo43j.js +0 -1
- package/out/_next/static/chunks/3zskk1hxu3-_o.js +0 -1
- /package/out/_next/static/{vHD3x58R_2B6QWAhZXCg7 → M9ZSIaKJeBgkjz1qktYio}/_buildManifest.js +0 -0
- /package/out/_next/static/{vHD3x58R_2B6QWAhZXCg7 → M9ZSIaKJeBgkjz1qktYio}/_clientMiddlewareManifest.js +0 -0
- /package/out/_next/static/{vHD3x58R_2B6QWAhZXCg7 → M9ZSIaKJeBgkjz1qktYio}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,1166 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,28657,78875,23344,e=>{"use strict";var r=e.i(12423);let a="bumpFragmentMainFunctions",i=`#ifndef TEXRD_DEFINED
|
|
2
|
+
fn TEXRD(t: texture_2d<f32>,ts: sampler,uv: vec2f)->vec4f {return textureSample(t,ts,uv);}
|
|
3
|
+
#define TEXRD_DEFINED
|
|
4
|
+
#endif
|
|
5
|
+
#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)
|
|
6
|
+
#if defined(TANGENT) && defined(NORMAL)
|
|
7
|
+
varying vTBN0: vec3f;varying vTBN1: vec3f;varying vTBN2: vec3f;
|
|
8
|
+
#endif
|
|
9
|
+
#ifdef OBJECTSPACE_NORMALMAP
|
|
10
|
+
uniform normalMatrix: mat4x4f;fn toNormalMatrix(m: mat4x4f)->mat4x4f
|
|
11
|
+
{var a00=m[0][0];var a01=m[0][1];var a02=m[0][2];var a03=m[0][3];var a10=m[1][0];var a11=m[1][1];var a12=m[1][2];var a13=m[1][3];var a20=m[2][0];
|
|
12
|
+
var a21=m[2][1];var a22=m[2][2];var a23=m[2][3];var a30=m[3][0];
|
|
13
|
+
var a31=m[3][1];var a32=m[3][2];var a33=m[3][3];var b00=a00*a11-a01*a10;var b01=a00*a12-a02*a10;var b02=a00*a13-a03*a10;var b03=a01*a12-a02*a11;var b04=a01*a13-a03*a11;var b05=a02*a13-a03*a12;var b06=a20*a31-a21*a30;var b07=a20*a32-a22*a30;var b08=a20*a33-a23*a30;var b09=a21*a32-a22*a31;var b10=a21*a33-a23*a31;var b11=a22*a33-a23*a32;var det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;var mi=mat4x4<f32>(
|
|
14
|
+
(a11*b11-a12*b10+a13*b09)/det,
|
|
15
|
+
(a02*b10-a01*b11-a03*b09)/det,
|
|
16
|
+
(a31*b05-a32*b04+a33*b03)/det,
|
|
17
|
+
(a22*b04-a21*b05-a23*b03)/det,
|
|
18
|
+
(a12*b08-a10*b11-a13*b07)/det,
|
|
19
|
+
(a00*b11-a02*b08+a03*b07)/det,
|
|
20
|
+
(a32*b02-a30*b05-a33*b01)/det,
|
|
21
|
+
(a20*b05-a22*b02+a23*b01)/det,
|
|
22
|
+
(a10*b10-a11*b08+a13*b06)/det,
|
|
23
|
+
(a01*b08-a00*b10-a03*b06)/det,
|
|
24
|
+
(a30*b04-a31*b02+a33*b00)/det,
|
|
25
|
+
(a21*b02-a20*b04-a23*b00)/det,
|
|
26
|
+
(a11*b07-a10*b09-a12*b06)/det,
|
|
27
|
+
(a00*b09-a01*b07+a02*b06)/det,
|
|
28
|
+
(a31*b01-a30*b03-a32*b00)/det,
|
|
29
|
+
(a20*b03-a21*b01+a22*b00)/det);return mat4x4<f32>(mi[0][0],mi[1][0],mi[2][0],mi[3][0],
|
|
30
|
+
mi[0][1],mi[1][1],mi[2][1],mi[3][1],
|
|
31
|
+
mi[0][2],mi[1][2],mi[2][2],mi[3][2],
|
|
32
|
+
mi[0][3],mi[1][3],mi[2][3],mi[3][3]);}
|
|
33
|
+
#endif
|
|
34
|
+
fn perturbNormalBase(cotangentFrame: mat3x3f,normal: vec3f,scale: f32)->vec3f
|
|
35
|
+
{var output=normal;
|
|
36
|
+
#ifdef NORMALXYSCALE
|
|
37
|
+
output=normalize(output* vec3f(scale,scale,1.0));
|
|
38
|
+
#endif
|
|
39
|
+
return normalize(cotangentFrame*output);}
|
|
40
|
+
fn perturbNormal(cotangentFrame: mat3x3f,textureSample: vec3f,scale: f32)->vec3f
|
|
41
|
+
{return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);}
|
|
42
|
+
fn cotangent_frame(normal: vec3f,p: vec3f,uv: vec2f,tangentSpaceParams: vec2f)->mat3x3f
|
|
43
|
+
{var dp1: vec3f=dpdx(p);var dp2: vec3f=dpdy(p);var duv1: vec2f=dpdx(uv);var duv2: vec2f=dpdy(uv);var dp2perp: vec3f=cross(dp2,normal);var dp1perp: vec3f=cross(normal,dp1);var tangent: vec3f=dp2perp*duv1.x+dp1perp*duv2.x;var bitangent: vec3f=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;var det: f32=max(dot(tangent,tangent),dot(bitangent,bitangent));var invmax: f32=select(inverseSqrt(det),0.0,det==0.0);return mat3x3f(tangent*invmax,bitangent*invmax,normal);}
|
|
44
|
+
#endif
|
|
45
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[a]||(r.ShaderStore.IncludesShadersStoreWGSL[a]=i),e.s(["bumpFragmentMainFunctionsWGSL",0,{name:a,shader:i}],28657),e.i(67367);let f="bumpFragmentFunctions",n=`#if defined(BUMP)
|
|
46
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)
|
|
47
|
+
#endif
|
|
48
|
+
#if defined(DETAIL)
|
|
49
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
|
|
50
|
+
#endif
|
|
51
|
+
#if defined(BUMP) && defined(PARALLAX)
|
|
52
|
+
const minSamples: f32=4.;const maxSamples: f32=15.;const iMaxSamples: i32=15;fn parallaxOcclusion(vViewDirCoT: vec3f,vNormalCoT: vec3f,texCoord: vec2f,parallaxScale: f32)->vec2f {var parallaxLimit: f32=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;var vOffsetDir: vec2f=normalize(vViewDirCoT.xy);var vMaxOffset: vec2f=vOffsetDir*parallaxLimit;var numSamples: f32=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));var stepSize: f32=1.0/numSamples;var currRayHeight: f32=1.0;var vCurrOffset: vec2f= vec2f(0,0);var vLastOffset: vec2f= vec2f(0,0);var lastSampledHeight: f32=1.0;var currSampledHeight: f32=1.0;var keepWorking: bool=true;for (var i: i32=0; i<iMaxSamples; i++)
|
|
53
|
+
{currSampledHeight=textureSample(bumpSampler,bumpSamplerSampler,texCoord+vCurrOffset).w;if (!keepWorking)
|
|
54
|
+
{}
|
|
55
|
+
else if (currSampledHeight>currRayHeight)
|
|
56
|
+
{var delta1: f32=currSampledHeight-currRayHeight;var delta2: f32=(currRayHeight+stepSize)-lastSampledHeight;var ratio: f32=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;}
|
|
57
|
+
else
|
|
58
|
+
{currRayHeight-=stepSize;vLastOffset=vCurrOffset;
|
|
59
|
+
#ifdef PARALLAX_RHS
|
|
60
|
+
vCurrOffset-=stepSize*vMaxOffset;
|
|
61
|
+
#else
|
|
62
|
+
vCurrOffset+=stepSize*vMaxOffset;
|
|
63
|
+
#endif
|
|
64
|
+
lastSampledHeight=currSampledHeight;}}
|
|
65
|
+
return vCurrOffset;}
|
|
66
|
+
fn parallaxOffset(viewDir: vec3f,heightScale: f32)->vec2f
|
|
67
|
+
{var height: f32=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).w;var texCoordOffset: vec2f=heightScale*viewDir.xy*height;
|
|
68
|
+
#ifdef PARALLAX_RHS
|
|
69
|
+
return texCoordOffset;
|
|
70
|
+
#else
|
|
71
|
+
return -texCoordOffset;
|
|
72
|
+
#endif
|
|
73
|
+
}
|
|
74
|
+
#endif
|
|
75
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[f]||(r.ShaderStore.IncludesShadersStoreWGSL[f]=n),e.s(["bumpFragmentFunctionsWGSL",0,{name:f,shader:n}],78875);let t="bumpFragment",o=`var uvOffset: vec2f= vec2f(0.0,0.0);
|
|
76
|
+
#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)
|
|
77
|
+
#ifdef NORMALXYSCALE
|
|
78
|
+
var normalScale: f32=1.0;
|
|
79
|
+
#elif defined(BUMP)
|
|
80
|
+
var normalScale: f32=uniforms.vBumpInfos.y;
|
|
81
|
+
#else
|
|
82
|
+
var normalScale: f32=1.0;
|
|
83
|
+
#endif
|
|
84
|
+
#if defined(TANGENT) && defined(NORMAL)
|
|
85
|
+
var TBN: mat3x3f=mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2);
|
|
86
|
+
#elif defined(BUMP)
|
|
87
|
+
var TBNUV: vec2f=select(-fragmentInputs.vBumpUV,fragmentInputs.vBumpUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV,uniforms.vTangentSpaceParams);
|
|
88
|
+
#else
|
|
89
|
+
var TBNUV: vec2f=select(-fragmentInputs.vDetailUV,fragmentInputs.vDetailUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV, vec2f(1.,1.));
|
|
90
|
+
#endif
|
|
91
|
+
#elif defined(ANISOTROPIC)
|
|
92
|
+
#if defined(TANGENT) && defined(NORMAL)
|
|
93
|
+
var TBN: mat3x3f=mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2);
|
|
94
|
+
#else
|
|
95
|
+
var TBNUV: vec2f=select( -fragmentInputs.vMainUV1,fragmentInputs.vMainUV1,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW,input.vPositionW,TBNUV, vec2f(1.,1.));
|
|
96
|
+
#endif
|
|
97
|
+
#endif
|
|
98
|
+
#ifdef PARALLAX
|
|
99
|
+
var invTBN: mat3x3f=transposeMat3(TBN);
|
|
100
|
+
#ifdef PARALLAXOCCLUSION
|
|
101
|
+
uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,fragmentInputs.vBumpUV,uniforms.vBumpInfos.z);
|
|
102
|
+
#else
|
|
103
|
+
uvOffset=parallaxOffset(invTBN*viewDirectionW,uniforms.vBumpInfos.z);
|
|
104
|
+
#endif
|
|
105
|
+
#endif
|
|
106
|
+
#ifdef DETAIL
|
|
107
|
+
var detailColor: vec4f=textureSample(detailSampler,detailSamplerSampler,fragmentInputs.vDetailUV+uvOffset);var detailNormalRG: vec2f=detailColor.wy*2.0-1.0;var detailNormalB: f32=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));var detailNormal: vec3f= vec3f(detailNormalRG,detailNormalB);
|
|
108
|
+
#endif
|
|
109
|
+
#ifdef BUMP
|
|
110
|
+
#ifdef OBJECTSPACE_NORMALMAP
|
|
111
|
+
#define CUSTOM_FRAGMENT_BUMP_FRAGMENT
|
|
112
|
+
normalW=normalize(TEXRD(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).xyz *2.0-1.0);normalW=normalize(mat3x3f(uniforms.normalMatrix[0].xyz,uniforms.normalMatrix[1].xyz,uniforms.normalMatrix[2].xyz)*normalW);
|
|
113
|
+
#elif !defined(DETAIL)
|
|
114
|
+
normalW=perturbNormal(TBN,TEXRD(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV+uvOffset).xyz,uniforms.vBumpInfos.y);
|
|
115
|
+
#else
|
|
116
|
+
var bumpNormal: vec3f=TEXRD(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV+uvOffset).xyz*2.0-1.0;
|
|
117
|
+
#if DETAIL_NORMALBLENDMETHOD==0
|
|
118
|
+
detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);var blendedNormal: vec3f=normalize( vec3f(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));
|
|
119
|
+
#elif DETAIL_NORMALBLENDMETHOD==1
|
|
120
|
+
detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);bumpNormal+= vec3f(0.0,0.0,1.0);detailNormal*= vec3f(-1.0,-1.0,1.0);var blendedNormal: vec3f=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;
|
|
121
|
+
#endif
|
|
122
|
+
normalW=perturbNormalBase(TBN,blendedNormal,uniforms.vBumpInfos.y);
|
|
123
|
+
#endif
|
|
124
|
+
#elif defined(DETAIL)
|
|
125
|
+
detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);normalW=perturbNormalBase(TBN,detailNormal,uniforms.vDetailInfos.z);
|
|
126
|
+
#endif
|
|
127
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[t]||(r.ShaderStore.IncludesShadersStoreWGSL[t]=o),e.s(["bumpFragmentWGSL",0,{name:t,shader:o}],23344)},4357,e=>{"use strict";var r=e.i(12423);let a="helperFunctions",i=`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;
|
|
128
|
+
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;}
|
|
129
|
+
fn saturate(x: f32)->f32 {return clamp(x,0.0,1.0);}
|
|
130
|
+
fn saturateVec3(x: vec3f)->vec3f {return clamp(x,vec3f(),vec3f(1.0));}
|
|
131
|
+
fn saturateEps(x: f32)->f32 {return clamp(x,Epsilon,1.0);}
|
|
132
|
+
fn maxEps(x: f32)->f32 {return max(x,Epsilon);}
|
|
133
|
+
fn maxEpsVec3(x: vec3f)->vec3f {return max(x,vec3f(Epsilon));}
|
|
134
|
+
fn absEps(x: f32)->f32 {return abs(x)+Epsilon;}
|
|
135
|
+
fn transposeMat3(inMatrix: mat3x3f)->mat3x3f {let i0: vec3f=inMatrix[0];let i1: vec3f=inMatrix[1];let i2: vec3f=inMatrix[2];let outMatrix:mat3x3f=mat3x3f(
|
|
136
|
+
vec3(i0.x,i1.x,i2.x),
|
|
137
|
+
vec3(i0.y,i1.y,i2.y),
|
|
138
|
+
vec3(i0.z,i1.z,i2.z)
|
|
139
|
+
);return outMatrix;}
|
|
140
|
+
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,
|
|
141
|
+
b11/det,(a22*a00-a02*a20)/det,(-a12*a00+a02*a10)/det,
|
|
142
|
+
b21/det,(-a21*a00+a01*a20)/det,(a11*a00-a01*a10)/det);}
|
|
143
|
+
#if USE_EXACT_SRGB_CONVERSIONS
|
|
144
|
+
fn toLinearSpaceExact(color: vec3f)->vec3f
|
|
145
|
+
{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)));}
|
|
146
|
+
fn toGammaSpaceExact(color: vec3f)->vec3f
|
|
147
|
+
{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)));}
|
|
148
|
+
#endif
|
|
149
|
+
fn toLinearSpace(color: f32)->f32
|
|
150
|
+
{
|
|
151
|
+
#if USE_EXACT_SRGB_CONVERSIONS
|
|
152
|
+
var nearZeroSection=0.0773993808*color;var remainingSection=pow(0.947867299*(color+0.055),2.4);return select(remainingSection,nearZeroSection,color<=0.04045);
|
|
153
|
+
#else
|
|
154
|
+
return pow(color,LinearEncodePowerApprox);
|
|
155
|
+
#endif
|
|
156
|
+
}
|
|
157
|
+
fn toLinearSpaceVec3(color: vec3f)->vec3f
|
|
158
|
+
{
|
|
159
|
+
#if USE_EXACT_SRGB_CONVERSIONS
|
|
160
|
+
return toLinearSpaceExact(color);
|
|
161
|
+
#else
|
|
162
|
+
return pow(color,vec3f(LinearEncodePowerApprox));
|
|
163
|
+
#endif
|
|
164
|
+
}
|
|
165
|
+
fn toLinearSpaceVec4(color: vec4<f32>)->vec4<f32>
|
|
166
|
+
{
|
|
167
|
+
#if USE_EXACT_SRGB_CONVERSIONS
|
|
168
|
+
return vec4f(toLinearSpaceExact(color.rgb),color.a);
|
|
169
|
+
#else
|
|
170
|
+
return vec4f(pow(color.rgb,vec3f(LinearEncodePowerApprox)),color.a);
|
|
171
|
+
#endif
|
|
172
|
+
}
|
|
173
|
+
fn toGammaSpace(color: vec4<f32>)->vec4<f32>
|
|
174
|
+
{
|
|
175
|
+
#if USE_EXACT_SRGB_CONVERSIONS
|
|
176
|
+
return vec4<f32>(toGammaSpaceExact(color.rgb),color.a);
|
|
177
|
+
#else
|
|
178
|
+
return vec4<f32>(pow(color.rgb,vec3f(GammaEncodePowerApprox)),color.a);
|
|
179
|
+
#endif
|
|
180
|
+
}
|
|
181
|
+
fn toGammaSpaceVec3(color: vec3f)->vec3f
|
|
182
|
+
{
|
|
183
|
+
#if USE_EXACT_SRGB_CONVERSIONS
|
|
184
|
+
return toGammaSpaceExact(color);
|
|
185
|
+
#else
|
|
186
|
+
return pow(color,vec3f(GammaEncodePowerApprox));
|
|
187
|
+
#endif
|
|
188
|
+
}
|
|
189
|
+
fn squareVec3(value: vec3f)->vec3f
|
|
190
|
+
{return value*value;}
|
|
191
|
+
fn pow5(value: f32)->f32 {let sq: f32=value*value;return sq*sq*value;}
|
|
192
|
+
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);}
|
|
193
|
+
fn getLuminanceUnclamped(color: vec3f)->f32
|
|
194
|
+
{return dot(color,LuminanceEncodeApprox);}
|
|
195
|
+
fn getLuminance(color: vec3f)->f32
|
|
196
|
+
{return saturate(getLuminanceUnclamped(color));}
|
|
197
|
+
fn getRand(seed: vec2<f32>)->f32 {return fract(sin(dot(seed.xy ,vec2<f32>(12.9898,78.233)))*43758.5453);}
|
|
198
|
+
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;}
|
|
199
|
+
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);}
|
|
200
|
+
fn fromRGBD(rgbd: vec4<f32>)->vec3f {let rgb=toLinearSpaceVec3(rgbd.rgb);return rgb/rgbd.a;}
|
|
201
|
+
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;}
|
|
202
|
+
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;}
|
|
203
|
+
fn sqrtClamped(value: f32)->f32 {return sqrt(max(value,0.));}
|
|
204
|
+
fn avg(value: vec3f)->f32 {return dot(value,vec3f(0.333333333));}
|
|
205
|
+
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);}
|
|
206
|
+
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;}
|
|
207
|
+
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);}
|
|
208
|
+
fn min3(v: vec3f)->f32 {return min(v.x,min(v.y,v.z));}
|
|
209
|
+
fn max3(v: vec3f)->f32 {return max(v.x,max(v.y,v.z));}
|
|
210
|
+
fn uint2float(i: u32)->f32 {return bitcast<f32>(0x3F800000u | (i>>9u))-1.0;}
|
|
211
|
+
fn plasticSequence(rstate: u32)->vec2f {return vec2f(uint2float(rstate*3242174889u),
|
|
212
|
+
uint2float(rstate*2447445414u));}
|
|
213
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[a]||(r.ShaderStore.IncludesShadersStoreWGSL[a]=i),e.s(["helperFunctionsWGSL",0,{name:a,shader:i}])},60106,e=>{"use strict";var r=e.i(12423);let a="sceneUboDeclaration",i=`struct Scene {viewProjection : mat4x4<f32>,
|
|
214
|
+
#ifdef MULTIVIEW
|
|
215
|
+
viewProjectionR : mat4x4<f32>,
|
|
216
|
+
#endif
|
|
217
|
+
view : mat4x4<f32>,
|
|
218
|
+
projection : mat4x4<f32>,
|
|
219
|
+
vEyePosition : vec4<f32>,
|
|
220
|
+
inverseProjection : mat4x4<f32>,};
|
|
221
|
+
#define SCENE_UBO
|
|
222
|
+
var<uniform> scene : Scene;
|
|
223
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[a]||(r.ShaderStore.IncludesShadersStoreWGSL[a]=i),e.s(["sceneUboDeclarationWGSL",0,{name:a,shader:i}])},61202,e=>{"use strict";var r=e.i(12423);let a="pbrBRDFFunctions",i=`#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
|
|
224
|
+
#define BRDF_DIFFUSE_MODEL_EON 0
|
|
225
|
+
#define BRDF_DIFFUSE_MODEL_BURLEY 1
|
|
226
|
+
#define BRDF_DIFFUSE_MODEL_LAMBERT 2
|
|
227
|
+
#define BRDF_DIFFUSE_MODEL_LEGACY 3
|
|
228
|
+
#define DIELECTRIC_SPECULAR_MODEL_GLTF 0
|
|
229
|
+
#define DIELECTRIC_SPECULAR_MODEL_OPENPBR 1
|
|
230
|
+
#define CONDUCTOR_SPECULAR_MODEL_GLTF 0
|
|
231
|
+
#define CONDUCTOR_SPECULAR_MODEL_OPENPBR 1
|
|
232
|
+
#if !defined(PBR_VERTEX_SHADER) && !defined(OPENPBR_VERTEX_SHADER)
|
|
233
|
+
#ifdef MS_BRDF_ENERGY_CONSERVATION
|
|
234
|
+
fn getEnergyConservationFactor(specularEnvironmentR0: vec3f,environmentBrdf: vec3f)->vec3f {return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);}
|
|
235
|
+
#endif
|
|
236
|
+
#if CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR
|
|
237
|
+
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));}
|
|
238
|
+
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;}
|
|
239
|
+
fn getF82DirectionalAlbedo(F0: vec3f,F90: vec3f,b: vec3f,environmentBrdf: vec3f)->vec3f {return (F90-F0)*environmentBrdf.x+F0*environmentBrdf.y-b*environmentBrdf.z;}
|
|
240
|
+
fn getF82AverageFresnel(F0: vec3f,b: vec3f)->vec3f {return F0+(vec3f(1.0)-F0)/21.0-b/126.0;}
|
|
241
|
+
#endif
|
|
242
|
+
#ifdef FUZZENVIRONMENTBRDF
|
|
243
|
+
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;}
|
|
244
|
+
#endif
|
|
245
|
+
#ifdef ENVIRONMENTBRDF
|
|
246
|
+
fn getBRDFLookup(NdotV: f32,perceptualRoughness: f32)->vec3f {var UV: vec2f= vec2f(NdotV,perceptualRoughness);var brdfLookup: vec4f= textureSample(environmentBrdfSampler,environmentBrdfSamplerSampler,UV);
|
|
247
|
+
#ifdef ENVIRONMENTBRDF_RGBD
|
|
248
|
+
brdfLookup=vec4f(fromRGBD(brdfLookup.rgba),brdfLookup.a);
|
|
249
|
+
#endif
|
|
250
|
+
return brdfLookup.rgb;}
|
|
251
|
+
fn getReflectanceFromBRDFWithEnvLookup(specularEnvironmentR0: vec3f,specularEnvironmentR90: vec3f,environmentBrdf: vec3f)->vec3f {
|
|
252
|
+
#ifdef BRDF_V_HEIGHT_CORRELATED
|
|
253
|
+
var reflectance: vec3f=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;
|
|
254
|
+
#else
|
|
255
|
+
var reflectance: vec3f=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;
|
|
256
|
+
#endif
|
|
257
|
+
return reflectance;}
|
|
258
|
+
fn getReflectanceFromBRDFLookup(specularEnvironmentR0: vec3f,environmentBrdf: vec3f)->vec3f {
|
|
259
|
+
#ifdef BRDF_V_HEIGHT_CORRELATED
|
|
260
|
+
var reflectance: vec3f=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);
|
|
261
|
+
#else
|
|
262
|
+
var reflectance: vec3f=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;
|
|
263
|
+
#endif
|
|
264
|
+
return reflectance;}
|
|
265
|
+
#endif
|
|
266
|
+
/* NOT USED
|
|
267
|
+
#if defined(SHEEN) && defined(SHEEN_SOFTER)
|
|
268
|
+
fn getBRDFLookupCharlieSheen(NdotV: f32,perceptualRoughness: f32)->f32
|
|
269
|
+
{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));}
|
|
270
|
+
#endif
|
|
271
|
+
*/
|
|
272
|
+
#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)
|
|
273
|
+
fn getReflectanceFromAnalyticalBRDFLookup_Jones(VdotN: f32,reflectance0: vec3f,reflectance90: vec3f,smoothness: f32)->vec3f
|
|
274
|
+
{var weight: f32=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));}
|
|
275
|
+
#endif
|
|
276
|
+
#if defined(SHEEN) && defined(ENVIRONMENTBRDF)
|
|
277
|
+
/**
|
|
278
|
+
* The sheen BRDF not containing F can be easily stored in the blue channel of the BRDF texture.
|
|
279
|
+
* The blue channel contains DCharlie*VAshikhmin*NdotL as a lokkup table
|
|
280
|
+
*/
|
|
281
|
+
fn getSheenReflectanceFromBRDFLookup(reflectance0: vec3f,environmentBrdf: vec3f)->vec3f {var sheenEnvironmentReflectance: vec3f=reflectance0*environmentBrdf.b;return sheenEnvironmentReflectance;}
|
|
282
|
+
#endif
|
|
283
|
+
fn fresnelSchlickGGXVec3(VdotH: f32,reflectance0: vec3f,reflectance90: vec3f)->vec3f
|
|
284
|
+
{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}
|
|
285
|
+
fn fresnelSchlickGGX(VdotH: f32,reflectance0: f32,reflectance90: f32)->f32
|
|
286
|
+
{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}
|
|
287
|
+
#ifdef CLEARCOAT
|
|
288
|
+
fn getR0RemappedForClearCoat(f0: vec3f)->vec3f {
|
|
289
|
+
#ifdef CLEARCOAT_DEFAULTIOR
|
|
290
|
+
#ifdef MOBILE
|
|
291
|
+
return saturateVec3(f0*(f0*0.526868+0.529324)-0.0482256);
|
|
292
|
+
#else
|
|
293
|
+
return saturateVec3(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);
|
|
294
|
+
#endif
|
|
295
|
+
#else
|
|
296
|
+
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);
|
|
297
|
+
#endif
|
|
298
|
+
}
|
|
299
|
+
#endif
|
|
300
|
+
#ifdef IRIDESCENCE
|
|
301
|
+
const XYZ_TO_REC709: mat3x3f= mat3x3f(
|
|
302
|
+
3.2404542,-0.9692660, 0.0556434,
|
|
303
|
+
-1.5371385, 1.8760108,-0.2040259,
|
|
304
|
+
-0.4985314, 0.0415560, 1.0572252
|
|
305
|
+
);fn getIORTfromAirToSurfaceR0(f0: vec3f)->vec3f {var sqrtF0: vec3f=sqrt(f0);return (1.+sqrtF0)/(1.-sqrtF0);}
|
|
306
|
+
fn getR0fromIORsVec3(iorT: vec3f,iorI: f32)->vec3f {return squareVec3((iorT- vec3f(iorI))/(iorT+ vec3f(iorI)));}
|
|
307
|
+
fn getR0fromIORs(iorT: f32,iorI: f32)->f32 {return square((iorT-iorI)/(iorT+iorI));}
|
|
308
|
+
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;}
|
|
309
|
+
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;}
|
|
310
|
+
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;}
|
|
311
|
+
var phi21: f32=PI-phi12;var baseIOR: vec3f=getIORTfromAirToSurfaceR0(clamp(baseF0,vec3f(0.0),vec3f(0.9999)));
|
|
312
|
+
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));}
|
|
313
|
+
var R23: vec3f=fresnelSchlickGGXVec3(cosTheta2,R1,vec3f(1.));var phi23: vec3f=vec3f(0.0);if (baseIOR[0]<iridescenceIOR) {phi23[0]=PI;}
|
|
314
|
+
if (baseIOR[1]<iridescenceIOR) {phi23[1]=PI;}
|
|
315
|
+
if (baseIOR[2]<iridescenceIOR) {phi23[2]=PI;}
|
|
316
|
+
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++)
|
|
317
|
+
{Cm*=r123;var Sm: vec3f=2.0*evalSensitivity(f32(m)*opd,f32(m)*phi);I+=Cm*Sm;}
|
|
318
|
+
return max(I,vec3f(0.0));}
|
|
319
|
+
#endif
|
|
320
|
+
fn normalDistributionFunction_TrowbridgeReitzGGX(NdotH: f32,alphaG: f32)->f32
|
|
321
|
+
{var a2: f32=alphaG*alphaG;var d: f32=NdotH*NdotH*(a2-1.0)+1.0;return a2/(PI*d*d);}
|
|
322
|
+
#ifdef SHEEN
|
|
323
|
+
fn normalDistributionFunction_CharlieSheen(NdotH: f32,alphaG: f32)->f32
|
|
324
|
+
{var invR: f32=1./alphaG;var cos2h: f32=NdotH*NdotH;var sin2h: f32=1.-cos2h;return (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);}
|
|
325
|
+
#endif
|
|
326
|
+
#ifdef ANISOTROPIC
|
|
327
|
+
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;}
|
|
328
|
+
#endif
|
|
329
|
+
#ifdef BRDF_V_HEIGHT_CORRELATED
|
|
330
|
+
fn smithVisibility_GGXCorrelated(NdotL: f32,NdotV: f32,alphaG: f32)->f32 {
|
|
331
|
+
#ifdef MOBILE
|
|
332
|
+
var GGXV: f32=NdotL*(NdotV*(1.0-alphaG)+alphaG);var GGXL: f32=NdotV*(NdotL*(1.0-alphaG)+alphaG);return 0.5/(GGXV+GGXL);
|
|
333
|
+
#else
|
|
334
|
+
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);
|
|
335
|
+
#endif
|
|
336
|
+
}
|
|
337
|
+
#else
|
|
338
|
+
fn smithVisibilityG1_TrowbridgeReitzGGXFast(dot: f32,alphaG: f32)->f32
|
|
339
|
+
{
|
|
340
|
+
#ifdef MOBILE
|
|
341
|
+
return 1.0/(dot+alphaG+(1.0-alphaG)*dot ));
|
|
342
|
+
#else
|
|
343
|
+
var alphaSquared: f32=alphaG*alphaG;return 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));
|
|
344
|
+
#endif
|
|
345
|
+
}
|
|
346
|
+
fn smithVisibility_TrowbridgeReitzGGXFast(NdotL: f32,NdotV: f32,alphaG: f32)->f32
|
|
347
|
+
{var visibility: f32=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);return visibility;}
|
|
348
|
+
#endif
|
|
349
|
+
#ifdef ANISOTROPIC
|
|
350
|
+
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;}
|
|
351
|
+
#endif
|
|
352
|
+
#ifdef CLEARCOAT
|
|
353
|
+
fn visibility_Kelemen(VdotH: f32)->f32 {return 0.25/(VdotH*VdotH); }
|
|
354
|
+
#endif
|
|
355
|
+
#ifdef SHEEN
|
|
356
|
+
fn visibility_Ashikhmin(NdotL: f32,NdotV: f32)->f32
|
|
357
|
+
{return 1./(4.*(NdotL+NdotV-NdotL*NdotV));}
|
|
358
|
+
/* NOT USED
|
|
359
|
+
#ifdef SHEEN_SOFTER
|
|
360
|
+
fn l(x: f32,alphaG: f32)->f32
|
|
361
|
+
{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;}
|
|
362
|
+
fn lambdaSheen(cosTheta: f32,alphaG: f32)->f32
|
|
363
|
+
{return abs(cosTheta)<0.5 ? exp(l(cosTheta,alphaG)) : exp(2.0*l(0.5,alphaG)-l(1.0-cosTheta,alphaG));}
|
|
364
|
+
fn visibility_CharlieSheen(NdotL: f32,NdotV: f32,alphaG: f32)->f32
|
|
365
|
+
{var G: f32=1.0/(1.0+lambdaSheen(NdotV,alphaG)+lambdaSheen(NdotL,alphaG));return G/(4.0*NdotV*NdotL);}
|
|
366
|
+
#endif
|
|
367
|
+
*/
|
|
368
|
+
#endif
|
|
369
|
+
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
|
|
370
|
+
{var sigma: f32=roughness;
|
|
371
|
+
var mucomp: f32=1.0f-mu;var mucomp2: f32=mucomp*mucomp;const Gcoeffs: mat2x2f=mat2x2f(0.0571085289f,-0.332181442f,
|
|
372
|
+
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);}
|
|
373
|
+
fn diffuseBRDF_EON(albedo: vec3f,roughness: f32,NdotL: f32,NdotV: f32,LdotV: f32)->vec3f
|
|
374
|
+
{var rho: vec3f=albedo;var sigma: f32=roughness;
|
|
375
|
+
var mu_i: f32=NdotL;
|
|
376
|
+
var mu_o: f32=NdotV;
|
|
377
|
+
var s: f32=LdotV-mu_i*mu_o;
|
|
378
|
+
var sovertF: f32=select(s,s/max(mu_i,mu_o),s>0.0f);
|
|
379
|
+
var AF: f32=1.0f/(1.0f+constant1_FON*sigma);
|
|
380
|
+
var f_ss: vec3f=(rho*RECIPROCAL_PI)*AF*(1.0f+sigma*sovertF);
|
|
381
|
+
var EFo: f32=E_FON_approx(mu_o,sigma);
|
|
382
|
+
var EFi: f32=E_FON_approx(mu_i,sigma);
|
|
383
|
+
var avgEF: f32=AF*(1.0f+constant2_FON*sigma);
|
|
384
|
+
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)
|
|
385
|
+
* max(eps,1.0f-EFi)
|
|
386
|
+
/ max(eps,1.0f-avgEF);return (f_ss+f_ms);}
|
|
387
|
+
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 =
|
|
388
|
+
(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *
|
|
389
|
+
(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);return fresnel/PI;}
|
|
390
|
+
#ifdef SS_TRANSLUCENCY
|
|
391
|
+
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);}
|
|
392
|
+
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);}
|
|
393
|
+
#endif
|
|
394
|
+
#endif
|
|
395
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[a]||(r.ShaderStore.IncludesShadersStoreWGSL[a]=i),e.s(["pbrBRDFFunctionsWGSL",0,{name:a,shader:i}])},35182,63406,e=>{"use strict";var r=e.i(12423);let a="clipPlaneFragmentDeclaration",i=`#ifdef CLIPPLANE
|
|
396
|
+
varying fClipDistance: f32;
|
|
397
|
+
#endif
|
|
398
|
+
#ifdef CLIPPLANE2
|
|
399
|
+
varying fClipDistance2: f32;
|
|
400
|
+
#endif
|
|
401
|
+
#ifdef CLIPPLANE3
|
|
402
|
+
varying fClipDistance3: f32;
|
|
403
|
+
#endif
|
|
404
|
+
#ifdef CLIPPLANE4
|
|
405
|
+
varying fClipDistance4: f32;
|
|
406
|
+
#endif
|
|
407
|
+
#ifdef CLIPPLANE5
|
|
408
|
+
varying fClipDistance5: f32;
|
|
409
|
+
#endif
|
|
410
|
+
#ifdef CLIPPLANE6
|
|
411
|
+
varying fClipDistance6: f32;
|
|
412
|
+
#endif
|
|
413
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[a]||(r.ShaderStore.IncludesShadersStoreWGSL[a]=i),e.s(["clipPlaneFragmentDeclarationWGSL",0,{name:a,shader:i}],35182);let f="clipPlaneFragment",n=`#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
|
|
414
|
+
if (false) {}
|
|
415
|
+
#endif
|
|
416
|
+
#ifdef CLIPPLANE
|
|
417
|
+
else if (fragmentInputs.fClipDistance>0.0)
|
|
418
|
+
{discard;}
|
|
419
|
+
#endif
|
|
420
|
+
#ifdef CLIPPLANE2
|
|
421
|
+
else if (fragmentInputs.fClipDistance2>0.0)
|
|
422
|
+
{discard;}
|
|
423
|
+
#endif
|
|
424
|
+
#ifdef CLIPPLANE3
|
|
425
|
+
else if (fragmentInputs.fClipDistance3>0.0)
|
|
426
|
+
{discard;}
|
|
427
|
+
#endif
|
|
428
|
+
#ifdef CLIPPLANE4
|
|
429
|
+
else if (fragmentInputs.fClipDistance4>0.0)
|
|
430
|
+
{discard;}
|
|
431
|
+
#endif
|
|
432
|
+
#ifdef CLIPPLANE5
|
|
433
|
+
else if (fragmentInputs.fClipDistance5>0.0)
|
|
434
|
+
{discard;}
|
|
435
|
+
#endif
|
|
436
|
+
#ifdef CLIPPLANE6
|
|
437
|
+
else if (fragmentInputs.fClipDistance6>0.0)
|
|
438
|
+
{discard;}
|
|
439
|
+
#endif
|
|
440
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[f]||(r.ShaderStore.IncludesShadersStoreWGSL[f]=n),e.s(["clipPlaneFragmentWGSL",0,{name:f,shader:n}],63406)},67367,23356,e=>{"use strict";var r=e.i(12423);let a="samplerFragmentDeclaration",i=`#ifdef _DEFINENAME_
|
|
441
|
+
#if _DEFINENAME_DIRECTUV==1
|
|
442
|
+
#define v_VARYINGNAME_UV vMainUV1
|
|
443
|
+
#elif _DEFINENAME_DIRECTUV==2
|
|
444
|
+
#define v_VARYINGNAME_UV vMainUV2
|
|
445
|
+
#elif _DEFINENAME_DIRECTUV==3
|
|
446
|
+
#define v_VARYINGNAME_UV vMainUV3
|
|
447
|
+
#elif _DEFINENAME_DIRECTUV==4
|
|
448
|
+
#define v_VARYINGNAME_UV vMainUV4
|
|
449
|
+
#elif _DEFINENAME_DIRECTUV==5
|
|
450
|
+
#define v_VARYINGNAME_UV vMainUV5
|
|
451
|
+
#elif _DEFINENAME_DIRECTUV==6
|
|
452
|
+
#define v_VARYINGNAME_UV vMainUV6
|
|
453
|
+
#else
|
|
454
|
+
varying v_VARYINGNAME_UV: vec2f;
|
|
455
|
+
#endif
|
|
456
|
+
var _SAMPLERNAME_SamplerSampler: sampler;var _SAMPLERNAME_Sampler: texture_2d<f32>;
|
|
457
|
+
#endif
|
|
458
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[a]||(r.ShaderStore.IncludesShadersStoreWGSL[a]=i),e.s(["samplerFragmentDeclarationWGSL",0,{name:a,shader:i}],67367);let f="reflectionFunction",n=`fn computeFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f
|
|
459
|
+
{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); }
|
|
460
|
+
fn computeMirroredFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f
|
|
461
|
+
{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); }
|
|
462
|
+
fn computeEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
|
|
463
|
+
{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);}
|
|
464
|
+
fn computeSphericalCoords(worldPos: vec4f,worldNormal: vec3f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f
|
|
465
|
+
{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);}
|
|
466
|
+
fn computePlanarCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
|
|
467
|
+
{var viewDir: vec3f=worldPos.xyz-eyePosition;var coords: vec3f=normalize(reflect(viewDir,worldNormal));return (reflectionMatrix* vec4f(coords,1)).xyz;}
|
|
468
|
+
fn computeCubicCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
|
|
469
|
+
{var viewDir: vec3f=normalize(worldPos.xyz-eyePosition);var coords: vec3f=reflect(viewDir,worldNormal);coords= (reflectionMatrix* vec4f(coords,0)).xyz;
|
|
470
|
+
#ifdef INVERTCUBICMAP
|
|
471
|
+
coords.y*=-1.0;
|
|
472
|
+
#endif
|
|
473
|
+
return coords;}
|
|
474
|
+
fn computeCubicLocalCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f,reflectionSize: vec3f,reflectionPosition: vec3f)->vec3f
|
|
475
|
+
{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;
|
|
476
|
+
#ifdef INVERTCUBICMAP
|
|
477
|
+
coords.y*=-1.0;
|
|
478
|
+
#endif
|
|
479
|
+
return coords;}
|
|
480
|
+
fn computeProjectionCoords(worldPos: vec4f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f
|
|
481
|
+
{return (reflectionMatrix*(view*worldPos)).xyz;}
|
|
482
|
+
fn computeSkyBoxCoords(positionW: vec3f,reflectionMatrix: mat4x4f)->vec3f
|
|
483
|
+
{return (reflectionMatrix* vec4f(positionW,1.)).xyz;}
|
|
484
|
+
#ifdef REFLECTION
|
|
485
|
+
fn computeReflectionCoords(worldPos: vec4f,worldNormal: vec3f)->vec3f
|
|
486
|
+
{
|
|
487
|
+
#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
|
|
488
|
+
var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);
|
|
489
|
+
#endif
|
|
490
|
+
#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
|
|
491
|
+
var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeFixedEquirectangularCoords(worldPos,worldNormal,direction);
|
|
492
|
+
#endif
|
|
493
|
+
#ifdef REFLECTIONMAP_EQUIRECTANGULAR
|
|
494
|
+
return computeEquirectangularCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
|
|
495
|
+
#endif
|
|
496
|
+
#ifdef REFLECTIONMAP_SPHERICAL
|
|
497
|
+
return computeSphericalCoords(worldPos,worldNormal,scene.view,uniforms.reflectionMatrix);
|
|
498
|
+
#endif
|
|
499
|
+
#ifdef REFLECTIONMAP_PLANAR
|
|
500
|
+
return computePlanarCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
|
|
501
|
+
#endif
|
|
502
|
+
#ifdef REFLECTIONMAP_CUBIC
|
|
503
|
+
#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
|
|
504
|
+
return computeCubicLocalCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix,uniforms.vReflectionSize,uniforms.vReflectionPosition);
|
|
505
|
+
#else
|
|
506
|
+
return computeCubicCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
|
|
507
|
+
#endif
|
|
508
|
+
#endif
|
|
509
|
+
#ifdef REFLECTIONMAP_PROJECTION
|
|
510
|
+
return computeProjectionCoords(worldPos,scene.view,uniforms.reflectionMatrix);
|
|
511
|
+
#endif
|
|
512
|
+
#ifndef REFLECTIONMAP_CUBIC
|
|
513
|
+
#ifdef REFLECTIONMAP_SKYBOX
|
|
514
|
+
return computeSkyBoxCoords(fragmentInputs.vPositionUVW,uniforms.reflectionMatrix);
|
|
515
|
+
#endif
|
|
516
|
+
#endif
|
|
517
|
+
#ifdef REFLECTIONMAP_EXPLICIT
|
|
518
|
+
return vec3f(0,0,0);
|
|
519
|
+
#endif
|
|
520
|
+
}
|
|
521
|
+
#endif
|
|
522
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[f]||(r.ShaderStore.IncludesShadersStoreWGSL[f]=n),e.s(["reflectionFunctionWGSL",0,{name:f,shader:n}],23356)},90780,82518,e=>{"use strict";var r=e.i(12423);let a="pbrFragmentReflectionDeclaration",i=`#ifdef REFLECTION
|
|
523
|
+
#ifdef REFLECTIONMAP_3D
|
|
524
|
+
var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube<f32>;
|
|
525
|
+
#ifdef LODBASEDMICROSFURACE
|
|
526
|
+
#else
|
|
527
|
+
var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_cube<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_cube<f32>;
|
|
528
|
+
#endif
|
|
529
|
+
#ifdef USEIRRADIANCEMAP
|
|
530
|
+
var irradianceSamplerSampler: sampler;var irradianceSampler: texture_cube<f32>;
|
|
531
|
+
#endif
|
|
532
|
+
#else
|
|
533
|
+
var reflectionSamplerSampler: sampler;var reflectionSampler: texture_2d<f32>;
|
|
534
|
+
#ifdef LODBASEDMICROSFURACE
|
|
535
|
+
#else
|
|
536
|
+
var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_2d<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_2d<f32>;
|
|
537
|
+
#endif
|
|
538
|
+
#ifdef USEIRRADIANCEMAP
|
|
539
|
+
var irradianceSamplerSampler: sampler;var irradianceSampler: texture_2d<f32>;
|
|
540
|
+
#endif
|
|
541
|
+
#endif
|
|
542
|
+
#ifdef REFLECTIONMAP_SKYBOX
|
|
543
|
+
varying vPositionUVW: vec3f;
|
|
544
|
+
#else
|
|
545
|
+
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
|
546
|
+
varying vDirectionW: vec3f;
|
|
547
|
+
#endif
|
|
548
|
+
#endif
|
|
549
|
+
#endif
|
|
550
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[a]||(r.ShaderStore.IncludesShadersStoreWGSL[a]=i),e.s(["pbrFragmentReflectionDeclarationWGSL",0,{name:a,shader:i}],90780);let f="pbrIBLFunctions",n=`#if defined(REFLECTION) || defined(SS_REFRACTION)
|
|
551
|
+
fn getLodFromAlphaG(cubeMapDimensionPixels: f32,microsurfaceAverageSlope: f32)->f32 {var microsurfaceAverageSlopeTexels: f32=cubeMapDimensionPixels*microsurfaceAverageSlope;var lod: f32=log2(microsurfaceAverageSlopeTexels);return lod;}
|
|
552
|
+
fn getLinearLodFromRoughness(cubeMapDimensionPixels: f32,roughness: f32)->f32 {var lod: f32=log2(cubeMapDimensionPixels)*roughness;return lod;}
|
|
553
|
+
#endif
|
|
554
|
+
#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)
|
|
555
|
+
fn environmentRadianceOcclusion(ambientOcclusion: f32,NdotVUnclamped: f32)->f32 {var temp: f32=NdotVUnclamped+ambientOcclusion;return saturate(temp*temp-1.0+ambientOcclusion);}
|
|
556
|
+
#endif
|
|
557
|
+
#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)
|
|
558
|
+
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;}
|
|
559
|
+
#endif
|
|
560
|
+
#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)
|
|
561
|
+
fn UNPACK_LOD(x: f32)->f32 {return (1.0-x)*255.0;}
|
|
562
|
+
fn getLodFromAlphaGNdotV(cubeMapDimensionPixels: f32,alphaG: f32,NdotV: f32)->f32 {var microsurfaceAverageSlope: f32=alphaG;microsurfaceAverageSlope*=sqrt(abs(NdotV));return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);}
|
|
563
|
+
#endif
|
|
564
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[f]||(r.ShaderStore.IncludesShadersStoreWGSL[f]=n),e.s(["pbrIBLFunctionsWGSL",0,{name:f,shader:n}],82518)},30420,22389,63189,e=>{"use strict";var r=e.i(12423);let a="openpbrDielectricReflectance",i=`struct ReflectanceParams
|
|
565
|
+
{F0: f32,
|
|
566
|
+
F90: f32,
|
|
567
|
+
coloredF0: vec3f,
|
|
568
|
+
coloredF90: vec3f,};
|
|
569
|
+
#define pbr_inline
|
|
570
|
+
fn dielectricReflectance(
|
|
571
|
+
insideIOR: f32,outsideIOR: f32,specularColor: vec3f,specularWeight: f32
|
|
572
|
+
)->ReflectanceParams
|
|
573
|
+
{var outParams: ReflectanceParams;let dielectricF0=pow((insideIOR-outsideIOR)/(insideIOR+outsideIOR),2.0);
|
|
574
|
+
#if DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_GLTF
|
|
575
|
+
let maxF0=max(specularColor.r,max(specularColor.g,specularColor.b));outParams.F0=dielectricF0*maxF0*specularWeight;
|
|
576
|
+
#else
|
|
577
|
+
outParams.F0=dielectricF0*specularWeight;
|
|
578
|
+
#endif
|
|
579
|
+
let f90Scale=clamp(2.0f*abs(insideIOR-outsideIOR),0.0f,1.0f);outParams.F90=f90Scale*specularWeight;outParams.coloredF0=vec3f(dielectricF0*specularWeight)*specularColor.rgb;
|
|
580
|
+
#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR)
|
|
581
|
+
let dielectricColorF90: vec3f=specularColor.rgb*vec3f(f90Scale)*specularWeight;
|
|
582
|
+
#else
|
|
583
|
+
let dielectricColorF90: vec3f=vec3f(f90Scale)*specularWeight;
|
|
584
|
+
#endif
|
|
585
|
+
outParams.coloredF90=dielectricColorF90;return outParams;}
|
|
586
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[a]||(r.ShaderStore.IncludesShadersStoreWGSL[a]=i),e.s(["openpbrDielectricReflectanceWGSL",0,{name:a,shader:i}],30420);let f="openpbrGeometryInfo",n=`struct geometryInfoOutParams
|
|
587
|
+
{NdotV: f32,
|
|
588
|
+
NdotVUnclamped: f32,
|
|
589
|
+
environmentBrdf: vec3f,
|
|
590
|
+
horizonOcclusion: f32};struct geometryInfoAnisoOutParams
|
|
591
|
+
{NdotV: f32,
|
|
592
|
+
NdotVUnclamped: f32,
|
|
593
|
+
environmentBrdf: vec3f,
|
|
594
|
+
horizonOcclusion: f32,
|
|
595
|
+
anisotropy: f32,
|
|
596
|
+
anisotropicTangent: vec3f,
|
|
597
|
+
anisotropicBitangent: vec3f,
|
|
598
|
+
TBN: mat3x3<f32>};fn geometryInfo(
|
|
599
|
+
normalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f
|
|
600
|
+
)->geometryInfoOutParams
|
|
601
|
+
{var outParams: geometryInfoOutParams;outParams.NdotVUnclamped=dot(normalW,viewDirectionW);outParams.NdotV=absEps(outParams.NdotVUnclamped);
|
|
602
|
+
#if defined(ENVIRONMENTBRDF)
|
|
603
|
+
outParams.environmentBrdf=getBRDFLookup(outParams.NdotV,roughness);
|
|
604
|
+
#else
|
|
605
|
+
outParams.environmentBrdf=vec3f(0.0);
|
|
606
|
+
#endif
|
|
607
|
+
outParams.horizonOcclusion=1.0f;
|
|
608
|
+
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
|
609
|
+
#ifdef HORIZONOCCLUSION
|
|
610
|
+
#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL)
|
|
611
|
+
#ifdef REFLECTIONMAP_3D
|
|
612
|
+
outParams.horizonOcclusion=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
|
|
613
|
+
#endif
|
|
614
|
+
#endif
|
|
615
|
+
#endif
|
|
616
|
+
#endif
|
|
617
|
+
return outParams;}
|
|
618
|
+
fn geometryInfoAniso(
|
|
619
|
+
normalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f
|
|
620
|
+
,vAnisotropy: vec3f,TBN: mat3x3<f32>
|
|
621
|
+
)->geometryInfoAnisoOutParams
|
|
622
|
+
{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;}
|
|
623
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[f]||(r.ShaderStore.IncludesShadersStoreWGSL[f]=n),e.s(["openpbrGeometryInfoWGSL",0,{name:f,shader:n}],22389);let t="openpbrIblFunctions",o=`#ifdef REFLECTION
|
|
624
|
+
fn sampleIrradiance(
|
|
625
|
+
surfaceNormal: vec3f
|
|
626
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
627
|
+
,vEnvironmentIrradianceSH: vec3f
|
|
628
|
+
#endif
|
|
629
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
630
|
+
,iblMatrix: mat4x4f
|
|
631
|
+
#endif
|
|
632
|
+
#ifdef USEIRRADIANCEMAP
|
|
633
|
+
#ifdef REFLECTIONMAP_3D
|
|
634
|
+
,irradianceSampler: texture_cube<f32>
|
|
635
|
+
,irradianceSamplerSampler: sampler
|
|
636
|
+
#else
|
|
637
|
+
,irradianceSampler: texture_2d<f32>
|
|
638
|
+
,irradianceSamplerSampler: sampler
|
|
639
|
+
#endif
|
|
640
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
641
|
+
,reflectionDominantDirection: vec3f
|
|
642
|
+
#endif
|
|
643
|
+
#endif
|
|
644
|
+
#ifdef REALTIME_FILTERING
|
|
645
|
+
,reflectionFilteringInfo: vec2f
|
|
646
|
+
#ifdef IBL_CDF_FILTERING
|
|
647
|
+
,icdfSampler: texture_2d<f32>
|
|
648
|
+
,icdfSamplerSampler: sampler
|
|
649
|
+
#endif
|
|
650
|
+
#endif
|
|
651
|
+
,reflectionInfos: vec2f
|
|
652
|
+
,viewDirectionW: vec3f
|
|
653
|
+
,diffuseRoughness: f32
|
|
654
|
+
,surfaceAlbedo: vec3f
|
|
655
|
+
)->vec3f {var environmentIrradiance=vec3f(0.,0.,0.);
|
|
656
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
657
|
+
var irradianceVector=(iblMatrix*vec4f(surfaceNormal,0.0f)).xyz;var irradianceView=(iblMatrix*vec4f(viewDirectionW,0.0f)).xyz;
|
|
658
|
+
#if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING)
|
|
659
|
+
#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY
|
|
660
|
+
{let NdotV=max(dot(surfaceNormal,viewDirectionW),0.0f);irradianceVector=mix(irradianceVector,irradianceView,(0.5f*(1.0f-NdotV))*diffuseRoughness);}
|
|
661
|
+
#endif
|
|
662
|
+
#endif
|
|
663
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
664
|
+
irradianceVector.z*=-1.0;irradianceView.z*=-1.0;
|
|
665
|
+
#endif
|
|
666
|
+
#ifdef INVERTCUBICMAP
|
|
667
|
+
irradianceVector.y*=-1.0;irradianceView.y*=-1.0;
|
|
668
|
+
#endif
|
|
669
|
+
#endif
|
|
670
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
671
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
672
|
+
environmentIrradiance=vEnvironmentIrradianceSH;
|
|
673
|
+
#else
|
|
674
|
+
#if defined(REALTIME_FILTERING)
|
|
675
|
+
environmentIrradiance=irradiance(reflectionSampler,reflectionSamplerSampler,irradianceVector,reflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView
|
|
676
|
+
#ifdef IBL_CDF_FILTERING
|
|
677
|
+
,icdfSampler
|
|
678
|
+
,icdfSamplerSampler
|
|
679
|
+
#endif
|
|
680
|
+
);
|
|
681
|
+
#else
|
|
682
|
+
environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
|
|
683
|
+
#endif
|
|
684
|
+
#endif
|
|
685
|
+
#elif defined(USEIRRADIANCEMAP)
|
|
686
|
+
#ifdef REFLECTIONMAP_3D
|
|
687
|
+
let environmentIrradianceFromTexture: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,irradianceVector);
|
|
688
|
+
#else
|
|
689
|
+
let environmentIrradianceFromTexture: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,reflectionCoords);
|
|
690
|
+
#endif
|
|
691
|
+
environmentIrradiance=environmentIrradianceFromTexture.rgb;
|
|
692
|
+
#ifdef RGBDREFLECTION
|
|
693
|
+
environmentIrradiance.rgb=fromRGBD(environmentIrradianceFromTexture);
|
|
694
|
+
#endif
|
|
695
|
+
#ifdef GAMMAREFLECTION
|
|
696
|
+
environmentIrradiance.rgb=toLinearSpaceVec3(environmentIrradiance.rgb);
|
|
697
|
+
#endif
|
|
698
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
699
|
+
let Ls: vec3f=normalize(reflectionDominantDirection);let NoL: f32=dot(irradianceVector,Ls);let NoV: f32=dot(irradianceVector,irradianceView);var diffuseRoughnessTerm=vec3f(1.0f);
|
|
700
|
+
#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
|
|
701
|
+
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)));
|
|
702
|
+
#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
|
|
703
|
+
let H: vec3f=(irradianceView+Ls)*0.5f;let VoH: f32=dot(irradianceView,H);diffuseRoughnessTerm=vec3f(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);
|
|
704
|
+
#endif
|
|
705
|
+
environmentIrradiance=environmentIrradiance.rgb*diffuseRoughnessTerm;
|
|
706
|
+
#endif
|
|
707
|
+
#endif
|
|
708
|
+
environmentIrradiance*=reflectionInfos.x;return environmentIrradiance;}
|
|
709
|
+
#ifdef REFLECTIONMAP_3D
|
|
710
|
+
fn createReflectionCoords(vPositionW: vec3f,normalW: vec3f)->vec3f
|
|
711
|
+
#else
|
|
712
|
+
fn createReflectionCoords(vPositionW: vec3f,normalW: vec3f)->vec2f
|
|
713
|
+
#endif
|
|
714
|
+
{var reflectionVector: vec3f=computeReflectionCoords(vec4f(vPositionW,1.0f),normalW);
|
|
715
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
716
|
+
reflectionVector.z*=-1.0;
|
|
717
|
+
#endif
|
|
718
|
+
#ifdef REFLECTIONMAP_3D
|
|
719
|
+
var reflectionCoords: vec3f=reflectionVector;
|
|
720
|
+
#else
|
|
721
|
+
var reflectionCoords: vec2f=reflectionVector.xy;
|
|
722
|
+
#ifdef REFLECTIONMAP_PROJECTION
|
|
723
|
+
reflectionCoords/=reflectionVector.z;
|
|
724
|
+
#endif
|
|
725
|
+
reflectionCoords.y=1.0f-reflectionCoords.y;
|
|
726
|
+
#endif
|
|
727
|
+
return reflectionCoords;}
|
|
728
|
+
fn sampleRadiance(
|
|
729
|
+
alphaG: f32
|
|
730
|
+
,reflectionMicrosurfaceInfos: vec3f
|
|
731
|
+
,reflectionInfos: vec2f
|
|
732
|
+
,geoInfo: geometryInfoOutParams
|
|
733
|
+
#ifdef REFLECTIONMAP_3D
|
|
734
|
+
,reflectionSampler: texture_cube<f32>
|
|
735
|
+
,reflectionSamplerSampler: sampler
|
|
736
|
+
,reflectionCoords: vec3f
|
|
737
|
+
#else
|
|
738
|
+
,reflectionSampler: texture_2d<f32>
|
|
739
|
+
,reflectionSamplerSampler: sampler
|
|
740
|
+
,reflectionCoords: vec2f
|
|
741
|
+
#endif
|
|
742
|
+
#ifdef REALTIME_FILTERING
|
|
743
|
+
,reflectionFilteringInfo: vec2f
|
|
744
|
+
#endif
|
|
745
|
+
)->vec3f {var environmentRadiance: vec4f=vec4f(0.f,0.f,0.f,0.f);
|
|
746
|
+
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
|
747
|
+
var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,alphaG,geoInfo.NdotVUnclamped);
|
|
748
|
+
#elif defined(LINEARSPECULARREFLECTION)
|
|
749
|
+
var reflectionLOD: f32=getLinearLodFromRoughness(reflectionMicrosurfaceInfos.x,roughness);
|
|
750
|
+
#else
|
|
751
|
+
var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,alphaG);
|
|
752
|
+
#endif
|
|
753
|
+
reflectionLOD=reflectionLOD*reflectionMicrosurfaceInfos.y+reflectionMicrosurfaceInfos.z;
|
|
754
|
+
#ifdef REALTIME_FILTERING
|
|
755
|
+
environmentRadiance=vec4f(radiance(alphaG,reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionFilteringInfo),1.0f);
|
|
756
|
+
#else
|
|
757
|
+
environmentRadiance=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD);
|
|
758
|
+
#endif
|
|
759
|
+
#ifdef RGBDREFLECTION
|
|
760
|
+
environmentRadiance.rgb=fromRGBD(environmentRadiance);
|
|
761
|
+
#endif
|
|
762
|
+
#ifdef GAMMAREFLECTION
|
|
763
|
+
environmentRadiance.rgb=toLinearSpaceVec3(environmentRadiance.rgb);
|
|
764
|
+
#endif
|
|
765
|
+
environmentRadiance=vec4f(environmentRadiance.rgb*reflectionInfos.x,environmentRadiance.a);return environmentRadiance.rgb;}
|
|
766
|
+
#if defined(ANISOTROPIC)
|
|
767
|
+
fn sampleRadianceAnisotropic(
|
|
768
|
+
alphaG: f32
|
|
769
|
+
,reflectionMicrosurfaceInfos: vec3f
|
|
770
|
+
,reflectionInfos: vec2f
|
|
771
|
+
,geoInfo: geometryInfoAnisoOutParams
|
|
772
|
+
,normalW: vec3f
|
|
773
|
+
,viewDirectionW: vec3f
|
|
774
|
+
,positionW: vec3f
|
|
775
|
+
,noise: vec3f
|
|
776
|
+
,isRefraction: bool
|
|
777
|
+
,ior: f32
|
|
778
|
+
#ifdef REFLECTIONMAP_3D
|
|
779
|
+
,reflectionSampler: texture_cube<f32>
|
|
780
|
+
,reflectionSamplerSampler: sampler
|
|
781
|
+
#else
|
|
782
|
+
,reflectionSampler: texture_2d<f32>
|
|
783
|
+
,reflectionSamplerSampler: sampler
|
|
784
|
+
#endif
|
|
785
|
+
#ifdef REALTIME_FILTERING
|
|
786
|
+
,reflectionFilteringInfo: vec2f
|
|
787
|
+
#endif
|
|
788
|
+
)->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;
|
|
789
|
+
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
|
790
|
+
var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,modifiedAlphaG,geoInfo.NdotVUnclamped);
|
|
791
|
+
#elif defined(LINEARSPECULARREFLECTION)
|
|
792
|
+
var reflectionLOD: f32=getLinearLodFromRoughness(reflectionMicrosurfaceInfos.x,roughness);
|
|
793
|
+
#else
|
|
794
|
+
var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,modifiedAlphaG);
|
|
795
|
+
#endif
|
|
796
|
+
reflectionLOD=reflectionLOD*reflectionMicrosurfaceInfos.y+reflectionMicrosurfaceInfos.z;
|
|
797
|
+
#ifdef REALTIME_FILTERING
|
|
798
|
+
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;
|
|
799
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
800
|
+
view.z*=-1.0f;tangent.z*=-1.0f;bitangent.z*=-1.0f;normal.z*=-1.0f;
|
|
801
|
+
#endif
|
|
802
|
+
environmentRadiance =
|
|
803
|
+
vec4f(radianceAnisotropic(alphaT,alphaB,reflectionSampler,reflectionSamplerSampler,
|
|
804
|
+
view,tangent,
|
|
805
|
+
bitangent,normal,
|
|
806
|
+
reflectionFilteringInfo,noise.xy,isRefraction,ior),
|
|
807
|
+
1.0f);
|
|
808
|
+
#else
|
|
809
|
+
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;}
|
|
810
|
+
if (isRefraction) {reflectionCoords=double_refract(-viewDirectionW,bentNormal,ior);} else {reflectionCoords=reflect(-viewDirectionW,bentNormal);}
|
|
811
|
+
reflectionCoords=(uniforms.reflectionMatrix*vec4f(reflectionCoords,0.f)).xyz;
|
|
812
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
813
|
+
reflectionCoords.z*=-1.0f;
|
|
814
|
+
#endif
|
|
815
|
+
radianceSample=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD);
|
|
816
|
+
#ifdef RGBDREFLECTION
|
|
817
|
+
accumulatedRadiance+=vec3f(sample_weight)*fromRGBD(radianceSample);
|
|
818
|
+
#elif defined(GAMMAREFLECTION)
|
|
819
|
+
accumulatedRadiance+=vec3f(sample_weight)*toLinearSpaceVec3(radianceSample.rgb);
|
|
820
|
+
#else
|
|
821
|
+
accumulatedRadiance+=vec3f(sample_weight)*radianceSample.rgb;
|
|
822
|
+
#endif
|
|
823
|
+
total_weight+=sample_weight;}
|
|
824
|
+
environmentRadiance=vec4f(accumulatedRadiance/vec3f(total_weight),1.0f);
|
|
825
|
+
#endif
|
|
826
|
+
environmentRadiance=vec4f(environmentRadiance.rgb*reflectionInfos.xxx,environmentRadiance.a);return environmentRadiance.rgb;}
|
|
827
|
+
#endif
|
|
828
|
+
#endif
|
|
829
|
+
#ifdef ENVIRONMENTBRDF
|
|
830
|
+
fn computeDielectricIblFresnel(reflectance: ReflectanceParams,environmentBrdf: vec3f)->f32
|
|
831
|
+
{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);}
|
|
832
|
+
fn computeConductorIblFresnel(reflectance: ReflectanceParams,environmentBrdf: vec3f)->vec3f
|
|
833
|
+
{
|
|
834
|
+
#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
|
|
835
|
+
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));
|
|
836
|
+
#else
|
|
837
|
+
return getReflectanceFromBRDFLookup(reflectance.coloredF0,reflectance.coloredF90,environmentBrdf);
|
|
838
|
+
#endif
|
|
839
|
+
}
|
|
840
|
+
#endif
|
|
841
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[t]||(r.ShaderStore.IncludesShadersStoreWGSL[t]=o),e.s(["openpbrIblFunctionsWGSL",0,{name:t,shader:o}],63189)},80899,e=>{"use strict";var r=e.i(12423);let a="openpbrSubsurfaceLayerData",i=`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);
|
|
842
|
+
#ifdef SUBSURFACE_WEIGHT
|
|
843
|
+
let subsurfaceWeightFromTexture: vec4f=TEXRD(subsurfaceWeightSampler,subsurfaceWeightSamplerSampler,fragmentInputs.vSubsurfaceWeightUV+uvOffset);
|
|
844
|
+
#endif
|
|
845
|
+
#ifdef SUBSURFACE_COLOR
|
|
846
|
+
let subsurfaceColorFromTexture: vec4f=TEXRD(subsurfaceColorSampler,subsurfaceColorSamplerSampler,fragmentInputs.vSubsurfaceColorUV+uvOffset);
|
|
847
|
+
#endif
|
|
848
|
+
#ifdef SUBSURFACE_RADIUS_SCALE
|
|
849
|
+
let subsurfaceRadiusScaleFromTexture: vec4f=TEXRD(subsurfaceRadiusScaleSampler,subsurfaceRadiusScaleSamplerSampler,fragmentInputs.vSubsurfaceRadiusScaleUV+uvOffset);
|
|
850
|
+
#endif
|
|
851
|
+
#ifdef SUBSURFACE_WEIGHT
|
|
852
|
+
#ifdef SUBSURFACE_WEIGHT_FROM_TEXTURE_ALPHA
|
|
853
|
+
subsurface_weight*=subsurfaceWeightFromTexture.a;
|
|
854
|
+
#else
|
|
855
|
+
subsurface_weight*=subsurfaceWeightFromTexture.r;
|
|
856
|
+
#endif
|
|
857
|
+
#endif
|
|
858
|
+
#ifdef SUBSURFACE_COLOR
|
|
859
|
+
#ifdef SUBSURFACE_COLOR_GAMMA
|
|
860
|
+
subsurface_color*=toLinearSpaceVec3(subsurfaceColorFromTexture.rgb);
|
|
861
|
+
#else
|
|
862
|
+
subsurface_color*=subsurfaceColorFromTexture.rgb;
|
|
863
|
+
#endif
|
|
864
|
+
subsurface_color*=uniforms.vSubsurfaceColorInfos.y;
|
|
865
|
+
#endif
|
|
866
|
+
#ifdef SUBSURFACE_RADIUS_SCALE
|
|
867
|
+
subsurface_radius_scale*=subsurfaceRadiusScaleFromTexture.rgb;
|
|
868
|
+
#endif
|
|
869
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[a]||(r.ShaderStore.IncludesShadersStoreWGSL[a]=i),e.s(["openpbrSubsurfaceLayerDataWGSL",0,{name:a,shader:i}])},4558,e=>{"use strict";var r=e.i(12423);let a="openpbrTransmissionLayerData",i=`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;
|
|
870
|
+
#ifdef TRANSMISSION_WEIGHT
|
|
871
|
+
let transmissionWeightFromTexture: vec4f=TEXRD(transmissionWeightSampler,transmissionWeightSamplerSampler,fragmentInputs.vTransmissionWeightUV+uvOffset);
|
|
872
|
+
#endif
|
|
873
|
+
#ifdef TRANSMISSION_COLOR
|
|
874
|
+
let transmissionColorFromTexture: vec4f=TEXRD(transmissionColorSampler,transmissionColorSamplerSampler,fragmentInputs.vTransmissionColorUV+uvOffset);
|
|
875
|
+
#endif
|
|
876
|
+
#ifdef TRANSMISSION_DEPTH
|
|
877
|
+
let transmissionDepthFromTexture: vec4f=TEXRD(transmissionDepthSampler,transmissionDepthSamplerSampler,fragmentInputs.vTransmissionDepthUV+uvOffset);
|
|
878
|
+
#endif
|
|
879
|
+
#ifdef TRANSMISSION_SCATTER
|
|
880
|
+
let transmissionScatterFromTexture: vec4f=TEXRD(transmissionScatterSampler,transmissionScatterSamplerSampler,fragmentInputs.vTransmissionScatterUV+uvOffset);
|
|
881
|
+
#endif
|
|
882
|
+
#ifdef TRANSMISSION_DISPERSION_SCALE
|
|
883
|
+
let transmissionDispersionScaleFromTexture: vec4f=TEXRD(transmissionDispersionScaleSampler,transmissionDispersionScaleSamplerSampler,fragmentInputs.vTransmissionDispersionScaleUV+uvOffset);
|
|
884
|
+
#endif
|
|
885
|
+
#ifdef TRANSMISSION_WEIGHT
|
|
886
|
+
transmission_weight*=transmissionWeightFromTexture.r;
|
|
887
|
+
#endif
|
|
888
|
+
#ifdef TRANSMISSION_COLOR
|
|
889
|
+
#ifdef TRANSMISSION_COLOR_GAMMA
|
|
890
|
+
transmission_color*=toLinearSpaceVec3(transmissionColorFromTexture.rgb);
|
|
891
|
+
#else
|
|
892
|
+
transmission_color*=transmissionColorFromTexture.rgb;
|
|
893
|
+
#endif
|
|
894
|
+
transmission_color*=uniforms.vTransmissionColorInfos.y;
|
|
895
|
+
#endif
|
|
896
|
+
#ifdef TRANSMISSION_DEPTH
|
|
897
|
+
transmission_depth*=transmissionDepthFromTexture.r;
|
|
898
|
+
#endif
|
|
899
|
+
#ifdef TRANSMISSION_SCATTER
|
|
900
|
+
transmission_scatter*=transmissionScatterFromTexture.rgb;
|
|
901
|
+
#endif
|
|
902
|
+
#ifdef TRANSMISSION_DISPERSION_SCALE
|
|
903
|
+
transmission_dispersion_scale*=transmissionDispersionScaleFromTexture.r;
|
|
904
|
+
#endif
|
|
905
|
+
`;r.ShaderStore.IncludesShadersStoreWGSL[a]||(r.ShaderStore.IncludesShadersStoreWGSL[a]=i),e.s(["openpbrTransmissionLayerDataWGSL",0,{name:a,shader:i}])},89511,e=>{"use strict";var r=e.i(12423),a=e.i(35182),i=e.i(28657),f=e.i(67367),n=e.i(78875),t=e.i(4357),o=e.i(90780),c=e.i(60106),s=e.i(61202),l=e.i(30420),d=e.i(82518),v=e.i(23356),m=e.i(22389),u=e.i(63189),p=e.i(63406),S=e.i(23344),E=e.i(80899),R=e.i(4558);let I="geometryPixelShader",N=`#ifdef BUMP
|
|
906
|
+
varying vWorldView0: vec4f;varying vWorldView1: vec4f;varying vWorldView2: vec4f;varying vWorldView3: vec4f;varying vNormalW: vec3f;
|
|
907
|
+
#else
|
|
908
|
+
varying vNormalV: vec3f;
|
|
909
|
+
#endif
|
|
910
|
+
varying vViewPos: vec4f;
|
|
911
|
+
#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE)
|
|
912
|
+
varying vPositionW: vec3f;
|
|
913
|
+
#endif
|
|
914
|
+
#if defined(VELOCITY) || defined(VELOCITY_LINEAR)
|
|
915
|
+
varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f;
|
|
916
|
+
#endif
|
|
917
|
+
#ifdef NEED_UV
|
|
918
|
+
varying vUV: vec2f;
|
|
919
|
+
#endif
|
|
920
|
+
#ifdef BUMP
|
|
921
|
+
uniform vBumpInfos: vec3f;uniform vTangentSpaceParams: vec2f;
|
|
922
|
+
#endif
|
|
923
|
+
#if defined(REFLECTIVITY)
|
|
924
|
+
#if defined(ORMTEXTURE) || defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)
|
|
925
|
+
var reflectivitySamplerSampler: sampler;var reflectivitySampler: texture_2d<f32>;varying vReflectivityUV: vec2f;
|
|
926
|
+
#else
|
|
927
|
+
#ifdef METALLIC_TEXTURE
|
|
928
|
+
var metallicSamplerSampler: sampler;var metallicSampler: texture_2d<f32>;varying vMetallicUV: vec2f;
|
|
929
|
+
#endif
|
|
930
|
+
#ifdef ROUGHNESS_TEXTURE
|
|
931
|
+
var roughnessSamplerSampler: sampler;var roughnessSampler: texture_2d<f32>;varying vRoughnessUV: vec2f;
|
|
932
|
+
#endif
|
|
933
|
+
#endif
|
|
934
|
+
#ifdef ALBEDOTEXTURE
|
|
935
|
+
varying vAlbedoUV: vec2f;var albedoSamplerSampler: sampler;var albedoSampler: texture_2d<f32>;
|
|
936
|
+
#endif
|
|
937
|
+
#ifdef REFLECTIVITYCOLOR
|
|
938
|
+
uniform reflectivityColor: vec3f;
|
|
939
|
+
#endif
|
|
940
|
+
#ifdef ALBEDOCOLOR
|
|
941
|
+
uniform albedoColor: vec3f;
|
|
942
|
+
#endif
|
|
943
|
+
#ifdef METALLIC
|
|
944
|
+
uniform metallic: f32;
|
|
945
|
+
#endif
|
|
946
|
+
#if defined(ROUGHNESS) || defined(GLOSSINESS)
|
|
947
|
+
uniform glossiness: f32;
|
|
948
|
+
#endif
|
|
949
|
+
#endif
|
|
950
|
+
#if defined(ALPHATEST) && defined(NEED_UV)
|
|
951
|
+
var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d<f32>;
|
|
952
|
+
#endif
|
|
953
|
+
#include<clipPlaneFragmentDeclaration>
|
|
954
|
+
#include<bumpFragmentMainFunctions>
|
|
955
|
+
#include<bumpFragmentFunctions>
|
|
956
|
+
#include<helperFunctions>
|
|
957
|
+
#ifdef IRRADIANCE
|
|
958
|
+
#include<pbrFragmentReflectionDeclaration>
|
|
959
|
+
#ifdef REFLECTION
|
|
960
|
+
#ifdef USEIRRADIANCEMAP
|
|
961
|
+
#include<sceneUboDeclaration>
|
|
962
|
+
uniform reflectionMatrix: mat4x4f;uniform vReflectionInfos: vec2f;uniform vReflectionDominantDirection: vec3f;
|
|
963
|
+
#include<pbrBRDFFunctions>
|
|
964
|
+
#include<openpbrDielectricReflectance>
|
|
965
|
+
#include<pbrIBLFunctions>
|
|
966
|
+
#include<reflectionFunction>
|
|
967
|
+
#include<openpbrGeometryInfo>
|
|
968
|
+
#include<openpbrIblFunctions>
|
|
969
|
+
#elif defined(USESPHERICALFROMREFLECTIONMAP)
|
|
970
|
+
varying vEnvironmentIrradiance: vec3f;
|
|
971
|
+
#endif
|
|
972
|
+
#ifdef IBL_SHADOW_TEXTURE
|
|
973
|
+
var iblShadowSampler: texture_2d<f32>;var iblShadowSamplerSampler: sampler;uniform shadowTextureSize: vec2f;
|
|
974
|
+
#endif
|
|
975
|
+
#ifdef IRRADIANCE_SCATTER_MASK
|
|
976
|
+
uniform vSubsurfaceWeight: f32;
|
|
977
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_SAMPLERNAME_,subsurfaceWeight)
|
|
978
|
+
uniform vSubsurfaceScatterAnisotropy: f32;uniform vTransmissionWeight: f32;
|
|
979
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_SAMPLERNAME_,transmissionWeight)
|
|
980
|
+
uniform vTransmissionScatterAnisotropy: f32;
|
|
981
|
+
#endif
|
|
982
|
+
#endif
|
|
983
|
+
#endif
|
|
984
|
+
@fragment
|
|
985
|
+
fn main(input: FragmentInputs)->FragmentOutputs {
|
|
986
|
+
#include<clipPlaneFragment>
|
|
987
|
+
#ifdef ALPHATEST
|
|
988
|
+
if (textureSample(diffuseSampler,diffuseSamplerSampler,input.vUV).a<0.4) {discard;}
|
|
989
|
+
#endif
|
|
990
|
+
var normalOutput: vec3f;
|
|
991
|
+
#ifdef BUMP
|
|
992
|
+
var normalW: vec3f=normalize(input.vNormalW);
|
|
993
|
+
#include<bumpFragment>
|
|
994
|
+
#ifdef NORMAL_WORLDSPACE
|
|
995
|
+
normalOutput=normalW;
|
|
996
|
+
#else
|
|
997
|
+
normalOutput=normalize( (mat4x4f(input.vWorldView0,input.vWorldView1,input.vWorldView2,input.vWorldView3)* vec4f(normalW,0.0)).xyz);
|
|
998
|
+
#endif
|
|
999
|
+
#elif defined(HAS_NORMAL_ATTRIBUTE)
|
|
1000
|
+
normalOutput=normalize(input.vNormalV);
|
|
1001
|
+
#elif defined(POSITION)
|
|
1002
|
+
normalOutput=normalize(-cross(dpdx(input.vPositionW),dpdy(input.vPositionW)));
|
|
1003
|
+
#endif
|
|
1004
|
+
#ifdef ENCODE_NORMAL
|
|
1005
|
+
normalOutput=normalOutput*0.5+0.5;
|
|
1006
|
+
#endif
|
|
1007
|
+
var fragData: array<vec4<f32>,SCENE_MRT_COUNT>;
|
|
1008
|
+
#ifdef DEPTH
|
|
1009
|
+
fragData[DEPTH_INDEX]=vec4f(input.vViewPos.z/input.vViewPos.w,0.0,0.0,1.0);
|
|
1010
|
+
#endif
|
|
1011
|
+
#ifdef NORMAL
|
|
1012
|
+
fragData[NORMAL_INDEX]=vec4f(normalOutput,1.0);
|
|
1013
|
+
#endif
|
|
1014
|
+
#ifdef SCREENSPACE_DEPTH
|
|
1015
|
+
fragData[SCREENSPACE_DEPTH_INDEX]=vec4f(fragmentInputs.position.z,0.0,0.0,1.0);
|
|
1016
|
+
#endif
|
|
1017
|
+
#ifdef POSITION
|
|
1018
|
+
fragData[POSITION_INDEX]= vec4f(input.vPositionW,1.0);
|
|
1019
|
+
#endif
|
|
1020
|
+
#ifdef VELOCITY
|
|
1021
|
+
var a: vec2f=(input.vCurrentPosition.xy/input.vCurrentPosition.w)*0.5+0.5;var b: vec2f=(input.vPreviousPosition.xy/input.vPreviousPosition.w)*0.5+0.5;var velocity: vec2f=abs(a-b);velocity= vec2f(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;fragData[VELOCITY_INDEX]= vec4f(velocity,0.0,1.0);
|
|
1022
|
+
#endif
|
|
1023
|
+
#ifdef VELOCITY_LINEAR
|
|
1024
|
+
var velocity : vec2f=vec2f(0.5)*((input.vPreviousPosition.xy /
|
|
1025
|
+
input.vPreviousPosition.w) -
|
|
1026
|
+
(input.vCurrentPosition.xy /
|
|
1027
|
+
input.vCurrentPosition.w));fragData[VELOCITY_LINEAR_INDEX]=vec4f(velocity,0.0,1.0);
|
|
1028
|
+
#endif
|
|
1029
|
+
#ifdef REFLECTIVITY
|
|
1030
|
+
var reflectivity: vec4f= vec4f(0.0,0.0,0.0,1.0);
|
|
1031
|
+
#ifdef METALLICWORKFLOW
|
|
1032
|
+
var metal: f32=1.0;var roughness: f32=1.0;
|
|
1033
|
+
#ifdef ORMTEXTURE
|
|
1034
|
+
metal*=textureSample(reflectivitySampler,reflectivitySamplerSampler,input.vReflectivityUV).b;roughness*=textureSample(reflectivitySampler,reflectivitySamplerSampler,input.vReflectivityUV).g;
|
|
1035
|
+
#else
|
|
1036
|
+
#ifdef METALLIC_TEXTURE
|
|
1037
|
+
metal*=textureSample(metallicSampler,metallicSamplerSampler,input.vMetallicUV).r;
|
|
1038
|
+
#endif
|
|
1039
|
+
#ifdef ROUGHNESS_TEXTURE
|
|
1040
|
+
roughness*=textureSample(roughnessSampler,roughnessSamplerSampler,input.vRoughnessUV).r;
|
|
1041
|
+
#endif
|
|
1042
|
+
#endif
|
|
1043
|
+
#ifdef METALLIC
|
|
1044
|
+
metal*=uniforms.metallic;
|
|
1045
|
+
#endif
|
|
1046
|
+
#ifdef ROUGHNESS
|
|
1047
|
+
roughness*=(1.0-uniforms.glossiness);
|
|
1048
|
+
#endif
|
|
1049
|
+
reflectivity=vec4f(reflectivity.rgb,reflectivity.a-roughness);var color: vec3f= vec3f(1.0);
|
|
1050
|
+
#ifdef ALBEDOTEXTURE
|
|
1051
|
+
color=textureSample(albedoSampler,albedoSamplerSampler,input.vAlbedoUV).rgb;
|
|
1052
|
+
#ifdef GAMMAALBEDO
|
|
1053
|
+
color=toLinearSpaceVec4(color);
|
|
1054
|
+
#endif
|
|
1055
|
+
#endif
|
|
1056
|
+
#ifdef ALBEDOCOLOR
|
|
1057
|
+
color*=uniforms.albedoColor.xyz;
|
|
1058
|
+
#endif
|
|
1059
|
+
reflectivity=vec4f(mix( vec3f(0.04),color,metal),reflectivity.a);
|
|
1060
|
+
#else
|
|
1061
|
+
#if defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)
|
|
1062
|
+
reflectivity=textureSample(reflectivitySampler,reflectivitySamplerSampler,input.vReflectivityUV);
|
|
1063
|
+
#ifdef GAMMAREFLECTIVITYTEXTURE
|
|
1064
|
+
reflectivity=vec4f(toLinearSpaceVec3(reflectivity.rgb),reflectivity.a);
|
|
1065
|
+
#endif
|
|
1066
|
+
#else
|
|
1067
|
+
#ifdef REFLECTIVITYCOLOR
|
|
1068
|
+
reflectivity=vec4f(toLinearSpaceVec3(uniforms.reflectivityColor.xyz),1.0);
|
|
1069
|
+
#endif
|
|
1070
|
+
#endif
|
|
1071
|
+
#ifdef GLOSSINESSS
|
|
1072
|
+
reflectivity=vec4f(reflectivity.rgb,reflectivity.a*glossiness);
|
|
1073
|
+
#endif
|
|
1074
|
+
#endif
|
|
1075
|
+
fragData[REFLECTIVITY_INDEX]=reflectivity;
|
|
1076
|
+
#endif
|
|
1077
|
+
#ifdef IRRADIANCE
|
|
1078
|
+
var irradiance: vec3f=vec3f(0.0);var irradiance_alpha: f32=1.0;
|
|
1079
|
+
#ifdef REFLECTION
|
|
1080
|
+
#ifdef IRRADIANCE_SCATTER_MASK
|
|
1081
|
+
#ifndef BUMP
|
|
1082
|
+
let uvOffset: vec2f=vec2f(0.0);
|
|
1083
|
+
#endif
|
|
1084
|
+
var vSubsurfaceColor: vec3f=vec3f(1.0);var vSubsurfaceRadius: f32=0.0;var vSubsurfaceRadiusScale: vec3f=vec3f(1.0);
|
|
1085
|
+
#include<openpbrSubsurfaceLayerData>(uniforms.vSubsurfaceColor,vSubsurfaceColor,uniforms.vSubsurfaceRadius,vSubsurfaceRadius,uniforms.vSubsurfaceRadiusScale,vSubsurfaceRadiusScale)
|
|
1086
|
+
var vTransmissionDepth: f32=1.0;var vTransmissionColor: vec3f=vec3f(1.0);var vTransmissionScatter: vec3f=vec3f(0.0);var vTransmissionDispersionScale: f32=0.0;var vTransmissionDispersionAbbeNumber: f32=0.0;
|
|
1087
|
+
#include<openpbrTransmissionLayerData>(uniforms.vTransmissionDispersionScale,vTransmissionDispersionScale,uniforms.vTransmissionDispersionAbbeNumber,vTransmissionDispersionAbbeNumber,uniforms.vTransmissionColor,vTransmissionColor,uniforms.vTransmissionDepth,vTransmissionDepth,uniforms.vTransmissionScatter\\.,vTransmissionScatter.)
|
|
1088
|
+
#endif
|
|
1089
|
+
#ifdef IBL_SHADOW_TEXTURE
|
|
1090
|
+
#ifdef COLORED_IBL_SHADOWS
|
|
1091
|
+
let iblShadowValue: vec3f=textureSample(iblShadowSampler,iblShadowSamplerSampler,fragmentInputs.position.xy/uniforms.shadowTextureSize).rgb;
|
|
1092
|
+
#else
|
|
1093
|
+
let iblShadowValue: vec3f=vec3f(textureSample(iblShadowSampler,iblShadowSamplerSampler,fragmentInputs.position.xy/uniforms.shadowTextureSize).r);
|
|
1094
|
+
#endif
|
|
1095
|
+
#endif
|
|
1096
|
+
#if defined(USEIRRADIANCEMAP)
|
|
1097
|
+
#ifdef IRRADIANCE_SCATTER_MASK
|
|
1098
|
+
let bendAmount: f32=subsurface_weight*-min(subsurface_scatter_anisotropy,0.0);let mixedBendAmount: f32=mix(bendAmount,-min(transmission_scatter_anisotropy,0.0),transmission_weight);let viewVector: vec3f=normalize(scene.vEyePosition.xyz-input.vPositionW);let bentNormal: vec3f=mix(normalOutput,viewVector,mixedBendAmount*dot(normalOutput,viewVector));
|
|
1099
|
+
#else
|
|
1100
|
+
let bentNormal: vec3f=normalOutput;
|
|
1101
|
+
#endif
|
|
1102
|
+
irradiance=sampleIrradiance(
|
|
1103
|
+
bentNormal
|
|
1104
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
1105
|
+
,input.vEnvironmentIrradiance
|
|
1106
|
+
#endif
|
|
1107
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
1108
|
+
,uniforms.reflectionMatrix
|
|
1109
|
+
#endif
|
|
1110
|
+
#ifdef USEIRRADIANCEMAP
|
|
1111
|
+
,irradianceSampler
|
|
1112
|
+
,irradianceSamplerSampler
|
|
1113
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
1114
|
+
,uniforms.vReflectionDominantDirection
|
|
1115
|
+
#endif
|
|
1116
|
+
#endif
|
|
1117
|
+
#ifdef REALTIME_FILTERING
|
|
1118
|
+
,uniforms.vReflectionFilteringInfo
|
|
1119
|
+
#ifdef IBL_CDF_FILTERING
|
|
1120
|
+
,icdfSampler
|
|
1121
|
+
,icdfSamplerSampler
|
|
1122
|
+
#endif
|
|
1123
|
+
#endif
|
|
1124
|
+
,uniforms.vReflectionInfos
|
|
1125
|
+
,input.vViewPos.xyz
|
|
1126
|
+
,1.0
|
|
1127
|
+
,vec3f(1.0)
|
|
1128
|
+
);
|
|
1129
|
+
#elif defined(USESPHERICALFROMREFLECTIONMAP)
|
|
1130
|
+
irradiance=input.vEnvironmentIrradiance;
|
|
1131
|
+
#endif
|
|
1132
|
+
#ifdef IBL_SHADOW_TEXTURE
|
|
1133
|
+
irradiance*=iblShadowValue;
|
|
1134
|
+
#endif
|
|
1135
|
+
#ifdef IRRADIANCE_SCATTER_MASK
|
|
1136
|
+
irradiance_alpha=min(subsurface_weight+transmission_weight,1.0);
|
|
1137
|
+
#endif
|
|
1138
|
+
#endif
|
|
1139
|
+
fragData[IRRADIANCE_INDEX]=vec4f(irradiance,irradiance_alpha);
|
|
1140
|
+
#endif
|
|
1141
|
+
#if SCENE_MRT_COUNT>0
|
|
1142
|
+
fragmentOutputs.fragData0=fragData[0];
|
|
1143
|
+
#endif
|
|
1144
|
+
#if SCENE_MRT_COUNT>1
|
|
1145
|
+
fragmentOutputs.fragData1=fragData[1];
|
|
1146
|
+
#endif
|
|
1147
|
+
#if SCENE_MRT_COUNT>2
|
|
1148
|
+
fragmentOutputs.fragData2=fragData[2];
|
|
1149
|
+
#endif
|
|
1150
|
+
#if SCENE_MRT_COUNT>3
|
|
1151
|
+
fragmentOutputs.fragData3=fragData[3];
|
|
1152
|
+
#endif
|
|
1153
|
+
#if SCENE_MRT_COUNT>4
|
|
1154
|
+
fragmentOutputs.fragData4=fragData[4];
|
|
1155
|
+
#endif
|
|
1156
|
+
#if SCENE_MRT_COUNT>5
|
|
1157
|
+
fragmentOutputs.fragData5=fragData[5];
|
|
1158
|
+
#endif
|
|
1159
|
+
#if SCENE_MRT_COUNT>6
|
|
1160
|
+
fragmentOutputs.fragData6=fragData[6];
|
|
1161
|
+
#endif
|
|
1162
|
+
#if SCENE_MRT_COUNT>7
|
|
1163
|
+
fragmentOutputs.fragData7=fragData[7];
|
|
1164
|
+
#endif
|
|
1165
|
+
}
|
|
1166
|
+
`;for(let e of(r.ShaderStore.ShadersStoreWGSL[I]||(r.ShaderStore.ShadersStoreWGSL[I]=N),[a.clipPlaneFragmentDeclarationWGSL,i.bumpFragmentMainFunctionsWGSL,f.samplerFragmentDeclarationWGSL,n.bumpFragmentFunctionsWGSL,t.helperFunctionsWGSL,o.pbrFragmentReflectionDeclarationWGSL,c.sceneUboDeclarationWGSL,s.pbrBRDFFunctionsWGSL,l.openpbrDielectricReflectanceWGSL,d.pbrIBLFunctionsWGSL,v.reflectionFunctionWGSL,m.openpbrGeometryInfoWGSL,u.openpbrIblFunctionsWGSL,p.clipPlaneFragmentWGSL,S.bumpFragmentWGSL,E.openpbrSubsurfaceLayerDataWGSL,R.openpbrTransmissionLayerDataWGSL]))r.ShaderStore.IncludesShadersStoreWGSL[e.name]||(r.ShaderStore.IncludesShadersStoreWGSL[e.name]=e.shader);e.s(["geometryPixelShaderWGSL",0,{name:I,shader:N}])}]);
|