@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,1405 @@
1
+ import { b0 as e } from "./index-CS3Icp_r.js";
2
+ import "./oitFragment-DH3h3T6x.js";
3
+ import "./openpbrUboDeclaration-CA2pvSbt.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 "./openpbrTransmissionLayerData-CfDVObj5.js";
12
+ const t = "openpbrFragmentSamplersDeclaration", I = `#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_SAMPLERNAME_,baseColor)
13
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight)
14
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness)
15
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness,_SAMPLERNAME_,baseMetalness)
16
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight,_SAMPLERNAME_,specularWeight)
17
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor,_SAMPLERNAME_,specularColor)
18
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness,_SAMPLERNAME_,specularRoughness)
19
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy,_SAMPLERNAME_,specularRoughnessAnisotropy)
20
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_SAMPLERNAME_,transmissionWeight)
21
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_COLOR,_VARYINGNAME_,TransmissionColor,_SAMPLERNAME_,transmissionColor)
22
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_DEPTH,_VARYINGNAME_,TransmissionDepth,_SAMPLERNAME_,transmissionDepth)
23
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_SCATTER,_VARYINGNAME_,TransmissionScatter,_SAMPLERNAME_,transmissionScatter)
24
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_DISPERSION_SCALE,_VARYINGNAME_,TransmissionDispersionScale,_SAMPLERNAME_,transmissionDispersionScale)
25
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_SAMPLERNAME_,subsurfaceWeight)
26
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_COLOR,_VARYINGNAME_,SubsurfaceColor,_SAMPLERNAME_,subsurfaceColor)
27
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_RADIUS_SCALE,_VARYINGNAME_,SubsurfaceRadiusScale,_SAMPLERNAME_,subsurfaceRadiusScale)
28
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight,_SAMPLERNAME_,coatWeight)
29
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_COLOR,_VARYINGNAME_,CoatColor,_SAMPLERNAME_,coatColor)
30
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness,_SAMPLERNAME_,coatRoughness)
31
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy,_SAMPLERNAME_,coatRoughnessAnisotropy)
32
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening,_SAMPLERNAME_,coatDarkening)
33
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,FUZZ_WEIGHT,_VARYINGNAME_,FuzzWeight,_SAMPLERNAME_,fuzzWeight)
34
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,FUZZ_COLOR,_VARYINGNAME_,FuzzColor,_SAMPLERNAME_,fuzzColor)
35
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,FUZZ_ROUGHNESS,_VARYINGNAME_,FuzzRoughness,_SAMPLERNAME_,fuzzRoughness)
36
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity,_SAMPLERNAME_,geometryOpacity)
37
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent,_SAMPLERNAME_,geometryTangent)
38
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_COAT_TANGENT,_VARYINGNAME_,GeometryCoatTangent,_SAMPLERNAME_,geometryCoatTangent)
39
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_THICKNESS,_VARYINGNAME_,GeometryThickness,_SAMPLERNAME_,geometryThickness)
40
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor,_SAMPLERNAME_,emissionColor)
41
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,THIN_FILM_WEIGHT,_VARYINGNAME_,ThinFilmWeight,_SAMPLERNAME_,thinFilmWeight)
42
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,THIN_FILM_THICKNESS,_VARYINGNAME_,ThinFilmThickness,_SAMPLERNAME_,thinFilmThickness)
43
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_SAMPLERNAME_,ambientOcclusion)
44
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
45
+ #include<pbrFragmentReflectionDeclaration>
46
+ #ifdef ENVIRONMENTBRDF
47
+ var environmentBrdfSamplerSampler: sampler;var environmentBrdfSampler: texture_2d<f32>;
48
+ #endif
49
+ #ifdef FUZZENVIRONMENTBRDF
50
+ var environmentFuzzBrdfSamplerSampler: sampler;var environmentFuzzBrdfSampler: texture_2d<f32>;
51
+ #endif
52
+ #ifdef REFRACTED_BACKGROUND
53
+ var backgroundRefractionSamplerSampler: sampler;var backgroundRefractionSampler: texture_2d<f32>;
54
+ #endif
55
+ #ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING
56
+ var sceneIrradianceSampler: texture_2d<f32>;var sceneDepthSampler: texture_2d<f32>;
57
+ #endif
58
+ #if defined(ANISOTROPIC) || defined(FUZZ) || defined(REFRACTED_BACKGROUND) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING)
59
+ var blueNoiseSamplerSampler: sampler;var blueNoiseSampler: texture_2d<f32>;
60
+ #endif
61
+ #ifdef IBL_CDF_FILTERING
62
+ var icdfSamplerSampler: sampler;var icdfSampler: texture_2d<f32>;
63
+ #endif
64
+ `;
65
+ e.IncludesShadersStoreWGSL[t] || (e.IncludesShadersStoreWGSL[t] = I);
66
+ const a = "openpbrNormalMapFragmentMainFunctions", R = `#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(ANISOTROPIC) || defined(FUZZ) || defined(DETAIL)
67
+ #if defined(TANGENT) && defined(NORMAL)
68
+ varying vTBN0: vec3f;varying vTBN1: vec3f;varying vTBN2: vec3f;
69
+ #endif
70
+ #ifdef OBJECTSPACE_NORMALMAP
71
+ uniform normalMatrix: mat4x4f;fn toNormalMatrix(m: mat4x4f)->mat4x4f
72
+ {var a00=m[0][0];var a01=m[0][1];var a02=m[0][2];var a03=m[0][3];var a10=m[1][0];var a11=m[1][1];var a12=m[1][2];var a13=m[1][3];var a20=m[2][0];
73
+ var a21=m[2][1];var a22=m[2][2];var a23=m[2][3];var a30=m[3][0];
74
+ var a31=m[3][1];var a32=m[3][2];var a33=m[3][3];var b00=a00*a11-a01*a10;var b01=a00*a12-a02*a10;var b02=a00*a13-a03*a10;var b03=a01*a12-a02*a11;var b04=a01*a13-a03*a11;var b05=a02*a13-a03*a12;var b06=a20*a31-a21*a30;var b07=a20*a32-a22*a30;var b08=a20*a33-a23*a30;var b09=a21*a32-a22*a31;var b10=a21*a33-a23*a31;var b11=a22*a33-a23*a32;var det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;var mi=mat4x4<f32>(
75
+ (a11*b11-a12*b10+a13*b09)/det,
76
+ (a02*b10-a01*b11-a03*b09)/det,
77
+ (a31*b05-a32*b04+a33*b03)/det,
78
+ (a22*b04-a21*b05-a23*b03)/det,
79
+ (a12*b08-a10*b11-a13*b07)/det,
80
+ (a00*b11-a02*b08+a03*b07)/det,
81
+ (a32*b02-a30*b05-a33*b01)/det,
82
+ (a20*b05-a22*b02+a23*b01)/det,
83
+ (a10*b10-a11*b08+a13*b06)/det,
84
+ (a01*b08-a00*b10-a03*b06)/det,
85
+ (a30*b04-a31*b02+a33*b00)/det,
86
+ (a21*b02-a20*b04-a23*b00)/det,
87
+ (a11*b07-a10*b09-a12*b06)/det,
88
+ (a00*b09-a01*b07+a02*b06)/det,
89
+ (a31*b01-a30*b03-a32*b00)/det,
90
+ (a20*b03-a21*b01+a22*b00)/det);return mat4x4<f32>(mi[0][0],mi[1][0],mi[2][0],mi[3][0],
91
+ mi[0][1],mi[1][1],mi[2][1],mi[3][1],
92
+ mi[0][2],mi[1][2],mi[2][2],mi[3][2],
93
+ mi[0][3],mi[1][3],mi[2][3],mi[3][3]);}
94
+ #endif
95
+ fn perturbNormalBase(cotangentFrame: mat3x3f,normal: vec3f,scale: f32)->vec3f
96
+ {var output=normal;
97
+ #ifdef NORMALXYSCALE
98
+ output=normalize(output* vec3f(scale,scale,1.0));
99
+ #endif
100
+ return normalize(cotangentFrame*output);}
101
+ fn perturbNormal(cotangentFrame: mat3x3f,textureSample: vec3f,scale: f32)->vec3f
102
+ {return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);}
103
+ fn cotangent_frame(normal: vec3f,p: vec3f,uv: vec2f,tangentSpaceParams: vec2f)->mat3x3f
104
+ {var dp1: vec3f=dpdx(p);var dp2: vec3f=dpdy(p);var duv1: vec2f=dpdx(uv);var duv2: vec2f=dpdy(uv);var dp2perp: vec3f=cross(dp2,normal);var dp1perp: vec3f=cross(normal,dp1);var tangent: vec3f=dp2perp*duv1.x+dp1perp*duv2.x;var bitangent: vec3f=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;var det: f32=max(dot(tangent,tangent),dot(bitangent,bitangent));var invmax: f32=select(inverseSqrt(det),0.0,det==0.0);return mat3x3f(tangent*invmax,bitangent*invmax,normal);}
105
+ #endif
106
+ `;
107
+ e.IncludesShadersStoreWGSL[a] || (e.IncludesShadersStoreWGSL[a] = R);
108
+ const i = "openpbrNormalMapFragmentFunctions", T = `#if defined(GEOMETRY_NORMAL)
109
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_NORMAL,_VARYINGNAME_,GeometryNormal,_SAMPLERNAME_,geometryNormal)
110
+ #endif
111
+ #if defined(GEOMETRY_COAT_NORMAL)
112
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_COAT_NORMAL,_VARYINGNAME_,GeometryCoatNormal,_SAMPLERNAME_,geometryCoatNormal)
113
+ #endif
114
+ #if defined(DETAIL)
115
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
116
+ #endif
117
+ #if defined(GEOMETRY_NORMAL) && defined(PARALLAX)
118
+ const minSamples: f32=4.;const maxSamples: f32=15.;const iMaxSamples: i32=15;fn parallaxOcclusion(vViewDirCoT: vec3f,vNormalCoT: vec3f,texCoord: vec2f,parallaxScale: f32)->vec2f {var parallaxLimit: f32=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;var vOffsetDir: vec2f=normalize(vViewDirCoT.xy);var vMaxOffset: vec2f=vOffsetDir*parallaxLimit;var numSamples: f32=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));var stepSize: f32=1.0/numSamples;var currRayHeight: f32=1.0;var vCurrOffset: vec2f= vec2f(0,0);var vLastOffset: vec2f= vec2f(0,0);var lastSampledHeight: f32=1.0;var currSampledHeight: f32=1.0;var keepWorking: bool=true;for (var i: i32=0; i<iMaxSamples; i++)
119
+ {currSampledHeight=textureSample(geometryNormalSampler,geometryNormalSamplerSampler,texCoord+vCurrOffset).w;if (!keepWorking)
120
+ {}
121
+ else if (currSampledHeight>currRayHeight)
122
+ {var delta1: f32=currSampledHeight-currRayHeight;var delta2: f32=(currRayHeight+stepSize)-lastSampledHeight;var ratio: f32=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;}
123
+ else
124
+ {currRayHeight-=stepSize;vLastOffset=vCurrOffset;
125
+ #ifdef PARALLAX_RHS
126
+ vCurrOffset-=stepSize*vMaxOffset;
127
+ #else
128
+ vCurrOffset+=stepSize*vMaxOffset;
129
+ #endif
130
+ lastSampledHeight=currSampledHeight;}}
131
+ return vCurrOffset;}
132
+ fn parallaxOffset(viewDir: vec3f,heightScale: f32)->vec2f
133
+ {var height: f32=textureSample(geometryNormalSampler,geometryNormalSamplerSampler,fragmentInputs.vGeometryNormalUV).w;var texCoordOffset: vec2f=heightScale*viewDir.xy*height;
134
+ #ifdef PARALLAX_RHS
135
+ return texCoordOffset;
136
+ #else
137
+ return -texCoordOffset;
138
+ #endif
139
+ }
140
+ #endif
141
+ `;
142
+ e.IncludesShadersStoreWGSL[i] || (e.IncludesShadersStoreWGSL[i] = T);
143
+ const o = "openpbrConductorReflectance", N = `#define pbr_inline
144
+ fn conductorReflectance(baseColor: vec3f,specularColor: vec3f,specularWeight: f32)->ReflectanceParams
145
+ {var outParams: ReflectanceParams;
146
+ #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
147
+ outParams.coloredF0=baseColor*specularWeight;outParams.coloredF90=specularColor*specularWeight;
148
+ #else
149
+ outParams.coloredF0=baseColor;outParams.coloredF90=vec3f(1.0f);
150
+ #endif
151
+ outParams.F0=1.0f;outParams.F90=1.0f;return outParams;}`;
152
+ e.IncludesShadersStoreWGSL[o] || (e.IncludesShadersStoreWGSL[o] = N);
153
+ const n = "openpbrAmbientOcclusionFunctions", A = `fn compute_specular_occlusion(n_dot_v: f32,metallic: f32,ambient_occlusion: f32,roughness: f32)->f32
154
+ {let specular_occlusion: f32=saturate(pow(n_dot_v+ambient_occlusion,exp2(-16.0*roughness-1.0))-1.0+ambient_occlusion);return mix(specular_occlusion,1.0,metallic*square(1.0-roughness));}
155
+ `;
156
+ e.IncludesShadersStoreWGSL[n] || (e.IncludesShadersStoreWGSL[n] = A);
157
+ const f = "openpbrVolumeFunctions", b = `struct OpenPBRHomogeneousVolume {extinction_coeff: vec3f,
158
+ ss_albedo: vec3f,
159
+ multi_scatter_color: vec3f,
160
+ absorption_coeff: vec3f,
161
+ scatter_coeff: vec3f,
162
+ anisotropy: f32, };fn computeOpenPBRTransmissionVolume(
163
+ transmission_color: vec3f,
164
+ transmission_depth: f32,
165
+ transmission_scatter: vec3f,
166
+ anisotropy: f32
167
+ )->OpenPBRHomogeneousVolume
168
+ {var volumeParams: OpenPBRHomogeneousVolume;volumeParams.absorption_coeff=vec3f(0.0f);volumeParams.scatter_coeff=vec3f(0.0f);volumeParams.anisotropy=anisotropy;
169
+ #ifdef GEOMETRY_THIN_WALLED
170
+ volumeParams.scatter_coeff=vec3f(1.0f);volumeParams.anisotropy=1.0f;
171
+ volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=vec3f(1.0f);
172
+ #else
173
+ if (transmission_depth>0.0f) {let invDepth: vec3f=vec3f(1.f/maxEps(transmission_depth));volumeParams.extinction_coeff=-log(maxEpsVec3(transmission_color.rgb))*invDepth;volumeParams.scatter_coeff=transmission_scatter.rgb*invDepth;volumeParams.absorption_coeff=volumeParams.extinction_coeff-volumeParams.scatter_coeff.rgb;let minCoeff: f32=min3(volumeParams.absorption_coeff);if (minCoeff<0.0f) {volumeParams.absorption_coeff-=vec3f(minCoeff);}
174
+ volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=volumeParams.scatter_coeff/(volumeParams.extinction_coeff);} else {volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=vec3f(0.0f);}
175
+ #endif
176
+ return volumeParams;}
177
+ fn computeOpenPBRSubsurfaceVolume(
178
+ subsurface_color: vec3f,
179
+ subsurface_radius: f32,
180
+ subsurface_radius_scale: vec3f,
181
+ anisotropy: f32
182
+ )->OpenPBRHomogeneousVolume
183
+ {var volumeParams: OpenPBRHomogeneousVolume;volumeParams.absorption_coeff=vec3f(0.0f);volumeParams.scatter_coeff=vec3f(0.0f);volumeParams.anisotropy=anisotropy;volumeParams.multi_scatter_color=subsurface_color;let mfp: vec3f=subsurface_radius_scale*vec3f(subsurface_radius);volumeParams.extinction_coeff=vec3f(1.0f)/maxEpsVec3(mfp);volumeParams.ss_albedo=multiScatterToSingleScatterAlbedoWithAniso(subsurface_color,anisotropy);volumeParams.scatter_coeff=volumeParams.ss_albedo*volumeParams.extinction_coeff;volumeParams.absorption_coeff=volumeParams.extinction_coeff-volumeParams.scatter_coeff.rgb;let minCoeff: f32=min3(volumeParams.absorption_coeff);if (minCoeff<0.0f) {volumeParams.absorption_coeff-=vec3f(minCoeff);}
184
+ volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;return volumeParams;}
185
+ fn sss_pdf(r: f32,d: vec3f)->vec3f
186
+ {let d_clamped=max(vec3f(1e-4f),d);return (exp(-r/d_clamped)+exp(-r/(3.0f*d_clamped)))/max(vec3f(1e-5f),8.0f*PI*d_clamped*r);}
187
+ fn sss_samples_pdf(r: f32,d: f32)->f32
188
+ {let d_clamped=max(1e-4f,d);return exp(-r/(3.0f*d_clamped))/(6.0f*PI*d_clamped*r);}
189
+ fn sss_samples_icdf(x: f32,d: f32)->f32
190
+ {let d_clamped=max(1e-4f,d);let x_clamped=max(1e-4f,x);return -3.0f*log(x_clamped)*d_clamped;}
191
+ fn samples_scale(x: f32,d: f32)->f32
192
+ {return 1.0f-exp(-x/(3.0f*d));}
193
+ fn sss_get_position(depth_texture: texture_2d<f32>,tex_coord: vec2f,render_resolution: vec2f,inv_proj: mat4x4f)->vec3f
194
+ {var P: vec4f=vec4f(tex_coord,textureLoad(depth_texture,vec2i(tex_coord*render_resolution),0).x,1.0f);P.x=2.0f*P.x-1.0f;P.y=2.0f*P.y-1.0f;P=inv_proj*P;return P.xyz/P.w;}
195
+ fn sss_filter_scale(currZ: f32,proj: mat4x4f)->f32
196
+ {return 1.0f/dot(vec2f(proj[2].w,proj[3].w),vec2f(currZ,1.0f));}
197
+ fn projective_to_pixels(proj_dist: f32,proj: mat4x4f,resolution: vec2f)->f32
198
+ {return proj_dist*proj[1][1]*resolution.y;}
199
+ fn pixels_to_projective(pixel_dist: f32,proj: mat4x4f,resolution: vec2f)->f32
200
+ {return pixel_dist/(proj[1][1]*resolution.y);}
201
+ fn sss_convolve(sss_irradiance_texture: texture_2d<f32>,depth_texture: texture_2d<f32>,render_resolution: vec2f,d: vec3f,proj: mat4x4f,inv_proj: mat4x4f,sample_count: i32,noise: vec2f)->vec3f
202
+ {let tex_coord: vec2f=fragmentInputs.position.xy/render_resolution;let unconvolved_irradiance: vec3f=textureLoad(sss_irradiance_texture,vec2i(fragmentInputs.position.xy),0).rgb;let curr_pos: vec3f=sss_get_position(depth_texture,tex_coord,render_resolution,inv_proj);var dmax: f32=max3(d);let max_dmax: f32=0.1*f32(sample_count);var d_adjusted=d;if (dmax>max_dmax)
203
+ {d_adjusted*=max_dmax/dmax;dmax=max_dmax;}
204
+ var dz: f32=dmax*sss_filter_scale(curr_pos.z,proj);let projMat2d: mat2x2f=mat2x2f(proj[0].xy,proj[1].xy);if (determinant(projMat2d)*dz<1e-4f) {return unconvolved_irradiance;}
205
+ let overscan_size_in_pixels: f32=max(render_resolution.x,render_resolution.y)*0.1;let filter_crop_ratio: f32=0.8f;
206
+ let crop_radius: f32=projective_to_pixels(sss_samples_icdf(1.0f-filter_crop_ratio,dz),proj,render_resolution);if (crop_radius>overscan_size_in_pixels)
207
+ {d_adjusted*=overscan_size_in_pixels/crop_radius;dz*=overscan_size_in_pixels/crop_radius;}
208
+ let filter_samples_scale: f32=samples_scale(pixels_to_projective(overscan_size_in_pixels,proj,render_resolution),dz);var irradiance_sum: vec3f=vec3f(0.0f);var weight_sum: vec3f=vec3f(0.0f);for (var i: i32=0; i<sample_count; i++)
209
+ {var r: vec2f=fract(plasticSequence(u32(i))+noise);r.x*=TWO_PI;r.y*=filter_samples_scale;let icdf: f32=sss_samples_icdf(1.0-r.y,dz);let sample_uv: vec2f=tex_coord+icdf*projMat2d*vec2f(cos(r.x),sin(r.x));let sss_irradiance: vec4f=textureLoad(sss_irradiance_texture,vec2i(sample_uv*render_resolution),0);let dist: f32=distance(curr_pos,sss_get_position(depth_texture,sample_uv,render_resolution,inv_proj));if (dist>0.0f)
210
+ {let weights: vec3f=sss_irradiance.a/sss_samples_pdf(icdf,dz)*sss_pdf(dist,d_adjusted);irradiance_sum+=weights*sss_irradiance.rgb;weight_sum+=weights;}}
211
+ return vec3f(select(unconvolved_irradiance.r,irradiance_sum.r/weight_sum.r,weight_sum.r>=1e-5f),
212
+ select(unconvolved_irradiance.g,irradiance_sum.g/weight_sum.g,weight_sum.g>=1e-5f),
213
+ select(unconvolved_irradiance.b,irradiance_sum.b/weight_sum.b,weight_sum.b>=1e-5f));}
214
+ `;
215
+ e.IncludesShadersStoreWGSL[f] || (e.IncludesShadersStoreWGSL[f] = b);
216
+ const s = "openpbrNormalMapFragment", L = `var uvOffset: vec2f= vec2f(0.0,0.0);
217
+ #if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(PARALLAX) || defined(DETAIL)
218
+ #ifdef NORMALXYSCALE
219
+ var normalScale: f32=1.0;
220
+ #elif defined(GEOMETRY_NORMAL)
221
+ var normalScale: f32=uniforms.vGeometryNormalInfos.y;
222
+ #else
223
+ var normalScale: f32=1.0;
224
+ #endif
225
+ #if defined(TANGENT) && defined(NORMAL)
226
+ var TBN: mat3x3f=mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2);
227
+ #elif defined(GEOMETRY_NORMAL)
228
+ var TBNUV: vec2f=select(-fragmentInputs.vGeometryNormalUV,fragmentInputs.vGeometryNormalUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV,uniforms.vTangentSpaceParams);
229
+ #elif defined(GEOMETRY_COAT_NORMAL)
230
+ var TBNUV: vec2f=select(-fragmentInputs.vGeometryCoatNormalUV,fragmentInputs.vGeometryCoatNormalUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV,uniforms.vTangentSpaceParams);
231
+ #else
232
+ var TBNUV: vec2f=select(-fragmentInputs.vDetailUV,fragmentInputs.vDetailUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV, vec2f(1.,1.));
233
+ #endif
234
+ #elif defined(ANISOTROPIC) || defined(FUZZ)
235
+ #if defined(TANGENT) && defined(NORMAL)
236
+ var TBN: mat3x3f=mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2);
237
+ #else
238
+ var TBNUV: vec2f=select( -fragmentInputs.vMainUV1,fragmentInputs.vMainUV1,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW,input.vPositionW,TBNUV, vec2f(1.,1.));
239
+ #endif
240
+ #endif
241
+ #ifdef PARALLAX
242
+ var invTBN: mat3x3f=transposeMat3(TBN);
243
+ #ifdef PARALLAXOCCLUSION
244
+ #else
245
+ #endif
246
+ #endif
247
+ #ifdef DETAIL
248
+ var detailColor: vec4f=textureSample(detailSampler,detailSamplerSampler,fragmentInputs.vDetailUV+uvOffset);var detailNormalRG: vec2f=detailColor.wy*2.0-1.0;var detailNormalB: f32=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));var detailNormal: vec3f= vec3f(detailNormalRG,detailNormalB);
249
+ #endif
250
+ #ifdef GEOMETRY_COAT_NORMAL
251
+ coatNormalW=perturbNormal(TBN,TEXRD(geometryCoatNormalSampler,geometryCoatNormalSamplerSampler,fragmentInputs.vGeometryCoatNormalUV+uvOffset).xyz,uniforms.vGeometryCoatNormalInfos.y);
252
+ #endif
253
+ #ifdef GEOMETRY_NORMAL
254
+ #ifdef OBJECTSPACE_NORMALMAP
255
+ #define CUSTOM_FRAGMENT_BUMP_FRAGMENT
256
+ normalW=normalize(TEXRD(geometryNormalSampler,geometryNormalSamplerSampler,fragmentInputs.vGeometryNormalUV).xyz *2.0-1.0);normalW=normalize(mat3x3f(uniforms.normalMatrix[0].xyz,uniforms.normalMatrix[1].xyz,uniforms.normalMatrix[2].xyz)*normalW);
257
+ #elif !defined(DETAIL)
258
+ normalW=perturbNormal(TBN,TEXRD(geometryNormalSampler,geometryNormalSamplerSampler,fragmentInputs.vGeometryNormalUV+uvOffset).xyz,uniforms.vGeometryNormalInfos.y);
259
+ #else
260
+ var sampledNormal: vec3f=TEXRD(geometryNormalSampler,geometryNormalSamplerSampler,fragmentInputs.vGeometryNormalUV+uvOffset).xyz*2.0-1.0;
261
+ #if DETAIL_NORMALBLENDMETHOD==0
262
+ detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);var blendedNormal: vec3f=normalize( vec3f(sampledNormal.xy+detailNormal.xy,sampledNormal.z*detailNormal.z));
263
+ #elif DETAIL_NORMALBLENDMETHOD==1
264
+ detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);sampledNormal+= vec3f(0.0,0.0,1.0);detailNormal*= vec3f(-1.0,-1.0,1.0);var blendedNormal: vec3f=sampledNormal*dot(sampledNormal,detailNormal)/sampledNormal.z-detailNormal;
265
+ #endif
266
+ normalW=perturbNormalBase(TBN,blendedNormal,uniforms.vGeometryNormalInfos.y);
267
+ #endif
268
+ #elif defined(DETAIL)
269
+ detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);normalW=perturbNormalBase(TBN,detailNormal,uniforms.vDetailInfos.z);
270
+ #endif
271
+ `;
272
+ e.IncludesShadersStoreWGSL[s] || (e.IncludesShadersStoreWGSL[s] = L);
273
+ const l = "openpbrBlockNormalFinal", F = `#if defined(FORCENORMALFORWARD) && defined(NORMAL)
274
+ var faceNormal: vec3f=normalize(cross(dpdx(fragmentInputs.vPositionW),dpdy(fragmentInputs.vPositionW)))*scene.vEyePosition.w;
275
+ #if defined(TWOSIDEDLIGHTING)
276
+ faceNormal=select(-faceNormal,faceNormal,fragmentInputs.frontFacing);
277
+ #endif
278
+ normalW*=sign(dot(normalW,faceNormal));coatNormalW*=sign(dot(coatNormalW,faceNormal));
279
+ #endif
280
+ #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
281
+ #if defined(MIRRORED)
282
+ normalW=select(normalW,-normalW,fragmentInputs.frontFacing);coatNormalW=select(coatNormalW,-coatNormalW,fragmentInputs.frontFacing);
283
+ #else
284
+ normalW=select(-normalW,normalW,fragmentInputs.frontFacing);coatNormalW=select(-coatNormalW,coatNormalW,fragmentInputs.frontFacing);
285
+ #endif
286
+ #endif
287
+ `;
288
+ e.IncludesShadersStoreWGSL[l] || (e.IncludesShadersStoreWGSL[l] = F);
289
+ const c = "openpbrBaseLayerData", O = `var base_color=vec3f(0.8);var base_metalness: f32=0.0;var base_diffuse_roughness: f32=0.0;var specular_weight: f32=1.0;var specular_roughness: f32=0.3;var specular_color: vec3f=vec3f(1.0);var specular_roughness_anisotropy: f32=0.0;var specular_ior: f32=1.5;var alpha: f32=1.0;var geometry_tangent: vec2f=vec2f(1.0,0.0);var geometry_thickness: f32=0.0;
290
+ #ifdef BASE_WEIGHT
291
+ let baseWeightFromTexture: vec4f=TEXRD(baseWeightSampler,baseWeightSamplerSampler,fragmentInputs.vBaseWeightUV+uvOffset);
292
+ #endif
293
+ #ifdef BASE_COLOR
294
+ let baseColorFromTexture: vec4f=TEXRD(baseColorSampler,baseColorSamplerSampler,fragmentInputs.vBaseColorUV+uvOffset);
295
+ #endif
296
+ #ifdef BASE_METALNESS
297
+ let metallicFromTexture: vec4f=TEXRD(baseMetalnessSampler,baseMetalnessSamplerSampler,fragmentInputs.vBaseMetalnessUV+uvOffset);
298
+ #endif
299
+ #ifdef BASE_DIFFUSE_ROUGHNESS
300
+ let baseDiffuseRoughnessFromTexture: f32=TEXRD(baseDiffuseRoughnessSampler,baseDiffuseRoughnessSamplerSampler,fragmentInputs.vBaseDiffuseRoughnessUV+uvOffset).r;
301
+ #endif
302
+ #ifdef GEOMETRY_TANGENT
303
+ let geometryTangentFromTexture: vec3f=TEXRD(geometryTangentSampler,geometryTangentSamplerSampler,fragmentInputs.vGeometryTangentUV+uvOffset).rgb;
304
+ #endif
305
+ #ifdef SPECULAR_ROUGHNESS_ANISOTROPY
306
+ let anisotropyFromTexture: f32=TEXRD(specularRoughnessAnisotropySampler,specularRoughnessAnisotropySamplerSampler,fragmentInputs.vSpecularRoughnessAnisotropyUV+uvOffset).r*uniforms.vSpecularRoughnessAnisotropyInfos.y;
307
+ #endif
308
+ #ifdef GEOMETRY_OPACITY
309
+ let opacityFromTexture: vec4f=TEXRD(geometryOpacitySampler,geometryOpacitySamplerSampler,fragmentInputs.vGeometryOpacityUV+uvOffset);
310
+ #endif
311
+ #ifdef GEOMETRY_THICKNESS
312
+ let thicknessFromTexture: vec4f=TEXRD(geometryThicknessSampler,geometryThicknessSamplerSampler,fragmentInputs.vGeometryThicknessUV+uvOffset);
313
+ #endif
314
+ #ifdef DECAL
315
+ let decalFromTexture: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset);
316
+ #endif
317
+ #ifdef SPECULAR_COLOR
318
+ let specularColorFromTexture: vec4f=TEXRD(specularColorSampler,specularColorSamplerSampler,fragmentInputs.vSpecularColorUV+uvOffset);
319
+ #endif
320
+ #if defined(SPECULAR_WEIGHT)
321
+ #ifdef SPECULAR_WEIGHT_IN_ALPHA
322
+ let specularWeightFromTexture: f32=TEXRD(specularWeightSampler,specularWeightSamplerSampler,fragmentInputs.vSpecularWeightUV+uvOffset).a;
323
+ #else
324
+ let specularWeightFromTexture: f32=TEXRD(specularWeightSampler,specularWeightSamplerSampler,fragmentInputs.vSpecularWeightUV+uvOffset).r;
325
+ #endif
326
+ #endif
327
+ #if defined(ANISOTROPIC) || defined(FUZZ) || defined(REFRACTED_BACKGROUND) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING)
328
+ let noise=vec3f(2.0)*textureSample(blueNoiseSampler,blueNoiseSamplerSampler,fragmentInputs.position.xy/256.0).xyz-vec3f(1.0);
329
+ #endif
330
+ #if defined(SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN) && defined(BASE_METALNESS)
331
+ let roughnessFromTexture: f32=metallicFromTexture.g;
332
+ #elif defined(SPECULAR_ROUGHNESS)
333
+ let roughnessFromTexture: f32=TEXRD(specularRoughnessSampler,specularRoughnessSamplerSampler,fragmentInputs.vSpecularRoughnessUV+uvOffset).r;
334
+ #endif
335
+ base_color=uniforms.vBaseColor.rgb;
336
+ #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
337
+ base_color*=fragmentInputs.vColor.rgb;
338
+ #endif
339
+ #if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
340
+ alpha*=fragmentInputs.vColor.a;
341
+ #endif
342
+ base_color*=vec3(uniforms.vBaseWeight);alpha=uniforms.vBaseColor.a;base_metalness=uniforms.vReflectanceInfo.x;base_diffuse_roughness=uniforms.vBaseDiffuseRoughness;specular_roughness=uniforms.vReflectanceInfo.y;specular_color=uniforms.vSpecularColor.rgb;specular_weight=uniforms.vReflectanceInfo.a;specular_ior=uniforms.vReflectanceInfo.z;specular_roughness_anisotropy=uniforms.vSpecularAnisotropy.b;geometry_tangent=uniforms.vSpecularAnisotropy.rg;geometry_thickness=uniforms.vGeometryThickness;
343
+ #ifdef BASE_COLOR
344
+ #ifdef BASE_COLOR_GAMMA
345
+ base_color*=toLinearSpaceVec3(baseColorFromTexture.rgb);
346
+ #else
347
+ base_color*=baseColorFromTexture.rgb;
348
+ #endif
349
+ base_color*=uniforms.vBaseColorInfos.y;
350
+ #endif
351
+ #ifdef BASE_WEIGHT
352
+ base_color*=baseWeightFromTexture.r;
353
+ #endif
354
+ #if defined(BASE_COLOR) && defined(ALPHA_FROM_BASE_COLOR_TEXTURE)
355
+ alpha*=baseColorFromTexture.a;
356
+ #elif defined(GEOMETRY_OPACITY)
357
+ alpha*=opacityFromTexture.a;alpha*=uniforms.vGeometryOpacityInfos.y;
358
+ #endif
359
+ #ifdef GEOMETRY_THICKNESS
360
+ #ifdef GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL
361
+ geometry_thickness*=thicknessFromTexture.g;
362
+ #else
363
+ geometry_thickness*=thicknessFromTexture.r;
364
+ #endif
365
+ geometry_thickness*=uniforms.vGeometryThicknessInfos.y;
366
+ #endif
367
+ #ifdef ALPHATEST
368
+ #if DEBUGMODE != 88
369
+ if (alpha<ALPHATESTVALUE)
370
+ discard;
371
+ #endif
372
+ #ifndef ALPHABLEND
373
+ alpha=1.0;
374
+ #endif
375
+ #endif
376
+ #ifdef BASE_METALNESS
377
+ #ifdef BASE_METALNESS_FROM_METALNESS_TEXTURE_BLUE
378
+ base_metalness*=metallicFromTexture.b;
379
+ #else
380
+ base_metalness*=metallicFromTexture.r;
381
+ #endif
382
+ #endif
383
+ #ifdef BASE_DIFFUSE_ROUGHNESS
384
+ base_diffuse_roughness*=baseDiffuseRoughnessFromTexture*uniforms.vBaseDiffuseRoughnessInfos.y;
385
+ #endif
386
+ #ifdef SPECULAR_COLOR
387
+ #ifdef SPECULAR_COLOR_GAMMA
388
+ specular_color*=toLinearSpaceVec3(specularColorFromTexture.rgb);
389
+ #else
390
+ specular_color*=specularColorFromTexture.rgb;
391
+ #endif
392
+ #ifdef SPECULAR_WEIGHT_FROM_SPECULAR_COLOR_TEXTURE
393
+ specular_weight*=specularColorFromTexture.a;
394
+ #elif defined(SPECULAR_WEIGHT)
395
+ specular_weight*=specularWeightFromTexture;
396
+ #endif
397
+ #endif
398
+ #if defined(SPECULAR_ROUGHNESS) || (defined(SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN) && defined(BASE_METALNESS))
399
+ specular_roughness*=roughnessFromTexture;
400
+ #endif
401
+ #ifdef GEOMETRY_TANGENT
402
+ {let tangentFromTexture: vec2f=normalize(geometryTangentFromTexture.xy*vec2f(2.0f)-vec2f(1.0f));let tangent_angle_texture: f32=atan2(tangentFromTexture.y,tangentFromTexture.x);let tangent_angle_uniform: f32=atan2(geometry_tangent.y,geometry_tangent.x);let tangent_angle: f32=tangent_angle_texture+tangent_angle_uniform;geometry_tangent=vec2f(cos(tangent_angle),sin(tangent_angle));}
403
+ #endif
404
+ #if defined(GEOMETRY_TANGENT) && defined(SPECULAR_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE)
405
+ specular_roughness_anisotropy*=geometryTangentFromTexture.b;
406
+ #elif defined(SPECULAR_ROUGHNESS_ANISOTROPY)
407
+ specular_roughness_anisotropy*=anisotropyFromTexture;
408
+ #endif
409
+ #ifdef DETAIL
410
+ let detailRoughness: f32=mix(0.5f,detailColor.b,vDetailInfos.w);let loLerp: f32=mix(0.f,specular_roughness,detailRoughness*2.f);let hiLerp: f32=mix(specular_roughness,1.f,(detailRoughness-0.5f)*2.f);specular_roughness=mix(loLerp,hiLerp,step(detailRoughness,0.5f));
411
+ #endif
412
+ #ifdef USE_GLTF_STYLE_ANISOTROPY
413
+ let baseAlpha: f32=specular_roughness*specular_roughness;let roughnessT: f32=mix(baseAlpha,1.0f,specular_roughness_anisotropy*specular_roughness_anisotropy);let roughnessB: f32=baseAlpha;specular_roughness_anisotropy=1.0f-roughnessB/max(roughnessT,0.00001f);specular_roughness=sqrt(roughnessT/sqrt(2.0f/(1.0f+(1.0f-specular_roughness_anisotropy)*(1.0f-specular_roughness_anisotropy))));
414
+ #endif
415
+ `;
416
+ e.IncludesShadersStoreWGSL[c] || (e.IncludesShadersStoreWGSL[c] = O);
417
+ const _ = "openpbrCoatLayerData", C = `var coat_weight: f32=0.0f;var coat_color: vec3f=vec3f(1.0f);var coat_roughness: f32=0.0f;var coat_roughness_anisotropy: f32=0.0f;var coat_ior: f32=1.6f;var coat_darkening: f32=1.0f;var geometry_coat_tangent: vec2f=vec2f(1.0f,0.0f);
418
+ #ifdef COAT_WEIGHT
419
+ var coatWeightFromTexture: vec4f=TEXRD(coatWeightSampler,coatWeightSamplerSampler,fragmentInputs.vCoatWeightUV+uvOffset);
420
+ #endif
421
+ #ifdef COAT_COLOR
422
+ var coatColorFromTexture: vec4f=TEXRD(coatColorSampler,coatColorSamplerSampler,fragmentInputs.vCoatColorUV+uvOffset);
423
+ #endif
424
+ #ifdef COAT_ROUGHNESS
425
+ var coatRoughnessFromTexture: vec4f=TEXRD(coatRoughnessSampler,coatRoughnessSamplerSampler,fragmentInputs.vCoatRoughnessUV+uvOffset);
426
+ #endif
427
+ #ifdef COAT_ROUGHNESS_ANISOTROPY
428
+ var coatRoughnessAnisotropyFromTexture: f32=TEXRD(coatRoughnessAnisotropySampler,coatRoughnessAnisotropySamplerSampler,fragmentInputs.vCoatRoughnessAnisotropyUV+uvOffset).r;
429
+ #endif
430
+ #ifdef COAT_DARKENING
431
+ var coatDarkeningFromTexture: vec4f=TEXRD(coatDarkeningSampler,coatDarkeningSamplerSampler,fragmentInputs.vCoatDarkeningUV+uvOffset);
432
+ #endif
433
+ #ifdef GEOMETRY_COAT_TANGENT
434
+ var geometryCoatTangentFromTexture: vec3f=TEXRD(geometryCoatTangentSampler,geometryCoatTangentSamplerSampler,fragmentInputs.vGeometryCoatTangentUV+uvOffset).rgb;
435
+ #endif
436
+ coat_color=uniforms.vCoatColor.rgb;coat_weight=uniforms.vCoatWeight;coat_roughness=uniforms.vCoatRoughness;coat_roughness_anisotropy=uniforms.vCoatRoughnessAnisotropy;coat_ior=uniforms.vCoatIor;coat_darkening=uniforms.vCoatDarkening;geometry_coat_tangent=uniforms.vGeometryCoatTangent.rg;
437
+ #ifdef COAT_WEIGHT
438
+ coat_weight*=coatWeightFromTexture.r;
439
+ #endif
440
+ #ifdef COAT_COLOR
441
+ #ifdef COAT_COLOR_GAMMA
442
+ coat_color*=toLinearSpaceVec3(coatColorFromTexture.rgb);
443
+ #else
444
+ coat_color*=coatColorFromTexture.rgb;
445
+ #endif
446
+ coat_color*=uniforms.vCoatColorInfos.y;
447
+ #endif
448
+ #ifdef COAT_ROUGHNESS
449
+ #ifdef COAT_ROUGHNESS_FROM_GREEN_CHANNEL
450
+ coat_roughness*=coatRoughnessFromTexture.g;
451
+ #else
452
+ coat_roughness*=coatRoughnessFromTexture.r;
453
+ #endif
454
+ #endif
455
+ #if defined(GEOMETRY_COAT_TANGENT) && defined(COAT_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE)
456
+ coat_roughness_anisotropy*=geometryCoatTangentFromTexture.b;
457
+ #elif defined(COAT_ROUGHNESS_ANISOTROPY)
458
+ coat_roughness_anisotropy*=coatRoughnessAnisotropyFromTexture;
459
+ #endif
460
+ #ifdef COAT_DARKENING
461
+ coat_darkening*=coatDarkeningFromTexture.r;
462
+ #endif
463
+ #ifdef GEOMETRY_COAT_TANGENT
464
+ {let tangentFromTexture: vec2f=normalize(geometryCoatTangentFromTexture.xy*vec2f(2.0f)-vec2f(1.0f));let tangent_angle_texture: f32=atan2(tangentFromTexture.y,tangentFromTexture.x);let tangent_angle_uniform: f32=atan2(geometry_coat_tangent.y,geometry_coat_tangent.x);let tangent_angle: f32=tangent_angle_texture+tangent_angle_uniform;geometry_coat_tangent=vec2f(cos(tangent_angle),sin(tangent_angle));}
465
+ #endif
466
+ #ifdef USE_GLTF_STYLE_ANISOTROPY
467
+ let coatAlpha: f32=coat_roughness*coat_roughness;let coatRoughnessT: f32=mix(coatAlpha,1.0f,coat_roughness_anisotropy*coat_roughness_anisotropy);let coatRoughnessB: f32=coatAlpha;coat_roughness_anisotropy=1.0f-coatRoughnessB/max(coatRoughnessT,0.00001f);coat_roughness=sqrt(coatRoughnessT/sqrt(2.0f/(1.0f+(1.0f-coat_roughness_anisotropy)*(1.0f-coat_roughness_anisotropy))));
468
+ #endif
469
+ `;
470
+ e.IncludesShadersStoreWGSL[_] || (e.IncludesShadersStoreWGSL[_] = C);
471
+ const m = "openpbrThinFilmLayerData", D = `#ifdef THIN_FILM
472
+ var thin_film_weight: f32=uniforms.vThinFilmWeight;var thin_film_thickness: f32=uniforms.vThinFilmThickness.r*1000.0f;
473
+ var thin_film_ior: f32=uniforms.vThinFilmIor;
474
+ #ifdef THIN_FILM_WEIGHT
475
+ var thinFilmWeightFromTexture: f32=TEXRD(thinFilmWeightSampler,thinFilmWeightSamplerSampler,fragmentInputs.vThinFilmWeightUV+uvOffset).r*uniforms.vThinFilmWeightInfos.y;
476
+ #endif
477
+ #ifdef THIN_FILM_THICKNESS
478
+ var thinFilmThicknessFromTexture: f32=TEXRD(thinFilmThicknessSampler,thinFilmThicknessSamplerSampler,fragmentInputs.vThinFilmThicknessUV+uvOffset).g*uniforms.vThinFilmThicknessInfos.y;
479
+ #endif
480
+ #ifdef THIN_FILM_WEIGHT
481
+ thin_film_weight*=thinFilmWeightFromTexture;
482
+ #endif
483
+ #ifdef THIN_FILM_THICKNESS
484
+ thin_film_thickness*=thinFilmThicknessFromTexture;
485
+ #endif
486
+ let thin_film_ior_scale: f32=clamp(2.0f*abs(thin_film_ior-1.0f),0.0f,1.0f);
487
+ #endif
488
+ `;
489
+ e.IncludesShadersStoreWGSL[m] || (e.IncludesShadersStoreWGSL[m] = D);
490
+ const d = "openpbrFuzzLayerData", P = `var fuzz_weight: f32=0.0f;var fuzz_color: vec3f=vec3f(1.0f);var fuzz_roughness: f32=0.0f;
491
+ #ifdef FUZZ
492
+ #ifdef FUZZ_WEIGHT
493
+ let fuzzWeightFromTexture: vec4f=TEXRD(fuzzWeightSampler,fuzzWeightSamplerSampler,fragmentInputs.vFuzzWeightUV+uvOffset);
494
+ #endif
495
+ #ifdef FUZZ_COLOR
496
+ var fuzzColorFromTexture: vec4f=TEXRD(fuzzColorSampler,fuzzColorSamplerSampler,fragmentInputs.vFuzzColorUV+uvOffset);
497
+ #endif
498
+ #ifdef FUZZ_ROUGHNESS
499
+ let fuzzRoughnessFromTexture: vec4f=TEXRD(fuzzRoughnessSampler,fuzzRoughnessSamplerSampler,fragmentInputs.vFuzzRoughnessUV+uvOffset);
500
+ #endif
501
+ fuzz_color=uniforms.vFuzzColor.rgb;fuzz_weight=uniforms.vFuzzWeight;fuzz_roughness=uniforms.vFuzzRoughness;
502
+ #ifdef FUZZ_WEIGHT
503
+ fuzz_weight*=fuzzWeightFromTexture.r;
504
+ #endif
505
+ #ifdef FUZZ_COLOR
506
+ #ifdef FUZZ_COLOR_GAMMA
507
+ fuzz_color*=toLinearSpaceVec3(fuzzColorFromTexture.rgb);
508
+ #else
509
+ fuzz_color*=fuzzColorFromTexture.rgb;
510
+ #endif
511
+ fuzz_color*=uniforms.vFuzzColorInfos.y;
512
+ #endif
513
+ #if defined(FUZZ_ROUGHNESS) && defined(FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA)
514
+ fuzz_roughness*=fuzzRoughnessFromTexture.a;
515
+ #elif defined(FUZZ_ROUGHNESS)
516
+ fuzz_roughness*=fuzzRoughnessFromTexture.r;
517
+ #endif
518
+ #endif
519
+ `;
520
+ e.IncludesShadersStoreWGSL[d] || (e.IncludesShadersStoreWGSL[d] = P);
521
+ const u = "openpbrAmbientOcclusionData", x = `var ambient_occlusion: vec3f=vec3f(1.0f,1.0f,1.0f);var specular_ambient_occlusion: f32=1.0f;var coat_specular_ambient_occlusion: f32=1.0f;
522
+ #ifdef AMBIENT_OCCLUSION
523
+ var ambientOcclusionFromTexture: vec3f=TEXRD(ambientOcclusionSampler,ambientOcclusionSamplerSampler,fragmentInputs.vAmbientOcclusionUV+uvOffset).rgb;ambient_occlusion=vec3f(ambientOcclusionFromTexture.r*uniforms.vAmbientOcclusionInfos.y+(1.0f-uniforms.vAmbientOcclusionInfos.y));
524
+ #endif
525
+ `;
526
+ e.IncludesShadersStoreWGSL[u] || (e.IncludesShadersStoreWGSL[u] = x);
527
+ const g = "openpbrBackgroundTransmission", M = `var slab_translucent_background: vec4f=vec4f(0.,0.,0.,1.);
528
+ #ifdef REFRACTED_BACKGROUND
529
+ {let refractionLOD: f32=min(transmission_roughness,0.8)*uniforms.vBackgroundRefractionInfos.x;let lodTexelSize: f32=pow(2.0f,refractionLOD-uniforms.vBackgroundRefractionInfos.x);
530
+ #ifdef DISPERSION
531
+ {
532
+ #ifdef REFRACTION_HIGH_QUALITY_BLUR
533
+ {var dispResult: vec3f=vec3f(0.0);var dispWeight: vec3f=vec3f(0.0);let noiseOffset: vec2f=noise.xy*select(0.0f,lodTexelSize,refractionLOD>0.0f);for (var k: i32=0; k<6; k++) {let t: f32=(f32(k)+noise.y)/6.0f;let t_rg: f32=clamp(t*2.0f,0.0f,1.0f);let t_gb: f32=clamp((t-0.5f)*2.0f,0.0f,1.0f);let refVec: vec3f=mix(mix(refractedViewVectors[0],refractedViewVectors[1],t_rg),refractedViewVectors[2],t_gb);let uvw: vec3f=vec3f((uniforms.backgroundRefractionMatrix*(scene.view*vec4f(fragmentInputs.vPositionW+refVec*geometry_thickness,1.0f))).xyz);var coords: vec2f=uvw.xy/uvw.z;coords.y=1.0f-coords.y;let s: vec4f=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,coords+noiseOffset,refractionLOD);let rw: f32=max(0.0f,1.0f-2.0f*t);let gw: f32=max(0.0f,1.0f-abs(2.0f*t-1.0f));let bw: f32=max(0.0f,2.0f*t-1.0f);let w: vec3f=vec3f(rw,gw,bw);dispResult+=s.rgb*w;dispWeight+=w;}
534
+ slab_translucent_background=vec4f(dispResult/max(dispWeight,vec3f(1e-6)),1.0f);}
535
+ #else
536
+ for (var i: i32=0; i<3; i++) {let refractedViewVector: vec3f=refractedViewVectors[i];let uvw: vec3f=vec3f((uniforms.backgroundRefractionMatrix*(scene.view*vec4f(fragmentInputs.vPositionW+refractedViewVector*geometry_thickness,1.0f))).xyz);var coords: vec2f=uvw.xy/uvw.z;coords.y=1.0f-coords.y;if (refractionLOD>0.0f) {let noiseOffset: vec2f=noise.xy*lodTexelSize;slab_translucent_background[i]=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,coords+noiseOffset,refractionLOD)[i];} else {slab_translucent_background[i]=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,coords,0.0f)[i];}}
537
+ #endif
538
+ }
539
+ #else
540
+ {let refractionUVW: vec3f=vec3f((uniforms.backgroundRefractionMatrix*(scene.view*vec4f(fragmentInputs.vPositionW+refractedViewVector*geometry_thickness,1.0f))).xyz);var refractionCoords: vec2f=refractionUVW.xy/refractionUVW.z;refractionCoords.y=1.0f-refractionCoords.y;if (refractionLOD>0.0f) {
541
+ #ifdef REFRACTION_HIGH_QUALITY_BLUR
542
+ let cosA: f32=cos(noise.x*PI);let sinA: f32=sin(noise.x*PI);let u: vec2f=vec2f( cosA,sinA)*(0.5f*lodTexelSize);let v: vec2f=vec2f(-sinA,cosA)*(0.5f*lodTexelSize);slab_translucent_background=0.25f*(
543
+ textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords+u+v,refractionLOD) +
544
+ textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords-u+v,refractionLOD) +
545
+ textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords+u-v,refractionLOD) +
546
+ textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords-u-v,refractionLOD)
547
+ );
548
+ #else
549
+ let noiseOffset: vec2f=noise.xy*lodTexelSize;slab_translucent_background=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords+noiseOffset,refractionLOD);
550
+ #endif
551
+ } else {slab_translucent_background=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords,0.0f);}}
552
+ #endif
553
+ }
554
+ #endif
555
+ `;
556
+ e.IncludesShadersStoreWGSL[g] || (e.IncludesShadersStoreWGSL[g] = M);
557
+ const p = "openpbrEnvironmentLighting", G = `#if defined(REFLECTION) || defined(REFRACTED_BACKGROUND)
558
+ var coatAbsorption=vec3f(1.0f);var coatIblFresnel: f32=0.0;if (coat_weight>0.0) {coatIblFresnel=computeDielectricIblFresnel(coatReflectance,coatGeoInfo.environmentBrdf);let hemisphere_avg_fresnel: f32=coatReflectance.F0+0.5f*(1.0f-coatReflectance.F0);var averageReflectance: f32=(coatIblFresnel+hemisphere_avg_fresnel)*0.5f;let roughnessFactor=1.0f-coat_roughness*0.5f;averageReflectance*=roughnessFactor;var darkened_transmission: f32=(1.0f-averageReflectance)*(1.0f-averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);var sin2: f32=1.0f-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior)*coat_weight;let cos_t: f32=sqrt(1.0f-sin2);let coatPathLength=1.0f/cos_t;let effectivePathLength=coatPathLength*coat_weight;let colored_transmission: vec3f=pow(coat_color,vec3f(effectivePathLength));coatAbsorption=colored_transmission*mix(1.0f,darkened_transmission,coat_weight);}
559
+ #endif
560
+ #ifdef REFLECTION
561
+ #ifdef FUZZ
562
+ let environmentFuzzBrdf: vec3f=getFuzzBRDFLookup(fuzzGeoInfo.NdotV,sqrt(fuzz_roughness));
563
+ #endif
564
+ var baseDiffuseEnvironmentLight: vec3f=sampleIrradiance(
565
+ normalW
566
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
567
+ ,vEnvironmentIrradiance
568
+ #endif
569
+ #if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
570
+ ,uniforms.reflectionMatrix
571
+ #endif
572
+ #ifdef USEIRRADIANCEMAP
573
+ ,irradianceSampler
574
+ ,irradianceSamplerSampler
575
+ #ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
576
+ ,uniforms.vReflectionDominantDirection
577
+ #endif
578
+ #endif
579
+ #ifdef REALTIME_FILTERING
580
+ ,uniforms.vReflectionFilteringInfo
581
+ #ifdef IBL_CDF_FILTERING
582
+ ,icdfSampler
583
+ ,icdfSamplerSampler
584
+ #endif
585
+ #endif
586
+ ,uniforms.vReflectionInfos
587
+ ,viewDirectionW
588
+ ,base_diffuse_roughness
589
+ ,base_color
590
+ );
591
+ #ifdef REFLECTIONMAP_3D
592
+ var reflectionCoords: vec3f=vec3f(0.f,0.f,0.f);
593
+ #else
594
+ var reflectionCoords: vec2f=vec2f(0.f,0.f);
595
+ #endif
596
+ let specularAlphaG: f32=specular_roughness*specular_roughness;
597
+ #ifdef ANISOTROPIC_BASE
598
+ var baseSpecularEnvironmentLight: vec3f=sampleRadianceAnisotropic(specularAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
599
+ ,baseGeoInfo
600
+ ,normalW
601
+ ,viewDirectionW
602
+ ,fragmentInputs.vPositionW
603
+ ,noise
604
+ ,false
605
+ ,1.0
606
+ ,reflectionSampler
607
+ ,reflectionSamplerSampler
608
+ #ifdef REALTIME_FILTERING
609
+ ,uniforms.vReflectionFilteringInfo
610
+ #endif
611
+ );
612
+ #else
613
+ reflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,normalW);var baseSpecularEnvironmentLight: vec3f=sampleRadiance(specularAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
614
+ ,baseGeoInfo
615
+ ,reflectionSampler
616
+ ,reflectionSamplerSampler
617
+ ,reflectionCoords
618
+ #ifdef REALTIME_FILTERING
619
+ ,uniforms.vReflectionFilteringInfo
620
+ #endif
621
+ );
622
+ #endif
623
+ #ifdef ANISOTROPIC_BASE
624
+ baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG*specularAlphaG *max(1.0f-baseGeoInfo.anisotropy,0.3f));
625
+ #else
626
+ baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG);
627
+ #endif
628
+ var coatEnvironmentLight: vec3f=vec3f(0.f,0.f,0.f);if (coat_weight>0.0) {
629
+ #ifdef REFLECTIONMAP_3D
630
+ var reflectionCoords: vec3f=vec3f(0.f,0.f,0.f);
631
+ #else
632
+ var reflectionCoords: vec2f=vec2f(0.f,0.f);
633
+ #endif
634
+ reflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,coatNormalW);var coatAlphaG: f32=coat_roughness*coat_roughness;
635
+ #ifdef ANISOTROPIC_COAT
636
+ coatEnvironmentLight=sampleRadianceAnisotropic(coatAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
637
+ ,coatGeoInfo
638
+ ,coatNormalW
639
+ ,viewDirectionW
640
+ ,fragmentInputs.vPositionW
641
+ ,noise
642
+ ,false
643
+ ,1.0
644
+ ,reflectionSampler
645
+ ,reflectionSamplerSampler
646
+ #ifdef REALTIME_FILTERING
647
+ ,uniforms.vReflectionFilteringInfo
648
+ #endif
649
+ );
650
+ #else
651
+ coatEnvironmentLight=sampleRadiance(coatAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
652
+ ,coatGeoInfo
653
+ ,reflectionSampler
654
+ ,reflectionSamplerSampler
655
+ ,reflectionCoords
656
+ #ifdef REALTIME_FILTERING
657
+ ,uniforms.vReflectionFilteringInfo
658
+ #endif
659
+ );
660
+ #endif
661
+ }
662
+ #ifdef FUZZ
663
+ let modifiedFuzzRoughness: f32=clamp(fuzz_roughness*(1.0f-0.5f*environmentFuzzBrdf.y),0.0f,1.0f);var fuzzEnvironmentLight=vec3f(0.0f,0.0f,0.0f);var totalWeight=0.0f;let fuzzIblFresnel: f32=sqrt(environmentFuzzBrdf.z);for (var i: i32=0; i<i32(FUZZ_IBL_SAMPLES); i++) {var angle: f32=(f32(i)+noise.x)*(3.141592f*2.0f/f32(FUZZ_IBL_SAMPLES));var fiberCylinderNormal: vec3f=normalize(cos(angle)*fuzzTangent+sin(angle)*fuzzBitangent);let fiberBend=min(environmentFuzzBrdf.x*environmentFuzzBrdf.x*modifiedFuzzRoughness,1.0f);fiberCylinderNormal=normalize(mix(fiberCylinderNormal,fuzzNormalW,fiberBend));let sampleWeight=max(dot(viewDirectionW,fiberCylinderNormal),0.0f);var fuzzReflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,fiberCylinderNormal);let radianceSample: vec3f=sampleRadiance(modifiedFuzzRoughness,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
664
+ ,fuzzGeoInfo
665
+ ,reflectionSampler
666
+ ,reflectionSamplerSampler
667
+ ,fuzzReflectionCoords
668
+ #ifdef REALTIME_FILTERING
669
+ ,uniforms.vReflectionFilteringInfo
670
+ #endif
671
+ );fuzzEnvironmentLight+=sampleWeight*mix(radianceSample,baseDiffuseEnvironmentLight,fiberBend);totalWeight+=sampleWeight;}
672
+ fuzzEnvironmentLight/=totalWeight;
673
+ #endif
674
+ var dielectricIblFresnel: f32=computeDielectricIblFresnel(baseDielectricReflectance,baseGeoInfo.environmentBrdf);var dielectricIblColoredFresnel: vec3f=dielectricIblFresnel*specular_color;
675
+ #ifdef THIN_FILM
676
+ let thin_film_cos_theta: f32=max(baseGeoInfo.NdotV,specularAlphaG);let thin_film_desaturation_scale=(thin_film_ior-1.0)*sqrt(thin_film_thickness*0.001f*thin_film_cos_theta);let tf_brdf_x: f32=baseGeoInfo.environmentBrdf.x;let tf_E_ss: f32 =baseGeoInfo.environmentBrdf.y;var thinFilmDielectricF0: vec3f=evalIridescence(thin_film_outside_ior,thin_film_ior,1.0,thin_film_thickness,vec3f(baseDielectricReflectance.F0));thinFilmDielectricF0=mix(thinFilmDielectricF0,vec3(dot(thinFilmDielectricF0,vec3f(0.3333f))),thin_film_desaturation_scale);var thinFilmDielectricDir: vec3f=evalIridescence(thin_film_outside_ior,thin_film_ior,thin_film_cos_theta,thin_film_thickness,vec3f(baseDielectricReflectance.F0));thinFilmDielectricDir=mix(thinFilmDielectricDir,vec3(dot(thinFilmDielectricDir,vec3f(0.3333f))),thin_film_desaturation_scale);let tf_f0d_avg: f32 =dot(thinFilmDielectricF0, vec3f(0.3333f));let tf_dird_avg: f32=dot(thinFilmDielectricDir,vec3f(0.3333f));var thin_film_dielectric: vec3f=thinFilmDielectricDir*(tf_f0d_avg/max(tf_dird_avg,1e-5));let tf_E_dielectric: vec3f=(vec3f(1.0)-thin_film_dielectric)*vec3f(tf_brdf_x)+thin_film_dielectric*vec3f(tf_E_ss);let tf_F_avg_dielectric: vec3f=thin_film_dielectric+(vec3f(1.0)-thin_film_dielectric)/21.0;let tf_ECF_dielectric: vec3f=vec3f(1.0)+tf_F_avg_dielectric*(vec3f(1.0)/vec3f(tf_E_ss)-vec3f(1.0));thin_film_dielectric=clamp(tf_E_dielectric*tf_ECF_dielectric,vec3f(0.0),vec3f(1.0));dielectricIblColoredFresnel=mix(dielectricIblColoredFresnel,thin_film_dielectric*specular_color,thin_film_weight*thin_film_ior_scale);dielectricIblFresnel=max(dielectricIblColoredFresnel.r,max(dielectricIblColoredFresnel.g,dielectricIblColoredFresnel.b));
677
+ #endif
678
+ var conductorIblFresnel: vec3f=computeConductorIblFresnel(baseConductorReflectance,baseGeoInfo.environmentBrdf);
679
+ #ifdef THIN_FILM
680
+ var thinFilmConductorF0: vec3f=evalIridescence(thin_film_outside_ior,thin_film_ior,1.0,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorF0=mix(thinFilmConductorF0,vec3(dot(thinFilmConductorF0,vec3f(0.3333f))),thin_film_desaturation_scale);var thinFilmConductorDir: vec3f=evalIridescence(thin_film_outside_ior,thin_film_ior,thin_film_cos_theta,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorDir=mix(thinFilmConductorDir,vec3(dot(thinFilmConductorDir,vec3f(0.3333f))),thin_film_desaturation_scale);let tf_f0c_avg: f32 =dot(thinFilmConductorF0, vec3f(0.3333f));let tf_dirc_avg: f32=dot(thinFilmConductorDir,vec3f(0.3333f));var thinFilmConductorRaw: vec3f=thinFilmConductorDir*(tf_f0c_avg/max(tf_dirc_avg,1e-5));
681
+ #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) && defined(ENVIRONMENTBRDF)
682
+ let tf_b: vec3f=getF82B(baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);let tf_brdf_z: f32=baseGeoInfo.environmentBrdf.z/BRDF_Z_SCALE;let tf_E_conductor: vec3f=(vec3f(1.0)-thinFilmConductorRaw)*vec3f(tf_brdf_x)+thinFilmConductorRaw*vec3f(tf_E_ss)-tf_b*vec3f(tf_brdf_z);let tf_F_avg_conductor: vec3f=thinFilmConductorRaw+(vec3f(1.0)-thinFilmConductorRaw)/21.0-tf_b/126.0;
683
+ #else
684
+ let tf_E_conductor: vec3f=(vec3f(1.0)-thinFilmConductorRaw)*vec3f(tf_brdf_x)+thinFilmConductorRaw*vec3f(tf_E_ss);let tf_F_avg_conductor: vec3f=thinFilmConductorRaw+(vec3f(1.0)-thinFilmConductorRaw)/21.0;
685
+ #endif
686
+ let tf_ECF_conductor: vec3f=vec3f(1.0)+tf_F_avg_conductor*(vec3f(1.0)/vec3f(tf_E_ss)-vec3f(1.0));var thinFilmConductorFresnel: vec3f=specular_weight*clamp(tf_E_conductor*tf_ECF_conductor,vec3f(0.0),vec3f(1.0));conductorIblFresnel=mix(conductorIblFresnel,thinFilmConductorFresnel,thin_film_weight*thin_film_ior_scale);
687
+ #endif
688
+ var slab_diffuse_ibl: vec3f=vec3f(0.,0.,0.);var slab_glossy_ibl: vec3f=vec3f(0.,0.,0.);var slab_metal_ibl: vec3f=vec3f(0.,0.,0.);var slab_coat_ibl: vec3f=vec3f(0.,0.,0.);slab_diffuse_ibl=baseDiffuseEnvironmentLight*uniforms.vLightingIntensity.z;
689
+ #ifdef AMBIENT_OCCLUSION
690
+ specular_ambient_occlusion=compute_specular_occlusion(baseGeoInfo.NdotV,base_metalness,ambient_occlusion.x,specular_roughness);
691
+ #endif
692
+ slab_glossy_ibl=baseSpecularEnvironmentLight*uniforms.vLightingIntensity.z;slab_metal_ibl=baseSpecularEnvironmentLight*conductorIblFresnel*uniforms.vLightingIntensity.z;if (coat_weight>0.0) {slab_coat_ibl=coatEnvironmentLight*uniforms.vLightingIntensity.z;
693
+ #ifdef AMBIENT_OCCLUSION
694
+ coat_specular_ambient_occlusion=compute_specular_occlusion(coatGeoInfo.NdotV,0.0,ambient_occlusion.x,coat_roughness);
695
+ #endif
696
+ }
697
+ #ifdef FUZZ
698
+ var slab_fuzz_ibl=fuzzEnvironmentLight*uniforms.vLightingIntensity.z;
699
+ #endif
700
+ var slab_translucent_base_ibl: vec3f=vec3f(0.0f,0.0f,0.0f);
701
+ #ifdef REFRACTED_ENVIRONMENT
702
+ #ifdef ANISOTROPIC_BASE
703
+ var forwardScatteredEnvironmentLight: vec3f=sampleRadianceAnisotropic(transmission_roughness_alpha,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
704
+ ,baseGeoInfo
705
+ #ifdef GEOMETRY_THIN_WALLED
706
+ ,viewDirectionW
707
+ #else
708
+ ,normalW
709
+ #endif
710
+ ,viewDirectionW
711
+ ,fragmentInputs.vPositionW
712
+ ,noise
713
+ ,true
714
+ #ifdef GEOMETRY_THIN_WALLED
715
+ ,1.05f
716
+ #else
717
+ ,specular_ior
718
+ #endif
719
+ ,reflectionSampler
720
+ ,reflectionSamplerSampler
721
+ #ifdef REALTIME_FILTERING
722
+ ,uniforms.vReflectionFilteringInfo
723
+ #endif
724
+ );
725
+ #else
726
+ var forwardScatteredEnvironmentLight: vec3f=vec3f(0.,0.,0.);
727
+ #ifdef DISPERSION
728
+ for (var i: i32=0; i<3; i++) {var iblRefractionCoords: vec3f=refractedViewVectors[i];
729
+ #else
730
+ var iblRefractionCoords: vec3f=refractedViewVector;
731
+ #endif
732
+ #ifdef REFRACTED_ENVIRONMENT_OPPOSITEZ
733
+ iblRefractionCoords.z*=-1.0f;
734
+ #endif
735
+ #ifdef REFRACTED_ENVIRONMENT_LOCAL_CUBE
736
+ iblRefractionCoords=parallaxCorrectNormal(fragmentInputs.vPositionW,refractedViewVector,uniforms.refractionSize,uniforms.refractionPosition);
737
+ #endif
738
+ iblRefractionCoords=(uniforms.reflectionMatrix*vec4f(iblRefractionCoords,0.0f)).xyz;
739
+ #ifdef DISPERSION
740
+ forwardScatteredEnvironmentLight[i]=sampleRadiance(transmission_roughness_alpha,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
741
+ ,baseGeoInfo
742
+ ,reflectionSampler
743
+ ,reflectionSamplerSampler
744
+ ,iblRefractionCoords
745
+ #ifdef REALTIME_FILTERING
746
+ ,uniforms.vReflectionFilteringInfo
747
+ #endif
748
+ )[i];
749
+ #else
750
+ forwardScatteredEnvironmentLight=sampleRadiance(transmission_roughness_alpha,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos
751
+ ,baseGeoInfo
752
+ ,reflectionSampler
753
+ ,reflectionSamplerSampler
754
+ ,iblRefractionCoords
755
+ #ifdef REALTIME_FILTERING
756
+ ,uniforms.vReflectionFilteringInfo
757
+ #endif
758
+ );
759
+ #endif
760
+ #ifdef DISPERSION
761
+ }
762
+ #endif
763
+ #endif
764
+ #ifdef REFRACTED_BACKGROUND
765
+ #ifdef GEOMETRY_THIN_WALLED
766
+ forwardScatteredEnvironmentLight=mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight.rgb,0.2*transmission_roughness_alpha);
767
+ #else
768
+ forwardScatteredEnvironmentLight=max(slab_translucent_background.rgb,mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight,transmission_roughness_alpha));
769
+ #endif
770
+ #endif
771
+ #ifdef SCATTERING
772
+ #ifdef GEOMETRY_THIN_WALLED
773
+ var scatterVector: vec3f=normalW;
774
+ #else
775
+ #if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)
776
+ var scatterVector: vec3f=mix(uniforms.vReflectionDominantDirection,normalW,max3(iso_scatter_density));
777
+ #else
778
+ var scatterVector: vec3f=normalW;
779
+ #endif
780
+ scatterVector=mix(viewDirectionW,scatterVector,back_to_iso_scattering_blend);
781
+ #endif
782
+ #if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(GEOMETRY_THIN_WALLED)
783
+ var scatteredEnvironmentLight: vec3f=scattered_light_from_irradiance_texture;
784
+ #else
785
+ var scatteredEnvironmentLight: vec3f=sampleIrradiance(
786
+ scatterVector
787
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
788
+ ,vEnvironmentIrradiance
789
+ #endif
790
+ #if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
791
+ ,uniforms.reflectionMatrix
792
+ #endif
793
+ #ifdef USEIRRADIANCEMAP
794
+ ,irradianceSampler
795
+ ,irradianceSamplerSampler
796
+ #ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
797
+ ,uniforms.vReflectionDominantDirection
798
+ #endif
799
+ #endif
800
+ #ifdef REALTIME_FILTERING
801
+ ,uniforms.vReflectionFilteringInfo
802
+ #ifdef IBL_CDF_FILTERING
803
+ ,icdfSampler
804
+ ,icdfSamplerSampler
805
+ #endif
806
+ #endif
807
+ ,uniforms.vReflectionInfos
808
+ ,viewDirectionW
809
+ #if defined(GEOMETRY_THIN_WALLED)
810
+ ,base_diffuse_roughness
811
+ ,subsurface_color.rgb
812
+ #else
813
+ ,1.0f
814
+ ,volumeParams.multi_scatter_color
815
+ #endif
816
+ );
817
+ #endif
818
+ #ifdef GEOMETRY_THIN_WALLED
819
+ let forward_scattered_light: vec3f=forwardScatteredEnvironmentLight*transmission_tint*volumeParams.multi_scatter_color;let back_scattered_light: vec3f=scatteredEnvironmentLight*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(back_scattered_light,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy);
820
+ #else
821
+ let forward_scattered_light: vec3f=forwardScatteredEnvironmentLight*volume_absorption;let back_scattered_light: vec3f=mix(forward_scattered_light,scatteredEnvironmentLight*backscatter_color,iso_scatter_density);let iso_scattered_light: vec3f=mix(forward_scattered_light,scatteredEnvironmentLight*volumeParams.multi_scatter_color,iso_scatter_density);slab_translucent_base_ibl=mix(back_scattered_light,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;
822
+ #endif
823
+ #else
824
+ slab_translucent_base_ibl+=forwardScatteredEnvironmentLight*transmission_tint*volume_absorption;
825
+ #endif
826
+ #endif
827
+ #define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION
828
+ slab_diffuse_ibl*=ambient_occlusion;slab_metal_ibl*=specular_ambient_occlusion;slab_glossy_ibl*=specular_ambient_occlusion;slab_coat_ibl*=coat_specular_ambient_occlusion;let material_dielectric_base_ibl: vec3f=mix(slab_diffuse_ibl*base_color.rgb,slab_translucent_base_ibl,surface_translucency_weight);let material_dielectric_gloss_ibl: vec3f=material_dielectric_base_ibl*(1.0-dielectricIblFresnel)+slab_glossy_ibl*dielectricIblColoredFresnel;let material_base_substrate_ibl: vec3f=mix(material_dielectric_gloss_ibl,slab_metal_ibl,base_metalness);let material_coated_base_ibl: vec3f=layer(material_base_substrate_ibl,slab_coat_ibl,coatIblFresnel,coatAbsorption,vec3f(1.0f));
829
+ #ifdef FUZZ
830
+ slab_fuzz_ibl*=min(vec3(specular_ambient_occlusion),ambient_occlusion);material_surface_ibl=layer(material_coated_base_ibl,slab_fuzz_ibl,fuzzIblFresnel*fuzz_weight,vec3f(1.0f),fuzz_color);
831
+ #else
832
+ material_surface_ibl=material_coated_base_ibl;
833
+ #endif
834
+ #elif defined(REFRACTED_BACKGROUND)
835
+ let black=vec3f(0.0f);var slab_translucent_base_ibl: vec3f=vec3f(0.0f);
836
+ #ifdef GEOMETRY_THIN_WALLED
837
+ #ifdef SCATTERING
838
+ let forward_scattered_light: vec3f=slab_translucent_background.rgb*transmission_tint*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(black,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy);
839
+ #else
840
+ slab_translucent_base_ibl=slab_translucent_background.rgb*transmission_tint;
841
+ #endif
842
+ #else
843
+ #ifdef SCATTERING
844
+ let forward_scattered_light: vec3f=slab_translucent_background.rgb*volume_absorption;let iso_scattered_light: vec3f=(1.0f-iso_scatter_density)*forward_scattered_light;slab_translucent_base_ibl=mix(black,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;
845
+ #else
846
+ slab_translucent_base_ibl=slab_translucent_background.rgb*volume_absorption*transmission_tint;
847
+ #endif
848
+ #endif
849
+ let material_dielectric_base_ibl: vec3f=mix(black,slab_translucent_base_ibl.rgb,surface_translucency_weight);let material_dielectric_gloss_ibl: vec3f=material_dielectric_base_ibl*(baseGeoInfo.NdotV);let material_base_substrate_ibl: vec3f=mix(material_dielectric_gloss_ibl,black,base_metalness);let material_coated_base_ibl: vec3f=layer(material_base_substrate_ibl,black,coatIblFresnel,coatAbsorption,vec3f(1.0f));material_surface_ibl=material_coated_base_ibl;
850
+ #endif
851
+ `;
852
+ e.IncludesShadersStoreWGSL[p] || (e.IncludesShadersStoreWGSL[p] = G);
853
+ const v = "openpbrDirectLightingInit", y = `#ifdef LIGHT{X}
854
+ var preInfo{X}: preLightingInfo;var preInfoCoat{X}: preLightingInfo;let lightColor{X}: vec4f=light{X}.vLightDiffuse;var shadow{X}: f32=1.0f;
855
+ #if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
856
+ #else
857
+ #define CUSTOM_LIGHT{X}_COLOR
858
+ #ifdef SPOTLIGHT{X}
859
+ preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,fragmentInputs.vPositionW);
860
+ #elif defined(POINTLIGHT{X})
861
+ preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,fragmentInputs.vPositionW);
862
+ #elif defined(HEMILIGHT{X})
863
+ preInfo{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);
864
+ #elif defined(DIRLIGHT{X})
865
+ preInfo{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);
866
+ #elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
867
+ preInfo{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,specular_roughness);preInfoCoat{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,coatNormalW,fragmentInputs.vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,coat_roughness);
868
+ #endif
869
+ preInfo{X}.NdotV=baseGeoInfo.NdotV;preInfoCoat{X}.NdotV=coatGeoInfo.NdotV;
870
+ #ifdef SPOTLIGHT{X}
871
+ #ifdef LIGHT_FALLOFF_GLTF{X}
872
+ preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);
873
+ #ifdef IESLIGHTTEXTURE{X}
874
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
875
+ #else
876
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
877
+ #endif
878
+ #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
879
+ preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);
880
+ #ifdef IESLIGHTTEXTURE{X}
881
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
882
+ #else
883
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w);
884
+ #endif
885
+ #elif defined(LIGHT_FALLOFF_STANDARD{X})
886
+ preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);
887
+ #ifdef IESLIGHTTEXTURE{X}
888
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
889
+ #else
890
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
891
+ #endif
892
+ #else
893
+ preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
894
+ #ifdef IESLIGHTTEXTURE{X}
895
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
896
+ #else
897
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
898
+ #endif
899
+ #endif
900
+ #elif defined(POINTLIGHT{X})
901
+ #ifdef LIGHT_FALLOFF_GLTF{X}
902
+ preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);
903
+ #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
904
+ preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);
905
+ #elif defined(LIGHT_FALLOFF_STANDARD{X})
906
+ preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);
907
+ #else
908
+ preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
909
+ #endif
910
+ #else
911
+ preInfo{X}.attenuation=1.0f;
912
+ #endif
913
+ preInfoCoat{X}.attenuation=preInfo{X}.attenuation;
914
+ #if defined(HEMILIGHT{X})
915
+ preInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;
916
+ #elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
917
+ preInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;
918
+ #else
919
+ preInfo{X}.roughness=adjustRoughnessFromLightProperties(specular_roughness,light{X}.vLightSpecular.a,preInfo{X}.lightDistance);preInfoCoat{X}.roughness=adjustRoughnessFromLightProperties(coat_roughness,light{X}.vLightSpecular.a,preInfoCoat{X}.lightDistance);
920
+ #endif
921
+ preInfo{X}.diffuseRoughness=base_diffuse_roughness;preInfo{X}.surfaceAlbedo=base_color.rgb;
922
+ #endif
923
+ #endif
924
+ `;
925
+ e.IncludesShadersStoreWGSL[v] || (e.IncludesShadersStoreWGSL[v] = y);
926
+ const E = "openpbrDirectLighting", z = `#ifdef LIGHT{X}
927
+ {var slab_diffuse: vec3f=vec3f(0.f,0.f,0.f);var slab_translucent: vec3f=vec3f(0.f,0.f,0.f);var slab_glossy: vec3f=vec3f(0.f,0.f,0.f);var specularFresnel: f32=0.0f;var specularColoredFresnel: vec3f=vec3f(0.f,0.f,0.f);var slab_metal: vec3f=vec3f(0.f,0.f,0.f);var slab_coat: vec3f=vec3f(0.f,0.f,0.f);var coatFresnel: f32=0.0f;var slab_fuzz: vec3f=vec3f(0.f,0.f,0.f);var fuzzFresnel: f32=0.0f;
928
+ #ifdef HEMILIGHT{X}
929
+ slab_diffuse=computeHemisphericDiffuseLighting(preInfo{X},lightColor{X}.rgb,light{X}.vLightGround);
930
+ #elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
931
+ slab_diffuse=computeAreaDiffuseLighting(preInfo{X},lightColor{X}.rgb);
932
+ #else
933
+ slab_diffuse=computeDiffuseLighting(preInfo{X},lightColor{X}.rgb);
934
+ #endif
935
+ #ifdef PROJECTEDLIGHTTEXTURE{X}
936
+ slab_diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},fragmentInputs.vPositionW);
937
+ #endif
938
+ #ifdef FUZZ
939
+ let fuzzNdotH: f32=max(dot(fuzzNormalW,preInfo{X}.H),0.0f);let fuzzBrdf: vec3f=getFuzzBRDFLookup(fuzzNdotH,sqrt(fuzz_roughness));
940
+ #endif
941
+ #ifdef THIN_FILM
942
+ let thin_film_desaturation_scale: f32=(thin_film_ior-1.0f)*sqrt(thin_film_thickness*0.001f);
943
+ #endif
944
+ #if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
945
+ slab_glossy=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);
946
+ #else
947
+ {
948
+ #ifdef ANISOTROPIC_BASE
949
+ slab_glossy=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,
950
+ baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,
951
+ 0.0f,lightColor{X}.rgb);
952
+ #else
953
+ slab_glossy=computeSpecularLighting(preInfo{X},normalW,vec3(1.0),vec3(1.0),specular_roughness,lightColor{X}.rgb);
954
+ #endif
955
+ specularFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseDielectricReflectance.F0,baseDielectricReflectance.F90);specularColoredFresnel=specularFresnel*specular_color;
956
+ #ifdef THIN_FILM
957
+ var thinFilmDielectricFresnel: vec3f=evalIridescence(thin_film_outside_ior,thin_film_ior,preInfo{X}.VdotH,thin_film_thickness,vec3f(baseDielectricReflectance.F0));thinFilmDielectricFresnel=mix(thinFilmDielectricFresnel,vec3f(dot(thinFilmDielectricFresnel,vec3f(0.3333f))),thin_film_desaturation_scale);specularColoredFresnel=mix(specularColoredFresnel,thinFilmDielectricFresnel*specular_color,thin_film_weight*thin_film_ior_scale);
958
+ #endif
959
+ }
960
+ #endif
961
+ #ifdef REFRACTED_LIGHTS
962
+ var forwardScatteredLight: vec3f=vec3f(0.0f);
963
+ #if AREALIGHT{X}
964
+ #else
965
+ {var preInfoTrans=preInfo{X};
966
+ #ifdef SCATTERING
967
+ preInfoTrans.roughness=sqrt(sqrt(max(transmission_roughness_alpha,0.05f)));
968
+ #else
969
+ preInfoTrans.roughness=transmission_roughness;
970
+ #endif
971
+ if (preInfoTrans.NdotLUnclamped<=0.0) {specularFresnel=0.0;specularColoredFresnel=specularFresnel*specular_color;}
972
+ #ifdef GEOMETRY_THIN_WALLED
973
+ let refractNormalW: vec3f=viewDirectionW;
974
+ #else
975
+ let refractNormalW: vec3f=normalW;
976
+ #endif
977
+ preInfoTrans.NdotL=0.5f*max(dot(-refractNormalW,preInfoTrans.L),0.0f)+0.5f;
978
+ #if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)
979
+ var dispersion_iors_local: vec3f=dispersion_iors;let diff: f32=min(dispersion_iors_local[2]-dispersion_iors_local[0],max(dispersion_iors_local[0]-1.0f,1.0f));dispersion_iors_local[2]+=diff;dispersion_iors_local[0]-=diff;for (var i: i32=0; i<3; i++) {let eta: f32=1.0f/dispersion_iors_local[i];
980
+ #elif defined(GEOMETRY_THIN_WALLED)
981
+ let eta: f32=1.0f;
982
+ #else
983
+ let eta: f32=1.0f/specular_ior;
984
+ #endif
985
+ preInfoTrans.H=preInfoTrans.L+min(eta,0.95f)*viewDirectionW;let len2: f32=dot(preInfoTrans.H,preInfoTrans.H);if (len2<1e-6f) {preInfoTrans.H=preInfoTrans.L;} else {preInfoTrans.H=preInfoTrans.H*inverseSqrt(len2);}
986
+ #ifdef ANISOTROPIC_BASE
987
+ preInfoTrans.H=-preInfoTrans.H;
988
+ #endif
989
+ preInfoTrans.VdotH=dot(viewDirectionW,preInfoTrans.H);
990
+ #if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)
991
+ forwardScatteredLight[i]+=
992
+ #else
993
+ forwardScatteredLight+=
994
+ #endif
995
+ #if defined(ANISOTROPIC_BASE)
996
+ computeAnisotropicSpecularLighting(preInfoTrans,viewDirectionW,refractNormalW,
997
+ baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,
998
+ transmission_roughness_alpha,lightColor{X}.rgb
999
+ #else
1000
+ computeSpecularLighting(preInfoTrans,-refractNormalW,vec3f(1.0f),vec3f(1.0f),transmission_roughness_alpha,lightColor{X}.rgb
1001
+ #endif
1002
+ #if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)
1003
+ )[i];}
1004
+ #else
1005
+ );
1006
+ #endif
1007
+ #if !defined(GEOMETRY_THIN_WALLED)
1008
+ forwardScatteredLight=mix(forwardScatteredLight,0.25f*preInfoTrans.attenuation*lightColor{X}.rgb,clamp(1.0f-pow(baseGeoInfo.NdotV,transmission_roughness_alpha),0.0f,1.0f));
1009
+ #endif
1010
+ #ifdef REFRACTED_BACKGROUND
1011
+ #ifdef GEOMETRY_THIN_WALLED
1012
+ forwardScatteredLight=mix(vec3f(0.0f),forwardScatteredLight.rgb,0.2*transmission_roughness_alpha);
1013
+ #else
1014
+ forwardScatteredLight=max(vec3f(0.0f),mix(vec3f(0.0f),forwardScatteredLight,transmission_roughness_alpha));
1015
+ #endif
1016
+ #endif
1017
+ #ifdef SCATTERING
1018
+ #if !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER)
1019
+ preInfoTrans.roughness=1.0f;let diffused_forward_scattered_light: vec3f=computeSpecularLighting(preInfoTrans,normalW,vec3f(1.0f),vec3f(1.0f),1.0f,lightColor{X}.rgb)*volume_absorption;
1020
+ #endif
1021
+ #ifdef GEOMETRY_THIN_WALLED
1022
+ let forward_scattered_light: vec3f=forwardScatteredLight*transmission_tint*volumeParams.multi_scatter_color;let back_scattered_light: vec3f=slab_diffuse*volumeParams.multi_scatter_color;slab_translucent=mix(back_scattered_light,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy);
1023
+ #else
1024
+ let back_scattered_normal: vec3f=normalize(normalW+viewDirectionW);preInfoTrans.NdotL=max(dot(back_scattered_normal,preInfoTrans.L),0.0f);preInfoTrans.NdotV=dot(back_scattered_normal,viewDirectionW);preInfoTrans.H=normalize(viewDirectionW+preInfoTrans.L);preInfoTrans.VdotH=clamp(dot(viewDirectionW,preInfoTrans.H),0.0f,1.0f);preInfoTrans.roughness=0.2f;let back_scattered_light: vec3f=computeSpecularLighting(preInfoTrans,viewDirectionW,vec3f(1.0f),vec3f(0.08f),0.0f,lightColor{X}.rgb);let forward_scattered_light: vec3f=(forwardScatteredLight*volume_absorption);let iso_scattered_light: vec3f=slab_diffuse;let back_scattering: vec3f=mix(forward_scattered_light,forward_scattered_light+back_scattered_light*backscatter_color,iso_scatter_density);
1025
+ #if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER)
1026
+ let iso_scattering: vec3f=mix(forward_scattered_light,scattered_light_from_irradiance_texture*volumeParams.multi_scatter_color,iso_scatter_density);
1027
+ #else
1028
+ let iso_scattering: vec3f=mix(forward_scattered_light,(diffused_forward_scattered_light+iso_scattered_light)*volumeParams.multi_scatter_color,iso_scatter_density);
1029
+ #endif
1030
+ slab_translucent=mix(back_scattering,iso_scattering,back_to_iso_scattering_blend);slab_translucent=mix(slab_translucent,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;
1031
+ #endif
1032
+ #else
1033
+ slab_translucent=forwardScatteredLight*transmission_tint*volume_absorption;
1034
+ #endif
1035
+ }
1036
+ #endif
1037
+ #endif
1038
+ #if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1039
+ slab_metal=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);
1040
+ #else
1041
+ {
1042
+ #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
1043
+ var coloredFresnel: vec3f=getF82Specular(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90,specular_roughness);
1044
+ #else
1045
+ var coloredFresnel: vec3f=fresnelSchlickGGX(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);
1046
+ #endif
1047
+ #ifdef THIN_FILM
1048
+ let thinFilmConductorAngle: f32=max(preInfo{X}.VdotH,specular_roughness);var thinFilmConductorFresnel: vec3f=evalIridescence(thin_film_outside_ior,thin_film_ior,thinFilmConductorAngle,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorFresnel=mix(thinFilmConductorFresnel,vec3f(dot(thinFilmConductorFresnel,vec3f(0.3333f))),thin_film_desaturation_scale);coloredFresnel=mix(coloredFresnel,specular_weight*thinFilmConductorFresnel,thin_film_weight*thin_film_ior_scale);
1049
+ #endif
1050
+ #ifdef ANISOTROPIC_BASE
1051
+ slab_metal=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,0.0,lightColor{X}.rgb);
1052
+ #else
1053
+ slab_metal=computeSpecularLighting(preInfo{X},normalW,vec3f(baseConductorReflectance.coloredF0),coloredFresnel,specular_roughness,lightColor{X}.rgb);
1054
+ #endif
1055
+ }
1056
+ #endif
1057
+ #if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1058
+ slab_coat=computeAreaSpecularLighting(preInfoCoat{X},light{X}.vLightSpecular.rgb,coatReflectance.F0,coatReflectance.F90);
1059
+ #else
1060
+ {
1061
+ #ifdef ANISOTROPIC_COAT
1062
+ slab_coat=computeAnisotropicSpecularLighting(preInfoCoat{X},viewDirectionW,coatNormalW,
1063
+ coatGeoInfo.anisotropicTangent,coatGeoInfo.anisotropicBitangent,coatGeoInfo.anisotropy,0.0,
1064
+ lightColor{X}.rgb);
1065
+ #else
1066
+ slab_coat=computeSpecularLighting(preInfoCoat{X},coatNormalW,vec3f(coatReflectance.F0),vec3f(1.0f),coat_roughness,lightColor{X}.rgb);
1067
+ #endif
1068
+ let NdotH: f32=saturateEps(dot(coatNormalW,preInfoCoat{X}.H));coatFresnel=fresnelSchlickGGX(NdotH,coatReflectance.F0,coatReflectance.F90);}
1069
+ #endif
1070
+ var coatAbsorption=vec3f(1.0f);if (coat_weight>0.0) {let cosTheta_view: f32=max(preInfoCoat{X}.NdotV,0.001f);let cosTheta_light: f32=max(preInfoCoat{X}.NdotL,0.001f);let fresnel_view: f32=coatReflectance.F0+(1.0f-coatReflectance.F0)*pow(1.0f-cosTheta_view,5.0);let fresnel_light: f32=coatReflectance.F0+(1.0f-coatReflectance.F0)*pow(1.0f-cosTheta_light,5.0);let averageReflectance: f32=(fresnel_view+fresnel_light)*0.5;var darkened_transmission: f32=(1.0f-averageReflectance)/(1.0f+averageReflectance);darkened_transmission=mix(1.0f,darkened_transmission,coat_darkening);var sin2: f32=1.0f-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior)*coat_weight;let cos_t: f32=sqrt(1.0f-sin2);let coatPathLength=1.0f/cos_t;let effectivePathLength=coatPathLength*coat_weight;let colored_transmission: vec3f=pow(coat_color,vec3f(effectivePathLength));coatAbsorption=colored_transmission*mix(1.0f,darkened_transmission,coat_weight);}
1071
+ #ifdef FUZZ
1072
+ fuzzFresnel=fuzzBrdf.z;let fuzzNormalW=mix(normalW,coatNormalW,coat_weight);let fuzzNdotV: f32=max(dot(fuzzNormalW,viewDirectionW.xyz),0.0f);let fuzzNdotL: f32=max(dot(fuzzNormalW,preInfo{X}.L),0.0);slab_fuzz=lightColor{X}.rgb*preInfo{X}.attenuation*evalFuzz(preInfo{X}.L,fuzzNdotL,fuzzNdotV,fuzzTangent,fuzzBitangent,fuzzBrdf);
1073
+ #else
1074
+ let fuzz_color=vec3f(0.0);
1075
+ #endif
1076
+ #ifdef PREPASS_IRRADIANCE
1077
+ total_direct_diffuse+=slab_diffuse;
1078
+ #endif
1079
+ let material_dielectric_base: vec3f=mix(slab_diffuse*base_color.rgb,slab_translucent,surface_translucency_weight);let material_dielectric_gloss: vec3f=material_dielectric_base*(1.0f-specularFresnel)+slab_glossy*specularColoredFresnel;let material_base_substrate: vec3f=mix(material_dielectric_gloss,slab_metal,base_metalness);let material_coated_base: vec3f=layer(material_base_substrate,slab_coat,coatFresnel,coatAbsorption,vec3f(1.0f));material_surface_direct+=layer(material_coated_base,slab_fuzz,fuzzFresnel*fuzz_weight,vec3f(1.0f),fuzz_color);}
1080
+ #endif
1081
+ `;
1082
+ e.IncludesShadersStoreWGSL[E] || (e.IncludesShadersStoreWGSL[E] = z);
1083
+ const S = "openpbrBlockPrePass", W = `#if SCENE_MRT_COUNT>0
1084
+ var writeGeometryInfo: f32=select(0.0,1.0,finalColor.a>ALPHATESTVALUE);var fragData: array<vec4<f32>,SCENE_MRT_COUNT>;
1085
+ #ifdef PREPASS_POSITION
1086
+ fragData[PREPASS_POSITION_INDEX]= vec4f(fragmentInputs.vPositionW,writeGeometryInfo);
1087
+ #endif
1088
+ #ifdef PREPASS_LOCAL_POSITION
1089
+ fragData[PREPASS_LOCAL_POSITION_INDEX]=vec4f(fragmentInputs.vPosition,writeGeometryInfo);
1090
+ #endif
1091
+ #ifdef PREPASS_VELOCITY
1092
+ 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);
1093
+ #elif defined(PREPASS_VELOCITY_LINEAR)
1094
+ var velocity : vec2f=vec2f(0.5)*((fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w) -
1095
+ (fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w));fragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4f(velocity,0.0,writeGeometryInfo);
1096
+ #endif
1097
+ #ifdef PREPASS_ALBEDO
1098
+ fragData[PREPASS_ALBEDO_INDEX]=vec4f(surfaceAlbedo,writeGeometryInfo);
1099
+ #endif
1100
+ #ifdef PREPASS_ALBEDO_SQRT
1101
+ var sqAlbedo : vec3f=sqrt(surfaceAlbedo);
1102
+ #endif
1103
+ #ifdef PREPASS_IRRADIANCE
1104
+ var irradiance : vec3f=total_direct_diffuse;
1105
+ #ifndef UNLIT
1106
+ #ifdef REFLECTION
1107
+ irradiance+=slab_diffuse_ibl;
1108
+ #endif
1109
+ #endif
1110
+ #ifdef SCATTERING
1111
+ let scatter_mask: f32=min(subsurface_weight+transmission_weight,1.0);
1112
+ #else
1113
+ let scatter_mask: f32=0.0;
1114
+ #endif
1115
+ fragData[PREPASS_IRRADIANCE_INDEX]=vec4f(irradiance,writeGeometryInfo*scatter_mask);
1116
+ #elif defined(PREPASS_COLOR)
1117
+ fragData[PREPASS_COLOR_INDEX]=vec4f(finalColor.rgb,finalColor.a);
1118
+ #endif
1119
+ #ifdef PREPASS_DEPTH
1120
+ fragData[PREPASS_DEPTH_INDEX]=vec4f(fragmentInputs.vViewPos.z,0.0,0.0,writeGeometryInfo);
1121
+ #endif
1122
+ #ifdef PREPASS_SCREENSPACE_DEPTH
1123
+ fragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4f(fragmentInputs.position.z,0.0,0.0,writeGeometryInfo);
1124
+ #endif
1125
+ #ifdef PREPASS_NORMALIZED_VIEW_DEPTH
1126
+ fragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4f(fragmentInputs.vNormViewDepth,0.0,0.0,writeGeometryInfo);
1127
+ #endif
1128
+ #ifdef PREPASS_NORMAL
1129
+ #ifdef PREPASS_NORMAL_WORLDSPACE
1130
+ fragData[PREPASS_NORMAL_INDEX]=vec4f(normalW,writeGeometryInfo);
1131
+ #else
1132
+ fragData[PREPASS_NORMAL_INDEX]=vec4f(normalize((scene.view*vec4f(normalW,0.0)).rgb),writeGeometryInfo);
1133
+ #endif
1134
+ #endif
1135
+ #ifdef PREPASS_WORLD_NORMAL
1136
+ fragData[PREPASS_WORLD_NORMAL_INDEX]=vec4f(normalW*0.5+0.5,writeGeometryInfo);
1137
+ #endif
1138
+ #ifdef PREPASS_ALBEDO_SQRT
1139
+ fragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4f(sqAlbedo,writeGeometryInfo);
1140
+ #endif
1141
+ #ifdef PREPASS_REFLECTIVITY
1142
+ #ifndef UNLIT
1143
+ fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(specularEnvironmentR0,microSurface)*writeGeometryInfo;
1144
+ #else
1145
+ fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(0.0,0.0,0.0,1.0)*writeGeometryInfo;
1146
+ #endif
1147
+ #endif
1148
+ #if SCENE_MRT_COUNT>0
1149
+ fragmentOutputs.fragData0=fragData[0];
1150
+ #endif
1151
+ #if SCENE_MRT_COUNT>1
1152
+ fragmentOutputs.fragData1=fragData[1];
1153
+ #endif
1154
+ #if SCENE_MRT_COUNT>2
1155
+ fragmentOutputs.fragData2=fragData[2];
1156
+ #endif
1157
+ #if SCENE_MRT_COUNT>3
1158
+ fragmentOutputs.fragData3=fragData[3];
1159
+ #endif
1160
+ #if SCENE_MRT_COUNT>4
1161
+ fragmentOutputs.fragData4=fragData[4];
1162
+ #endif
1163
+ #if SCENE_MRT_COUNT>5
1164
+ fragmentOutputs.fragData5=fragData[5];
1165
+ #endif
1166
+ #if SCENE_MRT_COUNT>6
1167
+ fragmentOutputs.fragData6=fragData[6];
1168
+ #endif
1169
+ #if SCENE_MRT_COUNT>7
1170
+ fragmentOutputs.fragData7=fragData[7];
1171
+ #endif
1172
+ #endif
1173
+ `;
1174
+ e.IncludesShadersStoreWGSL[S] || (e.IncludesShadersStoreWGSL[S] = W);
1175
+ const r = "openpbrPixelShader", h = `#define OPENPBR_FRAGMENT_SHADER
1176
+ #define CUSTOM_FRAGMENT_BEGIN
1177
+ #include<prePassDeclaration>[SCENE_MRT_COUNT]
1178
+ #include<oitDeclaration>
1179
+ #ifndef FROMLINEARSPACE
1180
+ #define FROMLINEARSPACE
1181
+ #endif
1182
+ #include<openpbrUboDeclaration>
1183
+ #include<pbrFragmentExtraDeclaration>
1184
+ #include<lightUboDeclaration>[0..maxSimultaneousLights]
1185
+ #include<openpbrFragmentSamplersDeclaration>
1186
+ #include<imageProcessingDeclaration>
1187
+ #include<clipPlaneFragmentDeclaration>
1188
+ #include<logDepthDeclaration>
1189
+ #include<fogFragmentDeclaration>
1190
+ #include<textureRepetitionFunctions>
1191
+ #include<helperFunctions>
1192
+ #include<subSurfaceScatteringFunctions>
1193
+ #include<importanceSampling>
1194
+ #include<pbrHelperFunctions>
1195
+ #include<imageProcessingFunctions>
1196
+ #include<shadowsFragmentFunctions>
1197
+ #include<harmonicsFunctions>
1198
+ #include<pbrDirectLightingSetupFunctions>
1199
+ #include<pbrDirectLightingFalloffFunctions>
1200
+ #include<pbrBRDFFunctions>
1201
+ #include<hdrFilteringFunctions>
1202
+ #include<pbrDirectLightingFunctions>
1203
+ #include<pbrIBLFunctions>
1204
+ #include<openpbrNormalMapFragmentMainFunctions>
1205
+ #include<openpbrNormalMapFragmentFunctions>
1206
+ #ifdef REFLECTION
1207
+ #include<reflectionFunction>
1208
+ #endif
1209
+ #define CUSTOM_FRAGMENT_DEFINITIONS
1210
+ #include<openpbrDielectricReflectance>
1211
+ #include<openpbrConductorReflectance>
1212
+ #include<openpbrAmbientOcclusionFunctions>
1213
+ #include<openpbrGeometryInfo>
1214
+ #include<openpbrIblFunctions>
1215
+ #include<openpbrVolumeFunctions>
1216
+ fn layer(slab_bottom: vec3f,slab_top: vec3f,lerp_factor: f32,bottom_multiplier: vec3f,top_multiplier: vec3f)->vec3f {return mix(slab_bottom*bottom_multiplier,slab_top*top_multiplier,lerp_factor);}
1217
+ @fragment
1218
+ fn main(input: FragmentInputs)->FragmentOutputs {
1219
+ #ifdef PREPASS_IRRADIANCE
1220
+ var total_direct_diffuse: vec3f=vec3f(0.0f);
1221
+ #endif
1222
+ #define CUSTOM_FRAGMENT_MAIN_BEGIN
1223
+ #include<clipPlaneFragment>
1224
+ #include<pbrBlockNormalGeometric>
1225
+ var coatNormalW: vec3f=normalW;
1226
+ #include<openpbrNormalMapFragment>
1227
+ #include<openpbrBlockNormalFinal>
1228
+ #include<openpbrBaseLayerData>
1229
+ #include<openpbrTransmissionLayerData>
1230
+ #include<openpbrSubsurfaceLayerData>
1231
+ #include<openpbrCoatLayerData>
1232
+ #include<openpbrThinFilmLayerData>
1233
+ #include<openpbrFuzzLayerData>
1234
+ #include<openpbrAmbientOcclusionData>
1235
+ #define CUSTOM_FRAGMENT_UPDATE_ALPHA
1236
+ #include<depthPrePass>
1237
+ #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
1238
+ #ifdef ANISOTROPIC_COAT
1239
+ let coatGeoInfo: geometryInfoAnisoOutParams=geometryInfoAniso(
1240
+ coatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW
1241
+ ,vec3f(geometry_coat_tangent.x,geometry_coat_tangent.y,coat_roughness_anisotropy),TBN
1242
+ );
1243
+ #else
1244
+ let coatGeoInfo: geometryInfoOutParams=geometryInfo(
1245
+ coatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW
1246
+ );
1247
+ #endif
1248
+ specular_roughness=mix(specular_roughness,pow(min(1.0f,pow(specular_roughness,4.0f)+2.0f*pow(coat_roughness,4.0f)),0.25f),coat_weight);
1249
+ #ifdef ANISOTROPIC_BASE
1250
+ let baseGeoInfo: geometryInfoAnisoOutParams=geometryInfoAniso(
1251
+ normalW,viewDirectionW.xyz,specular_roughness,geometricNormalW
1252
+ ,vec3f(geometry_tangent.x,geometry_tangent.y,specular_roughness_anisotropy),TBN
1253
+ );
1254
+ #else
1255
+ let baseGeoInfo: geometryInfoOutParams=geometryInfo(
1256
+ normalW,viewDirectionW.xyz,specular_roughness,geometricNormalW
1257
+ );
1258
+ #endif
1259
+ #ifdef FUZZ
1260
+ let fuzzNormalW=normalize(mix(normalW,coatNormalW,coat_weight));var fuzzTangent=normalize(TBN[0]);fuzzTangent=normalize(fuzzTangent-dot(fuzzTangent,fuzzNormalW)*fuzzNormalW);let fuzzBitangent=cross(fuzzNormalW,fuzzTangent);let fuzzGeoInfo: geometryInfoOutParams=geometryInfo(
1261
+ fuzzNormalW,viewDirectionW.xyz,fuzz_roughness,geometricNormalW
1262
+ );
1263
+ #endif
1264
+ let coatReflectance: ReflectanceParams=dielectricReflectance(
1265
+ coat_ior
1266
+ ,1.0f
1267
+ ,vec3f(1.0f)
1268
+ ,coat_weight
1269
+ );
1270
+ #ifdef THIN_FILM
1271
+ let thin_film_outside_ior: f32=mix(1.0f,coat_ior,coat_weight);
1272
+ #endif
1273
+ let baseDielectricReflectance: ReflectanceParams=dielectricReflectance(
1274
+ specular_ior
1275
+ ,mix(1.0f,coat_ior,coat_weight)
1276
+ ,specular_color
1277
+ ,specular_weight
1278
+ );let baseConductorReflectance: ReflectanceParams=conductorReflectance(base_color,specular_color,specular_weight);var volume_absorption: vec3f=vec3f(1.0f);var transmission_tint: vec3f=vec3f(1.0f);var surface_translucency_weight: f32=0.0f;
1279
+ #if defined(REFRACTED_BACKGROUND) || defined(REFRACTED_ENVIRONMENT) || defined(REFRACTED_LIGHTS)
1280
+ #if defined(GEOMETRY_THIN_WALLED)
1281
+ let refractedViewVector: vec3f=-viewDirectionW;
1282
+ #else
1283
+ #ifdef DISPERSION
1284
+ var refractedViewVectors: array<vec3f,3>;let iorDispersionSpread: f32=transmission_dispersion_scale/transmission_dispersion_abbe_number*(specular_ior-1.0f);let dispersion_iors: vec3f=vec3f(specular_ior-iorDispersionSpread,specular_ior,specular_ior+iorDispersionSpread);for (var i: i32=0; i<3; i++) {refractedViewVectors[i]=double_refract(-viewDirectionW,normalW,dispersion_iors[i]); }
1285
+ #else
1286
+ let refractedViewVector: vec3f=double_refract(-viewDirectionW,normalW,specular_ior);
1287
+ #endif
1288
+ #endif
1289
+ #ifdef GEOMETRY_THIN_WALLED
1290
+ var transmission_roughness: f32=specular_roughness;
1291
+ #else
1292
+ var transmission_roughness: f32=specular_roughness*clamp(4.0f*(specular_ior-1.0f),0.001f,1.0f);
1293
+ #endif
1294
+ #if (defined(TRANSMISSION_SLAB) || defined(SUBSURFACE_SLAB))
1295
+ var volumeParams: OpenPBRHomogeneousVolume;{
1296
+ #if defined(TRANSMISSION_SLAB)
1297
+ let transmissionVolumeParams: OpenPBRHomogeneousVolume=computeOpenPBRTransmissionVolume(
1298
+ transmission_color.rgb,
1299
+ transmission_depth,
1300
+ transmission_scatter.rgb,
1301
+ transmission_scatter_anisotropy
1302
+ );
1303
+ #endif
1304
+ #if defined(SUBSURFACE_SLAB)
1305
+ let subsurfaceVolumeParams: OpenPBRHomogeneousVolume=computeOpenPBRSubsurfaceVolume(
1306
+ subsurface_color.rgb,
1307
+ subsurface_radius,
1308
+ subsurface_radius_scale.rgb,
1309
+ subsurface_scatter_anisotropy
1310
+ );
1311
+ #endif
1312
+ #if !defined(TRANSMISSION_SLAB)
1313
+ volumeParams=subsurfaceVolumeParams;surface_translucency_weight=subsurface_weight;
1314
+ #elif !defined(SUBSURFACE_SLAB)
1315
+ volumeParams=transmissionVolumeParams;
1316
+ #ifdef TRANSMISSION_SLAB_VOLUME
1317
+ volumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);
1318
+ #endif
1319
+ surface_translucency_weight=transmission_weight;
1320
+ #else
1321
+ let subsurface_fraction_of_dielectric: f32=(1.0f-transmission_weight)*subsurface_weight;let subsurface_and_transmission_fraction_of_dielectric: f32=subsurface_fraction_of_dielectric+transmission_weight;let reciprocal_of_subsurface_and_transmission_fraction_of_dielectric: f32 =
1322
+ 1.0f/maxEps(subsurface_and_transmission_fraction_of_dielectric);let trans_weight: f32=transmission_weight*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;let subsurf_weight: f32=subsurface_fraction_of_dielectric*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;volumeParams.scatter_coeff=transmissionVolumeParams.scatter_coeff*trans_weight+subsurfaceVolumeParams.scatter_coeff*subsurf_weight;volumeParams.absorption_coeff=transmissionVolumeParams.absorption_coeff*trans_weight+subsurfaceVolumeParams.absorption_coeff*subsurf_weight;volumeParams.anisotropy=(transmissionVolumeParams.anisotropy*trans_weight+subsurfaceVolumeParams.anisotropy*subsurf_weight)/maxEps(trans_weight+subsurf_weight);volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=volumeParams.scatter_coeff/maxEpsVec3(volumeParams.extinction_coeff);volumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);surface_translucency_weight=subsurface_and_transmission_fraction_of_dielectric;
1323
+ #endif
1324
+ }
1325
+ volume_absorption=exp(-volumeParams.absorption_coeff*geometry_thickness);var backscatter_color: vec3f=vec3f(1.0f);{let reduced_scatter: vec3f=volumeParams.scatter_coeff*vec3f(1.0f-volumeParams.anisotropy);let reduced_albedo: vec3f=reduced_scatter/(volumeParams.absorption_coeff+reduced_scatter);let sqrt_term: vec3f=max(sqrt(vec3f(1.0f)-reduced_albedo),vec3f(0.0001f));backscatter_color=(vec3f(1.0f)-sqrt_term)/(vec3f(1.0f)+sqrt_term);}
1326
+ #elif defined(TRANSMISSION_SLAB)
1327
+ surface_translucency_weight=transmission_weight;
1328
+ #endif
1329
+ #ifdef SCATTERING
1330
+ #ifdef GEOMETRY_THIN_WALLED
1331
+ var iso_scatter_density: vec3f=vec3f(1.0f);
1332
+ #else
1333
+ #ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING
1334
+ let mfp: vec3f=vec3f(100.0f)/volumeParams.extinction_coeff;var scattered_light_from_irradiance_texture: vec3f=sss_convolve(sceneIrradianceSampler,sceneDepthSampler,uniforms.renderTargetSize,mfp,scene.projection,scene.inverseProjection,SSS_SAMPLE_COUNT,noise.xy);var numLights=f32(LIGHTCOUNT);
1335
+ #ifdef REFLECTION
1336
+ numLights+=1.0f;
1337
+ #endif
1338
+ scattered_light_from_irradiance_texture/=vec3f(numLights);
1339
+ #else
1340
+ let scattered_light_from_irradiance_texture: vec3f=vec3f(0.0f);
1341
+ #endif
1342
+ let back_to_iso_scattering_blend: f32=min(1.0f+volumeParams.anisotropy,1.0f);let iso_to_forward_scattering_blend: f32=max(volumeParams.anisotropy,0.0f);let iso_scatter_transmittance: vec3f=pow(exp(-volumeParams.scatter_coeff*geometry_thickness),vec3f(0.2f));var iso_scatter_density: vec3f=clamp(vec3f(1.0f)-iso_scatter_transmittance,vec3f(0.0f),vec3f(1.0f));transmission_roughness=min(transmission_roughness+pow((1.0f-abs(volumeParams.anisotropy))*max3(iso_scatter_density*iso_scatter_density),3.0f),1.0f);
1343
+ #endif
1344
+ volumeParams.multi_scatter_color=mix(volumeParams.ss_albedo,volumeParams.multi_scatter_color,max3(iso_scatter_density));
1345
+ #endif
1346
+ #if defined(TRANSMISSION_SLAB) && (!defined(TRANSMISSION_SLAB_VOLUME) || defined(GEOMETRY_THIN_WALLED))
1347
+ transmission_tint*=transmission_color.rgb;
1348
+ #ifdef GEOMETRY_THIN_WALLED
1349
+ var sin2: f32=1.0f-baseGeoInfo.NdotV*baseGeoInfo.NdotV;sin2=sin2/(specular_ior*specular_ior);let cos_t: f32=sqrt(1.0f-sin2);let pathLength: f32=1.0f/cos_t;transmission_tint=pow(transmission_tint,vec3f(pathLength));
1350
+ #else
1351
+ transmission_tint*=transmission_color.rgb;
1352
+ #endif
1353
+ #endif
1354
+ #if defined(SUBSURFACE_SLAB) && defined(GEOMETRY_THIN_WALLED)
1355
+ let unweighted_translucency: f32=max(mix(subsurface_weight,1.0f,transmission_weight),0.0001f);transmission_tint=mix(vec3f(1.0f),transmission_tint,transmission_weight/unweighted_translucency);transmission_roughness=mix(1.0f,transmission_roughness,transmission_weight/unweighted_translucency);
1356
+ #endif
1357
+ let transmission_roughness_alpha: f32=transmission_roughness*transmission_roughness;
1358
+ #endif
1359
+ #include<openpbrBackgroundTransmission>
1360
+ var material_surface_ibl: vec3f=vec3f(0.f,0.f,0.f);
1361
+ #include<openpbrEnvironmentLighting>
1362
+ var material_surface_direct: vec3f=vec3f(0.f,0.f,0.f);
1363
+ #if defined(LIGHT0)
1364
+ var aggShadow: f32=0.f;
1365
+ #include<openpbrDirectLightingInit>[0..maxSimultaneousLights]
1366
+ #include<openpbrDirectLighting>[0..maxSimultaneousLights]
1367
+ #endif
1368
+ var material_surface_emission: vec3f=uniforms.vEmissionColor;
1369
+ #ifdef EMISSION_COLOR
1370
+ let emissionColorTex: vec3f=textureSample(emissionColorSampler,emissionColorSamplerSampler,fragmentInputs.vEmissionColorUV+uvOffset).rgb;
1371
+ #ifdef EMISSION_COLOR_GAMMA
1372
+ material_surface_emission*=toLinearSpaceVec3(emissionColorTex.rgb);
1373
+ #else
1374
+ material_surface_emission*=emissionColorTex.rgb;
1375
+ #endif
1376
+ material_surface_emission*= uniforms.vEmissionColorInfos.y;
1377
+ #endif
1378
+ material_surface_emission*=uniforms.vLightingIntensity.y;
1379
+ #define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
1380
+ var finalColor: vec4f=vec4f(material_surface_ibl+material_surface_direct+material_surface_emission,alpha);
1381
+ #define CUSTOM_FRAGMENT_BEFORE_FOG
1382
+ finalColor=max(finalColor,vec4f(0.0));
1383
+ #include<logDepthFragment>
1384
+ #include<fogFragment>(color,finalColor)
1385
+ #include<pbrBlockImageProcessing>
1386
+ #define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
1387
+ #ifdef PREPASS
1388
+ #include<openpbrBlockPrePass>
1389
+ #endif
1390
+ #if !defined(PREPASS) && !defined(ORDER_INDEPENDENT_TRANSPARENCY)
1391
+ fragmentOutputs.color=finalColor;
1392
+ #endif
1393
+ #include<oitFragment>
1394
+ #if ORDER_INDEPENDENT_TRANSPARENCY
1395
+ 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;}
1396
+ #endif
1397
+ #include<pbrDebug>
1398
+ #define CUSTOM_FRAGMENT_MAIN_END
1399
+ }
1400
+ `;
1401
+ e.ShadersStoreWGSL[r] || (e.ShadersStoreWGSL[r] = h);
1402
+ const q = { name: r, shader: h };
1403
+ export {
1404
+ q as openpbrPixelShaderWGSL
1405
+ };