@vived/component-abb-6700 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/.todo.md +13 -0
  2. package/README.md +122 -0
  3. package/dist/.gitkeep +0 -0
  4. package/dist/Adapters/aBB6700PMAdapter.d.ts +10 -0
  5. package/dist/Adapters/aBB6700PMAdapter.d.ts.map +1 -0
  6. package/dist/Controllers/createABB6700.d.ts +12 -0
  7. package/dist/Controllers/createABB6700.d.ts.map +1 -0
  8. package/dist/Controllers/getPose.d.ts +11 -0
  9. package/dist/Controllers/getPose.d.ts.map +1 -0
  10. package/dist/Controllers/setJointAngle.d.ts +12 -0
  11. package/dist/Controllers/setJointAngle.d.ts.map +1 -0
  12. package/dist/Controllers/setPose.d.ts +11 -0
  13. package/dist/Controllers/setPose.d.ts.map +1 -0
  14. package/dist/Entities/ABB6700Entity.d.ts +35 -0
  15. package/dist/Entities/ABB6700Entity.d.ts.map +1 -0
  16. package/dist/Entities/ABB6700Repo.d.ts +32 -0
  17. package/dist/Entities/ABB6700Repo.d.ts.map +1 -0
  18. package/dist/Factory/ABB6700FeatureFactory.d.ts +26 -0
  19. package/dist/Factory/ABB6700FeatureFactory.d.ts.map +1 -0
  20. package/dist/Mocks/MockABB6700PM.d.ts +11 -0
  21. package/dist/Mocks/MockABB6700PM.d.ts.map +1 -0
  22. package/dist/Mocks/MockSetJointAngleUC.d.ts +7 -0
  23. package/dist/Mocks/MockSetJointAngleUC.d.ts.map +1 -0
  24. package/dist/Mocks/MockSetPoseUC.d.ts +7 -0
  25. package/dist/Mocks/MockSetPoseUC.d.ts.map +1 -0
  26. package/dist/PMs/ABB6700PM.d.ts +32 -0
  27. package/dist/PMs/ABB6700PM.d.ts.map +1 -0
  28. package/dist/UCs/CalcStabilizerUC.d.ts +7 -0
  29. package/dist/UCs/CalcStabilizerUC.d.ts.map +1 -0
  30. package/dist/UCs/SetJointAngleUC.d.ts +15 -0
  31. package/dist/UCs/SetJointAngleUC.d.ts.map +1 -0
  32. package/dist/UCs/SetPoseUC.d.ts +22 -0
  33. package/dist/UCs/SetPoseUC.d.ts.map +1 -0
  34. package/dist/Views/ABB6700BabylonView.d.ts +27 -0
  35. package/dist/Views/ABB6700BabylonView.d.ts.map +1 -0
  36. package/dist/abb_6700.glb +0 -0
  37. package/dist/abstractAudioBus-CyBWsmuN.js +14 -0
  38. package/dist/animationGroup-BhNThqQe.js +1454 -0
  39. package/dist/basisTextureLoader-BT391BsV.js +310 -0
  40. package/dist/brdfTextureTools-DUyKBAXf.js +79 -0
  41. package/dist/bumpFragment-Dd-ojPA1.js +134 -0
  42. package/dist/bumpFragment-KE1_PuMl.js +287 -0
  43. package/dist/bumpVertex-BcdvVFVx.js +8 -0
  44. package/dist/bumpVertexDeclaration-B5Uvs-RS.js +8 -0
  45. package/dist/bumpVertexDeclaration-ixSg-yGI.js +8 -0
  46. package/dist/clipPlaneFragment-DJwQynjA.js +136 -0
  47. package/dist/clipPlaneVertex-D4Wk50XG.js +376 -0
  48. package/dist/clipPlaneVertex-eQ147Tn2.js +350 -0
  49. package/dist/component.config.d.ts +17 -0
  50. package/dist/component.config.d.ts.map +1 -0
  51. package/dist/ddsTextureLoader-DeoF3iGO.js +331 -0
  52. package/dist/default.fragment-DKnTR9nY.js +548 -0
  53. package/dist/default.fragment-rIGWrUS5.js +486 -0
  54. package/dist/default.vertex-Bt5y1VyA.js +212 -0
  55. package/dist/default.vertex-Dext1liJ.js +224 -0
  56. package/dist/defaultUboDeclaration-BwslQZX8.js +11 -0
  57. package/dist/defaultUboDeclaration-DSXACgip.js +9 -0
  58. package/dist/easing-BAt0SO-B.js +163 -0
  59. package/dist/envTextureLoader-CBiW_Q-U.js +40 -0
  60. package/dist/exrTextureLoader-5SC6PKIA.js +740 -0
  61. package/dist/flowGraphApplyForceBlock-6e8-wcaw.js +32 -0
  62. package/dist/flowGraphApplyImpulseBlock-B27EZQow.js +32 -0
  63. package/dist/flowGraphArrayIndexBlock-DIUn5e4i.js +31 -0
  64. package/dist/flowGraphBezierCurveEasingBlock-BJmiHk40.js +25 -0
  65. package/dist/flowGraphBinaryOperationBlock-Bj7TANCc.js +25 -0
  66. package/dist/flowGraphBranchBlock-7CRvIKWc.js +19 -0
  67. package/dist/flowGraphCachedOperationBlock-CP1ZiuIB.js +26 -0
  68. package/dist/flowGraphCancelDelayBlock-DqtgzBGm.js +20 -0
  69. package/dist/flowGraphCodeExecutionBlock-CaYXCGqo.js +23 -0
  70. package/dist/flowGraphConditionalDataBlock-DJ7evX8_.js +28 -0
  71. package/dist/flowGraphConsoleLogBlock-cMkpqLzO.js +68 -0
  72. package/dist/flowGraphConstantBlock-JWybwT0A.js +28 -0
  73. package/dist/flowGraphContextBlock-CFDXHcbn.js +19 -0
  74. package/dist/flowGraphCounterBlock-B0uPkgw9.js +24 -0
  75. package/dist/flowGraphDataSwitchBlock-B0GSifvJ.js +27 -0
  76. package/dist/flowGraphDebounceBlock-CSw8zKym.js +24 -0
  77. package/dist/flowGraphDebugBlock-DiSR6Ahn.js +65 -0
  78. package/dist/flowGraphDoNBlock-C-48oQ2H.js +24 -0
  79. package/dist/flowGraphEasingBlock-DKUaE7Rp.js +50 -0
  80. package/dist/flowGraphFlipFlopBlock-DX5BGhMV.js +20 -0
  81. package/dist/flowGraphForLoopBlock-Di-Qwg23.js +27 -0
  82. package/dist/flowGraphFunctionReferenceBlock-D8X5TFsO.js +20 -0
  83. package/dist/flowGraphGLTFDataProvider-C4j7nPQv.js +16 -0
  84. package/dist/flowGraphGetAngularVelocityBlock-Cq-yTQ4D.js +31 -0
  85. package/dist/flowGraphGetAssetBlock-B36eioor.js +21 -0
  86. package/dist/flowGraphGetLinearVelocityBlock-MdrV0eUD.js +31 -0
  87. package/dist/flowGraphGetPhysicsMassPropertiesBlock-wXDZP1wM.js +30 -0
  88. package/dist/flowGraphGetPropertyBlock-eP0badwf.js +46 -0
  89. package/dist/flowGraphGetSoundVolumeBlock-D3gXGHXa.js +29 -0
  90. package/dist/flowGraphGetVariableBlock-C7-qZAec.js +31 -0
  91. package/dist/flowGraphIndexOfBlock-CC5l9n9P.js +31 -0
  92. package/dist/flowGraphInterpolationBlock-B6922jzt.js +50 -0
  93. package/dist/flowGraphIsKeyPressedBlock-X_iuiUOX.js +31 -0
  94. package/dist/flowGraphIsSoundPlayingBlock-DONQX8N8.js +29 -0
  95. package/dist/flowGraphJsonPointerParserBlock-DBH_gN8I.js +95 -0
  96. package/dist/flowGraphKeyDownEventBlock-D5T1Uyfv.js +26 -0
  97. package/dist/flowGraphKeyUpEventBlock-BPY_Kgkm.js +21 -0
  98. package/dist/flowGraphKeyboardEventBlock-C49fx3TC.js +20 -0
  99. package/dist/flowGraphMathBlocks-CkvrN3VJ.js +864 -0
  100. package/dist/flowGraphMathCombineExtractBlocks-QSjGlnoz.js +248 -0
  101. package/dist/flowGraphMatrixMathBlocks-B3D7Cz9p.js +117 -0
  102. package/dist/flowGraphMeshPickEventBlock-BBTz-taa.js +35 -0
  103. package/dist/flowGraphMultiGateBlock-BhY1y5BG.js +50 -0
  104. package/dist/flowGraphPauseAnimationBlock-CHZZXMbg.js +19 -0
  105. package/dist/flowGraphPauseSoundBlock-B7hMmJ0c.js +31 -0
  106. package/dist/flowGraphPhysicsCollisionEventBlock-CxoPpT-q.js +56 -0
  107. package/dist/flowGraphPlayAnimationBlock-DVAvIFux.js +99 -0
  108. package/dist/flowGraphPlaySoundBlock-DjHGrqbC.js +32 -0
  109. package/dist/flowGraphPointerDownEventBlock-qI-H0JST.js +31 -0
  110. package/dist/flowGraphPointerMoveEventBlock-DAi4VUyy.js +31 -0
  111. package/dist/flowGraphPointerOutEventBlock-CFtj68aC.js +21 -0
  112. package/dist/flowGraphPointerOverEventBlock-VxdHhFuu.js +23 -0
  113. package/dist/flowGraphPointerUpEventBlock-DRR1f07q.js +31 -0
  114. package/dist/flowGraphReceiveCustomEventBlock-B3bwdB66.js +52 -0
  115. package/dist/flowGraphSceneReadyEventBlock-Dy6lDT3j.js +23 -0
  116. package/dist/flowGraphSceneTickEventBlock-Bl9BF_Xw.js +32 -0
  117. package/dist/flowGraphSendCustomEventBlock-BAR4PGFq.js +35 -0
  118. package/dist/flowGraphSequenceBlock-veqU32ZZ.js +32 -0
  119. package/dist/flowGraphSetAngularVelocityBlock-Dj9b-zu6.js +31 -0
  120. package/dist/flowGraphSetDelayBlock-CMjudtvk.js +131 -0
  121. package/dist/flowGraphSetLinearVelocityBlock-DVDhhJBd.js +31 -0
  122. package/dist/flowGraphSetPhysicsMotionTypeBlock-CL3cxNCO.js +36 -0
  123. package/dist/flowGraphSetPropertyBlock-D3sWL3Ss.js +47 -0
  124. package/dist/flowGraphSetSoundVolumeBlock-CxVk45yR.js +32 -0
  125. package/dist/flowGraphSetVariableBlock-D1oJiwLj.js +47 -0
  126. package/dist/flowGraphSoundEndedEventBlock-CubEwii0.js +47 -0
  127. package/dist/flowGraphStopAnimationBlock-B9inwIQx.js +48 -0
  128. package/dist/flowGraphStopSoundBlock-BijIX2jC.js +31 -0
  129. package/dist/flowGraphSwitchBlock-BMhPb4OX.js +54 -0
  130. package/dist/flowGraphThrottleBlock-C7vrnkb1.js +37 -0
  131. package/dist/flowGraphTransformCoordinatesSystemBlock-DoISqaUG.js +29 -0
  132. package/dist/flowGraphTypeToTypeBlocks-CSML6QWx.js +57 -0
  133. package/dist/flowGraphUnaryOperationBlock-B0Shf-lJ.js +24 -0
  134. package/dist/flowGraphVectorMathBlocks-DoTRR_E0.js +178 -0
  135. package/dist/flowGraphWaitAllBlock-BvmDMc24.js +54 -0
  136. package/dist/flowGraphWhileLoopBlock-BaIq4-K2.js +27 -0
  137. package/dist/geometry.fragment-Bsis3UG2.js +275 -0
  138. package/dist/geometry.vertex-DskQ5b8j.js +222 -0
  139. package/dist/harmonicsFunctions-CtNrRfir.js +193 -0
  140. package/dist/harmonicsFunctions-PEz6APC7.js +18 -0
  141. package/dist/hdrTextureLoader-D9rYxJ9q.js +112 -0
  142. package/dist/helperFunctions-Bt7Zfkrp.js +89 -0
  143. package/dist/helperFunctions-CPmRxd37.js +121 -0
  144. package/dist/iesTextureLoader-BGUFjVhI.js +93 -0
  145. package/dist/index-CS3Icp_r.js +67657 -0
  146. package/dist/index.d.ts +23 -0
  147. package/dist/index.d.ts.map +1 -0
  148. package/dist/index.js +27 -0
  149. package/dist/ktxTextureLoader-cUaGg9_L.js +459 -0
  150. package/dist/lightFragment-BRDibDKG.js +404 -0
  151. package/dist/lightFragment-DCqtGMp_.js +402 -0
  152. package/dist/logDepthDeclaration-Bwm-3KyB.js +16 -0
  153. package/dist/logDepthDeclaration-gUfeSnXX.js +20 -0
  154. package/dist/logDepthVertex-CKeuJ6ae.js +213 -0
  155. package/dist/logDepthVertex-CXkmZels.js +459 -0
  156. package/dist/mesh.vertexData.functions-Bc9lJlrU.js +74 -0
  157. package/dist/oitFragment-B8zuQigp.js +792 -0
  158. package/dist/oitFragment-DH3h3T6x.js +657 -0
  159. package/dist/openpbr.fragment-BglYS6LA.js +1405 -0
  160. package/dist/openpbr.fragment-DrOTZs4m.js +1553 -0
  161. package/dist/openpbr.vertex-B-PaLFOR.js +384 -0
  162. package/dist/openpbr.vertex-DMdFRTnX.js +268 -0
  163. package/dist/openpbrMaterial-HCU0aOca.js +2880 -0
  164. package/dist/openpbrMaterialLoadingAdapter-CWRAa-7S.js +1122 -0
  165. package/dist/openpbrTransmissionLayerData-CfDVObj5.js +352 -0
  166. package/dist/openpbrUboDeclaration-CA2pvSbt.js +9 -0
  167. package/dist/openpbrUboDeclaration-xU8VOaib.js +10 -0
  168. package/dist/pass.fragment-1mMP54bb.js +10 -0
  169. package/dist/pass.fragment-DzaUp_jk.js +10 -0
  170. package/dist/passCube.fragment-CQaXS7g3.js +29 -0
  171. package/dist/passCube.fragment-QJGPwAXI.js +29 -0
  172. package/dist/pbr.fragment-BnaAAGxb.js +2775 -0
  173. package/dist/pbr.fragment-CYZk_EGU.js +2619 -0
  174. package/dist/pbr.vertex-CyvdCw91.js +372 -0
  175. package/dist/pbr.vertex-DJMAkDxs.js +270 -0
  176. package/dist/pbrBRDFFunctions-EugoWm6O.js +175 -0
  177. package/dist/pbrDebug-Bk3sPoEG.js +719 -0
  178. package/dist/pbrDebug-Cdalzb1I.js +614 -0
  179. package/dist/pbrIBLFunctions-B0bVAXCF.js +47 -0
  180. package/dist/pbrIBLFunctions-C06z-ouZ.js +51 -0
  181. package/dist/pbrMaterial-C4FCKBZQ.js +1660 -0
  182. package/dist/pbrMaterialLoadingAdapter-BGHlS_ZN.js +1032 -0
  183. package/dist/pbrUboDeclaration-1lN5_-Bw.js +9 -0
  184. package/dist/pbrUboDeclaration-BJOUUOZ2.js +10 -0
  185. package/dist/procedural.vertex-CFPKczKj.js +14 -0
  186. package/dist/procedural.vertex-DUW7bYZt.js +13 -0
  187. package/dist/rgbdDecode.fragment-CEGgE4tL.js +8 -0
  188. package/dist/rgbdDecode.fragment-FT0wkgah.js +8 -0
  189. package/dist/rgbdEncode.fragment-CLnJJf6E.js +8 -0
  190. package/dist/rgbdEncode.fragment-CaAcMsY9.js +8 -0
  191. package/dist/sceneUboDeclaration-B6oxsfcj.js +8 -0
  192. package/dist/sceneUboDeclaration-JByfVKik.js +13 -0
  193. package/dist/setupABB6700InstanceFactory.d.ts +7 -0
  194. package/dist/setupABB6700InstanceFactory.d.ts.map +1 -0
  195. package/dist/studio.env +0 -0
  196. package/dist/textureProcessor.fragment-BYPw6SMQ.js +152 -0
  197. package/dist/textureProcessor.fragment-Ciw9-F3w.js +157 -0
  198. package/dist/textureTools-Cct_bGgp.js +40 -0
  199. package/dist/tgaTextureLoader-BJOIdnFr.js +198 -0
  200. package/dist/thinEngine-Bt9FW4dD.js +2425 -0
  201. package/dist/webAudioBus-BUzRHSxr.js +88 -0
  202. package/dist/webAudioMainBus-Dds1TgJG.js +49 -0
  203. package/package.json +49 -0
@@ -0,0 +1,2619 @@
1
+ import { b0 as e } from "./index-CS3Icp_r.js";
2
+ import "./oitFragment-DH3h3T6x.js";
3
+ import "./pbrUboDeclaration-1lN5_-Bw.js";
4
+ import "./pbrDebug-Bk3sPoEG.js";
5
+ import "./clipPlaneFragment-DJwQynjA.js";
6
+ import "./pbrIBLFunctions-B0bVAXCF.js";
7
+ import "./logDepthDeclaration-Bwm-3KyB.js";
8
+ import "./helperFunctions-Bt7Zfkrp.js";
9
+ import "./harmonicsFunctions-PEz6APC7.js";
10
+ import "./pbrBRDFFunctions-EugoWm6O.js";
11
+ import "./bumpFragment-Dd-ojPA1.js";
12
+ import "./lightFragment-DCqtGMp_.js";
13
+ const i = "samplerFragmentAlternateDeclaration", T = `#ifdef _DEFINENAME_
14
+ #if _DEFINENAME_DIRECTUV==1
15
+ #define v_VARYINGNAME_UV vMainUV1
16
+ #elif _DEFINENAME_DIRECTUV==2
17
+ #define v_VARYINGNAME_UV vMainUV2
18
+ #elif _DEFINENAME_DIRECTUV==3
19
+ #define v_VARYINGNAME_UV vMainUV3
20
+ #elif _DEFINENAME_DIRECTUV==4
21
+ #define v_VARYINGNAME_UV vMainUV4
22
+ #elif _DEFINENAME_DIRECTUV==5
23
+ #define v_VARYINGNAME_UV vMainUV5
24
+ #elif _DEFINENAME_DIRECTUV==6
25
+ #define v_VARYINGNAME_UV vMainUV6
26
+ #else
27
+ varying v_VARYINGNAME_UV: vec2f;
28
+ #endif
29
+ #endif
30
+ `;
31
+ e.IncludesShadersStoreWGSL[i] || (e.IncludesShadersStoreWGSL[i] = T);
32
+ const r = "pbrFragmentSamplersDeclaration", L = `#include<samplerFragmentDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)
33
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight)
34
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness)
35
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
36
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
37
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
38
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
39
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)
40
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)
41
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)
42
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)
43
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
44
+ #ifdef CLEARCOAT
45
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)
46
+ #include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
47
+ #if defined(CLEARCOAT_TEXTURE_ROUGHNESS)
48
+ var clearCoatRoughnessSamplerSampler: sampler;var clearCoatRoughnessSampler: texture_2d<f32>;
49
+ #endif
50
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)
51
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)
52
+ #endif
53
+ #ifdef IRIDESCENCE
54
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_SAMPLERNAME_,iridescence)
55
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_SAMPLERNAME_,iridescenceThickness)
56
+ #endif
57
+ #ifdef SHEEN
58
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)
59
+ #include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
60
+ #if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS)
61
+ var sheenRoughnessSamplerSampler: sampler;var sheenRoughnessSampler: texture_2d<f32>;
62
+ #endif
63
+ #endif
64
+ #ifdef ANISOTROPIC
65
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)
66
+ #endif
67
+ #include<pbrFragmentReflectionDeclaration>
68
+ #ifdef ENVIRONMENTBRDF
69
+ var environmentBrdfSamplerSampler: sampler;var environmentBrdfSampler: texture_2d<f32>;
70
+ #endif
71
+ #ifdef SUBSURFACE
72
+ #ifdef SS_REFRACTION
73
+ #ifdef SS_REFRACTIONMAP_3D
74
+ var refractionSamplerSampler: sampler;var refractionSampler: texture_cube<f32>;
75
+ #ifdef LODBASEDMICROSFURACE
76
+ #else
77
+ var refractionLowSamplerSampler: sampler;var refractionLowSampler: texture_cube<f32>;var refractionHighSamplerSampler: sampler;var refractionHighSampler: texture_cube<f32>;
78
+ #endif
79
+ #else
80
+ var refractionSamplerSampler: sampler;var refractionSampler: texture_2d<f32>;
81
+ #ifdef LODBASEDMICROSFURACE
82
+ #else
83
+ var refractionLowSamplerSampler: sampler;var refractionLowSampler: texture_2d<f32>;var refractionHighSamplerSampler: sampler;var refractionHighSampler: texture_2d<f32>;
84
+ #endif
85
+ #endif
86
+ #endif
87
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)
88
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)
89
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)
90
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_SAMPLERNAME_,translucencyColor)
91
+ #endif
92
+ #ifdef IBL_CDF_FILTERING
93
+ var icdfSamplerSampler: sampler;var icdfSampler: texture_2d<f32>;
94
+ #endif
95
+ `;
96
+ e.IncludesShadersStoreWGSL[r] || (e.IncludesShadersStoreWGSL[r] = L);
97
+ const n = "pbrBlockAlbedoOpacity", _ = `struct albedoOpacityOutParams
98
+ {surfaceAlbedo: vec3f,
99
+ alpha: f32};
100
+ #define pbr_inline
101
+ fn albedoOpacityBlock(
102
+ vAlbedoColor: vec4f
103
+ #ifdef ALBEDO
104
+ ,albedoTexture: vec4f
105
+ ,albedoInfos: vec2f
106
+ #endif
107
+ ,baseWeight: f32
108
+ #ifdef BASE_WEIGHT
109
+ ,baseWeightTexture: vec4f
110
+ ,vBaseWeightInfos: vec2f
111
+ #endif
112
+ #ifdef OPACITY
113
+ ,opacityMap: vec4f
114
+ ,vOpacityInfos: vec2f
115
+ #endif
116
+ #ifdef DETAIL
117
+ ,detailColor: vec4f
118
+ ,vDetailInfos: vec4f
119
+ #endif
120
+ #ifdef DECAL
121
+ ,decalColor: vec4f
122
+ ,vDecalInfos: vec4f
123
+ #endif
124
+ )->albedoOpacityOutParams
125
+ {var outParams: albedoOpacityOutParams;var surfaceAlbedo: vec3f=vAlbedoColor.rgb;var alpha: f32=vAlbedoColor.a;
126
+ #ifdef ALBEDO
127
+ #if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)
128
+ alpha*=albedoTexture.a;
129
+ #endif
130
+ #ifdef GAMMAALBEDO
131
+ surfaceAlbedo*=toLinearSpaceVec3(albedoTexture.rgb);
132
+ #else
133
+ surfaceAlbedo*=albedoTexture.rgb;
134
+ #endif
135
+ surfaceAlbedo*=albedoInfos.y;
136
+ #endif
137
+ #ifndef DECAL_AFTER_DETAIL
138
+ #include<decalFragment>
139
+ #endif
140
+ #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
141
+ surfaceAlbedo*=fragmentInputs.vColor.rgb;
142
+ #endif
143
+ #ifdef DETAIL
144
+ var detailAlbedo: f32=2.0*mix(0.5,detailColor.r,vDetailInfos.y);surfaceAlbedo=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;
145
+ #endif
146
+ #ifdef DECAL_AFTER_DETAIL
147
+ #include<decalFragment>
148
+ #endif
149
+ #define CUSTOM_FRAGMENT_UPDATE_ALBEDO
150
+ surfaceAlbedo*=baseWeight;
151
+ #ifdef BASE_WEIGHT
152
+ surfaceAlbedo*=baseWeightTexture.r;
153
+ #endif
154
+ #ifdef OPACITY
155
+ #ifdef OPACITYRGB
156
+ alpha=getLuminance(opacityMap.rgb);
157
+ #else
158
+ alpha*=opacityMap.a;
159
+ #endif
160
+ alpha*=vOpacityInfos.y;
161
+ #endif
162
+ #if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
163
+ alpha*=fragmentInputs.vColor.a;
164
+ #endif
165
+ #if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)
166
+ #ifdef ALPHATEST
167
+ #if DEBUGMODE != 88
168
+ if (alpha<ALPHATESTVALUE) {discard;}
169
+ #endif
170
+ #ifndef ALPHABLEND
171
+ alpha=1.0;
172
+ #endif
173
+ #endif
174
+ #endif
175
+ outParams.surfaceAlbedo=surfaceAlbedo;outParams.alpha=alpha;return outParams;}
176
+ `;
177
+ e.IncludesShadersStoreWGSL[n] || (e.IncludesShadersStoreWGSL[n] = _);
178
+ const f = "pbrBlockReflectivity", M = `struct reflectivityOutParams
179
+ {microSurface: f32,
180
+ roughness: f32,
181
+ diffuseRoughness: f32,
182
+ reflectanceF0: f32,
183
+ reflectanceF90: vec3f,
184
+ colorReflectanceF0: vec3f,
185
+ colorReflectanceF90: vec3f,
186
+ #ifdef METALLICWORKFLOW
187
+ surfaceAlbedo: vec3f,
188
+ metallic: f32,
189
+ specularWeight: f32,
190
+ dielectricColorF0: vec3f,
191
+ #endif
192
+ #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
193
+ ambientOcclusionColor: vec3f,
194
+ #endif
195
+ #if DEBUGMODE>0
196
+ #ifdef METALLICWORKFLOW
197
+ #ifdef REFLECTIVITY
198
+ surfaceMetallicColorMap: vec4f,
199
+ #endif
200
+ metallicF0: vec3f,
201
+ #else
202
+ #ifdef REFLECTIVITY
203
+ surfaceReflectivityColorMap: vec4f,
204
+ #endif
205
+ #endif
206
+ #endif
207
+ };
208
+ #define pbr_inline
209
+ fn reflectivityBlock(
210
+ reflectivityColor: vec4f
211
+ #ifdef METALLICWORKFLOW
212
+ ,surfaceAlbedo: vec3f
213
+ ,metallicReflectanceFactors: vec4f
214
+ #endif
215
+ ,baseDiffuseRoughness: f32
216
+ #ifdef BASE_DIFFUSE_ROUGHNESS
217
+ ,baseDiffuseRoughnessTexture: f32
218
+ ,baseDiffuseRoughnessInfos: vec2f
219
+ #endif
220
+ #ifdef REFLECTIVITY
221
+ ,reflectivityInfos: vec3f
222
+ ,surfaceMetallicOrReflectivityColorMap: vec4f
223
+ #endif
224
+ #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
225
+ ,ambientOcclusionColorIn: vec3f
226
+ #endif
227
+ #ifdef MICROSURFACEMAP
228
+ ,microSurfaceTexel: vec4f
229
+ #endif
230
+ #ifdef DETAIL
231
+ ,detailColor: vec4f
232
+ ,vDetailInfos: vec4f
233
+ #endif
234
+ )->reflectivityOutParams
235
+ {var outParams: reflectivityOutParams;var microSurface: f32=reflectivityColor.a;var surfaceReflectivityColor: vec3f=reflectivityColor.rgb;
236
+ #ifdef METALLICWORKFLOW
237
+ var metallicRoughness: vec2f=surfaceReflectivityColor.rg;var ior: f32=surfaceReflectivityColor.b;
238
+ #ifdef REFLECTIVITY
239
+ #if DEBUGMODE>0
240
+ outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
241
+ #endif
242
+ #ifdef AOSTOREINMETALMAPRED
243
+ var aoStoreInMetalMap: vec3f= vec3f(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
244
+ #endif
245
+ #ifdef METALLNESSSTOREINMETALMAPBLUE
246
+ metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
247
+ #else
248
+ metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
249
+ #endif
250
+ #ifdef ROUGHNESSSTOREINMETALMAPALPHA
251
+ metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
252
+ #else
253
+ #ifdef ROUGHNESSSTOREINMETALMAPGREEN
254
+ metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
255
+ #endif
256
+ #endif
257
+ #endif
258
+ #ifdef DETAIL
259
+ var detailRoughness: f32=mix(0.5,detailColor.b,vDetailInfos.w);var loLerp: f32=mix(0.,metallicRoughness.g,detailRoughness*2.);var hiLerp: f32=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
260
+ #endif
261
+ #ifdef MICROSURFACEMAP
262
+ metallicRoughness.g*=microSurfaceTexel.r;
263
+ #endif
264
+ #define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS
265
+ microSurface=1.0-metallicRoughness.g;var baseColor: vec3f=surfaceAlbedo;outParams.metallic=metallicRoughness.r;outParams.specularWeight=metallicReflectanceFactors.a;var dielectricF0 : f32=reflectivityColor.a*outParams.specularWeight;surfaceReflectivityColor=metallicReflectanceFactors.rgb;
266
+ #if DEBUGMODE>0
267
+ outParams.metallicF0=dielectricF0*surfaceReflectivityColor;
268
+ #endif
269
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
270
+ outParams.surfaceAlbedo=baseColor.rgb*(vec3f(1.0)-vec3f(dielectricF0)*surfaceReflectivityColor)*(1.0-outParams.metallic);
271
+ #else
272
+ outParams.surfaceAlbedo=baseColor.rgb;
273
+ #endif
274
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
275
+ {let reflectivityColor: vec3f=mix(dielectricF0*surfaceReflectivityColor,baseColor.rgb,outParams.metallic);outParams.reflectanceF0=max(reflectivityColor.r,max(reflectivityColor.g,reflectivityColor.b));}
276
+ #else
277
+ #if DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_GLTF
278
+ let maxF0: f32=max(surfaceReflectivityColor.r,max(surfaceReflectivityColor.g,surfaceReflectivityColor.b));outParams.reflectanceF0=mix(dielectricF0*maxF0,1.0f,outParams.metallic);
279
+ #else
280
+ outParams.reflectanceF0=mix(dielectricF0,1.0,outParams.metallic);
281
+ #endif
282
+ #endif
283
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
284
+ outParams.reflectanceF90=vec3(outParams.specularWeight);var f90Scale: f32=1.0;
285
+ #else
286
+ var f90Scale: f32=clamp(2.0*(ior-1.0),0.0,1.0);outParams.reflectanceF90=vec3(mix(
287
+ outParams.specularWeight*f90Scale,1.0,outParams.metallic));
288
+ #endif
289
+ outParams.dielectricColorF0=vec3f(dielectricF0*surfaceReflectivityColor);var metallicColorF0: vec3f=baseColor.rgb;outParams.colorReflectanceF0=mix(outParams.dielectricColorF0,metallicColorF0,outParams.metallic);
290
+ #if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR)
291
+ let dielectricColorF90
292
+ : vec3f=surfaceReflectivityColor *
293
+ vec3f(outParams.specularWeight*f90Scale);
294
+ #else
295
+ let dielectricColorF90
296
+ : vec3f=vec3f(outParams.specularWeight*f90Scale);
297
+ #endif
298
+ #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
299
+ let conductorColorF90: vec3f=surfaceReflectivityColor;
300
+ #else
301
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
302
+ let conductorColorF90: vec3f=outParams.reflectanceF90;
303
+ #else
304
+ let conductorColorF90: vec3f=vec3f(1.0f);
305
+ #endif
306
+ #endif
307
+ outParams.colorReflectanceF90=mix(dielectricColorF90,conductorColorF90,outParams.metallic);
308
+ #else
309
+ #ifdef REFLECTIVITY
310
+ surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
311
+ #if DEBUGMODE>0
312
+ outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
313
+ #endif
314
+ #ifdef MICROSURFACEFROMREFLECTIVITYMAP
315
+ microSurface*=surfaceMetallicOrReflectivityColorMap.a;microSurface*=reflectivityInfos.z;
316
+ #else
317
+ #ifdef MICROSURFACEAUTOMATIC
318
+ microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
319
+ #endif
320
+ #ifdef MICROSURFACEMAP
321
+ microSurface*=microSurfaceTexel.r;
322
+ #endif
323
+ #define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE
324
+ #endif
325
+ #endif
326
+ outParams.colorReflectanceF0=surfaceReflectivityColor;outParams.reflectanceF0=max(surfaceReflectivityColor.r,max(surfaceReflectivityColor.g,surfaceReflectivityColor.b));outParams.reflectanceF90=vec3f(1.0);
327
+ #if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR)
328
+ outParams.colorReflectanceF90=surfaceReflectivityColor;
329
+ #else
330
+ outParams.colorReflectanceF90=vec3(1.0);
331
+ #endif
332
+ #endif
333
+ microSurface=saturate(microSurface);var roughness: f32=1.-microSurface;var diffuseRoughness: f32=baseDiffuseRoughness;
334
+ #ifdef BASE_DIFFUSE_ROUGHNESS
335
+ diffuseRoughness*=baseDiffuseRoughnessTexture*baseDiffuseRoughnessInfos.y;
336
+ #endif
337
+ outParams.microSurface=microSurface;outParams.roughness=roughness;outParams.diffuseRoughness=diffuseRoughness;return outParams;}
338
+ `;
339
+ e.IncludesShadersStoreWGSL[f] || (e.IncludesShadersStoreWGSL[f] = M);
340
+ const o = "pbrBlockAmbientOcclusion", D = `struct ambientOcclusionOutParams
341
+ {ambientOcclusionColor: vec3f,
342
+ #if DEBUGMODE>0 && defined(AMBIENT)
343
+ ambientOcclusionColorMap: vec3f
344
+ #endif
345
+ };
346
+ #define pbr_inline
347
+ fn ambientOcclusionBlock(
348
+ #ifdef AMBIENT
349
+ ambientOcclusionColorMap_: vec3f,
350
+ vAmbientInfos: vec4f
351
+ #endif
352
+ )->ambientOcclusionOutParams
353
+ {
354
+ var outParams: ambientOcclusionOutParams;var ambientOcclusionColor: vec3f= vec3f(1.,1.,1.);
355
+ #ifdef AMBIENT
356
+ var ambientOcclusionColorMap: vec3f=ambientOcclusionColorMap_*vAmbientInfos.y;
357
+ #ifdef AMBIENTINGRAYSCALE
358
+ ambientOcclusionColorMap= vec3f(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);
359
+ #endif
360
+ ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);
361
+ #if DEBUGMODE>0
362
+ outParams.ambientOcclusionColorMap=ambientOcclusionColorMap;
363
+ #endif
364
+ #endif
365
+ outParams.ambientOcclusionColor=ambientOcclusionColor;return outParams;}
366
+ `;
367
+ e.IncludesShadersStoreWGSL[o] || (e.IncludesShadersStoreWGSL[o] = D);
368
+ const t = "pbrBlockAlphaFresnel", F = `#ifdef ALPHAFRESNEL
369
+ #if defined(ALPHATEST) || defined(ALPHABLEND)
370
+ struct alphaFresnelOutParams
371
+ {alpha: f32};fn faceforward(N: vec3<f32>,I: vec3<f32>,Nref: vec3<f32>)->vec3<f32> {return select(N,-N,dot(Nref,I)>0.0);}
372
+ #define pbr_inline
373
+ fn alphaFresnelBlock(
374
+ normalW: vec3f,
375
+ viewDirectionW: vec3f,
376
+ alpha: f32,
377
+ microSurface: f32
378
+ )->alphaFresnelOutParams
379
+ {var outParams: alphaFresnelOutParams;var opacityPerceptual: f32=alpha;
380
+ #ifdef LINEARALPHAFRESNEL
381
+ var opacity0: f32=opacityPerceptual;
382
+ #else
383
+ var opacity0: f32=opacityPerceptual*opacityPerceptual;
384
+ #endif
385
+ var opacity90: f32=fresnelGrazingReflectance(opacity0);var normalForward: vec3f=faceforward(normalW,-viewDirectionW,normalW);outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)), vec3f(opacity0), vec3f(opacity90),sqrt(microSurface)).x;
386
+ #ifdef ALPHATEST
387
+ if (outParams.alpha<ALPHATESTVALUE) {discard;}
388
+ #ifndef ALPHABLEND
389
+ outParams.alpha=1.0;
390
+ #endif
391
+ #endif
392
+ return outParams;}
393
+ #endif
394
+ #endif
395
+ `;
396
+ e.IncludesShadersStoreWGSL[t] || (e.IncludesShadersStoreWGSL[t] = F);
397
+ const c = "pbrBlockAnisotropic", P = `#ifdef ANISOTROPIC
398
+ struct anisotropicOutParams
399
+ {anisotropy: f32,
400
+ anisotropicTangent: vec3f,
401
+ anisotropicBitangent: vec3f,
402
+ anisotropicNormal: vec3f,
403
+ #if DEBUGMODE>0 && defined(ANISOTROPIC_TEXTURE)
404
+ anisotropyMapData: vec3f
405
+ #endif
406
+ };
407
+ #define pbr_inline
408
+ fn anisotropicBlock(
409
+ vAnisotropy: vec3f,
410
+ roughness: f32,
411
+ #ifdef ANISOTROPIC_TEXTURE
412
+ anisotropyMapData: vec3f,
413
+ #endif
414
+ TBN: mat3x3f,
415
+ normalW: vec3f,
416
+ viewDirectionW: vec3f
417
+ )->anisotropicOutParams
418
+ {
419
+ var outParams: anisotropicOutParams;var anisotropy: f32=vAnisotropy.b;var anisotropyDirection: vec3f= vec3f(vAnisotropy.xy,0.);
420
+ #ifdef ANISOTROPIC_TEXTURE
421
+ var amd=anisotropyMapData.rg;anisotropy*=anisotropyMapData.b;
422
+ #if DEBUGMODE>0
423
+ outParams.anisotropyMapData=anisotropyMapData;
424
+ #endif
425
+ amd=amd*2.0-1.0;
426
+ #ifdef ANISOTROPIC_LEGACY
427
+ anisotropyDirection=vec3f(anisotropyDirection.xy*amd,anisotropyDirection.z);
428
+ #else
429
+ anisotropyDirection=vec3f(mat2x2f(anisotropyDirection.x,anisotropyDirection.y,-anisotropyDirection.y,anisotropyDirection.x)*normalize(amd),anisotropyDirection.z);
430
+ #endif
431
+ #endif
432
+ var anisoTBN: mat3x3f= mat3x3f(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));var anisotropicTangent: vec3f=normalize(anisoTBN*anisotropyDirection);var anisotropicBitangent: vec3f=normalize(cross(anisoTBN[2],anisotropicTangent));outParams.anisotropy=anisotropy;outParams.anisotropicTangent=anisotropicTangent;outParams.anisotropicBitangent=anisotropicBitangent;outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy,roughness);return outParams;}
433
+ #endif
434
+ `;
435
+ e.IncludesShadersStoreWGSL[c] || (e.IncludesShadersStoreWGSL[c] = P);
436
+ const l = "pbrBlockReflection", g = `#ifdef REFLECTION
437
+ struct reflectionOutParams
438
+ {environmentRadiance: vec4f
439
+ ,environmentIrradiance: vec3f
440
+ #ifdef REFLECTIONMAP_3D
441
+ ,reflectionCoords: vec3f
442
+ #else
443
+ ,reflectionCoords: vec2f
444
+ #endif
445
+ #ifdef SS_TRANSLUCENCY
446
+ #ifdef USESPHERICALFROMREFLECTIONMAP
447
+ #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
448
+ ,irradianceVector: vec3f
449
+ #endif
450
+ #endif
451
+ #endif
452
+ };
453
+ #define pbr_inline
454
+ #ifdef REFLECTIONMAP_3D
455
+ fn createReflectionCoords(
456
+ vPositionW: vec3f,
457
+ normalW: vec3f,
458
+ #ifdef ANISOTROPIC
459
+ anisotropicOut: anisotropicOutParams,
460
+ #endif
461
+ )->vec3f
462
+ {var reflectionCoords: vec3f;
463
+ #else
464
+ fn createReflectionCoords(
465
+ vPositionW: vec3f,
466
+ normalW: vec3f,
467
+ #ifdef ANISOTROPIC
468
+ anisotropicOut: anisotropicOutParams,
469
+ #endif
470
+ )->vec2f
471
+ {
472
+ var reflectionCoords: vec2f;
473
+ #endif
474
+ #ifdef ANISOTROPIC
475
+ var reflectionVector: vec3f=computeReflectionCoords( vec4f(vPositionW,1.0),anisotropicOut.anisotropicNormal);
476
+ #else
477
+ var reflectionVector: vec3f=computeReflectionCoords( vec4f(vPositionW,1.0),normalW);
478
+ #endif
479
+ #ifdef REFLECTIONMAP_OPPOSITEZ
480
+ reflectionVector.z*=-1.0;
481
+ #endif
482
+ #ifdef REFLECTIONMAP_3D
483
+ reflectionCoords=reflectionVector;
484
+ #else
485
+ reflectionCoords=reflectionVector.xy;
486
+ #ifdef REFLECTIONMAP_PROJECTION
487
+ reflectionCoords/=reflectionVector.z;
488
+ #endif
489
+ reflectionCoords.y=1.0-reflectionCoords.y;
490
+ #endif
491
+ return reflectionCoords;}
492
+ #define pbr_inline
493
+ fn sampleReflectionTexture(
494
+ alphaG: f32
495
+ ,vReflectionMicrosurfaceInfos: vec3f
496
+ ,vReflectionInfos: vec2f
497
+ ,vReflectionColor: vec3f
498
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
499
+ ,NdotVUnclamped: f32
500
+ #endif
501
+ #ifdef LINEARSPECULARREFLECTION
502
+ ,roughness: f32
503
+ #endif
504
+ #ifdef REFLECTIONMAP_3D
505
+ ,reflectionSampler: texture_cube<f32>
506
+ ,reflectionSamplerSampler: sampler
507
+ ,reflectionCoords: vec3f
508
+ #else
509
+ ,reflectionSampler: texture_2d<f32>
510
+ ,reflectionSamplerSampler: sampler
511
+ ,reflectionCoords: vec2f
512
+ #endif
513
+ #ifndef LODBASEDMICROSFURACE
514
+ #ifdef REFLECTIONMAP_3D
515
+ ,reflectionLowSampler: texture_cube<f32>
516
+ ,reflectionLowSamplerSampler: sampler
517
+ ,reflectionHighSampler: texture_cube<f32>
518
+ ,reflectionHighSamplerSampler: sampler
519
+ #else
520
+ ,reflectionLowSampler: texture_2d<f32>
521
+ ,reflectionLowSamplerSampler: sampler
522
+ ,reflectionHighSampler: texture_2d<f32>
523
+ ,reflectionHighSamplerSampler: sampler
524
+ #endif
525
+ #endif
526
+ #ifdef REALTIME_FILTERING
527
+ ,vReflectionFilteringInfo: vec2f
528
+ #endif
529
+ )->vec4f
530
+ {var environmentRadiance: vec4f;
531
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
532
+ var reflectionLOD: f32=getLodFromAlphaGNdotV(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
533
+ #elif defined(LINEARSPECULARREFLECTION)
534
+ var reflectionLOD: f32=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
535
+ #else
536
+ var reflectionLOD: f32=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
537
+ #endif
538
+ #ifdef LODBASEDMICROSFURACE
539
+ reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
540
+ #ifdef LODINREFLECTIONALPHA
541
+ var automaticReflectionLOD: f32=UNPACK_LOD(textureSample(reflectionSampler,reflectionSamplerSampler,reflectionCoords).a);var requestedReflectionLOD: f32=max(automaticReflectionLOD,reflectionLOD);
542
+ #else
543
+ var requestedReflectionLOD: f32=reflectionLOD;
544
+ #endif
545
+ #ifdef REALTIME_FILTERING
546
+ environmentRadiance= vec4f(radiance(alphaG,reflectionSampler,reflectionSamplerSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
547
+ #else
548
+ environmentRadiance=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD);
549
+ #endif
550
+ #else
551
+ var lodReflectionNormalized: f32=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));var lodReflectionNormalizedDoubled: f32=lodReflectionNormalized*2.0;var environmentMid: vec4f=textureSample(reflectionSampler,reflectionSamplerSampler,reflectionCoords);if (lodReflectionNormalizedDoubled<1.0){environmentRadiance=mix(
552
+ textureSample(reflectionHighSampler,reflectionHighSamplerSampler,reflectionCoords),
553
+ environmentMid,
554
+ lodReflectionNormalizedDoubled
555
+ );} else {environmentRadiance=mix(
556
+ environmentMid,
557
+ textureSample(reflectionLowSampler,reflectionLowSamplerSampler,reflectionCoords),
558
+ lodReflectionNormalizedDoubled-1.0
559
+ );}
560
+ #endif
561
+ var envRadiance=environmentRadiance.rgb;
562
+ #ifdef RGBDREFLECTION
563
+ envRadiance=fromRGBD(environmentRadiance);
564
+ #endif
565
+ #ifdef GAMMAREFLECTION
566
+ envRadiance=toLinearSpaceVec3(environmentRadiance.rgb);
567
+ #endif
568
+ envRadiance*=vReflectionInfos.x;envRadiance*=vReflectionColor.rgb;return vec4f(envRadiance,environmentRadiance.a);}
569
+ #define pbr_inline
570
+ fn reflectionBlock(
571
+ vPositionW: vec3f
572
+ ,normalW: vec3f
573
+ ,alphaG: f32
574
+ ,vReflectionMicrosurfaceInfos: vec3f
575
+ ,vReflectionInfos: vec2f
576
+ ,vReflectionColor: vec3f
577
+ #ifdef ANISOTROPIC
578
+ ,anisotropicOut: anisotropicOutParams
579
+ #endif
580
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
581
+ ,NdotVUnclamped: f32
582
+ #endif
583
+ #ifdef LINEARSPECULARREFLECTION
584
+ ,roughness: f32
585
+ #endif
586
+ #ifdef REFLECTIONMAP_3D
587
+ ,reflectionSampler: texture_cube<f32>
588
+ ,reflectionSamplerSampler: sampler
589
+ #else
590
+ ,reflectionSampler: texture_2d<f32>
591
+ ,reflectionSamplerSampler: sampler
592
+ #endif
593
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
594
+ ,vEnvironmentIrradiance: vec3f
595
+ #endif
596
+ #if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
597
+ ,reflectionMatrix: mat4x4f
598
+ #endif
599
+ #ifdef USEIRRADIANCEMAP
600
+ #ifdef REFLECTIONMAP_3D
601
+ ,irradianceSampler: texture_cube<f32>
602
+ ,irradianceSamplerSampler: sampler
603
+ #else
604
+ ,irradianceSampler: texture_2d<f32>
605
+ ,irradianceSamplerSampler: sampler
606
+ #endif
607
+ #ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
608
+ ,reflectionDominantDirection: vec3f
609
+ #endif
610
+ #endif
611
+ #ifndef LODBASEDMICROSFURACE
612
+ #ifdef REFLECTIONMAP_3D
613
+ ,reflectionLowSampler: texture_cube<f32>
614
+ ,reflectionLowSamplerSampler: sampler
615
+ ,reflectionHighSampler: texture_cube<f32>
616
+ ,reflectionHighSamplerSampler: sampler
617
+ #else
618
+ ,reflectionLowSampler: texture_2d<f32>
619
+ ,reflectionLowSamplerSampler: sampler
620
+ ,reflectionHighSampler: texture_2d<f32>
621
+ ,reflectionHighSamplerSampler: sampler
622
+ #endif
623
+ #endif
624
+ #ifdef REALTIME_FILTERING
625
+ ,vReflectionFilteringInfo: vec2f
626
+ #ifdef IBL_CDF_FILTERING
627
+ ,icdfSampler: texture_2d<f32>
628
+ ,icdfSamplerSampler: sampler
629
+ #endif
630
+ #endif
631
+ ,viewDirectionW: vec3f
632
+ ,diffuseRoughness: f32
633
+ ,surfaceAlbedo: vec3f
634
+ )->reflectionOutParams
635
+ {var outParams: reflectionOutParams;var environmentRadiance: vec4f= vec4f(0.,0.,0.,0.);
636
+ #ifdef REFLECTIONMAP_3D
637
+ var reflectionCoords: vec3f= vec3f(0.);
638
+ #else
639
+ var reflectionCoords: vec2f= vec2f(0.);
640
+ #endif
641
+ reflectionCoords=createReflectionCoords(
642
+ vPositionW,
643
+ normalW,
644
+ #ifdef ANISOTROPIC
645
+ anisotropicOut,
646
+ #endif
647
+ );environmentRadiance=sampleReflectionTexture(
648
+ alphaG
649
+ ,vReflectionMicrosurfaceInfos
650
+ ,vReflectionInfos
651
+ ,vReflectionColor
652
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
653
+ ,NdotVUnclamped
654
+ #endif
655
+ #ifdef LINEARSPECULARREFLECTION
656
+ ,roughness
657
+ #endif
658
+ #ifdef REFLECTIONMAP_3D
659
+ ,reflectionSampler
660
+ ,reflectionSamplerSampler
661
+ ,reflectionCoords
662
+ #else
663
+ ,reflectionSampler
664
+ ,reflectionSamplerSampler
665
+ ,reflectionCoords
666
+ #endif
667
+ #ifndef LODBASEDMICROSFURACE
668
+ ,reflectionLowSampler
669
+ ,reflectionLowSamplerSampler
670
+ ,reflectionHighSampler
671
+ ,reflectionHighSamplerSampler
672
+ #endif
673
+ #ifdef REALTIME_FILTERING
674
+ ,vReflectionFilteringInfo
675
+ #endif
676
+ );var environmentIrradiance: vec3f= vec3f(0.,0.,0.);
677
+ #if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
678
+ #ifdef ANISOTROPIC
679
+ var irradianceVector: vec3f= (reflectionMatrix* vec4f(anisotropicOut.anisotropicNormal,0)).xyz;
680
+ #else
681
+ var irradianceVector: vec3f= (reflectionMatrix* vec4f(normalW,0)).xyz;
682
+ #endif
683
+ var irradianceView: vec3f= (reflectionMatrix* vec4f(viewDirectionW,0)).xyz;
684
+ #if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING)
685
+ #if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY
686
+ var NdotV: f32=max(dot(normalW,viewDirectionW),0.0);irradianceVector=mix(irradianceVector,irradianceView,(0.5*(1.0-NdotV))*diffuseRoughness);
687
+ #endif
688
+ #endif
689
+ #ifdef REFLECTIONMAP_OPPOSITEZ
690
+ irradianceVector.z*=-1.0;irradianceView.z*=-1.0;
691
+ #endif
692
+ #ifdef INVERTCUBICMAP
693
+ irradianceVector.y*=-1.0;irradianceView.y*=-1.0;
694
+ #endif
695
+ #endif
696
+ #ifdef USESPHERICALFROMREFLECTIONMAP
697
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
698
+ environmentIrradiance=vEnvironmentIrradiance;
699
+ #else
700
+ #if defined(REALTIME_FILTERING)
701
+ environmentIrradiance=irradiance(reflectionSampler,reflectionSamplerSampler,irradianceVector,vReflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView
702
+ #ifdef IBL_CDF_FILTERING
703
+ ,icdfSampler
704
+ ,icdfSamplerSampler
705
+ #endif
706
+ );
707
+ #else
708
+ environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
709
+ #endif
710
+ #ifdef SS_TRANSLUCENCY
711
+ outParams.irradianceVector=irradianceVector;
712
+ #endif
713
+ #endif
714
+ #elif defined(USEIRRADIANCEMAP)
715
+ #ifdef REFLECTIONMAP_3D
716
+ var environmentIrradiance4: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,irradianceVector);
717
+ #else
718
+ var environmentIrradiance4: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,reflectionCoords);
719
+ #endif
720
+ #ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
721
+ var Ls: vec3f=normalize(reflectionDominantDirection);var NoL: f32=dot(irradianceVector,Ls);var NoV: f32=dot(irradianceVector,irradianceView);var diffuseRoughnessTerm: vec3f=vec3f(1.0);
722
+ #if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
723
+ var LoV: f32=dot(Ls,irradianceView);var mag: f32=length(reflectionDominantDirection)*2.0f;var clampedAlbedo: vec3f=clamp(surfaceAlbedo,vec3f(0.1),vec3f(1.0));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3f(1.0),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0,1.0f)));
724
+ #elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
725
+ var H: vec3f=(irradianceView+Ls)*0.5f;var VoH: f32=dot(irradianceView,H);diffuseRoughnessTerm=vec3f(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);
726
+ #endif
727
+ environmentIrradiance=environmentIrradiance4.rgb*diffuseRoughnessTerm;
728
+ #else
729
+ environmentIrradiance=environmentIrradiance4.rgb;
730
+ #endif
731
+ #ifdef RGBDREFLECTION
732
+ environmentIrradiance=fromRGBD(environmentIrradiance4);
733
+ #endif
734
+ #ifdef GAMMAREFLECTION
735
+ environmentIrradiance=toLinearSpaceVec3(environmentIrradiance.rgb);
736
+ #endif
737
+ #endif
738
+ environmentIrradiance*=vReflectionColor.rgb*vReflectionInfos.x;
739
+ #ifdef MIX_IBL_RADIANCE_WITH_IRRADIANCE
740
+ outParams.environmentRadiance=vec4f(mix(environmentRadiance.rgb,environmentIrradiance,alphaG),environmentRadiance.a);
741
+ #else
742
+ outParams.environmentRadiance=environmentRadiance;
743
+ #endif
744
+ outParams.environmentIrradiance=environmentIrradiance;outParams.reflectionCoords=reflectionCoords;return outParams;}
745
+ #endif
746
+ `;
747
+ e.IncludesShadersStoreWGSL[l] || (e.IncludesShadersStoreWGSL[l] = g);
748
+ const d = "pbrBlockSheen", h = `#ifdef SHEEN
749
+ struct sheenOutParams
750
+ {sheenIntensity: f32
751
+ ,sheenColor: vec3f
752
+ ,sheenRoughness: f32
753
+ #ifdef SHEEN_LINKWITHALBEDO
754
+ ,surfaceAlbedo: vec3f
755
+ #endif
756
+ #if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
757
+ ,sheenAlbedoScaling: f32
758
+ #endif
759
+ #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
760
+ ,finalSheenRadianceScaled: vec3f
761
+ #endif
762
+ #if DEBUGMODE>0
763
+ #ifdef SHEEN_TEXTURE
764
+ ,sheenMapData: vec4f
765
+ #endif
766
+ #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
767
+ ,sheenEnvironmentReflectance: vec3f
768
+ #endif
769
+ #endif
770
+ };
771
+ #define pbr_inline
772
+ fn sheenBlock(
773
+ vSheenColor: vec4f
774
+ #ifdef SHEEN_ROUGHNESS
775
+ ,vSheenRoughness: f32
776
+ #if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
777
+ ,sheenMapRoughnessData: vec4f
778
+ #endif
779
+ #endif
780
+ ,roughness: f32
781
+ #ifdef SHEEN_TEXTURE
782
+ ,sheenMapData: vec4f
783
+ ,sheenMapLevel: f32
784
+ #endif
785
+ ,reflectance: f32
786
+ #ifdef SHEEN_LINKWITHALBEDO
787
+ ,baseColor: vec3f
788
+ ,surfaceAlbedo: vec3f
789
+ #endif
790
+ #ifdef ENVIRONMENTBRDF
791
+ ,NdotV: f32
792
+ ,environmentBrdf: vec3f
793
+ #endif
794
+ #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
795
+ ,AARoughnessFactors: vec2f
796
+ ,vReflectionMicrosurfaceInfos: vec3f
797
+ ,vReflectionInfos: vec2f
798
+ ,vReflectionColor: vec3f
799
+ ,vLightingIntensity: vec4f
800
+ #ifdef REFLECTIONMAP_3D
801
+ ,reflectionSampler: texture_cube<f32>
802
+ ,reflectionSamplerSampler: sampler
803
+ ,reflectionCoords: vec3f
804
+ #else
805
+ ,reflectionSampler: texture_2d<f32>
806
+ ,reflectionSamplerSampler: sampler
807
+ ,reflectionCoords: vec2f
808
+ #endif
809
+ ,NdotVUnclamped: f32
810
+ #ifndef LODBASEDMICROSFURACE
811
+ #ifdef REFLECTIONMAP_3D
812
+ ,reflectionLowSampler: texture_cube<f32>
813
+ ,reflectionLowSamplerSampler: sampler
814
+ ,reflectionHighSampler: texture_cube<f32>
815
+ ,reflectionHighSamplerSampler: sampler
816
+ #else
817
+ ,reflectionLowSampler: texture_2d<f32>
818
+ ,reflectionLowSamplerSampler: sampler
819
+ ,reflectionHighSampler: texture_2d<f32>
820
+ ,reflectionHighSamplerSampler: sampler
821
+ #endif
822
+ #endif
823
+ #ifdef REALTIME_FILTERING
824
+ ,vReflectionFilteringInfo: vec2f
825
+ #endif
826
+ #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
827
+ ,seo: f32
828
+ #endif
829
+ #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
830
+ ,eho: f32
831
+ #endif
832
+ #endif
833
+ )->sheenOutParams
834
+ {var outParams: sheenOutParams;var sheenIntensity: f32=vSheenColor.a;
835
+ #ifdef SHEEN_TEXTURE
836
+ #if DEBUGMODE>0
837
+ outParams.sheenMapData=sheenMapData;
838
+ #endif
839
+ #endif
840
+ #ifdef SHEEN_LINKWITHALBEDO
841
+ var sheenFactor: f32=pow5(1.0-sheenIntensity);var sheenColor: vec3f=baseColor.rgb*(1.0-sheenFactor);var sheenRoughness: f32=sheenIntensity;outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
842
+ #ifdef SHEEN_TEXTURE
843
+ sheenIntensity*=sheenMapData.a;
844
+ #endif
845
+ #else
846
+ var sheenColor: vec3f=vSheenColor.rgb;
847
+ #ifdef SHEEN_TEXTURE
848
+ #ifdef SHEEN_GAMMATEXTURE
849
+ sheenColor*=toLinearSpaceVec3(sheenMapData.rgb);
850
+ #else
851
+ sheenColor*=sheenMapData.rgb;
852
+ #endif
853
+ sheenColor*=sheenMapLevel;
854
+ #endif
855
+ #ifdef SHEEN_ROUGHNESS
856
+ var sheenRoughness: f32=vSheenRoughness;
857
+ #ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
858
+ #if defined(SHEEN_TEXTURE)
859
+ sheenRoughness*=sheenMapData.a;
860
+ #endif
861
+ #elif defined(SHEEN_TEXTURE_ROUGHNESS)
862
+ sheenRoughness*=sheenMapRoughnessData.a;
863
+ #endif
864
+ #else
865
+ var sheenRoughness: f32=roughness;
866
+ #ifdef SHEEN_TEXTURE
867
+ sheenIntensity*=sheenMapData.a;
868
+ #endif
869
+ #endif
870
+ #if !defined(SHEEN_ALBEDOSCALING)
871
+ sheenIntensity*=(1.-reflectance);
872
+ #endif
873
+ sheenColor*=sheenIntensity;
874
+ #endif
875
+ #ifdef ENVIRONMENTBRDF
876
+ /*#ifdef SHEEN_SOFTER
877
+ var environmentSheenBrdf: vec3f= vec3f(0.,0.,getBRDFLookupCharlieSheen(NdotV,sheenRoughness));
878
+ #else*/
879
+ #ifdef SHEEN_ROUGHNESS
880
+ var environmentSheenBrdf: vec3f=getBRDFLookup(NdotV,sheenRoughness);
881
+ #else
882
+ var environmentSheenBrdf: vec3f=environmentBrdf;
883
+ #endif
884
+ /*#endif*/
885
+ #endif
886
+ #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
887
+ var sheenAlphaG: f32=convertRoughnessToAverageSlope(sheenRoughness);
888
+ #ifdef SPECULARAA
889
+ sheenAlphaG+=AARoughnessFactors.y;
890
+ #endif
891
+ var environmentSheenRadiance: vec4f= vec4f(0.,0.,0.,0.);environmentSheenRadiance=sampleReflectionTexture(
892
+ sheenAlphaG
893
+ ,vReflectionMicrosurfaceInfos
894
+ ,vReflectionInfos
895
+ ,vReflectionColor
896
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
897
+ ,NdotVUnclamped
898
+ #endif
899
+ #ifdef LINEARSPECULARREFLECTION
900
+ ,sheenRoughness
901
+ #endif
902
+ ,reflectionSampler
903
+ ,reflectionSamplerSampler
904
+ ,reflectionCoords
905
+ #ifndef LODBASEDMICROSFURACE
906
+ ,reflectionLowSampler
907
+ ,reflectionLowSamplerSampler
908
+ ,reflectionHighSampler
909
+ ,reflectionHighSamplerSampler
910
+ #endif
911
+ #ifdef REALTIME_FILTERING
912
+ ,vReflectionFilteringInfo
913
+ #endif
914
+ );var sheenEnvironmentReflectance: vec3f=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
915
+ #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
916
+ sheenEnvironmentReflectance*=seo;
917
+ #endif
918
+ #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
919
+ sheenEnvironmentReflectance*=eho;
920
+ #endif
921
+ #if DEBUGMODE>0
922
+ outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
923
+ #endif
924
+ outParams.finalSheenRadianceScaled=
925
+ environmentSheenRadiance.rgb *
926
+ sheenEnvironmentReflectance *
927
+ vLightingIntensity.z;
928
+ #endif
929
+ #if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
930
+ outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
931
+ #endif
932
+ outParams.sheenIntensity=sheenIntensity;outParams.sheenColor=sheenColor;outParams.sheenRoughness=sheenRoughness;return outParams;}
933
+ #endif
934
+ `;
935
+ e.IncludesShadersStoreWGSL[d] || (e.IncludesShadersStoreWGSL[d] = h);
936
+ const s = "pbrBlockClearcoat", U = `struct clearcoatOutParams
937
+ {specularEnvironmentR0: vec3f,
938
+ conservationFactor: f32,
939
+ clearCoatNormalW: vec3f,
940
+ clearCoatAARoughnessFactors: vec2f,
941
+ clearCoatIntensity: f32,
942
+ clearCoatRoughness: f32,
943
+ #ifdef REFLECTION
944
+ finalClearCoatRadianceScaled: vec3f,
945
+ #endif
946
+ #ifdef CLEARCOAT_TINT
947
+ absorption: vec3f,
948
+ clearCoatNdotVRefract: f32,
949
+ clearCoatColor: vec3f,
950
+ clearCoatThickness: f32,
951
+ #endif
952
+ #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
953
+ energyConservationFactorClearCoat: vec3f,
954
+ #endif
955
+ #if DEBUGMODE>0
956
+ #ifdef CLEARCOAT_BUMP
957
+ TBNClearCoat: mat3x3f,
958
+ #endif
959
+ #ifdef CLEARCOAT_TEXTURE
960
+ clearCoatMapData: vec2f,
961
+ #endif
962
+ #if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
963
+ clearCoatTintMapData: vec4f,
964
+ #endif
965
+ #ifdef REFLECTION
966
+ environmentClearCoatRadiance: vec4f,
967
+ clearCoatEnvironmentReflectance: vec3f,
968
+ #endif
969
+ clearCoatNdotV: f32
970
+ #endif
971
+ };
972
+ #ifdef CLEARCOAT
973
+ #define pbr_inline
974
+ fn clearcoatBlock(
975
+ vPositionW: vec3f
976
+ ,geometricNormalW: vec3f
977
+ ,viewDirectionW: vec3f
978
+ ,vClearCoatParams: vec2f
979
+ #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
980
+ ,clearCoatMapRoughnessData: vec4f
981
+ #endif
982
+ ,specularEnvironmentR0: vec3f
983
+ #ifdef CLEARCOAT_TEXTURE
984
+ ,clearCoatMapData: vec2f
985
+ #endif
986
+ #ifdef CLEARCOAT_TINT
987
+ ,vClearCoatTintParams: vec4f
988
+ ,clearCoatColorAtDistance: f32
989
+ ,vClearCoatRefractionParams: vec4f
990
+ #ifdef CLEARCOAT_TINT_TEXTURE
991
+ ,clearCoatTintMapData: vec4f
992
+ #endif
993
+ #endif
994
+ #ifdef CLEARCOAT_BUMP
995
+ ,vClearCoatBumpInfos: vec2f
996
+ ,clearCoatBumpMapData: vec4f
997
+ ,vClearCoatBumpUV: vec2f
998
+ #if defined(TANGENT) && defined(NORMAL)
999
+ ,vTBN: mat3x3f
1000
+ #else
1001
+ ,vClearCoatTangentSpaceParams: vec2f
1002
+ #endif
1003
+ #ifdef OBJECTSPACE_NORMALMAP
1004
+ ,normalMatrix: mat4x4f
1005
+ #endif
1006
+ #endif
1007
+ #if defined(FORCENORMALFORWARD) && defined(NORMAL)
1008
+ ,faceNormal: vec3f
1009
+ #endif
1010
+ #ifdef REFLECTION
1011
+ ,vReflectionMicrosurfaceInfos: vec3f
1012
+ ,vReflectionInfos: vec2f
1013
+ ,vReflectionColor: vec3f
1014
+ ,vLightingIntensity: vec4f
1015
+ #ifdef REFLECTIONMAP_3D
1016
+ ,reflectionSampler: texture_cube<f32>
1017
+ ,reflectionSamplerSampler: sampler
1018
+ #else
1019
+ ,reflectionSampler: texture_2d<f32>
1020
+ ,reflectionSamplerSampler: sampler
1021
+ #endif
1022
+ #ifndef LODBASEDMICROSFURACE
1023
+ #ifdef REFLECTIONMAP_3D
1024
+ ,reflectionLowSampler: texture_cube<f32>
1025
+ ,reflectionLowSamplerSampler: sampler
1026
+ ,reflectionHighSampler: texture_cube<f32>
1027
+ ,reflectionHighSamplerSampler: sampler
1028
+ #else
1029
+ ,reflectionLowSampler: texture_2d<f32>
1030
+ ,reflectionLowSamplerSampler: sampler
1031
+ ,reflectionHighSampler: texture_2d<f32>
1032
+ ,reflectionHighSamplerSampler: sampler
1033
+ #endif
1034
+ #endif
1035
+ #ifdef REALTIME_FILTERING
1036
+ ,vReflectionFilteringInfo: vec2f
1037
+ #endif
1038
+ #endif
1039
+ #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
1040
+ ,frontFacingMultiplier: f32
1041
+ #endif
1042
+ )->clearcoatOutParams
1043
+ {var outParams: clearcoatOutParams;var clearCoatIntensity: f32=vClearCoatParams.x;var clearCoatRoughness: f32=vClearCoatParams.y;
1044
+ #ifdef CLEARCOAT_TEXTURE
1045
+ clearCoatIntensity*=clearCoatMapData.x;
1046
+ #ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE
1047
+ clearCoatRoughness*=clearCoatMapData.y;
1048
+ #endif
1049
+ #if DEBUGMODE>0
1050
+ outParams.clearCoatMapData=clearCoatMapData;
1051
+ #endif
1052
+ #endif
1053
+ #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
1054
+ clearCoatRoughness*=clearCoatMapRoughnessData.y;
1055
+ #endif
1056
+ outParams.clearCoatIntensity=clearCoatIntensity;outParams.clearCoatRoughness=clearCoatRoughness;
1057
+ #ifdef CLEARCOAT_TINT
1058
+ var clearCoatColor: vec3f=vClearCoatTintParams.rgb;var clearCoatThickness: f32=vClearCoatTintParams.a;
1059
+ #ifdef CLEARCOAT_TINT_TEXTURE
1060
+ #ifdef CLEARCOAT_TINT_GAMMATEXTURE
1061
+ clearCoatColor*=toLinearSpaceVec3(clearCoatTintMapData.rgb);
1062
+ #else
1063
+ clearCoatColor*=clearCoatTintMapData.rgb;
1064
+ #endif
1065
+ clearCoatThickness*=clearCoatTintMapData.a;
1066
+ #if DEBUGMODE>0
1067
+ outParams.clearCoatTintMapData=clearCoatTintMapData;
1068
+ #endif
1069
+ #endif
1070
+ outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);outParams.clearCoatThickness=clearCoatThickness;
1071
+ #endif
1072
+ #ifdef CLEARCOAT_REMAP_F0
1073
+ var specularEnvironmentR0Updated: vec3f=getR0RemappedForClearCoat(specularEnvironmentR0);
1074
+ #else
1075
+ var specularEnvironmentR0Updated: vec3f=specularEnvironmentR0;
1076
+ #endif
1077
+ outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);var clearCoatNormalW: vec3f=geometricNormalW;
1078
+ #ifdef CLEARCOAT_BUMP
1079
+ #ifdef NORMALXYSCALE
1080
+ var clearCoatNormalScale: f32=1.0;
1081
+ #else
1082
+ var clearCoatNormalScale: f32=vClearCoatBumpInfos.y;
1083
+ #endif
1084
+ #if defined(TANGENT) && defined(NORMAL)
1085
+ var TBNClearCoat: mat3x3f=vTBN;
1086
+ #else
1087
+ var TBNClearCoatUV: vec2f=vClearCoatBumpUV*frontFacingMultiplier;var TBNClearCoat: mat3x3f=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams);
1088
+ #endif
1089
+ #if DEBUGMODE>0
1090
+ outParams.TBNClearCoat=TBNClearCoat;
1091
+ #endif
1092
+ #ifdef OBJECTSPACE_NORMALMAP
1093
+ clearCoatNormalW=normalize(clearCoatBumpMapData.xyz *2.0-1.0);clearCoatNormalW=normalize( mat3x3f(normalMatrix[0].xyz,normalMatrix[1].xyz,normalMatrix[2].xyz)*clearCoatNormalW);
1094
+ #else
1095
+ clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);
1096
+ #endif
1097
+ #endif
1098
+ #if defined(FORCENORMALFORWARD) && defined(NORMAL)
1099
+ clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));
1100
+ #endif
1101
+ #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
1102
+ clearCoatNormalW=clearCoatNormalW*frontFacingMultiplier;
1103
+ #endif
1104
+ outParams.clearCoatNormalW=clearCoatNormalW;outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);var clearCoatNdotVUnclamped: f32=dot(clearCoatNormalW,viewDirectionW);var clearCoatNdotV: f32=absEps(clearCoatNdotVUnclamped);
1105
+ #if DEBUGMODE>0
1106
+ outParams.clearCoatNdotV=clearCoatNdotV;
1107
+ #endif
1108
+ #ifdef CLEARCOAT_TINT
1109
+ var clearCoatVRefract: vec3f=refract(-viewDirectionW,clearCoatNormalW,vClearCoatRefractionParams.y);outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));
1110
+ #endif
1111
+ #if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION))
1112
+ var environmentClearCoatBrdf: vec3f=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);
1113
+ #endif
1114
+ #if defined(REFLECTION)
1115
+ var clearCoatAlphaG: f32=convertRoughnessToAverageSlope(clearCoatRoughness);
1116
+ #ifdef SPECULARAA
1117
+ clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;
1118
+ #endif
1119
+ var environmentClearCoatRadiance: vec4f= vec4f(0.,0.,0.,0.);var clearCoatReflectionVector: vec3f=computeReflectionCoords( vec4f(vPositionW,1.0),clearCoatNormalW);
1120
+ #ifdef REFLECTIONMAP_OPPOSITEZ
1121
+ clearCoatReflectionVector.z*=-1.0;
1122
+ #endif
1123
+ #ifdef REFLECTIONMAP_3D
1124
+ var clearCoatReflectionCoords: vec3f=clearCoatReflectionVector;
1125
+ #else
1126
+ var clearCoatReflectionCoords: vec2f=clearCoatReflectionVector.xy;
1127
+ #ifdef REFLECTIONMAP_PROJECTION
1128
+ clearCoatReflectionCoords/=clearCoatReflectionVector.z;
1129
+ #endif
1130
+ clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;
1131
+ #endif
1132
+ environmentClearCoatRadiance=sampleReflectionTexture(
1133
+ clearCoatAlphaG
1134
+ ,vReflectionMicrosurfaceInfos
1135
+ ,vReflectionInfos
1136
+ ,vReflectionColor
1137
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
1138
+ ,clearCoatNdotVUnclamped
1139
+ #endif
1140
+ #ifdef LINEARSPECULARREFLECTION
1141
+ ,clearCoatRoughness
1142
+ #endif
1143
+ ,reflectionSampler
1144
+ ,reflectionSamplerSampler
1145
+ ,clearCoatReflectionCoords
1146
+ #ifndef LODBASEDMICROSFURACE
1147
+ ,reflectionLowSampler
1148
+ ,reflectionLowSamplerSampler
1149
+ ,reflectionHighSampler
1150
+ ,reflectionHighSamplerSampler
1151
+ #endif
1152
+ #ifdef REALTIME_FILTERING
1153
+ ,vReflectionFilteringInfo
1154
+ #endif
1155
+ );
1156
+ #if DEBUGMODE>0
1157
+ outParams.environmentClearCoatRadiance=environmentClearCoatRadiance;
1158
+ #endif
1159
+ #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
1160
+ var clearCoatEnvironmentReflectance: vec3f=getReflectanceFromBRDFLookup(vec3f(uniforms.vClearCoatRefractionParams.x),environmentClearCoatBrdf);
1161
+ #ifdef HORIZONOCCLUSION
1162
+ #ifdef BUMP
1163
+ #ifdef REFLECTIONMAP_3D
1164
+ var clearCoatEho: f32=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);clearCoatEnvironmentReflectance*=clearCoatEho;
1165
+ #endif
1166
+ #endif
1167
+ #endif
1168
+ #else
1169
+ var clearCoatEnvironmentReflectance: vec3f=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV, vec3f(1.), vec3f(1.),sqrt(1.-clearCoatRoughness));
1170
+ #endif
1171
+ clearCoatEnvironmentReflectance*=clearCoatIntensity;
1172
+ #if DEBUGMODE>0
1173
+ outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;
1174
+ #endif
1175
+ outParams.finalClearCoatRadianceScaled=
1176
+ environmentClearCoatRadiance.rgb *
1177
+ clearCoatEnvironmentReflectance *
1178
+ vLightingIntensity.z;
1179
+ #endif
1180
+ #if defined(CLEARCOAT_TINT)
1181
+ outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);
1182
+ #endif
1183
+ var fresnelIBLClearCoat: f32=fresnelSchlickGGX(clearCoatNdotV,uniforms.vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnelIBLClearCoat*=clearCoatIntensity;outParams.conservationFactor=(1.-fresnelIBLClearCoat);
1184
+ #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
1185
+ outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);
1186
+ #endif
1187
+ return outParams;}
1188
+ #endif
1189
+ `;
1190
+ e.IncludesShadersStoreWGSL[s] || (e.IncludesShadersStoreWGSL[s] = U);
1191
+ const E = "pbrBlockIridescence", b = `struct iridescenceOutParams
1192
+ {iridescenceIntensity: f32,
1193
+ iridescenceIOR: f32,
1194
+ iridescenceThickness: f32,
1195
+ specularEnvironmentR0: vec3f};
1196
+ #ifdef IRIDESCENCE
1197
+ fn iridescenceBlock(
1198
+ vIridescenceParams: vec4f
1199
+ ,viewAngle_: f32
1200
+ ,specularEnvironmentR0: vec3f
1201
+ #ifdef IRIDESCENCE_TEXTURE
1202
+ ,iridescenceMapData: vec2f
1203
+ #endif
1204
+ #ifdef IRIDESCENCE_THICKNESS_TEXTURE
1205
+ ,iridescenceThicknessMapData: vec2f
1206
+ #endif
1207
+ #ifdef CLEARCOAT
1208
+ ,NdotVUnclamped: f32
1209
+ ,vClearCoatParams: vec2f
1210
+ #ifdef CLEARCOAT_TEXTURE
1211
+ ,clearCoatMapData: vec2f
1212
+ #endif
1213
+ #endif
1214
+ )->iridescenceOutParams
1215
+ {var outParams: iridescenceOutParams;var iridescenceIntensity: f32=vIridescenceParams.x;var iridescenceIOR: f32=vIridescenceParams.y;var iridescenceThicknessMin: f32=vIridescenceParams.z;var iridescenceThicknessMax: f32=vIridescenceParams.w;var iridescenceThicknessWeight: f32=1.;var viewAngle=viewAngle_;
1216
+ #ifdef IRIDESCENCE_TEXTURE
1217
+ iridescenceIntensity*=iridescenceMapData.x;
1218
+ #endif
1219
+ #if defined(IRIDESCENCE_THICKNESS_TEXTURE)
1220
+ iridescenceThicknessWeight=iridescenceThicknessMapData.g;
1221
+ #endif
1222
+ var iridescenceThickness: f32=mix(iridescenceThicknessMin,iridescenceThicknessMax,iridescenceThicknessWeight);var topIor: f32=1.;
1223
+ #ifdef CLEARCOAT
1224
+ var clearCoatIntensity: f32=vClearCoatParams.x;
1225
+ #ifdef CLEARCOAT_TEXTURE
1226
+ clearCoatIntensity*=clearCoatMapData.x;
1227
+ #endif
1228
+ topIor=mix(1.0,uniforms.vClearCoatRefractionParams.w-1.,clearCoatIntensity);viewAngle=sqrt(1.0+((1.0/topIor)*(1.0/topIor))*((NdotVUnclamped*NdotVUnclamped)-1.0));
1229
+ #endif
1230
+ var iridescenceFresnel: vec3f=evalIridescence(topIor,iridescenceIOR,viewAngle,iridescenceThickness,specularEnvironmentR0);outParams.specularEnvironmentR0=mix(specularEnvironmentR0,iridescenceFresnel,iridescenceIntensity);outParams.iridescenceIntensity=iridescenceIntensity;outParams.iridescenceThickness=iridescenceThickness;outParams.iridescenceIOR=iridescenceIOR;return outParams;}
1231
+ #endif
1232
+ `;
1233
+ e.IncludesShadersStoreWGSL[E] || (e.IncludesShadersStoreWGSL[E] = b);
1234
+ const R = "pbrBlockSubSurface", y = `struct subSurfaceOutParams
1235
+ {specularEnvironmentReflectance: vec3f,
1236
+ #ifdef SS_REFRACTION
1237
+ finalRefraction: vec3f,
1238
+ surfaceAlbedo: vec3f,
1239
+ #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
1240
+ alpha: f32,
1241
+ #endif
1242
+ refractionOpacity: f32,
1243
+ #endif
1244
+ #ifdef SS_TRANSLUCENCY
1245
+ transmittance: vec3f,
1246
+ translucencyIntensity: f32,
1247
+ #ifdef REFLECTION
1248
+ refractionIrradiance: vec3f,
1249
+ #endif
1250
+ #endif
1251
+ #if DEBUGMODE>0
1252
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
1253
+ thicknessMap: vec4f,
1254
+ #endif
1255
+ #ifdef SS_REFRACTION
1256
+ environmentRefraction: vec4f,
1257
+ refractionTransmittance: vec3f
1258
+ #endif
1259
+ #endif
1260
+ };
1261
+ #ifdef SUBSURFACE
1262
+ #ifdef SS_REFRACTION
1263
+ #define pbr_inline
1264
+ fn sampleEnvironmentRefraction(
1265
+ ior: f32
1266
+ ,thickness: f32
1267
+ ,refractionLOD: f32
1268
+ ,normalW: vec3f
1269
+ ,vPositionW: vec3f
1270
+ ,viewDirectionW: vec3f
1271
+ ,view: mat4x4f
1272
+ ,vRefractionInfos: vec4f
1273
+ ,refractionMatrix: mat4x4f
1274
+ ,vRefractionMicrosurfaceInfos: vec4f
1275
+ ,alphaG: f32
1276
+ #ifdef SS_REFRACTIONMAP_3D
1277
+ ,refractionSampler: texture_cube<f32>
1278
+ ,refractionSamplerSampler: sampler
1279
+ #ifndef LODBASEDMICROSFURACE
1280
+ ,refractionLowSampler: texture_cube<f32>
1281
+ ,refractionLowSamplerSampler: sampler
1282
+ ,refractionHighSampler: texture_cube<f32>
1283
+ ,refractionHighSamplerSampler: sampler
1284
+ #endif
1285
+ #else
1286
+ ,refractionSampler: texture_2d<f32>
1287
+ ,refractionSamplerSampler: sampler
1288
+ #ifndef LODBASEDMICROSFURACE
1289
+ ,refractionLowSampler: texture_2d<f32>
1290
+ ,refractionLowSamplerSampler: sampler
1291
+ ,refractionHighSampler: texture_2d<f32>
1292
+ ,refractionHighSamplerSampler: sampler
1293
+ #endif
1294
+ #endif
1295
+ #ifdef ANISOTROPIC
1296
+ ,anisotropicOut: anisotropicOutParams
1297
+ #endif
1298
+ #ifdef REALTIME_FILTERING
1299
+ ,vRefractionFilteringInfo: vec2f
1300
+ #endif
1301
+ #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
1302
+ ,refractionPosition: vec3f
1303
+ ,refractionSize: vec3f
1304
+ #endif
1305
+ )->vec4f {var environmentRefraction: vec4f= vec4f(0.,0.,0.,0.);
1306
+ #ifdef ANISOTROPIC
1307
+ var refractionVector: vec3f=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,ior);
1308
+ #else
1309
+ var refractionVector: vec3f=refract(-viewDirectionW,normalW,ior);
1310
+ #endif
1311
+ #ifdef SS_REFRACTIONMAP_OPPOSITEZ
1312
+ refractionVector.z*=-1.0;
1313
+ #endif
1314
+ #ifdef SS_REFRACTIONMAP_3D
1315
+ #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
1316
+ refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition);
1317
+ #endif
1318
+ refractionVector.y=refractionVector.y*vRefractionInfos.w;var refractionCoords: vec3f=refractionVector;refractionCoords= (refractionMatrix* vec4f(refractionCoords,0)).xyz;
1319
+ #else
1320
+ #ifdef SS_USE_THICKNESS_AS_DEPTH
1321
+ var vRefractionUVW: vec3f= (refractionMatrix*(view* vec4f(vPositionW+refractionVector*thickness,1.0))).xyz;
1322
+ #else
1323
+ var vRefractionUVW: vec3f= (refractionMatrix*(view* vec4f(vPositionW+refractionVector*vRefractionInfos.z,1.0))).xyz;
1324
+ #endif
1325
+ var refractionCoords: vec2f=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;
1326
+ #endif
1327
+ #ifdef LODBASEDMICROSFURACE
1328
+ var lod=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;
1329
+ #ifdef SS_LODINREFRACTIONALPHA
1330
+ var automaticRefractionLOD: f32=UNPACK_LOD(textureSample(refractionSampler,refractionSamplerSampler,refractionCoords).a);var requestedRefractionLOD: f32=max(automaticRefractionLOD,lod);
1331
+ #else
1332
+ var requestedRefractionLOD: f32=lod;
1333
+ #endif
1334
+ #if defined(REALTIME_FILTERING) && defined(SS_REFRACTIONMAP_3D)
1335
+ environmentRefraction= vec4f(radiance(alphaG,refractionSampler,refractionSamplerSampler,refractionCoords,vRefractionFilteringInfo),1.0);
1336
+ #else
1337
+ environmentRefraction=textureSampleLevel(refractionSampler,refractionSamplerSampler,refractionCoords,requestedRefractionLOD);
1338
+ #endif
1339
+ #else
1340
+ var lodRefractionNormalized: f32=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));var lodRefractionNormalizedDoubled: f32=lodRefractionNormalized*2.0;var environmentRefractionMid: vec4f=textureSample(refractionSampler,refractionSamplerSampler,refractionCoords);if (lodRefractionNormalizedDoubled<1.0){environmentRefraction=mix(
1341
+ textureSample(refractionHighSampler,refractionHighSamplerSampler,refractionCoords),
1342
+ environmentRefractionMid,
1343
+ lodRefractionNormalizedDoubled
1344
+ );} else {environmentRefraction=mix(
1345
+ environmentRefractionMid,
1346
+ textureSample(refractionLowSampler,refractionLowSamplerSampler,refractionCoords),
1347
+ lodRefractionNormalizedDoubled-1.0
1348
+ );}
1349
+ #endif
1350
+ var refraction=environmentRefraction.rgb;
1351
+ #ifdef SS_RGBDREFRACTION
1352
+ refraction=fromRGBD(environmentRefraction);
1353
+ #endif
1354
+ #ifdef SS_GAMMAREFRACTION
1355
+ refraction=toLinearSpaceVec3(environmentRefraction.rgb);
1356
+ #endif
1357
+ return vec4f(refraction,environmentRefraction.a);}
1358
+ #endif
1359
+ #define pbr_inline
1360
+ fn subSurfaceBlock(
1361
+ vSubSurfaceIntensity: vec3f
1362
+ ,vThicknessParam: vec2f
1363
+ ,vTintColor: vec4f
1364
+ ,normalW: vec3f
1365
+ ,specularEnvironmentReflectance: vec3f
1366
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
1367
+ ,thicknessMap: vec4f
1368
+ #endif
1369
+ #ifdef SS_REFRACTIONINTENSITY_TEXTURE
1370
+ ,refractionIntensityMap: vec4f
1371
+ #endif
1372
+ #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
1373
+ ,translucencyIntensityMap: vec4f
1374
+ #endif
1375
+ #ifdef REFLECTION
1376
+ #ifdef SS_TRANSLUCENCY
1377
+ ,reflectionMatrix: mat4x4f
1378
+ #ifdef USESPHERICALFROMREFLECTIONMAP
1379
+ #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
1380
+ ,irradianceVector_: vec3f
1381
+ #endif
1382
+ #if defined(REALTIME_FILTERING)
1383
+ ,reflectionSampler: texture_cube<f32>
1384
+ ,reflectionSamplerSampler: sampler
1385
+ ,vReflectionFilteringInfo: vec2f
1386
+ #ifdef IBL_CDF_FILTERING
1387
+ ,icdfSampler: texture_2d<f32>
1388
+ ,icdfSamplerSampler: sampler
1389
+ #endif
1390
+ #endif
1391
+ #endif
1392
+ #ifdef USEIRRADIANCEMAP
1393
+ #ifdef REFLECTIONMAP_3D
1394
+ ,irradianceSampler: texture_cube<f32>
1395
+ ,irradianceSamplerSampler: sampler
1396
+ #else
1397
+ ,irradianceSampler: texture_2d<f32>
1398
+ ,irradianceSamplerSampler: sampler
1399
+ #endif
1400
+ #endif
1401
+ #endif
1402
+ #endif
1403
+ #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
1404
+ ,surfaceAlbedo: vec3f
1405
+ #endif
1406
+ #ifdef SS_REFRACTION
1407
+ ,vPositionW: vec3f
1408
+ ,viewDirectionW: vec3f
1409
+ ,view: mat4x4f
1410
+ ,vRefractionInfos: vec4f
1411
+ ,refractionMatrix: mat4x4f
1412
+ ,vRefractionMicrosurfaceInfos: vec4f
1413
+ ,vLightingIntensity: vec4f
1414
+ #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
1415
+ ,alpha: f32
1416
+ #endif
1417
+ #ifdef SS_LODINREFRACTIONALPHA
1418
+ ,NdotVUnclamped: f32
1419
+ #endif
1420
+ #ifdef SS_LINEARSPECULARREFRACTION
1421
+ ,roughness: f32
1422
+ #endif
1423
+ ,alphaG: f32
1424
+ #ifdef SS_REFRACTIONMAP_3D
1425
+ ,refractionSampler: texture_cube<f32>
1426
+ ,refractionSamplerSampler: sampler
1427
+ #ifndef LODBASEDMICROSFURACE
1428
+ ,refractionLowSampler: texture_cube<f32>
1429
+ ,refractionLowSamplerSampler: sampler
1430
+ ,refractionHighSampler: texture_cube<f32>
1431
+ ,refractionHighSamplerSampler: sampler
1432
+ #endif
1433
+ #else
1434
+ ,refractionSampler: texture_2d<f32>
1435
+ ,refractionSamplerSampler: sampler
1436
+ #ifndef LODBASEDMICROSFURACE
1437
+ ,refractionLowSampler: texture_2d<f32>
1438
+ ,refractionLowSamplerSampler: sampler
1439
+ ,refractionHighSampler: texture_2d<f32>
1440
+ ,refractionHighSamplerSampler: sampler
1441
+ #endif
1442
+ #endif
1443
+ #ifdef ANISOTROPIC
1444
+ ,anisotropicOut: anisotropicOutParams
1445
+ #endif
1446
+ #ifdef REALTIME_FILTERING
1447
+ ,vRefractionFilteringInfo: vec2f
1448
+ #endif
1449
+ #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
1450
+ ,refractionPosition: vec3f
1451
+ ,refractionSize: vec3f
1452
+ #endif
1453
+ #ifdef SS_DISPERSION
1454
+ ,dispersion: f32
1455
+ #endif
1456
+ #endif
1457
+ #ifdef SS_TRANSLUCENCY
1458
+ ,vDiffusionDistance: vec3f
1459
+ ,vTranslucencyColor: vec4f
1460
+ #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
1461
+ ,translucencyColorMap: vec4f
1462
+ #endif
1463
+ #endif
1464
+ )->subSurfaceOutParams
1465
+ {var outParams: subSurfaceOutParams;outParams.specularEnvironmentReflectance=specularEnvironmentReflectance;
1466
+ #ifdef SS_REFRACTION
1467
+ var refractionIntensity: f32=vSubSurfaceIntensity.x;
1468
+ #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
1469
+ refractionIntensity*=(1.0-alpha);outParams.alpha=1.0;
1470
+ #endif
1471
+ #endif
1472
+ #ifdef SS_TRANSLUCENCY
1473
+ var translucencyIntensity: f32=vSubSurfaceIntensity.y;
1474
+ #endif
1475
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
1476
+ #ifdef SS_USE_GLTF_TEXTURES
1477
+ var thickness: f32=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;
1478
+ #else
1479
+ var thickness: f32=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;
1480
+ #endif
1481
+ #if DEBUGMODE>0
1482
+ outParams.thicknessMap=thicknessMap;
1483
+ #endif
1484
+ #if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS)
1485
+ #ifdef SS_USE_GLTF_TEXTURES
1486
+ refractionIntensity*=thicknessMap.r;
1487
+ #else
1488
+ refractionIntensity*=thicknessMap.g;
1489
+ #endif
1490
+ #endif
1491
+ #if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS)
1492
+ #ifdef SS_USE_GLTF_TEXTURES
1493
+ translucencyIntensity*=thicknessMap.a;
1494
+ #else
1495
+ translucencyIntensity*=thicknessMap.b;
1496
+ #endif
1497
+ #endif
1498
+ #else
1499
+ var thickness: f32=vThicknessParam.y;
1500
+ #endif
1501
+ #if defined(SS_REFRACTION) && defined(SS_REFRACTIONINTENSITY_TEXTURE)
1502
+ #ifdef SS_USE_GLTF_TEXTURES
1503
+ refractionIntensity*=refractionIntensityMap.r;
1504
+ #else
1505
+ refractionIntensity*=refractionIntensityMap.g;
1506
+ #endif
1507
+ #endif
1508
+ #if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCYINTENSITY_TEXTURE)
1509
+ #ifdef SS_USE_GLTF_TEXTURES
1510
+ translucencyIntensity*=translucencyIntensityMap.a;
1511
+ #else
1512
+ translucencyIntensity*=translucencyIntensityMap.b;
1513
+ #endif
1514
+ #endif
1515
+ #ifdef SS_TRANSLUCENCY
1516
+ thickness=maxEps(thickness);var translucencyColor: vec4f=vTranslucencyColor;
1517
+ #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
1518
+ translucencyColor*=translucencyColorMap;
1519
+ #endif
1520
+ var transmittance: vec3f=transmittanceBRDF_Burley(translucencyColor.rgb,vDiffusionDistance,thickness);transmittance*=translucencyIntensity;outParams.transmittance=transmittance;outParams.translucencyIntensity=translucencyIntensity;
1521
+ #endif
1522
+ #ifdef SS_REFRACTION
1523
+ var environmentRefraction: vec4f= vec4f(0.,0.,0.,0.);
1524
+ #ifdef SS_HAS_THICKNESS
1525
+ var ior: f32=vRefractionInfos.y;
1526
+ #else
1527
+ var ior: f32=vRefractionMicrosurfaceInfos.w;
1528
+ #endif
1529
+ #ifdef SS_LODINREFRACTIONALPHA
1530
+ var refractionAlphaG: f32=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));var refractionLOD: f32=getLodFromAlphaGNdotV(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped);
1531
+ #elif defined(SS_LINEARSPECULARREFRACTION)
1532
+ var refractionRoughness: f32=alphaG;refractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));var refractionLOD: f32=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness);
1533
+ #else
1534
+ var refractionAlphaG: f32=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));var refractionLOD: f32=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG);
1535
+ #endif
1536
+ var refraction_ior: f32=vRefractionInfos.y;
1537
+ #ifdef SS_DISPERSION
1538
+ var realIOR: f32=1.0/refraction_ior;var iorDispersionSpread: f32=0.04*dispersion*(realIOR-1.0);var iors: vec3f= vec3f(1.0/(realIOR-iorDispersionSpread),refraction_ior,1.0/(realIOR+iorDispersionSpread));for (var i: i32=0; i<3; i++) {refraction_ior=iors[i];
1539
+ #endif
1540
+ var envSample: vec4f=sampleEnvironmentRefraction(refraction_ior,thickness,refractionLOD,normalW,vPositionW,viewDirectionW,view,vRefractionInfos,refractionMatrix,vRefractionMicrosurfaceInfos,alphaG
1541
+ #ifdef SS_REFRACTIONMAP_3D
1542
+ ,refractionSampler
1543
+ ,refractionSamplerSampler
1544
+ #ifndef LODBASEDMICROSFURACE
1545
+ ,refractionLowSampler
1546
+ ,refractionLowSamplerSampler
1547
+ ,refractionHighSampler
1548
+ ,refractionHighSamplerSampler
1549
+ #endif
1550
+ #else
1551
+ ,refractionSampler
1552
+ ,refractionSamplerSampler
1553
+ #ifndef LODBASEDMICROSFURACE
1554
+ ,refractionLowSampler
1555
+ ,refractionLowSamplerSampler
1556
+ ,refractionHighSampler
1557
+ ,refractionHighSamplerSampler
1558
+ #endif
1559
+ #endif
1560
+ #ifdef ANISOTROPIC
1561
+ ,anisotropicOut
1562
+ #endif
1563
+ #ifdef REALTIME_FILTERING
1564
+ ,vRefractionFilteringInfo
1565
+ #endif
1566
+ #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
1567
+ ,refractionPosition
1568
+ ,refractionSize
1569
+ #endif
1570
+ );
1571
+ #ifdef SS_DISPERSION
1572
+ environmentRefraction[i]=envSample[i];}
1573
+ #else
1574
+ environmentRefraction=envSample;
1575
+ #endif
1576
+ environmentRefraction=vec4f(environmentRefraction.rgb*vRefractionInfos.x,environmentRefraction.a);
1577
+ #endif
1578
+ #ifdef SS_REFRACTION
1579
+ var refractionTransmittance: vec3f= vec3f(refractionIntensity);
1580
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
1581
+ var volumeAlbedo: vec3f=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambertVec3(volumeAlbedo,thickness);
1582
+ #elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)
1583
+ var maxChannel: f32=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);var volumeAlbedo: vec3f=saturateVec3(maxChannel*surfaceAlbedo);environmentRefraction=vec4f(environmentRefraction.rgb*volumeAlbedo,environmentRefraction.a);
1584
+ #else
1585
+ var volumeAlbedo: vec3f=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambertVec3(volumeAlbedo,vThicknessParam.y);
1586
+ #endif
1587
+ #ifdef SS_ALBEDOFORREFRACTIONTINT
1588
+ environmentRefraction=vec4f(environmentRefraction.rgb*surfaceAlbedo.rgb,environmentRefraction.a);
1589
+ #endif
1590
+ outParams.surfaceAlbedo=surfaceAlbedo;outParams.refractionOpacity=1.-refractionIntensity;
1591
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
1592
+ outParams.surfaceAlbedo*=outParams.refractionOpacity;
1593
+ #endif
1594
+ #ifdef UNUSED_MULTIPLEBOUNCES
1595
+ var bounceSpecularEnvironmentReflectance: vec3f=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);
1596
+ #endif
1597
+ #if DEBUGMODE>0
1598
+ outParams.refractionTransmittance=refractionTransmittance;
1599
+ #endif
1600
+ outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;outParams.finalRefraction*=vec3f(1.0)-specularEnvironmentReflectance;
1601
+ #if DEBUGMODE>0
1602
+ outParams.environmentRefraction=environmentRefraction;
1603
+ #endif
1604
+ #endif
1605
+ #if defined(REFLECTION) && defined(SS_TRANSLUCENCY)
1606
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)
1607
+ var irradianceVector: vec3f= (reflectionMatrix* vec4f(normalW,0)).xyz;
1608
+ #ifdef REFLECTIONMAP_OPPOSITEZ
1609
+ irradianceVector.z*=-1.0;
1610
+ #endif
1611
+ #ifdef INVERTCUBICMAP
1612
+ irradianceVector.y*=-1.0;
1613
+ #endif
1614
+ #else
1615
+ var irradianceVector: vec3f=irradianceVector_;
1616
+ #endif
1617
+ #if defined(USESPHERICALFROMREFLECTIONMAP)
1618
+ #if defined(REALTIME_FILTERING)
1619
+ var refractionIrradiance: vec3f=irradiance(reflectionSampler,reflectionSamplerSampler,-irradianceVector,vReflectionFilteringInfo,0.0,surfaceAlbedo,irradianceVector
1620
+ #ifdef IBL_CDF_FILTERING
1621
+ ,icdfSampler
1622
+ ,icdfSamplerSampler
1623
+ #endif
1624
+ );
1625
+ #else
1626
+ var refractionIrradiance: vec3f=computeEnvironmentIrradiance(-irradianceVector);
1627
+ #endif
1628
+ #elif defined(USEIRRADIANCEMAP)
1629
+ #ifdef REFLECTIONMAP_3D
1630
+ var irradianceCoords: vec3f=irradianceVector;
1631
+ #else
1632
+ var irradianceCoords: vec2f=irradianceVector.xy;
1633
+ #ifdef REFLECTIONMAP_PROJECTION
1634
+ irradianceCoords/=irradianceVector.z;
1635
+ #endif
1636
+ irradianceCoords.y=1.0-irradianceCoords.y;
1637
+ #endif
1638
+ var temp: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,-irradianceCoords);var refractionIrradiance=temp.rgb;
1639
+ #ifdef RGBDREFLECTION
1640
+ refractionIrradiance=fromRGBD(temp).rgb;
1641
+ #endif
1642
+ #ifdef GAMMAREFLECTION
1643
+ refractionIrradiance=toLinearSpaceVec3(refractionIrradiance);
1644
+ #endif
1645
+ #else
1646
+ var refractionIrradiance: vec3f= vec3f(0.);
1647
+ #endif
1648
+ refractionIrradiance*=transmittance;
1649
+ #ifdef SS_ALBEDOFORTRANSLUCENCYTINT
1650
+ refractionIrradiance*=surfaceAlbedo.rgb;
1651
+ #endif
1652
+ outParams.refractionIrradiance=refractionIrradiance;
1653
+ #endif
1654
+ return outParams;}
1655
+ #endif
1656
+ `;
1657
+ e.IncludesShadersStoreWGSL[R] || (e.IncludesShadersStoreWGSL[R] = y);
1658
+ const S = "pbrBlockNormalFinal", B = `#if defined(FORCENORMALFORWARD) && defined(NORMAL)
1659
+ var faceNormal: vec3f=normalize(cross(dpdx(fragmentInputs.vPositionW),dpdy(fragmentInputs.vPositionW)))*scene.vEyePosition.w;
1660
+ #if defined(TWOSIDEDLIGHTING)
1661
+ faceNormal=select(-faceNormal,faceNormal,fragmentInputs.frontFacing);
1662
+ #endif
1663
+ normalW*=sign(dot(normalW,faceNormal));
1664
+ #endif
1665
+ #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
1666
+ #if defined(MIRRORED)
1667
+ normalW=select(normalW,-normalW,fragmentInputs.frontFacing);
1668
+ #else
1669
+ normalW=select(-normalW,normalW,fragmentInputs.frontFacing);
1670
+ #endif
1671
+ #endif
1672
+ `;
1673
+ e.IncludesShadersStoreWGSL[S] || (e.IncludesShadersStoreWGSL[S] = B);
1674
+ const m = "pbrBlockLightmapInit", G = `#ifdef LIGHTMAP
1675
+ var lightmapColor: vec4f=TEXRD(lightmapSampler,lightmapSamplerSampler,fragmentInputs.vLightmapUV+uvOffset);
1676
+ #ifdef RGBDLIGHTMAP
1677
+ lightmapColor=vec4f(fromRGBD(lightmapColor),lightmapColor.a);
1678
+ #endif
1679
+ #ifdef GAMMALIGHTMAP
1680
+ lightmapColor=vec4f(toLinearSpaceVec3(lightmapColor.rgb),lightmapColor.a);
1681
+ #endif
1682
+ lightmapColor=vec4f(lightmapColor.rgb*uniforms.vLightmapInfos.y,lightmapColor.a);
1683
+ #endif
1684
+ `;
1685
+ e.IncludesShadersStoreWGSL[m] || (e.IncludesShadersStoreWGSL[m] = G);
1686
+ const C = "pbrBlockGeometryInfo", V = `var NdotVUnclamped: f32=dot(normalW,viewDirectionW);var NdotV: f32=absEps(NdotVUnclamped);var alphaG: f32=convertRoughnessToAverageSlope(roughness);var AARoughnessFactors: vec2f=getAARoughnessFactors(normalW.xyz);
1687
+ #ifdef SPECULARAA
1688
+ alphaG+=AARoughnessFactors.y;
1689
+ #endif
1690
+ #if defined(ENVIRONMENTBRDF)
1691
+ var environmentBrdf: vec3f=getBRDFLookup(NdotV,roughness);
1692
+ #endif
1693
+ #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
1694
+ #ifdef RADIANCEOCCLUSION
1695
+ #ifdef AMBIENTINGRAYSCALE
1696
+ var ambientMonochrome: f32=aoOut.ambientOcclusionColor.r;
1697
+ #else
1698
+ var ambientMonochrome: f32=getLuminance(aoOut.ambientOcclusionColor);
1699
+ #endif
1700
+ var seo: f32=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);
1701
+ #endif
1702
+ #ifdef HORIZONOCCLUSION
1703
+ #ifdef BUMP
1704
+ #ifdef REFLECTIONMAP_3D
1705
+ var eho: f32=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
1706
+ #endif
1707
+ #endif
1708
+ #endif
1709
+ #endif
1710
+ `;
1711
+ e.IncludesShadersStoreWGSL[C] || (e.IncludesShadersStoreWGSL[C] = V);
1712
+ const v = "pbrBlockReflectance", H = `#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
1713
+ var baseSpecularEnvironmentReflectance: vec3f=getReflectanceFromBRDFWithEnvLookup(vec3f(reflectanceF0),vec3f(reflectivityOut.reflectanceF90),environmentBrdf);
1714
+ #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
1715
+ let metalEnvironmentReflectance: vec3f=vec3f(reflectivityOut.specularWeight)*getF82Specular(NdotV,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);let dielectricEnvironmentReflectance=getReflectanceFromBRDFWithEnvLookup(reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90,environmentBrdf);var colorSpecularEnvironmentReflectance: vec3f=mix(dielectricEnvironmentReflectance,metalEnvironmentReflectance,reflectivityOut.metallic);
1716
+ #else
1717
+ var colorSpecularEnvironmentReflectance=getReflectanceFromBRDFWithEnvLookup(clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,environmentBrdf);
1718
+ #endif
1719
+ #ifdef RADIANCEOCCLUSION
1720
+ colorSpecularEnvironmentReflectance*=seo;
1721
+ #endif
1722
+ #ifdef HORIZONOCCLUSION
1723
+ #ifdef BUMP
1724
+ #ifdef REFLECTIONMAP_3D
1725
+ colorSpecularEnvironmentReflectance*=eho;
1726
+ #endif
1727
+ #endif
1728
+ #endif
1729
+ #else
1730
+ var colorSpecularEnvironmentReflectance: vec3f=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));var baseSpecularEnvironmentReflectance: vec3f=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,vec3f(reflectanceF0),vec3f(reflectivityOut.reflectanceF90),sqrt(microSurface));
1731
+ #endif
1732
+ #ifdef CLEARCOAT
1733
+ colorSpecularEnvironmentReflectance*=clearcoatOut.conservationFactor;
1734
+ #if defined(CLEARCOAT_TINT)
1735
+ colorSpecularEnvironmentReflectance*=clearcoatOut.absorption;
1736
+ #endif
1737
+ #endif
1738
+ `;
1739
+ e.IncludesShadersStoreWGSL[v] || (e.IncludesShadersStoreWGSL[v] = H);
1740
+ const u = "pbrBlockDirectLighting", x = `var diffuseBase: vec3f=vec3f(0.,0.,0.);
1741
+ #ifdef SS_TRANSLUCENCY
1742
+ var diffuseTransmissionBase: vec3f=vec3f(0.,0.,0.);
1743
+ #endif
1744
+ #ifdef SPECULARTERM
1745
+ var specularBase: vec3f=vec3f(0.,0.,0.);
1746
+ #endif
1747
+ #ifdef CLEARCOAT
1748
+ var clearCoatBase: vec3f=vec3f(0.,0.,0.);
1749
+ #endif
1750
+ #ifdef SHEEN
1751
+ var sheenBase: vec3f=vec3f(0.,0.,0.);
1752
+ #endif
1753
+ #if defined(SPECULARTERM) && defined(LIGHT0)
1754
+ var coloredFresnel: vec3f=vec3f(0.,0.,0.);
1755
+ #endif
1756
+ var preInfo: preLightingInfo;var info: lightingInfo;var shadow: f32=1.;
1757
+ var aggShadow: f32=0.;var numLights: f32=0.;
1758
+ #if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
1759
+ var absorption: vec3f=vec3f(0.);
1760
+ #endif
1761
+ `;
1762
+ e.IncludesShadersStoreWGSL[u] || (e.IncludesShadersStoreWGSL[u] = x);
1763
+ const I = "pbrBlockFinalLitComponents", W = `aggShadow=aggShadow/numLights;
1764
+ #if defined(ENVIRONMENTBRDF)
1765
+ #ifdef MS_BRDF_ENERGY_CONSERVATION
1766
+ var baseSpecularEnergyConservationFactor: vec3f=getEnergyConservationFactor(vec3f(reflectanceF0),environmentBrdf);var coloredEnergyConservationFactor: vec3f=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);
1767
+ #endif
1768
+ #endif
1769
+ #if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
1770
+ surfaceAlbedo=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;
1771
+ #endif
1772
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
1773
+ #ifndef METALLICWORKFLOW
1774
+ #ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION
1775
+ surfaceAlbedo=vec3f(1.-reflectanceF0)*surfaceAlbedo.rgb;
1776
+ #endif
1777
+ #endif
1778
+ #endif
1779
+ #ifdef REFLECTION
1780
+ var finalIrradiance: vec3f=reflectionOut.environmentIrradiance;
1781
+ #ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION
1782
+ #if defined(METALLICWORKFLOW) || defined(SPECULAR_GLOSSINESS_ENERGY_CONSERVATION)
1783
+ var baseSpecularEnergy: vec3f=vec3f(baseSpecularEnvironmentReflectance);
1784
+ #if defined(ENVIRONMENTBRDF)
1785
+ #ifdef MS_BRDF_ENERGY_CONSERVATION
1786
+ baseSpecularEnergy*=baseSpecularEnergyConservationFactor;
1787
+ #endif
1788
+ #endif
1789
+ finalIrradiance*=clamp(vec3f(1.0)-baseSpecularEnergy,vec3f(0.0),vec3f(1.0));
1790
+ #endif
1791
+ #endif
1792
+ #if defined(CLEARCOAT)
1793
+ finalIrradiance*=clearcoatOut.conservationFactor;
1794
+ #if defined(CLEARCOAT_TINT)
1795
+ finalIrradiance*=clearcoatOut.absorption;
1796
+ #endif
1797
+ #endif
1798
+ #ifndef SS_APPLY_ALBEDO_AFTER_SUBSURFACE
1799
+ finalIrradiance*=surfaceAlbedo.rgb;
1800
+ #endif
1801
+ #if defined(SS_REFRACTION)
1802
+ finalIrradiance*=subSurfaceOut.refractionOpacity;
1803
+ #endif
1804
+ #if defined(SS_TRANSLUCENCY)
1805
+ finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);finalIrradiance+=subSurfaceOut.refractionIrradiance;
1806
+ #endif
1807
+ #ifdef SS_APPLY_ALBEDO_AFTER_SUBSURFACE
1808
+ finalIrradiance*=surfaceAlbedo.rgb;
1809
+ #endif
1810
+ finalIrradiance*=uniforms.vLightingIntensity.z;finalIrradiance*=aoOut.ambientOcclusionColor;
1811
+ #endif
1812
+ #ifdef SPECULARTERM
1813
+ var finalSpecular: vec3f=specularBase;finalSpecular=max(finalSpecular,vec3f(0.0));var finalSpecularScaled: vec3f=finalSpecular*uniforms.vLightingIntensity.x*uniforms.vLightingIntensity.w;
1814
+ #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
1815
+ finalSpecularScaled*=coloredEnergyConservationFactor;
1816
+ #endif
1817
+ #if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
1818
+ finalSpecularScaled*=sheenOut.sheenAlbedoScaling;
1819
+ #endif
1820
+ #endif
1821
+ #ifdef REFLECTION
1822
+ var finalRadiance: vec3f=reflectionOut.environmentRadiance.rgb;finalRadiance*=colorSpecularEnvironmentReflectance;;var finalRadianceScaled: vec3f=finalRadiance*uniforms.vLightingIntensity.z;
1823
+ #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
1824
+ finalRadianceScaled*=coloredEnergyConservationFactor;
1825
+ #endif
1826
+ #if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
1827
+ finalRadianceScaled*=sheenOut.sheenAlbedoScaling;
1828
+ #endif
1829
+ #endif
1830
+ #ifdef SHEEN
1831
+ var finalSheen: vec3f=sheenBase*sheenOut.sheenColor;finalSheen=max(finalSheen,vec3f(0.0));var finalSheenScaled: vec3f=finalSheen*uniforms.vLightingIntensity.x*uniforms.vLightingIntensity.w;
1832
+ #if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)
1833
+ sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;
1834
+ #if defined(CLEARCOAT_TINT)
1835
+ sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;
1836
+ #endif
1837
+ #endif
1838
+ #endif
1839
+ #ifdef CLEARCOAT
1840
+ var finalClearCoat: vec3f=clearCoatBase;finalClearCoat=max(finalClearCoat,vec3f(0.0));var finalClearCoatScaled: vec3f=finalClearCoat*uniforms.vLightingIntensity.x*uniforms.vLightingIntensity.w;
1841
+ #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
1842
+ finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;
1843
+ #endif
1844
+ #ifdef SS_REFRACTION
1845
+ subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;
1846
+ #ifdef CLEARCOAT_TINT
1847
+ subSurfaceOut.finalRefraction*=clearcoatOut.absorption;
1848
+ #endif
1849
+ #endif
1850
+ #endif
1851
+ #ifdef ALPHABLEND
1852
+ var luminanceOverAlpha: f32=0.0;
1853
+ #if defined(REFLECTION) && defined(RADIANCEOVERALPHA)
1854
+ luminanceOverAlpha+=getLuminance(finalRadianceScaled);
1855
+ #if defined(CLEARCOAT)
1856
+ luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);
1857
+ #endif
1858
+ #endif
1859
+ #if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)
1860
+ luminanceOverAlpha+=getLuminance(finalSpecularScaled);
1861
+ #endif
1862
+ #if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)
1863
+ luminanceOverAlpha+=getLuminance(finalClearCoatScaled);
1864
+ #endif
1865
+ #if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)
1866
+ alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);
1867
+ #endif
1868
+ #endif
1869
+ `;
1870
+ e.IncludesShadersStoreWGSL[I] || (e.IncludesShadersStoreWGSL[I] = W);
1871
+ const A = "pbrBlockFinalUnlitComponents", X = `var finalDiffuse: vec3f=diffuseBase;finalDiffuse*=surfaceAlbedo;
1872
+ #if defined(SS_REFRACTION) && !defined(UNLIT) && !defined(LEGACY_SPECULAR_ENERGY_CONSERVATION)
1873
+ finalDiffuse*=subSurfaceOut.refractionOpacity;
1874
+ #endif
1875
+ #if defined(SS_TRANSLUCENCY) && !defined(UNLIT)
1876
+ finalDiffuse+=diffuseTransmissionBase;
1877
+ #endif
1878
+ finalDiffuse=max(finalDiffuse,vec3f(0.0));finalDiffuse*=uniforms.vLightingIntensity.x;var finalAmbient: vec3f=uniforms.vAmbientColor;finalAmbient=finalAmbient*surfaceAlbedo.rgb;var finalEmissive: vec3f=uniforms.vEmissiveColor;
1879
+ #ifdef EMISSIVE
1880
+ var emissiveColorTex: vec3f=TEXRD(emissiveSampler,emissiveSamplerSampler,fragmentInputs.vEmissiveUV+uvOffset).rgb;
1881
+ #ifdef GAMMAEMISSIVE
1882
+ finalEmissive*=toLinearSpaceVec3(emissiveColorTex.rgb);
1883
+ #else
1884
+ finalEmissive*=emissiveColorTex.rgb;
1885
+ #endif
1886
+ finalEmissive*= uniforms.vEmissiveInfos.y;
1887
+ #endif
1888
+ finalEmissive*=uniforms.vLightingIntensity.y;
1889
+ #ifdef AMBIENT
1890
+ var ambientOcclusionForDirectDiffuse: vec3f=mix( vec3f(1.),aoOut.ambientOcclusionColor,uniforms.vAmbientInfos.w);
1891
+ #else
1892
+ var ambientOcclusionForDirectDiffuse: vec3f=aoOut.ambientOcclusionColor;
1893
+ #endif
1894
+ finalAmbient*=aoOut.ambientOcclusionColor;finalDiffuse*=ambientOcclusionForDirectDiffuse;
1895
+ `;
1896
+ e.IncludesShadersStoreWGSL[A] || (e.IncludesShadersStoreWGSL[A] = X);
1897
+ const p = "pbrBlockFinalColorComposition", Y = `var finalColor: vec4f= vec4f(
1898
+ #ifndef UNLIT
1899
+ #ifdef REFLECTION
1900
+ finalIrradiance +
1901
+ #endif
1902
+ #ifdef SPECULARTERM
1903
+ finalSpecularScaled +
1904
+ #endif
1905
+ #ifdef SHEEN
1906
+ finalSheenScaled +
1907
+ #endif
1908
+ #ifdef CLEARCOAT
1909
+ finalClearCoatScaled +
1910
+ #endif
1911
+ #ifdef REFLECTION
1912
+ finalRadianceScaled +
1913
+ #if defined(SHEEN) && defined(ENVIRONMENTBRDF)
1914
+ sheenOut.finalSheenRadianceScaled +
1915
+ #endif
1916
+ #ifdef CLEARCOAT
1917
+ clearcoatOut.finalClearCoatRadianceScaled +
1918
+ #endif
1919
+ #endif
1920
+ #ifdef SS_REFRACTION
1921
+ subSurfaceOut.finalRefraction +
1922
+ #endif
1923
+ #endif
1924
+ finalAmbient +
1925
+ finalDiffuse,
1926
+ alpha);
1927
+ #ifdef LIGHTMAP
1928
+ #ifndef LIGHTMAPEXCLUDED
1929
+ #ifdef USELIGHTMAPASSHADOWMAP
1930
+ finalColor=vec4f(finalColor.rgb*lightmapColor.rgb,finalColor.a);
1931
+ #else
1932
+ finalColor=vec4f(finalColor.rgb+lightmapColor.rgb,finalColor.a);
1933
+ #endif
1934
+ #endif
1935
+ #endif
1936
+ finalColor=vec4f(finalColor.rgb+finalEmissive,finalColor.a);
1937
+ #define CUSTOM_FRAGMENT_BEFORE_FOG
1938
+ finalColor=max(finalColor,vec4f(0.0));
1939
+ `;
1940
+ e.IncludesShadersStoreWGSL[p] || (e.IncludesShadersStoreWGSL[p] = Y);
1941
+ const N = "pbrBlockPrePass", w = `#if SCENE_MRT_COUNT>0
1942
+ var writeGeometryInfo: f32=select(0.0,1.0,finalColor.a>ALPHATESTVALUE);var fragData: array<vec4<f32>,SCENE_MRT_COUNT>;
1943
+ #ifdef PREPASS_POSITION
1944
+ fragData[PREPASS_POSITION_INDEX]= vec4f(fragmentInputs.vPositionW,writeGeometryInfo);
1945
+ #endif
1946
+ #ifdef PREPASS_LOCAL_POSITION
1947
+ fragData[PREPASS_LOCAL_POSITION_INDEX]=vec4f(fragmentInputs.vPosition,writeGeometryInfo);
1948
+ #endif
1949
+ #ifdef PREPASS_VELOCITY
1950
+ var a: vec2f=(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w)*0.5+0.5;var b: vec2f=(fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w)*0.5+0.5;var velocity: vec2f=abs(a-b);velocity= vec2f(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;fragData[PREPASS_VELOCITY_INDEX]= vec4f(velocity,0.0,writeGeometryInfo);
1951
+ #elif defined(PREPASS_VELOCITY_LINEAR)
1952
+ var velocity : vec2f=vec2f(0.5)*((fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w) -
1953
+ (fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w));fragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4f(velocity,0.0,writeGeometryInfo);
1954
+ #endif
1955
+ #ifdef PREPASS_ALBEDO
1956
+ fragData[PREPASS_ALBEDO_INDEX]=vec4f(surfaceAlbedo,writeGeometryInfo);
1957
+ #endif
1958
+ #ifdef PREPASS_ALBEDO_SQRT
1959
+ var sqAlbedo : vec3f=sqrt(surfaceAlbedo);
1960
+ #endif
1961
+ #ifdef PREPASS_IRRADIANCE_LEGACY
1962
+ var irradiance : vec3f=finalDiffuse;
1963
+ #ifndef UNLIT
1964
+ #ifdef REFLECTION
1965
+ irradiance+=finalIrradiance;
1966
+ #endif
1967
+ #endif
1968
+ #ifdef SS_SCATTERING
1969
+ #ifdef PREPASS_COLOR
1970
+ fragData[PREPASS_COLOR_INDEX]=vec4f(finalColor.rgb-irradiance,finalColor.a);
1971
+ #endif
1972
+ irradiance/=sqAlbedo;fragData[PREPASS_IRRADIANCE_LEGACY_INDEX]=vec4f(clamp(irradiance,vec3f(0.),vec3f(1.)),writeGeometryInfo*uniforms.scatteringDiffusionProfile/255.);
1973
+ #else
1974
+ #ifdef PREPASS_COLOR
1975
+ fragData[PREPASS_COLOR_INDEX]=finalColor;
1976
+ #endif
1977
+ fragData[PREPASS_IRRADIANCE_LEGACY_INDEX]=vec4f(clamp(irradiance,vec3f(0.),vec3f(1.)),writeGeometryInfo);
1978
+ #endif
1979
+ #else
1980
+ #ifdef PREPASS_IRRADIANCE
1981
+ var irradiance : vec3f=finalDiffuse;
1982
+ #ifndef UNLIT
1983
+ #ifdef REFLECTION
1984
+ irradiance+=finalIrradiance;
1985
+ #endif
1986
+ #endif
1987
+ fragData[PREPASS_IRRADIANCE_INDEX]=vec4f(irradiance,writeGeometryInfo);
1988
+ #endif
1989
+ #ifdef PREPASS_COLOR
1990
+ fragData[PREPASS_COLOR_INDEX]=vec4f(finalColor.rgb,finalColor.a);
1991
+ #endif
1992
+ #endif
1993
+ #ifdef PREPASS_DEPTH
1994
+ fragData[PREPASS_DEPTH_INDEX]=vec4f(fragmentInputs.vViewPos.z,0.0,0.0,writeGeometryInfo);
1995
+ #endif
1996
+ #ifdef PREPASS_SCREENSPACE_DEPTH
1997
+ fragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4f(fragmentInputs.position.z,0.0,0.0,writeGeometryInfo);
1998
+ #endif
1999
+ #ifdef PREPASS_NORMALIZED_VIEW_DEPTH
2000
+ fragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4f(fragmentInputs.vNormViewDepth,0.0,0.0,writeGeometryInfo);
2001
+ #endif
2002
+ #ifdef PREPASS_NORMAL
2003
+ #ifdef PREPASS_NORMAL_WORLDSPACE
2004
+ fragData[PREPASS_NORMAL_INDEX]=vec4f(normalW,writeGeometryInfo);
2005
+ #else
2006
+ fragData[PREPASS_NORMAL_INDEX]=vec4f(normalize((scene.view*vec4f(normalW,0.0)).rgb),writeGeometryInfo);
2007
+ #endif
2008
+ #endif
2009
+ #ifdef PREPASS_WORLD_NORMAL
2010
+ fragData[PREPASS_WORLD_NORMAL_INDEX]=vec4f(normalW*0.5+0.5,writeGeometryInfo);
2011
+ #endif
2012
+ #ifdef PREPASS_ALBEDO_SQRT
2013
+ fragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4f(sqAlbedo,writeGeometryInfo);
2014
+ #endif
2015
+ #ifdef PREPASS_REFLECTIVITY
2016
+ #ifndef UNLIT
2017
+ fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(specularEnvironmentR0,microSurface)*writeGeometryInfo;
2018
+ #else
2019
+ fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(0.0,0.0,0.0,1.0)*writeGeometryInfo;
2020
+ #endif
2021
+ #endif
2022
+ #if SCENE_MRT_COUNT>0
2023
+ fragmentOutputs.fragData0=fragData[0];
2024
+ #endif
2025
+ #if SCENE_MRT_COUNT>1
2026
+ fragmentOutputs.fragData1=fragData[1];
2027
+ #endif
2028
+ #if SCENE_MRT_COUNT>2
2029
+ fragmentOutputs.fragData2=fragData[2];
2030
+ #endif
2031
+ #if SCENE_MRT_COUNT>3
2032
+ fragmentOutputs.fragData3=fragData[3];
2033
+ #endif
2034
+ #if SCENE_MRT_COUNT>4
2035
+ fragmentOutputs.fragData4=fragData[4];
2036
+ #endif
2037
+ #if SCENE_MRT_COUNT>5
2038
+ fragmentOutputs.fragData5=fragData[5];
2039
+ #endif
2040
+ #if SCENE_MRT_COUNT>6
2041
+ fragmentOutputs.fragData6=fragData[6];
2042
+ #endif
2043
+ #if SCENE_MRT_COUNT>7
2044
+ fragmentOutputs.fragData7=fragData[7];
2045
+ #endif
2046
+ #endif
2047
+ `;
2048
+ e.IncludesShadersStoreWGSL[N] || (e.IncludesShadersStoreWGSL[N] = w);
2049
+ const a = "pbrPixelShader", O = `#define PBR_FRAGMENT_SHADER
2050
+ #define CUSTOM_FRAGMENT_BEGIN
2051
+ #include<prePassDeclaration>[SCENE_MRT_COUNT]
2052
+ #include<oitDeclaration>
2053
+ #ifndef FROMLINEARSPACE
2054
+ #define FROMLINEARSPACE
2055
+ #endif
2056
+ #include<pbrUboDeclaration>
2057
+ #include<pbrFragmentExtraDeclaration>
2058
+ #include<lightUboDeclaration>[0..maxSimultaneousLights]
2059
+ #include<pbrFragmentSamplersDeclaration>
2060
+ #include<imageProcessingDeclaration>
2061
+ #include<clipPlaneFragmentDeclaration>
2062
+ #include<logDepthDeclaration>
2063
+ #include<fogFragmentDeclaration>
2064
+ #include<textureRepetitionFunctions>
2065
+ #include<helperFunctions>
2066
+ #include<subSurfaceScatteringFunctions>
2067
+ #include<importanceSampling>
2068
+ #include<pbrHelperFunctions>
2069
+ #include<imageProcessingFunctions>
2070
+ #include<shadowsFragmentFunctions>
2071
+ #include<harmonicsFunctions>
2072
+ #include<pbrDirectLightingSetupFunctions>
2073
+ #include<pbrDirectLightingFalloffFunctions>
2074
+ #include<pbrBRDFFunctions>
2075
+ #include<hdrFilteringFunctions>
2076
+ #include<pbrDirectLightingFunctions>
2077
+ #include<pbrIBLFunctions>
2078
+ #include<bumpFragmentMainFunctions>
2079
+ #include<bumpFragmentFunctions>
2080
+ #ifdef REFLECTION
2081
+ #include<reflectionFunction>
2082
+ #endif
2083
+ #define CUSTOM_FRAGMENT_DEFINITIONS
2084
+ #include<pbrBlockAlbedoOpacity>
2085
+ #include<pbrBlockReflectivity>
2086
+ #include<pbrBlockAmbientOcclusion>
2087
+ #include<pbrBlockAlphaFresnel>
2088
+ #include<pbrBlockAnisotropic>
2089
+ #include<pbrBlockReflection>
2090
+ #include<pbrBlockSheen>
2091
+ #include<pbrBlockClearcoat>
2092
+ #include<pbrBlockIridescence>
2093
+ #include<pbrBlockSubSurface>
2094
+ @fragment
2095
+ fn main(input: FragmentInputs)->FragmentOutputs {
2096
+ #define CUSTOM_FRAGMENT_MAIN_BEGIN
2097
+ #include<clipPlaneFragment>
2098
+ #include<pbrBlockNormalGeometric>
2099
+ #include<bumpFragment>
2100
+ #include<pbrBlockNormalFinal>
2101
+ var albedoOpacityOut: albedoOpacityOutParams;
2102
+ #ifdef ALBEDO
2103
+ var albedoTexture: vec4f=TEXRD(albedoSampler,albedoSamplerSampler,fragmentInputs.vAlbedoUV+uvOffset);
2104
+ #endif
2105
+ #ifdef BASE_WEIGHT
2106
+ var baseWeightTexture: vec4f=TEXRD(baseWeightSampler,baseWeightSamplerSampler,fragmentInputs.vBaseWeightUV+uvOffset);
2107
+ #endif
2108
+ #ifdef OPACITY
2109
+ var opacityMap: vec4f=TEXRD(opacitySampler,opacitySamplerSampler,fragmentInputs.vOpacityUV+uvOffset);
2110
+ #endif
2111
+ #ifdef DECAL
2112
+ var decalColor: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset);
2113
+ #endif
2114
+ albedoOpacityOut=albedoOpacityBlock(
2115
+ uniforms.vAlbedoColor
2116
+ #ifdef ALBEDO
2117
+ ,albedoTexture
2118
+ ,uniforms.vAlbedoInfos
2119
+ #endif
2120
+ ,uniforms.baseWeight
2121
+ #ifdef BASE_WEIGHT
2122
+ ,baseWeightTexture
2123
+ ,uniforms.vBaseWeightInfos
2124
+ #endif
2125
+ #ifdef OPACITY
2126
+ ,opacityMap
2127
+ ,uniforms.vOpacityInfos
2128
+ #endif
2129
+ #ifdef DETAIL
2130
+ ,detailColor
2131
+ ,uniforms.vDetailInfos
2132
+ #endif
2133
+ #ifdef DECAL
2134
+ ,decalColor
2135
+ ,uniforms.vDecalInfos
2136
+ #endif
2137
+ );var surfaceAlbedo: vec3f=albedoOpacityOut.surfaceAlbedo;var alpha: f32=albedoOpacityOut.alpha;
2138
+ #define CUSTOM_FRAGMENT_UPDATE_ALPHA
2139
+ #include<depthPrePass>
2140
+ #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
2141
+ var aoOut: ambientOcclusionOutParams;
2142
+ #ifdef AMBIENT
2143
+ var ambientOcclusionColorMap: vec3f=TEXRD(ambientSampler,ambientSamplerSampler,fragmentInputs.vAmbientUV+uvOffset).rgb;
2144
+ #endif
2145
+ aoOut=ambientOcclusionBlock(
2146
+ #ifdef AMBIENT
2147
+ ambientOcclusionColorMap,
2148
+ uniforms.vAmbientInfos
2149
+ #endif
2150
+ );
2151
+ #include<pbrBlockLightmapInit>
2152
+ #ifdef UNLIT
2153
+ var diffuseBase: vec3f= vec3f(1.,1.,1.);
2154
+ #else
2155
+ var baseColor: vec3f=surfaceAlbedo;var reflectivityOut: reflectivityOutParams;
2156
+ #if defined(REFLECTIVITY)
2157
+ var surfaceMetallicOrReflectivityColorMap: vec4f=TEXRD(reflectivitySampler,reflectivitySamplerSampler,fragmentInputs.vReflectivityUV+uvOffset);var baseReflectivity: vec4f=surfaceMetallicOrReflectivityColorMap;
2158
+ #ifndef METALLICWORKFLOW
2159
+ #ifdef REFLECTIVITY_GAMMA
2160
+ surfaceMetallicOrReflectivityColorMap=toLinearSpaceVec4(surfaceMetallicOrReflectivityColorMap);
2161
+ #endif
2162
+ surfaceMetallicOrReflectivityColorMap=vec4f(surfaceMetallicOrReflectivityColorMap.rgb*uniforms.vReflectivityInfos.y,surfaceMetallicOrReflectivityColorMap.a);
2163
+ #endif
2164
+ #endif
2165
+ #if defined(MICROSURFACEMAP)
2166
+ var microSurfaceTexel: vec4f=TEXRD(microSurfaceSampler,microSurfaceSamplerSampler,fragmentInputs.vMicroSurfaceSamplerUV+uvOffset)*uniforms.vMicroSurfaceSamplerInfos.y;
2167
+ #endif
2168
+ #ifdef BASE_DIFFUSE_ROUGHNESS
2169
+ var baseDiffuseRoughnessTexture: f32=TEXRD(baseDiffuseRoughnessSampler,baseDiffuseRoughnessSamplerSampler,fragmentInputs.vBaseDiffuseRoughnessUV+uvOffset).x;
2170
+ #endif
2171
+ #ifdef METALLICWORKFLOW
2172
+ var metallicReflectanceFactors: vec4f=uniforms.vMetallicReflectanceFactors;
2173
+ #ifdef REFLECTANCE
2174
+ var reflectanceFactorsMap: vec4f=TEXRD(reflectanceSampler,reflectanceSamplerSampler,fragmentInputs.vReflectanceUV+uvOffset);
2175
+ #ifdef REFLECTANCE_GAMMA
2176
+ reflectanceFactorsMap=toLinearSpaceVec4(reflectanceFactorsMap);
2177
+ #endif
2178
+ metallicReflectanceFactors=vec4f(metallicReflectanceFactors.rgb*reflectanceFactorsMap.rgb,metallicReflectanceFactors.a);
2179
+ #endif
2180
+ #ifdef METALLIC_REFLECTANCE
2181
+ var metallicReflectanceFactorsMap: vec4f=TEXRD(metallicReflectanceSampler,metallicReflectanceSamplerSampler,fragmentInputs.vMetallicReflectanceUV+uvOffset);
2182
+ #ifdef METALLIC_REFLECTANCE_GAMMA
2183
+ metallicReflectanceFactorsMap=toLinearSpaceVec4(metallicReflectanceFactorsMap);
2184
+ #endif
2185
+ #ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY
2186
+ metallicReflectanceFactors=vec4f(metallicReflectanceFactors.rgb*metallicReflectanceFactorsMap.rgb,metallicReflectanceFactors.a);
2187
+ #endif
2188
+ metallicReflectanceFactors.a*=metallicReflectanceFactorsMap.a;
2189
+ #endif
2190
+ #endif
2191
+ reflectivityOut=reflectivityBlock(
2192
+ uniforms.vReflectivityColor
2193
+ #ifdef METALLICWORKFLOW
2194
+ ,surfaceAlbedo
2195
+ ,metallicReflectanceFactors
2196
+ #endif
2197
+ ,uniforms.baseDiffuseRoughness
2198
+ #ifdef BASE_DIFFUSE_ROUGHNESS
2199
+ ,baseDiffuseRoughnessTexture
2200
+ ,uniforms.vBaseDiffuseRoughnessInfos
2201
+ #endif
2202
+ #ifdef REFLECTIVITY
2203
+ ,uniforms.vReflectivityInfos
2204
+ ,surfaceMetallicOrReflectivityColorMap
2205
+ #endif
2206
+ #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
2207
+ ,aoOut.ambientOcclusionColor
2208
+ #endif
2209
+ #ifdef MICROSURFACEMAP
2210
+ ,microSurfaceTexel
2211
+ #endif
2212
+ #ifdef DETAIL
2213
+ ,detailColor
2214
+ ,uniforms.vDetailInfos
2215
+ #endif
2216
+ );var microSurface: f32=reflectivityOut.microSurface;var roughness: f32=reflectivityOut.roughness;var diffuseRoughness: f32=reflectivityOut.diffuseRoughness;
2217
+ #ifdef METALLICWORKFLOW
2218
+ surfaceAlbedo=reflectivityOut.surfaceAlbedo;
2219
+ #endif
2220
+ #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
2221
+ aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
2222
+ #endif
2223
+ #ifdef ALPHAFRESNEL
2224
+ #if defined(ALPHATEST) || defined(ALPHABLEND)
2225
+ var alphaFresnelOut: alphaFresnelOutParams;alphaFresnelOut=alphaFresnelBlock(
2226
+ normalW,
2227
+ viewDirectionW,
2228
+ alpha,
2229
+ microSurface
2230
+ );alpha=alphaFresnelOut.alpha;
2231
+ #endif
2232
+ #endif
2233
+ #include<pbrBlockGeometryInfo>
2234
+ #ifdef ANISOTROPIC
2235
+ var anisotropicOut: anisotropicOutParams;
2236
+ #ifdef ANISOTROPIC_TEXTURE
2237
+ var anisotropyMapData: vec3f=TEXRD(anisotropySampler,anisotropySamplerSampler,fragmentInputs.vAnisotropyUV+uvOffset).rgb*uniforms.vAnisotropyInfos.y;
2238
+ #endif
2239
+ anisotropicOut=anisotropicBlock(
2240
+ uniforms.vAnisotropy,
2241
+ roughness,
2242
+ #ifdef ANISOTROPIC_TEXTURE
2243
+ anisotropyMapData,
2244
+ #endif
2245
+ TBN,
2246
+ normalW,
2247
+ viewDirectionW
2248
+ );
2249
+ #endif
2250
+ #ifdef REFLECTION
2251
+ var reflectionOut: reflectionOutParams;
2252
+ #ifndef USE_CUSTOM_REFLECTION
2253
+ reflectionOut=reflectionBlock(
2254
+ fragmentInputs.vPositionW
2255
+ ,normalW
2256
+ ,alphaG
2257
+ ,uniforms.vReflectionMicrosurfaceInfos
2258
+ ,uniforms.vReflectionInfos
2259
+ ,uniforms.vReflectionColor
2260
+ #ifdef ANISOTROPIC
2261
+ ,anisotropicOut
2262
+ #endif
2263
+ #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
2264
+ ,NdotVUnclamped
2265
+ #endif
2266
+ #ifdef LINEARSPECULARREFLECTION
2267
+ ,roughness
2268
+ #endif
2269
+ ,reflectionSampler
2270
+ ,reflectionSamplerSampler
2271
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
2272
+ ,fragmentInputs.vEnvironmentIrradiance
2273
+ #endif
2274
+ #if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
2275
+ ,uniforms.reflectionMatrix
2276
+ #endif
2277
+ #ifdef USEIRRADIANCEMAP
2278
+ ,irradianceSampler
2279
+ ,irradianceSamplerSampler
2280
+ #ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
2281
+ ,uniforms.vReflectionDominantDirection
2282
+ #endif
2283
+ #endif
2284
+ #ifndef LODBASEDMICROSFURACE
2285
+ ,reflectionLowSampler
2286
+ ,reflectionLowSamplerSampler
2287
+ ,reflectionHighSampler
2288
+ ,reflectionHighSamplerSampler
2289
+ #endif
2290
+ #ifdef REALTIME_FILTERING
2291
+ ,uniforms.vReflectionFilteringInfo
2292
+ #ifdef IBL_CDF_FILTERING
2293
+ ,icdfSampler
2294
+ ,icdfSamplerSampler
2295
+ #endif
2296
+ #endif
2297
+ ,viewDirectionW
2298
+ ,diffuseRoughness
2299
+ ,surfaceAlbedo
2300
+ );
2301
+ #else
2302
+ #define CUSTOM_REFLECTION
2303
+ #endif
2304
+ #endif
2305
+ #include<pbrBlockReflectance0>
2306
+ #ifdef SHEEN
2307
+ var sheenOut: sheenOutParams;
2308
+ #ifdef SHEEN_TEXTURE
2309
+ var sheenMapData: vec4f=TEXRD(sheenSampler,sheenSamplerSampler,fragmentInputs.vSheenUV+uvOffset);
2310
+ #endif
2311
+ #if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
2312
+ var sheenMapRoughnessData: vec4f=TEXRD(sheenRoughnessSampler,sheenRoughnessSamplerSampler,fragmentInputs.vSheenRoughnessUV+uvOffset)*uniforms.vSheenInfos.w;
2313
+ #endif
2314
+ sheenOut=sheenBlock(
2315
+ uniforms.vSheenColor
2316
+ #ifdef SHEEN_ROUGHNESS
2317
+ ,uniforms.vSheenRoughness
2318
+ #if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
2319
+ ,sheenMapRoughnessData
2320
+ #endif
2321
+ #endif
2322
+ ,roughness
2323
+ #ifdef SHEEN_TEXTURE
2324
+ ,sheenMapData
2325
+ ,uniforms.vSheenInfos.y
2326
+ #endif
2327
+ ,reflectanceF0
2328
+ #ifdef SHEEN_LINKWITHALBEDO
2329
+ ,baseColor
2330
+ ,surfaceAlbedo
2331
+ #endif
2332
+ #ifdef ENVIRONMENTBRDF
2333
+ ,NdotV
2334
+ ,environmentBrdf
2335
+ #endif
2336
+ #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
2337
+ ,AARoughnessFactors
2338
+ ,uniforms.vReflectionMicrosurfaceInfos
2339
+ ,uniforms.vReflectionInfos
2340
+ ,uniforms.vReflectionColor
2341
+ ,uniforms.vLightingIntensity
2342
+ ,reflectionSampler
2343
+ ,reflectionSamplerSampler
2344
+ ,reflectionOut.reflectionCoords
2345
+ ,NdotVUnclamped
2346
+ #ifndef LODBASEDMICROSFURACE
2347
+ ,reflectionLowSampler
2348
+ ,reflectionLowSamplerSampler
2349
+ ,reflectionHighSampler
2350
+ ,reflectionHighSamplerSampler
2351
+ #endif
2352
+ #ifdef REALTIME_FILTERING
2353
+ ,uniforms.vReflectionFilteringInfo
2354
+ #endif
2355
+ #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
2356
+ ,seo
2357
+ #endif
2358
+ #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
2359
+ ,eho
2360
+ #endif
2361
+ #endif
2362
+ );
2363
+ #ifdef SHEEN_LINKWITHALBEDO
2364
+ surfaceAlbedo=sheenOut.surfaceAlbedo;
2365
+ #endif
2366
+ #endif
2367
+ #ifdef CLEARCOAT
2368
+ #ifdef CLEARCOAT_TEXTURE
2369
+ var clearCoatMapData: vec2f=TEXRD(clearCoatSampler,clearCoatSamplerSampler,fragmentInputs.vClearCoatUV+uvOffset).rg*uniforms.vClearCoatInfos.y;
2370
+ #endif
2371
+ #endif
2372
+ #ifdef IRIDESCENCE
2373
+ var iridescenceOut: iridescenceOutParams;
2374
+ #ifdef IRIDESCENCE_TEXTURE
2375
+ var iridescenceMapData: vec2f=TEXRD(iridescenceSampler,iridescenceSamplerSampler,fragmentInputs.vIridescenceUV+uvOffset).rg*uniforms.vIridescenceInfos.y;
2376
+ #endif
2377
+ #ifdef IRIDESCENCE_THICKNESS_TEXTURE
2378
+ var iridescenceThicknessMapData: vec2f=TEXRD(iridescenceThicknessSampler,iridescenceThicknessSamplerSampler,fragmentInputs.vIridescenceThicknessUV+uvOffset).rg*uniforms.vIridescenceInfos.w;
2379
+ #endif
2380
+ iridescenceOut=iridescenceBlock(
2381
+ uniforms.vIridescenceParams
2382
+ ,NdotV
2383
+ ,specularEnvironmentR0
2384
+ #ifdef IRIDESCENCE_TEXTURE
2385
+ ,iridescenceMapData
2386
+ #endif
2387
+ #ifdef IRIDESCENCE_THICKNESS_TEXTURE
2388
+ ,iridescenceThicknessMapData
2389
+ #endif
2390
+ #ifdef CLEARCOAT
2391
+ ,NdotVUnclamped
2392
+ ,uniforms.vClearCoatParams
2393
+ #ifdef CLEARCOAT_TEXTURE
2394
+ ,clearCoatMapData
2395
+ #endif
2396
+ #endif
2397
+ );var iridescenceIntensity: f32=iridescenceOut.iridescenceIntensity;specularEnvironmentR0=iridescenceOut.specularEnvironmentR0;
2398
+ #endif
2399
+ var clearcoatOut: clearcoatOutParams;
2400
+ #ifdef CLEARCOAT
2401
+ #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
2402
+ var clearCoatMapRoughnessData: vec4f=TEXRD(clearCoatRoughnessSampler,clearCoatRoughnessSamplerSampler,fragmentInputs.vClearCoatRoughnessUV+uvOffset)*uniforms.vClearCoatInfos.w;
2403
+ #endif
2404
+ #if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
2405
+ var clearCoatTintMapData: vec4f=TEXRD(clearCoatTintSampler,clearCoatTintSamplerSampler,fragmentInputs.vClearCoatTintUV+uvOffset);
2406
+ #endif
2407
+ #ifdef CLEARCOAT_BUMP
2408
+ var clearCoatBumpMapData: vec4f=TEXRD(clearCoatBumpSampler,clearCoatBumpSamplerSampler,fragmentInputs.vClearCoatBumpUV+uvOffset);
2409
+ #endif
2410
+ clearcoatOut=clearcoatBlock(
2411
+ fragmentInputs.vPositionW
2412
+ ,geometricNormalW
2413
+ ,viewDirectionW
2414
+ ,uniforms.vClearCoatParams
2415
+ #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
2416
+ ,clearCoatMapRoughnessData
2417
+ #endif
2418
+ ,specularEnvironmentR0
2419
+ #ifdef CLEARCOAT_TEXTURE
2420
+ ,clearCoatMapData
2421
+ #endif
2422
+ #ifdef CLEARCOAT_TINT
2423
+ ,uniforms.vClearCoatTintParams
2424
+ ,uniforms.clearCoatColorAtDistance
2425
+ ,uniforms.vClearCoatRefractionParams
2426
+ #ifdef CLEARCOAT_TINT_TEXTURE
2427
+ ,clearCoatTintMapData
2428
+ #endif
2429
+ #endif
2430
+ #ifdef CLEARCOAT_BUMP
2431
+ ,uniforms.vClearCoatBumpInfos
2432
+ ,clearCoatBumpMapData
2433
+ ,fragmentInputs.vClearCoatBumpUV
2434
+ #if defined(TANGENT) && defined(NORMAL)
2435
+ ,mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2)
2436
+ #else
2437
+ ,uniforms.vClearCoatTangentSpaceParams
2438
+ #endif
2439
+ #ifdef OBJECTSPACE_NORMALMAP
2440
+ ,uniforms.normalMatrix
2441
+ #endif
2442
+ #endif
2443
+ #if defined(FORCENORMALFORWARD) && defined(NORMAL)
2444
+ ,faceNormal
2445
+ #endif
2446
+ #ifdef REFLECTION
2447
+ ,uniforms.vReflectionMicrosurfaceInfos
2448
+ ,uniforms.vReflectionInfos
2449
+ ,uniforms.vReflectionColor
2450
+ ,uniforms.vLightingIntensity
2451
+ ,reflectionSampler
2452
+ ,reflectionSamplerSampler
2453
+ #ifndef LODBASEDMICROSFURACE
2454
+ ,reflectionLowSampler
2455
+ ,reflectionLowSamplerSampler
2456
+ ,reflectionHighSampler
2457
+ ,reflectionHighSamplerSampler
2458
+ #endif
2459
+ #ifdef REALTIME_FILTERING
2460
+ ,uniforms.vReflectionFilteringInfo
2461
+ #endif
2462
+ #endif
2463
+ #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
2464
+ ,select(-1.,1.,fragmentInputs.frontFacing)
2465
+ #endif
2466
+ );
2467
+ #else
2468
+ clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
2469
+ #endif
2470
+ #include<pbrBlockReflectance>
2471
+ var subSurfaceOut: subSurfaceOutParams;
2472
+ #ifdef SUBSURFACE
2473
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
2474
+ var thicknessMap: vec4f=TEXRD(thicknessSampler,thicknessSamplerSampler,fragmentInputs.vThicknessUV+uvOffset);
2475
+ #endif
2476
+ #ifdef SS_REFRACTIONINTENSITY_TEXTURE
2477
+ var refractionIntensityMap: vec4f=TEXRD(refractionIntensitySampler,refractionIntensitySamplerSampler,fragmentInputs.vRefractionIntensityUV+uvOffset);
2478
+ #endif
2479
+ #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
2480
+ var translucencyIntensityMap: vec4f=TEXRD(translucencyIntensitySampler,translucencyIntensitySamplerSampler,fragmentInputs.vTranslucencyIntensityUV+uvOffset);
2481
+ #endif
2482
+ #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
2483
+ var translucencyColorMap: vec4f=TEXRD(translucencyColorSampler,translucencyColorSamplerSampler,fragmentInputs.vTranslucencyColorUV+uvOffset);
2484
+ #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA
2485
+ translucencyColorMap=toLinearSpaceVec4(translucencyColorMap);
2486
+ #endif
2487
+ #endif
2488
+ subSurfaceOut=subSurfaceBlock(
2489
+ uniforms.vSubSurfaceIntensity
2490
+ ,uniforms.vThicknessParam
2491
+ ,uniforms.vTintColor
2492
+ ,normalW
2493
+ #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
2494
+ ,vec3f(max(colorSpecularEnvironmentReflectance.r,max(colorSpecularEnvironmentReflectance.g,colorSpecularEnvironmentReflectance.b)))
2495
+ #else
2496
+ ,baseSpecularEnvironmentReflectance
2497
+ #endif
2498
+ #ifdef SS_THICKNESSANDMASK_TEXTURE
2499
+ ,thicknessMap
2500
+ #endif
2501
+ #ifdef SS_REFRACTIONINTENSITY_TEXTURE
2502
+ ,refractionIntensityMap
2503
+ #endif
2504
+ #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
2505
+ ,translucencyIntensityMap
2506
+ #endif
2507
+ #ifdef REFLECTION
2508
+ #ifdef SS_TRANSLUCENCY
2509
+ ,uniforms.reflectionMatrix
2510
+ #ifdef USESPHERICALFROMREFLECTIONMAP
2511
+ #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
2512
+ ,reflectionOut.irradianceVector
2513
+ #endif
2514
+ #if defined(REALTIME_FILTERING)
2515
+ ,reflectionSampler
2516
+ ,reflectionSamplerSampler
2517
+ ,uniforms.vReflectionFilteringInfo
2518
+ #ifdef IBL_CDF_FILTERING
2519
+ ,icdfSampler
2520
+ ,icdfSamplerSampler
2521
+ #endif
2522
+ #endif
2523
+ #endif
2524
+ #ifdef USEIRRADIANCEMAP
2525
+ ,irradianceSampler
2526
+ ,irradianceSamplerSampler
2527
+ #endif
2528
+ #endif
2529
+ #endif
2530
+ #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
2531
+ ,surfaceAlbedo
2532
+ #endif
2533
+ #ifdef SS_REFRACTION
2534
+ ,fragmentInputs.vPositionW
2535
+ ,viewDirectionW
2536
+ ,scene.view
2537
+ ,uniforms.vRefractionInfos
2538
+ ,uniforms.refractionMatrix
2539
+ ,uniforms.vRefractionMicrosurfaceInfos
2540
+ ,uniforms.vLightingIntensity
2541
+ #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
2542
+ ,alpha
2543
+ #endif
2544
+ #ifdef SS_LODINREFRACTIONALPHA
2545
+ ,NdotVUnclamped
2546
+ #endif
2547
+ #ifdef SS_LINEARSPECULARREFRACTION
2548
+ ,roughness
2549
+ #endif
2550
+ ,alphaG
2551
+ ,refractionSampler
2552
+ ,refractionSamplerSampler
2553
+ #ifndef LODBASEDMICROSFURACE
2554
+ ,refractionLowSampler
2555
+ ,refractionLowSamplerSampler
2556
+ ,refractionHighSampler
2557
+ ,refractionHighSamplerSampler
2558
+ #endif
2559
+ #ifdef ANISOTROPIC
2560
+ ,anisotropicOut
2561
+ #endif
2562
+ #ifdef REALTIME_FILTERING
2563
+ ,uniforms.vRefractionFilteringInfo
2564
+ #endif
2565
+ #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
2566
+ ,uniforms.vRefractionPosition
2567
+ ,uniforms.vRefractionSize
2568
+ #endif
2569
+ #ifdef SS_DISPERSION
2570
+ ,uniforms.dispersion
2571
+ #endif
2572
+ #endif
2573
+ #ifdef SS_TRANSLUCENCY
2574
+ ,uniforms.vDiffusionDistance
2575
+ ,uniforms.vTranslucencyColor
2576
+ #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
2577
+ ,translucencyColorMap
2578
+ #endif
2579
+ #endif
2580
+ );
2581
+ #ifdef SS_REFRACTION
2582
+ surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
2583
+ #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
2584
+ alpha=subSurfaceOut.alpha;
2585
+ #endif
2586
+ #endif
2587
+ #else
2588
+ subSurfaceOut.specularEnvironmentReflectance=colorSpecularEnvironmentReflectance;
2589
+ #endif
2590
+ #include<pbrBlockDirectLighting>
2591
+ #include<lightFragment>[0..maxSimultaneousLights]
2592
+ #include<pbrBlockFinalLitComponents>
2593
+ #endif
2594
+ #include<pbrBlockFinalUnlitComponents>
2595
+ #define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
2596
+ #include<pbrBlockFinalColorComposition>
2597
+ #include<logDepthFragment>
2598
+ #include<fogFragment>(color,finalColor)
2599
+ #include<pbrBlockImageProcessing>
2600
+ #define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
2601
+ #ifdef PREPASS
2602
+ #include<pbrBlockPrePass>
2603
+ #endif
2604
+ #if !defined(PREPASS) && !defined(ORDER_INDEPENDENT_TRANSPARENCY)
2605
+ fragmentOutputs.color=finalColor;
2606
+ #endif
2607
+ #include<oitFragment>
2608
+ #if ORDER_INDEPENDENT_TRANSPARENCY
2609
+ if (fragDepth==nearestDepth) {fragmentOutputs.frontColor=vec4f(fragmentOutputs.frontColor.rgb+finalColor.rgb*finalColor.a*alphaMultiplier,1.0-alphaMultiplier*(1.0-finalColor.a));} else {fragmentOutputs.backColor+=finalColor;}
2610
+ #endif
2611
+ #include<pbrDebug>
2612
+ #define CUSTOM_FRAGMENT_MAIN_END
2613
+ }
2614
+ `;
2615
+ e.ShadersStoreWGSL[a] || (e.ShadersStoreWGSL[a] = O);
2616
+ const re = { name: a, shader: O };
2617
+ export {
2618
+ re as pbrPixelShaderWGSL
2619
+ };