@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.
- package/_mat4-storage-f64-Bvh5TymE.js +10 -0
- package/_mat4-storage-f64-Bvh5TymE.js.map +1 -0
- package/{alpha-test-fragment-CUiHCw7W.js → alpha-test-fragment-BCChpzaV.js} +2 -2
- package/{alpha-test-fragment-CUiHCw7W.js.map → alpha-test-fragment-BCChpzaV.js.map} +1 -1
- package/{background-dds-skybox-yHTqabU3.js → background-dds-skybox-ZjrSIxrT.js} +4 -4
- package/background-dds-skybox-ZjrSIxrT.js.map +1 -0
- package/{background-ground-DIw6D3qf.js → background-ground-B2Mie-MI.js} +3 -3
- package/background-ground-B2Mie-MI.js.map +1 -0
- package/{background-hdr-skybox-c4uuTmkP.js → background-hdr-skybox-DDRJYuT2.js} +3 -3
- package/background-hdr-skybox-DDRJYuT2.js.map +1 -0
- package/{background-solid-skybox-DPGBpPbm.js → background-solid-skybox-fjXlnWaD.js} +3 -3
- package/{background-solid-skybox-DPGBpPbm.js.map → background-solid-skybox-fjXlnWaD.js.map} +1 -1
- package/{billboard-renderable-D8mlVGCd.js → billboard-renderable-DKmlOgbM.js} +2 -2
- package/{billboard-renderable-D8mlVGCd.js.map → billboard-renderable-DKmlOgbM.js.map} +1 -1
- package/{clamp-block-BdII67hT.js → clamp-block-CxRBPlUq.js} +2 -2
- package/{clamp-block-BdII67hT.js.map → clamp-block-CxRBPlUq.js.map} +1 -1
- package/{clearcoat-fragment-LCiG98Rf.js → clearcoat-fragment-KbZAa0TA.js} +2 -2
- package/{clearcoat-fragment-LCiG98Rf.js.map → clearcoat-fragment-KbZAa0TA.js.map} +1 -1
- package/{create-skeleton-C9JdIJnb.js → create-skeleton-BBI5urcj.js} +2 -2
- package/{create-skeleton-C9JdIJnb.js.map → create-skeleton-BBI5urcj.js.map} +1 -1
- package/{cubemap-skybox-material-DvXMVc4k.js → cubemap-skybox-material-DvW81drX.js} +2 -2
- package/{cubemap-skybox-material-DvXMVc4k.js.map → cubemap-skybox-material-DvW81drX.js.map} +1 -1
- package/{curve-block-BlJpXVYv.js → curve-block-Dh_xdUj-.js} +2 -2
- package/{curve-block-BlJpXVYv.js.map → curve-block-Dh_xdUj-.js.map} +1 -1
- package/{emissive-fragment-BnNvbBCw.js → emissive-fragment-DD8cvHyx.js} +2 -2
- package/{emissive-fragment-BnNvbBCw.js.map → emissive-fragment-DD8cvHyx.js.map} +1 -1
- package/{esm-shadow-view-DGKdF1NI.js → esm-shadow-view-15S4JK6p.js} +2 -2
- package/{esm-shadow-view-DGKdF1NI.js.map → esm-shadow-view-15S4JK6p.js.map} +1 -1
- package/{esm-shadow-view-Dk9NFtLq.js → esm-shadow-view-DHVS9r7H.js} +2 -2
- package/{esm-shadow-view-Dk9NFtLq.js.map → esm-shadow-view-DHVS9r7H.js.map} +1 -1
- package/{esm-shadow-view-DN9HIaM4.js → esm-shadow-view-DYAc62Kl.js} +2 -2
- package/{esm-shadow-view-DN9HIaM4.js.map → esm-shadow-view-DYAc62Kl.js.map} +1 -1
- package/{gaussian-splatting-pipeline-sh-DgJl7l56.js → gaussian-splatting-pipeline-sh-BvkUhA9V.js} +2 -2
- package/{gaussian-splatting-pipeline-sh-DgJl7l56.js.map → gaussian-splatting-pipeline-sh-BvkUhA9V.js.map} +1 -1
- package/{gltf-animation-D7uyTyO3.js → gltf-animation-KnPzeOIY.js} +3 -3
- package/{gltf-animation-D7uyTyO3.js.map → gltf-animation-KnPzeOIY.js.map} +1 -1
- package/gltf-color-normalize-Qxl-9C48.js +29 -0
- package/gltf-color-normalize-Qxl-9C48.js.map +1 -0
- package/{gltf-ext-basisu-CPg5kPrx.js → gltf-ext-basisu-kmth3UWX.js} +7 -4
- package/gltf-ext-basisu-kmth3UWX.js.map +1 -0
- package/{gltf-ext-node-visibility-MafA9ot2.js → gltf-ext-node-visibility-BjRRd6si.js} +2 -2
- package/{gltf-ext-node-visibility-MafA9ot2.js.map → gltf-ext-node-visibility-BjRRd6si.js.map} +1 -1
- package/{gltf-ext-uv-transform-CE_-T1Tr.js → gltf-ext-uv-transform-MHmR-YyM.js} +2 -2
- package/{gltf-ext-uv-transform-CE_-T1Tr.js.map → gltf-ext-uv-transform-MHmR-YyM.js.map} +1 -1
- package/{gltf-feature-animation-pointer-BjpwOOqo.js → gltf-feature-animation-pointer-rFqLfbO_.js} +3 -3
- package/{gltf-feature-animation-pointer-BjpwOOqo.js.map → gltf-feature-animation-pointer-rFqLfbO_.js.map} +1 -1
- package/{gltf-feature-animations-CCizegp8.js → gltf-feature-animations-DikONdzi.js} +2 -2
- package/{gltf-feature-animations-CCizegp8.js.map → gltf-feature-animations-DikONdzi.js.map} +1 -1
- package/{gltf-feature-gpu-instancing-2e_CFQnl.js → gltf-feature-gpu-instancing-Cj1XjmM6.js} +5 -4
- package/gltf-feature-gpu-instancing-Cj1XjmM6.js.map +1 -0
- package/{gltf-feature-lights-punctual-DDDg4j0U.js → gltf-feature-lights-punctual-C-0SlGmD.js} +5 -5
- package/{gltf-feature-lights-punctual-DDDg4j0U.js.map → gltf-feature-lights-punctual-C-0SlGmD.js.map} +1 -1
- package/{gltf-feature-morph-CKCw6tkX.js → gltf-feature-morph-BAcY14XU.js} +3 -3
- package/{gltf-feature-morph-CKCw6tkX.js.map → gltf-feature-morph-BAcY14XU.js.map} +1 -1
- package/gltf-feature-registry-97sY_x5O.js +59 -0
- package/gltf-feature-registry-97sY_x5O.js.map +1 -0
- package/{gltf-feature-skeleton-D8hWLqi2.js → gltf-feature-skeleton-lVjkDfIU.js} +3 -3
- package/{gltf-feature-skeleton-D8hWLqi2.js.map → gltf-feature-skeleton-lVjkDfIU.js.map} +1 -1
- package/{gltf-feature-variants-Ds6v9byg.js → gltf-feature-variants-BphF4JmV.js} +2 -2
- package/{gltf-feature-variants-Ds6v9byg.js.map → gltf-feature-variants-BphF4JmV.js.map} +1 -1
- package/{gltf-interleave-DGnUlz28.js → gltf-interleave-C9eBqH_F.js} +2 -2
- package/{gltf-interleave-DGnUlz28.js.map → gltf-interleave-C9eBqH_F.js.map} +1 -1
- package/gltf-normals-b2h74380.js +37 -0
- package/gltf-normals-b2h74380.js.map +1 -0
- package/{gltf-pbr-builder-ext-BFOxOCnQ.js → gltf-pbr-builder-ext-DPC0zg_u.js} +2 -2
- package/{gltf-pbr-builder-ext-BFOxOCnQ.js.map → gltf-pbr-builder-ext-DPC0zg_u.js.map} +1 -1
- package/{gltf-variants-DFbr8EES.js → gltf-variants-CnBEZr0o.js} +4 -4
- package/{gltf-variants-DFbr8EES.js.map → gltf-variants-CnBEZr0o.js.map} +1 -1
- package/{gs-picking-pipeline-DzfMASL9.js → gs-picking-pipeline-Bx8LTav6.js} +2 -2
- package/{gs-picking-pipeline-DzfMASL9.js.map → gs-picking-pipeline-Bx8LTav6.js.map} +1 -1
- package/{index-C8HOR2sB.js → index-B7Qhw0xL.js} +3047 -1037
- package/index-B7Qhw0xL.js.map +1 -0
- package/index.d.ts +504 -17
- package/index.js +322 -304
- package/{input-block-DgAJBzN_.js → input-block-Coi_aZwl.js} +2 -2
- package/{input-block-DgAJBzN_.js.map → input-block-Coi_aZwl.js.map} +1 -1
- package/{iridescence-fragment-Gymp7or5.js → iridescence-fragment-DwZcCTdD.js} +2 -2
- package/{iridescence-fragment-Gymp7or5.js.map → iridescence-fragment-DwZcCTdD.js.map} +1 -1
- package/{light-block-B11ew7FA.js → light-block-Np_h5gPI.js} +2 -2
- package/{light-block-B11ew7FA.js.map → light-block-Np_h5gPI.js.map} +1 -1
- package/{loop-block-Bb23EOMb.js → loop-block-BFkLFYGm.js} +2 -2
- package/{loop-block-Bb23EOMb.js.map → loop-block-BFkLFYGm.js.map} +1 -1
- package/{mesh-features-BLENkYVt.js → mesh-features-BAJpbMog.js} +6 -3
- package/mesh-features-BAJpbMog.js.map +1 -0
- package/{morph-fragment-DOVo70gP.js → morph-fragment-DqH-w61u.js} +2 -2
- package/{morph-fragment-DOVo70gP.js.map → morph-fragment-DqH-w61u.js.map} +1 -1
- package/{multilight-wgsl-BGyiIOp3.js → multilight-wgsl-B9Mf9d-q.js} +4 -4
- package/{multilight-wgsl-BGyiIOp3.js.map → multilight-wgsl-B9Mf9d-q.js.map} +1 -1
- package/no-color-view-DsyLSL-W.js +8 -0
- package/no-color-view-DsyLSL-W.js.map +1 -0
- package/{node-registry-DwgC4yth.js → node-registry-Bd-AlrgC.js} +8 -8
- package/{node-registry-DwgC4yth.js.map → node-registry-Bd-AlrgC.js.map} +1 -1
- package/{node-registry-extra-compat-Dhrw8fDQ.js → node-registry-extra-compat-Ch7ApZHF.js} +2 -2
- package/{node-registry-extra-compat-Dhrw8fDQ.js.map → node-registry-extra-compat-Ch7ApZHF.js.map} +1 -1
- package/{node-registry-extra-math-CsAHvIZo.js → node-registry-extra-math-6ezzTkPj.js} +2 -2
- package/{node-registry-extra-math-CsAHvIZo.js.map → node-registry-extra-math-6ezzTkPj.js.map} +1 -1
- package/{node-renderable-DlLIdBmd.js → node-renderable-CS0CmsSp.js} +28 -11
- package/node-renderable-CS0CmsSp.js.map +1 -0
- package/{node-shadow-DKrcqmNg.js → node-shadow-CpnrdvtJ.js} +2 -2
- package/{node-shadow-DKrcqmNg.js.map → node-shadow-CpnrdvtJ.js.map} +1 -1
- package/{normal-map-fragment-DpsIXrJf.js → normal-map-fragment-DradEMl-.js} +3 -3
- package/{normal-map-fragment-DpsIXrJf.js.map → normal-map-fragment-DradEMl-.js.map} +1 -1
- package/pack-mat4-with-offset-BqB8Jqo7.js +37 -0
- package/pack-mat4-with-offset-BqB8Jqo7.js.map +1 -0
- package/package.json +3 -3
- package/{parse-camera-DM3oJJeT.js → parse-camera-CgV4bWc0.js} +2 -2
- package/{parse-camera-DM3oJJeT.js.map → parse-camera-CgV4bWc0.js.map} +1 -1
- package/pbr-fog-wgsl-BqdCid6r.js +8 -0
- package/pbr-fog-wgsl-BqdCid6r.js.map +1 -0
- package/{pbr-metallic-roughness-block-h_KAOZrW.js → pbr-metallic-roughness-block-BFwZj2Nw.js} +2 -2
- package/{pbr-metallic-roughness-block-h_KAOZrW.js.map → pbr-metallic-roughness-block-BFwZj2Nw.js.map} +1 -1
- package/{pbr-metallic-roughness-block-full-6vMm1Jk6.js → pbr-metallic-roughness-block-full-5t0HT3xl.js} +2 -2
- package/{pbr-metallic-roughness-block-full-6vMm1Jk6.js.map → pbr-metallic-roughness-block-full-5t0HT3xl.js.map} +1 -1
- package/{pbr-mr-helper-core-CIwm-T1G.js → pbr-mr-helper-core-R5tOZ8Ap.js} +2 -2
- package/{pbr-mr-helper-core-CIwm-T1G.js.map → pbr-mr-helper-core-R5tOZ8Ap.js.map} +1 -1
- package/{pbr-refraction-DGmMSa2v.js → pbr-refraction-Dd11HnaI.js} +2 -2
- package/{pbr-refraction-DGmMSa2v.js.map → pbr-refraction-Dd11HnaI.js.map} +1 -1
- package/{pbr-renderable-BJxUtPBb.js → pbr-renderable-BHAdF5Vw.js} +80 -38
- package/pbr-renderable-BHAdF5Vw.js.map +1 -0
- package/{pbr-shadow-fragment-LO9SlbJj.js → pbr-shadow-fragment-BxUrFJYZ.js} +6 -1
- package/pbr-shadow-fragment-BxUrFJYZ.js.map +1 -0
- package/{pbr-template-ext-8q7BcTDf.js → pbr-template-ext-CGgB2n2y.js} +3 -2
- package/{pbr-template-ext-8q7BcTDf.js.map → pbr-template-ext-CGgB2n2y.js.map} +1 -1
- package/{pbr-tracking-B3alzn91.js → pbr-tracking-D6i3yPb7.js} +2 -2
- package/{pbr-tracking-B3alzn91.js.map → pbr-tracking-D6i3yPb7.js.map} +1 -1
- package/pbr-transmission-ext-Dll8EYwE.js +190 -0
- package/pbr-transmission-ext-Dll8EYwE.js.map +1 -0
- package/{reflectance-fragment-BCrgPmrt.js → reflectance-fragment-ejMJ4O1o.js} +2 -2
- package/{reflectance-fragment-BCrgPmrt.js.map → reflectance-fragment-ejMJ4O1o.js.map} +1 -1
- package/{shader-renderable-D-6796KR.js → shader-renderable-BMf_vvO0.js} +41 -12
- package/shader-renderable-BMf_vvO0.js.map +1 -0
- package/shader-thin-instance-5_WUfi3m.js +150 -0
- package/shader-thin-instance-5_WUfi3m.js.map +1 -0
- package/shadow-fragment-core-DHN2G6FI.js.map +1 -1
- package/{sheen-fragment-Dze2f7XJ.js → sheen-fragment-CS6z29Fs.js} +2 -2
- package/{sheen-fragment-Dze2f7XJ.js.map → sheen-fragment-CS6z29Fs.js.map} +1 -1
- package/{singlelight-directional-wgsl-CmUDZxwz.js → singlelight-directional-wgsl-4MIgZMeC.js} +2 -2
- package/{singlelight-directional-wgsl-CmUDZxwz.js.map → singlelight-directional-wgsl-4MIgZMeC.js.map} +1 -1
- package/{singlelight-hemispheric-wgsl-t-83IP_s.js → singlelight-hemispheric-wgsl-CK-GUYWe.js} +2 -2
- package/{singlelight-hemispheric-wgsl-t-83IP_s.js.map → singlelight-hemispheric-wgsl-CK-GUYWe.js.map} +1 -1
- package/{singlelight-point-wgsl-CLzULIYV.js → singlelight-point-wgsl-CYtzqCbP.js} +2 -2
- package/{singlelight-point-wgsl-CLzULIYV.js.map → singlelight-point-wgsl-CYtzqCbP.js.map} +1 -1
- package/{singlelight-spot-wgsl-DEEUrfVM.js → singlelight-spot-wgsl-DVbaVufF.js} +2 -2
- package/{singlelight-spot-wgsl-DEEUrfVM.js.map → singlelight-spot-wgsl-DVbaVufF.js.map} +1 -1
- package/{skeleton-fragment-B_XlFbtx.js → skeleton-fragment-BOVmc8YS.js} +2 -2
- package/{skeleton-fragment-B_XlFbtx.js.map → skeleton-fragment-BOVmc8YS.js.map} +1 -1
- package/{skybox-renderable-DDwzu-PT.js → skybox-renderable-DDcCPSly.js} +3 -3
- package/{skybox-renderable-DDwzu-PT.js.map → skybox-renderable-DDcCPSly.js.map} +1 -1
- package/{standard-renderable-GjxL9xSf.js → standard-renderable-D1bhoF0K.js} +27 -81
- package/standard-renderable-D1bhoF0K.js.map +1 -0
- package/{std-ambient-fragment-BoUsD06w.js → std-ambient-fragment-C6WNm8dQ.js} +2 -2
- package/{std-ambient-fragment-BoUsD06w.js.map → std-ambient-fragment-C6WNm8dQ.js.map} +1 -1
- package/{std-cube-reflection-fragment-ulqc3bsP.js → std-cube-reflection-fragment-Bqutpy2q.js} +2 -2
- package/{std-cube-reflection-fragment-ulqc3bsP.js.map → std-cube-reflection-fragment-Bqutpy2q.js.map} +1 -1
- package/{std-emissive-fragment-DNGj1HdQ.js → std-emissive-fragment-B-A83rqX.js} +2 -2
- package/{std-emissive-fragment-DNGj1HdQ.js.map → std-emissive-fragment-B-A83rqX.js.map} +1 -1
- package/{std-lightmap-fragment-Bqj89aIe.js → std-lightmap-fragment-Df7KJezh.js} +2 -2
- package/{std-lightmap-fragment-Bqj89aIe.js.map → std-lightmap-fragment-Df7KJezh.js.map} +1 -1
- package/{std-opacity-fragment-KuPh5N2Z.js → std-opacity-fragment-D9et2jip.js} +2 -2
- package/{std-opacity-fragment-KuPh5N2Z.js.map → std-opacity-fragment-D9et2jip.js.map} +1 -1
- package/{std-reflection-fragment-BA5Ghn_M.js → std-reflection-fragment-DBJeT-yg.js} +2 -2
- package/{std-reflection-fragment-BA5Ghn_M.js.map → std-reflection-fragment-DBJeT-yg.js.map} +1 -1
- package/std-shadow-fragment-C6fD8rW-.js +13 -0
- package/std-shadow-fragment-C6fD8rW-.js.map +1 -0
- package/{std-specular-fragment-CE-6scqd.js → std-specular-fragment-C2ZOss-t.js} +2 -2
- package/{std-specular-fragment-CE-6scqd.js.map → std-specular-fragment-C2ZOss-t.js.map} +1 -1
- package/{std-tracking-CNKZ-hJN.js → std-tracking-C4L4nQGc.js} +2 -2
- package/{std-tracking-CNKZ-hJN.js.map → std-tracking-C4L4nQGc.js.map} +1 -1
- package/{subsurface-fragment-liM3y2-P.js → subsurface-fragment-C1H4ytqK.js} +2 -2
- package/{subsurface-fragment-liM3y2-P.js.map → subsurface-fragment-C1H4ytqK.js.map} +1 -1
- package/thin-instance-cull-binding-CCxrPNO6.js +310 -0
- package/thin-instance-cull-binding-CCxrPNO6.js.map +1 -0
- package/{thin-instance-gpu-C9Gv_Z1w.js → thin-instance-gpu-E8DBd8XL.js} +20 -3
- package/thin-instance-gpu-E8DBd8XL.js.map +1 -0
- package/{tracking-primitives-wgdBY85t.js → tracking-primitives-w4BVV9p9.js} +2 -2
- package/{tracking-primitives-wgdBY85t.js.map → tracking-primitives-w4BVV9p9.js.map} +1 -1
- package/{unlit-fragment-BIlhJpz6.js → unlit-fragment-DU9_mhzZ.js} +2 -2
- package/{unlit-fragment-BIlhJpz6.js.map → unlit-fragment-DU9_mhzZ.js.map} +1 -1
- package/{wgsl-helpers-DyzNzCeE.js → wgsl-helpers-D8sl1VVA.js} +4 -4
- package/{wgsl-helpers-DyzNzCeE.js.map → wgsl-helpers-D8sl1VVA.js.map} +1 -1
- package/background-dds-skybox-yHTqabU3.js.map +0 -1
- package/background-ground-DIw6D3qf.js.map +0 -1
- package/background-hdr-skybox-c4uuTmkP.js.map +0 -1
- package/gltf-ext-basisu-CPg5kPrx.js.map +0 -1
- package/gltf-feature-gpu-instancing-2e_CFQnl.js.map +0 -1
- package/index-C8HOR2sB.js.map +0 -1
- package/mesh-features-BLENkYVt.js.map +0 -1
- package/node-renderable-DlLIdBmd.js.map +0 -1
- package/pbr-renderable-BJxUtPBb.js.map +0 -1
- package/pbr-shadow-fragment-LO9SlbJj.js.map +0 -1
- package/pbr-transmission-ext-BxW4CEGu.js +0 -581
- package/pbr-transmission-ext-BxW4CEGu.js.map +0 -1
- package/shader-renderable-D-6796KR.js.map +0 -1
- package/standard-renderable-GjxL9xSf.js.map +0 -1
- package/std-shadow-fragment-FNQfrJuC.js +0 -8
- package/std-shadow-fragment-FNQfrJuC.js.map +0 -1
- package/thin-instance-gpu-C9Gv_Z1w.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as MSH_HAS_UV2, d as MSH_HAS_TANGENTS, e as composeShader, f as MSH_RECEIVE_SHADOWS, g as MSH_HAS_THIN_INSTANCES, h as MSH_HAS_VERTEX_COLOR, i as MSH_HAS_INSTANCE_COLOR, b as MSH_HAS_MORPH_TARGETS, _ as _computeMeshFeatures } from "./mesh-features-
|
|
1
|
+
import { bh as _getPbrExtsSorted, ah as PBR2_HAS_UV2, az as PBR_HAS_EMISSIVE, bi as PBR_HAS_SPEC_GLOSS, P as PBR2_ESM_SHADOW_OUTPUT, t as targetSignatureKey, j as getSceneBindGroupLayout, bj as REVERSE_DEPTH_COMPARE, bk as PBR_HAS_NORMAL_MAP, bl as PBR2_NO_COLOR_OUTPUT, C as PBR_HAS_ALPHA_BLEND, bm as PBR_HAS_DOUBLE_SIDED, bn as appendMeshLightUboFields, bo as meshLightIndexWGSL, bp as _getPbrExts, bq as PBR2_HAS_UV_TRANSFORM, br as PBR_HAS_ANISOTROPY, bs as PBR_HAS_SKYBOX, bt as PBR_HAS_SPECULAR_AA, bu as PBR_HAS_ENV, bv as PBR_HAS_FOG, bw as PBR_HAS_OCCLUSION, bx as PBR2_HAS_BASE_COLOR_FACTOR, by as PBR_HAS_GAMMA_ALBEDO, bz as PBR_HAS_TONEMAP, ay as PBR_HAS_EMISSIVE_COLOR, ae as PBR_HAS_METALLIC_REFLECTANCE_MAP, af as PBR_HAS_REFLECTANCE_MAP, ag as PBR2_HAS_REFLECTANCE_FACTORS, a as writeMeshLightSelection, bA as _registerPbrExt, bB as clearSamplerCache, bC as _computePbrMaterialFeatures, p as packMat4IntoF32, a_ as createUniformBuffer, b9 as PBR2_HAS_REFRACTION, bD as collectPbrBoundTextures, b4 as acquireTexture, b5 as releaseTexture } from "./index-B7Qhw0xL.js";
|
|
2
|
+
import { c as MSH_HAS_UV2, d as MSH_HAS_TANGENTS, e as composeShader, f as MSH_RECEIVE_SHADOWS, g as MSH_HAS_THIN_INSTANCES, h as MSH_HAS_VERTEX_COLOR, i as MSH_HAS_INSTANCE_COLOR, b as MSH_HAS_MORPH_TARGETS, _ as _computeMeshFeatures } from "./mesh-features-BAJpbMog.js";
|
|
3
3
|
const _bindingsCache = /* @__PURE__ */ new Map();
|
|
4
4
|
let _cachedDevice = null;
|
|
5
5
|
function ensureDevice(engine) {
|
|
@@ -179,6 +179,8 @@ function createPbrTemplate(config) {
|
|
|
179
179
|
_hasSpecGloss = false,
|
|
180
180
|
_hasDoubleSided = false,
|
|
181
181
|
_hasTonemap = false,
|
|
182
|
+
_fogHelper = "",
|
|
183
|
+
_fogBlock = "",
|
|
182
184
|
_acesHelpers = "",
|
|
183
185
|
_acesTonemapCall = "",
|
|
184
186
|
_hasAlphaBlend = false,
|
|
@@ -362,10 +364,12 @@ var directSpecular=vec3<f32>(0.0);
|
|
|
362
364
|
const acesBlock = useAces ? _acesHelpers : "";
|
|
363
365
|
const tonemapBlock = _hasTonemap ? useAces ? _acesTonemapCall : `color*=scene.vImageInfos.x;
|
|
364
366
|
color=1.0-exp2(-1.590579*color);` : `color*=scene.vImageInfos.x;`;
|
|
367
|
+
const fogHelper = _fogHelper;
|
|
368
|
+
const fogBlock = _fogBlock;
|
|
365
369
|
const alphaBlock = _noColorOutput ? "" : _hasAlphaBlend ? `var finalAlpha=alpha*material.materialAlpha;
|
|
366
370
|
var luminanceOverAlpha=0.0;
|
|
367
371
|
/*BA*/
|
|
368
|
-
luminanceOverAlpha+=dot(${_hasIbl ?
|
|
372
|
+
luminanceOverAlpha+=dot(${_hasIbl ? `finalSpecularScaled` : `directSpecular`},vec3<f32>(0.2126,0.7152,0.0722));
|
|
369
373
|
finalAlpha=saturate(finalAlpha+luminanceOverAlpha*luminanceOverAlpha);
|
|
370
374
|
return vec4<f32>(color,finalAlpha);` : `return vec4<f32>(color,alpha*material.materialAlpha);`;
|
|
371
375
|
const doubleSidedEntry = _hasDoubleSided ? `@fragment fn main(input: FragmentInput, @builtin(front_facing) frontFacing: bool)${_noColorOutput ? "" : " -> @location(0) vec4<f32>"} {` : `@fragment fn main(input: FragmentInput)${_noColorOutput ? "" : " -> @location(0) vec4<f32>"} {`;
|
|
@@ -387,6 +391,7 @@ ${_esmShadowOutput ? "struct shadowParamsUniforms { biasAndScale: vec4<f32>, dep
|
|
|
387
391
|
/*FI*/
|
|
388
392
|
${BRDF_FUNCTIONS}
|
|
389
393
|
${acesBlock}
|
|
394
|
+
${fogHelper}
|
|
390
395
|
${anisoBrdfBlock}
|
|
391
396
|
${lightDecls}
|
|
392
397
|
${lightBindingDecl}
|
|
@@ -417,6 +422,7 @@ ${directLightBlock}
|
|
|
417
422
|
var color=directDiffuse+directSpecular+emissive;
|
|
418
423
|
/*AI*/
|
|
419
424
|
/*NI*/
|
|
425
|
+
${fogBlock}
|
|
420
426
|
${tonemapBlock}
|
|
421
427
|
color=pow(color,vec3<f32>(1.0/2.2));
|
|
422
428
|
color=clamp(color,vec3<f32>(0.0),vec3<f32>(1.0));
|
|
@@ -446,6 +452,8 @@ function createPbrComposer(deps) {
|
|
|
446
452
|
_multiLightLoop,
|
|
447
453
|
_acesHelpers,
|
|
448
454
|
_acesTonemapCall,
|
|
455
|
+
_fogHelper,
|
|
456
|
+
_fogBlock,
|
|
449
457
|
_createPbrTemplateExt,
|
|
450
458
|
_anisoExt,
|
|
451
459
|
_iblSkyboxCalc,
|
|
@@ -499,6 +507,8 @@ function createPbrComposer(deps) {
|
|
|
499
507
|
_hasSpecGloss: has(PBR_HAS_SPEC_GLOSS),
|
|
500
508
|
_hasDoubleSided: has(PBR_HAS_DOUBLE_SIDED),
|
|
501
509
|
_hasTonemap: hasScene(PBR_HAS_TONEMAP),
|
|
510
|
+
_fogHelper: hasScene(PBR_HAS_FOG) ? _fogHelper : "",
|
|
511
|
+
_fogBlock: hasScene(PBR_HAS_FOG) ? _fogBlock : "",
|
|
502
512
|
_acesHelpers,
|
|
503
513
|
_acesTonemapCall,
|
|
504
514
|
_hasAlphaBlend: has(PBR_HAS_ALPHA_BLEND),
|
|
@@ -551,7 +561,7 @@ function createPbrComposer(deps) {
|
|
|
551
561
|
};
|
|
552
562
|
}
|
|
553
563
|
async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
554
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
564
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
555
565
|
const engine = scene.engine;
|
|
556
566
|
const device = engine._device;
|
|
557
567
|
const materialScratch = /* @__PURE__ */ new Map();
|
|
@@ -595,6 +605,7 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
595
605
|
let hasSomeSkeletons = false;
|
|
596
606
|
let hasSomeMorphs = false;
|
|
597
607
|
let hasSomeThinInstances = false;
|
|
608
|
+
let hasCullingTI = false;
|
|
598
609
|
let hasAnyUnlit = false;
|
|
599
610
|
let hasAnyUvTransform = false;
|
|
600
611
|
let hasAnyUv2 = false;
|
|
@@ -616,6 +627,7 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
616
627
|
hasSomeSkeletons || (hasSomeSkeletons = !!m.skeleton);
|
|
617
628
|
hasSomeMorphs || (hasSomeMorphs = !!m.morphTargets);
|
|
618
629
|
hasSomeThinInstances || (hasSomeThinInstances = !!m.thinInstances);
|
|
630
|
+
hasCullingTI || (hasCullingTI = !!((_h = m.thinInstances) == null ? void 0 : _h._gpuCullingEnabled));
|
|
619
631
|
hasAnyUnlit || (hasAnyUnlit = !!mat.unlit);
|
|
620
632
|
hasAnyUvTransform || (hasAnyUvTransform = !!mat._hasUvTx);
|
|
621
633
|
hasAnyUv2 || (hasAnyUv2 = !!m._gpu.uv2Buffer && mat.occlusionTexCoord === 1);
|
|
@@ -648,12 +660,12 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
648
660
|
};
|
|
649
661
|
}
|
|
650
662
|
if (needsMultiLightPath) {
|
|
651
|
-
const wgslMod = await import("./multilight-wgsl-
|
|
663
|
+
const wgslMod = await import("./multilight-wgsl-B9Mf9d-q.js");
|
|
652
664
|
_multiLightWGSL = wgslMod.MULTI_LIGHT_STRUCTS() + wgslMod.COMPUTE_PBR_LIGHT;
|
|
653
665
|
_multiLightLoop = wgslMod.getMultiLightLoop();
|
|
654
666
|
}
|
|
655
667
|
if (hasAnyAffectedLight && hasSomeShadows) {
|
|
656
|
-
const shadowMod = await import("./pbr-shadow-fragment-
|
|
668
|
+
const shadowMod = await import("./pbr-shadow-fragment-BxUrFJYZ.js");
|
|
657
669
|
_createPbrShadowFragment = shadowMod.createPbrShadowFragment;
|
|
658
670
|
}
|
|
659
671
|
const _drainPbrExts = async (loaders) => {
|
|
@@ -664,22 +676,22 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
664
676
|
}
|
|
665
677
|
};
|
|
666
678
|
await _drainPbrExts([
|
|
667
|
-
[hasAlphaTest, () => import("./alpha-test-fragment-
|
|
668
|
-
[hasMetallicReflectance, () => import("./reflectance-fragment-
|
|
669
|
-
[hasClearcoat, () => import("./clearcoat-fragment-
|
|
670
|
-
[hasSheen, () => import("./sheen-fragment-
|
|
671
|
-
[hasIridescence, () => import("./iridescence-fragment-
|
|
672
|
-
[hasAnySubsurface, () => import("./subsurface-fragment-
|
|
679
|
+
[hasAlphaTest, () => import("./alpha-test-fragment-BCChpzaV.js")],
|
|
680
|
+
[hasMetallicReflectance, () => import("./reflectance-fragment-ejMJ4O1o.js")],
|
|
681
|
+
[hasClearcoat, () => import("./clearcoat-fragment-KbZAa0TA.js")],
|
|
682
|
+
[hasSheen, () => import("./sheen-fragment-CS6z29Fs.js")],
|
|
683
|
+
[hasIridescence, () => import("./iridescence-fragment-DwZcCTdD.js")],
|
|
684
|
+
[hasAnySubsurface, () => import("./subsurface-fragment-C1H4ytqK.js")]
|
|
673
685
|
]);
|
|
674
686
|
if (hasTransmissionRefraction) {
|
|
675
|
-
const mod = await import("./pbr-refraction-
|
|
687
|
+
const mod = await import("./pbr-refraction-Dd11HnaI.js");
|
|
676
688
|
await mod.registerPbrRefraction(scene, engine, _registerPbrExt);
|
|
677
689
|
}
|
|
678
690
|
await _drainPbrExts([
|
|
679
|
-
[needsEmissiveColor, () => import("./emissive-fragment-
|
|
680
|
-
[hasAnyUnlit, () => import("./unlit-fragment-
|
|
681
|
-
[hasSomeSkeletons, () => import("./skeleton-fragment-
|
|
682
|
-
[hasSomeMorphs, () => import("./morph-fragment-
|
|
691
|
+
[needsEmissiveColor, () => import("./emissive-fragment-DD8cvHyx.js")],
|
|
692
|
+
[hasAnyUnlit, () => import("./unlit-fragment-DU9_mhzZ.js")],
|
|
693
|
+
[hasSomeSkeletons, () => import("./skeleton-fragment-BOVmc8YS.js")],
|
|
694
|
+
[hasSomeMorphs, () => import("./morph-fragment-DqH-w61u.js")],
|
|
683
695
|
[hasAnyUvTransform, () => import("./uv-transform-fragment-hYujGpZg.js")]
|
|
684
696
|
]);
|
|
685
697
|
let _anisoExt = null;
|
|
@@ -689,16 +701,22 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
689
701
|
}
|
|
690
702
|
let _createPbrTemplateExt = null;
|
|
691
703
|
if (hasAnyUvTransform || hasAnyVertexColor || hasAnyUv2) {
|
|
692
|
-
const extMod = await import("./pbr-template-ext-
|
|
704
|
+
const extMod = await import("./pbr-template-ext-CGgB2n2y.js");
|
|
693
705
|
_createPbrTemplateExt = extMod.createPbrTemplateExt;
|
|
694
706
|
}
|
|
695
707
|
let _createThinInstanceFragment = null;
|
|
696
708
|
let _syncThinInstanceBuffers = null;
|
|
709
|
+
let _cull;
|
|
710
|
+
let _syncThinInstanceGpuData = null;
|
|
697
711
|
if (hasSomeThinInstances) {
|
|
698
712
|
const mod = await import("./thin-instance-fragment-hsv-RyDs.js");
|
|
699
713
|
_createThinInstanceFragment = mod.createThinInstanceFragment;
|
|
700
|
-
const gpuMod = await import("./thin-instance-gpu-
|
|
714
|
+
const gpuMod = await import("./thin-instance-gpu-E8DBd8XL.js");
|
|
701
715
|
_syncThinInstanceBuffers = gpuMod.syncThinInstanceBuffers;
|
|
716
|
+
if (hasCullingTI) {
|
|
717
|
+
_cull = await import("./thin-instance-cull-binding-CCxrPNO6.js");
|
|
718
|
+
}
|
|
719
|
+
_syncThinInstanceGpuData = gpuMod.syncThinInstanceGpuData;
|
|
702
720
|
}
|
|
703
721
|
let _acesHelpers = "";
|
|
704
722
|
let _acesTonemapCall = "";
|
|
@@ -708,6 +726,13 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
708
726
|
_acesHelpers = acesMod.ACES_HELPERS_WGSL;
|
|
709
727
|
_acesTonemapCall = acesMod.ACES_TONEMAP_CALL_WGSL;
|
|
710
728
|
}
|
|
729
|
+
let _fogHelper = "";
|
|
730
|
+
let _fogBlock = "";
|
|
731
|
+
if (scene.fog) {
|
|
732
|
+
const fogMod = await import("./pbr-fog-wgsl-BqdCid6r.js");
|
|
733
|
+
_fogHelper = fogMod.PBR_FOG_HELPER;
|
|
734
|
+
_fogBlock = fogMod.PBR_FOG_BLOCK;
|
|
735
|
+
}
|
|
711
736
|
const composePbr = createPbrComposer({
|
|
712
737
|
_singleLightWGSL,
|
|
713
738
|
_getSingleLightBlock,
|
|
@@ -715,6 +740,8 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
715
740
|
_multiLightLoop,
|
|
716
741
|
_acesHelpers,
|
|
717
742
|
_acesTonemapCall,
|
|
743
|
+
_fogHelper,
|
|
744
|
+
_fogBlock,
|
|
718
745
|
_createPbrTemplateExt,
|
|
719
746
|
_anisoExt,
|
|
720
747
|
_iblSkyboxCalc,
|
|
@@ -722,10 +749,12 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
722
749
|
_shadowLights: shadowLights,
|
|
723
750
|
_createThinInstanceFragment
|
|
724
751
|
});
|
|
725
|
-
const sceneFeatures = (hasEnv ? PBR_HAS_ENV : 0) | (hasTonemap ? PBR_HAS_TONEMAP : 0);
|
|
752
|
+
const sceneFeatures = (hasEnv ? PBR_HAS_ENV : 0) | (hasTonemap ? PBR_HAS_TONEMAP : 0) | (scene.fog ? PBR_HAS_FOG : 0);
|
|
726
753
|
const shadowBGCache = /* @__PURE__ */ new Map();
|
|
727
754
|
const syncThinInstanceBuffers = _syncThinInstanceBuffers;
|
|
755
|
+
const syncThinInstanceGpuData = _syncThinInstanceGpuData;
|
|
728
756
|
const rebuildSingle = (s, mesh, materialOverride) => {
|
|
757
|
+
var _a2, _b2;
|
|
729
758
|
const materialInput = materialOverride ?? mesh.material;
|
|
730
759
|
const mat = materialInput;
|
|
731
760
|
const renderFeatures = mat._renderFeatures ?? (mat._renderFeatures = _computePbrMaterialFeatures(mat));
|
|
@@ -746,7 +775,8 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
746
775
|
const composed = composePbr(features, features2, meshFeatures, sceneFeatures, lightMode, singleLightType, esmShadowDepthCode, vbLayout, vbKey);
|
|
747
776
|
const bindings = getOrCreatePbrBindings(engine, features, features2, meshFeatures, sceneFeatures, composed, `${lightMode}:${singleLightType}${vbKey}`);
|
|
748
777
|
const meshUboData = new Float32Array(composed._meshUboSpec._totalBytes / 4);
|
|
749
|
-
|
|
778
|
+
const _packMeshWorld = ((_a2 = engine._makePackMeshWorld) == null ? void 0 : _a2.call(engine, s)) ?? packMat4IntoF32;
|
|
779
|
+
_packMeshWorld(meshUboData, mesh.worldMatrix, 0, 0);
|
|
750
780
|
writeMeshLightSelection(mesh, s.lights, meshUboData);
|
|
751
781
|
const meshUBO = createUniformBuffer(engine, meshUboData);
|
|
752
782
|
const materialSpec = composed._materialUboSpec;
|
|
@@ -795,10 +825,10 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
795
825
|
const hasVertexColor = (meshFeatures & MSH_HAS_VERTEX_COLOR) !== 0;
|
|
796
826
|
const hasTI = (meshFeatures & MSH_HAS_THIN_INSTANCES) !== 0;
|
|
797
827
|
const hasTIColor = (meshFeatures & MSH_HAS_INSTANCE_COLOR) !== 0;
|
|
798
|
-
let _lastWorldVersion =
|
|
828
|
+
let _lastWorldVersion = mesh.worldMatrixVersion;
|
|
799
829
|
let _lastLightsCount = s.lights.length;
|
|
800
830
|
const sortCenter = isTransparent || needsTaskRefraction ? [mesh.worldMatrix[12], mesh.worldMatrix[13], mesh.worldMatrix[14]] : null;
|
|
801
|
-
const
|
|
831
|
+
const _baseUpdate = () => {
|
|
802
832
|
const worldVersion = mesh.worldMatrixVersion;
|
|
803
833
|
if (worldVersion !== _lastWorldVersion || s.lights.length !== _lastLightsCount) {
|
|
804
834
|
if (sortCenter) {
|
|
@@ -806,7 +836,7 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
806
836
|
sortCenter[1] = mesh.worldMatrix[13];
|
|
807
837
|
sortCenter[2] = mesh.worldMatrix[14];
|
|
808
838
|
}
|
|
809
|
-
meshUboData
|
|
839
|
+
_packMeshWorld(meshUboData, mesh.worldMatrix, 0, 0);
|
|
810
840
|
writeMeshLightSelection(mesh, s.lights, meshUboData);
|
|
811
841
|
device.queue.writeBuffer(meshUBO, 0, meshUboData);
|
|
812
842
|
_lastWorldVersion = worldVersion;
|
|
@@ -825,9 +855,19 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
825
855
|
writeMaterialData(data, mat, materialSpec);
|
|
826
856
|
device.queue.writeBuffer(materialUBO, 0, data.buffer, 0, data.byteLength);
|
|
827
857
|
}
|
|
858
|
+
if (hasTI && syncThinInstanceGpuData) {
|
|
859
|
+
const ti = mesh.thinInstances;
|
|
860
|
+
if (ti) {
|
|
861
|
+
syncThinInstanceGpuData(engine, ti, hasTIColor);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
const _invalidate = () => {
|
|
866
|
+
_lastWorldVersion = -1;
|
|
828
867
|
};
|
|
829
|
-
const
|
|
830
|
-
|
|
868
|
+
const update = ((_b2 = engine._wrapRenderableForFO) == null ? void 0 : _b2.call(engine, _baseUpdate, s, _invalidate)) ?? _baseUpdate;
|
|
869
|
+
const drawWith = (pass, materialBindGroup, cullBinding) => {
|
|
870
|
+
var _a3, _b3, _c2, _d2, _e2, _f2;
|
|
831
871
|
if (!isOverride && mesh.material !== materialInput) {
|
|
832
872
|
return 0;
|
|
833
873
|
}
|
|
@@ -838,8 +878,8 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
838
878
|
}
|
|
839
879
|
let slot = 0;
|
|
840
880
|
const vb = gpu._vbLayout;
|
|
841
|
-
pass.setVertexBuffer(slot++, gpu.positionBuffer, (
|
|
842
|
-
pass.setVertexBuffer(slot++, gpu.normalBuffer, (
|
|
881
|
+
pass.setVertexBuffer(slot++, gpu.positionBuffer, (_a3 = vb == null ? void 0 : vb._p) == null ? void 0 : _a3._offset);
|
|
882
|
+
pass.setVertexBuffer(slot++, gpu.normalBuffer, (_b3 = vb == null ? void 0 : vb._n) == null ? void 0 : _b3._offset);
|
|
843
883
|
if (hasNormalMap && gpu.tangentBuffer) {
|
|
844
884
|
pass.setVertexBuffer(slot++, gpu.tangentBuffer, (_c2 = vb == null ? void 0 : vb._t) == null ? void 0 : _c2._offset);
|
|
845
885
|
}
|
|
@@ -860,17 +900,18 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
860
900
|
}
|
|
861
901
|
const ti = hasTI ? mesh.thinInstances : null;
|
|
862
902
|
if (ti && syncThinInstanceBuffers) {
|
|
863
|
-
slot = syncThinInstanceBuffers(engine, ti, pass, slot, hasTIColor);
|
|
903
|
+
slot = syncThinInstanceBuffers(engine, ti, pass, slot, hasTIColor, cullBinding == null ? void 0 : cullBinding.cullDrawBufs);
|
|
864
904
|
}
|
|
865
905
|
pass.setIndexBuffer(gpu.indexBuffer, gpu.indexFormat);
|
|
866
|
-
if (
|
|
906
|
+
if (cullBinding) {
|
|
907
|
+
cullBinding.draw(pass, gpu.indexCount, ti.count);
|
|
908
|
+
} else if (ti && ti.count > 0) {
|
|
867
909
|
pass.drawIndexed(gpu.indexCount, ti.count);
|
|
868
910
|
} else {
|
|
869
911
|
pass.drawIndexed(gpu.indexCount);
|
|
870
912
|
}
|
|
871
913
|
return 1;
|
|
872
914
|
};
|
|
873
|
-
const draw = (pass) => drawWith(pass, materialBindGroupStatic);
|
|
874
915
|
const r = {
|
|
875
916
|
order,
|
|
876
917
|
isTransparent,
|
|
@@ -879,11 +920,12 @@ async function buildPbrRenderables(scene, meshes, envTextures) {
|
|
|
879
920
|
bind(eng, sig) {
|
|
880
921
|
const pipeline = getOrCreatePbrPipeline(eng, sig, bindings);
|
|
881
922
|
const materialBindGroup = needsTaskRefraction ? createPbrMeshBindGroup(engine, bindings, composed, meshUBO, materialUBO, mat, envTextures ?? null, mesh, sig._transmissionTexture) : materialBindGroupStatic;
|
|
923
|
+
const cb = _cull == null ? void 0 : _cull.tryBind(r, s, mesh, engine, hasTIColor, isTransparent || needsTaskRefraction, update);
|
|
882
924
|
return {
|
|
883
925
|
renderable: r,
|
|
884
926
|
pipeline,
|
|
885
|
-
update,
|
|
886
|
-
draw:
|
|
927
|
+
update: cb ? cb.update : update,
|
|
928
|
+
draw: (pass) => drawWith(pass, materialBindGroup, cb)
|
|
887
929
|
};
|
|
888
930
|
}
|
|
889
931
|
};
|
|
@@ -918,15 +960,15 @@ function getPackedSingleLightType(lights, packedIndex) {
|
|
|
918
960
|
}
|
|
919
961
|
async function importSingleLightWgsl(type) {
|
|
920
962
|
if (type === "hemispheric") {
|
|
921
|
-
return import("./singlelight-hemispheric-wgsl-
|
|
963
|
+
return import("./singlelight-hemispheric-wgsl-CK-GUYWe.js");
|
|
922
964
|
}
|
|
923
965
|
if (type === "directional") {
|
|
924
|
-
return import("./singlelight-directional-wgsl-
|
|
966
|
+
return import("./singlelight-directional-wgsl-4MIgZMeC.js");
|
|
925
967
|
}
|
|
926
968
|
if (type === "spot") {
|
|
927
|
-
return import("./singlelight-spot-wgsl-
|
|
969
|
+
return import("./singlelight-spot-wgsl-DVbaVufF.js");
|
|
928
970
|
}
|
|
929
|
-
return import("./singlelight-point-wgsl-
|
|
971
|
+
return import("./singlelight-point-wgsl-CYtzqCbP.js");
|
|
930
972
|
}
|
|
931
973
|
function writeMaterialData(data, material, spec) {
|
|
932
974
|
data[0] = material.environmentIntensity ?? 1;
|
|
@@ -958,4 +1000,4 @@ function writeMaterialData(data, material, spec) {
|
|
|
958
1000
|
export {
|
|
959
1001
|
buildPbrRenderables
|
|
960
1002
|
};
|
|
961
|
-
//# sourceMappingURL=pbr-renderable-
|
|
1003
|
+
//# sourceMappingURL=pbr-renderable-BHAdF5Vw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbr-renderable-BHAdF5Vw.js","sources":["../src/material/pbr/pbr-pipeline.ts","../src/material/pbr/pbr-template.ts","../src/material/pbr/pbr-compose.ts","../src/material/pbr/pbr-renderable.ts"],"sourcesContent":["/** Dynamic PBR pipeline builder — creates and caches GPU render pipelines\n * based on per-mesh PBR feature flags + ComposedShader from the fragment system.\n *\n * Two-tier cache:\n * - Shader bindings (BGLs + composed shader + per-sig pipeline cache) keyed by\n * `(features, features2)`. Sig-independent.\n * - Pipelines live inside each `_PbrShaderBindings`, keyed by `targetSignatureKey(sig)`.\n */\n\nimport type { PbrMaterialProps } from \"./pbr-material.js\";\nimport type { EnvironmentTextures } from \"../../loader-env/load-env.js\";\nimport type { ComposedShader } from \"../../shader/fragment-types.js\";\nimport type { EngineContext } from \"../../engine/engine.js\";\nimport type { RenderTargetSignature } from \"../../engine/render-target.js\";\nimport type { Texture2D } from \"../../texture/texture-2d.js\";\nimport type { _PbrBindCtx, PbrExt } from \"./pbr-flags.js\";\nimport { _getPbrExtsSorted, PBR2_ESM_SHADOW_OUTPUT, PBR2_NO_COLOR_OUTPUT, PBR2_HAS_UV2 } from \"./pbr-flags.js\";\nimport { PBR_HAS_NORMAL_MAP, PBR_HAS_EMISSIVE, PBR_HAS_SPEC_GLOSS, PBR_HAS_DOUBLE_SIDED, PBR_HAS_ALPHA_BLEND } from \"./pbr-flags.js\";\nimport { MSH_HAS_TANGENTS, MSH_HAS_UV2 } from \"../mesh-features.js\";\nimport { REVERSE_DEPTH_COMPARE, targetSignatureKey } from \"../../engine/render-target.js\";\nimport { getSceneBindGroupLayout } from \"../../render/scene-helpers.js\";\n\n// ─── Shader Bindings (sig-independent) ──────────────────────────────\n\ninterface _PbrShaderBindings {\n _features: number;\n _features2: number;\n _meshFeatures: number;\n _meshBGL: GPUBindGroupLayout;\n _shadowBGL: GPUBindGroupLayout | null;\n _composed: ComposedShader;\n /** Per-sig pipeline cache. Key = `targetSignatureKey(sig)`. */\n _pipelines: Map<string, GPURenderPipeline>;\n}\n\n// ─── Caches ─────────────────────────────────────────────────────────\n\nconst _bindingsCache = new Map<string, _PbrShaderBindings>();\nlet _cachedDevice: GPUDevice | null = null;\n\nfunction ensureDevice(engine: EngineContext): void {\n if (_cachedDevice !== engine._device) {\n _bindingsCache.clear();\n _cachedDevice = engine._device;\n }\n}\n\n/** Clear the pipeline cache. Must be called when a GPU device is destroyed. */\nexport function clearPbrPipelineCache(): void {\n _bindingsCache.clear();\n _cachedDevice = null;\n}\n\n/** Get-or-build the sig-independent PBR shader bindings. Used at renderable build time\n * so per-mesh bind groups can be created BEFORE any sig is known. */\nexport function getOrCreatePbrBindings(\n engine: EngineContext,\n features: number,\n features2: number,\n meshFeatures: number,\n sceneFeatures: number,\n composed: ComposedShader,\n shaderKey = \"\"\n): _PbrShaderBindings {\n ensureDevice(engine);\n const key = `${features}:${features2}:${meshFeatures}:${sceneFeatures}:${shaderKey}`;\n const cached = _bindingsCache.get(key);\n if (cached) {\n return cached;\n }\n\n const device = engine._device;\n const meshBGL = device.createBindGroupLayout(composed._meshBGLDescriptor);\n let shadowBGL: GPUBindGroupLayout | null = null;\n if (composed._shadowBGLDescriptor) {\n shadowBGL = device.createBindGroupLayout(composed._shadowBGLDescriptor);\n }\n const bindings: _PbrShaderBindings = {\n _features: features,\n _features2: features2,\n _meshFeatures: meshFeatures,\n _meshBGL: meshBGL,\n _shadowBGL: shadowBGL,\n _composed: composed,\n _pipelines: new Map(),\n };\n _bindingsCache.set(key, bindings);\n return bindings;\n}\n\n/** Get-or-build the sig-specific pipeline on top of a PBR shader bindings. Called at bind() time. */\nexport function getOrCreatePbrPipeline(engine: EngineContext, sig: RenderTargetSignature, bindings: _PbrShaderBindings): GPURenderPipeline {\n ensureDevice(engine);\n const key = targetSignatureKey(sig);\n const cached = bindings._pipelines.get(key);\n if (cached) {\n return cached;\n }\n\n const device = engine._device;\n const { _features: features, _features2: features2, _composed: composed } = bindings;\n const esmShadowOutput = (features2 & PBR2_ESM_SHADOW_OUTPUT) !== 0;\n const hasAlpha = !esmShadowOutput && (features & PBR_HAS_ALPHA_BLEND) !== 0;\n const hasDoubleSided = (features & PBR_HAS_DOUBLE_SIDED) !== 0;\n\n const sceneBGL = getSceneBindGroupLayout(engine);\n const bgls: GPUBindGroupLayout[] = bindings._shadowBGL ? [sceneBGL, bindings._meshBGL, bindings._shadowBGL] : [sceneBGL, bindings._meshBGL];\n\n const vertModule = device.createShaderModule({ code: composed._vertexWGSL });\n const noColorOutput = (features2 & PBR2_NO_COLOR_OUTPUT) !== 0;\n const fragModule = !sig._colorFormat && !noColorOutput ? null : device.createShaderModule({ code: composed._fragmentWGSL });\n\n const fragTarget: GPUColorTargetState | null = noColorOutput ? null : { format: sig._colorFormat!, writeMask: GPUColorWrite.ALL };\n if (hasAlpha && fragTarget) {\n fragTarget.blend = {\n color: { srcFactor: \"src-alpha\", dstFactor: \"one-minus-src-alpha\", operation: \"add\" },\n alpha: { srcFactor: \"one\", dstFactor: \"one\", operation: \"add\" },\n };\n }\n\n const pipeline = device.createRenderPipeline({\n layout: device.createPipelineLayout({ bindGroupLayouts: bgls }),\n vertex: { module: vertModule, entryPoint: \"main\", buffers: composed._vertexBufferLayouts },\n ...(fragModule ? { fragment: { module: fragModule, entryPoint: \"main\", targets: fragTarget ? [fragTarget] : [] } } : {}),\n ...(sig._depthStencilFormat\n ? {\n depthStencil: {\n format: sig._depthStencilFormat,\n depthCompare: sig._depthCompare ?? REVERSE_DEPTH_COMPARE,\n depthWriteEnabled: noColorOutput || esmShadowOutput || !hasAlpha,\n },\n }\n : {}),\n multisample: { count: sig._sampleCount },\n primitive: { topology: \"triangle-list\", cullMode: hasDoubleSided ? (\"none\" as GPUCullMode) : \"back\", frontFace: sig._flipY ? \"cw\" : \"ccw\" },\n });\n bindings._pipelines.set(key, pipeline);\n return pipeline;\n}\n\n// ─── Per-Mesh Bind Group ────────────────────────────────────────────\n\nexport function createPbrMeshBindGroup(\n engine: EngineContext,\n bindings: _PbrShaderBindings,\n composed: ComposedShader,\n meshUBO: GPUBuffer,\n materialUBO: GPUBuffer,\n material: PbrMaterialProps,\n env: EnvironmentTextures | null,\n meshCtx: { skeleton?: { boneTexture: GPUTexture } | null; morphTargets?: { texture: GPUTexture; weightsBuffer?: GPUBuffer } | null } | null,\n refractionTexture?: Texture2D | null\n): GPUBindGroup {\n const device = engine._device;\n const features = bindings._features;\n const features2 = bindings._features2;\n const meshFeatures = bindings._meshFeatures;\n const hasNormal = (features & PBR_HAS_NORMAL_MAP) !== 0 && (meshFeatures & MSH_HAS_TANGENTS) !== 0;\n const hasCotangentNormal = (features & PBR_HAS_NORMAL_MAP) !== 0 && (meshFeatures & MSH_HAS_TANGENTS) === 0;\n const hasAnyNormal = hasNormal || hasCotangentNormal;\n const hasEmissive = (features & PBR_HAS_EMISSIVE) !== 0;\n const hasSpecGloss = (features & PBR_HAS_SPEC_GLOSS) !== 0;\n const esmShadowOutput = (features2 & PBR2_ESM_SHADOW_OUTPUT) !== 0;\n\n const entries: GPUBindGroupEntry[] = [];\n let b = 0;\n const addTex = (t: { view: GPUTextureView; sampler: GPUSampler }) => {\n entries.push({ binding: b++, resource: t.view });\n entries.push({ binding: b++, resource: t.sampler });\n };\n\n const ctx: _PbrBindCtx = {\n _engine: engine,\n _features: features,\n _features2: features2,\n _meshFeatures: meshFeatures,\n _material: material,\n _mesh: meshCtx ?? undefined,\n _env: env,\n _refractionTexture: refractionTexture,\n };\n\n const sortedExts = _getPbrExtsSorted();\n\n const fragIds = composed._fragmentKey ? composed._fragmentKey.split(\"|\").filter((s) => s.length > 0) : [];\n\n entries.push({ binding: b++, resource: { buffer: meshUBO } });\n entries.push({ binding: b++, resource: { buffer: materialUBO } });\n for (const ext of sortedExts) {\n if (ext.phase === \"vertex\" && ext.bind) {\n b = ext.bind(ctx, entries, b);\n }\n }\n addTex(material.baseColorTexture!);\n if (hasAnyNormal) {\n addTex(material.normalTexture!);\n }\n addTex(material.ormTexture!);\n if ((features2 & PBR2_HAS_UV2) !== 0 && (meshFeatures & MSH_HAS_UV2) !== 0 && material.occlusionTexture) {\n addTex(material.occlusionTexture);\n }\n if (hasEmissive) {\n addTex(material.emissiveTexture!);\n }\n if (hasSpecGloss) {\n addTex(material.specGlossTexture!);\n }\n if (esmShadowOutput) {\n entries.push({\n binding: b++,\n resource: { buffer: (material as PbrMaterialProps & { readonly _esmShadowParamsUBO: GPUBuffer })._esmShadowParamsUBO },\n });\n }\n const seenExts: PbrExt[] = [];\n for (const fid of fragIds) {\n const ext = sortedExts.find((e) => e.id === fid || fid.startsWith(e.id + \"-\"));\n if (!ext || ext.phase === \"vertex\" || !ext.bind || seenExts.includes(ext)) {\n continue;\n }\n seenExts.push(ext);\n b = ext.bind(ctx, entries, b);\n }\n\n return device.createBindGroup({ layout: bindings._meshBGL, entries });\n}\n","/**\n * PBR Base Template\n *\n * Provides the base PBR shader structure with slot markers where\n * fragments inject their code. This is the PBR equivalent of\n * what composePbrVertex/composePbrFragment produce today.\n *\n * The template is parameterized by light type and feature flags\n * because these fundamentally change the shader structure.\n */\n\nimport type { ShaderTemplate, UboField, VertexAttribute, Varying, BindingDecl } from \"../../shader/fragment-types.js\";\nimport type { PbrTemplateExt } from \"./pbr-template-ext.js\";\nimport type { MeshVbLayout } from \"../../mesh/mesh.js\";\nimport { appendMeshLightUboFields, meshLightIndexWGSL } from \"../../render/lights-ubo.js\";\n\nconst STAGE_FRAGMENT = 0x2;\n\n// ── BRDF functions (always present in PBR) ──────────────────────\n\nconst BRDF_FUNCTIONS = `\nconst PI:f32=3.14159265358979323846;\nfn distributionGGX(NdotH:f32,alphaG:f32)->f32{\nlet a2=alphaG*alphaG;\nlet d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\nfn geometrySmithGGX(NdotL:f32,NdotV:f32,alphaG:f32)->f32{\nlet a2=alphaG*alphaG;\nlet gl=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\nlet gv=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\nreturn 0.5/(gl+gv);\n}\nfn fresnelSchlick(cosTheta:f32,F0:vec3<f32>,F90:vec3<f32>)->vec3<f32>{\nlet t=1.0-cosTheta;\nlet t2=t*t;\nreturn F0+(F90-F0)*(t2*t2*t);\n}\n`;\n\nexport interface PbrTemplateConfig {\n /** When true, generates a non-looping single-light direct block + lights UBO binding. */\n /** @internal */\n readonly _hasSingleLight?: boolean;\n /** When true, generates a multi-light loop + lights UBO binding.\n * Used for multiple lights or shadow receivers. */\n /** @internal */\n readonly _hasMultiLight?: boolean;\n /** Pre-built WGSL for the single-light UBO structs. */\n /** @internal */\n readonly _singleLightWGSL?: string;\n /** Pre-built WGSL for the single-light direct lighting block. */\n /** @internal */\n readonly _singleLightBlock?: string;\n /** Pre-built WGSL for multi-light (structs + computePbrLight). Passed from\n * dynamically imported fragments/multilight-wgsl.ts to keep it out of non-shadow bundles. */\n /** @internal */\n readonly _multiLightWGSL?: string;\n /** Pre-built WGSL for the multi-light direct lighting loop body. */\n /** @internal */\n readonly _multiLightLoop?: string;\n /** Normal map mode (default: \"none\") */\n /** @internal */\n readonly _normalMode?: \"tangent\" | \"cotangent\" | \"none\";\n /** Has emissive texture */\n /** @internal */\n readonly _hasEmissiveTexture?: boolean;\n /** Has specular-glossiness workflow */\n /** @internal */\n readonly _hasSpecGloss?: boolean;\n /** Has double-sided rendering */\n /** @internal */\n readonly _hasDoubleSided?: boolean;\n /** Has tonemap */\n /** @internal */\n readonly _hasTonemap?: boolean;\n /** Scene has fog (scene.fog != null). `calcFogFactor` helper WGSL, supplied by the dynamic\n * pbr-fog-wgsl import only for fog scenes; \"\" otherwise (zero bytes for non-fog scenes). */\n /** @internal */\n readonly _fogHelper?: string;\n /** Fog blend WGSL, emitted just before the tonemap block; \"\" for non-fog scenes. */\n /** @internal */\n readonly _fogBlock?: string;\n /** ACES WGSL: tonemap helper functions (dynamically imported). Empty string = standard exponential tonemap. */\n /** @internal */\n readonly _acesHelpers?: string;\n /** ACES WGSL: tonemap call block replacing the default exponential one. */\n /** @internal */\n readonly _acesTonemapCall?: string;\n /** Has alpha blending */\n /** @internal */\n readonly _hasAlphaBlend?: boolean;\n /** Has specular AA */\n /** @internal */\n readonly _hasSpecularAA?: boolean;\n /** Has gamma albedo (sRGB base color decode) */\n /** @internal */\n readonly _hasGammaAlbedo?: boolean;\n /** Has a non-default base-color factor multiplied over the base-color texture. */\n /** @internal */\n readonly _hasBaseColorFactor?: boolean;\n /** Has morph targets (changes position/normal variable names in vertex shader) */\n /** @internal */\n readonly _hasMorph?: boolean;\n /** Has occlusion in ORM texture (simple path, no reflectance ext) */\n /** @internal */\n readonly _hasOcclusion?: boolean;\n /** Has emissive color UBO field (fragment handles emissive computation) */\n /** @internal */\n readonly _hasEmissiveColor?: boolean;\n /** When true, the reflectance fragment handles F0 + occlusion computation */\n /** @internal */\n readonly _hasReflectanceExt?: boolean;\n /** When true, include IBL SH coefficients in scene UBO */\n /** @internal */\n readonly _hasIbl?: boolean;\n /** Has anisotropy layer */\n /** @internal */\n readonly _hasAnisotropy?: boolean;\n /** Anisotropy WGSL: BRDF helper functions (dynamically imported). */\n /** @internal */\n readonly _anisoBrdfFunctions?: string;\n /** Anisotropy WGSL: T/B computation block (dynamically imported). */\n /** @internal */\n readonly _anisoTBBlock?: string;\n /** Optional extension config for advanced features (UV transforms, UV2, vertex colors).\n * When undefined, base template defaults to master-like behavior (no feature strings). */\n /** @internal */\n readonly _ext?: PbrTemplateExt;\n /** Generate a fragment stage that runs discard/alpha-test logic and writes no color. */\n /** @internal */\n readonly _noColorOutput?: boolean;\n /** Generate a fragment stage that runs discard/alpha-test logic and writes ESM shadow color. */\n /** @internal */\n readonly _esmShadowOutput?: boolean;\n /** ESM shadow depth output code. Supplied by the ESM material view so normal PBR bundles don't retain it. */\n /** @internal */\n readonly _esmShadowDepthCode?: string;\n /** @internal Per-attribute vertex-buffer interleave layout. Undefined (or per-attribute\n * undefined) → canonical tight strides (12/12/16/8). Only set for meshes\n * sourcing attributes from a strided bufferView. */\n readonly _vbStrides?: MeshVbLayout;\n}\n\n/**\n * Create a PBR ShaderTemplate from the given configuration.\n * The template contains slot markers that the composer fills with fragment code.\n */\nexport function createPbrTemplate(config: PbrTemplateConfig): ShaderTemplate {\n const {\n _hasSingleLight = false,\n _hasMultiLight = false,\n _singleLightWGSL = \"\",\n _singleLightBlock = \"\",\n _multiLightWGSL = \"\",\n _multiLightLoop = \"\",\n _normalMode = \"none\",\n _hasEmissiveTexture = false,\n _hasSpecGloss = false,\n _hasDoubleSided = false,\n _hasTonemap = false,\n _fogHelper = \"\",\n _fogBlock = \"\",\n _acesHelpers = \"\",\n _acesTonemapCall = \"\",\n _hasAlphaBlend = false,\n _hasSpecularAA = false,\n _hasGammaAlbedo = false,\n _hasBaseColorFactor = false,\n _hasMorph = false,\n _hasOcclusion = false,\n _hasEmissiveColor = false,\n _hasReflectanceExt = false,\n _hasIbl = false,\n _hasAnisotropy = false,\n _anisoBrdfFunctions = \"\",\n _anisoTBBlock = \"\",\n _ext,\n _noColorOutput = false,\n _esmShadowOutput = false,\n _esmShadowDepthCode = \"\",\n _vbStrides,\n } = config;\n const hasNormal = _normalMode === \"tangent\";\n const hasCotangentNormal = _normalMode === \"cotangent\";\n const hasAnyNormal = hasNormal || hasCotangentNormal;\n\n // ── Base vertex attributes ──────────────────────────────────\n // arrayStride defaults to the canonical tight element size; interleaved meshes\n // override it (e.g. 24 for POSITION+NORMAL sharing one stride-24 bufferView).\n const _baseVertexAttributes: VertexAttribute[] = [\n { _name: \"position\", _type: \"vec3<f32>\", _gpuFormat: \"float32x3\", _arrayStride: _vbStrides?._p?._stride ?? 12 },\n { _name: \"normal\", _type: \"vec3<f32>\", _gpuFormat: \"float32x3\", _arrayStride: _vbStrides?._n?._stride ?? 12 },\n ];\n if (hasNormal) {\n _baseVertexAttributes.push({ _name: \"tangent\", _type: \"vec4<f32>\", _gpuFormat: \"float32x4\", _arrayStride: _vbStrides?._t?._stride ?? 16 });\n }\n _baseVertexAttributes.push({ _name: \"uv\", _type: \"vec2<f32>\", _gpuFormat: \"float32x2\", _arrayStride: _vbStrides?._u?._stride ?? 8 });\n if (_ext) {\n _baseVertexAttributes.push(..._ext.extraVertexAttributes);\n }\n\n // ── Base varyings ───────────────────────────────────────────\n const _baseVaryings: Varying[] = [\n { _name: \"worldPos\", _type: \"vec3<f32>\" },\n { _name: \"worldNormal\", _type: \"vec3<f32>\" },\n ];\n if (hasNormal) {\n _baseVaryings.push({ _name: \"worldTangent\", _type: \"vec3<f32>\" }, { _name: \"worldBitangent\", _type: \"vec3<f32>\" });\n }\n _baseVaryings.push({ _name: \"uv\", _type: \"vec2<f32>\" });\n if (_ext) {\n _baseVaryings.push(..._ext.extraVaryings);\n }\n\n // ── Base mesh UBO fields (world matrix + affected light indices — UV transforms are\n // per-texture now, emitted on the material UBO when hasUvTransform). ─\n const _baseMeshUboFields: UboField[] = [{ _name: \"world\", _type: \"mat4x4<f32>\" }];\n appendMeshLightUboFields(_baseMeshUboFields);\n\n // ── Base material UBO fields ────────────────────────────────────\n const _baseMaterialUboFields: UboField[] = [\n { _name: \"environmentIntensity\", _type: \"f32\" },\n { _name: \"directIntensity\", _type: \"f32\" },\n { _name: \"reflectance\", _type: \"f32\" },\n { _name: \"materialAlpha\", _type: \"f32\" },\n ...(_hasBaseColorFactor ? [{ _name: \"baseColorFactor\", _type: \"vec4<f32>\" as const }] : []),\n // glTF metallicFactor / roughnessFactor (default 1.0) — applied over MR texture channels.\n { _name: \"metallicFactor\", _type: \"f32\" },\n { _name: \"roughnessFactor\", _type: \"f32\" },\n { _name: \"normalScale\", _type: \"f32\" },\n { _name: \"lightFalloffMode\", _type: \"f32\" },\n // Anisotropy UBO field stays on the base template because anisotropy is\n // template-only (no ShaderFragment) — the anisotropyExt just writes its\n // slice through the unified ext.writeUbo hook.\n ...(_hasAnisotropy ? [{ _name: \"anisotropyParams\", _type: \"vec4<f32>\" as const }] : []),\n // ── Extension fields (per-texture UV transforms, etc.) ─\n ...(_ext ? _ext.extraMaterialUboFields : []),\n ];\n\n // ── Helper: texture + sampler binding pair ────────────────────\n const tex2d = (name: string, sampler: string): BindingDecl[] => [\n { _name: name, _type: { _kind: \"texture\", _textureType: \"texture_2d<f32>\" }, _visibility: STAGE_FRAGMENT },\n { _name: sampler, _type: { _kind: \"sampler\", _samplerType: \"sampler\" }, _visibility: STAGE_FRAGMENT },\n ];\n\n // ── Base bindings (always-present textures) ─────────────────\n const _baseBindings: BindingDecl[] = tex2d(\"baseColorTexture\", \"baseColorSampler\");\n if (hasAnyNormal) {\n _baseBindings.push(...tex2d(\"normalTexture\", \"normalSampler_\"));\n }\n _baseBindings.push(...tex2d(\"ormTexture\", \"ormSampler\"));\n if (_ext) {\n _baseBindings.push(..._ext.extraBindings);\n }\n if (_hasEmissiveTexture) {\n _baseBindings.push(...tex2d(\"emissiveTexture\", \"emissiveSampler\"));\n }\n if (_hasSpecGloss) {\n _baseBindings.push(...tex2d(\"specGlossTexture\", \"specGlossSampler\"));\n }\n if (_esmShadowOutput) {\n _baseBindings.push({ _name: \"shadowParams\", _type: { _kind: \"uniform-buffer\" }, _visibility: STAGE_FRAGMENT });\n }\n // ── Vertex template ─────────────────────────────────────────\n // When morph targets are active, the morph fragment's VR\n // defines morphedPos/morphedNorm. The base template uses those instead\n // of the raw vertex attributes.\n const posVar = _hasMorph ? \"morphedPos\" : \"position\";\n const normVar = _hasMorph ? \"morphedNorm\" : \"normal\";\n\n // The vertex template uses morphedPos/morphedNorm when morph fragment is present,\n // falling back to position/normal. The morph fragment's VR defines these vars.\n const tangentBlock = hasNormal\n ? `let N_local=normalize(${normVar});\nlet T_local=normalize(tangent.xyz);\nlet B_local=cross(N_local,T_local)*tangent.w;\nout.worldTangent=(finalWorld*vec4<f32>(T_local,0.0)).xyz;\nout.worldBitangent=(finalWorld*vec4<f32>(B_local,0.0)).xyz;`\n : \"\";\n\n const _vertexTemplate = `/*SU*/\n/*MU*/\n@group(1) @binding(0) var<uniform> mesh: MeshUniforms;\n/*VH*/\n/*VD*/\n/*VO*/\n@vertex fn main(\n/*VP*/\n) -> VertexOutput {\nvar out: VertexOutput;\n/*VR*/\nvar finalWorld = mesh.world;\n/*VW*/\nlet worldPos4 = finalWorld * vec4<f32>(${posVar}, 1.0);\nout.worldPos = worldPos4.xyz;\nout.clipPos = scene.viewProjection * worldPos4;\nout.worldNormal = (finalWorld * vec4<f32>(normalize(${normVar}), 0.0)).xyz;\n${tangentBlock}\nout.uv = uv;\n ${_ext ? _ext.vertexBodyExtra : \"\"}/*VB*/\nreturn out;\n}`;\n\n // ── Fragment template ────────────────────────────────────────\n\n // Normal handling block\n const normalUV = _ext?.uvForNormal ?? \"input.uv\";\n const normalScaleMod = _ext?.normalScaleMod ?? \"\";\n const normalRef = _ext?.normalScaleMod ? \"scaledNormal\" : \"normalMapRaw\";\n const normalRefCt = _ext?.normalScaleMod ? \"scaledNormalCT\" : \"normalMapSample\";\n let normalBlock: string;\n if (hasNormal) {\n normalBlock = `let normalMapRaw=textureSample(normalTexture,normalSampler_,${normalUV}).rgb*2.0-1.0;\n${normalScaleMod}let normalMapNorm=normalize(${normalRef});\nlet N_geom=normalize(input.worldNormal);\nlet TBN=mat3x3<f32>(input.worldTangent,input.worldBitangent,input.worldNormal);\nvar N=normalize(TBN*normalMapNorm);`;\n } else if (hasCotangentNormal) {\n normalBlock = `let normalMapSample=textureSample(normalTexture,normalSampler_,${normalUV}).rgb*2.0-1.0;\n${normalScaleMod.replace(/normalMapRaw/g, \"normalMapSample\").replace(/scaledNormal/g, \"scaledNormalCT\")}let N_geom=normalize(input.worldNormal);\nlet dp1=dpdx(input.worldPos);\nlet dp2=dpdy(input.worldPos);\nlet duv1=dpdx(${normalUV});\nlet duv2=dpdy(${normalUV});\nlet dp2perp=cross(dp2,N_geom);\nlet dp1perp=cross(N_geom,dp1);\nlet tangent_ct=dp2perp*duv1.x+dp1perp*duv2.x;\nlet bitangent_ct=-(dp2perp*duv1.y+dp1perp*duv2.y);\nlet det=max(dot(tangent_ct,tangent_ct),dot(bitangent_ct,bitangent_ct));\nlet invmax=select(inverseSqrt(det),0.0,det==0.0);\nlet cotangentFrame=mat3x3<f32>(tangent_ct*invmax,bitangent_ct*invmax,N_geom);\nvar N=normalize(cotangentFrame*normalize(${normalRefCt}));`;\n } else {\n normalBlock = `let N_geom=normalize(input.worldNormal);\nvar N=N_geom;`;\n }\n\n // Anisotropy: tangent/bitangent frame (passed in from dynamic import, empty if not used)\n const anisotropyTBBlock = _hasAnisotropy ? _anisoTBBlock : \"\";\n\n // Base color decoding\n const vertexColorMod = _ext?.baseColorMod ?? \"\";\n const baseColorFactorRgb = _hasBaseColorFactor ? \"*material.baseColorFactor.rgb\" : \"\";\n const baseColorFactorAlpha = _hasBaseColorFactor ? \"*material.baseColorFactor.a\" : \"\";\n const baseColorDecode = _hasGammaAlbedo\n ? `var baseColor=pow(baseColorSample.rgb,vec3<f32>(2.2))${baseColorFactorRgb};\nvar alpha=baseColorSample.a${baseColorFactorAlpha};${vertexColorMod}`\n : `var baseColor=baseColorSample.rgb${baseColorFactorRgb};\nvar alpha=baseColorSample.a${baseColorFactorAlpha};${vertexColorMod}`;\n\n // Roughness / metallic\n const specGlossUV = _ext?.uvForSpecGloss ?? \"input.uv\";\n const roughnessMetallic = _hasSpecGloss\n ? `let specGloss=textureSample(specGlossTexture,specGlossSampler,${specGlossUV});\nlet roughness=clamp(1.0-specGloss.a,0.0,1.0);\nlet metallic=0.0;`\n : `let roughness=clamp(orm.g*material.roughnessFactor,0.0,1.0);\nlet metallic=orm.b*material.metallicFactor;`;\n\n // Emissive default (overridden by emissive-color fragment's AT slot)\n const emissiveUV = _ext?.uvForEmissive ?? \"input.uv\";\n const emissiveDefault = _hasEmissiveColor\n ? ``\n : _hasEmissiveTexture\n ? `let emissive=textureSample(emissiveTexture,emissiveSampler,${emissiveUV}).rgb;`\n : `let emissive=vec3<f32>(0.0);`;\n\n // Occlusion default (overridden by reflectance fragment's AT slot or ext occlusion override)\n const occlusionDefault = _hasReflectanceExt ? `` : _ext?.occlusionOverride ? _ext.occlusionOverride : _hasOcclusion ? `let occlusion=orm.r;` : `let occlusion=1.0;`;\n // F0 computation (overridden by reflectance fragment's MF slot)\n const f0Default = _hasReflectanceExt\n ? ``\n : _hasSpecGloss\n ? `var colorF0=specGloss.rgb;\nlet colorF90=vec3<f32>(1.0);\nlet maxSpecular=max(colorF0.r,max(colorF0.g,colorF0.b));\nlet surfaceAlbedo=baseColor*(1.0-maxSpecular);`\n : `let dielectricF0=material.reflectance;\nvar colorF0=mix(vec3<f32>(dielectricF0),baseColor,metallic);\nlet colorF90=vec3<f32>(1.0);\nlet surfaceAlbedo=baseColor*(1.0-dielectricF0)*(1.0-metallic);`;\n\n // Specular AA + geometric-curvature roughness factors (BJS getAARoughnessFactors).\n // AA_factor_x is the direct-light roughness floor (matches BJS `computeSheenLighting`\n // which clamps info.roughness upward). AA_factor_y is the IBL/alphaG additive bump.\n // Emitted unconditionally as var so sheen/other fragments can reference them\n // without needing a define; zero on the no-curvature path makes them a no-op.\n const specularAABlock =\n _hasSpecularAA || hasAnyNormal\n ? `var AA_factor_x=0.0;\nvar AA_factor_y=0.0;\n{let nDfdx_AA=dpdx(N);\nlet nDfdy_AA=dpdy(N);\nlet slopeSquare_AA=max(dot(nDfdx_AA,nDfdx_AA),dot(nDfdy_AA,nDfdy_AA));\nAA_factor_x=pow(saturate(slopeSquare_AA),0.333);\nAA_factor_y=sqrt(slopeSquare_AA)*0.75;\nalphaG+=AA_factor_y;}`\n : `var AA_factor_x=0.0;\nvar AA_factor_y=0.0;`;\n\n // Direct lighting block — use the compact non-looping shader for one non-shadow light,\n // and the generic multi-light loop for multiple lights or shadow receivers.\n const directLightBlock: string = _hasMultiLight\n ? _multiLightLoop\n : _hasSingleLight\n ? _singleLightBlock\n : `var directDiffuse=vec3<f32>(0.0);\nvar directSpecular=vec3<f32>(0.0);\n/*BL*/`;\n\n // Tonemap: BJS TONEMAPPING_STANDARD (exponential) by default; caller-supplied\n // ACES WGSL (from pbr-aces-wgsl.ts) is used when provided.\n const useAces = _hasTonemap && _acesTonemapCall !== \"\";\n const acesBlock = useAces ? _acesHelpers : \"\";\n const tonemapBlock = _hasTonemap\n ? useAces\n ? _acesTonemapCall\n : `color*=scene.vImageInfos.x;\ncolor=1.0-exp2(-1.590579*color);`\n : `color*=scene.vImageInfos.x;`;\n\n // Fog (opt-in via scene.fog). The fog WGSL — `_fogHelper` (calcFogFactor) and `_fogBlock`\n // (the blend, emitted just before the tonemap block) — is supplied by pbr-renderable, which\n // dynamically imports pbr-fog-wgsl.ts only when scene.fog is set. Both are \"\" for non-fog\n // scenes, so those bundles carry zero fog bytes (see pbr-fog-wgsl.ts for the parity details).\n const fogHelper = _fogHelper;\n const fogBlock = _fogBlock;\n\n // Alpha output\n const alphaBlock = _noColorOutput\n ? \"\"\n : _hasAlphaBlend\n ? `var finalAlpha=alpha*material.materialAlpha;\nvar luminanceOverAlpha=0.0;\n/*BA*/\nluminanceOverAlpha+=dot(${_hasIbl ? `finalSpecularScaled` : `directSpecular`},vec3<f32>(0.2126,0.7152,0.0722));\nfinalAlpha=saturate(finalAlpha+luminanceOverAlpha*luminanceOverAlpha);\nreturn vec4<f32>(color,finalAlpha);`\n : `return vec4<f32>(color,alpha*material.materialAlpha);`;\n\n const doubleSidedEntry = _hasDoubleSided\n ? `@fragment fn main(input: FragmentInput, @builtin(front_facing) frontFacing: bool)${_noColorOutput ? \"\" : \" -> @location(0) vec4<f32>\"} {`\n : `@fragment fn main(input: FragmentInput)${_noColorOutput ? \"\" : \" -> @location(0) vec4<f32>\"} {`;\n const doubleSidedFlip = _hasDoubleSided ? `if (!frontFacing) { N = -N; }` : \"\";\n\n const lightDecls = _hasMultiLight ? _multiLightWGSL : _hasSingleLight ? _singleLightWGSL : \"\";\n const lightBindingDecl = _hasSingleLight || _hasMultiLight ? `@group(0) @binding(1) var<uniform> lights: lightsUniforms;` : \"\";\n const meshLightIndexHelper = _hasSingleLight || _hasMultiLight ? meshLightIndexWGSL(\"mesh\") : \"\";\n\n const anisoBrdfBlock = _hasAnisotropy ? _anisoBrdfFunctions : \"\";\n\n const fragmentHelpers = _ext?.fragmentHelpers ?? \"\";\n const fragmentPrelude = _ext?.fragmentPrelude ?? \"\";\n const baseColorUV = _ext?.uvForBaseColor ?? \"input.uv\";\n const ormUV = _ext?.uvForOrm ?? \"input.uv\";\n\n const _fragmentTemplate = `/*SU*/\n${_esmShadowOutput ? \"struct shadowParamsUniforms { biasAndScale: vec4<f32>, depthValues: vec4<f32>, }\" : \"\"}\n/*MU*/\n@group(1) @binding(0) var<uniform> mesh: MeshUniforms;\n/*HF*/\n/*FB*/\n/*FI*/\n${BRDF_FUNCTIONS}\n${acesBlock}\n${fogHelper}\n${anisoBrdfBlock}\n${lightDecls}\n${lightBindingDecl}\n${meshLightIndexHelper}\n${fragmentHelpers}\n${doubleSidedEntry}\n${fragmentPrelude}/*SV*/\nlet baseColorSample=textureSample(baseColorTexture,baseColorSampler,${baseColorUV});\n${baseColorDecode}\nlet orm=textureSample(ormTexture,ormSampler,${ormUV}).rgb;\n${occlusionDefault}\n${roughnessMetallic}\n${emissiveDefault}\n/*AT*/\n${_noColorOutput ? \"return;\" : _esmShadowOutput ? _esmShadowDepthCode : \"\"}\n${normalBlock}\n${doubleSidedFlip}\n${anisotropyTBBlock}\n/*AC*/\nlet V=normalize(scene.vEyePosition.xyz-input.worldPos);\nlet NdotVUnclamped=dot(N,V);\nlet NdotV=abs(NdotVUnclamped)+0.0000001;\n${f0Default}\n/*MF*/\nvar alphaG=roughness*roughness+0.0005;\n${specularAABlock}\n${directLightBlock}\nvar color=directDiffuse+directSpecular+emissive;\n/*AI*/\n/*NI*/\n${fogBlock}\n${tonemapBlock}\ncolor=pow(color,vec3<f32>(1.0/2.2));\ncolor=clamp(color,vec3<f32>(0.0),vec3<f32>(1.0));\nlet highContrast=color*color*(3.0-2.0*color);\nif(scene.vImageInfos.y<1.0){color=mix(vec3<f32>(0.5),color,scene.vImageInfos.y);}\nelse{color=mix(color,highContrast,scene.vImageInfos.y-1.0);}\ncolor=max(color,vec3<f32>(0.0));\n/*BC*/\n${alphaBlock}\n}`;\n\n return {\n _vertexTemplate,\n _fragmentTemplate,\n _baseMeshUboFields,\n _baseMaterialUboFields,\n _baseVertexAttributes,\n _baseVaryings,\n _baseBindings,\n };\n}\n","/** PBR shader composer factory — extracts the per-feature-set shader composition\n * from pbr-renderable.ts. All dynamic dependencies (ACES, anisotropy, shadow,\n * multi-light, template-ext, thin-instance) are passed in via a deps object,\n * already resolved by the caller. Nothing is snapshotted at module load. */\n\nimport type { ShaderFragment, ComposedShader } from \"../../shader/fragment-types.js\";\nimport type { PbrShadowLightSlot } from \"./fragments/pbr-shadow-fragment.js\";\nimport { composeShader } from \"../../shader/shader-composer.js\";\nimport { createPbrTemplate } from \"./pbr-template.js\";\nimport type { MeshVbLayout } from \"../../mesh/mesh.js\";\nimport {\n PBR_HAS_NORMAL_MAP,\n PBR_HAS_ALPHA_BLEND,\n PBR2_HAS_UV_TRANSFORM,\n PBR2_HAS_REFLECTANCE_FACTORS,\n PBR2_HAS_UV2,\n PBR2_HAS_BASE_COLOR_FACTOR,\n PBR_HAS_METALLIC_REFLECTANCE_MAP,\n PBR_HAS_REFLECTANCE_MAP,\n PBR_HAS_SPECULAR_AA,\n PBR_HAS_EMISSIVE_COLOR,\n PBR_HAS_GAMMA_ALBEDO,\n PBR_HAS_ANISOTROPY,\n PBR_HAS_DOUBLE_SIDED,\n PBR_HAS_EMISSIVE,\n PBR_HAS_ENV,\n PBR_HAS_TONEMAP,\n PBR_HAS_FOG,\n PBR_HAS_SPEC_GLOSS,\n PBR_HAS_OCCLUSION,\n PBR_HAS_SKYBOX,\n PBR2_ESM_SHADOW_OUTPUT,\n PBR2_NO_COLOR_OUTPUT,\n} from \"./pbr-flag-bits.js\";\nimport { _getPbrExts, type _PbrFragCtx } from \"./pbr-flags.js\";\nimport {\n MSH_HAS_TANGENTS,\n MSH_HAS_MORPH_TARGETS,\n MSH_RECEIVE_SHADOWS,\n MSH_HAS_THIN_INSTANCES,\n MSH_HAS_INSTANCE_COLOR,\n MSH_HAS_VERTEX_COLOR,\n MSH_HAS_UV2,\n} from \"../mesh-features.js\";\n\ninterface PbrComposerDeps {\n readonly _singleLightWGSL: string;\n readonly _getSingleLightBlock: ((type: string) => string) | null;\n readonly _multiLightWGSL: string;\n readonly _multiLightLoop: string;\n readonly _acesHelpers: string;\n readonly _acesTonemapCall: string;\n /** Fog WGSL (calcFogFactor helper + blend block), dynamically loaded by pbr-renderable only\n * when scene.fog is set; \"\" otherwise so non-fog scenes bundle zero fog bytes. */\n readonly _fogHelper: string;\n readonly _fogBlock: string;\n readonly _createPbrTemplateExt: typeof import(\"./pbr-template-ext.js\").createPbrTemplateExt | null;\n readonly _anisoExt: typeof import(\"./fragments/anisotropy-fragment.js\") | null;\n readonly _iblSkyboxCalc: string;\n readonly _createPbrShadowFragment: ((slots: PbrShadowLightSlot[]) => ShaderFragment) | null;\n readonly _shadowLights: readonly { readonly lightIndex: number; readonly shadowType: import(\"./fragments/pbr-shadow-fragment.js\").PbrShadowLightSlot[\"shadowType\"] }[];\n readonly _createThinInstanceFragment: ((hasColor: boolean) => ShaderFragment) | null;\n}\n\nexport type PbrLightMode = 0 | 1 | 2;\ntype PbrComposeFn = (\n _features: number,\n _features2?: number,\n _meshFeatures?: number,\n _sceneFeatures?: number,\n _lightMode?: PbrLightMode,\n _singleLightType?: string,\n _esmShadowDepthCode?: string,\n _vbStrides?: MeshVbLayout,\n _vbKey?: string\n) => ComposedShader;\n\n/** Create a memoized shader composer for a given scene's resolved PBR deps. */\nexport function createPbrComposer(deps: PbrComposerDeps): PbrComposeFn {\n const cache = new Map<string, ComposedShader>();\n const {\n _singleLightWGSL,\n _getSingleLightBlock,\n _multiLightWGSL,\n _multiLightLoop,\n _acesHelpers,\n _acesTonemapCall,\n _fogHelper,\n _fogBlock,\n _createPbrTemplateExt,\n _anisoExt,\n _iblSkyboxCalc,\n _createPbrShadowFragment,\n _shadowLights,\n _createThinInstanceFragment,\n } = deps;\n\n return function composePbr(\n features: number,\n features2: number = 0,\n meshFeatures = 0,\n sceneFeatures = 0,\n lightMode: PbrLightMode = 0,\n singleLightType = \"\",\n _esmShadowDepthCode = \"\",\n vbStrides?: MeshVbLayout,\n vbKey = \"\"\n ): ComposedShader {\n const ckey = `${features}:${features2}:${meshFeatures}:${sceneFeatures}:${lightMode}:${singleLightType}${vbKey}`;\n const cached = cache.get(ckey);\n if (cached) {\n return cached;\n }\n\n const has = (bit: number) => (features & bit) !== 0;\n const hasMesh = (bit: number) => (meshFeatures & bit) !== 0;\n const hasScene = (bit: number) => (sceneFeatures & bit) !== 0;\n const hasNormal = has(PBR_HAS_NORMAL_MAP) && hasMesh(MSH_HAS_TANGENTS);\n const hasCotangent = has(PBR_HAS_NORMAL_MAP) && !hasMesh(MSH_HAS_TANGENTS);\n const _hasAnyNormal = hasNormal || hasCotangent;\n const _hasReflectanceExt = has(PBR_HAS_METALLIC_REFLECTANCE_MAP | PBR_HAS_REFLECTANCE_MAP) || (features2 & PBR2_HAS_REFLECTANCE_FACTORS) !== 0;\n const _hasIbl = hasScene(PBR_HAS_ENV);\n const _hasMorph = hasMesh(MSH_HAS_MORPH_TARGETS);\n const hasShadow = hasMesh(MSH_RECEIVE_SHADOWS);\n const _hasAnisotropy = has(PBR_HAS_ANISOTROPY);\n const _hasEmissiveColor = has(PBR_HAS_EMISSIVE_COLOR);\n const _hasEmissiveTexture = has(PBR_HAS_EMISSIVE);\n const hasTI = hasMesh(MSH_HAS_THIN_INSTANCES);\n\n const _hasUvTransform = (features2 & PBR2_HAS_UV_TRANSFORM) !== 0;\n const _hasVertexColor = hasMesh(MSH_HAS_VERTEX_COLOR);\n const _hasUv2 = (features2 & PBR2_HAS_UV2) !== 0 && hasMesh(MSH_HAS_UV2);\n const needsExt = _hasUvTransform || _hasVertexColor || _hasUv2;\n const _hasSpecularAA = has(PBR_HAS_SPECULAR_AA);\n const _ext =\n needsExt && _createPbrTemplateExt\n ? _createPbrTemplateExt({\n _hasUvTransform,\n _hasVertexColor,\n _hasUv2,\n _hasOcclusionUv2: _hasUv2,\n _hasAnyNormal,\n _hasEmissiveTexture,\n _hasSpecGloss: has(PBR_HAS_SPEC_GLOSS),\n })\n : undefined;\n\n const template = createPbrTemplate({\n _hasSingleLight: lightMode === 1,\n _hasMultiLight: lightMode === 2,\n _singleLightWGSL,\n _singleLightBlock: lightMode === 1 && _getSingleLightBlock ? _getSingleLightBlock(singleLightType) : \"\",\n _multiLightWGSL,\n _multiLightLoop,\n _normalMode: hasNormal ? \"tangent\" : hasCotangent ? \"cotangent\" : \"none\",\n _hasEmissiveTexture,\n _hasSpecGloss: has(PBR_HAS_SPEC_GLOSS),\n _hasDoubleSided: has(PBR_HAS_DOUBLE_SIDED),\n _hasTonemap: hasScene(PBR_HAS_TONEMAP),\n _fogHelper: hasScene(PBR_HAS_FOG) ? _fogHelper : \"\",\n _fogBlock: hasScene(PBR_HAS_FOG) ? _fogBlock : \"\",\n _acesHelpers: _acesHelpers,\n _acesTonemapCall: _acesTonemapCall,\n _hasAlphaBlend: has(PBR_HAS_ALPHA_BLEND),\n _hasSpecularAA,\n _hasGammaAlbedo: has(PBR_HAS_GAMMA_ALBEDO),\n _hasBaseColorFactor: (features2 & PBR2_HAS_BASE_COLOR_FACTOR) !== 0,\n _hasMorph,\n _hasOcclusion: has(PBR_HAS_OCCLUSION) && !_hasReflectanceExt,\n _hasEmissiveColor,\n _hasReflectanceExt,\n _hasIbl,\n _hasAnisotropy,\n _anisoBrdfFunctions: _hasAnisotropy && _anisoExt ? _anisoExt.ANISO_BRDF_FUNCTIONS : \"\",\n _anisoTBBlock: _hasAnisotropy && _anisoExt ? _anisoExt.makeAnisotropyTBBlock(hasNormal) : \"\",\n _ext,\n _noColorOutput: (features2 & PBR2_NO_COLOR_OUTPUT) !== 0,\n _esmShadowOutput: (features2 & PBR2_ESM_SHADOW_OUTPUT) !== 0,\n _esmShadowDepthCode,\n _vbStrides: vbStrides,\n });\n\n const frags: ShaderFragment[] = [];\n const fragCtx: _PbrFragCtx = {\n _features: features,\n _features2: features2,\n _meshFeatures: meshFeatures,\n _hasIbl: _hasIbl,\n _hasAnyNormal,\n _hasSpecularAA,\n _anisoBentNormalCode: _hasAnisotropy && _anisoExt ? _anisoExt.ANISO_BENT_NORMAL : \"\",\n _iblSkyboxCalc: has(PBR_HAS_SKYBOX) ? _iblSkyboxCalc : \"\",\n };\n // Registration order defines iteration order; callers register in composer-matching order.\n for (const regExt of _getPbrExts().values()) {\n if (regExt.frag) {\n const fr = regExt.frag(fragCtx);\n if (fr) {\n frags.push(fr);\n }\n }\n }\n if (hasShadow && _createPbrShadowFragment) {\n const slots = _shadowLights.map((sl) => ({ lightIndex: sl.lightIndex, shadowType: sl.shadowType }));\n frags.push(_createPbrShadowFragment(slots));\n }\n if (hasTI && _createThinInstanceFragment) {\n frags.push(_createThinInstanceFragment(hasMesh(MSH_HAS_INSTANCE_COLOR)));\n }\n\n const composed = composeShader(template, frags);\n cache.set(ckey, composed);\n return composed;\n };\n}\n","/** PBR mesh renderable — builds Renderables from glTF PBR meshes + environment.\n *\n * `buildPbrRenderables` does shared per-scene setup (extension/fragment imports,\n * shader composer, scene bind group, multi-light UBO), then delegates per-mesh\n * work to `buildSinglePbrRenderable`. Both initial build and material-swap\n * rebuilds go through the same single-mesh function. */\n\nimport type { EngineContext } from \"../../engine/engine.js\";\nimport type { SceneContext } from \"../../scene/scene.js\";\nimport type { Mesh } from \"../../mesh/mesh.js\";\nimport type { PbrMaterialProps } from \"./pbr-material.js\";\nimport { collectPbrBoundTextures } from \"./pbr-material.js\";\nimport type { EnvironmentTextures } from \"../../loader-env/load-env.js\";\n\nimport type { Renderable, MeshGroupBuildResult } from \"../../render/renderable.js\";\nimport type { ShaderFragment } from \"../../shader/fragment-types.js\";\nimport { acquireTexture, releaseTexture, clearSamplerCache } from \"../../resource/gpu-pool.js\";\nimport { createUniformBuffer } from \"../../resource/gpu-buffers.js\";\nimport { getOrCreatePbrBindings, getOrCreatePbrPipeline, createPbrMeshBindGroup, clearPbrPipelineCache } from \"./pbr-pipeline.js\";\nimport {\n _registerPbrExt,\n _getPbrExts,\n PBR_HAS_NORMAL_MAP,\n PBR_HAS_ALPHA_BLEND,\n PBR2_NO_COLOR_OUTPUT,\n PBR2_HAS_REFRACTION,\n PBR2_HAS_UV2,\n PBR_HAS_ENV,\n PBR_HAS_TONEMAP,\n PBR_HAS_FOG,\n PBR2_ESM_SHADOW_OUTPUT,\n} from \"./pbr-flags.js\";\nimport type { PbrExt } from \"./pbr-flags.js\";\nimport { createPbrComposer } from \"./pbr-compose.js\";\nimport { _computePbrMaterialFeatures } from \"./pbr-material.js\";\nimport type { ShadowGenerator } from \"../../shadow/shadow-generator.js\";\nimport type { ThinInstanceData } from \"../../mesh/thin-instance.js\";\nimport type { PbrShadowLightSlot } from \"./fragments/pbr-shadow-fragment.js\";\nimport { writeMeshLightSelection } from \"../../render/lights-ubo.js\";\nimport type { PbrLightMode } from \"./pbr-compose.js\";\nimport type { Material, MaterialRenderFeatures } from \"../material.js\";\nimport { _computeMeshFeatures, MSH_HAS_INSTANCE_COLOR, MSH_HAS_THIN_INSTANCES, MSH_HAS_UV2, MSH_HAS_VERTEX_COLOR } from \"../mesh-features.js\";\nimport { packMat4IntoF32 } from \"../../math/pack-mat4-into-f32.js\";\n\ntype SingleLightType = \"hemispheric\" | \"directional\" | \"spot\" | \"point\";\ninterface SingleLightWgslModule {\n SINGLE_LIGHT_STRUCTS: string;\n getSingleLightBlock(): string;\n}\n\n/** Build PBR Renderable(s) + a SceneUniformUpdater from PBR meshes. */\nexport async function buildPbrRenderables(scene: SceneContext, meshes: Mesh[], envTextures: EnvironmentTextures | undefined): Promise<MeshGroupBuildResult> {\n const engine = scene.engine;\n const device = engine._device;\n // Per-size scratch buffers for material UBO re-writes (zero allocation per frame).\n const materialScratch = new Map<number, Float32Array>();\n const hasEnv = !!envTextures;\n const shadowLights: { lightIndex: number; shadowType: \"esm\" | \"pcf\" | \"csm\"; gen: ShadowGenerator }[] = [];\n for (let i = 0; i < scene.lights.length; i++) {\n const sg = scene.lights[i]!.shadowGenerator;\n if (sg) {\n shadowLights.push({ lightIndex: i, shadowType: sg._shadowType, gen: sg });\n }\n }\n const hasSomeShadows = shadowLights.length > 0;\n let hasAnyAffectedLight = false;\n let needsSingleLightPath = false;\n let needsMultiLightPath = false;\n const singleLightTypes: SingleLightType[] = [];\n for (const mesh of meshes) {\n const lr = writeMeshLightSelection(mesh, scene.lights);\n const affectedCount = lr > 0 ? 1 : -lr;\n hasAnyAffectedLight ||= affectedCount > 0;\n if (affectedCount === 1 && !(mesh.receiveShadows && hasSomeShadows)) {\n needsSingleLightPath = true;\n const type = getPackedSingleLightType(scene.lights, lr - 1);\n if (!singleLightTypes.includes(type)) {\n singleLightTypes.push(type);\n }\n } else if (affectedCount > 0) {\n needsMultiLightPath = true;\n }\n }\n\n // ── Single O(N) scan over meshes for all scene-wide feature flags ──\n // Flags are plain locals (not an object return) so terser can mangle their names.\n // Replaces ~11 sequential meshes.some() loops (was O(11N)).\n let hasSkybox = false;\n let hasMetallicReflectance = false;\n let hasClearcoat = false;\n let hasSheen = false;\n let hasIridescence = false;\n let hasAnyAnisotropy = false;\n let hasAnySubsurface = false;\n let hasAlphaTest = false;\n let hasTransmissionRefraction = false;\n let needsEmissiveColor = false;\n let hasSomeSkeletons = false;\n let hasSomeMorphs = false;\n let hasSomeThinInstances = false;\n let hasCullingTI = false;\n let hasAnyUnlit = false;\n let hasAnyUvTransform = false;\n let hasAnyUv2 = false;\n let hasAnyVertexColor = false;\n for (let i = 0; i < meshes.length; i++) {\n const m = meshes[i]!;\n const mat = m.material as PbrMaterialProps & { _hasReflExt?: boolean; _hasUvTx?: boolean };\n const refractionIntensity = mat.subsurface?.refraction?.intensity ?? 0;\n hasSkybox ||= !!mat.skyboxMode;\n hasMetallicReflectance ||= !!(mat.metallicReflectanceTexture || mat.reflectanceTexture || mat._hasReflExt);\n hasClearcoat ||= !!mat.clearCoat?.isEnabled;\n hasSheen ||= !!mat.sheen?.isEnabled;\n hasIridescence ||= !!mat.iridescence?.isEnabled;\n hasAnyAnisotropy ||= !!mat.anisotropy?.isEnabled;\n hasAnySubsurface ||= !!mat.subsurface?.translucency;\n hasAlphaTest ||= mat.alphaCutOff! > 0;\n hasTransmissionRefraction ||= refractionIntensity > 0 && !!mat.transmissive;\n needsEmissiveColor ||= !!mat.emissiveColor;\n hasSomeSkeletons ||= !!m.skeleton;\n hasSomeMorphs ||= !!m.morphTargets;\n hasSomeThinInstances ||= !!m.thinInstances;\n hasCullingTI ||= !!m.thinInstances?._gpuCullingEnabled;\n hasAnyUnlit ||= !!mat.unlit;\n hasAnyUvTransform ||= !!mat._hasUvTx;\n // UV2 only counts when occlusion samples texcoord 1.\n hasAnyUv2 ||= !!m._gpu.uv2Buffer && mat.occlusionTexCoord === 1;\n hasAnyVertexColor ||= !!m._gpu.colorBuffer;\n }\n\n // ── Dynamically import fragment creators based on scene capabilities ──\n\n // IBL fragment.\n let _iblSkyboxCalc = \"\";\n if (hasEnv) {\n const mod = await import(\"./fragments/ibl-fragment.js\");\n _registerPbrExt(mod.pbrExt);\n if (hasSkybox) {\n // Skybox-mode WGSL is only loaded when at least one mesh in the scene needs it.\n const sky = await import(\"./fragments/ibl-skybox-wgsl.js\");\n _iblSkyboxCalc = sky.IBL_SKYBOX_CALCULATION;\n }\n }\n\n // Light/shadow helpers stay dynamic so single-light and non-shadow bundles stay lean.\n let _createPbrShadowFragment: ((slots: PbrShadowLightSlot[]) => ShaderFragment) | null = null;\n let _singleLightWGSL = \"\";\n let _getSingleLightBlock: ((type: string) => string) | null = null;\n const singleLightBlocks: Partial<Record<SingleLightType, () => string>> = {};\n let _multiLightWGSL = \"\";\n let _multiLightLoop = \"\";\n if (needsSingleLightPath) {\n for (const type of singleLightTypes) {\n const single = await importSingleLightWgsl(type);\n _singleLightWGSL = single.SINGLE_LIGHT_STRUCTS;\n singleLightBlocks[type] = single.getSingleLightBlock;\n }\n _getSingleLightBlock = (type) => singleLightBlocks[toSingleLightType(type)]?.() ?? \"\";\n }\n if (needsMultiLightPath) {\n const wgslMod = await import(\"./fragments/multilight-wgsl.js\");\n _multiLightWGSL = wgslMod.MULTI_LIGHT_STRUCTS() + wgslMod.COMPUTE_PBR_LIGHT;\n _multiLightLoop = wgslMod.getMultiLightLoop();\n }\n if (hasAnyAffectedLight && hasSomeShadows) {\n const shadowMod = await import(\"./fragments/pbr-shadow-fragment.js\");\n _createPbrShadowFragment = shadowMod.createPbrShadowFragment;\n }\n\n // ── Per-mesh fragment creators (imported if any mesh needs them) ──\n // Each optional PBR fragment module exports a uniform `pbrExt`, so registration\n // collapses to a single data-driven loop over [flag, loader] pairs. The `import()`\n // specifiers stay literal (required for Vite code-splitting) and the shared\n // `_registerPbrExt((await load()).pbrExt)` glue is emitted once instead of per\n // feature, keeping this management layer small as features are added.\n // Registration order is the iteration order consumed by `_getPbrExts().values()`\n // on the hot paths (composePbr, writeMaterialData, collectPbrBoundTextures).\n type PbrExtLoad = () => Promise<{ pbrExt: PbrExt }>;\n const _drainPbrExts = async (loaders: Array<readonly [boolean, PbrExtLoad]>) => {\n for (const [flag, load] of loaders) {\n if (flag) {\n _registerPbrExt((await load()).pbrExt);\n }\n }\n };\n\n await _drainPbrExts([\n [hasAlphaTest, () => import(\"./fragments/alpha-test-fragment.js\")],\n [hasMetallicReflectance, () => import(\"./fragments/reflectance-fragment.js\")],\n [hasClearcoat, () => import(\"./fragments/clearcoat-fragment.js\")],\n [hasSheen, () => import(\"./fragments/sheen-fragment.js\")],\n [hasIridescence, () => import(\"./fragments/iridescence-fragment.js\")],\n [hasAnySubsurface, () => import(\"./fragments/subsurface-fragment.js\")],\n ]);\n if (hasTransmissionRefraction) {\n const mod = await import(\"./pbr-refraction.js\");\n await mod.registerPbrRefraction(scene as SceneContext, engine, _registerPbrExt);\n }\n await _drainPbrExts([\n [needsEmissiveColor, () => import(\"./fragments/emissive-fragment.js\")],\n [hasAnyUnlit, () => import(\"./fragments/unlit-fragment.js\")],\n [hasSomeSkeletons, () => import(\"./fragments/skeleton-fragment.js\")],\n [hasSomeMorphs, () => import(\"./fragments/morph-fragment.js\")],\n [hasAnyUvTransform, () => import(\"./fragments/uv-transform-fragment.js\")],\n ]);\n\n // Anisotropy needs its module reference retained (for ANISO_BRDF_FUNCTIONS /\n // makeAnisotropyTBBlock / ANISO_DIRECT_DG / ANISO_BENT_NORMAL strings consumed\n // by the template below), so it keeps the full module binding.\n let _anisoExt: typeof import(\"./fragments/anisotropy-fragment.js\") | null = null;\n if (hasAnyAnisotropy) {\n _anisoExt = await import(\"./fragments/anisotropy-fragment.js\");\n _registerPbrExt(_anisoExt.pbrExt);\n }\n\n // Lazy-load pbr-template-ext when any advanced features are present.\n // Scene1 has none of these, so it won't pay the ~1.5KB cost.\n let _createPbrTemplateExt: typeof import(\"./pbr-template-ext.js\").createPbrTemplateExt | null = null;\n if (hasAnyUvTransform || hasAnyVertexColor || hasAnyUv2) {\n const extMod = await import(\"./pbr-template-ext.js\");\n _createPbrTemplateExt = extMod.createPbrTemplateExt;\n }\n\n let _createThinInstanceFragment: ((hasColor: boolean) => ShaderFragment) | null = null;\n let _syncThinInstanceBuffers:\n | ((\n engine: EngineContext,\n ti: ThinInstanceData,\n pass: GPURenderPassEncoder | GPURenderBundleEncoder,\n slot: number,\n hasColor: boolean,\n drawBuffers?: import(\"../../mesh/thin-instance-gpu.js\").ThinInstanceDrawBuffers | null\n ) => number)\n | null = null;\n let _cull: typeof import(\"../../mesh/thin-instance-cull-binding.js\") | undefined;\n // Per-frame thin-instance matrix/color UPLOAD (no pass — just writeBuffer of the dirty range).\n // The bundle-recorded draw only re-binds the buffer; animated instances (e.g. wind-swayed flora)\n // mutate their matrices every frame, but the cached opaque bundle is NOT re-recorded each frame,\n // so the draw-time sync never runs on a steady frame. We therefore upload dirty thin-instance data\n // from the per-frame update() below (which always runs). It is version-gated, so static instances\n // cost nothing, and it never recreates the buffer for a same-capacity update — keeping the cached\n // bundle's setVertexBuffer reference valid.\n let _syncThinInstanceGpuData: ((engine: EngineContext, ti: ThinInstanceData, hasColor: boolean) => void) | null = null;\n if (hasSomeThinInstances) {\n const mod = await import(\"../../shader/fragments/thin-instance-fragment.js\");\n _createThinInstanceFragment = mod.createThinInstanceFragment;\n const gpuMod = await import(\"../../mesh/thin-instance-gpu.js\");\n _syncThinInstanceBuffers = gpuMod.syncThinInstanceBuffers;\n if (hasCullingTI) {\n _cull = await import(\"../../mesh/thin-instance-cull-binding.js\");\n }\n _syncThinInstanceGpuData = gpuMod.syncThinInstanceGpuData;\n }\n\n // ACES tonemap WGSL is dynamically imported only when requested (keeps standard-tonemap bundles lean).\n // Must be loaded before the composer is created so deps are fully resolved.\n let _acesHelpers = \"\";\n let _acesTonemapCall = \"\";\n const hasTonemap = scene.imageProcessing.toneMappingEnabled;\n if (hasTonemap && scene.imageProcessing.toneMappingType === \"aces\") {\n const acesMod = await import(\"./pbr-aces-wgsl.js\");\n _acesHelpers = acesMod.ACES_HELPERS_WGSL;\n _acesTonemapCall = acesMod.ACES_TONEMAP_CALL_WGSL;\n }\n\n // Fog WGSL is dynamically imported only when the scene has fog, so non-fog PBR scenes\n // bundle zero fog bytes (a static import would defeat tree-shaking — see pbr-fog-wgsl.ts).\n let _fogHelper = \"\";\n let _fogBlock = \"\";\n if (scene.fog) {\n const fogMod = await import(\"./pbr-fog-wgsl.js\");\n _fogHelper = fogMod.PBR_FOG_HELPER;\n _fogBlock = fogMod.PBR_FOG_BLOCK;\n }\n\n const composePbr = createPbrComposer({\n _singleLightWGSL,\n _getSingleLightBlock,\n _multiLightWGSL,\n _multiLightLoop,\n _acesHelpers,\n _acesTonemapCall,\n _fogHelper,\n _fogBlock,\n _createPbrTemplateExt,\n _anisoExt,\n _iblSkyboxCalc,\n _createPbrShadowFragment,\n _shadowLights: shadowLights,\n _createThinInstanceFragment,\n });\n\n const sceneFeatures = (hasEnv ? PBR_HAS_ENV : 0) | (hasTonemap ? PBR_HAS_TONEMAP : 0) | (scene.fog ? PBR_HAS_FOG : 0);\n // Shadow bind group cache — within one scene build, all receiving meshes share the\n // same shadowLights array, so a BG keyed by shadowBGL alone is correct.\n const shadowBGCache = new Map<GPUBindGroupLayout, GPUBindGroup>();\n const syncThinInstanceBuffers = _syncThinInstanceBuffers;\n const syncThinInstanceGpuData = _syncThinInstanceGpuData;\n\n // Closure used both for the initial per-mesh build below AND for later\n // material-swap / per-pass-override rebuilds (set on pbrGroupBuilder._rebuildSingle).\n // Captures the per-scene context — no separate WeakMap needed.\n const rebuildSingle = (s: SceneContext, mesh: Mesh, materialOverride?: Material): Renderable => {\n const materialInput = (materialOverride ?? mesh.material) as PbrMaterialProps;\n const mat = materialInput;\n const renderFeatures = (mat._renderFeatures ??= _computePbrMaterialFeatures(mat)) as MaterialRenderFeatures;\n const isOverride = materialOverride != null;\n const mi = mesh;\n\n const lr = writeMeshLightSelection(mesh, s.lights);\n const lightCount = lr > 0 ? 1 : -lr;\n const features = renderFeatures.features;\n const features2 = renderFeatures.features2 ?? 0;\n const shadowOutput = (features2 & (PBR2_NO_COLOR_OUTPUT | PBR2_ESM_SHADOW_OUTPUT)) !== 0;\n const receiveShadows = !shadowOutput && mesh.receiveShadows && hasSomeShadows;\n const lightMode: PbrLightMode = lightCount === 0 ? 0 : lightCount === 1 && !receiveShadows ? 1 : 2;\n const singleLightType = lightMode === 1 ? getPackedSingleLightType(s.lights, lr - 1) : \"\";\n const meshFeatures = _computeMeshFeatures(mesh, receiveShadows);\n const esmShadowDepthCode = (features2 & PBR2_ESM_SHADOW_OUTPUT) !== 0 ? (mat as PbrMaterialProps & { readonly _esmShadowDepthCode: string })._esmShadowDepthCode : \"\";\n\n // Genuine GPU interleaving. Tight meshes have `_vbLayout` undefined → vbKey \"\"\n // → composed shader, bindings, and pipeline cache keys are byte-identical to\n // today. Interleaved meshes carry a precomputed vbKey from the loader module.\n const vbLayout = mi._gpu._vbLayout;\n const vbKey = mi._gpu._vbKey ?? \"\";\n\n const composed = composePbr(features, features2, meshFeatures, sceneFeatures, lightMode, singleLightType, esmShadowDepthCode, vbLayout, vbKey);\n const bindings = getOrCreatePbrBindings(engine, features, features2, meshFeatures, sceneFeatures, composed, `${lightMode}:${singleLightType}${vbKey}`);\n\n // Mesh UBO (world matrix at offset 0; spec.totalBytes covers any extra fields).\n const meshUboData = new Float32Array(composed._meshUboSpec._totalBytes / 4);\n const _packMeshWorld = engine._makePackMeshWorld?.(s as SceneContext) ?? packMat4IntoF32;\n _packMeshWorld(meshUboData, mesh.worldMatrix, 0, 0);\n writeMeshLightSelection(mesh, s.lights, meshUboData);\n const meshUBO = createUniformBuffer(engine, meshUboData);\n\n // Material UBO.\n const materialSpec = composed._materialUboSpec!;\n const matInitData = new Float32Array(materialSpec._totalBytes / 4);\n writeMaterialData(matInitData, mat, materialSpec);\n const materialUBO = createUniformBuffer(engine, matInitData);\n\n const needsTaskRefraction = !!mat.transmissive && (features2 & PBR2_HAS_REFRACTION) !== 0;\n const materialBindGroupStatic = needsTaskRefraction ? null : createPbrMeshBindGroup(engine, bindings, composed, meshUBO, materialUBO, mat, envTextures ?? null, mesh);\n\n // Shadow bind group (group 2) — shared across receiving meshes via shadowBGCache.\n let shadowBindGroup: GPUBindGroup | null = null;\n const meshShadowLights = receiveShadows ? shadowLights : [];\n if (meshShadowLights.length > 0 && bindings._shadowBGL) {\n let cached = shadowBGCache.get(bindings._shadowBGL);\n if (!cached) {\n const entries: GPUBindGroupEntry[] = [];\n let b = 0;\n for (const sl of meshShadowLights) {\n const sg = sl.gen;\n entries.push({ binding: b++, resource: sg._depthTexture.createView() });\n entries.push({ binding: b++, resource: sg._depthSampler });\n entries.push({ binding: b++, resource: { buffer: sg._shadowUBO } });\n }\n cached = device.createBindGroup({ layout: bindings._shadowBGL, entries });\n shadowBGCache.set(bindings._shadowBGL, cached);\n }\n shadowBindGroup = cached;\n }\n\n const boundTextures = collectPbrBoundTextures(mat);\n for (const t of boundTextures) {\n acquireTexture(t);\n }\n s._meshDisposables.set(mesh, [\n () => {\n meshUBO.destroy();\n materialUBO.destroy();\n },\n () => {\n for (const t of boundTextures) {\n releaseTexture(t);\n }\n },\n ]);\n\n const isTransparent = (features2 & (PBR2_NO_COLOR_OUTPUT | PBR2_ESM_SHADOW_OUTPUT)) === 0 && (features & PBR_HAS_ALPHA_BLEND) !== 0;\n const order = mesh.renderOrder ?? (isTransparent || needsTaskRefraction ? 150 : 100);\n\n const hasNormalMap = (features & PBR_HAS_NORMAL_MAP) !== 0;\n const hasUV2 = (features2 & PBR2_HAS_UV2) !== 0 && (meshFeatures & MSH_HAS_UV2) !== 0;\n const hasVertexColor = (meshFeatures & MSH_HAS_VERTEX_COLOR) !== 0;\n const hasTI = (meshFeatures & MSH_HAS_THIN_INSTANCES) !== 0;\n const hasTIColor = (meshFeatures & MSH_HAS_INSTANCE_COLOR) !== 0;\n\n let _lastWorldVersion = mesh.worldMatrixVersion;\n let _lastLightsCount = s.lights.length;\n const sortCenter = isTransparent || needsTaskRefraction ? ([mesh.worldMatrix[12]!, mesh.worldMatrix[13]!, mesh.worldMatrix[14]!] as [number, number, number]) : null;\n const _baseUpdate = (): void => {\n const worldVersion = mesh.worldMatrixVersion;\n if (worldVersion !== _lastWorldVersion || s.lights.length !== _lastLightsCount) {\n if (sortCenter) {\n sortCenter[0] = mesh.worldMatrix[12]!;\n sortCenter[1] = mesh.worldMatrix[13]!;\n sortCenter[2] = mesh.worldMatrix[14]!;\n }\n _packMeshWorld(meshUboData, mesh.worldMatrix, 0, 0);\n writeMeshLightSelection(mesh, s.lights, meshUboData);\n device.queue.writeBuffer(meshUBO, 0, meshUboData as Float32Array<ArrayBuffer>);\n _lastWorldVersion = worldVersion;\n _lastLightsCount = s.lights.length;\n }\n const uboVersion = mat._uboVersion;\n if (uboVersion !== _lastUboVersion) {\n _lastUboVersion = uboVersion;\n let data = materialScratch.get(materialSpec._totalBytes);\n if (!data) {\n data = new Float32Array(materialSpec._totalBytes / 4);\n materialScratch.set(materialSpec._totalBytes, data);\n } else {\n data.fill(0);\n }\n writeMaterialData(data, mat, materialSpec);\n device.queue.writeBuffer(materialUBO, 0, data.buffer, 0, data.byteLength);\n }\n // Upload any dirty thin-instance matrices/colors every frame (version-gated; see the\n // _syncThinInstanceGpuData declaration above). This is what makes per-frame animated\n // instance transforms (wind sway) actually reach the GPU despite the cached draw bundle.\n if (hasTI && syncThinInstanceGpuData) {\n const ti = mesh.thinInstances;\n if (ti) {\n syncThinInstanceGpuData(engine, ti, hasTIColor);\n }\n }\n };\n // FO-version wrapper applied only when the engine has floating-origin\n // on (see standard-renderable for the rationale).\n const _invalidate = (): void => {\n _lastWorldVersion = -1;\n };\n const update = engine._wrapRenderableForFO?.(_baseUpdate, s as SceneContext, _invalidate) ?? _baseUpdate;\n\n const drawWith = (\n pass: GPURenderPassEncoder | GPURenderBundleEncoder,\n materialBindGroup: GPUBindGroup,\n cullBinding?: import(\"../../mesh/thin-instance-cull-binding.js\").TiCullBinding\n ): number => {\n if (!isOverride && mesh.material !== materialInput) {\n return 0;\n }\n const gpu = mi._gpu;\n pass.setBindGroup(1, materialBindGroup);\n if (shadowBindGroup) {\n pass.setBindGroup(2, shadowBindGroup);\n }\n let slot = 0;\n const vb = gpu._vbLayout;\n pass.setVertexBuffer(slot++, gpu.positionBuffer, vb?._p?._offset);\n pass.setVertexBuffer(slot++, gpu.normalBuffer, vb?._n?._offset);\n if (hasNormalMap && gpu.tangentBuffer) {\n pass.setVertexBuffer(slot++, gpu.tangentBuffer, vb?._t?._offset);\n }\n pass.setVertexBuffer(slot++, gpu.uvBuffer, vb?._u?._offset);\n if (hasUV2 && gpu.uv2Buffer) {\n pass.setVertexBuffer(slot++, gpu.uv2Buffer, vb?._u2?._offset);\n }\n if (hasVertexColor && gpu.colorBuffer) {\n pass.setVertexBuffer(slot++, gpu.colorBuffer, vb?._c?._offset);\n }\n if (mesh.skeleton) {\n pass.setVertexBuffer(slot++, mesh.skeleton.jointsBuffer);\n pass.setVertexBuffer(slot++, mesh.skeleton.weightsBuffer);\n if (mesh.skeleton.joints1Buffer && mesh.skeleton.weights1Buffer) {\n pass.setVertexBuffer(slot++, mesh.skeleton.joints1Buffer);\n pass.setVertexBuffer(slot++, mesh.skeleton.weights1Buffer);\n }\n }\n\n const ti = hasTI ? mesh.thinInstances : null;\n if (ti && syncThinInstanceBuffers) {\n slot = syncThinInstanceBuffers(engine, ti, pass, slot, hasTIColor, cullBinding?.cullDrawBufs);\n }\n\n pass.setIndexBuffer(gpu.indexBuffer, gpu.indexFormat);\n if (cullBinding) {\n cullBinding.draw(pass, gpu.indexCount, ti!.count);\n } else if (ti && ti.count > 0) {\n pass.drawIndexed(gpu.indexCount, ti.count);\n } else {\n pass.drawIndexed(gpu.indexCount);\n }\n return 1;\n };\n\n const r: Renderable = {\n order,\n isTransparent,\n _transmissive: needsTaskRefraction,\n mesh,\n bind(eng, sig) {\n const pipeline = getOrCreatePbrPipeline(eng as EngineContext, sig, bindings);\n const materialBindGroup = needsTaskRefraction\n ? createPbrMeshBindGroup(engine, bindings, composed, meshUBO, materialUBO, mat, envTextures ?? null, mesh, sig._transmissionTexture)\n : materialBindGroupStatic!;\n // Opaque-only GPU culling (opt-in): tryBind returns a per-binding lifecycle or undefined.\n const cb = _cull?.tryBind(r, s, mesh, engine, hasTIColor, isTransparent || needsTaskRefraction, update);\n return {\n renderable: r,\n pipeline,\n update: cb ? cb.update : update,\n draw: (pass) => drawWith(pass, materialBindGroup, cb),\n };\n },\n };\n if (sortCenter) {\n r._worldCenter = sortCenter;\n }\n let _lastUboVersion = mat._uboVersion;\n return r;\n };\n\n const renderables = meshes.map((m) => rebuildSingle(scene, m));\n\n scene._disposables.push(\n () => clearPbrPipelineCache(),\n () => clearSamplerCache(engine)\n );\n\n return { renderables, rebuildSingle };\n}\n\nfunction toSingleLightType(type: string): SingleLightType {\n return type === \"hemispheric\" || type === \"directional\" || type === \"spot\" ? type : \"point\";\n}\n\nfunction getPackedSingleLightType(lights: SceneContext[\"lights\"], packedIndex: number): SingleLightType {\n let packed = 0;\n for (const light of lights) {\n if (!light._writeLightUbo) {\n continue;\n }\n if (packed === packedIndex) {\n return toSingleLightType(light.lightType);\n }\n packed++;\n }\n return \"point\";\n}\n\nasync function importSingleLightWgsl(type: SingleLightType): Promise<SingleLightWgslModule> {\n if (type === \"hemispheric\") {\n return import(\"./fragments/singlelight-hemispheric-wgsl.js\");\n }\n if (type === \"directional\") {\n return import(\"./fragments/singlelight-directional-wgsl.js\");\n }\n if (type === \"spot\") {\n return import(\"./fragments/singlelight-spot-wgsl.js\");\n }\n return import(\"./fragments/singlelight-point-wgsl.js\");\n}\n\n/** Write material properties into a pre-allocated Float32Array.\n * Core fields only; per-extension slices are contributed by registered\n * writers. */\nfunction writeMaterialData(data: Float32Array, material: PbrMaterialProps, spec: import(\"../../shader/fragment-types.js\").UboSpec): void {\n data[0] = material.environmentIntensity ?? 1.0;\n data[1] = material.directIntensity ?? 1.0;\n data[2] = material.reflectance ?? 0.04;\n data[3] = material.alpha ?? 1.0;\n const baseColorFactorOffset = spec._offsets.get(\"baseColorFactor\");\n if (baseColorFactorOffset !== undefined) {\n const off = baseColorFactorOffset / 4;\n const factor = material.baseColorFactor;\n data[off] = factor ? factor[0]! : 1.0;\n data[off + 1] = factor ? factor[1]! : 1.0;\n data[off + 2] = factor ? factor[2]! : 1.0;\n data[off + 3] = factor ? factor[3]! : 1.0;\n }\n if (spec._offsets.has(\"metallicFactor\")) {\n const off = spec._offsets.get(\"metallicFactor\")! / 4;\n data[off] = material.metallicFactor ?? 1.0;\n data[off + 1] = material.roughnessFactor ?? 1.0;\n data[off + 2] = material.normalTextureScale ?? 1.0;\n data[off + 3] = material.usePhysicalLightFalloff === false ? 0 : 1;\n }\n for (const ext of _getPbrExts().values()) {\n if (ext.writeUbo) {\n ext.writeUbo(data, material, spec._offsets);\n }\n }\n}\n"],"names":["_a","_b","_c","_d","_e","_f"],"mappings":";;AAqCA,MAAM,qCAAqB,IAAA;AAC3B,IAAI,gBAAkC;AAEtC,SAAS,aAAa,QAA6B;AAC/C,MAAI,kBAAkB,OAAO,SAAS;AAClC,mBAAe,MAAA;AACf,oBAAgB,OAAO;AAAA,EAC3B;AACJ;AAGO,SAAS,wBAA8B;AAC1C,iBAAe,MAAA;AACf,kBAAgB;AACpB;AAIO,SAAS,uBACZ,QACA,UACA,WACA,cACA,eACA,UACA,YAAY,IACM;AAClB,eAAa,MAAM;AACnB,QAAM,MAAM,GAAG,QAAQ,IAAI,SAAS,IAAI,YAAY,IAAI,aAAa,IAAI,SAAS;AAClF,QAAM,SAAS,eAAe,IAAI,GAAG;AACrC,MAAI,QAAQ;AACR,WAAO;AAAA,EACX;AAEA,QAAM,SAAS,OAAO;AACtB,QAAM,UAAU,OAAO,sBAAsB,SAAS,kBAAkB;AACxE,MAAI,YAAuC;AAC3C,MAAI,SAAS,sBAAsB;AAC/B,gBAAY,OAAO,sBAAsB,SAAS,oBAAoB;AAAA,EAC1E;AACA,QAAM,WAA+B;AAAA,IACjC,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,gCAAgB,IAAA;AAAA,EAAI;AAExB,iBAAe,IAAI,KAAK,QAAQ;AAChC,SAAO;AACX;AAGO,SAAS,uBAAuB,QAAuB,KAA4B,UAAiD;AACvI,eAAa,MAAM;AACnB,QAAM,MAAM,mBAAmB,GAAG;AAClC,Q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,CAAC,IAAK;AACtC,SAAK,MAAM,CAAC,IAAI,SAAS,OAAO,CAAC,IAAK;AACtC,SAAK,MAAM,CAAC,IAAI,SAAS,OAAO,CAAC,IAAK;AAAA,EAC1C;AACA,MAAI,KAAK,SAAS,IAAI,gBAAgB,GAAG;AACrC,UAAM,MAAM,KAAK,SAAS,IAAI,gBAAgB,IAAK;AACnD,SAAK,GAAG,IAAI,SAAS,kBAAkB;AACvC,SAAK,MAAM,CAAC,IAAI,SAAS,mBAAmB;AAC5C,SAAK,MAAM,CAAC,IAAI,SAAS,sBAAsB;AAC/C,SAAK,MAAM,CAAC,IAAI,SAAS,4BAA4B,QAAQ,IAAI;AAAA,EACrE;AACA,aAAW,OAAO,YAAA,EAAc,OAAA,GAAU;AACtC,QAAI,IAAI,UAAU;AACd,UAAI,SAAS,MAAM,UAAU,KAAK,QAAQ;AAAA,IAC9C;AAAA,EACJ;AACJ;"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { c as createShadowFragment } from "./shadow-fragment-core-DHN2G6FI.js";
|
|
2
|
+
import { ac as getCsmPbrReceiverFactory } from "./index-B7Qhw0xL.js";
|
|
2
3
|
function createPbrShadowFragment(shadowLights = [{ lightIndex: 0, shadowType: "esm" }]) {
|
|
3
4
|
var _a;
|
|
5
|
+
const csmSlots = shadowLights.filter((sl) => sl.shadowType === "csm");
|
|
6
|
+
if (csmSlots.length > 0) {
|
|
7
|
+
return getCsmPbrReceiverFactory()(csmSlots.map((s) => ({ lightIndex: s.lightIndex })));
|
|
8
|
+
}
|
|
4
9
|
const fragment = createShadowFragment("pbr-shadow", shadowLights);
|
|
5
10
|
const shadowCode = (_a = fragment._fragmentSlots) == null ? void 0 : _a.AD;
|
|
6
11
|
return {
|
|
@@ -11,4 +16,4 @@ function createPbrShadowFragment(shadowLights = [{ lightIndex: 0, shadowType: "e
|
|
|
11
16
|
export {
|
|
12
17
|
createPbrShadowFragment
|
|
13
18
|
};
|
|
14
|
-
//# sourceMappingURL=pbr-shadow-fragment-
|
|
19
|
+
//# sourceMappingURL=pbr-shadow-fragment-BxUrFJYZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbr-shadow-fragment-BxUrFJYZ.js","sources":["../src/material/pbr/fragments/pbr-shadow-fragment.ts"],"sourcesContent":["/**\n * PBR Shadow Fragment — Per-Light Shadow Support\n *\n * Thin wrapper around the shared shadow-fragment-core for PBR materials.\n * Only bundled when a scene uses shadow-receiving PBR meshes.\n */\n\nimport type { ShaderFragment } from \"../../../shader/fragment-types.js\";\nimport { createShadowFragment } from \"../../../shader/fragments/shadow-fragment-core.js\";\nimport type { ShadowLightSlot } from \"../../../shader/fragments/shadow-fragment-core.js\";\nimport { getCsmPbrReceiverFactory } from \"../../../shadow/csm-receiver-registry.js\";\n\n/** Type alias preserving the existing PBR-specific name. */\nexport type PbrShadowLightSlot = ShadowLightSlot;\n\n/**\n * Create a per-light PBR shadow fragment.\n * Each shadow-casting light gets its own varying, bindings, and sampling code.\n * The shadow factor for each light is stored in shadowFactors[lightIndex].\n *\n * If any slot is a cascaded-shadow (`\"csm\"`) light, the cascaded receiver factory\n * registered by the CSM generator is used (it already emits into slot `AS`).\n * Otherwise the plain ESM/PCF core is used and its `AD` slot is remapped to `AS`.\n */\nexport function createPbrShadowFragment(shadowLights: PbrShadowLightSlot[] = [{ lightIndex: 0, shadowType: \"esm\" }]): ShaderFragment {\n const csmSlots = shadowLights.filter((sl) => sl.shadowType === \"csm\");\n if (csmSlots.length > 0) {\n return getCsmPbrReceiverFactory()!(csmSlots.map((s) => ({ lightIndex: s.lightIndex })));\n }\n const fragment = createShadowFragment(\"pbr-shadow\", shadowLights);\n const shadowCode = fragment._fragmentSlots?.AD;\n return {\n ...fragment,\n _fragmentSlots: shadowCode ? { AS: shadowCode } : undefined,\n };\n}\n"],"names":[],"mappings":";;AAwBO,SAAS,wBAAwB,eAAqC,CAAC,EAAE,YAAY,GAAG,YAAY,MAAA,CAAO,GAAmB;;AACjI,QAAM,WAAW,aAAa,OAAO,CAAC,OAAO,GAAG,eAAe,KAAK;AACpE,MAAI,SAAS,SAAS,GAAG;AACrB,WAAO,yBAAA,EAA4B,SAAS,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,WAAA,EAAa,CAAC;AAAA,EAC1F;AACA,QAAM,WAAW,qBAAqB,cAAc,YAAY;AAChE,QAAM,cAAa,cAAS,mBAAT,mBAAyB;AAC5C,SAAO;AAAA,IACH,GAAG;AAAA,IACH,gBAAgB,aAAa,EAAE,IAAI,eAAe;AAAA,EAAA;AAE1D;"}
|
|
@@ -61,7 +61,8 @@ return vec2<f32>(dot(m.xy, uv), dot(m.zw, uv)) + t;
|
|
|
61
61
|
const uvForOrm = uvVarName("orm");
|
|
62
62
|
const uvForEmissive = uvVarName("emissive");
|
|
63
63
|
const uvForSpecGloss = uvVarName("specGloss");
|
|
64
|
-
const baseColorMod = _hasVertexColor ?
|
|
64
|
+
const baseColorMod = _hasVertexColor ? `
|
|
65
|
+
baseColor *= input.vColor;` : "";
|
|
65
66
|
const normalScaleMod = "let scaledNormal = vec3<f32>(normalMapRaw.xy * material.normalScale, normalMapRaw.z);\n";
|
|
66
67
|
const occlusionOverride = _hasOcclusionUv2 ? "let occlusion = textureSample(occlusionTexture, occlusionSampler_, input.uv2).r;" : null;
|
|
67
68
|
return {
|
|
@@ -85,4 +86,4 @@ return vec2<f32>(dot(m.xy, uv), dot(m.zw, uv)) + t;
|
|
|
85
86
|
export {
|
|
86
87
|
createPbrTemplateExt
|
|
87
88
|
};
|
|
88
|
-
//# sourceMappingURL=pbr-template-ext-
|
|
89
|
+
//# sourceMappingURL=pbr-template-ext-CGgB2n2y.js.map
|