@babylonjs/lite 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/_mat4-storage-f64-Bvh5TymE.js +10 -0
  2. package/_mat4-storage-f64-Bvh5TymE.js.map +1 -0
  3. package/{alpha-test-fragment-CUiHCw7W.js → alpha-test-fragment-BCChpzaV.js} +2 -2
  4. package/{alpha-test-fragment-CUiHCw7W.js.map → alpha-test-fragment-BCChpzaV.js.map} +1 -1
  5. package/{background-dds-skybox-yHTqabU3.js → background-dds-skybox-ZjrSIxrT.js} +4 -4
  6. package/background-dds-skybox-ZjrSIxrT.js.map +1 -0
  7. package/{background-ground-DIw6D3qf.js → background-ground-B2Mie-MI.js} +3 -3
  8. package/background-ground-B2Mie-MI.js.map +1 -0
  9. package/{background-hdr-skybox-c4uuTmkP.js → background-hdr-skybox-DDRJYuT2.js} +3 -3
  10. package/background-hdr-skybox-DDRJYuT2.js.map +1 -0
  11. package/{background-solid-skybox-DPGBpPbm.js → background-solid-skybox-fjXlnWaD.js} +3 -3
  12. package/{background-solid-skybox-DPGBpPbm.js.map → background-solid-skybox-fjXlnWaD.js.map} +1 -1
  13. package/{billboard-renderable-D8mlVGCd.js → billboard-renderable-DKmlOgbM.js} +2 -2
  14. package/{billboard-renderable-D8mlVGCd.js.map → billboard-renderable-DKmlOgbM.js.map} +1 -1
  15. package/{clamp-block-BdII67hT.js → clamp-block-CxRBPlUq.js} +2 -2
  16. package/{clamp-block-BdII67hT.js.map → clamp-block-CxRBPlUq.js.map} +1 -1
  17. package/{clearcoat-fragment-LCiG98Rf.js → clearcoat-fragment-KbZAa0TA.js} +2 -2
  18. package/{clearcoat-fragment-LCiG98Rf.js.map → clearcoat-fragment-KbZAa0TA.js.map} +1 -1
  19. package/{create-skeleton-C9JdIJnb.js → create-skeleton-BBI5urcj.js} +2 -2
  20. package/{create-skeleton-C9JdIJnb.js.map → create-skeleton-BBI5urcj.js.map} +1 -1
  21. package/{cubemap-skybox-material-DvXMVc4k.js → cubemap-skybox-material-DvW81drX.js} +2 -2
  22. package/{cubemap-skybox-material-DvXMVc4k.js.map → cubemap-skybox-material-DvW81drX.js.map} +1 -1
  23. package/{curve-block-BlJpXVYv.js → curve-block-Dh_xdUj-.js} +2 -2
  24. package/{curve-block-BlJpXVYv.js.map → curve-block-Dh_xdUj-.js.map} +1 -1
  25. package/{emissive-fragment-BnNvbBCw.js → emissive-fragment-DD8cvHyx.js} +2 -2
  26. package/{emissive-fragment-BnNvbBCw.js.map → emissive-fragment-DD8cvHyx.js.map} +1 -1
  27. package/{esm-shadow-view-DGKdF1NI.js → esm-shadow-view-15S4JK6p.js} +2 -2
  28. package/{esm-shadow-view-DGKdF1NI.js.map → esm-shadow-view-15S4JK6p.js.map} +1 -1
  29. package/{esm-shadow-view-Dk9NFtLq.js → esm-shadow-view-DHVS9r7H.js} +2 -2
  30. package/{esm-shadow-view-Dk9NFtLq.js.map → esm-shadow-view-DHVS9r7H.js.map} +1 -1
  31. package/{esm-shadow-view-DN9HIaM4.js → esm-shadow-view-DYAc62Kl.js} +2 -2
  32. package/{esm-shadow-view-DN9HIaM4.js.map → esm-shadow-view-DYAc62Kl.js.map} +1 -1
  33. package/{gaussian-splatting-pipeline-sh-DgJl7l56.js → gaussian-splatting-pipeline-sh-BvkUhA9V.js} +2 -2
  34. package/{gaussian-splatting-pipeline-sh-DgJl7l56.js.map → gaussian-splatting-pipeline-sh-BvkUhA9V.js.map} +1 -1
  35. package/{gltf-animation-D7uyTyO3.js → gltf-animation-KnPzeOIY.js} +3 -3
  36. package/{gltf-animation-D7uyTyO3.js.map → gltf-animation-KnPzeOIY.js.map} +1 -1
  37. package/gltf-color-normalize-Qxl-9C48.js +29 -0
  38. package/gltf-color-normalize-Qxl-9C48.js.map +1 -0
  39. package/{gltf-ext-basisu-CPg5kPrx.js → gltf-ext-basisu-kmth3UWX.js} +7 -4
  40. package/gltf-ext-basisu-kmth3UWX.js.map +1 -0
  41. package/{gltf-ext-node-visibility-MafA9ot2.js → gltf-ext-node-visibility-BjRRd6si.js} +2 -2
  42. package/{gltf-ext-node-visibility-MafA9ot2.js.map → gltf-ext-node-visibility-BjRRd6si.js.map} +1 -1
  43. package/{gltf-ext-uv-transform-CE_-T1Tr.js → gltf-ext-uv-transform-MHmR-YyM.js} +2 -2
  44. package/{gltf-ext-uv-transform-CE_-T1Tr.js.map → gltf-ext-uv-transform-MHmR-YyM.js.map} +1 -1
  45. package/{gltf-feature-animation-pointer-BjpwOOqo.js → gltf-feature-animation-pointer-rFqLfbO_.js} +3 -3
  46. package/{gltf-feature-animation-pointer-BjpwOOqo.js.map → gltf-feature-animation-pointer-rFqLfbO_.js.map} +1 -1
  47. package/{gltf-feature-animations-CCizegp8.js → gltf-feature-animations-DikONdzi.js} +2 -2
  48. package/{gltf-feature-animations-CCizegp8.js.map → gltf-feature-animations-DikONdzi.js.map} +1 -1
  49. package/{gltf-feature-gpu-instancing-2e_CFQnl.js → gltf-feature-gpu-instancing-Cj1XjmM6.js} +5 -4
  50. package/gltf-feature-gpu-instancing-Cj1XjmM6.js.map +1 -0
  51. package/{gltf-feature-lights-punctual-DDDg4j0U.js → gltf-feature-lights-punctual-C-0SlGmD.js} +5 -5
  52. package/{gltf-feature-lights-punctual-DDDg4j0U.js.map → gltf-feature-lights-punctual-C-0SlGmD.js.map} +1 -1
  53. package/{gltf-feature-morph-CKCw6tkX.js → gltf-feature-morph-BAcY14XU.js} +3 -3
  54. package/{gltf-feature-morph-CKCw6tkX.js.map → gltf-feature-morph-BAcY14XU.js.map} +1 -1
  55. package/gltf-feature-registry-97sY_x5O.js +59 -0
  56. package/gltf-feature-registry-97sY_x5O.js.map +1 -0
  57. package/{gltf-feature-skeleton-D8hWLqi2.js → gltf-feature-skeleton-lVjkDfIU.js} +3 -3
  58. package/{gltf-feature-skeleton-D8hWLqi2.js.map → gltf-feature-skeleton-lVjkDfIU.js.map} +1 -1
  59. package/{gltf-feature-variants-Ds6v9byg.js → gltf-feature-variants-BphF4JmV.js} +2 -2
  60. package/{gltf-feature-variants-Ds6v9byg.js.map → gltf-feature-variants-BphF4JmV.js.map} +1 -1
  61. package/{gltf-interleave-DGnUlz28.js → gltf-interleave-C9eBqH_F.js} +2 -2
  62. package/{gltf-interleave-DGnUlz28.js.map → gltf-interleave-C9eBqH_F.js.map} +1 -1
  63. package/gltf-normals-b2h74380.js +37 -0
  64. package/gltf-normals-b2h74380.js.map +1 -0
  65. package/{gltf-pbr-builder-ext-BFOxOCnQ.js → gltf-pbr-builder-ext-DPC0zg_u.js} +2 -2
  66. package/{gltf-pbr-builder-ext-BFOxOCnQ.js.map → gltf-pbr-builder-ext-DPC0zg_u.js.map} +1 -1
  67. package/{gltf-variants-DFbr8EES.js → gltf-variants-CnBEZr0o.js} +4 -4
  68. package/{gltf-variants-DFbr8EES.js.map → gltf-variants-CnBEZr0o.js.map} +1 -1
  69. package/{gs-picking-pipeline-DzfMASL9.js → gs-picking-pipeline-Bx8LTav6.js} +2 -2
  70. package/{gs-picking-pipeline-DzfMASL9.js.map → gs-picking-pipeline-Bx8LTav6.js.map} +1 -1
  71. package/{index-C8HOR2sB.js → index-B7Qhw0xL.js} +3047 -1037
  72. package/index-B7Qhw0xL.js.map +1 -0
  73. package/index.d.ts +504 -17
  74. package/index.js +322 -304
  75. package/{input-block-DgAJBzN_.js → input-block-Coi_aZwl.js} +2 -2
  76. package/{input-block-DgAJBzN_.js.map → input-block-Coi_aZwl.js.map} +1 -1
  77. package/{iridescence-fragment-Gymp7or5.js → iridescence-fragment-DwZcCTdD.js} +2 -2
  78. package/{iridescence-fragment-Gymp7or5.js.map → iridescence-fragment-DwZcCTdD.js.map} +1 -1
  79. package/{light-block-B11ew7FA.js → light-block-Np_h5gPI.js} +2 -2
  80. package/{light-block-B11ew7FA.js.map → light-block-Np_h5gPI.js.map} +1 -1
  81. package/{loop-block-Bb23EOMb.js → loop-block-BFkLFYGm.js} +2 -2
  82. package/{loop-block-Bb23EOMb.js.map → loop-block-BFkLFYGm.js.map} +1 -1
  83. package/{mesh-features-BLENkYVt.js → mesh-features-BAJpbMog.js} +6 -3
  84. package/mesh-features-BAJpbMog.js.map +1 -0
  85. package/{morph-fragment-DOVo70gP.js → morph-fragment-DqH-w61u.js} +2 -2
  86. package/{morph-fragment-DOVo70gP.js.map → morph-fragment-DqH-w61u.js.map} +1 -1
  87. package/{multilight-wgsl-BGyiIOp3.js → multilight-wgsl-B9Mf9d-q.js} +4 -4
  88. package/{multilight-wgsl-BGyiIOp3.js.map → multilight-wgsl-B9Mf9d-q.js.map} +1 -1
  89. package/no-color-view-DsyLSL-W.js +8 -0
  90. package/no-color-view-DsyLSL-W.js.map +1 -0
  91. package/{node-registry-DwgC4yth.js → node-registry-Bd-AlrgC.js} +8 -8
  92. package/{node-registry-DwgC4yth.js.map → node-registry-Bd-AlrgC.js.map} +1 -1
  93. package/{node-registry-extra-compat-Dhrw8fDQ.js → node-registry-extra-compat-Ch7ApZHF.js} +2 -2
  94. package/{node-registry-extra-compat-Dhrw8fDQ.js.map → node-registry-extra-compat-Ch7ApZHF.js.map} +1 -1
  95. package/{node-registry-extra-math-CsAHvIZo.js → node-registry-extra-math-6ezzTkPj.js} +2 -2
  96. package/{node-registry-extra-math-CsAHvIZo.js.map → node-registry-extra-math-6ezzTkPj.js.map} +1 -1
  97. package/{node-renderable-DlLIdBmd.js → node-renderable-CS0CmsSp.js} +28 -11
  98. package/node-renderable-CS0CmsSp.js.map +1 -0
  99. package/{node-shadow-DKrcqmNg.js → node-shadow-CpnrdvtJ.js} +2 -2
  100. package/{node-shadow-DKrcqmNg.js.map → node-shadow-CpnrdvtJ.js.map} +1 -1
  101. package/{normal-map-fragment-DpsIXrJf.js → normal-map-fragment-DradEMl-.js} +3 -3
  102. package/{normal-map-fragment-DpsIXrJf.js.map → normal-map-fragment-DradEMl-.js.map} +1 -1
  103. package/pack-mat4-with-offset-BqB8Jqo7.js +37 -0
  104. package/pack-mat4-with-offset-BqB8Jqo7.js.map +1 -0
  105. package/package.json +3 -3
  106. package/{parse-camera-DM3oJJeT.js → parse-camera-CgV4bWc0.js} +2 -2
  107. package/{parse-camera-DM3oJJeT.js.map → parse-camera-CgV4bWc0.js.map} +1 -1
  108. package/pbr-fog-wgsl-BqdCid6r.js +8 -0
  109. package/pbr-fog-wgsl-BqdCid6r.js.map +1 -0
  110. package/{pbr-metallic-roughness-block-h_KAOZrW.js → pbr-metallic-roughness-block-BFwZj2Nw.js} +2 -2
  111. package/{pbr-metallic-roughness-block-h_KAOZrW.js.map → pbr-metallic-roughness-block-BFwZj2Nw.js.map} +1 -1
  112. package/{pbr-metallic-roughness-block-full-6vMm1Jk6.js → pbr-metallic-roughness-block-full-5t0HT3xl.js} +2 -2
  113. package/{pbr-metallic-roughness-block-full-6vMm1Jk6.js.map → pbr-metallic-roughness-block-full-5t0HT3xl.js.map} +1 -1
  114. package/{pbr-mr-helper-core-CIwm-T1G.js → pbr-mr-helper-core-R5tOZ8Ap.js} +2 -2
  115. package/{pbr-mr-helper-core-CIwm-T1G.js.map → pbr-mr-helper-core-R5tOZ8Ap.js.map} +1 -1
  116. package/{pbr-refraction-DGmMSa2v.js → pbr-refraction-Dd11HnaI.js} +2 -2
  117. package/{pbr-refraction-DGmMSa2v.js.map → pbr-refraction-Dd11HnaI.js.map} +1 -1
  118. package/{pbr-renderable-BJxUtPBb.js → pbr-renderable-BHAdF5Vw.js} +80 -38
  119. package/pbr-renderable-BHAdF5Vw.js.map +1 -0
  120. package/{pbr-shadow-fragment-LO9SlbJj.js → pbr-shadow-fragment-BxUrFJYZ.js} +6 -1
  121. package/pbr-shadow-fragment-BxUrFJYZ.js.map +1 -0
  122. package/{pbr-template-ext-8q7BcTDf.js → pbr-template-ext-CGgB2n2y.js} +3 -2
  123. package/{pbr-template-ext-8q7BcTDf.js.map → pbr-template-ext-CGgB2n2y.js.map} +1 -1
  124. package/{pbr-tracking-B3alzn91.js → pbr-tracking-D6i3yPb7.js} +2 -2
  125. package/{pbr-tracking-B3alzn91.js.map → pbr-tracking-D6i3yPb7.js.map} +1 -1
  126. package/pbr-transmission-ext-Dll8EYwE.js +190 -0
  127. package/pbr-transmission-ext-Dll8EYwE.js.map +1 -0
  128. package/{reflectance-fragment-BCrgPmrt.js → reflectance-fragment-ejMJ4O1o.js} +2 -2
  129. package/{reflectance-fragment-BCrgPmrt.js.map → reflectance-fragment-ejMJ4O1o.js.map} +1 -1
  130. package/{shader-renderable-D-6796KR.js → shader-renderable-BMf_vvO0.js} +41 -12
  131. package/shader-renderable-BMf_vvO0.js.map +1 -0
  132. package/shader-thin-instance-5_WUfi3m.js +150 -0
  133. package/shader-thin-instance-5_WUfi3m.js.map +1 -0
  134. package/shadow-fragment-core-DHN2G6FI.js.map +1 -1
  135. package/{sheen-fragment-Dze2f7XJ.js → sheen-fragment-CS6z29Fs.js} +2 -2
  136. package/{sheen-fragment-Dze2f7XJ.js.map → sheen-fragment-CS6z29Fs.js.map} +1 -1
  137. package/{singlelight-directional-wgsl-CmUDZxwz.js → singlelight-directional-wgsl-4MIgZMeC.js} +2 -2
  138. package/{singlelight-directional-wgsl-CmUDZxwz.js.map → singlelight-directional-wgsl-4MIgZMeC.js.map} +1 -1
  139. package/{singlelight-hemispheric-wgsl-t-83IP_s.js → singlelight-hemispheric-wgsl-CK-GUYWe.js} +2 -2
  140. package/{singlelight-hemispheric-wgsl-t-83IP_s.js.map → singlelight-hemispheric-wgsl-CK-GUYWe.js.map} +1 -1
  141. package/{singlelight-point-wgsl-CLzULIYV.js → singlelight-point-wgsl-CYtzqCbP.js} +2 -2
  142. package/{singlelight-point-wgsl-CLzULIYV.js.map → singlelight-point-wgsl-CYtzqCbP.js.map} +1 -1
  143. package/{singlelight-spot-wgsl-DEEUrfVM.js → singlelight-spot-wgsl-DVbaVufF.js} +2 -2
  144. package/{singlelight-spot-wgsl-DEEUrfVM.js.map → singlelight-spot-wgsl-DVbaVufF.js.map} +1 -1
  145. package/{skeleton-fragment-B_XlFbtx.js → skeleton-fragment-BOVmc8YS.js} +2 -2
  146. package/{skeleton-fragment-B_XlFbtx.js.map → skeleton-fragment-BOVmc8YS.js.map} +1 -1
  147. package/{skybox-renderable-DDwzu-PT.js → skybox-renderable-DDcCPSly.js} +3 -3
  148. package/{skybox-renderable-DDwzu-PT.js.map → skybox-renderable-DDcCPSly.js.map} +1 -1
  149. package/{standard-renderable-GjxL9xSf.js → standard-renderable-D1bhoF0K.js} +27 -81
  150. package/standard-renderable-D1bhoF0K.js.map +1 -0
  151. package/{std-ambient-fragment-BoUsD06w.js → std-ambient-fragment-C6WNm8dQ.js} +2 -2
  152. package/{std-ambient-fragment-BoUsD06w.js.map → std-ambient-fragment-C6WNm8dQ.js.map} +1 -1
  153. package/{std-cube-reflection-fragment-ulqc3bsP.js → std-cube-reflection-fragment-Bqutpy2q.js} +2 -2
  154. package/{std-cube-reflection-fragment-ulqc3bsP.js.map → std-cube-reflection-fragment-Bqutpy2q.js.map} +1 -1
  155. package/{std-emissive-fragment-DNGj1HdQ.js → std-emissive-fragment-B-A83rqX.js} +2 -2
  156. package/{std-emissive-fragment-DNGj1HdQ.js.map → std-emissive-fragment-B-A83rqX.js.map} +1 -1
  157. package/{std-lightmap-fragment-Bqj89aIe.js → std-lightmap-fragment-Df7KJezh.js} +2 -2
  158. package/{std-lightmap-fragment-Bqj89aIe.js.map → std-lightmap-fragment-Df7KJezh.js.map} +1 -1
  159. package/{std-opacity-fragment-KuPh5N2Z.js → std-opacity-fragment-D9et2jip.js} +2 -2
  160. package/{std-opacity-fragment-KuPh5N2Z.js.map → std-opacity-fragment-D9et2jip.js.map} +1 -1
  161. package/{std-reflection-fragment-BA5Ghn_M.js → std-reflection-fragment-DBJeT-yg.js} +2 -2
  162. package/{std-reflection-fragment-BA5Ghn_M.js.map → std-reflection-fragment-DBJeT-yg.js.map} +1 -1
  163. package/std-shadow-fragment-C6fD8rW-.js +13 -0
  164. package/std-shadow-fragment-C6fD8rW-.js.map +1 -0
  165. package/{std-specular-fragment-CE-6scqd.js → std-specular-fragment-C2ZOss-t.js} +2 -2
  166. package/{std-specular-fragment-CE-6scqd.js.map → std-specular-fragment-C2ZOss-t.js.map} +1 -1
  167. package/{std-tracking-CNKZ-hJN.js → std-tracking-C4L4nQGc.js} +2 -2
  168. package/{std-tracking-CNKZ-hJN.js.map → std-tracking-C4L4nQGc.js.map} +1 -1
  169. package/{subsurface-fragment-liM3y2-P.js → subsurface-fragment-C1H4ytqK.js} +2 -2
  170. package/{subsurface-fragment-liM3y2-P.js.map → subsurface-fragment-C1H4ytqK.js.map} +1 -1
  171. package/thin-instance-cull-binding-CCxrPNO6.js +310 -0
  172. package/thin-instance-cull-binding-CCxrPNO6.js.map +1 -0
  173. package/{thin-instance-gpu-C9Gv_Z1w.js → thin-instance-gpu-E8DBd8XL.js} +20 -3
  174. package/thin-instance-gpu-E8DBd8XL.js.map +1 -0
  175. package/{tracking-primitives-wgdBY85t.js → tracking-primitives-w4BVV9p9.js} +2 -2
  176. package/{tracking-primitives-wgdBY85t.js.map → tracking-primitives-w4BVV9p9.js.map} +1 -1
  177. package/{unlit-fragment-BIlhJpz6.js → unlit-fragment-DU9_mhzZ.js} +2 -2
  178. package/{unlit-fragment-BIlhJpz6.js.map → unlit-fragment-DU9_mhzZ.js.map} +1 -1
  179. package/{wgsl-helpers-DyzNzCeE.js → wgsl-helpers-D8sl1VVA.js} +4 -4
  180. package/{wgsl-helpers-DyzNzCeE.js.map → wgsl-helpers-D8sl1VVA.js.map} +1 -1
  181. package/background-dds-skybox-yHTqabU3.js.map +0 -1
  182. package/background-ground-DIw6D3qf.js.map +0 -1
  183. package/background-hdr-skybox-c4uuTmkP.js.map +0 -1
  184. package/gltf-ext-basisu-CPg5kPrx.js.map +0 -1
  185. package/gltf-feature-gpu-instancing-2e_CFQnl.js.map +0 -1
  186. package/index-C8HOR2sB.js.map +0 -1
  187. package/mesh-features-BLENkYVt.js.map +0 -1
  188. package/node-renderable-DlLIdBmd.js.map +0 -1
  189. package/pbr-renderable-BJxUtPBb.js.map +0 -1
  190. package/pbr-shadow-fragment-LO9SlbJj.js.map +0 -1
  191. package/pbr-transmission-ext-BxW4CEGu.js +0 -581
  192. package/pbr-transmission-ext-BxW4CEGu.js.map +0 -1
  193. package/shader-renderable-D-6796KR.js.map +0 -1
  194. package/standard-renderable-GjxL9xSf.js.map +0 -1
  195. package/std-shadow-fragment-FNQfrJuC.js +0 -8
  196. package/std-shadow-fragment-FNQfrJuC.js.map +0 -1
  197. package/thin-instance-gpu-C9Gv_Z1w.js.map +0 -1
@@ -1,581 +0,0 @@
1
- import { aO as getOrCreateSampler, bq as createImageProcessingTask, br as biasedMipLevelCount, b2 as getBilinearSampler, bs as _vis, bt as recordMipmaps, bo as PBR2_HAS_REFRACTION, bu as PBR2_HAS_REFRACTION_MAP, aH as PBR_HAS_THICKNESS_MAP, bv as PBR2_LINEAR_IMAGE_PROCESSING, bw as PBR2_HAS_DISPERSION, aJ as PBR2_HAS_THICKNESS_GLTF_CHANNEL, bx as PBR2_HAS_VOLUME } from "./index-C8HOR2sB.js";
2
- const _trilinearAnisotropicDesc = {
3
- magFilter: "linear",
4
- minFilter: "linear",
5
- mipmapFilter: "linear",
6
- addressModeU: "repeat",
7
- addressModeV: "repeat",
8
- addressModeW: "repeat",
9
- maxAnisotropy: 4
10
- };
11
- function getTrilinearAnisotropicSampler(engine) {
12
- return getOrCreateSampler(engine, _trilinearAnisotropicDesc);
13
- }
14
- const BLIT_SHADER = `@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var s:sampler;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{var p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));var u=array<vec2f,3>(vec2f(0,1),vec2f(2,1),vec2f(0,-1));return V(vec4f(p[i],0,1),u[i]);}@fragment fn fs(v:V)->@location(0)vec4f{return textureSample(t,s,v.u);}`;
15
- const BLIT_MSAA_SHADER = `@group(0)@binding(0)var t:texture_multisampled_2d<f32>;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{var p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3));var u=array<vec2f,3>(vec2f(0,1),vec2f(2,1),vec2f(0,-1));return V(vec4f(p[i],0,1),u[i]);}fn l(p:vec2i)->vec4f{let n=textureNumSamples(t);var c=vec4f(0);for(var i=0u;i<n;i++){c+=textureLoad(t,p,i);}return c/f32(n);}@fragment fn fs(v:V)->@location(0)vec4f{let d=vec2i(textureDimensions(t));let q=clamp(v.u*vec2f(d)-.5,vec2f(0),vec2f(d-vec2i(1)));let p=vec2i(floor(q));let f=fract(q);let p1=min(p+vec2i(1),d-vec2i(1));return mix(mix(l(p),l(vec2i(p1.x,p.y)),f.x),mix(l(vec2i(p.x,p1.y)),l(p1),f.x),f.y);}`;
16
- const REFRACTION_LOD_BIAS = 4;
17
- let blitPipelines = null;
18
- let blitShader = null;
19
- let blitMsaaShader = null;
20
- let blitBgl = null;
21
- let blitMsaaBgl = null;
22
- let blitDevice = null;
23
- function enableSceneTransmission(scene, engine) {
24
- markPbrMaterialsLinear(scene);
25
- let lastRenderTask = null;
26
- for (const task of scene._frameGraph._tasks) {
27
- if ("_renderables" in task) {
28
- const renderTask = task;
29
- enableRenderTaskTransmission(renderTask, engine);
30
- lastRenderTask = renderTask;
31
- }
32
- }
33
- if (lastRenderTask && !scene._frameGraph._tasks.some((task) => task.name === "transmission-image-processing")) {
34
- scene._frameGraph._tasks.push(createImageProcessingTask({ name: "transmission-image-processing", source: lastRenderTask._config.rt }, engine, scene));
35
- }
36
- }
37
- function enableRenderTaskTransmission(task, engine) {
38
- var _a, _b;
39
- if (task._executeWithTransmission) {
40
- return;
41
- }
42
- retargetRenderTaskToLinearOffscreen(task, engine);
43
- let state = null;
44
- const record = task.record.bind(task);
45
- const execute = (_a = task.execute) == null ? void 0 : _a.bind(task);
46
- const dispose = (_b = task.dispose) == null ? void 0 : _b.bind(task);
47
- task.record = () => {
48
- disposeRenderTaskTransmission(state);
49
- state = createRenderTaskTransmission(task, engine);
50
- task._targetSignature._transmissionTexture = state.texture;
51
- record();
52
- configureTransmissionSource(state, task, engine);
53
- };
54
- if (execute) {
55
- task.execute = () => executeRenderTaskLinear(task.scene, execute);
56
- }
57
- task.dispose = () => {
58
- disposeRenderTaskTransmission(state);
59
- state = null;
60
- dispose == null ? void 0 : dispose();
61
- };
62
- task._executeWithTransmission = (sampleCount) => executePassWithTransmission(task, engine, state, sampleCount);
63
- }
64
- function retargetRenderTaskToLinearOffscreen(task, engine) {
65
- const desc = task._config.rt._descriptor;
66
- if (desc.resolveToSwapchain) {
67
- desc.resolveToSwapchain = false;
68
- desc.colorFormat = "rgba16float";
69
- desc.flipY = false;
70
- task._opaqueBundles.length = 0;
71
- task._lastVersion = -1;
72
- } else if (!desc.colorFormat) {
73
- desc.colorFormat = "rgba16float";
74
- }
75
- desc.sampleCount = engine.msaaSamples;
76
- const sig = task._targetSignature;
77
- sig._colorFormat = desc.colorFormat;
78
- sig._depthStencilFormat = desc.depthStencilFormat;
79
- sig._depthCompare = desc._depthCompare;
80
- sig._sampleCount = desc.sampleCount;
81
- sig._flipY = desc.flipY ?? true;
82
- }
83
- function executeRenderTaskLinear(scene, execute) {
84
- const imageProcessing = scene.imageProcessing;
85
- const toneMappingEnabled = imageProcessing.toneMappingEnabled;
86
- const clearColor = scene.clearColor;
87
- const linearClearColor = inverseImageProcessedColor(clearColor, imageProcessing.exposure, imageProcessing.contrast, toneMappingEnabled === true);
88
- imageProcessing.toneMappingEnabled = -1;
89
- scene.clearColor = linearClearColor;
90
- try {
91
- return execute();
92
- } finally {
93
- scene.clearColor = clearColor;
94
- imageProcessing.toneMappingEnabled = toneMappingEnabled;
95
- }
96
- }
97
- function inverseImageProcessedColor(color, exposure, contrast, toneMapping) {
98
- return {
99
- r: inverseImageProcessedChannel(color.r, exposure, contrast, toneMapping),
100
- g: inverseImageProcessedChannel(color.g, exposure, contrast, toneMapping),
101
- b: inverseImageProcessedChannel(color.b, exposure, contrast, toneMapping),
102
- a: color.a
103
- };
104
- }
105
- function inverseImageProcessedChannel(value, exposure, contrast, toneMapping) {
106
- let c = clamp01(value);
107
- if (contrast < 1) {
108
- c = contrast > 0 ? clamp01((c - 0.5 * (1 - contrast)) / contrast) : 0.5;
109
- } else if (contrast > 1) {
110
- const mixAmount = contrast - 1;
111
- let lo = 0;
112
- let hi = 1;
113
- for (let i = 0; i < 16; i++) {
114
- const mid = (lo + hi) * 0.5;
115
- const high = mid * mid * (3 - 2 * mid);
116
- const out = mid + (high - mid) * mixAmount;
117
- if (out < c) {
118
- lo = mid;
119
- } else {
120
- hi = mid;
121
- }
122
- }
123
- c = (lo + hi) * 0.5;
124
- }
125
- c = c ** 2.2;
126
- if (toneMapping) {
127
- c = -Math.log2(Math.max(1 - c, 1e-6)) / 1.5905790328979492;
128
- }
129
- return exposure > 0 ? c / exposure : c;
130
- }
131
- function clamp01(v) {
132
- return Math.min(Math.max(v, 0), 1);
133
- }
134
- function markPbrMaterialsLinear(scene) {
135
- for (const mesh of scene.meshes) {
136
- const mat = mesh.material;
137
- if (mat) {
138
- mat._linearImageProcessing = true;
139
- mat._renderFeatures = void 0;
140
- }
141
- }
142
- }
143
- function createRenderTaskTransmission(task, engine) {
144
- const rt = task._config.rt;
145
- const width = 1024;
146
- const height = 1024;
147
- const format = "rgba16float";
148
- const generateMipmaps = shouldGenerateMipmaps(task._config.transmission);
149
- const texture = engine._device.createTexture({
150
- label: task.name,
151
- size: { width, height },
152
- format,
153
- mipLevelCount: generateMipmaps ? biasedMipLevelCount(width, height, REFRACTION_LOD_BIAS) : 1,
154
- usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
155
- });
156
- const tex = {
157
- texture,
158
- view: texture.createView(),
159
- sampler: getTrilinearAnisotropicSampler(engine),
160
- width,
161
- height,
162
- invertY: false
163
- };
164
- return {
165
- texture: tex,
166
- _baseView: texture.createView({ baseMipLevel: 0, mipLevelCount: 1 }),
167
- _sourceWidth: rt._width,
168
- _sourceHeight: rt._height,
169
- _sourceTexture: null,
170
- _blit: null,
171
- _copyCount: normalizeCopyCount(task._config.transmission),
172
- _generateMipmaps: generateMipmaps,
173
- _copies: 0
174
- };
175
- }
176
- function configureTransmissionSource(state, task, engine) {
177
- const rt = task._config.rt;
178
- state._sourceWidth = rt._width;
179
- state._sourceHeight = rt._height;
180
- state._sourceTexture = rt._colorTexture;
181
- const sampleCount = task._targetSignature._sampleCount;
182
- if (!state._sourceTexture) {
183
- return;
184
- }
185
- state._blit = shouldBlitTransmission(state, sampleCount) ? createTransmissionBlit(state, engine, state._sourceTexture, sampleCount > 1) : null;
186
- }
187
- function disposeRenderTaskTransmission(state) {
188
- state == null ? void 0 : state.texture.texture.destroy();
189
- }
190
- function executePassWithTransmission(task, engine, state, sampleCount) {
191
- state._copies = 0;
192
- const transparent = task._transparentBindings;
193
- let pass = beginTaskPass(task, null, sampleCount, false);
194
- let draws = drawBaseTask(task, pass);
195
- let lastPipeline = null;
196
- for (let i = 0; i < transparent.length; i++) {
197
- const binding = transparent[i];
198
- const transmissive = binding.renderable._transmissive === true;
199
- if (transmissive && canUpdateTransmission(state)) {
200
- pass.end();
201
- updateTransmissionTexture(state, engine);
202
- pass = beginTaskPass(task, null, sampleCount, true);
203
- setPassState(task, pass);
204
- lastPipeline = null;
205
- }
206
- const mesh = binding.renderable.mesh;
207
- if (mesh && mesh.visible === false) {
208
- continue;
209
- }
210
- if (binding.pipeline !== lastPipeline) {
211
- pass.setPipeline(binding.pipeline);
212
- lastPipeline = binding.pipeline;
213
- }
214
- draws += binding.draw(pass, engine);
215
- }
216
- pass.end();
217
- return draws;
218
- }
219
- function updateTransmissionTexture(state, engine) {
220
- if (!state._sourceTexture) {
221
- throw new Error("No transmission source");
222
- }
223
- if (state._blit) {
224
- blitToTransmission(state, engine);
225
- } else {
226
- engine._currentEncoder.copyTextureToTexture(
227
- { texture: state._sourceTexture },
228
- { texture: state.texture.texture },
229
- { width: state.texture.width, height: state.texture.height }
230
- );
231
- }
232
- if (state._generateMipmaps) {
233
- recordMipmaps(engine, state.texture.texture, engine._currentEncoder);
234
- }
235
- state._copies++;
236
- }
237
- function getBlitPipeline(engine, format, multisampled) {
238
- const device = engine._device;
239
- if (device !== blitDevice) {
240
- blitPipelines == null ? void 0 : blitPipelines.clear();
241
- blitPipelines = null;
242
- blitShader = null;
243
- blitMsaaShader = null;
244
- blitBgl = null;
245
- blitMsaaBgl = null;
246
- blitDevice = device;
247
- }
248
- if (multisampled) {
249
- blitMsaaShader ?? (blitMsaaShader = device.createShaderModule({ code: BLIT_MSAA_SHADER }));
250
- blitMsaaBgl ?? (blitMsaaBgl = device.createBindGroupLayout({
251
- entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "unfilterable-float", multisampled: true } }]
252
- }));
253
- } else {
254
- blitShader ?? (blitShader = device.createShaderModule({ code: BLIT_SHADER }));
255
- blitBgl ?? (blitBgl = device.createBindGroupLayout({
256
- entries: [
257
- { binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "float" } },
258
- { binding: 1, visibility: GPUShaderStage.FRAGMENT, sampler: {} }
259
- ]
260
- }));
261
- }
262
- blitPipelines ?? (blitPipelines = /* @__PURE__ */ new Map());
263
- const key = `${format}:${multisampled ? "msaa" : ""}`;
264
- let pipeline = blitPipelines.get(key);
265
- if (!pipeline) {
266
- const bgl = multisampled ? blitMsaaBgl : blitBgl;
267
- pipeline = device.createRenderPipeline({
268
- label: "transmission-copy",
269
- layout: device.createPipelineLayout({ bindGroupLayouts: [bgl] }),
270
- vertex: { module: multisampled ? blitMsaaShader : blitShader, entryPoint: "vs" },
271
- fragment: { module: multisampled ? blitMsaaShader : blitShader, entryPoint: "fs", targets: [{ format }] },
272
- primitive: { topology: "triangle-list" }
273
- });
274
- blitPipelines.set(key, pipeline);
275
- }
276
- return pipeline;
277
- }
278
- function shouldBlitTransmission(state, sampleCount) {
279
- return sampleCount > 1 || state._sourceWidth !== state.texture.width || state._sourceHeight !== state.texture.height;
280
- }
281
- function createTransmissionBlit(state, engine, source, multisampled) {
282
- const device = engine._device;
283
- const pipeline = getBlitPipeline(engine, state.texture.texture.format, multisampled);
284
- const bindGroup = device.createBindGroup({
285
- layout: multisampled ? blitMsaaBgl : blitBgl,
286
- entries: multisampled ? [{ binding: 0, resource: source.createView() }] : [
287
- { binding: 0, resource: source.createView() },
288
- { binding: 1, resource: getBilinearSampler(engine) }
289
- ]
290
- });
291
- return { _pipeline: pipeline, _bindGroup: bindGroup };
292
- }
293
- function blitToTransmission(state, engine) {
294
- const blit = state._blit;
295
- const pass = engine._currentEncoder.beginRenderPass({
296
- colorAttachments: [{ view: state._baseView, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
297
- });
298
- pass.setPipeline(blit._pipeline);
299
- pass.setBindGroup(0, blit._bindGroup);
300
- pass.draw(3);
301
- pass.end();
302
- }
303
- function canUpdateTransmission(state) {
304
- return state._copyCount === 0 || state._copies < state._copyCount;
305
- }
306
- function beginTaskPass(task, resolveTarget, sampleCount, load) {
307
- const att = task._colorAttachment;
308
- const depthLoadOp = load || !task._config.clr ? "load" : "clear";
309
- if (load) {
310
- att.loadOp = "load";
311
- }
312
- const depthAttachment = task._renderPassDescriptor.depthStencilAttachment;
313
- if (depthAttachment) {
314
- depthAttachment.depthLoadOp = depthLoadOp;
315
- if (depthAttachment.stencilLoadOp) {
316
- depthAttachment.stencilLoadOp = depthLoadOp;
317
- }
318
- }
319
- if (sampleCount > 1) {
320
- att.resolveTarget = void 0;
321
- } else {
322
- att.resolveTarget = void 0;
323
- }
324
- return task.engine._currentEncoder.beginRenderPass(task._renderPassDescriptor);
325
- }
326
- function setPassState(task, pass) {
327
- const cfg = task._config;
328
- const rt = cfg.rt;
329
- const scene = task.scene;
330
- const camera = cfg.cam ?? scene.camera;
331
- const v = camera == null ? void 0 : camera.viewport;
332
- if (v) {
333
- const rw = rt._width;
334
- const rh = rt._height;
335
- const x = Math.floor(v.x * rw);
336
- const y = Math.floor((1 - v.y - v.height) * rh);
337
- const w = Math.ceil((v.x + v.width) * rw) - x;
338
- const h = Math.ceil((1 - v.y) * rh) - y;
339
- pass.setViewport(x, y, w, h, 0, 1);
340
- pass.setScissorRect(x, y, w, h);
341
- }
342
- pass.setBindGroup(0, task._sceneBG);
343
- }
344
- function drawBaseTask(task, pass) {
345
- const eng = task.engine;
346
- const rt = task._config.rt;
347
- const scene = task.scene;
348
- const opaqueBindings = task._opaqueBindings;
349
- const opaqueBundles = task._opaqueBundles;
350
- setPassState(task, pass);
351
- if (task._lastVersion !== scene._renderableVersion || task._lastVis !== _vis || opaqueBundles.length === 0) {
352
- const desc = rt._descriptor;
353
- const be = eng._device.createRenderBundleEncoder({
354
- colorFormats: desc.colorFormat ? [desc.colorFormat] : [],
355
- depthStencilFormat: desc.depthStencilFormat,
356
- sampleCount: desc.sampleCount ?? 1
357
- });
358
- be.setBindGroup(0, task._sceneBG);
359
- drawList(be, opaqueBindings, eng);
360
- opaqueBundles[0] = be.finish();
361
- task._lastVersion = scene._renderableVersion;
362
- task._lastVis = _vis;
363
- }
364
- let draws = opaqueBindings.length;
365
- pass.executeBundles(opaqueBundles);
366
- pass.setBindGroup(0, task._sceneBG);
367
- draws += drawList(pass, task._directBindings, eng);
368
- return draws;
369
- }
370
- function drawList(enc, list, engine) {
371
- let lp = null;
372
- let draws = 0;
373
- for (const b of list) {
374
- const mesh = b.renderable.mesh;
375
- if (mesh && mesh.visible === false) {
376
- continue;
377
- }
378
- if (b.pipeline !== lp) {
379
- enc.setPipeline(b.pipeline);
380
- lp = b.pipeline;
381
- }
382
- draws += b.draw(enc, engine);
383
- }
384
- return draws;
385
- }
386
- function normalizeCopyCount(cfg) {
387
- const count = (cfg == null ? void 0 : cfg.copyCount) ?? 1;
388
- return count === Infinity ? 0 : Math.max(0, count | 0);
389
- }
390
- function shouldGenerateMipmaps(cfg) {
391
- return (cfg == null ? void 0 : cfg.generateMipmaps) !== false;
392
- }
393
- const LINEAR_IMAGE_PROCESSING_SLOTS = { NI: `if(scene.vImageInfos.w>=0.0){`, BC: `}` };
394
- function makeRefractionMod(hasVolume, hasMap, hasThicknessMap, useGltfThicknessChannel, hasDispersion, dispersionSampleWgsl) {
395
- const thicknessScaleLine = hasVolume || hasThicknessMap ? `let ts=max(length(mesh.world[0].xyz),max(length(mesh.world[1].xyz),length(mesh.world[2].xyz)));` : ``;
396
- const thicknessLine = hasThicknessMap ? `let ths=textureSample(thicknessTexture_,thicknessSampler_,input.uv).${useGltfThicknessChannel ? "g" : "r"};
397
- let th=(material.thicknessParams.x+ths*material.thicknessParams.y)*ts;` : hasVolume ? `let th=material.refractionParams.z*ts;` : `let th=material.refractionParams.z;`;
398
- const textureLine = hasMap ? `let ri=material.refractionParams.x*textureSample(refractionMapTexture,refractionMapSampler,input.uv).r;` : `let ri=material.refractionParams.x;`;
399
- const absorptionLine = hasVolume ? `let ab=exp(material.volumeParams.rgb*th);` : ``;
400
- const refractionLine = hasVolume ? `let fr=er*surfaceAlbedo*(ri*ab)*(vec3<f32>(1.0)-colorSpecularEnvReflectance.rgb);` : `let fr=er*surfaceAlbedo*ri*(vec3<f32>(1.0)-colorSpecularEnvReflectance.rgb);`;
401
- const sampleLines = hasDispersion && dispersionSampleWgsl ? dispersionSampleWgsl : `let rd=refract(-V,N,material.refractionParams.y);
402
- let cp=scene.viewProjection*vec4<f32>(input.worldPos+rd*th,1.0);
403
- let ruv=(cp.xy/cp.w)*vec2<f32>(0.5,-0.5)+vec2<f32>(0.5,0.5);
404
- let er=textureSampleLevel(refractionTexture,refractionSampler_,ruv,lv).rgb*material.environmentIntensity;`;
405
- return `{
406
- ${thicknessScaleLine}
407
- ${textureLine}
408
- ${thicknessLine}
409
- let ro=1.0-ri;
410
- let ra=mix(alphaG,0.0,clamp(material.refractionParams.w*3.0-2.0,0.0,1.0));
411
- let lv=clamp(log2(f32(textureDimensions(refractionTexture).x)*ra)-4.0,0.0,f32(textureNumLevels(refractionTexture)-1));
412
- ${sampleLines}
413
- ${absorptionLine}
414
- ${refractionLine}
415
- color=finalIrradiance*ro*ro+finalRadianceScaled+finalSpecularScaled+directDiffuse*ro*ro+fr+emissive;
416
- }`;
417
- }
418
- function createRefractionRttFragment(hasVolume, hasMap, hasThicknessMap, useGltfThicknessChannel, linearImageProcessing, hasDispersion, dispersionSampleWgsl) {
419
- const uboFields = [{ _name: "refractionParams", _type: "vec4<f32>" }];
420
- if (hasVolume) {
421
- uboFields.push({ _name: "volumeParams", _type: "vec4<f32>" });
422
- }
423
- if (hasThicknessMap) {
424
- uboFields.push({ _name: "thicknessParams", _type: "vec4<f32>" });
425
- }
426
- const bindings = [
427
- { _name: "refractionTexture", _type: { _kind: "texture", _textureType: "texture_2d<f32>" }, _visibility: 2 },
428
- { _name: "refractionSampler_", _type: { _kind: "sampler", _samplerType: "sampler" }, _visibility: 2 }
429
- ];
430
- if (hasMap) {
431
- bindings.push(
432
- { _name: "refractionMapTexture", _type: { _kind: "texture", _textureType: "texture_2d<f32>" }, _visibility: 2 },
433
- { _name: "refractionMapSampler", _type: { _kind: "sampler", _samplerType: "sampler" }, _visibility: 2 }
434
- );
435
- }
436
- if (hasThicknessMap) {
437
- bindings.push(
438
- { _name: "thicknessTexture_", _type: { _kind: "texture", _textureType: "texture_2d<f32>" }, _visibility: 2 },
439
- { _name: "thicknessSampler_", _type: { _kind: "sampler", _samplerType: "sampler" }, _visibility: 2 }
440
- );
441
- }
442
- return {
443
- _id: "refraction",
444
- _dependencies: ["ibl"],
445
- _uboFields: uboFields,
446
- _bindings: bindings,
447
- _fragmentSlots: linearImageProcessing ? { AI: makeRefractionMod(hasVolume, hasMap, hasThicknessMap, useGltfThicknessChannel, hasDispersion, dispersionSampleWgsl), ...LINEAR_IMAGE_PROCESSING_SLOTS } : { AI: makeRefractionMod(hasVolume, hasMap, hasThicknessMap, useGltfThicknessChannel, hasDispersion, dispersionSampleWgsl) }
448
- };
449
- }
450
- function writeRefractionUBO(data, mat, offsets) {
451
- var _a, _b;
452
- const ss = mat.subsurface;
453
- const refr = ss == null ? void 0 : ss.refraction;
454
- if (!refr) {
455
- return;
456
- }
457
- const off = offsets.get("refractionParams");
458
- if (off === void 0) {
459
- return;
460
- }
461
- const o = off / 4;
462
- data[o] = refr.intensity ?? 0;
463
- const ior = refr.indexOfRefraction ?? 1.5;
464
- const thick = ss.thickness;
465
- data[o + 1] = 1 / (refr.useThicknessAsDepth && (thick == null ? void 0 : thick.max) ? ior : 1);
466
- data[o + 2] = refr.useThicknessAsDepth ? (thick == null ? void 0 : thick.max) ?? 0 : 1;
467
- data[o + 3] = 1 / ior;
468
- const vOff = offsets.get("volumeParams");
469
- if (vOff !== void 0) {
470
- const vo = vOff / 4;
471
- const tint = ((_a = ss.tint) == null ? void 0 : _a.color) ?? [1, 1, 1];
472
- const dist = Math.max(((_b = ss.tint) == null ? void 0 : _b.atDistance) ?? 1, 1e-4);
473
- data[vo] = Math.log(Math.max(tint[0], 1e-6)) / dist;
474
- data[vo + 1] = Math.log(Math.max(tint[1], 1e-6)) / dist;
475
- data[vo + 2] = Math.log(Math.max(tint[2], 1e-6)) / dist;
476
- data[vo + 3] = refr.dispersion ?? 0;
477
- }
478
- const tOff = offsets.get("thicknessParams");
479
- if (tOff !== void 0) {
480
- const to = tOff / 4;
481
- const min = (thick == null ? void 0 : thick.min) ?? 0;
482
- const max = (thick == null ? void 0 : thick.max) ?? 1;
483
- data[to] = min;
484
- data[to + 1] = max - min;
485
- }
486
- }
487
- function makeRefractionRttExt(dispersionSampleWgsl) {
488
- return {
489
- id: "refraction",
490
- phase: "fragment",
491
- detect(mat) {
492
- var _a, _b, _c;
493
- const m = mat;
494
- const ss = m.subsurface;
495
- const refr = ss == null ? void 0 : ss.refraction;
496
- const linearImageProcessing = m._linearImageProcessing ? PBR2_LINEAR_IMAGE_PROCESSING : 0;
497
- const intensity = m.transmissive ? (refr == null ? void 0 : refr.intensity) ?? 0 : 0;
498
- if (intensity <= 0) {
499
- return { f: 0, f2: linearImageProcessing };
500
- }
501
- let f = 0;
502
- let f2 = linearImageProcessing | PBR2_HAS_REFRACTION;
503
- if (refr == null ? void 0 : refr.texture) {
504
- f2 |= PBR2_HAS_REFRACTION_MAP;
505
- }
506
- if ((_a = ss == null ? void 0 : ss.thickness) == null ? void 0 : _a.texture) {
507
- f |= PBR_HAS_THICKNESS_MAP;
508
- }
509
- if ((_b = ss == null ? void 0 : ss.thickness) == null ? void 0 : _b.useGlTFChannel) {
510
- f2 |= PBR2_HAS_THICKNESS_GLTF_CHANNEL;
511
- }
512
- if (((_c = ss == null ? void 0 : ss.tint) == null ? void 0 : _c.atDistance) !== void 0) {
513
- f2 |= PBR2_HAS_VOLUME;
514
- if (refr == null ? void 0 : refr.dispersion) {
515
- f2 |= PBR2_HAS_DISPERSION;
516
- }
517
- }
518
- return { f, f2 };
519
- },
520
- frag(ctx) {
521
- const linearImageProcessing = (ctx._features2 & PBR2_LINEAR_IMAGE_PROCESSING) !== 0;
522
- if (!(ctx._features2 & PBR2_HAS_REFRACTION)) {
523
- return linearImageProcessing ? { _id: "linear", _fragmentSlots: LINEAR_IMAGE_PROCESSING_SLOTS } : null;
524
- }
525
- return createRefractionRttFragment(
526
- (ctx._features2 & PBR2_HAS_VOLUME) !== 0,
527
- (ctx._features2 & PBR2_HAS_REFRACTION_MAP) !== 0,
528
- (ctx._features & PBR_HAS_THICKNESS_MAP) !== 0,
529
- (ctx._features2 & PBR2_HAS_THICKNESS_GLTF_CHANNEL) !== 0,
530
- linearImageProcessing,
531
- (ctx._features2 & PBR2_HAS_DISPERSION) !== 0,
532
- dispersionSampleWgsl
533
- );
534
- },
535
- writeUbo(data, mat, offsets) {
536
- writeRefractionUBO(data, mat, offsets);
537
- },
538
- bind(ctx, entries, b) {
539
- var _a, _b, _c, _d;
540
- if (!(ctx._features2 & PBR2_HAS_REFRACTION)) {
541
- return b;
542
- }
543
- const texture = ctx._refractionTexture;
544
- if (!texture) {
545
- throw new Error("PBR transmission requires a frame-graph refraction texture.");
546
- }
547
- entries.push({ binding: b++, resource: texture.view });
548
- entries.push({ binding: b++, resource: texture.sampler });
549
- if ((ctx._features2 & PBR2_HAS_REFRACTION_MAP) !== 0) {
550
- const map = (_b = (_a = ctx._material.subsurface) == null ? void 0 : _a.refraction) == null ? void 0 : _b.texture;
551
- entries.push({ binding: b++, resource: map.view });
552
- entries.push({ binding: b++, resource: getTrilinearAnisotropicSampler(ctx._engine) });
553
- }
554
- if ((ctx._features & PBR_HAS_THICKNESS_MAP) !== 0) {
555
- const thickness = (_d = (_c = ctx._material.subsurface) == null ? void 0 : _c.thickness) == null ? void 0 : _d.texture;
556
- entries.push({ binding: b++, resource: thickness.view });
557
- entries.push({ binding: b++, resource: thickness.sampler });
558
- }
559
- return b;
560
- },
561
- textures(mat, out) {
562
- var _a, _b, _c, _d;
563
- const tex = (_b = (_a = mat.subsurface) == null ? void 0 : _a.refraction) == null ? void 0 : _b.texture;
564
- if (tex) {
565
- out.push(tex);
566
- }
567
- const thickness = (_d = (_c = mat.subsurface) == null ? void 0 : _c.thickness) == null ? void 0 : _d.texture;
568
- if (thickness) {
569
- out.push(thickness);
570
- }
571
- }
572
- };
573
- }
574
- function registerPbrTransmission(scene, engine, register, dispersionSampleWgsl) {
575
- enableSceneTransmission(scene, engine);
576
- register(makeRefractionRttExt(dispersionSampleWgsl));
577
- }
578
- export {
579
- registerPbrTransmission
580
- };
581
- //# sourceMappingURL=pbr-transmission-ext-BxW4CEGu.js.map