python-cad-tools 0.1.0rc1__py3-none-any.whl

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 (236) hide show
  1. python_cad_tools/__init__.py +10 -0
  2. python_cad_tools/_locking.py +63 -0
  3. python_cad_tools/_project_loader.py +273 -0
  4. python_cad_tools/_project_state.py +65 -0
  5. python_cad_tools/_scaffold.py +66 -0
  6. python_cad_tools/_transaction.py +208 -0
  7. python_cad_tools/_viewer_static/app.webmanifest +18 -0
  8. python_cad_tools/_viewer_static/asset-manifest.json +1 -0
  9. python_cad_tools/_viewer_static/assets/animationGroup-Sd34ntWg.js +1 -0
  10. python_cad_tools/_viewer_static/assets/bakedVertexAnimation-Cd_pRdrn.js +316 -0
  11. python_cad_tools/_viewer_static/assets/basisTextureLoader-DWgvS_1G.js +1 -0
  12. python_cad_tools/_viewer_static/assets/brdfTextureTools-CWGiG1W2.js +2 -0
  13. python_cad_tools/_viewer_static/assets/bumpFragment-CWULheF1.js +127 -0
  14. python_cad_tools/_viewer_static/assets/bumpVertex-DqzFZayE.js +6 -0
  15. python_cad_tools/_viewer_static/assets/bumpVertexDeclaration-C5EFyTio.js +6 -0
  16. python_cad_tools/_viewer_static/assets/clipPlaneFragment-BXRtt4jj.js +46 -0
  17. python_cad_tools/_viewer_static/assets/clipPlaneVertex-B_VhD1oQ.js +37 -0
  18. python_cad_tools/_viewer_static/assets/cubemapToSphericalPolynomial-DRpaukza.js +1 -0
  19. python_cad_tools/_viewer_static/assets/dds-Dkb2Cx2N.js +1 -0
  20. python_cad_tools/_viewer_static/assets/dds.pure-DtvJsKvY.js +1 -0
  21. python_cad_tools/_viewer_static/assets/ddsTextureLoader-H78xux1g.js +1 -0
  22. python_cad_tools/_viewer_static/assets/default.fragment-oSQ-tWhe.js +469 -0
  23. python_cad_tools/_viewer_static/assets/default.vertex-DhFjw_Da.js +209 -0
  24. python_cad_tools/_viewer_static/assets/defaultUboDeclaration-BMDHNppx.js +5 -0
  25. python_cad_tools/_viewer_static/assets/dumpTools-BaNZPjUX.js +2 -0
  26. python_cad_tools/_viewer_static/assets/envTextureLoader-V0YnLcIM.js +1 -0
  27. python_cad_tools/_viewer_static/assets/exrTextureLoader-CjGyIK3x.js +1 -0
  28. python_cad_tools/_viewer_static/assets/flowGraphApplyForceBlock-CW5nuobR.js +1 -0
  29. python_cad_tools/_viewer_static/assets/flowGraphApplyImpulseBlock-LFqYIkhj.js +1 -0
  30. python_cad_tools/_viewer_static/assets/flowGraphArrayIndexBlock-BMOHUbBm.js +1 -0
  31. python_cad_tools/_viewer_static/assets/flowGraphBezierCurveEasingBlock-knmTiuEk.js +1 -0
  32. python_cad_tools/_viewer_static/assets/flowGraphBinaryOperationBlock-DFLuCAKJ.js +1 -0
  33. python_cad_tools/_viewer_static/assets/flowGraphBranchBlock-BJRHMXMo.js +1 -0
  34. python_cad_tools/_viewer_static/assets/flowGraphCachedOperationBlock-Dng-6jE0.js +1 -0
  35. python_cad_tools/_viewer_static/assets/flowGraphCancelDelayBlock-CgbK3CQZ.js +1 -0
  36. python_cad_tools/_viewer_static/assets/flowGraphCodeExecutionBlock-8zMtq9tg.js +1 -0
  37. python_cad_tools/_viewer_static/assets/flowGraphConditionalDataBlock-BiLr2rkI.js +1 -0
  38. python_cad_tools/_viewer_static/assets/flowGraphConsoleLogBlock-J1vcCtNP.js +1 -0
  39. python_cad_tools/_viewer_static/assets/flowGraphConstantBlock-CFb5nuaV.js +1 -0
  40. python_cad_tools/_viewer_static/assets/flowGraphContextBlock-DAeGVzhC.js +1 -0
  41. python_cad_tools/_viewer_static/assets/flowGraphCounterBlock-lZlAQiJd.js +1 -0
  42. python_cad_tools/_viewer_static/assets/flowGraphDataSwitchBlock-BIzvmbVy.js +1 -0
  43. python_cad_tools/_viewer_static/assets/flowGraphDebounceBlock-DvNuMVwy.js +1 -0
  44. python_cad_tools/_viewer_static/assets/flowGraphDebugBlock-Dymd2VEE.js +1 -0
  45. python_cad_tools/_viewer_static/assets/flowGraphDoNBlock-v68aoNLH.js +1 -0
  46. python_cad_tools/_viewer_static/assets/flowGraphEasingBlock-CTnGv92q.js +1 -0
  47. python_cad_tools/_viewer_static/assets/flowGraphFlipFlopBlock-DXsO0Chw.js +1 -0
  48. python_cad_tools/_viewer_static/assets/flowGraphForLoopBlock-CPpe9T75.js +1 -0
  49. python_cad_tools/_viewer_static/assets/flowGraphFunctionReferenceBlock-DjDev4Pq.js +1 -0
  50. python_cad_tools/_viewer_static/assets/flowGraphGLTFDataProvider-GIYCz4AQ.js +1 -0
  51. python_cad_tools/_viewer_static/assets/flowGraphGetAngularVelocityBlock-BStkOVeL.js +1 -0
  52. python_cad_tools/_viewer_static/assets/flowGraphGetAssetBlock-Eiqoivbz.js +1 -0
  53. python_cad_tools/_viewer_static/assets/flowGraphGetLinearVelocityBlock-B0cpV5ws.js +1 -0
  54. python_cad_tools/_viewer_static/assets/flowGraphGetPhysicsMassPropertiesBlock-B-H64yaI.js +1 -0
  55. python_cad_tools/_viewer_static/assets/flowGraphGetPropertyBlock-CUyOsPw0.js +1 -0
  56. python_cad_tools/_viewer_static/assets/flowGraphGetSoundVolumeBlock-C0FjrsUz.js +1 -0
  57. python_cad_tools/_viewer_static/assets/flowGraphGetVariableBlock-O4597zBl.js +1 -0
  58. python_cad_tools/_viewer_static/assets/flowGraphIndexOfBlock-E00Z3KXM.js +1 -0
  59. python_cad_tools/_viewer_static/assets/flowGraphInterpolationBlock-DnkA9MNH.js +1 -0
  60. python_cad_tools/_viewer_static/assets/flowGraphIsKeyPressedBlock-DDfeuAyf.js +1 -0
  61. python_cad_tools/_viewer_static/assets/flowGraphIsSoundPlayingBlock-DMXg8jdM.js +1 -0
  62. python_cad_tools/_viewer_static/assets/flowGraphJsonPointerParserBlock-OmCorK0y.js +1 -0
  63. python_cad_tools/_viewer_static/assets/flowGraphKeyDownEventBlock-RuVtj6g2.js +1 -0
  64. python_cad_tools/_viewer_static/assets/flowGraphKeyUpEventBlock-DO4pAfHi.js +1 -0
  65. python_cad_tools/_viewer_static/assets/flowGraphKeyboardEventBlock-Bx3pAzzh.js +1 -0
  66. python_cad_tools/_viewer_static/assets/flowGraphMathBlocks-7W1XYOC8.js +1 -0
  67. python_cad_tools/_viewer_static/assets/flowGraphMathCombineExtractBlocks-a4f0Kv6e.js +1 -0
  68. python_cad_tools/_viewer_static/assets/flowGraphMatrixMathBlocks-C5Z-y1Au.js +1 -0
  69. python_cad_tools/_viewer_static/assets/flowGraphMeshPickEventBlock-D4m-I4CS.js +1 -0
  70. python_cad_tools/_viewer_static/assets/flowGraphMultiGateBlock-BISVSMw6.js +1 -0
  71. python_cad_tools/_viewer_static/assets/flowGraphPauseAnimationBlock-BYP2Z-HG.js +1 -0
  72. python_cad_tools/_viewer_static/assets/flowGraphPauseSoundBlock-Drh1EeW6.js +1 -0
  73. python_cad_tools/_viewer_static/assets/flowGraphPhysicsCollisionEventBlock-BoziAQ75.js +1 -0
  74. python_cad_tools/_viewer_static/assets/flowGraphPlayAnimationBlock-Clry-68M.js +1 -0
  75. python_cad_tools/_viewer_static/assets/flowGraphPlaySoundBlock-LbBVxGBE.js +1 -0
  76. python_cad_tools/_viewer_static/assets/flowGraphPointerDownEventBlock-DIVXCSHh.js +1 -0
  77. python_cad_tools/_viewer_static/assets/flowGraphPointerMoveEventBlock-BNNOzY2W.js +1 -0
  78. python_cad_tools/_viewer_static/assets/flowGraphPointerOutEventBlock-B8f2dOFT.js +1 -0
  79. python_cad_tools/_viewer_static/assets/flowGraphPointerOverEventBlock-CQr8LCee.js +1 -0
  80. python_cad_tools/_viewer_static/assets/flowGraphPointerUpEventBlock-DMg_iEHl.js +1 -0
  81. python_cad_tools/_viewer_static/assets/flowGraphReceiveCustomEventBlock-B8GJm9Ai.js +1 -0
  82. python_cad_tools/_viewer_static/assets/flowGraphSceneReadyEventBlock-Dcdb29K2.js +1 -0
  83. python_cad_tools/_viewer_static/assets/flowGraphSceneTickEventBlock-BLE5p4mi.js +1 -0
  84. python_cad_tools/_viewer_static/assets/flowGraphSendCustomEventBlock-BMzDItQ5.js +1 -0
  85. python_cad_tools/_viewer_static/assets/flowGraphSequenceBlock-DRURovjn.js +1 -0
  86. python_cad_tools/_viewer_static/assets/flowGraphSetAngularVelocityBlock-Ba8dhkLM.js +1 -0
  87. python_cad_tools/_viewer_static/assets/flowGraphSetDelayBlock-CnQR--Gn.js +1 -0
  88. python_cad_tools/_viewer_static/assets/flowGraphSetLinearVelocityBlock-Dm1r3vkh.js +1 -0
  89. python_cad_tools/_viewer_static/assets/flowGraphSetPhysicsMotionTypeBlock-BNtMLimi.js +1 -0
  90. python_cad_tools/_viewer_static/assets/flowGraphSetPropertyBlock-C-uv2jhP.js +1 -0
  91. python_cad_tools/_viewer_static/assets/flowGraphSetSoundVolumeBlock-D9LDx3lg.js +1 -0
  92. python_cad_tools/_viewer_static/assets/flowGraphSetVariableBlock-DszzRB5X.js +1 -0
  93. python_cad_tools/_viewer_static/assets/flowGraphSoundEndedEventBlock-DeTDSudb.js +1 -0
  94. python_cad_tools/_viewer_static/assets/flowGraphStopAnimationBlock-DWuwoFWr.js +1 -0
  95. python_cad_tools/_viewer_static/assets/flowGraphStopSoundBlock-DEnj2cQw.js +1 -0
  96. python_cad_tools/_viewer_static/assets/flowGraphSwitchBlock-zs8Fp9ky.js +1 -0
  97. python_cad_tools/_viewer_static/assets/flowGraphThrottleBlock-BYAKUQXd.js +1 -0
  98. python_cad_tools/_viewer_static/assets/flowGraphTransformCoordinatesSystemBlock-DYP54m5P.js +1 -0
  99. python_cad_tools/_viewer_static/assets/flowGraphTypeToTypeBlocks-vFwn79bS.js +1 -0
  100. python_cad_tools/_viewer_static/assets/flowGraphUnaryOperationBlock-CaRh4Ef0.js +1 -0
  101. python_cad_tools/_viewer_static/assets/flowGraphVectorMathBlocks-BEIhMs-A.js +1 -0
  102. python_cad_tools/_viewer_static/assets/flowGraphWaitAllBlock-DFbELP_j.js +1 -0
  103. python_cad_tools/_viewer_static/assets/flowGraphWhileLoopBlock-C1OKQ-_F.js +1 -0
  104. python_cad_tools/_viewer_static/assets/fogFragment-DtDlQBnz.js +25 -0
  105. python_cad_tools/_viewer_static/assets/gaussianSplatting-Cfigjb15.js +242 -0
  106. python_cad_tools/_viewer_static/assets/gaussianSplatting-DIn8R8oF.js +296 -0
  107. python_cad_tools/_viewer_static/assets/gaussianSplatting.fragment-BxeRJ2k-.js +38 -0
  108. python_cad_tools/_viewer_static/assets/gaussianSplatting.fragment-DNDmvRs-.js +37 -0
  109. python_cad_tools/_viewer_static/assets/gaussianSplatting.vertex-D92z5jYn.js +86 -0
  110. python_cad_tools/_viewer_static/assets/gaussianSplatting.vertex-DSWfFnKQ.js +86 -0
  111. python_cad_tools/_viewer_static/assets/gaussianSplattingVoxel.fragment-DBQE2gDk.js +12 -0
  112. python_cad_tools/_viewer_static/assets/gaussianSplattingVoxel.fragment-qwx5ntqJ.js +17 -0
  113. python_cad_tools/_viewer_static/assets/gaussianSplattingVoxel.vertex-CP2kd3jU.js +30 -0
  114. python_cad_tools/_viewer_static/assets/gaussianSplattingVoxel.vertex-Dr-fEg_W.js +19 -0
  115. python_cad_tools/_viewer_static/assets/geometry.fragment-CsJIm2H0.js +242 -0
  116. python_cad_tools/_viewer_static/assets/geometry.fragment-Dph3muZt.js +262 -0
  117. python_cad_tools/_viewer_static/assets/geometry.vertex-BXGMTA_J.js +212 -0
  118. python_cad_tools/_viewer_static/assets/geometry.vertex-Bm9Wg3Gi.js +214 -0
  119. python_cad_tools/_viewer_static/assets/glowBlurPostProcess.fragment-BJSwKIJD.js +7 -0
  120. python_cad_tools/_viewer_static/assets/glowMapGeneration.fragment-DcyS1cTF.js +63 -0
  121. python_cad_tools/_viewer_static/assets/glowMapGeneration.vertex-BGq1Fakj.js +75 -0
  122. python_cad_tools/_viewer_static/assets/glowMapMerge.fragment-DxcneU_F.js +25 -0
  123. python_cad_tools/_viewer_static/assets/glowMapMerge.vertex-DaJJKqMV.js +8 -0
  124. python_cad_tools/_viewer_static/assets/harmonicsFunctions-DzJcvNWG.js +16 -0
  125. python_cad_tools/_viewer_static/assets/hdrTextureLoader-BGQvgh0h.js +2 -0
  126. python_cad_tools/_viewer_static/assets/helperFunctions-Cugfp1Fz.js +87 -0
  127. python_cad_tools/_viewer_static/assets/iesTextureLoader-CO4G0p2M.js +2 -0
  128. python_cad_tools/_viewer_static/assets/index-B2zBEWsq.js +7007 -0
  129. python_cad_tools/_viewer_static/assets/index-DcTTrc-8.css +1 -0
  130. python_cad_tools/_viewer_static/assets/kernelBlur.fragment-B6CTXTxY.js +57 -0
  131. python_cad_tools/_viewer_static/assets/kernelBlur.fragment-BkKbudbW.js +57 -0
  132. python_cad_tools/_viewer_static/assets/kernelBlur.vertex-BYwFU5IS.js +11 -0
  133. python_cad_tools/_viewer_static/assets/kernelBlur.vertex-D371zUfT.js +11 -0
  134. python_cad_tools/_viewer_static/assets/kernelBlurVaryingDeclaration-CgBGaCHg.js +1 -0
  135. python_cad_tools/_viewer_static/assets/kernelBlurVaryingDeclaration-YS8JpqdO.js +1 -0
  136. python_cad_tools/_viewer_static/assets/ktxTextureLoader-ncMSJTjl.js +1 -0
  137. python_cad_tools/_viewer_static/assets/lightFragment-skHiFbKB.js +398 -0
  138. python_cad_tools/_viewer_static/assets/logDepthDeclaration-BR8XRz9F.js +4 -0
  139. python_cad_tools/_viewer_static/assets/logDepthVertex-UKrhEIvg.js +14 -0
  140. python_cad_tools/_viewer_static/assets/mainUVVaryingDeclaration-BxQWGFcG.js +4 -0
  141. python_cad_tools/_viewer_static/assets/mesh.vertexData.functions-ayNlGC5K.js +1 -0
  142. python_cad_tools/_viewer_static/assets/meshUboDeclaration-BnX046aQ.js +4 -0
  143. python_cad_tools/_viewer_static/assets/oitFragment-CTMCOfNP.js +605 -0
  144. python_cad_tools/_viewer_static/assets/openpbr.fragment-DPJPqi6p.js +1530 -0
  145. python_cad_tools/_viewer_static/assets/openpbr.fragment-Dv6qTVVi.js +1384 -0
  146. python_cad_tools/_viewer_static/assets/openpbr.vertex-Bn2wrdGL.js +364 -0
  147. python_cad_tools/_viewer_static/assets/openpbr.vertex-CHESW3gB.js +251 -0
  148. python_cad_tools/_viewer_static/assets/openpbrMaterial.pure-BdK7VgO_.js +3 -0
  149. python_cad_tools/_viewer_static/assets/openpbrMaterialLoadingAdapter-Bm_AHDUN.js +4 -0
  150. python_cad_tools/_viewer_static/assets/openpbrTransmissionLayerData-BDa9qEoN.js +339 -0
  151. python_cad_tools/_viewer_static/assets/openpbrTransmissionLayerData-Ba_ly4LE.js +343 -0
  152. python_cad_tools/_viewer_static/assets/openpbrUboDeclaration-BY2lSH2C.js +5 -0
  153. python_cad_tools/_viewer_static/assets/openpbrUboDeclaration-DajhikDS.js +6 -0
  154. python_cad_tools/_viewer_static/assets/packingFunctions-BHPwcGG2.js +4 -0
  155. python_cad_tools/_viewer_static/assets/packingFunctions-DTwzBRBx.js +4 -0
  156. python_cad_tools/_viewer_static/assets/pass.fragment-9oKU4pI3.js +4 -0
  157. python_cad_tools/_viewer_static/assets/passCube.fragment-CpAeiYx1.js +23 -0
  158. python_cad_tools/_viewer_static/assets/passCube.fragment-DHtSWVRF.js +23 -0
  159. python_cad_tools/_viewer_static/assets/pbr.fragment-cIhMKwLs.js +2560 -0
  160. python_cad_tools/_viewer_static/assets/pbr.vertex-BfdONsf2.js +255 -0
  161. python_cad_tools/_viewer_static/assets/pbrBRDFFunctions-B_ppOzPO.js +173 -0
  162. python_cad_tools/_viewer_static/assets/pbrDebug-DDdwL5_t.js +693 -0
  163. python_cad_tools/_viewer_static/assets/pbrIBLFunctions-b1zdpzOP.js +43 -0
  164. python_cad_tools/_viewer_static/assets/pbrMaterial.pure-BZA7yVhu.js +2 -0
  165. python_cad_tools/_viewer_static/assets/pbrMaterialLoadingAdapter-BRvKRnjl.js +1 -0
  166. python_cad_tools/_viewer_static/assets/pbrUboDeclaration-CMZp25k3.js +5 -0
  167. python_cad_tools/_viewer_static/assets/postprocess.vertex-DzdUpNbW.js +9 -0
  168. python_cad_tools/_viewer_static/assets/procedural.vertex-BnbuQ-1f.js +7 -0
  169. python_cad_tools/_viewer_static/assets/procedural.vertex-Dp-Ng7Pc.js +8 -0
  170. python_cad_tools/_viewer_static/assets/reflectionFunction-DBlr3oDs.js +83 -0
  171. python_cad_tools/_viewer_static/assets/rgbdDecode.fragment-CyvnZFOJ.js +5 -0
  172. python_cad_tools/_viewer_static/assets/rgbdEncode.fragment-Dz4zLnoD.js +5 -0
  173. python_cad_tools/_viewer_static/assets/rgbdEncode.fragment-iscgpA1_.js +5 -0
  174. python_cad_tools/_viewer_static/assets/sceneUboDeclaration-BzFIc4mb.js +11 -0
  175. python_cad_tools/_viewer_static/assets/textureProcessor.fragment-C9D0rd-M.js +151 -0
  176. python_cad_tools/_viewer_static/assets/textureProcessor.fragment-JMKyWZng.js +146 -0
  177. python_cad_tools/_viewer_static/assets/tgaTextureLoader-oxTElIQJ.js +1 -0
  178. python_cad_tools/_viewer_static/assets/vertexColorMixing-mdC9xZe1.js +418 -0
  179. python_cad_tools/_viewer_static/favicon.svg +10 -0
  180. python_cad_tools/_viewer_static/index.html +18 -0
  181. python_cad_tools/_viewer_static/sw.js +61 -0
  182. python_cad_tools/artifacts.py +546 -0
  183. python_cad_tools/build-info.json +1 -0
  184. python_cad_tools/build.py +270 -0
  185. python_cad_tools/cli.py +212 -0
  186. python_cad_tools/context.py +67 -0
  187. python_cad_tools/determinism.py +66 -0
  188. python_cad_tools/drawings/__init__.py +124 -0
  189. python_cad_tools/drawings/_catalog.py +79 -0
  190. python_cad_tools/drawings/_validation.py +238 -0
  191. python_cad_tools/elements.py +121 -0
  192. python_cad_tools/exceptions.py +45 -0
  193. python_cad_tools/exporters/__init__.py +8 -0
  194. python_cad_tools/exporters/base.py +24 -0
  195. python_cad_tools/exporters/drawings/__init__.py +5 -0
  196. python_cad_tools/exporters/drawings/annotations.py +444 -0
  197. python_cad_tools/exporters/drawings/dxf.py +110 -0
  198. python_cad_tools/exporters/drawings/model.py +70 -0
  199. python_cad_tools/exporters/drawings/pdf.py +119 -0
  200. python_cad_tools/exporters/drawings/primitives.py +93 -0
  201. python_cad_tools/exporters/drawings/projection.py +64 -0
  202. python_cad_tools/exporters/drawings/svg.py +135 -0
  203. python_cad_tools/exporters/glb.py +100 -0
  204. python_cad_tools/exporters/ifc.py +229 -0
  205. python_cad_tools/exporters/quantities.py +136 -0
  206. python_cad_tools/exporters/step.py +117 -0
  207. python_cad_tools/geometry.py +187 -0
  208. python_cad_tools/manifests.py +338 -0
  209. python_cad_tools/project_config.py +174 -0
  210. python_cad_tools/py.typed +1 -0
  211. python_cad_tools/runtime_sync.py +126 -0
  212. python_cad_tools/schemas/build-manifest-1.json +1 -0
  213. python_cad_tools/schemas/design-manifest-1.json +1 -0
  214. python_cad_tools/schemas/download-manifest-2.json +46 -0
  215. python_cad_tools/schemas/drawing-annotations-1.json +66 -0
  216. python_cad_tools/schemas/glb-manifest-1.json +1 -0
  217. python_cad_tools/schemas/ifc-validation-1.json +1 -0
  218. python_cad_tools/schemas/quantities-1.json +1 -0
  219. python_cad_tools/schemas/run-metadata-1.json +1 -0
  220. python_cad_tools/schemas/site-metadata-1.json +34 -0
  221. python_cad_tools/schemas/step-validation-1.json +1 -0
  222. python_cad_tools/site.py +676 -0
  223. python_cad_tools/templates/project/.gitignore +9 -0
  224. python_cad_tools/templates/project/README.md +38 -0
  225. python_cad_tools/templates/project/config.py +36 -0
  226. python_cad_tools/templates/project/drawing_annotations.py +117 -0
  227. python_cad_tools/templates/project/model.py +87 -0
  228. python_cad_tools/templates/project/pyproject.toml +27 -0
  229. python_cad_tools/units.py +207 -0
  230. python_cad_tools/validation.py +153 -0
  231. python_cad_tools-0.1.0rc1.dist-info/METADATA +149 -0
  232. python_cad_tools-0.1.0rc1.dist-info/RECORD +236 -0
  233. python_cad_tools-0.1.0rc1.dist-info/WHEEL +5 -0
  234. python_cad_tools-0.1.0rc1.dist-info/entry_points.txt +2 -0
  235. python_cad_tools-0.1.0rc1.dist-info/licenses/LICENSE +679 -0
  236. python_cad_tools-0.1.0rc1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1530 @@
1
+ import{S as e,cn as H,co as B,cp as V,s as k,m as Y,bf as Z,cq as $,cr as j,cs as q,an as K,ap as Q,ct as J,ah as ee,o as ie,ai as oe,cu as ae,p as te,cv as re,cw as ne,cx as se,cy as ce,cz as fe,aG as le,cA as _e,cB as de,cC as me,aq as ue,cD as ge,cE as Ee,ar as ve,as as pe,al as he,cF as Ie,cG as Re,aj as Se,ak as Te,cH as Ae,cI as Ne,cJ as be}from"./index-B2zBEWsq.js";import{s as Fe,o as Le,a as De,b as Oe,d as Ce,c as Pe}from"./openpbrTransmissionLayerData-BDa9qEoN.js";import{o as Me}from"./openpbrUboDeclaration-DajhikDS.js";const o="openpbrFragmentDeclaration",S=`uniform float vBaseWeight;uniform vec4 vBaseColor;uniform float vBaseDiffuseRoughness;uniform vec4 vReflectanceInfo;uniform vec4 vSpecularColor;uniform vec3 vSpecularAnisotropy;uniform float vTransmissionWeight;uniform vec3 vTransmissionColor;uniform float vTransmissionDepth;uniform vec3 vTransmissionScatter;uniform float vTransmissionScatterAnisotropy;uniform float vTransmissionDispersionScale;uniform float vTransmissionDispersionAbbeNumber;uniform float vSubsurfaceWeight;uniform vec3 vSubsurfaceColor;uniform float vSubsurfaceRadius;uniform vec3 vSubsurfaceRadiusScale;uniform float vSubsurfaceScatterAnisotropy;uniform float vCoatWeight;uniform vec3 vCoatColor;uniform float vCoatRoughness;uniform float vCoatRoughnessAnisotropy;uniform float vCoatIor;uniform float vCoatDarkening;uniform float vFuzzWeight;uniform vec3 vFuzzColor;uniform float vFuzzRoughness;uniform vec2 vGeometryCoatTangent;uniform float vGeometryThickness;uniform vec3 vEmissionColor;uniform float vThinFilmWeight;uniform vec2 vThinFilmThickness;uniform float vThinFilmIor;uniform float vGeometryThinWalled;uniform vec4 vLightingIntensity;uniform float visibility;uniform vec2 renderTargetSize;
2
+ #ifdef BASE_COLOR
3
+ uniform vec2 vBaseColorInfos;
4
+ #endif
5
+ #ifdef BASE_WEIGHT
6
+ uniform vec2 vBaseWeightInfos;
7
+ #endif
8
+ #ifdef BASE_METALNESS
9
+ uniform vec2 vBaseMetalnessInfos;
10
+ #endif
11
+ #ifdef BASE_DIFFUSE_ROUGHNESS
12
+ uniform vec2 vBaseDiffuseRoughnessInfos;
13
+ #endif
14
+ #ifdef SPECULAR_WEIGHT
15
+ uniform vec2 vSpecularWeightInfos;
16
+ #endif
17
+ #ifdef SPECULAR_COLOR
18
+ uniform vec2 vSpecularColorInfos;
19
+ #endif
20
+ #ifdef SPECULAR_ROUGHNESS
21
+ uniform vec2 vSpecularRoughnessInfos;
22
+ #endif
23
+ #ifdef SPECULAR_ROUGHNESS_ANISOTROPY
24
+ uniform vec2 vSpecularRoughnessAnisotropyInfos;
25
+ #endif
26
+ #ifdef SPECULAR_IOR
27
+ uniform vec2 vSpecularIorInfos;
28
+ #endif
29
+ #ifdef AMBIENT_OCCLUSION
30
+ uniform vec2 vAmbientOcclusionInfos;
31
+ #endif
32
+ #ifdef GEOMETRY_NORMAL
33
+ uniform vec2 vGeometryNormalInfos;
34
+ #endif
35
+ #ifdef GEOMETRY_TANGENT
36
+ uniform vec2 vGeometryTangentInfos;
37
+ #endif
38
+ #if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL)
39
+ uniform vec2 vTangentSpaceParams;
40
+ #endif
41
+ #ifdef GEOMETRY_COAT_NORMAL
42
+ uniform vec2 vGeometryCoatNormalInfos;
43
+ #endif
44
+ #ifdef GEOMETRY_OPACITY
45
+ uniform vec2 vGeometryOpacityInfos;
46
+ #endif
47
+ #ifdef GEOMETRY_THICKNESS
48
+ uniform vec2 vGeometryThicknessInfos;
49
+ #endif
50
+ #ifdef EMISSION_COLOR
51
+ uniform vec2 vEmissionColorInfos;
52
+ #endif
53
+ #ifdef TRANSMISSION_WEIGHT
54
+ uniform vec2 vTransmissionWeightInfos;
55
+ #endif
56
+ #ifdef TRANSMISSION_COLOR
57
+ uniform vec2 vTransmissionColorInfos;
58
+ #endif
59
+ #ifdef TRANSMISSION_DEPTH
60
+ uniform vec2 vTransmissionDepthInfos;
61
+ #endif
62
+ #ifdef TRANSMISSION_SCATTER
63
+ uniform vec2 vTransmissionScatterInfos;
64
+ #endif
65
+ #ifdef TRANSMISSION_DISPERSION_SCALE
66
+ uniform vec2 vTransmissionDispersionScaleInfos;
67
+ #endif
68
+ #ifdef SUBSURFACE_WEIGHT
69
+ uniform vec2 vSubsurfaceWeightInfos;
70
+ #endif
71
+ #ifdef SUBSURFACE_COLOR
72
+ uniform vec2 vSubsurfaceColorInfos;
73
+ #endif
74
+ #ifdef SUBSURFACE_RADIUS_SCALE
75
+ uniform vec2 vSubsurfaceRadiusScaleInfos;
76
+ #endif
77
+ #ifdef COAT_WEIGHT
78
+ uniform vec2 vCoatWeightInfos;
79
+ #endif
80
+ #ifdef COAT_COLOR
81
+ uniform vec2 vCoatColorInfos;
82
+ #endif
83
+ #ifdef COAT_ROUGHNESS
84
+ uniform vec2 vCoatRoughnessInfos;
85
+ #endif
86
+ #ifdef COAT_ROUGHNESS_ANISOTROPY
87
+ uniform vec2 vCoatRoughnessAnisotropyInfos;
88
+ #endif
89
+ #ifdef COAT_IOR
90
+ uniform vec2 vCoatIorInfos;
91
+ #endif
92
+ #ifdef COAT_DARKENING
93
+ uniform vec2 vCoatDarkeningInfos;
94
+ #endif
95
+ #ifdef FUZZ_WEIGHT
96
+ uniform vec2 vFuzzWeightInfos;
97
+ #endif
98
+ #ifdef FUZZ_COLOR
99
+ uniform vec2 vFuzzColorInfos;
100
+ #endif
101
+ #ifdef FUZZ_ROUGHNESS
102
+ uniform vec2 vFuzzRoughnessInfos;
103
+ #endif
104
+ #ifdef GEOMETRY_COAT_TANGENT
105
+ uniform vec2 vGeometryCoatTangentInfos;
106
+ #endif
107
+ #ifdef THIN_FILM_WEIGHT
108
+ uniform vec2 vThinFilmWeightInfos;
109
+ #endif
110
+ #ifdef THIN_FILM_THICKNESS
111
+ uniform vec2 vThinFilmThicknessInfos;
112
+ #endif
113
+ #include<sceneFragmentDeclaration>
114
+ #ifdef REFLECTION
115
+ uniform vec2 vReflectionInfos;
116
+ #ifdef REALTIME_FILTERING
117
+ uniform vec2 vReflectionFilteringInfo;
118
+ #endif
119
+ uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;
120
+ #if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)
121
+ uniform vec3 vReflectionDominantDirection;
122
+ #endif
123
+ #if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
124
+ uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;
125
+ #endif
126
+ #endif
127
+ #ifdef PREPASS
128
+ #ifdef SS_SCATTERING
129
+ uniform float scatteringDiffusionProfile;
130
+ #endif
131
+ #endif
132
+ #if DEBUGMODE>0
133
+ uniform vec2 vDebugMode;
134
+ #endif
135
+ #ifdef DETAIL
136
+ uniform vec4 vDetailInfos;
137
+ #endif
138
+ #include<decalFragmentDeclaration>
139
+ #ifdef USESPHERICALFROMREFLECTIONMAP
140
+ #ifdef SPHERICAL_HARMONICS
141
+ uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;
142
+ #else
143
+ uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;
144
+ #endif
145
+ #endif
146
+ #ifdef REFRACTED_BACKGROUND
147
+ uniform mat4 backgroundRefractionMatrix;uniform vec3 vBackgroundRefractionInfos;
148
+ #endif
149
+ #if TEXTURE_REPETITION_MODE>0
150
+ uniform vec4 vTextureRepetitionHexTilingParams;
151
+ #endif
152
+ #define ADDITIONAL_FRAGMENT_DECLARATION
153
+ `;e.IncludesShadersStore[o]||(e.IncludesShadersStore[o]=S);const Ge={name:o,shader:S},a="openpbrFragmentSamplersDeclaration",T=`#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_SAMPLERNAME_,baseColor)
154
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight)
155
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness)
156
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness,_SAMPLERNAME_,baseMetalness)
157
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight,_SAMPLERNAME_,specularWeight)
158
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor,_SAMPLERNAME_,specularColor)
159
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness,_SAMPLERNAME_,specularRoughness)
160
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy,_SAMPLERNAME_,specularRoughnessAnisotropy)
161
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_SAMPLERNAME_,transmissionWeight)
162
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_COLOR,_VARYINGNAME_,TransmissionColor,_SAMPLERNAME_,transmissionColor)
163
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_DEPTH,_VARYINGNAME_,TransmissionDepth,_SAMPLERNAME_,transmissionDepth)
164
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_SCATTER,_VARYINGNAME_,TransmissionScatter,_SAMPLERNAME_,transmissionScatter)
165
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_DISPERSION_SCALE,_VARYINGNAME_,TransmissionDispersionScale,_SAMPLERNAME_,transmissionDispersionScale)
166
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_SAMPLERNAME_,subsurfaceWeight)
167
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_COLOR,_VARYINGNAME_,SubsurfaceColor,_SAMPLERNAME_,subsurfaceColor)
168
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_RADIUS_SCALE,_VARYINGNAME_,SubsurfaceRadiusScale,_SAMPLERNAME_,subsurfaceRadiusScale)
169
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight,_SAMPLERNAME_,coatWeight)
170
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_COLOR,_VARYINGNAME_,CoatColor,_SAMPLERNAME_,coatColor)
171
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness,_SAMPLERNAME_,coatRoughness)
172
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy,_SAMPLERNAME_,coatRoughnessAnisotropy)
173
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening,_SAMPLERNAME_,coatDarkening)
174
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,FUZZ_WEIGHT,_VARYINGNAME_,FuzzWeight,_SAMPLERNAME_,fuzzWeight)
175
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,FUZZ_COLOR,_VARYINGNAME_,FuzzColor,_SAMPLERNAME_,fuzzColor)
176
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,FUZZ_ROUGHNESS,_VARYINGNAME_,FuzzRoughness,_SAMPLERNAME_,fuzzRoughness)
177
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity,_SAMPLERNAME_,geometryOpacity)
178
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent,_SAMPLERNAME_,geometryTangent)
179
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_COAT_TANGENT,_VARYINGNAME_,GeometryCoatTangent,_SAMPLERNAME_,geometryCoatTangent)
180
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_THICKNESS,_VARYINGNAME_,GeometryThickness,_SAMPLERNAME_,geometryThickness)
181
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor,_SAMPLERNAME_,emissionColor)
182
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,THIN_FILM_WEIGHT,_VARYINGNAME_,ThinFilmWeight,_SAMPLERNAME_,thinFilmWeight)
183
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,THIN_FILM_THICKNESS,_VARYINGNAME_,ThinFilmThickness,_SAMPLERNAME_,thinFilmThickness)
184
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_SAMPLERNAME_,ambientOcclusion)
185
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
186
+ #include<pbrFragmentReflectionDeclaration>
187
+ #ifdef ENVIRONMENTBRDF
188
+ uniform sampler2D environmentBrdfSampler;
189
+ #endif
190
+ #ifdef FUZZENVIRONMENTBRDF
191
+ uniform sampler2D environmentFuzzBrdfSampler;
192
+ #endif
193
+ #ifdef REFRACTED_BACKGROUND
194
+ uniform sampler2D backgroundRefractionSampler;
195
+ #endif
196
+ #ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING
197
+ uniform sampler2D sceneIrradianceSampler;uniform sampler2D sceneDepthSampler;
198
+ #endif
199
+ #if defined(ANISOTROPIC) || defined(FUZZ) || defined(REFRACTED_BACKGROUND) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING)
200
+ uniform sampler2D blueNoiseSampler;
201
+ #endif
202
+ #ifdef IBL_CDF_FILTERING
203
+ uniform sampler2D icdfSampler;
204
+ #endif
205
+ `;e.IncludesShadersStore[a]||(e.IncludesShadersStore[a]=T);const xe={name:a,shader:T},t="openpbrNormalMapFragmentMainFunctions",A=`#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(ANISOTROPIC) || defined(FUZZ) || defined(DETAIL)
206
+ #if defined(TANGENT) && defined(NORMAL)
207
+ varying mat3 vTBN;
208
+ #endif
209
+ #ifdef OBJECTSPACE_NORMALMAP
210
+ uniform mat4 normalMatrix;
211
+ #if defined(WEBGL2) || defined(WEBGPU)
212
+ mat4 toNormalMatrix(mat4 wMatrix)
213
+ {mat4 ret=inverse(wMatrix);ret=transpose(ret);ret[0][3]=0.;ret[1][3]=0.;ret[2][3]=0.;ret[3]=vec4(0.,0.,0.,1.);return ret;}
214
+ #else
215
+ mat4 toNormalMatrix(mat4 m)
216
+ {float
217
+ a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],
218
+ a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],
219
+ a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],
220
+ a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],
221
+ b00=a00*a11-a01*a10,
222
+ b01=a00*a12-a02*a10,
223
+ b02=a00*a13-a03*a10,
224
+ b03=a01*a12-a02*a11,
225
+ b04=a01*a13-a03*a11,
226
+ b05=a02*a13-a03*a12,
227
+ b06=a20*a31-a21*a30,
228
+ b07=a20*a32-a22*a30,
229
+ b08=a20*a33-a23*a30,
230
+ b09=a21*a32-a22*a31,
231
+ b10=a21*a33-a23*a31,
232
+ b11=a22*a33-a23*a32,
233
+ det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;mat4 mi=mat4(
234
+ a11*b11-a12*b10+a13*b09,
235
+ a02*b10-a01*b11-a03*b09,
236
+ a31*b05-a32*b04+a33*b03,
237
+ a22*b04-a21*b05-a23*b03,
238
+ a12*b08-a10*b11-a13*b07,
239
+ a00*b11-a02*b08+a03*b07,
240
+ a32*b02-a30*b05-a33*b01,
241
+ a20*b05-a22*b02+a23*b01,
242
+ a10*b10-a11*b08+a13*b06,
243
+ a01*b08-a00*b10-a03*b06,
244
+ a30*b04-a31*b02+a33*b00,
245
+ a21*b02-a20*b04-a23*b00,
246
+ a11*b07-a10*b09-a12*b06,
247
+ a00*b09-a01*b07+a02*b06,
248
+ a31*b01-a30*b03-a32*b00,
249
+ a20*b03-a21*b01+a22*b00)/det;return mat4(mi[0][0],mi[1][0],mi[2][0],mi[3][0],
250
+ mi[0][1],mi[1][1],mi[2][1],mi[3][1],
251
+ mi[0][2],mi[1][2],mi[2][2],mi[3][2],
252
+ mi[0][3],mi[1][3],mi[2][3],mi[3][3]);}
253
+ #endif
254
+ #endif
255
+ vec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)
256
+ {
257
+ #ifdef NORMALXYSCALE
258
+ normal=normalize(normal*vec3(scale,scale,1.0));
259
+ #endif
260
+ return normalize(cotangentFrame*normal);}
261
+ vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)
262
+ {return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);}
263
+ mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)
264
+ {vec3 dp1=dFdx(p);vec3 dp2=dFdy(p);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;float det=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=det==0.0 ? 0.0 : inversesqrt(det);return mat3(tangent*invmax,bitangent*invmax,normal);}
265
+ #endif
266
+ `;e.IncludesShadersStore[t]||(e.IncludesShadersStore[t]=A);const ye={name:t,shader:A},r="openpbrNormalMapFragmentFunctions",N=`#if defined(GEOMETRY_NORMAL)
267
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_NORMAL,_VARYINGNAME_,GeometryNormal,_SAMPLERNAME_,geometryNormal)
268
+ #endif
269
+ #if defined(GEOMETRY_COAT_NORMAL)
270
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_COAT_NORMAL,_VARYINGNAME_,GeometryCoatNormal,_SAMPLERNAME_,geometryCoatNormal)
271
+ #endif
272
+ #if defined(DETAIL)
273
+ #include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
274
+ #endif
275
+ #if defined(GEOMETRY_NORMAL) && defined(PARALLAX)
276
+ const float minSamples=4.;const float maxSamples=15.;const int iMaxSamples=15;vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;vec2 vOffsetDir=normalize(vViewDirCoT.xy);vec2 vMaxOffset=vOffsetDir*parallaxLimit;float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));float stepSize=1.0/numSamples;float currRayHeight=1.0;vec2 vCurrOffset=vec2(0,0);vec2 vLastOffset=vec2(0,0);float lastSampledHeight=1.0;float currSampledHeight=1.0;bool keepWorking=true;for (int i=0; i<iMaxSamples; i++)
277
+ {currSampledHeight=texture2D(geometryNormalSampler,texCoord+vCurrOffset).w;if (!keepWorking)
278
+ {}
279
+ else if (currSampledHeight>currRayHeight)
280
+ {float delta1=currSampledHeight-currRayHeight;float delta2=(currRayHeight+stepSize)-lastSampledHeight;float ratio=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;}
281
+ else
282
+ {currRayHeight-=stepSize;vLastOffset=vCurrOffset;
283
+ #ifdef PARALLAX_RHS
284
+ vCurrOffset-=stepSize*vMaxOffset;
285
+ #else
286
+ vCurrOffset+=stepSize*vMaxOffset;
287
+ #endif
288
+ lastSampledHeight=currSampledHeight;}}
289
+ return vCurrOffset;}
290
+ vec2 parallaxOffset(vec3 viewDir,float heightScale)
291
+ {float height=texture2D(geometryNormalSampler,vGeometryNormalUV).w;vec2 texCoordOffset=heightScale*viewDir.xy*height;
292
+ #ifdef PARALLAX_RHS
293
+ return texCoordOffset;
294
+ #else
295
+ return -texCoordOffset;
296
+ #endif
297
+ }
298
+ #endif
299
+ `;e.IncludesShadersStore[r]||(e.IncludesShadersStore[r]=N);const ze={name:r,shader:N},n="openpbrConductorReflectance",b=`#define pbr_inline
300
+ ReflectanceParams conductorReflectance(in vec3 baseColor,in vec3 specularColor,in float specularWeight)
301
+ {ReflectanceParams outParams;
302
+ #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
303
+ outParams.coloredF0=baseColor*specularWeight;outParams.coloredF90=specularColor*specularWeight;
304
+ #else
305
+ outParams.coloredF0=baseColor;outParams.coloredF90=vec3(1.0);
306
+ #endif
307
+ outParams.F0=1.0;outParams.F90=1.0;return outParams;}`;e.IncludesShadersStore[n]||(e.IncludesShadersStore[n]=b);const Ue={name:n,shader:b},s="openpbrAmbientOcclusionFunctions",F=`float compute_specular_occlusion(const float n_dot_v,const float metallic,const float ambient_occlusion,const float roughness)
308
+ {float specular_occlusion=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));}
309
+ `;e.IncludesShadersStore[s]||(e.IncludesShadersStore[s]=F);const Xe={name:s,shader:F},c="openpbrVolumeFunctions",L=`struct OpenPBRHomogeneousVolume {vec3 extinction_coeff;
310
+ vec3 ss_albedo;
311
+ vec3 multi_scatter_color;
312
+ vec3 absorption_coeff;
313
+ vec3 scatter_coeff;
314
+ float anisotropy; };OpenPBRHomogeneousVolume computeOpenPBRTransmissionVolume(
315
+ in vec3 transmission_color,
316
+ in float transmission_depth,
317
+ in vec3 transmission_scatter,
318
+ in float anisotropy
319
+ )
320
+ {OpenPBRHomogeneousVolume volumeParams;volumeParams.absorption_coeff=vec3(0.0);volumeParams.scatter_coeff=vec3(0.0);volumeParams.anisotropy=anisotropy;
321
+ #ifdef GEOMETRY_THIN_WALLED
322
+ volumeParams.scatter_coeff=vec3(1.0);volumeParams.anisotropy=1.0;
323
+ volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=vec3(1.0);
324
+ #else
325
+ if (transmission_depth>0.0) {vec3 invDepth=vec3(1./maxEps(transmission_depth));volumeParams.extinction_coeff=-log(maxEps(transmission_color.rgb))*invDepth;volumeParams.scatter_coeff=transmission_scatter.rgb*invDepth;volumeParams.absorption_coeff=volumeParams.extinction_coeff-volumeParams.scatter_coeff.rgb;float minCoeff=min3(volumeParams.absorption_coeff);if (minCoeff<0.0) {volumeParams.absorption_coeff-=vec3(minCoeff);}
326
+ 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=vec3(0.0);}
327
+ #endif
328
+ return volumeParams;}
329
+ OpenPBRHomogeneousVolume computeOpenPBRSubsurfaceVolume(
330
+ in vec3 subsurface_color,
331
+ in float subsurface_radius,
332
+ in vec3 subsurface_radius_scale,
333
+ in float anisotropy
334
+ )
335
+ {OpenPBRHomogeneousVolume volumeParams;volumeParams.absorption_coeff=vec3(0.0);volumeParams.scatter_coeff=vec3(0.0);volumeParams.anisotropy=anisotropy;volumeParams.multi_scatter_color=subsurface_color;vec3 mfp=subsurface_radius_scale*vec3(subsurface_radius);volumeParams.extinction_coeff=vec3(1.0)/maxEps(mfp);volumeParams.ss_albedo=multiScatterToSingleScatterAlbedo(subsurface_color,anisotropy);volumeParams.scatter_coeff=volumeParams.ss_albedo*volumeParams.extinction_coeff;volumeParams.absorption_coeff=volumeParams.extinction_coeff-volumeParams.scatter_coeff.rgb;float minCoeff=min3(volumeParams.absorption_coeff);if (minCoeff<0.0) {volumeParams.absorption_coeff-=vec3(minCoeff);}
336
+ volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;return volumeParams;}
337
+ vec3 sss_pdf(float r,vec3 d)
338
+ {d=max(vec3(1e-4f),d);return (exp(-r/d)+exp(-r/(3.0f*d)))/max(vec3(1e-5f),8.0f*PI*d*r);}
339
+ float sss_samples_pdf(float r,float d)
340
+ {d=max(1e-4f,d);return exp(-r/(3.0f*d))/(6.0f*PI*d*r);}
341
+ float sss_samples_icdf(float x,float d)
342
+ {d=max(1e-4f,d);x=max(1e-4f,x);return -3.0f*log(x)*d;}
343
+ float samples_scale(float x,float d)
344
+ {return 1.0f-exp(-x/(3.0f*d));}
345
+ vec3 sss_get_position(sampler2D depth_texture,vec2 tex_coord,vec2 render_resolution,mat4 inv_proj)
346
+ {vec4 P=vec4(tex_coord,texelFetch(depth_texture,ivec2(tex_coord*render_resolution),0).x,1.0f);P.xy=2.0f*P.xy-1.0f;P=inv_proj*P;return P.xyz/P.w;}
347
+ float sss_filter_scale(float currZ,mat4 proj)
348
+ {return 1.0f/dot(vec2(proj[2].w,proj[3].w),vec2(currZ,1.0f));}
349
+ float projective_to_pixels(float proj_dist,mat4 proj,vec2 resolution)
350
+ {return proj_dist*proj[1][1]*resolution.y;}
351
+ float pixels_to_projective(float pixel_dist,mat4 proj,vec2 resolution)
352
+ {return pixel_dist/(proj[1][1]*resolution.y);}
353
+ vec3 sss_convolve(sampler2D sss_irradiance_texture,sampler2D depth_texture,vec2 render_resolution,vec3 d,mat4 proj,mat4 inv_proj,int sample_count,vec2 noise)
354
+ {vec2 tex_coord=gl_FragCoord.xy/render_resolution;vec3 unconvolved_irradiance=texelFetch(sss_irradiance_texture,ivec2(gl_FragCoord.xy),0).rgb;vec3 curr_pos=sss_get_position(depth_texture,tex_coord,render_resolution,inv_proj);float dmax=max3(d);float max_dmax=0.1*float(sample_count);if (dmax>max_dmax)
355
+ {d.rgb*=max_dmax/dmax;dmax=max_dmax;}
356
+ float dz=dmax*sss_filter_scale(curr_pos.z,proj);mat2 projMat2d=mat2(proj);if (determinant(projMat2d)*dz<1e-4f)
357
+ return unconvolved_irradiance;float overscan_size_in_pixels=max(render_resolution.x,render_resolution.y)*0.1;const float filter_crop_ratio=0.8f;
358
+ float crop_radius=projective_to_pixels(sss_samples_icdf(1.0f-filter_crop_ratio,dz),proj,render_resolution);if (crop_radius>overscan_size_in_pixels)
359
+ {d.rgb*=overscan_size_in_pixels/crop_radius;dz*=overscan_size_in_pixels/crop_radius;}
360
+ float filter_samples_scale=samples_scale(pixels_to_projective(overscan_size_in_pixels,proj,render_resolution),dz);vec3 irradiance_sum=vec3(0.0f);vec3 weight_sum=vec3(0.0f);for (int i=0; i<sample_count; i++)
361
+ {vec2 r=fract(plasticSequence(uint(i))+noise);r.x*=TWO_PI;r.y*=filter_samples_scale;float icdf=sss_samples_icdf(1.0-r.y,dz);vec2 sample_uv=tex_coord+icdf*projMat2d*vec2(cos(r.x),sin(r.x));vec4 sss_irradiance=texelFetch(sss_irradiance_texture,ivec2(sample_uv*render_resolution),0);float dist=distance(curr_pos,sss_get_position(depth_texture,sample_uv,render_resolution,inv_proj));if (dist>0.0f)
362
+ {vec3 weights=sss_irradiance.a/sss_samples_pdf(icdf,dz)*sss_pdf(dist,d.rgb);irradiance_sum+=weights*sss_irradiance.rgb;weight_sum+=weights;}}
363
+ return vec3(weight_sum.r<1e-5f ? unconvolved_irradiance.r : irradiance_sum.r/weight_sum.r,
364
+ weight_sum.g<1e-5f ? unconvolved_irradiance.g : irradiance_sum.g/weight_sum.g,
365
+ weight_sum.b<1e-5f ? unconvolved_irradiance.b : irradiance_sum.b/weight_sum.b);}`;e.IncludesShadersStore[c]||(e.IncludesShadersStore[c]=L);const we={name:c,shader:L},f="openpbrNormalMapFragment",D=`vec2 uvOffset=vec2(0.0,0.0);
366
+ #if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(PARALLAX) || defined(DETAIL)
367
+ #ifdef NORMALXYSCALE
368
+ float normalScale=1.0;
369
+ #elif defined(GEOMETRY_NORMAL)
370
+ float normalScale=vGeometryNormalInfos.y;
371
+ #else
372
+ float normalScale=1.0;
373
+ #endif
374
+ #if defined(TANGENT) && defined(NORMAL)
375
+ mat3 TBN=vTBN;
376
+ #elif defined(GEOMETRY_NORMAL)
377
+ vec2 TBNUV=gl_FrontFacing ? vGeometryNormalUV : -vGeometryNormalUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);
378
+ #elif defined(GEOMETRY_COAT_NORMAL)
379
+ vec2 TBNUV=gl_FrontFacing ? vGeometryCoatNormalUV : -vGeometryCoatNormalUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);
380
+ #else
381
+ vec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.));
382
+ #endif
383
+ #elif defined(ANISOTROPIC) || defined(FUZZ)
384
+ #if defined(TANGENT) && defined(NORMAL)
385
+ mat3 TBN=vTBN;
386
+ #else
387
+ vec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;mat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.));
388
+ #endif
389
+ #endif
390
+ #ifdef PARALLAX
391
+ mat3 invTBN=transposeMat3(TBN);
392
+ #ifdef PARALLAXOCCLUSION
393
+ #else
394
+ #endif
395
+ #endif
396
+ #ifdef DETAIL
397
+ vec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);vec2 detailNormalRG=detailColor.wy*2.0-1.0;float detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));vec3 detailNormal=vec3(detailNormalRG,detailNormalB);
398
+ #endif
399
+ #ifdef GEOMETRY_COAT_NORMAL
400
+ coatNormalW=perturbNormal(TBN,TEXRD(geometryCoatNormalSampler,vGeometryCoatNormalUV+uvOffset).xyz,vGeometryCoatNormalInfos.y);
401
+ #endif
402
+ #ifdef GEOMETRY_NORMAL
403
+ #ifdef OBJECTSPACE_NORMALMAP
404
+ #define CUSTOM_FRAGMENT_BUMP_FRAGMENT
405
+ normalW=normalize(TEXRD(geometryNormalSampler,vGeometryNormalUV).xyz *2.0-1.0);normalW=normalize(mat3(normalMatrix)*normalW);
406
+ #elif !defined(DETAIL)
407
+ normalW=perturbNormal(TBN,TEXRD(geometryNormalSampler,vGeometryNormalUV+uvOffset).xyz,vGeometryNormalInfos.y);
408
+ #else
409
+ vec3 sampledNormal=TEXRD(geometryNormalSampler,vGeometryNormalUV+uvOffset).xyz*2.0-1.0;
410
+ #if DETAIL_NORMALBLENDMETHOD==0
411
+ detailNormal.xy*=vDetailInfos.z;vec3 blendedNormal=normalize(vec3(sampledNormal.xy+detailNormal.xy,sampledNormal.z*detailNormal.z));
412
+ #elif DETAIL_NORMALBLENDMETHOD==1
413
+ detailNormal.xy*=vDetailInfos.z;sampledNormal+=vec3(0.0,0.0,1.0);detailNormal*=vec3(-1.0,-1.0,1.0);vec3 blendedNormal=sampledNormal*dot(sampledNormal,detailNormal)/sampledNormal.z-detailNormal;
414
+ #endif
415
+ normalW=perturbNormalBase(TBN,blendedNormal,vGeometryNormalInfos.y);
416
+ #endif
417
+ #elif defined(DETAIL)
418
+ detailNormal.xy*=vDetailInfos.z;normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);
419
+ #endif
420
+ `;e.IncludesShadersStore[f]||(e.IncludesShadersStore[f]=D);const We={name:f,shader:D},l="openpbrBlockNormalFinal",O=`#if defined(FORCENORMALFORWARD) && defined(NORMAL)
421
+ vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
422
+ #if defined(TWOSIDEDLIGHTING)
423
+ faceNormal=gl_FrontFacing ? faceNormal : -faceNormal;
424
+ #endif
425
+ normalW*=sign(dot(normalW,faceNormal));coatNormalW*=sign(dot(coatNormalW,faceNormal));
426
+ #endif
427
+ #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
428
+ #if defined(MIRRORED)
429
+ normalW=gl_FrontFacing ? -normalW : normalW;coatNormalW=gl_FrontFacing ? -coatNormalW : coatNormalW;
430
+ #else
431
+ normalW=gl_FrontFacing ? normalW : -normalW;coatNormalW=gl_FrontFacing ? coatNormalW : -coatNormalW;
432
+ #endif
433
+ #endif
434
+ `;e.IncludesShadersStore[l]||(e.IncludesShadersStore[l]=O);const He={name:l,shader:O},_="openpbrBaseLayerData",C=`vec3 base_color=vec3(0.8);float base_metalness=0.0;float base_diffuse_roughness=0.0;float specular_weight=1.0;float specular_roughness=0.3;vec3 specular_color=vec3(1.0);float specular_roughness_anisotropy=0.0;float specular_ior=1.5;float alpha=1.0;vec2 geometry_tangent=vec2(1.0,0.0);float geometry_thickness=0.0;
435
+ #ifdef BASE_WEIGHT
436
+ vec4 baseWeightFromTexture=TEXRD(baseWeightSampler,vBaseWeightUV+uvOffset);
437
+ #endif
438
+ #ifdef BASE_COLOR
439
+ vec4 baseColorFromTexture=TEXRD(baseColorSampler,vBaseColorUV+uvOffset);
440
+ #endif
441
+ #ifdef BASE_METALNESS
442
+ vec4 metallicFromTexture=TEXRD(baseMetalnessSampler,vBaseMetalnessUV+uvOffset);
443
+ #endif
444
+ #if defined(SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN) && defined(BASE_METALNESS)
445
+ float roughnessFromTexture=metallicFromTexture.g;
446
+ #elif defined(SPECULAR_ROUGHNESS)
447
+ float roughnessFromTexture=TEXRD(specularRoughnessSampler,vSpecularRoughnessUV+uvOffset).r;
448
+ #endif
449
+ #ifdef GEOMETRY_TANGENT
450
+ vec3 geometryTangentFromTexture=TEXRD(geometryTangentSampler,vGeometryTangentUV+uvOffset).rgb;
451
+ #endif
452
+ #ifdef SPECULAR_ROUGHNESS_ANISOTROPY
453
+ float anisotropyFromTexture=TEXRD(specularRoughnessAnisotropySampler,vSpecularRoughnessAnisotropyUV+uvOffset).r*vSpecularRoughnessAnisotropyInfos.y;
454
+ #endif
455
+ #ifdef BASE_DIFFUSE_ROUGHNESS
456
+ float baseDiffuseRoughnessFromTexture=TEXRD(baseDiffuseRoughnessSampler,vBaseDiffuseRoughnessUV+uvOffset).r;
457
+ #endif
458
+ #ifdef GEOMETRY_OPACITY
459
+ vec4 opacityFromTexture=TEXRD(geometryOpacitySampler,vGeometryOpacityUV+uvOffset);
460
+ #endif
461
+ #ifdef GEOMETRY_THICKNESS
462
+ vec4 thicknessFromTexture=TEXRD(geometryThicknessSampler,vGeometryThicknessUV+uvOffset);
463
+ #endif
464
+ #ifdef DECAL
465
+ vec4 decalFromTexture=texture2D(decalSampler,vDecalUV+uvOffset);
466
+ #endif
467
+ #ifdef SPECULAR_COLOR
468
+ vec4 specularColorFromTexture=TEXRD(specularColorSampler,vSpecularColorUV+uvOffset);
469
+ #endif
470
+ #ifdef SPECULAR_WEIGHT
471
+ #ifdef SPECULAR_WEIGHT_IN_ALPHA
472
+ float specularWeightFromTexture=TEXRD(specularWeightSampler,vSpecularWeightUV+uvOffset).a;
473
+ #else
474
+ float specularWeightFromTexture=TEXRD(specularWeightSampler,vSpecularWeightUV+uvOffset).r;
475
+ #endif
476
+ #endif
477
+ #if defined(ANISOTROPIC) || defined(FUZZ) || defined(REFRACTED_BACKGROUND) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING)
478
+ vec3 noise=vec3(2.0)*TEXRD(blueNoiseSampler,gl_FragCoord.xy/256.0).xyz-vec3(1.0);
479
+ #endif
480
+ base_color=vBaseColor.rgb;
481
+ #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
482
+ base_color*=vColor.rgb;
483
+ #endif
484
+ #if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
485
+ alpha*=vColor.a;
486
+ #endif
487
+ base_color*=vec3(vBaseWeight);alpha=vBaseColor.a;base_metalness=vReflectanceInfo.x;base_diffuse_roughness=vBaseDiffuseRoughness;specular_roughness=vReflectanceInfo.y;specular_color=vSpecularColor.rgb;specular_weight=vReflectanceInfo.a;specular_ior=vReflectanceInfo.z;specular_roughness_anisotropy=vSpecularAnisotropy.b;geometry_tangent=vSpecularAnisotropy.rg;geometry_thickness=vGeometryThickness;
488
+ #ifdef BASE_COLOR
489
+ #ifdef BASE_COLOR_GAMMA
490
+ base_color*=toLinearSpace(baseColorFromTexture.rgb);
491
+ #else
492
+ base_color*=baseColorFromTexture.rgb;
493
+ #endif
494
+ base_color*=vBaseColorInfos.y;
495
+ #endif
496
+ #ifdef BASE_WEIGHT
497
+ base_color*=baseWeightFromTexture.r;
498
+ #endif
499
+ #if defined(BASE_COLOR) && defined(ALPHA_FROM_BASE_COLOR_TEXTURE)
500
+ alpha*=baseColorFromTexture.a;
501
+ #elif defined(GEOMETRY_OPACITY)
502
+ alpha*=opacityFromTexture.r;alpha*=vGeometryOpacityInfos.y;
503
+ #endif
504
+ #ifdef GEOMETRY_THICKNESS
505
+ #ifdef GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL
506
+ geometry_thickness*=thicknessFromTexture.g;
507
+ #else
508
+ geometry_thickness*=thicknessFromTexture.r;
509
+ #endif
510
+ geometry_thickness*=vGeometryThicknessInfos.y;
511
+ #endif
512
+ #ifdef ALPHATEST
513
+ #if DEBUGMODE != 88
514
+ if (alpha<ALPHATESTVALUE)
515
+ discard;
516
+ #endif
517
+ #ifndef ALPHABLEND
518
+ alpha=1.0;
519
+ #endif
520
+ #endif
521
+ #ifdef BASE_METALNESS
522
+ #ifdef BASE_METALNESS_FROM_METALNESS_TEXTURE_BLUE
523
+ base_metalness*=metallicFromTexture.b;
524
+ #else
525
+ base_metalness*=metallicFromTexture.r;
526
+ #endif
527
+ #endif
528
+ #ifdef BASE_DIFFUSE_ROUGHNESS
529
+ base_diffuse_roughness*=baseDiffuseRoughnessFromTexture*vBaseDiffuseRoughnessInfos.y;
530
+ #endif
531
+ #ifdef SPECULAR_COLOR
532
+ #ifdef SPECULAR_COLOR_GAMMA
533
+ specular_color*=toLinearSpace(specularColorFromTexture.rgb);
534
+ #else
535
+ specular_color*=specularColorFromTexture.rgb;
536
+ #endif
537
+ #ifdef SPECULAR_WEIGHT_FROM_SPECULAR_COLOR_TEXTURE
538
+ specular_weight*=specularColorFromTexture.a;
539
+ #elif defined(SPECULAR_WEIGHT)
540
+ specular_weight*=specularWeightFromTexture;
541
+ #endif
542
+ #endif
543
+ #if defined(SPECULAR_ROUGHNESS) || (defined(SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN) && defined(BASE_METALNESS))
544
+ specular_roughness*=roughnessFromTexture;
545
+ #endif
546
+ #ifdef GEOMETRY_TANGENT
547
+ {vec2 tangentFromTexture=normalize(geometryTangentFromTexture.xy*2.0-1.0);float tangent_angle_texture=atan(tangentFromTexture.y,tangentFromTexture.x);float tangent_angle_uniform=atan(geometry_tangent.y,geometry_tangent.x);float tangent_angle=tangent_angle_texture+tangent_angle_uniform;geometry_tangent=vec2(cos(tangent_angle),sin(tangent_angle));}
548
+ #endif
549
+ #if defined(GEOMETRY_TANGENT) && defined(SPECULAR_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE)
550
+ specular_roughness_anisotropy*=geometryTangentFromTexture.b;
551
+ #elif defined(SPECULAR_ROUGHNESS_ANISOTROPY)
552
+ specular_roughness_anisotropy*=anisotropyFromTexture;
553
+ #endif
554
+ #ifdef DETAIL
555
+ float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);float loLerp=mix(0.,specular_roughness,detailRoughness*2.);float hiLerp=mix(specular_roughness,1.,(detailRoughness-0.5)*2.);specular_roughness=mix(loLerp,hiLerp,step(detailRoughness,0.5));
556
+ #endif
557
+ #ifdef USE_GLTF_STYLE_ANISOTROPY
558
+ float baseAlpha=specular_roughness*specular_roughness;float roughnessT=mix(baseAlpha,1.0,specular_roughness_anisotropy*specular_roughness_anisotropy);float roughnessB=baseAlpha;specular_roughness_anisotropy=1.0-roughnessB/max(roughnessT,0.00001);specular_roughness=sqrt(roughnessT/sqrt(2.0/(1.0+(1.0-specular_roughness_anisotropy)*(1.0-specular_roughness_anisotropy))));
559
+ #endif
560
+ `;e.IncludesShadersStore[_]||(e.IncludesShadersStore[_]=C);const Be={name:_,shader:C},d="openpbrCoatLayerData",P=`float coat_weight=0.0;vec3 coat_color=vec3(1.0);float coat_roughness=0.0;float coat_roughness_anisotropy=0.0;float coat_ior=1.6;float coat_darkening=1.0;vec2 geometry_coat_tangent=vec2(1.0,0.0);
561
+ #ifdef COAT_WEIGHT
562
+ vec4 coatWeightFromTexture=TEXRD(coatWeightSampler,vCoatWeightUV+uvOffset);
563
+ #endif
564
+ #ifdef COAT_COLOR
565
+ vec4 coatColorFromTexture=TEXRD(coatColorSampler,vCoatColorUV+uvOffset);
566
+ #endif
567
+ #ifdef COAT_ROUGHNESS
568
+ vec4 coatRoughnessFromTexture=TEXRD(coatRoughnessSampler,vCoatRoughnessUV+uvOffset);
569
+ #endif
570
+ #ifdef COAT_ROUGHNESS_ANISOTROPY
571
+ float coatRoughnessAnisotropyFromTexture=TEXRD(coatRoughnessAnisotropySampler,vCoatRoughnessAnisotropyUV+uvOffset).r;
572
+ #endif
573
+ #ifdef COAT_DARKENING
574
+ vec4 coatDarkeningFromTexture=TEXRD(coatDarkeningSampler,vCoatDarkeningUV+uvOffset);
575
+ #endif
576
+ #ifdef GEOMETRY_COAT_TANGENT
577
+ vec3 geometryCoatTangentFromTexture=TEXRD(geometryCoatTangentSampler,vGeometryCoatTangentUV+uvOffset).rgb;
578
+ #endif
579
+ coat_color=vCoatColor.rgb;coat_weight=vCoatWeight;coat_roughness=vCoatRoughness;coat_roughness_anisotropy=vCoatRoughnessAnisotropy;coat_ior=vCoatIor;coat_darkening=vCoatDarkening;geometry_coat_tangent=vGeometryCoatTangent.rg;
580
+ #ifdef COAT_WEIGHT
581
+ coat_weight*=coatWeightFromTexture.r;
582
+ #endif
583
+ #ifdef COAT_COLOR
584
+ #ifdef COAT_COLOR_GAMMA
585
+ coat_color*=toLinearSpace(coatColorFromTexture.rgb);
586
+ #else
587
+ coat_color*=coatColorFromTexture.rgb;
588
+ #endif
589
+ coat_color*=vCoatColorInfos.y;
590
+ #endif
591
+ #ifdef COAT_ROUGHNESS
592
+ #ifdef COAT_ROUGHNESS_FROM_GREEN_CHANNEL
593
+ coat_roughness*=coatRoughnessFromTexture.g;
594
+ #else
595
+ coat_roughness*=coatRoughnessFromTexture.r;
596
+ #endif
597
+ #endif
598
+ #if defined(GEOMETRY_COAT_TANGENT) && defined(COAT_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE)
599
+ coat_roughness_anisotropy*=geometryCoatTangentFromTexture.b;
600
+ #elif defined(COAT_ROUGHNESS_ANISOTROPY)
601
+ coat_roughness_anisotropy*=coatRoughnessAnisotropyFromTexture;
602
+ #endif
603
+ #ifdef COAT_DARKENING
604
+ coat_darkening*=coatDarkeningFromTexture.r;
605
+ #endif
606
+ #ifdef GEOMETRY_COAT_TANGENT
607
+ {vec2 tangentFromTexture=normalize(geometryCoatTangentFromTexture.xy*2.0-1.0);float tangent_angle_texture=atan(tangentFromTexture.y,tangentFromTexture.x);float tangent_angle_uniform=atan(geometry_coat_tangent.y,geometry_coat_tangent.x);float tangent_angle=tangent_angle_texture+tangent_angle_uniform;geometry_coat_tangent=vec2(cos(tangent_angle),sin(tangent_angle));}
608
+ #endif
609
+ #ifdef USE_GLTF_STYLE_ANISOTROPY
610
+ float coatAlpha=coat_roughness*coat_roughness;float coatRoughnessT=mix(coatAlpha,1.0,coat_roughness_anisotropy*coat_roughness_anisotropy);float coatRoughnessB=coatAlpha;coat_roughness_anisotropy=1.0-coatRoughnessB/max(coatRoughnessT,0.00001);coat_roughness=sqrt(coatRoughnessT/sqrt(2.0/(1.0+(1.0-coat_roughness_anisotropy)*(1.0-coat_roughness_anisotropy))));
611
+ #endif
612
+ `;e.IncludesShadersStore[d]||(e.IncludesShadersStore[d]=P);const Ve={name:d,shader:P},m="openpbrThinFilmLayerData",M=`#ifdef THIN_FILM
613
+ float thin_film_weight=vThinFilmWeight;float thin_film_thickness=vThinFilmThickness.r*1000.0;
614
+ float thin_film_ior=vThinFilmIor;
615
+ #ifdef THIN_FILM_WEIGHT
616
+ float thinFilmWeightFromTexture=TEXRD(thinFilmWeightSampler,vThinFilmWeightUV+uvOffset).r*vThinFilmWeightInfos.y;
617
+ #endif
618
+ #ifdef THIN_FILM_THICKNESS
619
+ float thinFilmThicknessFromTexture=TEXRD(thinFilmThicknessSampler,vThinFilmThicknessUV+uvOffset).g*vThinFilmThicknessInfos.y;
620
+ #endif
621
+ #ifdef THIN_FILM_WEIGHT
622
+ thin_film_weight*=thinFilmWeightFromTexture;
623
+ #endif
624
+ #ifdef THIN_FILM_THICKNESS
625
+ thin_film_thickness*=thinFilmThicknessFromTexture;
626
+ #endif
627
+ float thin_film_ior_scale=clamp(2.0f*abs(thin_film_ior-1.0f),0.0f,1.0f);
628
+ #endif
629
+ `;e.IncludesShadersStore[m]||(e.IncludesShadersStore[m]=M);const ke={name:m,shader:M},u="openpbrFuzzLayerData",G=`float fuzz_weight=0.0;vec3 fuzz_color=vec3(1.0);float fuzz_roughness=0.0;
630
+ #ifdef FUZZ
631
+ #ifdef FUZZ_WEIGHT
632
+ vec4 fuzzWeightFromTexture=TEXRD(fuzzWeightSampler,vFuzzWeightUV+uvOffset);
633
+ #endif
634
+ #ifdef FUZZ_COLOR
635
+ vec4 fuzzColorFromTexture=TEXRD(fuzzColorSampler,vFuzzColorUV+uvOffset);
636
+ #endif
637
+ #ifdef FUZZ_ROUGHNESS
638
+ vec4 fuzzRoughnessFromTexture=TEXRD(fuzzRoughnessSampler,vFuzzRoughnessUV+uvOffset);
639
+ #endif
640
+ fuzz_color=vFuzzColor.rgb;fuzz_weight=vFuzzWeight;fuzz_roughness=vFuzzRoughness;
641
+ #ifdef FUZZ_WEIGHT
642
+ fuzz_weight*=fuzzWeightFromTexture.r;
643
+ #endif
644
+ #ifdef FUZZ_COLOR
645
+ #ifdef FUZZ_COLOR_GAMMA
646
+ fuzz_color*=toLinearSpace(fuzzColorFromTexture.rgb);
647
+ #else
648
+ fuzz_color*=fuzzColorFromTexture.rgb;
649
+ #endif
650
+ fuzz_color*=vFuzzColorInfos.y;
651
+ #endif
652
+ #if defined(FUZZ_ROUGHNESS) && defined(FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA)
653
+ fuzz_roughness*=fuzzRoughnessFromTexture.a;
654
+ #elif defined(FUZZ_ROUGHNESS)
655
+ fuzz_roughness*=fuzzRoughnessFromTexture.r;
656
+ #endif
657
+ #endif
658
+ `;e.IncludesShadersStore[u]||(e.IncludesShadersStore[u]=G);const Ye={name:u,shader:G},g="openpbrAmbientOcclusionData",x=`vec3 ambient_occlusion=vec3(1.0);float specular_ambient_occlusion=1.0;float coat_specular_ambient_occlusion=1.0;
659
+ #ifdef AMBIENT_OCCLUSION
660
+ vec3 ambientOcclusionFromTexture=TEXRD(ambientOcclusionSampler,vAmbientOcclusionUV+uvOffset).rgb;ambient_occlusion=vec3(ambientOcclusionFromTexture.r*vAmbientOcclusionInfos.y+(1.0-vAmbientOcclusionInfos.y));
661
+ #endif
662
+ `;e.IncludesShadersStore[g]||(e.IncludesShadersStore[g]=x);const Ze={name:g,shader:x},E="openpbrBackgroundTransmission",y=`vec4 slab_translucent_background=vec4(0.,0.,0.,1.);
663
+ #ifdef REFRACTED_BACKGROUND
664
+ {float refractionLOD=min(transmission_roughness,0.8)*vBackgroundRefractionInfos.x;float lodTexelSize=pow(2.0,refractionLOD-vBackgroundRefractionInfos.x);
665
+ #ifdef DISPERSION
666
+ {
667
+ #ifdef REFRACTION_HIGH_QUALITY_BLUR
668
+ {vec3 dispResult=vec3(0.0);vec3 dispWeight=vec3(0.0);vec2 noiseOffset=noise.xy*(refractionLOD>0.0 ? lodTexelSize : 0.0);for (int k=0; k<6; k++) {float t=(float(k)+noise.y)/6.0;float t_rg=clamp(t*2.0,0.0,1.0);float t_gb=clamp((t-0.5)*2.0,0.0,1.0);vec3 refVec=mix(mix(refractedViewVectors[0],refractedViewVectors[1],t_rg),refractedViewVectors[2],t_gb);vec3 uvw=vec3(backgroundRefractionMatrix*(view*vec4(vPositionW+refVec*geometry_thickness,1.0)));vec2 coords=uvw.xy/uvw.z;coords.y=1.0-coords.y;vec4 s=texture2DLodEXT(backgroundRefractionSampler,coords+noiseOffset,refractionLOD);float rw=max(0.0,1.0-2.0*t);float gw=max(0.0,1.0-abs(2.0*t-1.0));float bw=max(0.0,2.0*t-1.0);vec3 w=vec3(rw,gw,bw);dispResult+=s.rgb*w;dispWeight+=w;}
669
+ slab_translucent_background=vec4(dispResult/max(dispWeight,vec3(1e-6)),1.0);}
670
+ #else
671
+ for (int i=0; i<3; i++) {vec3 refractedViewVector=refractedViewVectors[i];vec3 uvw=vec3(backgroundRefractionMatrix*(view*vec4(vPositionW+refractedViewVector*geometry_thickness,1.0)));vec2 coords=uvw.xy/uvw.z;coords.y=1.0-coords.y;if (refractionLOD>0.0) {vec2 noiseOffset=noise.xy*lodTexelSize;slab_translucent_background[i]=texture2DLodEXT(backgroundRefractionSampler,coords+noiseOffset,refractionLOD)[i];} else {slab_translucent_background[i]=texture2DLodEXT(backgroundRefractionSampler,coords,0.0)[i];}}
672
+ #endif
673
+ }
674
+ #else
675
+ {vec3 refractionUVW=vec3(backgroundRefractionMatrix*(view*vec4(vPositionW+refractedViewVector*geometry_thickness,1.0)));vec2 refractionCoords=refractionUVW.xy/refractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;if (refractionLOD>0.0) {
676
+ #ifdef REFRACTION_HIGH_QUALITY_BLUR
677
+ float cosA=cos(noise.x*PI);float sinA=sin(noise.x*PI);vec2 u=vec2( cosA,sinA)*(0.5*lodTexelSize);vec2 v=vec2(-sinA,cosA)*(0.5*lodTexelSize);slab_translucent_background=0.25*(
678
+ texture2DLodEXT(backgroundRefractionSampler,refractionCoords+u+v,refractionLOD) +
679
+ texture2DLodEXT(backgroundRefractionSampler,refractionCoords-u+v,refractionLOD) +
680
+ texture2DLodEXT(backgroundRefractionSampler,refractionCoords+u-v,refractionLOD) +
681
+ texture2DLodEXT(backgroundRefractionSampler,refractionCoords-u-v,refractionLOD)
682
+ );
683
+ #else
684
+ vec2 noiseOffset=noise.xy*lodTexelSize;slab_translucent_background=texture2DLodEXT(backgroundRefractionSampler,refractionCoords+noiseOffset,refractionLOD);
685
+ #endif
686
+ } else {slab_translucent_background=texture2DLodEXT(backgroundRefractionSampler,refractionCoords,0.0);}}
687
+ #endif
688
+ }
689
+ #endif
690
+ `;e.IncludesShadersStore[E]||(e.IncludesShadersStore[E]=y);const $e={name:E,shader:y},v="openpbrEnvironmentLighting",z=`#if defined(REFLECTION) || defined(REFRACTED_BACKGROUND)
691
+ vec3 coatAbsorption=vec3(1.0);float coatIblFresnel=0.0;if (coat_weight>0.0) {coatIblFresnel=computeDielectricIblFresnel(coatReflectance,coatGeoInfo.environmentBrdf);float hemisphere_avg_fresnel=coatReflectance.F0+0.5*(1.0-coatReflectance.F0);float averageReflectance=(coatIblFresnel+hemisphere_avg_fresnel)*0.5;float roughnessFactor=1.0-coat_roughness*0.5;averageReflectance*=roughnessFactor;float darkened_transmission=(1.0-averageReflectance)*(1.0-averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);float sin2=1.0-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior)*coat_weight;float cos_t=sqrt(1.0-sin2);float coatPathLength=1.0/cos_t;float effectivePathLength=coatPathLength*coat_weight;vec3 colored_transmission=pow(coat_color,vec3(effectivePathLength));coatAbsorption=colored_transmission*mix(1.0,darkened_transmission,coat_weight);}
692
+ #endif
693
+ #ifdef REFLECTION
694
+ #if defined(FUZZ) && defined(FUZZENVIRONMENTBRDF)
695
+ vec3 environmentFuzzBrdf=getFuzzBRDFLookup(fuzzGeoInfo.NdotV,sqrt(fuzz_roughness));
696
+ #endif
697
+ vec3 baseDiffuseEnvironmentLight=sampleIrradiance(
698
+ normalW
699
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
700
+ ,vEnvironmentIrradiance
701
+ #endif
702
+ #if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
703
+ ,reflectionMatrix
704
+ #endif
705
+ #ifdef USEIRRADIANCEMAP
706
+ ,irradianceSampler
707
+ #ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
708
+ ,vReflectionDominantDirection
709
+ #endif
710
+ #endif
711
+ #ifdef REALTIME_FILTERING
712
+ ,vReflectionFilteringInfo
713
+ #ifdef IBL_CDF_FILTERING
714
+ ,icdfSampler
715
+ #endif
716
+ #endif
717
+ ,vReflectionInfos
718
+ ,viewDirectionW
719
+ ,base_diffuse_roughness
720
+ ,base_color
721
+ );
722
+ #ifdef REFLECTIONMAP_3D
723
+ vec3 reflectionCoords=vec3(0.,0.,0.);
724
+ #else
725
+ vec2 reflectionCoords=vec2(0.,0.);
726
+ #endif
727
+ float specularAlphaG=specular_roughness*specular_roughness;
728
+ #ifdef ANISOTROPIC_BASE
729
+ vec3 baseSpecularEnvironmentLight=sampleRadianceAnisotropic(specularAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
730
+ ,baseGeoInfo
731
+ ,normalW
732
+ ,viewDirectionW
733
+ ,vPositionW
734
+ ,noise
735
+ ,false
736
+ ,1.0
737
+ ,reflectionSampler
738
+ #ifdef REALTIME_FILTERING
739
+ ,vReflectionFilteringInfo
740
+ #endif
741
+ );
742
+ #else
743
+ reflectionCoords=createReflectionCoords(vPositionW,normalW);vec3 baseSpecularEnvironmentLight=sampleRadiance(specularAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
744
+ ,baseGeoInfo
745
+ ,reflectionSampler
746
+ ,reflectionCoords
747
+ #ifdef REALTIME_FILTERING
748
+ ,vReflectionFilteringInfo
749
+ #endif
750
+ );
751
+ #endif
752
+ #ifdef ANISOTROPIC_BASE
753
+ baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG*specularAlphaG*max(1.0-baseGeoInfo.anisotropy,0.3));
754
+ #else
755
+ baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG);
756
+ #endif
757
+ vec3 coatEnvironmentLight=vec3(0.,0.,0.);if (coat_weight>0.0) {
758
+ #ifdef REFLECTIONMAP_3D
759
+ vec3 reflectionCoords=vec3(0.,0.,0.);
760
+ #else
761
+ vec2 reflectionCoords=vec2(0.,0.);
762
+ #endif
763
+ reflectionCoords=createReflectionCoords(vPositionW,coatNormalW);float coatAlphaG=coat_roughness*coat_roughness;
764
+ #ifdef ANISOTROPIC_COAT
765
+ coatEnvironmentLight=sampleRadianceAnisotropic(coatAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
766
+ ,coatGeoInfo
767
+ ,coatNormalW
768
+ ,viewDirectionW
769
+ ,vPositionW
770
+ ,noise
771
+ ,false
772
+ ,1.0
773
+ ,reflectionSampler
774
+ #ifdef REALTIME_FILTERING
775
+ ,vReflectionFilteringInfo
776
+ #endif
777
+ );
778
+ #else
779
+ coatEnvironmentLight=sampleRadiance(coatAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
780
+ ,coatGeoInfo
781
+ ,reflectionSampler
782
+ ,reflectionCoords
783
+ #ifdef REALTIME_FILTERING
784
+ ,vReflectionFilteringInfo
785
+ #endif
786
+ );
787
+ #endif
788
+ }
789
+ #if defined(FUZZ) && defined(FUZZENVIRONMENTBRDF)
790
+ float modifiedFuzzRoughness=clamp(fuzz_roughness*fuzz_roughness*(1.0+0.5*environmentFuzzBrdf.y),0.0,1.0);vec3 fuzzEnvironmentLight=vec3(0.0);float fuzzIblFresnel=min(environmentFuzzBrdf.z*2.0,1.0);vec2 viewTangent=vec2(dot(viewDirectionW,fuzzTangent),dot(viewDirectionW,fuzzBitangent));float centerAngle=atan(viewTangent.y,viewTangent.x);for (int i=0; i<FUZZ_IBL_SAMPLES; ++i) {float angle=centerAngle+(float(i)/float(FUZZ_IBL_SAMPLES)-0.5+noise.x/float(FUZZ_IBL_SAMPLES))*3.141592;vec3 fiberCylinderNormal=normalize(cos(angle)*fuzzTangent+sin(angle)*fuzzBitangent);vec3 fuzzReflectionCoords=vec3(reflectionMatrix*vec4(fiberCylinderNormal,0));vec3 radianceSample=sampleRadiance(modifiedFuzzRoughness,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
791
+ ,fuzzGeoInfo
792
+ ,reflectionSampler
793
+ ,fuzzReflectionCoords
794
+ #ifdef REALTIME_FILTERING
795
+ ,vReflectionFilteringInfo
796
+ #endif
797
+ );fuzzEnvironmentLight+=radianceSample;}
798
+ fuzzEnvironmentLight/=float(FUZZ_IBL_SAMPLES);
799
+ #if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL)
800
+ vec3 fuzzDiffuseEnvironmentLight=sampleIrradiance(
801
+ fuzzNormalW
802
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
803
+ ,vEnvironmentIrradiance
804
+ #endif
805
+ #if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
806
+ ,reflectionMatrix
807
+ #endif
808
+ #ifdef USEIRRADIANCEMAP
809
+ ,irradianceSampler
810
+ #ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
811
+ ,vReflectionDominantDirection
812
+ #endif
813
+ #endif
814
+ #ifdef REALTIME_FILTERING
815
+ ,vReflectionFilteringInfo
816
+ #ifdef IBL_CDF_FILTERING
817
+ ,icdfSampler
818
+ #endif
819
+ #endif
820
+ ,vReflectionInfos
821
+ ,viewDirectionW
822
+ ,0.0
823
+ ,vec3(1.0)
824
+ );
825
+ #else
826
+ vec3 fuzzDiffuseEnvironmentLight=baseDiffuseEnvironmentLight;
827
+ #endif
828
+ fuzzEnvironmentLight=mix(min(fuzzEnvironmentLight,fuzzDiffuseEnvironmentLight),fuzzDiffuseEnvironmentLight,modifiedFuzzRoughness);
829
+ #endif
830
+ float dielectricIblFresnel=computeDielectricIblFresnel(baseDielectricReflectance,baseGeoInfo.environmentBrdf);vec3 dielectricIblColoredFresnel=dielectricIblFresnel*specular_color;
831
+ #ifdef THIN_FILM
832
+ float thin_film_cos_theta=max(baseGeoInfo.NdotV,specularAlphaG);float thin_film_desaturation_scale=(thin_film_ior-1.0)*sqrt(thin_film_thickness*0.001*thin_film_cos_theta);float tf_brdf_x=baseGeoInfo.environmentBrdf.x;float tf_E_ss =baseGeoInfo.environmentBrdf.y;vec3 thinFilmDielectricF0=evalIridescence(thin_film_outside_ior,thin_film_ior,1.0,thin_film_thickness,vec3(baseDielectricReflectance.F0));thinFilmDielectricF0=mix(thinFilmDielectricF0,vec3(dot(thinFilmDielectricF0,vec3(0.3333))),thin_film_desaturation_scale);vec3 thinFilmDielectricDir=evalIridescence(thin_film_outside_ior,thin_film_ior,thin_film_cos_theta,thin_film_thickness,vec3(baseDielectricReflectance.F0));thinFilmDielectricDir=mix(thinFilmDielectricDir,vec3(dot(thinFilmDielectricDir,vec3(0.3333))),thin_film_desaturation_scale);float tf_f0d_avg =dot(thinFilmDielectricF0, vec3(0.3333));float tf_dird_avg=dot(thinFilmDielectricDir,vec3(0.3333));vec3 thinFilmDielectricFresnel=thinFilmDielectricDir*(tf_f0d_avg/max(tf_dird_avg,1e-5));vec3 tf_E_dielectric=(vec3(1.0)-thinFilmDielectricFresnel)*vec3(tf_brdf_x)+thinFilmDielectricFresnel*vec3(tf_E_ss);vec3 tf_F_avg_dielectric=thinFilmDielectricFresnel+(vec3(1.0)-thinFilmDielectricFresnel)/21.0;vec3 tf_ECF_dielectric=vec3(1.0)+tf_F_avg_dielectric*(vec3(1.0)/vec3(tf_E_ss)-vec3(1.0));thinFilmDielectricFresnel=clamp(tf_E_dielectric*tf_ECF_dielectric,vec3(0.0),vec3(1.0));dielectricIblColoredFresnel=mix(dielectricIblColoredFresnel,thinFilmDielectricFresnel*specular_color,thin_film_weight*thin_film_ior_scale);dielectricIblFresnel=max(dielectricIblColoredFresnel.r,max(dielectricIblColoredFresnel.g,dielectricIblColoredFresnel.b));
833
+ #endif
834
+ vec3 conductorIblFresnel=computeConductorIblFresnel(baseConductorReflectance,baseGeoInfo.environmentBrdf);
835
+ #ifdef THIN_FILM
836
+ vec3 thinFilmConductorF0=evalIridescence(thin_film_outside_ior,thin_film_ior,1.0,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorF0=mix(thinFilmConductorF0,vec3(dot(thinFilmConductorF0,vec3(0.3333))),thin_film_desaturation_scale);vec3 thinFilmConductorDir=evalIridescence(thin_film_outside_ior,thin_film_ior,thin_film_cos_theta,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorDir=mix(thinFilmConductorDir,vec3(dot(thinFilmConductorDir,vec3(0.3333))),thin_film_desaturation_scale);float tf_f0c_avg =dot(thinFilmConductorF0, vec3(0.3333));float tf_dirc_avg=dot(thinFilmConductorDir,vec3(0.3333));vec3 thinFilmConductorRaw=thinFilmConductorDir*(tf_f0c_avg/max(tf_dirc_avg,1e-5));
837
+ #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) && defined(ENVIRONMENTBRDF)
838
+ vec3 tf_b=getF82B(baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);float tf_brdf_z=baseGeoInfo.environmentBrdf.z/BRDF_Z_SCALE;vec3 tf_E_conductor=(vec3(1.0)-thinFilmConductorRaw)*vec3(tf_brdf_x)+thinFilmConductorRaw*vec3(tf_E_ss)-tf_b*vec3(tf_brdf_z);vec3 tf_F_avg_conductor=thinFilmConductorRaw+(vec3(1.0)-thinFilmConductorRaw)/21.0-tf_b/126.0;
839
+ #else
840
+ vec3 tf_E_conductor=(vec3(1.0)-thinFilmConductorRaw)*vec3(tf_brdf_x)+thinFilmConductorRaw*vec3(tf_E_ss);vec3 tf_F_avg_conductor=thinFilmConductorRaw+(vec3(1.0)-thinFilmConductorRaw)/21.0;
841
+ #endif
842
+ vec3 tf_ECF_conductor=vec3(1.0)+tf_F_avg_conductor*(vec3(1.0)/vec3(tf_E_ss)-vec3(1.0));vec3 thinFilmConductorFresnel=specular_weight*clamp(tf_E_conductor*tf_ECF_conductor,vec3(0.0),vec3(1.0));conductorIblFresnel=mix(conductorIblFresnel,thinFilmConductorFresnel,thin_film_weight*thin_film_ior_scale);
843
+ #endif
844
+ vec3 slab_diffuse_ibl=vec3(0.,0.,0.);vec3 slab_glossy_ibl=vec3(0.,0.,0.);vec3 slab_metal_ibl=vec3(0.,0.,0.);vec3 slab_coat_ibl=vec3(0.,0.,0.);slab_diffuse_ibl=baseDiffuseEnvironmentLight*vLightingIntensity.z;
845
+ #ifdef AMBIENT_OCCLUSION
846
+ specular_ambient_occlusion=compute_specular_occlusion(baseGeoInfo.NdotV,base_metalness,ambient_occlusion.x,specular_roughness);
847
+ #endif
848
+ slab_glossy_ibl=baseSpecularEnvironmentLight*vLightingIntensity.z;slab_metal_ibl=baseSpecularEnvironmentLight*conductorIblFresnel*vLightingIntensity.z;if (coat_weight>0.0) {slab_coat_ibl=coatEnvironmentLight*vLightingIntensity.z;
849
+ #ifdef AMBIENT_OCCLUSION
850
+ coat_specular_ambient_occlusion=compute_specular_occlusion(coatGeoInfo.NdotV,0.0,ambient_occlusion.x,coat_roughness);
851
+ #endif
852
+ }
853
+ #if defined(FUZZ) && defined(FUZZENVIRONMENTBRDF)
854
+ vec3 slab_fuzz_ibl=fuzzEnvironmentLight*vLightingIntensity.z;
855
+ #endif
856
+ vec3 slab_translucent_base_ibl=vec3(0.0);vec3 slab_subsurface_ibl=vec3(0.,0.,0.);
857
+ #ifdef REFRACTED_ENVIRONMENT
858
+ #ifdef ANISOTROPIC_BASE
859
+ vec3 forwardScatteredEnvironmentLight=sampleRadianceAnisotropic(transmission_roughness_alpha,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
860
+ ,baseGeoInfo
861
+ #ifdef GEOMETRY_THIN_WALLED
862
+ ,viewDirectionW
863
+ #else
864
+ ,normalW
865
+ #endif
866
+ ,viewDirectionW
867
+ ,vPositionW
868
+ ,noise
869
+ ,true
870
+ #ifdef GEOMETRY_THIN_WALLED
871
+ ,1.05
872
+ #else
873
+ ,specular_ior
874
+ #endif
875
+ ,reflectionSampler
876
+ #ifdef REALTIME_FILTERING
877
+ ,vReflectionFilteringInfo
878
+ #endif
879
+ );
880
+ #else
881
+ vec3 forwardScatteredEnvironmentLight=vec3(0.,0.,0.);
882
+ #ifdef DISPERSION
883
+ for (int i=0; i<3; i++) {vec3 iblRefractionCoords=refractedViewVectors[i];
884
+ #else
885
+ vec3 iblRefractionCoords=refractedViewVector;
886
+ #endif
887
+ #ifdef REFRACTED_ENVIRONMENT_OPPOSITEZ
888
+ iblRefractionCoords.z*=-1.0;
889
+ #endif
890
+ #ifdef REFRACTED_ENVIRONMENT_LOCAL_CUBE
891
+ iblRefractionCoords=parallaxCorrectNormal(vPositionW,refractedViewVector,refractionSize,refractionPosition);
892
+ #endif
893
+ iblRefractionCoords=vec3(reflectionMatrix*vec4(iblRefractionCoords,0));
894
+ #ifdef DISPERSION
895
+ forwardScatteredEnvironmentLight[i]=sampleRadiance(transmission_roughness_alpha,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
896
+ ,baseGeoInfo
897
+ ,reflectionSampler
898
+ ,iblRefractionCoords
899
+ #ifdef REALTIME_FILTERING
900
+ ,vReflectionFilteringInfo
901
+ #endif
902
+ )[i];
903
+ #else
904
+ forwardScatteredEnvironmentLight=sampleRadiance(transmission_roughness_alpha,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
905
+ ,baseGeoInfo
906
+ ,reflectionSampler
907
+ ,iblRefractionCoords
908
+ #ifdef REALTIME_FILTERING
909
+ ,vReflectionFilteringInfo
910
+ #endif
911
+ );
912
+ #endif
913
+ #ifdef DISPERSION
914
+ }
915
+ #endif
916
+ #endif
917
+ #ifdef REFRACTED_BACKGROUND
918
+ #ifdef GEOMETRY_THIN_WALLED
919
+ forwardScatteredEnvironmentLight=mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight.rgb,0.2*transmission_roughness_alpha);
920
+ #else
921
+ forwardScatteredEnvironmentLight=max(slab_translucent_background.rgb,mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight,transmission_roughness_alpha));
922
+ #endif
923
+ #endif
924
+ #ifdef SCATTERING
925
+ #ifdef GEOMETRY_THIN_WALLED
926
+ vec3 scatterVector=normalW;
927
+ #else
928
+ #if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)
929
+ vec3 scatterVector=mix(vReflectionDominantDirection,normalW,max3(iso_scatter_density));
930
+ #else
931
+ vec3 scatterVector=normalW;
932
+ #endif
933
+ scatterVector=mix(viewDirectionW,scatterVector,back_to_iso_scattering_blend);
934
+ #endif
935
+ #if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(GEOMETRY_THIN_WALLED)
936
+ vec3 scatteredEnvironmentLight=scattered_light_from_irradiance_texture;
937
+ #else
938
+ vec3 scatteredEnvironmentLight=sampleIrradiance(
939
+ scatterVector
940
+ #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
941
+ ,vEnvironmentIrradiance
942
+ #endif
943
+ #if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
944
+ ,reflectionMatrix
945
+ #endif
946
+ #ifdef USEIRRADIANCEMAP
947
+ ,irradianceSampler
948
+ #ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
949
+ ,vReflectionDominantDirection
950
+ #endif
951
+ #endif
952
+ #ifdef REALTIME_FILTERING
953
+ ,vReflectionFilteringInfo
954
+ #ifdef IBL_CDF_FILTERING
955
+ ,icdfSampler
956
+ #endif
957
+ #endif
958
+ ,vReflectionInfos
959
+ ,viewDirectionW
960
+ #if defined(GEOMETRY_THIN_WALLED)
961
+ ,base_diffuse_roughness
962
+ ,subsurface_color.rgb
963
+ #else
964
+ ,1.0
965
+ ,volumeParams.multi_scatter_color
966
+ #endif
967
+ );
968
+ #endif
969
+ #ifdef GEOMETRY_THIN_WALLED
970
+ vec3 forward_scattered_light=forwardScatteredEnvironmentLight*transmission_tint*volumeParams.multi_scatter_color;vec3 back_scattered_light=scatteredEnvironmentLight*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(back_scattered_light,forward_scattered_light,0.5+0.5*volumeParams.anisotropy);
971
+ #else
972
+ vec3 forward_scattered_light=forwardScatteredEnvironmentLight*volume_absorption;vec3 back_scattered_light=mix(forward_scattered_light,scatteredEnvironmentLight*backscatter_color,iso_scatter_density);vec3 iso_scattered_light=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;
973
+ #endif
974
+ #else
975
+ slab_translucent_base_ibl+=forwardScatteredEnvironmentLight*transmission_tint*volume_absorption;
976
+ #endif
977
+ #endif
978
+ #define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION
979
+ slab_diffuse_ibl*=ambient_occlusion;slab_metal_ibl*=specular_ambient_occlusion;slab_glossy_ibl*=specular_ambient_occlusion;slab_coat_ibl*=coat_specular_ambient_occlusion;vec3 material_dielectric_base_ibl=mix(slab_diffuse_ibl*base_color.rgb,slab_translucent_base_ibl,surface_translucency_weight);vec3 material_dielectric_gloss_ibl=material_dielectric_base_ibl*(1.0-dielectricIblFresnel)+slab_glossy_ibl*dielectricIblColoredFresnel;vec3 material_base_substrate_ibl=mix(material_dielectric_gloss_ibl,slab_metal_ibl,base_metalness);vec3 material_coated_base_ibl=layer(material_base_substrate_ibl,slab_coat_ibl,coatIblFresnel,coatAbsorption,vec3(1.0));
980
+ #if defined(FUZZ) && defined(FUZZENVIRONMENTBRDF)
981
+ slab_fuzz_ibl*=min(vec3(specular_ambient_occlusion),ambient_occlusion);material_surface_ibl=layer(material_coated_base_ibl,slab_fuzz_ibl,fuzzIblFresnel*fuzz_weight,vec3(1.0),fuzz_color);
982
+ #else
983
+ material_surface_ibl=material_coated_base_ibl;
984
+ #endif
985
+ #elif defined(REFRACTED_BACKGROUND)
986
+ vec3 black=vec3(0.0);vec3 slab_translucent_base_ibl=vec3(0.0);
987
+ #ifdef GEOMETRY_THIN_WALLED
988
+ #ifdef SCATTERING
989
+ vec3 forward_scattered_light=slab_translucent_background.rgb*transmission_tint*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(black,forward_scattered_light,0.5+0.5*volumeParams.anisotropy);
990
+ #else
991
+ slab_translucent_base_ibl=slab_translucent_background.rgb*transmission_tint;
992
+ #endif
993
+ #else
994
+ #ifdef SCATTERING
995
+ vec3 forward_scattered_light=slab_translucent_background.rgb*volume_absorption;vec3 iso_scattered_light=(1.0-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;
996
+ #else
997
+ slab_translucent_base_ibl=slab_translucent_background.rgb*volume_absorption*transmission_tint;
998
+ #endif
999
+ #endif
1000
+ vec3 material_dielectric_base_ibl=mix(black,slab_translucent_base_ibl.rgb,surface_translucency_weight);vec3 material_dielectric_gloss_ibl=material_dielectric_base_ibl*(baseGeoInfo.NdotV);vec3 material_base_substrate_ibl=mix(material_dielectric_gloss_ibl,black,base_metalness);vec3 material_coated_base_ibl=layer(material_base_substrate_ibl,black,coatIblFresnel,coatAbsorption,vec3(1.0));material_surface_ibl=material_coated_base_ibl;
1001
+ #endif
1002
+ `;e.IncludesShadersStore[v]||(e.IncludesShadersStore[v]=z);const je={name:v,shader:z},p="openpbrDirectLightingInit",U=`#ifdef LIGHT{X}
1003
+ preLightingInfo preInfo{X};preLightingInfo preInfoCoat{X};vec4 lightColor{X}=light{X}.vLightDiffuse;float shadow{X}=1.;
1004
+ #if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
1005
+ #else
1006
+ #define CUSTOM_LIGHT{X}_COLOR
1007
+ #ifdef SPOTLIGHT{X}
1008
+ preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);
1009
+ #elif defined(POINTLIGHT{X})
1010
+ preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);
1011
+ #elif defined(HEMILIGHT{X})
1012
+ preInfo{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);
1013
+ #elif defined(DIRLIGHT{X})
1014
+ preInfo{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);
1015
+ #elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1016
+ preInfo{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,specular_roughness);preInfoCoat{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,coatNormalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,coat_roughness);
1017
+ #endif
1018
+ preInfo{X}.NdotV=baseGeoInfo.NdotV;preInfoCoat{X}.NdotV=coatGeoInfo.NdotV;
1019
+ #ifdef SPOTLIGHT{X}
1020
+ #ifdef LIGHT_FALLOFF_GLTF{X}
1021
+ preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);
1022
+ #ifdef IESLIGHTTEXTURE{X}
1023
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
1024
+ #else
1025
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
1026
+ #endif
1027
+ #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
1028
+ preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);
1029
+ #ifdef IESLIGHTTEXTURE{X}
1030
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
1031
+ #else
1032
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w);
1033
+ #endif
1034
+ #elif defined(LIGHT_FALLOFF_STANDARD{X})
1035
+ preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);
1036
+ #ifdef IESLIGHTTEXTURE{X}
1037
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
1038
+ #else
1039
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
1040
+ #endif
1041
+ #else
1042
+ preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
1043
+ #ifdef IESLIGHTTEXTURE{X}
1044
+ preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
1045
+ #else
1046
+ 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);
1047
+ #endif
1048
+ #endif
1049
+ #elif defined(POINTLIGHT{X})
1050
+ #ifdef LIGHT_FALLOFF_GLTF{X}
1051
+ preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);
1052
+ #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
1053
+ preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);
1054
+ #elif defined(LIGHT_FALLOFF_STANDARD{X})
1055
+ preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);
1056
+ #else
1057
+ preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
1058
+ #endif
1059
+ #else
1060
+ preInfo{X}.attenuation=1.0;
1061
+ #endif
1062
+ preInfoCoat{X}.attenuation=preInfo{X}.attenuation;
1063
+ #if defined(HEMILIGHT{X})
1064
+ preInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;
1065
+ #elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1066
+ preInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;
1067
+ #else
1068
+ 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);
1069
+ #endif
1070
+ preInfo{X}.diffuseRoughness=base_diffuse_roughness;preInfo{X}.surfaceAlbedo=base_color.rgb;
1071
+ #endif
1072
+ #endif
1073
+ `;e.IncludesShadersStore[p]||(e.IncludesShadersStore[p]=U);const qe={name:p,shader:U},h="openpbrDirectLighting",X=`#ifdef LIGHT{X}
1074
+ {vec3 slab_diffuse=vec3(0.,0.,0.);vec3 slab_translucent=vec3(0.,0.,0.);vec3 slab_glossy=vec3(0.,0.,0.);float specularFresnel=0.0;vec3 specularColoredFresnel=vec3(0.,0.,0.);vec3 slab_metal=vec3(0.,0.,0.);vec3 slab_coat=vec3(0.,0.,0.);float coatFresnel=0.0;vec3 slab_fuzz=vec3(0.,0.,0.);float fuzzFresnel=0.0;
1075
+ #ifdef HEMILIGHT{X}
1076
+ slab_diffuse=computeHemisphericDiffuseLighting(preInfo{X},lightColor{X}.rgb,light{X}.vLightGround);
1077
+ #elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1078
+ slab_diffuse=computeAreaDiffuseLighting(preInfo{X},lightColor{X}.rgb);
1079
+ #else
1080
+ slab_diffuse=computeDiffuseLighting(preInfo{X},lightColor{X}.rgb);
1081
+ #endif
1082
+ #ifdef PROJECTEDLIGHTTEXTURE{X}
1083
+ slab_diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW);
1084
+ #endif
1085
+ #ifdef FUZZ
1086
+ float fuzzNdotH=max(dot(fuzzNormalW,preInfo{X}.H),0.0);vec3 fuzzBrdf=getFuzzBRDFLookup(fuzzNdotH,sqrt(fuzz_roughness));
1087
+ #endif
1088
+ #ifdef THIN_FILM
1089
+ float thin_film_desaturation_scale=(thin_film_ior-1.0)*sqrt(thin_film_thickness*0.001);
1090
+ #endif
1091
+ #if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1092
+ slab_glossy=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);
1093
+ #else
1094
+ {
1095
+ #ifdef ANISOTROPIC_BASE
1096
+ slab_glossy=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,
1097
+ baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,
1098
+ 0.0,lightColor{X}.rgb);
1099
+ #else
1100
+ slab_glossy=computeSpecularLighting(preInfo{X},normalW,vec3(1.0),vec3(1.0),specular_roughness,lightColor{X}.rgb);
1101
+ #endif
1102
+ specularFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseDielectricReflectance.F0,baseDielectricReflectance.F90);specularColoredFresnel=specularFresnel*specular_color;
1103
+ #ifdef THIN_FILM
1104
+ vec3 thinFilmDielectricFresnel=evalIridescence(thin_film_outside_ior,thin_film_ior,preInfo{X}.VdotH,thin_film_thickness,vec3(baseDielectricReflectance.F0));thinFilmDielectricFresnel=mix(thinFilmDielectricFresnel,vec3(dot(thinFilmDielectricFresnel,vec3(0.3333))),thin_film_desaturation_scale);specularColoredFresnel=mix(specularColoredFresnel,thinFilmDielectricFresnel*specular_color,thin_film_weight*thin_film_ior_scale);
1105
+ #endif
1106
+ }
1107
+ #endif
1108
+ #ifdef REFRACTED_LIGHTS
1109
+ vec3 forwardScatteredLight=vec3(0.0);
1110
+ #if AREALIGHT{X}
1111
+ #else
1112
+ {preLightingInfo preInfoTrans=preInfo{X};
1113
+ #ifdef SCATTERING
1114
+ preInfoTrans.roughness=sqrt(sqrt(max(transmission_roughness_alpha,0.05)));
1115
+ #else
1116
+ preInfoTrans.roughness=transmission_roughness;
1117
+ #endif
1118
+ if (preInfoTrans.NdotLUnclamped<=0.0) {specularFresnel=0.0;specularColoredFresnel=specularFresnel*specular_color;}
1119
+ #ifdef GEOMETRY_THIN_WALLED
1120
+ vec3 refractNormalW=viewDirectionW;
1121
+ #else
1122
+ vec3 refractNormalW=normalW;
1123
+ #endif
1124
+ preInfoTrans.NdotL=0.5*max(dot(-refractNormalW,preInfoTrans.L),0.0)+0.5;
1125
+ #if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)
1126
+ float diff=min(dispersion_iors[2]-dispersion_iors[0],max(dispersion_iors[0]-1.0,1.0));dispersion_iors[2]+=diff;dispersion_iors[0]-=diff;for (int i=0; i<3; i++) {float eta=1.0/dispersion_iors[i];
1127
+ #elif defined(GEOMETRY_THIN_WALLED)
1128
+ float eta=1.0;
1129
+ #else
1130
+ float eta=1.0/specular_ior;
1131
+ #endif
1132
+ preInfoTrans.H=preInfoTrans.L+min(eta,0.95)*viewDirectionW;float len2=dot(preInfoTrans.H,preInfoTrans.H);if (len2<1e-6) {preInfoTrans.H=preInfoTrans.L;} else {preInfoTrans.H=preInfoTrans.H*inversesqrt(len2);}
1133
+ #ifdef ANISOTROPIC_BASE
1134
+ preInfoTrans.H=-preInfoTrans.H;
1135
+ #endif
1136
+ preInfoTrans.VdotH=dot(viewDirectionW,preInfoTrans.H);
1137
+ #if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)
1138
+ forwardScatteredLight[i]+=
1139
+ #else
1140
+ forwardScatteredLight+=
1141
+ #endif
1142
+ #if defined(ANISOTROPIC_BASE)
1143
+ computeAnisotropicSpecularLighting(preInfoTrans,viewDirectionW,refractNormalW,
1144
+ baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,
1145
+ transmission_roughness_alpha,lightColor{X}.rgb
1146
+ #else
1147
+ computeSpecularLighting(preInfoTrans,-refractNormalW,vec3(1.0),vec3(1.0),transmission_roughness_alpha,lightColor{X}.rgb
1148
+ #endif
1149
+ #if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)
1150
+ )[i];}
1151
+ #else
1152
+ );
1153
+ #endif
1154
+ #if !defined(GEOMETRY_THIN_WALLED)
1155
+ forwardScatteredLight=mix(forwardScatteredLight,0.25*preInfoTrans.attenuation*lightColor{X}.rgb,clamp(1.0-pow(baseGeoInfo.NdotV,transmission_roughness_alpha),0.0,1.0));
1156
+ #endif
1157
+ #ifdef REFRACTED_BACKGROUND
1158
+ #ifdef GEOMETRY_THIN_WALLED
1159
+ forwardScatteredLight=mix(vec3(0.0),forwardScatteredLight.rgb,0.2*transmission_roughness_alpha);
1160
+ #else
1161
+ forwardScatteredLight=max(vec3(0.0),mix(vec3(0.0),forwardScatteredLight,transmission_roughness_alpha));
1162
+ #endif
1163
+ #endif
1164
+ #ifdef SCATTERING
1165
+ #if !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER)
1166
+ preInfoTrans.roughness=1.0;vec3 diffused_forward_scattered_light=computeSpecularLighting(preInfoTrans,normalW,vec3(1.0),vec3(1.0),1.0,lightColor{X}.rgb)*volume_absorption;
1167
+ #endif
1168
+ #ifdef GEOMETRY_THIN_WALLED
1169
+ vec3 forward_scattered_light=forwardScatteredLight*transmission_tint*volumeParams.multi_scatter_color;vec3 back_scattered_light=slab_diffuse*volumeParams.multi_scatter_color;slab_translucent=mix(back_scattered_light,forward_scattered_light,0.5+0.5*volumeParams.anisotropy);
1170
+ #else
1171
+ vec3 back_scattered_normal=normalize(normalW+viewDirectionW);preInfoTrans.NdotL=max(dot(back_scattered_normal,preInfoTrans.L),0.0);preInfoTrans.NdotV=dot(back_scattered_normal,viewDirectionW);preInfoTrans.H=normalize(viewDirectionW+preInfoTrans.L);preInfoTrans.VdotH=clamp(dot(viewDirectionW,preInfoTrans.H),0.0,1.0);preInfoTrans.roughness=0.2;vec3 back_scattered_light=computeSpecularLighting(preInfoTrans,viewDirectionW,vec3(1.0),vec3(0.08),0.0,lightColor{X}.rgb);vec3 forward_scattered_light=(forwardScatteredLight*volume_absorption);vec3 iso_scattered_light=slab_diffuse;vec3 back_scattering=mix(forward_scattered_light,forward_scattered_light+back_scattered_light*backscatter_color,iso_scatter_density);
1172
+ #if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER)
1173
+ vec3 iso_scattering=mix(forward_scattered_light,scattered_light_from_irradiance_texture*volumeParams.multi_scatter_color,iso_scatter_density);
1174
+ #else
1175
+ vec3 iso_scattering=mix(forward_scattered_light,(diffused_forward_scattered_light+iso_scattered_light)*volumeParams.multi_scatter_color,iso_scatter_density);
1176
+ #endif
1177
+ 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;
1178
+ #endif
1179
+ #else
1180
+ slab_translucent=forwardScatteredLight*transmission_tint*volume_absorption;
1181
+ #endif
1182
+ }
1183
+ #endif
1184
+ #endif
1185
+ #if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1186
+ slab_metal=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);
1187
+ #else
1188
+ {
1189
+ #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
1190
+ vec3 coloredFresnel=getF82Specular(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90,specular_roughness);
1191
+ #else
1192
+ vec3 coloredFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);
1193
+ #endif
1194
+ #ifdef THIN_FILM
1195
+ float thinFilmConductorAngle=max(preInfo{X}.VdotH,specular_roughness);vec3 thinFilmConductorFresnel=evalIridescence(thin_film_outside_ior,thin_film_ior,thinFilmConductorAngle,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorFresnel=mix(thinFilmConductorFresnel,vec3(dot(thinFilmConductorFresnel,vec3(0.3333))),thin_film_desaturation_scale);coloredFresnel=mix(coloredFresnel,specular_weight*thinFilmConductorFresnel,thin_film_weight*thin_film_ior_scale);
1196
+ #endif
1197
+ #ifdef ANISOTROPIC_BASE
1198
+ slab_metal=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,0.0,lightColor{X}.rgb);
1199
+ #else
1200
+ slab_metal=computeSpecularLighting(preInfo{X},normalW,vec3(1.0),coloredFresnel,specular_roughness,lightColor{X}.rgb);
1201
+ #endif
1202
+ }
1203
+ #endif
1204
+ #if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
1205
+ slab_coat=computeAreaSpecularLighting(preInfoCoat{X},light{X}.vLightSpecular.rgb,coatReflectance.F0,coatReflectance.F90);
1206
+ #else
1207
+ {
1208
+ #ifdef ANISOTROPIC_COAT
1209
+ slab_coat=computeAnisotropicSpecularLighting(preInfoCoat{X},viewDirectionW,coatNormalW,
1210
+ coatGeoInfo.anisotropicTangent,coatGeoInfo.anisotropicBitangent,coatGeoInfo.anisotropy,
1211
+ 0.0,lightColor{X}.rgb);
1212
+ #else
1213
+ slab_coat=computeSpecularLighting(preInfoCoat{X},coatNormalW,vec3(coatReflectance.F0),vec3(1.0),coat_roughness,lightColor{X}.rgb);
1214
+ #endif
1215
+ float NdotH=max(dot(coatNormalW,preInfoCoat{X}.H),0.0);coatFresnel=fresnelSchlickGGX(NdotH,coatReflectance.F0,coatReflectance.F90);}
1216
+ #endif
1217
+ vec3 coatAbsorption=vec3(1.0);if (coat_weight>0.0) {float cosTheta_view=max(preInfoCoat{X}.NdotV,0.001);float cosTheta_light=max(preInfoCoat{X}.NdotL,0.001);float fresnel_view=coatReflectance.F0+(1.0-coatReflectance.F0)*pow(1.0-cosTheta_view,5.0);float fresnel_light=coatReflectance.F0+(1.0-coatReflectance.F0)*pow(1.0-cosTheta_light,5.0);float averageReflectance=(fresnel_view+fresnel_light)*0.5;float darkened_transmission=(1.0-averageReflectance)/(1.0+averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);float sin2=1.0-cosTheta_view*cosTheta_view;sin2=sin2/(coat_ior*coat_ior)*coat_weight;float cos_t=sqrt(1.0-sin2);float coatPathLength=1.0/cos_t;float effectivePathLength=coatPathLength*coat_weight;vec3 colored_transmission=pow(coat_color,vec3(effectivePathLength));coatAbsorption=colored_transmission*mix(1.0,darkened_transmission,coat_weight);}
1218
+ #ifdef FUZZ
1219
+ fuzzFresnel=fuzzBrdf.z;vec3 fuzzNormalW=mix(normalW,coatNormalW,coat_weight);float fuzzNdotV=max(dot(fuzzNormalW,viewDirectionW.xyz),0.0);float fuzzNdotL=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);
1220
+ #else
1221
+ vec3 fuzz_color=vec3(0.0);
1222
+ #endif
1223
+ #ifdef PREPASS_IRRADIANCE
1224
+ total_direct_diffuse+=slab_diffuse;
1225
+ #endif
1226
+ vec3 material_dielectric_base=mix(slab_diffuse*base_color.rgb,slab_translucent,surface_translucency_weight);vec3 material_dielectric_gloss=material_dielectric_base*(1.0-specularFresnel)+slab_glossy*specularColoredFresnel;vec3 material_base_substrate=mix(material_dielectric_gloss,slab_metal,base_metalness);vec3 material_coated_base=layer(material_base_substrate,slab_coat,coatFresnel,coatAbsorption,vec3(1.0));material_surface_direct+=layer(material_coated_base,slab_fuzz,fuzzFresnel*fuzz_weight,vec3(1.0),fuzz_color);}
1227
+ #endif
1228
+ `;e.IncludesShadersStore[h]||(e.IncludesShadersStore[h]=X);const Ke={name:h,shader:X},I="openpbrBlockPrePass",w=`#if SCENE_MRT_COUNT>0
1229
+ float writeGeometryInfo=finalColor.a>ALPHATESTVALUE ? 1.0 : 0.0;
1230
+ #ifdef PREPASS_POSITION
1231
+ gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
1232
+ #endif
1233
+ #ifdef PREPASS_LOCAL_POSITION
1234
+ gl_FragData[PREPASS_LOCAL_POSITION_INDEX]=vec4(vPosition,writeGeometryInfo);
1235
+ #endif
1236
+ #if defined(PREPASS_VELOCITY)
1237
+ vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
1238
+ #elif defined(PREPASS_VELOCITY_LINEAR)
1239
+ vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w)-(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
1240
+ #endif
1241
+ #ifdef PREPASS_ALBEDO
1242
+ gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(base_color,writeGeometryInfo);
1243
+ #endif
1244
+ #ifdef PREPASS_ALBEDO_SQRT
1245
+ vec3 sqAlbedo=sqrt(base_color);
1246
+ #endif
1247
+ #ifdef PREPASS_IRRADIANCE
1248
+ vec3 irradiance=total_direct_diffuse;
1249
+ #ifndef UNLIT
1250
+ #ifdef REFLECTION
1251
+ irradiance+=slab_diffuse_ibl;
1252
+ #endif
1253
+ #endif
1254
+ #ifdef SCATTERING
1255
+ float scatter_mask=min(subsurface_weight+transmission_weight,1.0);
1256
+ #else
1257
+ float scatter_mask=0.0;
1258
+ #endif
1259
+ gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(irradiance,writeGeometryInfo*scatter_mask);
1260
+ #endif
1261
+ #if defined(PREPASS_COLOR)
1262
+ gl_FragData[PREPASS_COLOR_INDEX]=vec4(finalColor.rgb,finalColor.a);
1263
+ #endif
1264
+ #ifdef PREPASS_DEPTH
1265
+ gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
1266
+ #endif
1267
+ #ifdef PREPASS_SCREENSPACE_DEPTH
1268
+ gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,writeGeometryInfo);
1269
+ #endif
1270
+ #ifdef PREPASS_NORMALIZED_VIEW_DEPTH
1271
+ gl_FragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4(vNormViewDepth,0.0,0.0,writeGeometryInfo);
1272
+ #endif
1273
+ #ifdef PREPASS_NORMAL
1274
+ #ifdef PREPASS_NORMAL_WORLDSPACE
1275
+ gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo);
1276
+ #else
1277
+ gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo);
1278
+ #endif
1279
+ #endif
1280
+ #ifdef PREPASS_WORLD_NORMAL
1281
+ gl_FragData[PREPASS_WORLD_NORMAL_INDEX]=vec4(normalW*0.5+0.5,writeGeometryInfo);
1282
+ #endif
1283
+ #ifdef PREPASS_ALBEDO_SQRT
1284
+ gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo);
1285
+ #endif
1286
+ #ifdef PREPASS_REFLECTIVITY
1287
+ #ifndef UNLIT
1288
+ gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularEnvironmentR0,microSurface)*writeGeometryInfo;
1289
+ #else
1290
+ gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4( 0.0,0.0,0.0,1.0 )*writeGeometryInfo;
1291
+ #endif
1292
+ #endif
1293
+ #endif
1294
+ `;e.IncludesShadersStore[I]||(e.IncludesShadersStore[I]=w);const Qe={name:I,shader:w},R="openpbrPixelShader",W=`#define OPENPBR_FRAGMENT_SHADER
1295
+ #define CUSTOM_FRAGMENT_EXTENSION
1296
+ #if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA)
1297
+ #extension GL_OES_standard_derivatives : enable
1298
+ #endif
1299
+ #ifdef LODBASEDMICROSFURACE
1300
+ #extension GL_EXT_shader_texture_lod : enable
1301
+ #endif
1302
+ #define CUSTOM_FRAGMENT_BEGIN
1303
+ #ifdef LOGARITHMICDEPTH
1304
+ #extension GL_EXT_frag_depth : enable
1305
+ #endif
1306
+ #include<prePassDeclaration>[SCENE_MRT_COUNT]
1307
+ precision highp float;
1308
+ #include<oitDeclaration>
1309
+ #ifndef FROMLINEARSPACE
1310
+ #define FROMLINEARSPACE
1311
+ #endif
1312
+ #include<__decl__openpbrFragment>
1313
+ #include<pbrFragmentExtraDeclaration>
1314
+ #include<__decl__lightFragment>[0..maxSimultaneousLights]
1315
+ #include<openpbrFragmentSamplersDeclaration>
1316
+ #include<imageProcessingDeclaration>
1317
+ #include<clipPlaneFragmentDeclaration>
1318
+ #include<logDepthDeclaration>
1319
+ #include<fogFragmentDeclaration>
1320
+ #include<textureRepetitionFunctions>
1321
+ #include<helperFunctions>
1322
+ #include<subSurfaceScatteringFunctions>
1323
+ #include<importanceSampling>
1324
+ #include<pbrHelperFunctions>
1325
+ #include<imageProcessingFunctions>
1326
+ #include<shadowsFragmentFunctions>
1327
+ #include<harmonicsFunctions>
1328
+ #include<pbrDirectLightingSetupFunctions>
1329
+ #include<pbrDirectLightingFalloffFunctions>
1330
+ #include<pbrBRDFFunctions>
1331
+ #include<hdrFilteringFunctions>
1332
+ #include<pbrDirectLightingFunctions>
1333
+ #include<pbrIBLFunctions>
1334
+ #include<openpbrNormalMapFragmentMainFunctions>
1335
+ #include<openpbrNormalMapFragmentFunctions>
1336
+ #ifdef REFLECTION
1337
+ #include<reflectionFunction>
1338
+ #endif
1339
+ #define CUSTOM_FRAGMENT_DEFINITIONS
1340
+ #include<openpbrDielectricReflectance>
1341
+ #include<openpbrConductorReflectance>
1342
+ #include<openpbrAmbientOcclusionFunctions>
1343
+ #include<openpbrGeometryInfo>
1344
+ #include<openpbrIblFunctions>
1345
+ #include<openpbrVolumeFunctions>
1346
+ vec3 layer(vec3 slab_bottom,vec3 slab_top,float lerp_factor,vec3 bottom_multiplier,vec3 top_multiplier) {return mix(slab_bottom*bottom_multiplier,slab_top*top_multiplier,lerp_factor);}
1347
+ void main(void) {
1348
+ #ifdef PREPASS_IRRADIANCE
1349
+ vec3 total_direct_diffuse=vec3(0.0);
1350
+ #endif
1351
+ #define CUSTOM_FRAGMENT_MAIN_BEGIN
1352
+ #include<clipPlaneFragment>
1353
+ #include<pbrBlockNormalGeometric>
1354
+ vec3 coatNormalW=normalW;
1355
+ #include<openpbrNormalMapFragment>
1356
+ #include<openpbrBlockNormalFinal>
1357
+ #include<openpbrBaseLayerData>
1358
+ #include<openpbrTransmissionLayerData>
1359
+ #include<openpbrSubsurfaceLayerData>
1360
+ #include<openpbrCoatLayerData>
1361
+ #include<openpbrThinFilmLayerData>
1362
+ #include<openpbrFuzzLayerData>
1363
+ #include<openpbrAmbientOcclusionData>
1364
+ #define CUSTOM_FRAGMENT_UPDATE_ALPHA
1365
+ #include<depthPrePass>
1366
+ #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
1367
+ #ifdef ANISOTROPIC_COAT
1368
+ geometryInfoAnisoOutParams coatGeoInfo=geometryInfoAniso(
1369
+ coatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW
1370
+ ,vec3(geometry_coat_tangent.x,geometry_coat_tangent.y,coat_roughness_anisotropy),TBN
1371
+ );
1372
+ #else
1373
+ geometryInfoOutParams coatGeoInfo=geometryInfo(
1374
+ coatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW
1375
+ );
1376
+ #endif
1377
+ specular_roughness=mix(specular_roughness,pow(min(1.0,pow(specular_roughness,4.0)+2.0*pow(coat_roughness,4.0)),0.25),coat_weight);
1378
+ #ifdef ANISOTROPIC_BASE
1379
+ geometryInfoAnisoOutParams baseGeoInfo=geometryInfoAniso(
1380
+ normalW,viewDirectionW.xyz,specular_roughness,geometricNormalW
1381
+ ,vec3(geometry_tangent.x,geometry_tangent.y,specular_roughness_anisotropy),TBN
1382
+ );
1383
+ #else
1384
+ geometryInfoOutParams baseGeoInfo=geometryInfo(
1385
+ normalW,viewDirectionW.xyz,specular_roughness,geometricNormalW
1386
+ );
1387
+ #endif
1388
+ #ifdef FUZZ
1389
+ vec3 fuzzNormalW=normalize(mix(normalW,coatNormalW,coat_weight));vec3 fuzzTangent=normalize(TBN[0]);fuzzTangent=normalize(fuzzTangent-dot(fuzzTangent,fuzzNormalW)*fuzzNormalW);vec3 fuzzBitangent=cross(fuzzNormalW,fuzzTangent);geometryInfoOutParams fuzzGeoInfo=geometryInfo(
1390
+ fuzzNormalW,viewDirectionW.xyz,fuzz_roughness,geometricNormalW
1391
+ );
1392
+ #endif
1393
+ ReflectanceParams coatReflectance;coatReflectance=dielectricReflectance(
1394
+ coat_ior
1395
+ ,1.0
1396
+ ,vec3(1.0)
1397
+ ,coat_weight
1398
+ );
1399
+ #ifdef THIN_FILM
1400
+ float thin_film_outside_ior=mix(1.0,coat_ior,coat_weight);
1401
+ #endif
1402
+ ReflectanceParams baseDielectricReflectance;{float effectiveCoatIor=mix(1.0,coat_ior,coat_weight);baseDielectricReflectance=dielectricReflectance(
1403
+ specular_ior
1404
+ ,effectiveCoatIor
1405
+ ,specular_color
1406
+ ,specular_weight
1407
+ );}
1408
+ ReflectanceParams baseConductorReflectance;baseConductorReflectance=conductorReflectance(base_color,specular_color,specular_weight);vec3 volume_absorption=vec3(1.0);vec3 transmission_tint=vec3(1.0);float surface_translucency_weight=0.0;
1409
+ #if defined(REFRACTED_BACKGROUND) || defined(REFRACTED_ENVIRONMENT) || defined(REFRACTED_LIGHTS)
1410
+ #if defined(GEOMETRY_THIN_WALLED)
1411
+ vec3 refractedViewVector=-viewDirectionW;
1412
+ #else
1413
+ #ifdef DISPERSION
1414
+ vec3 refractedViewVectors[3];float iorDispersionSpread=transmission_dispersion_scale/transmission_dispersion_abbe_number*(specular_ior-1.0);vec3 dispersion_iors=vec3(specular_ior-iorDispersionSpread,specular_ior,specular_ior+iorDispersionSpread);for (int i=0; i<3; i++) {refractedViewVectors[i]=double_refract(-viewDirectionW,normalW,dispersion_iors[i]); }
1415
+ #else
1416
+ vec3 refractedViewVector=double_refract(-viewDirectionW,normalW,specular_ior);
1417
+ #endif
1418
+ #endif
1419
+ #ifdef GEOMETRY_THIN_WALLED
1420
+ float transmission_roughness=specular_roughness;
1421
+ #else
1422
+ float transmission_roughness=specular_roughness*clamp(4.0*(specular_ior-1.0),0.001,1.0);
1423
+ #endif
1424
+ #if (defined(TRANSMISSION_SLAB) || defined(SUBSURFACE_SLAB))
1425
+ OpenPBRHomogeneousVolume volumeParams;{
1426
+ #if defined(TRANSMISSION_SLAB)
1427
+ OpenPBRHomogeneousVolume transmissionVolumeParams=computeOpenPBRTransmissionVolume(
1428
+ transmission_color.rgb,
1429
+ transmission_depth,
1430
+ transmission_scatter.rgb,
1431
+ transmission_scatter_anisotropy
1432
+ );
1433
+ #endif
1434
+ #if defined(SUBSURFACE_SLAB)
1435
+ OpenPBRHomogeneousVolume subsurfaceVolumeParams=computeOpenPBRSubsurfaceVolume(
1436
+ subsurface_color.rgb,
1437
+ subsurface_radius,
1438
+ subsurface_radius_scale.rgb,
1439
+ subsurface_scatter_anisotropy
1440
+ );
1441
+ #endif
1442
+ #if !defined(TRANSMISSION_SLAB)
1443
+ volumeParams=subsurfaceVolumeParams;surface_translucency_weight=subsurface_weight;
1444
+ #elif !defined(SUBSURFACE_SLAB)
1445
+ volumeParams=transmissionVolumeParams;
1446
+ #ifdef TRANSMISSION_SLAB_VOLUME
1447
+ volumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);
1448
+ #endif
1449
+ surface_translucency_weight=transmission_weight;
1450
+ #else
1451
+ float subsurface_fraction_of_dielectric=(1.0f-transmission_weight)*subsurface_weight;float subsurface_and_transmission_fraction_of_dielectric=subsurface_fraction_of_dielectric+transmission_weight;float reciprocal_of_subsurface_and_transmission_fraction_of_dielectric =
1452
+ 1.0f/maxEps(subsurface_and_transmission_fraction_of_dielectric);float trans_weight=transmission_weight*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;float subsurf_weight=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/maxEps(volumeParams.extinction_coeff);volumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);surface_translucency_weight=subsurface_and_transmission_fraction_of_dielectric;
1453
+ #endif
1454
+ }
1455
+ volume_absorption=exp(-volumeParams.absorption_coeff*geometry_thickness);vec3 backscatter_color=vec3(1.0);{vec3 reduced_scatter=volumeParams.scatter_coeff*vec3(1.0-volumeParams.anisotropy);vec3 reduced_albedo=reduced_scatter/(volumeParams.absorption_coeff+reduced_scatter);vec3 sqrt_term=max(sqrt(1.0-reduced_albedo),0.0001);backscatter_color=(1.0-sqrt_term)/(1.0+sqrt_term);}
1456
+ #elif defined(TRANSMISSION_SLAB)
1457
+ surface_translucency_weight=transmission_weight;
1458
+ #endif
1459
+ #ifdef SCATTERING
1460
+ #ifdef GEOMETRY_THIN_WALLED
1461
+ vec3 iso_scatter_density=vec3(1.0);
1462
+ #else
1463
+ #ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING
1464
+ vec3 mfp=vec3(100.0)/volumeParams.extinction_coeff;vec3 scattered_light_from_irradiance_texture=sss_convolve(sceneIrradianceSampler,sceneDepthSampler,renderTargetSize,mfp,projection,inverseProjection,SSS_SAMPLE_COUNT,noise.xy);float numLights=float(LIGHTCOUNT);
1465
+ #ifdef REFLECTION
1466
+ numLights+=1.0;
1467
+ #endif
1468
+ scattered_light_from_irradiance_texture/=numLights;
1469
+ #else
1470
+ vec3 scattered_light_from_irradiance_texture=vec3(0.0);
1471
+ #endif
1472
+ float back_to_iso_scattering_blend=min(1.0+volumeParams.anisotropy,1.0);float iso_to_forward_scattering_blend=max(volumeParams.anisotropy,0.0);vec3 iso_scatter_transmittance=pow(exp(-volumeParams.scatter_coeff*geometry_thickness),vec3(0.2));vec3 iso_scatter_density=clamp(vec3(1.0)-iso_scatter_transmittance,0.0,1.0);transmission_roughness=min(transmission_roughness+pow((1.0-abs(volumeParams.anisotropy))*max3(iso_scatter_density*iso_scatter_density),3.0),1.0);
1473
+ #endif
1474
+ volumeParams.multi_scatter_color=mix(volumeParams.ss_albedo,volumeParams.multi_scatter_color,max3(iso_scatter_density));
1475
+ #endif
1476
+ #if defined(TRANSMISSION_SLAB) && (!defined(TRANSMISSION_SLAB_VOLUME) || defined(GEOMETRY_THIN_WALLED))
1477
+ transmission_tint*=transmission_color.rgb;
1478
+ #ifdef GEOMETRY_THIN_WALLED
1479
+ float sin2=1.0-baseGeoInfo.NdotV*baseGeoInfo.NdotV;sin2=sin2/(specular_ior*specular_ior);float cos_t=sqrt(1.0-sin2);float pathLength=1.0/cos_t;transmission_tint=pow(transmission_tint,vec3(pathLength));
1480
+ #else
1481
+ transmission_tint*=transmission_color.rgb;
1482
+ #endif
1483
+ #endif
1484
+ #if defined(SUBSURFACE_SLAB) && defined(GEOMETRY_THIN_WALLED)
1485
+ float unweighted_translucency=max(mix(subsurface_weight,1.0f,transmission_weight),0.0001);transmission_tint=mix(vec3(1.0),transmission_tint,transmission_weight/unweighted_translucency);transmission_roughness=mix(1.0,transmission_roughness,transmission_weight/unweighted_translucency);
1486
+ #endif
1487
+ float transmission_roughness_alpha=transmission_roughness*transmission_roughness;
1488
+ #endif
1489
+ #include<openpbrBackgroundTransmission>
1490
+ vec3 material_surface_ibl=vec3(0.,0.,0.);
1491
+ #include<openpbrEnvironmentLighting>
1492
+ vec3 material_surface_direct=vec3(0.,0.,0.);
1493
+ #if defined(LIGHT0)
1494
+ float aggShadow=0.;
1495
+ #include<openpbrDirectLightingInit>[0..maxSimultaneousLights]
1496
+ #include<openpbrDirectLighting>[0..maxSimultaneousLights]
1497
+ #endif
1498
+ vec3 material_surface_emission=vEmissionColor;
1499
+ #ifdef EMISSION_COLOR
1500
+ vec3 emissionColorTex=TEXRD(emissionColorSampler,vEmissionColorUV+uvOffset).rgb;
1501
+ #ifdef EMISSION_COLOR_GAMMA
1502
+ material_surface_emission*=toLinearSpace(emissionColorTex.rgb);
1503
+ #else
1504
+ material_surface_emission*=emissionColorTex.rgb;
1505
+ #endif
1506
+ material_surface_emission*= vEmissionColorInfos.y;
1507
+ #endif
1508
+ material_surface_emission*=vLightingIntensity.y;
1509
+ #define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
1510
+ vec4 finalColor=vec4(material_surface_ibl+material_surface_direct+material_surface_emission,alpha);
1511
+ #define CUSTOM_FRAGMENT_BEFORE_FOG
1512
+ finalColor=max(finalColor,0.0);
1513
+ #include<logDepthFragment>
1514
+ #include<fogFragment>(color,finalColor)
1515
+ #include<pbrBlockImageProcessing>
1516
+ #define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
1517
+ #ifdef PREPASS
1518
+ #include<openpbrBlockPrePass>
1519
+ #endif
1520
+ #if !defined(PREPASS) || defined(WEBGL2)
1521
+ gl_FragColor=finalColor;
1522
+ #endif
1523
+ #include<oitFragment>
1524
+ #if ORDER_INDEPENDENT_TRANSPARENCY
1525
+ if (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;}
1526
+ #endif
1527
+ #include<pbrDebug>
1528
+ #define CUSTOM_FRAGMENT_MAIN_END
1529
+ }
1530
+ `;e.ShadersStore[R]||(e.ShadersStore[R]=W);const Je=[H,B,Fe,V,Ge,k,Y,Me,Z,$,j,q,K,Q,xe,J,ee,ie,oe,ae,te,re,ne,se,ce,fe,le,_e,de,me,ue,ge,Ee,ve,ye,ze,pe,Le,Ue,Xe,De,Oe,we,he,Ie,We,He,Be,Ce,Pe,Ve,ke,Ye,Ze,Re,$e,je,qe,Ke,Se,Te,Ae,Qe,Ne,be];for(const i of Je)e.IncludesShadersStore[i.name]||(e.IncludesShadersStore[i.name]=i.shader);const ai={name:R,shader:W};export{ai as openpbrPixelShader};