@onerjs/core 8.53.5 → 8.53.6

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 (841) hide show
  1. package/Animations/animationGroup.d.ts +0 -1
  2. package/Animations/animationGroup.js +0 -1
  3. package/Animations/animationGroup.js.map +1 -1
  4. package/Animations/animationGroup.pure.js +2 -0
  5. package/Animations/animationGroup.pure.js.map +1 -1
  6. package/Animations/runtimeAnimation.js +11 -0
  7. package/Animations/runtimeAnimation.js.map +1 -1
  8. package/Audio/audioSceneComponent.pure.js +1 -1
  9. package/AudioV2/abstractAudio/abstractSound.d.ts +2 -1
  10. package/AudioV2/abstractAudio/abstractSound.js +7 -2
  11. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  12. package/AudioV2/abstractAudio/abstractSoundInstance.d.ts +3 -1
  13. package/AudioV2/abstractAudio/abstractSoundInstance.js.map +1 -1
  14. package/AudioV2/abstractAudio/staticSound.d.ts +6 -0
  15. package/AudioV2/abstractAudio/staticSound.js +17 -1
  16. package/AudioV2/abstractAudio/staticSound.js.map +1 -1
  17. package/AudioV2/abstractAudio/staticSoundInstance.d.ts +4 -2
  18. package/AudioV2/abstractAudio/staticSoundInstance.js.map +1 -1
  19. package/AudioV2/abstractAudio/streamingSound.d.ts +6 -0
  20. package/AudioV2/abstractAudio/streamingSound.js +9 -1
  21. package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
  22. package/AudioV2/webAudio/webAudioStaticSound.d.ts +7 -1
  23. package/AudioV2/webAudio/webAudioStaticSound.js +56 -8
  24. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  25. package/AudioV2/webAudio/webAudioStreamingSound.d.ts +3 -1
  26. package/AudioV2/webAudio/webAudioStreamingSound.js +16 -4
  27. package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
  28. package/BakedVertexAnimation/bakedVertexAnimationManager.d.ts +2 -2
  29. package/BakedVertexAnimation/bakedVertexAnimationManager.js +151 -121
  30. package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
  31. package/Behaviors/Cameras/interpolatingBehavior.d.ts +17 -2
  32. package/Behaviors/Cameras/interpolatingBehavior.js +53 -23
  33. package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
  34. package/Bones/bone.pure.js +3 -3
  35. package/Buffers/buffer.pure.js +0 -12
  36. package/Buffers/buffer.pure.js.map +1 -1
  37. package/Cameras/Inputs/BaseCameraMouseWheelInput.js +141 -126
  38. package/Cameras/Inputs/BaseCameraMouseWheelInput.js.map +1 -1
  39. package/Cameras/Inputs/BaseCameraPointersInput.d.ts +2 -1
  40. package/Cameras/Inputs/BaseCameraPointersInput.js +290 -277
  41. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  42. package/Cameras/Inputs/arcRotateCameraGamepadInput.js +115 -102
  43. package/Cameras/Inputs/arcRotateCameraGamepadInput.js.map +1 -1
  44. package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.d.ts +3 -0
  45. package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js +334 -273
  46. package/Cameras/Inputs/arcRotateCameraKeyboardMoveInput.js.map +1 -1
  47. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +273 -258
  48. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  49. package/Cameras/Inputs/arcRotateCameraPointersInput.js +237 -213
  50. package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
  51. package/Cameras/Inputs/flyCameraKeyboardInput.js +199 -168
  52. package/Cameras/Inputs/flyCameraKeyboardInput.js.map +1 -1
  53. package/Cameras/Inputs/flyCameraMouseInput.js +243 -229
  54. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  55. package/Cameras/Inputs/followCameraKeyboardMoveInput.js +311 -266
  56. package/Cameras/Inputs/followCameraKeyboardMoveInput.js.map +1 -1
  57. package/Cameras/Inputs/followCameraMouseWheelInput.js +139 -119
  58. package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
  59. package/Cameras/Inputs/followCameraPointersInput.js +239 -203
  60. package/Cameras/Inputs/followCameraPointersInput.js.map +1 -1
  61. package/Cameras/Inputs/freeCameraGamepadInput.js +127 -114
  62. package/Cameras/Inputs/freeCameraGamepadInput.js.map +1 -1
  63. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js +278 -244
  64. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
  65. package/Cameras/Inputs/freeCameraMouseInput.js +216 -202
  66. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  67. package/Cameras/Inputs/freeCameraMouseWheelInput.js +368 -353
  68. package/Cameras/Inputs/freeCameraMouseWheelInput.js.map +1 -1
  69. package/Cameras/Inputs/freeCameraTouchInput.js +185 -172
  70. package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
  71. package/Cameras/Inputs/geospatialCameraKeyboardInput.d.ts +2 -0
  72. package/Cameras/Inputs/geospatialCameraKeyboardInput.js +291 -246
  73. package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -1
  74. package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +11 -1
  75. package/Cameras/Inputs/geospatialCameraPointersInput.js +18 -2
  76. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  77. package/Cameras/Inputs/orbitCameraPointersInput.js +112 -96
  78. package/Cameras/Inputs/orbitCameraPointersInput.js.map +1 -1
  79. package/Cameras/VR/vrExperienceHelper.d.ts +0 -2
  80. package/Cameras/VR/vrExperienceHelper.js +0 -2
  81. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  82. package/Cameras/VR/vrExperienceHelper.pure.js +5 -0
  83. package/Cameras/VR/vrExperienceHelper.pure.js.map +1 -1
  84. package/Cameras/arcRotateCamera.pure.js +1559 -1479
  85. package/Cameras/arcRotateCamera.pure.js.map +1 -1
  86. package/Cameras/camera.pure.js +1225 -1178
  87. package/Cameras/camera.pure.js.map +1 -1
  88. package/Cameras/flyCamera.pure.js +369 -351
  89. package/Cameras/flyCamera.pure.js.map +1 -1
  90. package/Cameras/followCamera.pure.js +229 -192
  91. package/Cameras/followCamera.pure.js.map +1 -1
  92. package/Cameras/freeCamera.pure.js +373 -351
  93. package/Cameras/freeCamera.pure.js.map +1 -1
  94. package/Cameras/geospatialCamera.pure.d.ts +30 -7
  95. package/Cameras/geospatialCamera.pure.js +502 -457
  96. package/Cameras/geospatialCamera.pure.js.map +1 -1
  97. package/Cameras/geospatialCameraMovement.js +2 -2
  98. package/Cameras/geospatialCameraMovement.js.map +1 -1
  99. package/Cameras/targetCamera.pure.d.ts +7 -0
  100. package/Cameras/targetCamera.pure.js +550 -509
  101. package/Cameras/targetCamera.pure.js.map +1 -1
  102. package/Cameras/universalCamera.pure.js +98 -85
  103. package/Cameras/universalCamera.pure.js.map +1 -1
  104. package/Collisions/gpuPicker.d.ts +111 -4
  105. package/Collisions/gpuPicker.js +696 -119
  106. package/Collisions/gpuPicker.js.map +1 -1
  107. package/Compute/computeShader.pure.js +372 -355
  108. package/Compute/computeShader.pure.js.map +1 -1
  109. package/Culling/Helper/transformFeedbackBoundingHelper.pure.js +2 -2
  110. package/Decorators/nodeDecorator.d.ts +11 -1
  111. package/Decorators/nodeDecorator.js +43 -6
  112. package/Decorators/nodeDecorator.js.map +1 -1
  113. package/Engines/AbstractEngine/abstractEngine.loadFile.pure.js +8 -0
  114. package/Engines/AbstractEngine/abstractEngine.loadFile.pure.js.map +1 -1
  115. package/Engines/Native/nativeHelpers.js +15 -0
  116. package/Engines/Native/nativeHelpers.js.map +1 -1
  117. package/Engines/Native/nativeInterfaces.d.ts +7 -2
  118. package/Engines/Native/nativeInterfaces.js.map +1 -1
  119. package/Engines/Native/nativeRenderTargetWrapper.d.ts +5 -0
  120. package/Engines/Native/nativeRenderTargetWrapper.js +35 -1
  121. package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
  122. package/Engines/Processors/shaderProcessor.js +5 -3
  123. package/Engines/Processors/shaderProcessor.js.map +1 -1
  124. package/Engines/WebGPU/Extensions/engine.videoTexture.pure.js +16 -3
  125. package/Engines/WebGPU/Extensions/engine.videoTexture.pure.js.map +1 -1
  126. package/Engines/WebGPU/webgpuClearQuad.pure.js +7 -1
  127. package/Engines/WebGPU/webgpuClearQuad.pure.js.map +1 -1
  128. package/Engines/abstractEngine.functions.d.ts +8 -2
  129. package/Engines/abstractEngine.functions.js +12 -4
  130. package/Engines/abstractEngine.functions.js.map +1 -1
  131. package/Engines/abstractEngine.pure.d.ts +20 -1
  132. package/Engines/abstractEngine.pure.js +21 -134
  133. package/Engines/abstractEngine.pure.js.map +1 -1
  134. package/Engines/engine.d.ts +208 -0
  135. package/Engines/engine.pure.js +0 -15
  136. package/Engines/engine.pure.js.map +1 -1
  137. package/Engines/nullEngine.pure.d.ts +66 -0
  138. package/Engines/nullEngine.pure.js +97 -0
  139. package/Engines/nullEngine.pure.js.map +1 -1
  140. package/Engines/thinEngine.pure.d.ts +0 -13
  141. package/Engines/thinEngine.pure.js +4 -23
  142. package/Engines/thinEngine.pure.js.map +1 -1
  143. package/Engines/thinNativeEngine.d.ts +0 -1
  144. package/Engines/thinNativeEngine.js +0 -1
  145. package/Engines/thinNativeEngine.js.map +1 -1
  146. package/Engines/thinNativeEngine.pure.d.ts +27 -0
  147. package/Engines/thinNativeEngine.pure.js +383 -17
  148. package/Engines/thinNativeEngine.pure.js.map +1 -1
  149. package/Engines/webgpuEngine.d.ts +1 -0
  150. package/Engines/webgpuEngine.js +1 -0
  151. package/Engines/webgpuEngine.js.map +1 -1
  152. package/Engines/webgpuEngine.pure.d.ts +9 -0
  153. package/Engines/webgpuEngine.pure.js +7 -0
  154. package/Engines/webgpuEngine.pure.js.map +1 -1
  155. package/FlowGraph/flowGraph.js +9 -0
  156. package/FlowGraph/flowGraph.js.map +1 -1
  157. package/FlowGraph/flowGraphContext.js +597 -584
  158. package/FlowGraph/flowGraphContext.js.map +1 -1
  159. package/FlowGraph/flowGraphDataConnection.pure.d.ts +14 -0
  160. package/FlowGraph/flowGraphDataConnection.pure.js +38 -1
  161. package/FlowGraph/flowGraphDataConnection.pure.js.map +1 -1
  162. package/FlowGraph/serialization.d.ts +11 -0
  163. package/FlowGraph/serialization.js +11 -1
  164. package/FlowGraph/serialization.js.map +1 -1
  165. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.pure.js +182 -170
  166. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.pure.js.map +1 -1
  167. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.pure.js +196 -184
  168. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.pure.js.map +1 -1
  169. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.js +222 -210
  170. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.pure.js.map +1 -1
  171. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +123 -111
  172. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
  173. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +158 -146
  174. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -1
  175. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.pure.js +63 -51
  176. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.pure.js.map +1 -1
  177. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.pure.js +122 -110
  178. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.pure.js.map +1 -1
  179. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.pure.js +76 -64
  180. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.pure.js.map +1 -1
  181. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.pure.js +89 -77
  182. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.pure.js.map +1 -1
  183. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.pure.js +134 -122
  184. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.pure.js.map +1 -1
  185. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.pure.js +58 -46
  186. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.pure.js.map +1 -1
  187. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.pure.js +107 -95
  188. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.pure.js.map +1 -1
  189. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.pure.js +181 -169
  190. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.pure.js.map +1 -1
  191. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.pure.js +63 -51
  192. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.pure.js.map +1 -1
  193. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.pure.js +63 -51
  194. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.pure.js.map +1 -1
  195. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.pure.js +76 -64
  196. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.pure.js.map +1 -1
  197. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.pure.js +246 -234
  198. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.pure.js.map +1 -1
  199. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.pure.js +108 -96
  200. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.pure.js.map +1 -1
  201. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.pure.js +87 -75
  202. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.pure.js.map +1 -1
  203. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.pure.js +76 -64
  204. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.pure.js.map +1 -1
  205. package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.pure.js +313 -301
  206. package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.pure.js.map +1 -1
  207. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.pure.js +502 -490
  208. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.pure.js.map +1 -1
  209. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.pure.js +147 -135
  210. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.pure.js.map +1 -1
  211. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.pure.js +90 -78
  212. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.pure.js.map +1 -1
  213. package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.pure.js +179 -167
  214. package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.pure.js.map +1 -1
  215. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +462 -451
  216. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  217. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +265 -253
  218. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js.map +1 -1
  219. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.pure.js +204 -192
  220. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.pure.js.map +1 -1
  221. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js +611 -550
  222. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.pure.js.map +1 -1
  223. package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.pure.js +320 -308
  224. package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.pure.js.map +1 -1
  225. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.pure.js +87 -75
  226. package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.pure.js.map +1 -1
  227. package/FrameGraph/Node/Blocks/Textures/clearBlock.pure.js +154 -142
  228. package/FrameGraph/Node/Blocks/Textures/clearBlock.pure.js.map +1 -1
  229. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.pure.js +150 -138
  230. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.pure.js.map +1 -1
  231. package/FrameGraph/Node/Blocks/inputBlock.pure.js +270 -256
  232. package/FrameGraph/Node/Blocks/inputBlock.pure.js.map +1 -1
  233. package/FrameGraph/Node/Blocks/lightingVolumeBlock.pure.js +95 -83
  234. package/FrameGraph/Node/Blocks/lightingVolumeBlock.pure.js.map +1 -1
  235. package/FrameGraph/Node/nodeRenderGraph.js +715 -693
  236. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  237. package/FrameGraph/Node/nodeRenderGraphBlock.js +548 -533
  238. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  239. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.d.ts +2 -2
  240. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js +43 -51
  241. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js.map +1 -1
  242. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.d.ts +0 -1
  243. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.js +0 -1
  244. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.js.map +1 -1
  245. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.d.ts +0 -1
  246. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js +66 -35
  247. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js.map +1 -1
  248. package/Helpers/environmentHelper.js +2 -2
  249. package/Helpers/environmentHelper.js.map +1 -1
  250. package/Layers/effectLayer.js +529 -519
  251. package/Layers/effectLayer.js.map +1 -1
  252. package/Layers/glowLayer.pure.js +428 -413
  253. package/Layers/glowLayer.pure.js.map +1 -1
  254. package/Layers/highlightLayer.pure.js +473 -458
  255. package/Layers/highlightLayer.pure.js.map +1 -1
  256. package/Layers/selectionOutlineLayer.pure.js +360 -345
  257. package/Layers/selectionOutlineLayer.pure.js.map +1 -1
  258. package/Lights/Clustered/clusteredLightContainer.pure.d.ts +1 -1
  259. package/Lights/Clustered/clusteredLightContainer.pure.js +583 -558
  260. package/Lights/Clustered/clusteredLightContainer.pure.js.map +1 -1
  261. package/Lights/Shadows/shadowGenerator.js +6 -1
  262. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  263. package/Lights/areaLight.pure.js +61 -39
  264. package/Lights/areaLight.pure.js.map +1 -1
  265. package/Lights/directionalLight.pure.js +308 -284
  266. package/Lights/directionalLight.pure.js.map +1 -1
  267. package/Lights/hemisphericLight.pure.js +123 -104
  268. package/Lights/hemisphericLight.pure.js.map +1 -1
  269. package/Lights/light.d.ts +5 -3
  270. package/Lights/light.js +869 -827
  271. package/Lights/light.js.map +1 -1
  272. package/Lights/pointLight.pure.js +185 -174
  273. package/Lights/pointLight.pure.js.map +1 -1
  274. package/Lights/rectAreaLight.pure.d.ts +17 -0
  275. package/Lights/rectAreaLight.pure.js +238 -159
  276. package/Lights/rectAreaLight.pure.js.map +1 -1
  277. package/Lights/shadowLight.js +280 -268
  278. package/Lights/shadowLight.js.map +1 -1
  279. package/Lights/spotLight.pure.js +460 -427
  280. package/Lights/spotLight.pure.js.map +1 -1
  281. package/Loading/Plugins/babylonFileLoader.pure.js +17 -5
  282. package/Loading/Plugins/babylonFileLoader.pure.js.map +1 -1
  283. package/Loading/sceneLoader.d.ts +5 -1
  284. package/Loading/sceneLoader.js +299 -402
  285. package/Loading/sceneLoader.js.map +1 -1
  286. package/Materials/Background/backgroundMaterial.pure.d.ts +18 -18
  287. package/Materials/Background/backgroundMaterial.pure.js +949 -794
  288. package/Materials/Background/backgroundMaterial.pure.js.map +1 -1
  289. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.d.ts +15 -0
  290. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js +34 -1
  291. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js.map +1 -1
  292. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.d.ts +9 -0
  293. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +26 -2
  294. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
  295. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.d.ts +2 -1
  296. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.js +169 -149
  297. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.pure.js.map +1 -1
  298. package/Materials/Node/Blocks/Dual/imageSourceBlock.pure.js +1 -1
  299. package/Materials/Node/Blocks/Dual/lightBlock.pure.js +442 -429
  300. package/Materials/Node/Blocks/Dual/lightBlock.pure.js.map +1 -1
  301. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.pure.js +396 -383
  302. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.pure.js.map +1 -1
  303. package/Materials/Node/Blocks/Dual/sceneDepthBlock.pure.js +237 -220
  304. package/Materials/Node/Blocks/Dual/sceneDepthBlock.pure.js.map +1 -1
  305. package/Materials/Node/Blocks/Dual/textureBlock.pure.js +1 -1
  306. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.pure.js +150 -133
  307. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.pure.js.map +1 -1
  308. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js +265 -250
  309. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.pure.js.map +1 -1
  310. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.pure.js +159 -142
  311. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.pure.js.map +1 -1
  312. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.pure.js +214 -201
  313. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.pure.js.map +1 -1
  314. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.pure.js +419 -400
  315. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.pure.js.map +1 -1
  316. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js +3 -1
  317. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js.map +1 -1
  318. package/Materials/Node/Blocks/PBR/clearCoatBlock.pure.js +302 -289
  319. package/Materials/Node/Blocks/PBR/clearCoatBlock.pure.js.map +1 -1
  320. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js +1327 -1272
  321. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js.map +1 -1
  322. package/Materials/Node/Blocks/PBR/reflectionBlock.pure.js +352 -337
  323. package/Materials/Node/Blocks/PBR/reflectionBlock.pure.js.map +1 -1
  324. package/Materials/Node/Blocks/PBR/refractionBlock.pure.js +297 -277
  325. package/Materials/Node/Blocks/PBR/refractionBlock.pure.js.map +1 -1
  326. package/Materials/Node/Blocks/PBR/sheenBlock.pure.js +146 -131
  327. package/Materials/Node/Blocks/PBR/sheenBlock.pure.js.map +1 -1
  328. package/Materials/Node/Blocks/PBR/subSurfaceBlock.pure.js +158 -145
  329. package/Materials/Node/Blocks/PBR/subSurfaceBlock.pure.js.map +1 -1
  330. package/Materials/Node/Blocks/clampBlock.pure.js +92 -77
  331. package/Materials/Node/Blocks/clampBlock.pure.js.map +1 -1
  332. package/Materials/Node/Blocks/cloudBlock.pure.js +145 -132
  333. package/Materials/Node/Blocks/cloudBlock.pure.js.map +1 -1
  334. package/Materials/Node/Blocks/conditionalBlock.pure.js +182 -169
  335. package/Materials/Node/Blocks/conditionalBlock.pure.js.map +1 -1
  336. package/Materials/Node/Blocks/curveBlock.pure.js +259 -246
  337. package/Materials/Node/Blocks/curveBlock.pure.js.map +1 -1
  338. package/Materials/Node/Blocks/debugBlock.pure.js +119 -106
  339. package/Materials/Node/Blocks/debugBlock.pure.js.map +1 -1
  340. package/Materials/Node/Blocks/loopBlock.pure.js +123 -110
  341. package/Materials/Node/Blocks/loopBlock.pure.js.map +1 -1
  342. package/Materials/Node/Blocks/meshAttributeExistsBlock.pure.js +185 -172
  343. package/Materials/Node/Blocks/meshAttributeExistsBlock.pure.js.map +1 -1
  344. package/Materials/Node/Blocks/remapBlock.pure.js +127 -112
  345. package/Materials/Node/Blocks/remapBlock.pure.js.map +1 -1
  346. package/Materials/Node/Blocks/transformBlock.pure.js +196 -185
  347. package/Materials/Node/Blocks/transformBlock.pure.js.map +1 -1
  348. package/Materials/Node/Blocks/triPlanarBlock.pure.js +451 -438
  349. package/Materials/Node/Blocks/triPlanarBlock.pure.js.map +1 -1
  350. package/Materials/Node/Blocks/trigonometryBlock.pure.js +184 -171
  351. package/Materials/Node/Blocks/trigonometryBlock.pure.js.map +1 -1
  352. package/Materials/Node/Blocks/waveBlock.pure.js +97 -84
  353. package/Materials/Node/Blocks/waveBlock.pure.js.map +1 -1
  354. package/Materials/Node/Blocks/worleyNoise3DBlock.pure.js +276 -263
  355. package/Materials/Node/Blocks/worleyNoise3DBlock.pure.js.map +1 -1
  356. package/Materials/Node/nodeMaterial.pure.js +1765 -1737
  357. package/Materials/Node/nodeMaterial.pure.js.map +1 -1
  358. package/Materials/Node/nodeMaterialBuildState.d.ts +3 -3
  359. package/Materials/PBR/openpbrMaterial.pure.d.ts +102 -102
  360. package/Materials/PBR/openpbrMaterial.pure.js +3115 -2243
  361. package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
  362. package/Materials/PBR/pbrAnisotropicConfiguration.d.ts +3 -3
  363. package/Materials/PBR/pbrAnisotropicConfiguration.js +255 -227
  364. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  365. package/Materials/PBR/pbrBRDFConfiguration.d.ts +9 -9
  366. package/Materials/PBR/pbrBRDFConfiguration.js +203 -155
  367. package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
  368. package/Materials/PBR/pbrBaseMaterial.pure.d.ts +1 -1
  369. package/Materials/PBR/pbrBaseMaterial.pure.js +1751 -1736
  370. package/Materials/PBR/pbrBaseMaterial.pure.js.map +1 -1
  371. package/Materials/PBR/pbrBaseSimpleMaterial.d.ts +13 -13
  372. package/Materials/PBR/pbrBaseSimpleMaterial.js +205 -117
  373. package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
  374. package/Materials/PBR/pbrClearCoatConfiguration.d.ts +9 -9
  375. package/Materials/PBR/pbrClearCoatConfiguration.js +464 -406
  376. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  377. package/Materials/PBR/pbrIridescenceConfiguration.d.ts +3 -3
  378. package/Materials/PBR/pbrIridescenceConfiguration.js +271 -239
  379. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  380. package/Materials/PBR/pbrMaterial.pure.d.ts +66 -66
  381. package/Materials/PBR/pbrMaterial.pure.js +1041 -685
  382. package/Materials/PBR/pbrMaterial.pure.js.map +1 -1
  383. package/Materials/PBR/pbrMetallicRoughnessMaterial.pure.d.ts +5 -5
  384. package/Materials/PBR/pbrMetallicRoughnessMaterial.pure.js +176 -115
  385. package/Materials/PBR/pbrMetallicRoughnessMaterial.pure.js.map +1 -1
  386. package/Materials/PBR/pbrSheenConfiguration.d.ts +7 -7
  387. package/Materials/PBR/pbrSheenConfiguration.js +314 -270
  388. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  389. package/Materials/PBR/pbrSpecularGlossinessMaterial.pure.d.ts +5 -5
  390. package/Materials/PBR/pbrSpecularGlossinessMaterial.pure.js +172 -117
  391. package/Materials/PBR/pbrSpecularGlossinessMaterial.pure.js.map +1 -1
  392. package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +16 -16
  393. package/Materials/PBR/pbrSubSurfaceConfiguration.js +864 -764
  394. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  395. package/Materials/Textures/HTML/htmlInCanvasPolyfill.d.ts +43 -0
  396. package/Materials/Textures/HTML/htmlInCanvasPolyfill.js +64 -0
  397. package/Materials/Textures/HTML/htmlInCanvasPolyfill.js.map +1 -0
  398. package/Materials/Textures/HTML/htmlInteractionManager.d.ts +69 -0
  399. package/Materials/Textures/HTML/htmlInteractionManager.js +130 -0
  400. package/Materials/Textures/HTML/htmlInteractionManager.js.map +1 -0
  401. package/Materials/Textures/HTML/htmlRaycastInteractionManager.d.ts +84 -0
  402. package/Materials/Textures/HTML/htmlRaycastInteractionManager.js +246 -0
  403. package/Materials/Textures/HTML/htmlRaycastInteractionManager.js.map +1 -0
  404. package/Materials/Textures/HTML/htmlTexture.d.ts +148 -0
  405. package/Materials/Textures/HTML/htmlTexture.js +455 -0
  406. package/Materials/Textures/HTML/htmlTexture.js.map +1 -0
  407. package/Materials/Textures/HTML/index.d.ts +4 -0
  408. package/Materials/Textures/HTML/index.js +5 -0
  409. package/Materials/Textures/HTML/index.js.map +1 -0
  410. package/Materials/Textures/HTML/pure.d.ts +5 -0
  411. package/Materials/Textures/HTML/pure.js +6 -0
  412. package/Materials/Textures/HTML/pure.js.map +1 -0
  413. package/Materials/Textures/Procedurals/proceduralTexture.pure.js +671 -643
  414. package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
  415. package/Materials/Textures/baseTexture.pure.js +880 -825
  416. package/Materials/Textures/baseTexture.pure.js.map +1 -1
  417. package/Materials/Textures/cubeTexture.d.ts +0 -1
  418. package/Materials/Textures/cubeTexture.js +0 -1
  419. package/Materials/Textures/cubeTexture.js.map +1 -1
  420. package/Materials/Textures/cubeTexture.pure.js +368 -333
  421. package/Materials/Textures/cubeTexture.pure.js.map +1 -1
  422. package/Materials/Textures/dynamicTexture.d.ts +0 -1
  423. package/Materials/Textures/dynamicTexture.js +0 -1
  424. package/Materials/Textures/dynamicTexture.js.map +1 -1
  425. package/Materials/Textures/dynamicTexture.pure.js +2 -0
  426. package/Materials/Textures/dynamicTexture.pure.js.map +1 -1
  427. package/Materials/Textures/htmlElementTexture.d.ts +0 -2
  428. package/Materials/Textures/htmlElementTexture.js +0 -2
  429. package/Materials/Textures/htmlElementTexture.js.map +1 -1
  430. package/Materials/Textures/htmlElementTexture.pure.js +4 -0
  431. package/Materials/Textures/htmlElementTexture.pure.js.map +1 -1
  432. package/Materials/Textures/index.d.ts +1 -0
  433. package/Materials/Textures/index.js +1 -1
  434. package/Materials/Textures/index.js.map +1 -1
  435. package/Materials/Textures/multiRenderTarget.d.ts +0 -1
  436. package/Materials/Textures/multiRenderTarget.js +0 -1
  437. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  438. package/Materials/Textures/multiRenderTarget.pure.js +2 -0
  439. package/Materials/Textures/multiRenderTarget.pure.js.map +1 -1
  440. package/Materials/Textures/pure.d.ts +1 -0
  441. package/Materials/Textures/pure.js +1 -0
  442. package/Materials/Textures/pure.js.map +1 -1
  443. package/Materials/Textures/texture.pure.js +961 -923
  444. package/Materials/Textures/texture.pure.js.map +1 -1
  445. package/Materials/Textures/videoTexture.pure.d.ts +3 -0
  446. package/Materials/Textures/videoTexture.pure.js +450 -401
  447. package/Materials/Textures/videoTexture.pure.js.map +1 -1
  448. package/Materials/colorCurves.pure.js +510 -477
  449. package/Materials/colorCurves.pure.js.map +1 -1
  450. package/Materials/effect.pure.js +0 -7
  451. package/Materials/effect.pure.js.map +1 -1
  452. package/Materials/imageProcessing.js +12 -4
  453. package/Materials/imageProcessing.js.map +1 -1
  454. package/Materials/imageProcessingConfiguration.pure.js +647 -587
  455. package/Materials/imageProcessingConfiguration.pure.js.map +1 -1
  456. package/Materials/material.decalMapConfiguration.pure.d.ts +2 -2
  457. package/Materials/material.decalMapConfiguration.pure.js +149 -130
  458. package/Materials/material.decalMapConfiguration.pure.js.map +1 -1
  459. package/Materials/material.detailMapConfiguration.d.ts +3 -3
  460. package/Materials/material.detailMapConfiguration.js +213 -175
  461. package/Materials/material.detailMapConfiguration.js.map +1 -1
  462. package/Materials/material.pure.js +1815 -1721
  463. package/Materials/material.pure.js.map +1 -1
  464. package/Materials/materialPluginBase.pure.js +270 -249
  465. package/Materials/materialPluginBase.pure.js.map +1 -1
  466. package/Materials/materialPluginManager.pure.js +18 -8
  467. package/Materials/materialPluginManager.pure.js.map +1 -1
  468. package/Materials/materialStencilState.js +211 -200
  469. package/Materials/materialStencilState.js.map +1 -1
  470. package/Materials/meshDebugPluginMaterial.pure.d.ts +2 -2
  471. package/Materials/meshDebugPluginMaterial.pure.js +397 -275
  472. package/Materials/meshDebugPluginMaterial.pure.js.map +1 -1
  473. package/Materials/standardMaterial.pure.d.ts +32 -32
  474. package/Materials/standardMaterial.pure.js +1804 -1394
  475. package/Materials/standardMaterial.pure.js.map +1 -1
  476. package/Maths/math.color.pure.js +5 -5
  477. package/Maths/math.functions.js +38 -30
  478. package/Maths/math.functions.js.map +1 -1
  479. package/Maths/math.vector.pure.js +25 -25
  480. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +18 -8
  481. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
  482. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +86 -1
  483. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +255 -104
  484. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
  485. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.d.ts +39 -0
  486. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js +322 -0
  487. package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js.map +1 -0
  488. package/Meshes/GreasedLine/greasedLineMesh.pure.js +4 -4
  489. package/Meshes/GreasedLine/greasedLineRibbonMesh.pure.js +3 -3
  490. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js +107 -94
  491. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js.map +1 -1
  492. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.pure.js +276 -263
  493. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.pure.js.map +1 -1
  494. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.pure.js +247 -232
  495. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.pure.js.map +1 -1
  496. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.pure.js +299 -284
  497. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.pure.js.map +1 -1
  498. package/Meshes/Node/Blocks/Set/aggregatorBlock.pure.js +196 -181
  499. package/Meshes/Node/Blocks/Set/aggregatorBlock.pure.js.map +1 -1
  500. package/Meshes/Node/Blocks/Set/latticeBlock.pure.js +198 -179
  501. package/Meshes/Node/Blocks/Set/latticeBlock.pure.js.map +1 -1
  502. package/Meshes/Node/Blocks/Set/setColorsBlock.pure.js +151 -138
  503. package/Meshes/Node/Blocks/Set/setColorsBlock.pure.js.map +1 -1
  504. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.pure.js +107 -94
  505. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.pure.js.map +1 -1
  506. package/Meshes/Node/Blocks/Set/setNormalsBlock.pure.js +138 -125
  507. package/Meshes/Node/Blocks/Set/setNormalsBlock.pure.js.map +1 -1
  508. package/Meshes/Node/Blocks/Set/setPositionsBlock.pure.js +213 -200
  509. package/Meshes/Node/Blocks/Set/setPositionsBlock.pure.js.map +1 -1
  510. package/Meshes/Node/Blocks/Set/setTangentsBlock.pure.js +138 -125
  511. package/Meshes/Node/Blocks/Set/setTangentsBlock.pure.js.map +1 -1
  512. package/Meshes/Node/Blocks/Set/setUVsBlock.pure.js +179 -164
  513. package/Meshes/Node/Blocks/Set/setUVsBlock.pure.js.map +1 -1
  514. package/Meshes/Node/Blocks/Sources/boxBlock.pure.js +183 -170
  515. package/Meshes/Node/Blocks/Sources/boxBlock.pure.js.map +1 -1
  516. package/Meshes/Node/Blocks/Sources/capsuleBlock.pure.js +125 -112
  517. package/Meshes/Node/Blocks/Sources/capsuleBlock.pure.js.map +1 -1
  518. package/Meshes/Node/Blocks/Sources/cylinderBlock.pure.js +153 -140
  519. package/Meshes/Node/Blocks/Sources/cylinderBlock.pure.js.map +1 -1
  520. package/Meshes/Node/Blocks/Sources/discBlock.pure.js +112 -99
  521. package/Meshes/Node/Blocks/Sources/discBlock.pure.js.map +1 -1
  522. package/Meshes/Node/Blocks/Sources/gridBlock.pure.js +133 -120
  523. package/Meshes/Node/Blocks/Sources/gridBlock.pure.js.map +1 -1
  524. package/Meshes/Node/Blocks/Sources/icoSphereBlock.pure.js +128 -115
  525. package/Meshes/Node/Blocks/Sources/icoSphereBlock.pure.js.map +1 -1
  526. package/Meshes/Node/Blocks/Sources/meshBlock.pure.js +116 -103
  527. package/Meshes/Node/Blocks/Sources/meshBlock.pure.js.map +1 -1
  528. package/Meshes/Node/Blocks/Sources/planeBlock.pure.js +160 -147
  529. package/Meshes/Node/Blocks/Sources/planeBlock.pure.js.map +1 -1
  530. package/Meshes/Node/Blocks/Sources/sphereBlock.pure.js +144 -131
  531. package/Meshes/Node/Blocks/Sources/sphereBlock.pure.js.map +1 -1
  532. package/Meshes/Node/Blocks/Sources/torusBlock.pure.js +112 -99
  533. package/Meshes/Node/Blocks/Sources/torusBlock.pure.js.map +1 -1
  534. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.pure.js +200 -185
  535. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.pure.js.map +1 -1
  536. package/Meshes/Node/Blocks/bevelBlock.pure.js +111 -98
  537. package/Meshes/Node/Blocks/bevelBlock.pure.js.map +1 -1
  538. package/Meshes/Node/Blocks/booleanGeometryBlock.pure.js +182 -165
  539. package/Meshes/Node/Blocks/booleanGeometryBlock.pure.js.map +1 -1
  540. package/Meshes/Node/Blocks/cleanGeometryBlock.pure.js +89 -76
  541. package/Meshes/Node/Blocks/cleanGeometryBlock.pure.js.map +1 -1
  542. package/Meshes/Node/Blocks/conditionBlock.pure.js +184 -169
  543. package/Meshes/Node/Blocks/conditionBlock.pure.js.map +1 -1
  544. package/Meshes/Node/Blocks/extrudeGeometryBlock.pure.js +270 -255
  545. package/Meshes/Node/Blocks/extrudeGeometryBlock.pure.js.map +1 -1
  546. package/Meshes/Node/Blocks/geometryCollectionBlock.pure.js +172 -159
  547. package/Meshes/Node/Blocks/geometryCollectionBlock.pure.js.map +1 -1
  548. package/Meshes/Node/Blocks/geometryCurveBlock.pure.js +230 -217
  549. package/Meshes/Node/Blocks/geometryCurveBlock.pure.js.map +1 -1
  550. package/Meshes/Node/Blocks/geometryEaseBlock.pure.js +256 -245
  551. package/Meshes/Node/Blocks/geometryEaseBlock.pure.js.map +1 -1
  552. package/Meshes/Node/Blocks/geometryOptimizeBlock.pure.js +206 -189
  553. package/Meshes/Node/Blocks/geometryOptimizeBlock.pure.js.map +1 -1
  554. package/Meshes/Node/Blocks/geometryTransformBlock.pure.js +166 -153
  555. package/Meshes/Node/Blocks/geometryTransformBlock.pure.js.map +1 -1
  556. package/Meshes/Node/Blocks/geometryTrigonometryBlock.pure.js +221 -208
  557. package/Meshes/Node/Blocks/geometryTrigonometryBlock.pure.js.map +1 -1
  558. package/Meshes/Node/Blocks/mappingBlock.pure.js +150 -137
  559. package/Meshes/Node/Blocks/mappingBlock.pure.js.map +1 -1
  560. package/Meshes/Node/Blocks/mathBlock.pure.js +269 -256
  561. package/Meshes/Node/Blocks/mathBlock.pure.js.map +1 -1
  562. package/Meshes/Node/Blocks/mergeGeometryBlock.pure.js +141 -128
  563. package/Meshes/Node/Blocks/mergeGeometryBlock.pure.js.map +1 -1
  564. package/Meshes/Node/Blocks/randomBlock.pure.js +161 -148
  565. package/Meshes/Node/Blocks/randomBlock.pure.js.map +1 -1
  566. package/Meshes/Node/Blocks/subdivideBlock.pure.js +102 -87
  567. package/Meshes/Node/Blocks/subdivideBlock.pure.js.map +1 -1
  568. package/Meshes/Node/nodeGeometry.js +560 -538
  569. package/Meshes/Node/nodeGeometry.js.map +1 -1
  570. package/Meshes/Node/nodeGeometryBlock.js +473 -458
  571. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  572. package/Meshes/abstractMesh.pure.js +2218 -2207
  573. package/Meshes/abstractMesh.pure.js.map +1 -1
  574. package/Meshes/geometry.js +30 -15
  575. package/Meshes/geometry.js.map +1 -1
  576. package/Meshes/mesh.pure.js +26 -14
  577. package/Meshes/mesh.pure.js.map +1 -1
  578. package/Meshes/mesh.vertexData.js +1665 -1655
  579. package/Meshes/mesh.vertexData.js.map +1 -1
  580. package/Meshes/transformNode.pure.js +1400 -1372
  581. package/Meshes/transformNode.pure.js.map +1 -1
  582. package/Misc/decorators.d.ts +34 -19
  583. package/Misc/decorators.functions.d.ts +33 -2
  584. package/Misc/decorators.functions.js +114 -35
  585. package/Misc/decorators.functions.js.map +1 -1
  586. package/Misc/decorators.js +96 -68
  587. package/Misc/decorators.js.map +1 -1
  588. package/Misc/decorators.serialization.js +47 -40
  589. package/Misc/decorators.serialization.js.map +1 -1
  590. package/Misc/decorators.serializationUtilities.d.ts +24 -0
  591. package/Misc/decorators.serializationUtilities.js +20 -0
  592. package/Misc/decorators.serializationUtilities.js.map +1 -0
  593. package/Misc/dumpTools.pure.js +43 -33
  594. package/Misc/dumpTools.pure.js.map +1 -1
  595. package/Misc/fileTools.pure.js +8 -0
  596. package/Misc/fileTools.pure.js.map +1 -1
  597. package/Misc/observable.pure.js +0 -7
  598. package/Misc/observable.pure.js.map +1 -1
  599. package/Misc/snapshotRenderingHelper.d.ts +4 -1
  600. package/Misc/snapshotRenderingHelper.js.map +1 -1
  601. package/Misc/symbolMetadataPolyfill.d.ts +11 -0
  602. package/Misc/symbolMetadataPolyfill.js +22 -0
  603. package/Misc/symbolMetadataPolyfill.js.map +1 -0
  604. package/Misc/tools.pure.js +2 -2
  605. package/Misc/tools.pure.js.map +1 -1
  606. package/Morph/morphTarget.js +382 -365
  607. package/Morph/morphTarget.js.map +1 -1
  608. package/Particles/Node/Blocks/Conditions/particleConditionBlock.pure.js +160 -145
  609. package/Particles/Node/Blocks/Conditions/particleConditionBlock.pure.js.map +1 -1
  610. package/Particles/Node/Blocks/Emitters/coneShapeBlock.pure.js +187 -174
  611. package/Particles/Node/Blocks/Emitters/coneShapeBlock.pure.js.map +1 -1
  612. package/Particles/Node/Blocks/Emitters/meshShapeBlock.pure.js +238 -219
  613. package/Particles/Node/Blocks/Emitters/meshShapeBlock.pure.js.map +1 -1
  614. package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.pure.js +140 -115
  615. package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.pure.js.map +1 -1
  616. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.pure.js +157 -144
  617. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.pure.js.map +1 -1
  618. package/Particles/Node/Blocks/Triggers/particleTriggerBlock.pure.js +133 -119
  619. package/Particles/Node/Blocks/Triggers/particleTriggerBlock.pure.js.map +1 -1
  620. package/Particles/Node/Blocks/Update/alignAngleBlock.pure.js +93 -80
  621. package/Particles/Node/Blocks/Update/alignAngleBlock.pure.js.map +1 -1
  622. package/Particles/Node/Blocks/particleDebugBlock.pure.js +117 -105
  623. package/Particles/Node/Blocks/particleDebugBlock.pure.js.map +1 -1
  624. package/Particles/Node/Blocks/particleFloatToIntBlock.pure.js +105 -92
  625. package/Particles/Node/Blocks/particleFloatToIntBlock.pure.js.map +1 -1
  626. package/Particles/Node/Blocks/particleGradientValueBlock.pure.js +82 -69
  627. package/Particles/Node/Blocks/particleGradientValueBlock.pure.js.map +1 -1
  628. package/Particles/Node/Blocks/particleLocalVariableBlock.pure.js +113 -101
  629. package/Particles/Node/Blocks/particleLocalVariableBlock.pure.js.map +1 -1
  630. package/Particles/Node/Blocks/particleMathBlock.pure.js +278 -265
  631. package/Particles/Node/Blocks/particleMathBlock.pure.js.map +1 -1
  632. package/Particles/Node/Blocks/particleNumberMathBlock.pure.js +155 -142
  633. package/Particles/Node/Blocks/particleNumberMathBlock.pure.js.map +1 -1
  634. package/Particles/Node/Blocks/particleRandomBlock.pure.js +156 -143
  635. package/Particles/Node/Blocks/particleRandomBlock.pure.js.map +1 -1
  636. package/Particles/Node/Blocks/particleTrigonometryBlock.pure.js +217 -204
  637. package/Particles/Node/Blocks/particleTrigonometryBlock.pure.js.map +1 -1
  638. package/Particles/Node/Blocks/particleVectorMathBlock.pure.js +106 -93
  639. package/Particles/Node/Blocks/particleVectorMathBlock.pure.js.map +1 -1
  640. package/Particles/Node/Blocks/systemBlock.pure.js +366 -330
  641. package/Particles/Node/Blocks/systemBlock.pure.js.map +1 -1
  642. package/Particles/Node/nodeParticleBlock.js +339 -324
  643. package/Particles/Node/nodeParticleBlock.js.map +1 -1
  644. package/Particles/Node/nodeParticleSystemSet.js +494 -473
  645. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  646. package/Particles/gpuParticleSystem.d.ts +0 -1
  647. package/Particles/gpuParticleSystem.js +0 -1
  648. package/Particles/gpuParticleSystem.js.map +1 -1
  649. package/Particles/gpuParticleSystem.pure.d.ts +4 -3
  650. package/Particles/gpuParticleSystem.pure.js +27 -16
  651. package/Particles/gpuParticleSystem.pure.js.map +1 -1
  652. package/Particles/particleSystem.pure.js +57 -2
  653. package/Particles/particleSystem.pure.js.map +1 -1
  654. package/Particles/thinParticleSystem.d.ts +0 -1
  655. package/Particles/thinParticleSystem.js +0 -1
  656. package/Particles/thinParticleSystem.js.map +1 -1
  657. package/Particles/thinParticleSystem.pure.js +2 -0
  658. package/Particles/thinParticleSystem.pure.js.map +1 -1
  659. package/Particles/webgl2ParticleSystem.pure.js +2 -0
  660. package/Particles/webgl2ParticleSystem.pure.js.map +1 -1
  661. package/Physics/v1/physicsImpostor.pure.js +4 -4
  662. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.pure.js +675 -656
  663. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.pure.js.map +1 -1
  664. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.d.ts +0 -1
  665. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js +0 -1
  666. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js.map +1 -1
  667. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.pure.js +521 -486
  668. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.pure.js.map +1 -1
  669. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.d.ts +0 -1
  670. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js +0 -1
  671. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
  672. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.pure.js +241 -220
  673. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.pure.js.map +1 -1
  674. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.pure.js +852 -835
  675. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.pure.js.map +1 -1
  676. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.pure.js +1135 -1073
  677. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.pure.js.map +1 -1
  678. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.pure.js +319 -303
  679. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.pure.js.map +1 -1
  680. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js +212 -199
  681. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
  682. package/PostProcesses/blackAndWhitePostProcess.pure.js +67 -55
  683. package/PostProcesses/blackAndWhitePostProcess.pure.js.map +1 -1
  684. package/PostProcesses/bloomMergePostProcess.pure.js +74 -62
  685. package/PostProcesses/bloomMergePostProcess.pure.js.map +1 -1
  686. package/PostProcesses/blurPostProcess.pure.js +127 -115
  687. package/PostProcesses/blurPostProcess.pure.js.map +1 -1
  688. package/PostProcesses/chromaticAberrationPostProcess.pure.js +130 -118
  689. package/PostProcesses/chromaticAberrationPostProcess.pure.js.map +1 -1
  690. package/PostProcesses/circleOfConfusionPostProcess.pure.js +115 -104
  691. package/PostProcesses/circleOfConfusionPostProcess.pure.js.map +1 -1
  692. package/PostProcesses/colorCorrectionPostProcess.pure.js +55 -43
  693. package/PostProcesses/colorCorrectionPostProcess.pure.js.map +1 -1
  694. package/PostProcesses/convolutionPostProcess.pure.js +96 -84
  695. package/PostProcesses/convolutionPostProcess.pure.js.map +1 -1
  696. package/PostProcesses/extractHighlightsPostProcess.pure.js +68 -57
  697. package/PostProcesses/extractHighlightsPostProcess.pure.js.map +1 -1
  698. package/PostProcesses/filterPostProcess.pure.js +66 -54
  699. package/PostProcesses/filterPostProcess.pure.js.map +1 -1
  700. package/PostProcesses/fxaaPostProcess.pure.js.map +1 -1
  701. package/PostProcesses/grainPostProcess.pure.js +82 -70
  702. package/PostProcesses/grainPostProcess.pure.js.map +1 -1
  703. package/PostProcesses/imageProcessingPostProcess.js +334 -322
  704. package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
  705. package/PostProcesses/motionBlurPostProcess.pure.js +246 -235
  706. package/PostProcesses/motionBlurPostProcess.pure.js.map +1 -1
  707. package/PostProcesses/passPostProcess.pure.js +75 -63
  708. package/PostProcesses/passPostProcess.pure.js.map +1 -1
  709. package/PostProcesses/postProcess.pure.js +899 -835
  710. package/PostProcesses/postProcess.pure.js.map +1 -1
  711. package/PostProcesses/refractionPostProcess.pure.js +114 -87
  712. package/PostProcesses/refractionPostProcess.pure.js.map +1 -1
  713. package/PostProcesses/screenSpaceCurvaturePostProcess.pure.js +108 -96
  714. package/PostProcesses/screenSpaceCurvaturePostProcess.pure.js.map +1 -1
  715. package/PostProcesses/screenSpaceReflectionPostProcess.pure.js +241 -220
  716. package/PostProcesses/screenSpaceReflectionPostProcess.pure.js.map +1 -1
  717. package/PostProcesses/sharpenPostProcess.pure.js +86 -74
  718. package/PostProcesses/sharpenPostProcess.pure.js.map +1 -1
  719. package/PostProcesses/tonemapPostProcess.pure.js +82 -70
  720. package/PostProcesses/tonemapPostProcess.pure.js.map +1 -1
  721. package/PostProcesses/volumetricLightScatteringPostProcess.pure.js +500 -465
  722. package/PostProcesses/volumetricLightScatteringPostProcess.pure.js.map +1 -1
  723. package/PostProcesses/vrMultiviewToSingleviewPostProcess.d.ts +0 -1
  724. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js +0 -1
  725. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js.map +1 -1
  726. package/PostProcesses/vrMultiviewToSingleviewPostProcess.pure.js +2 -0
  727. package/PostProcesses/vrMultiviewToSingleviewPostProcess.pure.js.map +1 -1
  728. package/Probes/reflectionProbe.pure.js +238 -224
  729. package/Probes/reflectionProbe.pure.js.map +1 -1
  730. package/Rendering/GlobalIllumination/giRSMManager.pure.d.ts +1 -1
  731. package/Rendering/GlobalIllumination/giRSMManager.pure.js +138 -105
  732. package/Rendering/GlobalIllumination/giRSMManager.pure.js.map +1 -1
  733. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.d.ts +1 -1
  734. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.js +155 -138
  735. package/Rendering/IBLShadows/iblShadowsPluginMaterial.pure.js.map +1 -1
  736. package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +0 -2
  737. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +0 -2
  738. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  739. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js +5 -0
  740. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js.map +1 -1
  741. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +0 -1
  742. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +0 -1
  743. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  744. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.d.ts +1 -0
  745. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +34 -0
  746. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
  747. package/Rendering/edgesRenderer.pure.js.map +1 -1
  748. package/Rendering/prePassRenderer.d.ts +0 -2
  749. package/Rendering/prePassRenderer.js +0 -2
  750. package/Rendering/prePassRenderer.js.map +1 -1
  751. package/Rendering/prePassRenderer.pure.js +2 -0
  752. package/Rendering/prePassRenderer.pure.js.map +1 -1
  753. package/Rendering/reflectiveShadowMap.pure.d.ts +1 -1
  754. package/Rendering/reflectiveShadowMap.pure.js +151 -130
  755. package/Rendering/reflectiveShadowMap.pure.js.map +1 -1
  756. package/Rendering/thinDepthPeelingRenderer.d.ts +0 -1
  757. package/Rendering/thinDepthPeelingRenderer.js +0 -1
  758. package/Rendering/thinDepthPeelingRenderer.js.map +1 -1
  759. package/Shaders/ShadersInclude/gaussianSplatting.js +1 -0
  760. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  761. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +35 -5
  762. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  763. package/Shaders/gaussianSplatting.fragment.js +17 -1
  764. package/Shaders/gaussianSplatting.fragment.js.map +1 -1
  765. package/Shaders/gaussianSplatting.vertex.js +1 -1
  766. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  767. package/Shaders/gaussianSplattingDepth.vertex.js +1 -1
  768. package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
  769. package/Shaders/picking.fragment.js +39 -3
  770. package/Shaders/picking.fragment.js.map +1 -1
  771. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +3 -1
  772. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  773. package/ShadersWGSL/ShadersInclude/helperFunctions.js +2 -2
  774. package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
  775. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +39 -7
  776. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  777. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +4 -3
  778. package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -1
  779. package/ShadersWGSL/gaussianSplatting.fragment.js +14 -1
  780. package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -1
  781. package/ShadersWGSL/gaussianSplatting.vertex.js +2 -2
  782. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  783. package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
  784. package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
  785. package/ShadersWGSL/lightingVolume.compute.js +2 -2
  786. package/ShadersWGSL/lightingVolume.compute.js.map +1 -1
  787. package/ShadersWGSL/picking.fragment.js +22 -1
  788. package/ShadersWGSL/picking.fragment.js.map +1 -1
  789. package/XR/features/Layers/WebXRCompositionLayer.d.ts +3 -2
  790. package/XR/features/Layers/WebXRCompositionLayer.js +2 -2
  791. package/XR/features/Layers/WebXRCompositionLayer.js.map +1 -1
  792. package/XR/features/Layers/WebXRWebGPUCompositionLayer.d.ts +59 -0
  793. package/XR/features/Layers/WebXRWebGPUCompositionLayer.js +120 -0
  794. package/XR/features/Layers/WebXRWebGPUCompositionLayer.js.map +1 -0
  795. package/XR/features/Layers/WebXRWebGPUProjectionLayer.d.ts +25 -0
  796. package/XR/features/Layers/WebXRWebGPUProjectionLayer.js +69 -0
  797. package/XR/features/Layers/WebXRWebGPUProjectionLayer.js.map +1 -0
  798. package/XR/features/WebXRLayers.pure.d.ts +8 -0
  799. package/XR/features/WebXRLayers.pure.js +43 -6
  800. package/XR/features/WebXRLayers.pure.js.map +1 -1
  801. package/XR/native/nativeXRRenderTarget.d.ts +2 -2
  802. package/XR/native/nativeXRRenderTarget.js +2 -2
  803. package/XR/native/nativeXRRenderTarget.js.map +1 -1
  804. package/XR/webXRExperienceHelper.js +10 -1
  805. package/XR/webXRExperienceHelper.js.map +1 -1
  806. package/XR/webXRGraphicsBinding.d.ts +90 -0
  807. package/XR/webXRGraphicsBinding.js +85 -0
  808. package/XR/webXRGraphicsBinding.js.map +1 -0
  809. package/XR/webXRLayerRenderTargetTexture.d.ts +24 -0
  810. package/XR/webXRLayerRenderTargetTexture.js +30 -0
  811. package/XR/webXRLayerRenderTargetTexture.js.map +1 -0
  812. package/XR/webXRManagedOutputCanvas.d.ts +14 -0
  813. package/XR/webXRManagedOutputCanvas.js +24 -5
  814. package/XR/webXRManagedOutputCanvas.js.map +1 -1
  815. package/XR/webXRRenderTargetTextureProvider.d.ts +25 -4
  816. package/XR/webXRRenderTargetTextureProvider.js +33 -35
  817. package/XR/webXRRenderTargetTextureProvider.js.map +1 -1
  818. package/XR/webXRSessionManager.d.ts +11 -0
  819. package/XR/webXRSessionManager.js +37 -0
  820. package/XR/webXRSessionManager.js.map +1 -1
  821. package/XR/webXRTypes.d.ts +9 -6
  822. package/XR/webXRTypes.js.map +1 -1
  823. package/XR/webXRWebGLLayer.d.ts +2 -2
  824. package/XR/webXRWebGLLayer.js +2 -2
  825. package/XR/webXRWebGLLayer.js.map +1 -1
  826. package/XR/webXRWebGLRenderTargetTextureProvider.d.ts +12 -0
  827. package/XR/webXRWebGLRenderTargetTextureProvider.js +58 -0
  828. package/XR/webXRWebGLRenderTargetTextureProvider.js.map +1 -0
  829. package/XR/webXRWebGPURenderTargetTextureProvider.d.ts +69 -0
  830. package/XR/webXRWebGPURenderTargetTextureProvider.js +148 -0
  831. package/XR/webXRWebGPURenderTargetTextureProvider.js.map +1 -0
  832. package/index.d.ts +1 -0
  833. package/index.js +1 -0
  834. package/index.js.map +1 -1
  835. package/node.js +878 -845
  836. package/node.js.map +1 -1
  837. package/package.json +8 -14
  838. package/scene.pure.d.ts +12 -0
  839. package/scene.pure.js +36 -0
  840. package/scene.pure.js.map +1 -1
  841. package/tslib.es6.js +304 -150
@@ -1,5 +1,5 @@
1
1
  /** This file must only contain pure code and pure imports */
2
- import { __decorate } from "../../tslib.es6.js";
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet, __esDecorate, __runInitializers } from "../../tslib.es6.js";
3
3
  /* eslint-disable @typescript-eslint/naming-convention */
4
4
  import { expandToProperty } from "../../Misc/decorators.js";
5
5
  import { Logger } from "../../Misc/logger.js";
@@ -218,1844 +218,1859 @@ class PBRBaseMaterialBase extends ImageProcessingMixin(PushMaterial) {
218
218
  * @see [WebGL](https://playground.babylonjs.com/#CGHTSM#1)
219
219
  * @see [WebGPU](https://playground.babylonjs.com/#CGHTSM#2)
220
220
  */
221
- export class PBRBaseMaterial extends PBRBaseMaterialBase {
222
- /* Realtime filtering system control */
223
- get systemRealTimeFiltering() {
224
- return this._systemRealTimeFiltering;
225
- }
226
- set systemRealTimeFiltering(value) {
227
- this._systemRealTimeFiltering = value;
228
- this.markAsDirty(1);
229
- }
230
- /**
231
- * Enables realtime filtering on the texture.
232
- */
233
- get realTimeFiltering() {
234
- return (this._realTimeFiltering ?? false) || !!this.systemRealTimeFiltering;
235
- }
236
- set realTimeFiltering(b) {
237
- this._realTimeFiltering = b;
238
- this.markAsDirty(1);
239
- }
240
- /**
241
- * Checks if the real-time filtering setting is explicitly set by the user.
242
- */
243
- get isUserSetRealTimeFiltering() {
244
- return typeof this._realTimeFiltering === "boolean";
245
- }
246
- /**
247
- * Quality switch for realtime filtering
248
- */
249
- get realTimeFilteringQuality() {
250
- return this._realTimeFilteringQuality;
251
- }
252
- set realTimeFilteringQuality(n) {
253
- this._realTimeFilteringQuality = n;
254
- this.markAsDirty(1);
255
- }
256
- /**
257
- * Checks if the real-time filtering quality has been set by the user.
258
- */
259
- get isUserSetRealTimeFilteringQuality() {
260
- return typeof this._realTimeFilteringQuality === "number";
261
- }
262
- /**
263
- * Can this material render to several textures at once
264
- */
265
- get canRenderToMRT() {
266
- return true;
267
- }
268
- /**
269
- * Instantiates a new PBRMaterial instance.
270
- *
271
- * @param name The material name
272
- * @param scene The scene the material will be use in.
273
- * @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
274
- */
275
- constructor(name, scene, forceGLSL = false) {
276
- super(name, scene, undefined, forceGLSL || PBRBaseMaterial.ForceGLSL);
277
- /**
278
- * Intensity of the direct lights e.g. the four lights available in your scene.
279
- * This impacts both the direct diffuse and specular highlights.
280
- * @internal
281
- */
282
- this._directIntensity = 1.0;
283
- /**
284
- * Intensity of the emissive part of the material.
285
- * This helps controlling the emissive effect without modifying the emissive color.
286
- * @internal
287
- */
288
- this._emissiveIntensity = 1.0;
289
- /**
290
- * Intensity of the environment e.g. how much the environment will light the object
291
- * either through harmonics for rough material or through the reflection for shiny ones.
292
- * @internal
293
- */
294
- this._environmentIntensity = 1.0;
295
- /**
296
- * This is a special control allowing the reduction of the specular highlights coming from the
297
- * four lights of the scene. Those highlights may not be needed in full environment lighting.
298
- * @internal
299
- */
300
- this._specularIntensity = 1.0;
301
- /**
302
- * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
303
- */
304
- this._lightingInfos = new Vector4(this._directIntensity, this._emissiveIntensity, this._environmentIntensity, this._specularIntensity);
305
- /**
306
- * Debug Control allowing disabling the bump map on this material.
307
- * @internal
308
- */
309
- this._disableBumpMap = false;
310
- /**
311
- * AKA Diffuse Texture in standard nomenclature.
312
- * @internal
313
- */
314
- this._albedoTexture = null;
315
- /**
316
- * Base Weight texture (multiplier to the diffuse and metal lobes).
317
- * @internal
318
- */
319
- this._baseWeightTexture = null;
320
- /**
321
- * Base Diffuse Roughness texture (roughness of the diffuse lobe).
322
- * @internal
323
- */
324
- this._baseDiffuseRoughnessTexture = null;
325
- /**
326
- * AKA Occlusion Texture in other nomenclature.
327
- * @internal
328
- */
329
- this._ambientTexture = null;
330
- /**
331
- * AKA Occlusion Texture Intensity in other nomenclature.
332
- * @internal
333
- */
334
- this._ambientTextureStrength = 1.0;
335
- /**
336
- * Defines how much the AO map is occluding the analytical lights (point spot...).
337
- * 1 means it completely occludes it
338
- * 0 mean it has no impact
339
- * @internal
340
- */
341
- this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
342
- /**
343
- * Stores the alpha values in a texture.
344
- * @internal
345
- */
346
- this._opacityTexture = null;
347
- /**
348
- * Stores the reflection values in a texture.
349
- * @internal
350
- */
351
- this._reflectionTexture = null;
352
- /**
353
- * Stores the emissive values in a texture.
354
- * @internal
355
- */
356
- this._emissiveTexture = null;
357
- /**
358
- * AKA Specular texture in other nomenclature.
359
- * @internal
360
- */
361
- this._reflectivityTexture = null;
362
- /**
363
- * Used to switch from specular/glossiness to metallic/roughness workflow.
364
- * @internal
365
- */
366
- this._metallicTexture = null;
367
- /**
368
- * Specifies the metallic scalar of the metallic/roughness workflow.
369
- * Can also be used to scale the metalness values of the metallic texture.
370
- * @internal
371
- */
372
- this._metallic = null;
373
- /**
374
- * Specifies the roughness scalar of the metallic/roughness workflow.
375
- * Can also be used to scale the roughness values of the metallic texture.
376
- * @internal
377
- */
378
- this._roughness = null;
379
- /**
380
- * In metallic workflow, specifies an F0 factor to help configuring the material F0.
381
- * By default the indexOfrefraction is used to compute F0;
382
- *
383
- * This is used as a factor against the default reflectance at normal incidence to tweak it.
384
- *
385
- * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
386
- * F90 = metallicReflectanceColor;
387
- * @internal
388
- */
389
- this._metallicF0Factor = 1;
390
- /**
391
- * In metallic workflow, specifies an F0 color.
392
- * By default the F90 is always 1;
393
- *
394
- * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
395
- *
396
- * F0 = defaultF0_from_IOR * metallicF0Factor * metallicReflectanceColor
397
- * F90 = metallicF0Factor;
398
- * @internal
399
- */
400
- this._metallicReflectanceColor = Color3.White();
401
- /**
402
- * Specifies that only the A channel from _metallicReflectanceTexture should be used.
403
- * If false, both RGB and A channels will be used
404
- * @internal
405
- */
406
- this._useOnlyMetallicFromMetallicReflectanceTexture = false;
407
- /**
408
- * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
409
- * This is multiply against the scalar values defined in the material.
410
- * @internal
411
- */
412
- this._metallicReflectanceTexture = null;
413
- /**
414
- * Defines to store reflectanceColor in RGB
415
- * This is multiplied against the scalar values defined in the material.
416
- * If both _reflectanceTexture and _metallicReflectanceTexture textures are provided and _useOnlyMetallicFromMetallicReflectanceTexture
417
- * is false, _metallicReflectanceTexture takes precedence and _reflectanceTexture is not used
418
- * @internal
419
- */
420
- this._reflectanceTexture = null;
421
- /**
422
- * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
423
- * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
424
- * @internal
425
- */
426
- this._microSurfaceTexture = null;
427
- /**
428
- * Stores surface normal data used to displace a mesh in a texture.
429
- * @internal
430
- */
431
- this._bumpTexture = null;
432
- /**
433
- * Stores the pre-calculated light information of a mesh in a texture.
434
- * @internal
435
- */
436
- this._lightmapTexture = null;
437
- /**
438
- * The color of a material in ambient lighting.
439
- * @internal
440
- */
441
- this._ambientColor = new Color3(0, 0, 0);
442
- /**
443
- * AKA Diffuse Color in other nomenclature.
444
- * @internal
445
- */
446
- this._albedoColor = new Color3(1, 1, 1);
447
- /**
448
- * Base Weight (multiplier to the diffuse and metal lobes).
449
- * @internal
450
- */
451
- this._baseWeight = 1;
452
- /**
453
- * Base Diffuse Roughness (roughness of the diffuse lobe).
454
- * Can also be used to scale the corresponding texture.
455
- * @internal
456
- */
457
- this._baseDiffuseRoughness = null;
458
- /**
459
- * AKA Specular Color in other nomenclature.
460
- * @internal
461
- */
462
- this._reflectivityColor = new Color3(1, 1, 1);
463
- /**
464
- * The color applied when light is reflected from a material.
465
- * @internal
466
- */
467
- this._reflectionColor = new Color3(1, 1, 1);
468
- /**
469
- * The color applied when light is emitted from a material.
470
- * @internal
471
- */
472
- this._emissiveColor = new Color3(0, 0, 0);
473
- /**
474
- * AKA Glossiness in other nomenclature.
475
- * @internal
476
- */
477
- this._microSurface = 0.9;
478
- /**
479
- * Specifies that the material will use the light map as a show map.
480
- * @internal
481
- */
482
- this._useLightmapAsShadowmap = false;
483
- /**
484
- * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
485
- * makes the reflect vector face the model (under horizon).
486
- * @internal
487
- */
488
- this._useHorizonOcclusion = true;
489
- /**
490
- * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
491
- * too much the area relying on ambient texture to define their ambient occlusion.
492
- * @internal
493
- */
494
- this._useRadianceOcclusion = true;
495
- /**
496
- * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
497
- * @internal
498
- */
499
- this._useAlphaFromAlbedoTexture = false;
500
- /**
501
- * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
502
- * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
503
- * @internal
504
- */
505
- this._useSpecularOverAlpha = true;
506
- /**
507
- * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
508
- * @internal
509
- */
510
- this._useMicroSurfaceFromReflectivityMapAlpha = false;
511
- /**
512
- * Specifies if the metallic texture contains the roughness information in its alpha channel.
513
- * @internal
514
- */
515
- this._useRoughnessFromMetallicTextureAlpha = true;
516
- /**
517
- * Specifies if the metallic texture contains the roughness information in its green channel.
518
- * @internal
519
- */
520
- this._useRoughnessFromMetallicTextureGreen = false;
521
- /**
522
- * Specifies if the metallic texture contains the metallness information in its blue channel.
523
- * @internal
524
- */
525
- this._useMetallnessFromMetallicTextureBlue = false;
526
- /**
527
- * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
528
- * @internal
529
- */
530
- this._useAmbientOcclusionFromMetallicTextureRed = false;
531
- /**
532
- * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
533
- * @internal
534
- */
535
- this._useAmbientInGrayScale = false;
536
- /**
537
- * In case the reflectivity map does not contain the microsurface information in its alpha channel,
538
- * The material will try to infer what glossiness each pixel should be.
539
- * @internal
540
- */
541
- this._useAutoMicroSurfaceFromReflectivityMap = false;
542
- /**
543
- * Defines the falloff type used in this material.
544
- * It by default is Physical.
545
- * @internal
546
- */
547
- this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
548
- /**
549
- * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
550
- * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
551
- * @internal
552
- */
553
- this._useRadianceOverAlpha = true;
554
- /**
555
- * Allows using an object space normal map (instead of tangent space).
556
- * @internal
557
- */
558
- this._useObjectSpaceNormalMap = false;
559
- /**
560
- * Allows using the bump map in parallax mode.
561
- * @internal
562
- */
563
- this._useParallax = false;
564
- /**
565
- * Allows using the bump map in parallax occlusion mode.
566
- * @internal
567
- */
568
- this._useParallaxOcclusion = false;
569
- /**
570
- * Controls the scale bias of the parallax mode.
571
- * @internal
572
- */
573
- this._parallaxScaleBias = 0.05;
574
- /**
575
- * If sets to true, disables all the lights affecting the material.
576
- * @internal
577
- */
578
- this._disableLighting = false;
579
- /**
580
- * Number of Simultaneous lights allowed on the material.
581
- * @internal
582
- */
583
- this._maxSimultaneousLights = 4;
584
- /**
585
- * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
586
- * @internal
587
- */
588
- this._invertNormalMapX = false;
589
- /**
590
- * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
591
- * @internal
592
- */
593
- this._invertNormalMapY = false;
594
- /**
595
- * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
596
- * @internal
597
- */
598
- this._twoSidedLighting = false;
599
- /**
600
- * Defines the alpha limits in alpha test mode.
601
- * @internal
602
- */
603
- this._alphaCutOff = 0.4;
604
- /**
605
- * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
606
- * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
607
- * @internal
608
- */
609
- this._useAlphaFresnel = false;
610
- /**
611
- * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
612
- * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
613
- * @internal
614
- */
615
- this._useLinearAlphaFresnel = false;
616
- /**
617
- * Specifies the environment BRDF texture used to compute the scale and offset roughness values
618
- * from cos theta and roughness:
619
- * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
620
- * @internal
621
- */
622
- this._environmentBRDFTexture = null;
623
- /**
624
- * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
625
- * @internal
626
- */
627
- this._forceIrradianceInFragment = false;
628
- this._systemRealTimeFiltering = undefined;
629
- this._realTimeFiltering = undefined;
630
- this._realTimeFilteringQuality = 8;
631
- /**
632
- * Force normal to face away from face.
633
- * @internal
634
- */
635
- this._forceNormalForward = false;
636
- /**
637
- * Enables specular anti aliasing in the PBR shader.
638
- * It will both interacts on the Geometry for analytical and IBL lighting.
639
- * It also prefilter the roughness map based on the bump values.
640
- * @internal
641
- */
642
- this._enableSpecularAntiAliasing = false;
643
- /**
644
- * Stores the available render targets.
645
- */
646
- this._renderTargets = new SmartArray(16);
647
- /**
648
- * Sets the global ambient color for the material used in lighting calculations.
649
- */
650
- this._globalAmbientColor = new Color3(0, 0, 0);
651
- /**
652
- * If set to true, no lighting calculations will be applied.
653
- * @internal
654
- */
655
- this._unlit = false;
656
- /**
657
- * If sets to true, the decal map will be applied after the detail map. Else, it is applied before (default: false)
658
- */
659
- this._applyDecalMapAfterDetailMap = false;
660
- this._debugMode = 0;
661
- this._shadersLoaded = false;
662
- this._breakShaderLoadedCheck = false;
663
- this._vertexPullingMetadata = null;
664
- /**
665
- * @internal
666
- * This is reserved for the inspector.
667
- * Defines the material debug mode.
668
- * It helps seeing only some components of the material while troubleshooting.
669
- */
670
- this.debugMode = 0;
671
- /**
672
- * @internal
673
- * This is reserved for the inspector.
674
- * Specify from where on screen the debug mode should start.
675
- * The value goes from -1 (full screen) to 1 (not visible)
676
- * It helps with side by side comparison against the final render
677
- * This defaults to -1
678
- */
679
- this.debugLimit = -1;
680
- /**
681
- * @internal
682
- * This is reserved for the inspector.
683
- * As the default viewing range might not be enough (if the ambient is really small for instance)
684
- * You can use the factor to better multiply the final value.
685
- */
686
- this.debugFactor = 1;
687
- this._cacheHasRenderTargetTextures = false;
688
- this.brdf = new PBRBRDFConfiguration(this);
689
- this.clearCoat = new PBRClearCoatConfiguration(this);
690
- this.iridescence = new PBRIridescenceConfiguration(this);
691
- this.anisotropy = new PBRAnisotropicConfiguration(this);
692
- this.sheen = new PBRSheenConfiguration(this);
693
- this.subSurface = new PBRSubSurfaceConfiguration(this);
694
- this.detailMap = new DetailMapConfiguration(this);
695
- // Setup the default processing configuration to the scene.
696
- this._attachImageProcessingConfiguration(null);
697
- this.getRenderTargetTextures = () => {
698
- this._renderTargets.reset();
699
- if (MaterialFlags.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
700
- this._renderTargets.push(this._reflectionTexture);
221
+ let PBRBaseMaterial = (() => {
222
+ var _a, _PBRBaseMaterial_debugMode_accessor_storage;
223
+ let _classSuper = PBRBaseMaterialBase;
224
+ let _debugMode_decorators;
225
+ let _debugMode_initializers = [];
226
+ let _debugMode_extraInitializers = [];
227
+ return _a = class PBRBaseMaterial extends _classSuper {
228
+ /* Realtime filtering system control */
229
+ get systemRealTimeFiltering() {
230
+ return this._systemRealTimeFiltering;
701
231
  }
702
- this._eventInfo.renderTargets = this._renderTargets;
703
- this._callbackPluginEventFillRenderTargetTextures(this._eventInfo);
704
- return this._renderTargets;
705
- };
706
- this._environmentBRDFTexture = GetEnvironmentBRDFTexture(this.getScene());
707
- this.prePassConfiguration = new PrePassConfiguration();
708
- }
709
- /**
710
- * Gets a boolean indicating that current material needs to register RTT
711
- */
712
- get hasRenderTargetTextures() {
713
- if (MaterialFlags.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
714
- return true;
715
- }
716
- return this._cacheHasRenderTargetTextures;
717
- }
718
- /**
719
- * Can this material render to prepass
720
- */
721
- get isPrePassCapable() {
722
- return !this.disableDepthWrite;
723
- }
724
- /**
725
- * @returns the name of the material class.
726
- */
727
- getClassName() {
728
- return "PBRBaseMaterial";
729
- }
730
- /**
731
- * Returns true if alpha blending should be disabled.
732
- */
733
- get _disableAlphaBlending() {
734
- return (this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
735
- this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST ||
736
- this.subSurface?.disableAlphaBlending);
737
- }
738
- /**
739
- * @returns whether or not this material should be rendered in alpha blend mode.
740
- */
741
- needAlphaBlending() {
742
- if (this._hasTransparencyMode) {
743
- return this._transparencyModeIsBlend;
744
- }
745
- if (this._disableAlphaBlending) {
746
- return false;
747
- }
748
- return this.alpha < 1.0 || this._opacityTexture != null || this._shouldUseAlphaFromAlbedoTexture();
749
- }
750
- /**
751
- * @returns whether or not this material should be rendered in alpha test mode.
752
- */
753
- needAlphaTesting() {
754
- if (this._hasTransparencyMode) {
755
- return this._transparencyModeIsTest;
756
- }
757
- if (this.subSurface?.disableAlphaBlending) {
758
- return false;
759
- }
760
- return this._hasAlphaChannel() && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
761
- }
762
- /**
763
- * @returns whether or not the alpha value of the albedo texture should be used for alpha blending.
764
- */
765
- _shouldUseAlphaFromAlbedoTexture() {
766
- return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
767
- }
768
- /**
769
- * @returns whether or not there is a usable alpha channel for transparency.
770
- */
771
- _hasAlphaChannel() {
772
- return (this._albedoTexture != null && this._albedoTexture.hasAlpha) || this._opacityTexture != null;
773
- }
774
- /**
775
- * @returns the texture used for the alpha test.
776
- */
777
- getAlphaTestTexture() {
778
- return this._albedoTexture;
779
- }
780
- /**
781
- * Specifies that the submesh is ready to be used.
782
- * @param mesh - BJS mesh.
783
- * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
784
- * @param useInstances - Specifies that instances should be used.
785
- * @returns - boolean indicating that the submesh is ready or not.
786
- */
787
- isReadyForSubMesh(mesh, subMesh, useInstances) {
788
- if (!this._uniformBufferLayoutBuilt) {
789
- this.buildUniformLayout();
790
- }
791
- const drawWrapper = subMesh._drawWrapper;
792
- if (drawWrapper.effect && this.isFrozen) {
793
- if (drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {
232
+ set systemRealTimeFiltering(value) {
233
+ this._systemRealTimeFiltering = value;
234
+ this.markAsDirty(1);
235
+ }
236
+ /**
237
+ * Enables realtime filtering on the texture.
238
+ */
239
+ get realTimeFiltering() {
240
+ return (this._realTimeFiltering ?? false) || !!this.systemRealTimeFiltering;
241
+ }
242
+ set realTimeFiltering(b) {
243
+ this._realTimeFiltering = b;
244
+ this.markAsDirty(1);
245
+ }
246
+ /**
247
+ * Checks if the real-time filtering setting is explicitly set by the user.
248
+ */
249
+ get isUserSetRealTimeFiltering() {
250
+ return typeof this._realTimeFiltering === "boolean";
251
+ }
252
+ /**
253
+ * Quality switch for realtime filtering
254
+ */
255
+ get realTimeFilteringQuality() {
256
+ return this._realTimeFilteringQuality;
257
+ }
258
+ set realTimeFilteringQuality(n) {
259
+ this._realTimeFilteringQuality = n;
260
+ this.markAsDirty(1);
261
+ }
262
+ /**
263
+ * Checks if the real-time filtering quality has been set by the user.
264
+ */
265
+ get isUserSetRealTimeFilteringQuality() {
266
+ return typeof this._realTimeFilteringQuality === "number";
267
+ }
268
+ /**
269
+ * Can this material render to several textures at once
270
+ */
271
+ get canRenderToMRT() {
794
272
  return true;
795
273
  }
796
- }
797
- if (!subMesh.materialDefines) {
798
- this._callbackPluginEventGeneric(4 /* MaterialPluginEvent.GetDefineNames */, this._eventInfo);
799
- subMesh.materialDefines = new PBRMaterialDefines(this._eventInfo.defineNames);
800
- }
801
- const defines = subMesh.materialDefines;
802
- if (this._isReadyForSubMesh(subMesh)) {
803
- return true;
804
- }
805
- const scene = this.getScene();
806
- const engine = scene.getEngine();
807
- if (defines._areTexturesDirty) {
808
- this._eventInfo.hasRenderTargetTextures = false;
809
- this._callbackPluginEventHasRenderTargetTextures(this._eventInfo);
810
- this._cacheHasRenderTargetTextures = this._eventInfo.hasRenderTargetTextures;
811
- if (scene.texturesEnabled) {
812
- if (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled) {
813
- if (!this._albedoTexture.isReadyOrNotBlocking()) {
814
- return false;
274
+ /**
275
+ * @internal
276
+ * This is reserved for the inspector.
277
+ * Defines the material debug mode.
278
+ * It helps seeing only some components of the material while troubleshooting.
279
+ */
280
+ get debugMode() { return __classPrivateFieldGet(this, _PBRBaseMaterial_debugMode_accessor_storage, "f"); }
281
+ set debugMode(value) { __classPrivateFieldSet(this, _PBRBaseMaterial_debugMode_accessor_storage, value, "f"); }
282
+ /**
283
+ * Instantiates a new PBRMaterial instance.
284
+ *
285
+ * @param name The material name
286
+ * @param scene The scene the material will be use in.
287
+ * @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
288
+ */
289
+ constructor(name, scene, forceGLSL = false) {
290
+ super(name, scene, undefined, forceGLSL || _a.ForceGLSL);
291
+ /**
292
+ * Intensity of the direct lights e.g. the four lights available in your scene.
293
+ * This impacts both the direct diffuse and specular highlights.
294
+ * @internal
295
+ */
296
+ this._directIntensity = 1.0;
297
+ /**
298
+ * Intensity of the emissive part of the material.
299
+ * This helps controlling the emissive effect without modifying the emissive color.
300
+ * @internal
301
+ */
302
+ this._emissiveIntensity = 1.0;
303
+ /**
304
+ * Intensity of the environment e.g. how much the environment will light the object
305
+ * either through harmonics for rough material or through the reflection for shiny ones.
306
+ * @internal
307
+ */
308
+ this._environmentIntensity = 1.0;
309
+ /**
310
+ * This is a special control allowing the reduction of the specular highlights coming from the
311
+ * four lights of the scene. Those highlights may not be needed in full environment lighting.
312
+ * @internal
313
+ */
314
+ this._specularIntensity = 1.0;
315
+ /**
316
+ * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
317
+ */
318
+ this._lightingInfos = new Vector4(this._directIntensity, this._emissiveIntensity, this._environmentIntensity, this._specularIntensity);
319
+ /**
320
+ * Debug Control allowing disabling the bump map on this material.
321
+ * @internal
322
+ */
323
+ this._disableBumpMap = false;
324
+ /**
325
+ * AKA Diffuse Texture in standard nomenclature.
326
+ * @internal
327
+ */
328
+ this._albedoTexture = null;
329
+ /**
330
+ * Base Weight texture (multiplier to the diffuse and metal lobes).
331
+ * @internal
332
+ */
333
+ this._baseWeightTexture = null;
334
+ /**
335
+ * Base Diffuse Roughness texture (roughness of the diffuse lobe).
336
+ * @internal
337
+ */
338
+ this._baseDiffuseRoughnessTexture = null;
339
+ /**
340
+ * AKA Occlusion Texture in other nomenclature.
341
+ * @internal
342
+ */
343
+ this._ambientTexture = null;
344
+ /**
345
+ * AKA Occlusion Texture Intensity in other nomenclature.
346
+ * @internal
347
+ */
348
+ this._ambientTextureStrength = 1.0;
349
+ /**
350
+ * Defines how much the AO map is occluding the analytical lights (point spot...).
351
+ * 1 means it completely occludes it
352
+ * 0 mean it has no impact
353
+ * @internal
354
+ */
355
+ this._ambientTextureImpactOnAnalyticalLights = _a.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
356
+ /**
357
+ * Stores the alpha values in a texture.
358
+ * @internal
359
+ */
360
+ this._opacityTexture = null;
361
+ /**
362
+ * Stores the reflection values in a texture.
363
+ * @internal
364
+ */
365
+ this._reflectionTexture = null;
366
+ /**
367
+ * Stores the emissive values in a texture.
368
+ * @internal
369
+ */
370
+ this._emissiveTexture = null;
371
+ /**
372
+ * AKA Specular texture in other nomenclature.
373
+ * @internal
374
+ */
375
+ this._reflectivityTexture = null;
376
+ /**
377
+ * Used to switch from specular/glossiness to metallic/roughness workflow.
378
+ * @internal
379
+ */
380
+ this._metallicTexture = null;
381
+ /**
382
+ * Specifies the metallic scalar of the metallic/roughness workflow.
383
+ * Can also be used to scale the metalness values of the metallic texture.
384
+ * @internal
385
+ */
386
+ this._metallic = null;
387
+ /**
388
+ * Specifies the roughness scalar of the metallic/roughness workflow.
389
+ * Can also be used to scale the roughness values of the metallic texture.
390
+ * @internal
391
+ */
392
+ this._roughness = null;
393
+ /**
394
+ * In metallic workflow, specifies an F0 factor to help configuring the material F0.
395
+ * By default the indexOfrefraction is used to compute F0;
396
+ *
397
+ * This is used as a factor against the default reflectance at normal incidence to tweak it.
398
+ *
399
+ * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
400
+ * F90 = metallicReflectanceColor;
401
+ * @internal
402
+ */
403
+ this._metallicF0Factor = 1;
404
+ /**
405
+ * In metallic workflow, specifies an F0 color.
406
+ * By default the F90 is always 1;
407
+ *
408
+ * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
409
+ *
410
+ * F0 = defaultF0_from_IOR * metallicF0Factor * metallicReflectanceColor
411
+ * F90 = metallicF0Factor;
412
+ * @internal
413
+ */
414
+ this._metallicReflectanceColor = Color3.White();
415
+ /**
416
+ * Specifies that only the A channel from _metallicReflectanceTexture should be used.
417
+ * If false, both RGB and A channels will be used
418
+ * @internal
419
+ */
420
+ this._useOnlyMetallicFromMetallicReflectanceTexture = false;
421
+ /**
422
+ * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
423
+ * This is multiply against the scalar values defined in the material.
424
+ * @internal
425
+ */
426
+ this._metallicReflectanceTexture = null;
427
+ /**
428
+ * Defines to store reflectanceColor in RGB
429
+ * This is multiplied against the scalar values defined in the material.
430
+ * If both _reflectanceTexture and _metallicReflectanceTexture textures are provided and _useOnlyMetallicFromMetallicReflectanceTexture
431
+ * is false, _metallicReflectanceTexture takes precedence and _reflectanceTexture is not used
432
+ * @internal
433
+ */
434
+ this._reflectanceTexture = null;
435
+ /**
436
+ * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
437
+ * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
438
+ * @internal
439
+ */
440
+ this._microSurfaceTexture = null;
441
+ /**
442
+ * Stores surface normal data used to displace a mesh in a texture.
443
+ * @internal
444
+ */
445
+ this._bumpTexture = null;
446
+ /**
447
+ * Stores the pre-calculated light information of a mesh in a texture.
448
+ * @internal
449
+ */
450
+ this._lightmapTexture = null;
451
+ /**
452
+ * The color of a material in ambient lighting.
453
+ * @internal
454
+ */
455
+ this._ambientColor = new Color3(0, 0, 0);
456
+ /**
457
+ * AKA Diffuse Color in other nomenclature.
458
+ * @internal
459
+ */
460
+ this._albedoColor = new Color3(1, 1, 1);
461
+ /**
462
+ * Base Weight (multiplier to the diffuse and metal lobes).
463
+ * @internal
464
+ */
465
+ this._baseWeight = 1;
466
+ /**
467
+ * Base Diffuse Roughness (roughness of the diffuse lobe).
468
+ * Can also be used to scale the corresponding texture.
469
+ * @internal
470
+ */
471
+ this._baseDiffuseRoughness = null;
472
+ /**
473
+ * AKA Specular Color in other nomenclature.
474
+ * @internal
475
+ */
476
+ this._reflectivityColor = new Color3(1, 1, 1);
477
+ /**
478
+ * The color applied when light is reflected from a material.
479
+ * @internal
480
+ */
481
+ this._reflectionColor = new Color3(1, 1, 1);
482
+ /**
483
+ * The color applied when light is emitted from a material.
484
+ * @internal
485
+ */
486
+ this._emissiveColor = new Color3(0, 0, 0);
487
+ /**
488
+ * AKA Glossiness in other nomenclature.
489
+ * @internal
490
+ */
491
+ this._microSurface = 0.9;
492
+ /**
493
+ * Specifies that the material will use the light map as a show map.
494
+ * @internal
495
+ */
496
+ this._useLightmapAsShadowmap = false;
497
+ /**
498
+ * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
499
+ * makes the reflect vector face the model (under horizon).
500
+ * @internal
501
+ */
502
+ this._useHorizonOcclusion = true;
503
+ /**
504
+ * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
505
+ * too much the area relying on ambient texture to define their ambient occlusion.
506
+ * @internal
507
+ */
508
+ this._useRadianceOcclusion = true;
509
+ /**
510
+ * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
511
+ * @internal
512
+ */
513
+ this._useAlphaFromAlbedoTexture = false;
514
+ /**
515
+ * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
516
+ * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
517
+ * @internal
518
+ */
519
+ this._useSpecularOverAlpha = true;
520
+ /**
521
+ * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
522
+ * @internal
523
+ */
524
+ this._useMicroSurfaceFromReflectivityMapAlpha = false;
525
+ /**
526
+ * Specifies if the metallic texture contains the roughness information in its alpha channel.
527
+ * @internal
528
+ */
529
+ this._useRoughnessFromMetallicTextureAlpha = true;
530
+ /**
531
+ * Specifies if the metallic texture contains the roughness information in its green channel.
532
+ * @internal
533
+ */
534
+ this._useRoughnessFromMetallicTextureGreen = false;
535
+ /**
536
+ * Specifies if the metallic texture contains the metallness information in its blue channel.
537
+ * @internal
538
+ */
539
+ this._useMetallnessFromMetallicTextureBlue = false;
540
+ /**
541
+ * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
542
+ * @internal
543
+ */
544
+ this._useAmbientOcclusionFromMetallicTextureRed = false;
545
+ /**
546
+ * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
547
+ * @internal
548
+ */
549
+ this._useAmbientInGrayScale = false;
550
+ /**
551
+ * In case the reflectivity map does not contain the microsurface information in its alpha channel,
552
+ * The material will try to infer what glossiness each pixel should be.
553
+ * @internal
554
+ */
555
+ this._useAutoMicroSurfaceFromReflectivityMap = false;
556
+ /**
557
+ * Defines the falloff type used in this material.
558
+ * It by default is Physical.
559
+ * @internal
560
+ */
561
+ this._lightFalloff = _a.LIGHTFALLOFF_PHYSICAL;
562
+ /**
563
+ * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
564
+ * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
565
+ * @internal
566
+ */
567
+ this._useRadianceOverAlpha = true;
568
+ /**
569
+ * Allows using an object space normal map (instead of tangent space).
570
+ * @internal
571
+ */
572
+ this._useObjectSpaceNormalMap = false;
573
+ /**
574
+ * Allows using the bump map in parallax mode.
575
+ * @internal
576
+ */
577
+ this._useParallax = false;
578
+ /**
579
+ * Allows using the bump map in parallax occlusion mode.
580
+ * @internal
581
+ */
582
+ this._useParallaxOcclusion = false;
583
+ /**
584
+ * Controls the scale bias of the parallax mode.
585
+ * @internal
586
+ */
587
+ this._parallaxScaleBias = 0.05;
588
+ /**
589
+ * If sets to true, disables all the lights affecting the material.
590
+ * @internal
591
+ */
592
+ this._disableLighting = false;
593
+ /**
594
+ * Number of Simultaneous lights allowed on the material.
595
+ * @internal
596
+ */
597
+ this._maxSimultaneousLights = 4;
598
+ /**
599
+ * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
600
+ * @internal
601
+ */
602
+ this._invertNormalMapX = false;
603
+ /**
604
+ * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
605
+ * @internal
606
+ */
607
+ this._invertNormalMapY = false;
608
+ /**
609
+ * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
610
+ * @internal
611
+ */
612
+ this._twoSidedLighting = false;
613
+ /**
614
+ * Defines the alpha limits in alpha test mode.
615
+ * @internal
616
+ */
617
+ this._alphaCutOff = 0.4;
618
+ /**
619
+ * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
620
+ * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
621
+ * @internal
622
+ */
623
+ this._useAlphaFresnel = false;
624
+ /**
625
+ * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
626
+ * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
627
+ * @internal
628
+ */
629
+ this._useLinearAlphaFresnel = false;
630
+ /**
631
+ * Specifies the environment BRDF texture used to compute the scale and offset roughness values
632
+ * from cos theta and roughness:
633
+ * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
634
+ * @internal
635
+ */
636
+ this._environmentBRDFTexture = null;
637
+ /**
638
+ * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
639
+ * @internal
640
+ */
641
+ this._forceIrradianceInFragment = false;
642
+ this._systemRealTimeFiltering = undefined;
643
+ this._realTimeFiltering = undefined;
644
+ this._realTimeFilteringQuality = 8;
645
+ /**
646
+ * Force normal to face away from face.
647
+ * @internal
648
+ */
649
+ this._forceNormalForward = false;
650
+ /**
651
+ * Enables specular anti aliasing in the PBR shader.
652
+ * It will both interacts on the Geometry for analytical and IBL lighting.
653
+ * It also prefilter the roughness map based on the bump values.
654
+ * @internal
655
+ */
656
+ this._enableSpecularAntiAliasing = false;
657
+ /**
658
+ * Stores the available render targets.
659
+ */
660
+ this._renderTargets = new SmartArray(16);
661
+ /**
662
+ * Sets the global ambient color for the material used in lighting calculations.
663
+ */
664
+ this._globalAmbientColor = new Color3(0, 0, 0);
665
+ /**
666
+ * If set to true, no lighting calculations will be applied.
667
+ * @internal
668
+ */
669
+ this._unlit = false;
670
+ /**
671
+ * If sets to true, the decal map will be applied after the detail map. Else, it is applied before (default: false)
672
+ */
673
+ this._applyDecalMapAfterDetailMap = false;
674
+ this._debugMode = 0;
675
+ this._shadersLoaded = false;
676
+ this._breakShaderLoadedCheck = false;
677
+ this._vertexPullingMetadata = null;
678
+ _PBRBaseMaterial_debugMode_accessor_storage.set(this, __runInitializers(this, _debugMode_initializers, 0));
679
+ /**
680
+ * @internal
681
+ * This is reserved for the inspector.
682
+ * Specify from where on screen the debug mode should start.
683
+ * The value goes from -1 (full screen) to 1 (not visible)
684
+ * It helps with side by side comparison against the final render
685
+ * This defaults to -1
686
+ */
687
+ this.debugLimit = (__runInitializers(this, _debugMode_extraInitializers), -1);
688
+ /**
689
+ * @internal
690
+ * This is reserved for the inspector.
691
+ * As the default viewing range might not be enough (if the ambient is really small for instance)
692
+ * You can use the factor to better multiply the final value.
693
+ */
694
+ this.debugFactor = 1;
695
+ this._cacheHasRenderTargetTextures = false;
696
+ this.brdf = new PBRBRDFConfiguration(this);
697
+ this.clearCoat = new PBRClearCoatConfiguration(this);
698
+ this.iridescence = new PBRIridescenceConfiguration(this);
699
+ this.anisotropy = new PBRAnisotropicConfiguration(this);
700
+ this.sheen = new PBRSheenConfiguration(this);
701
+ this.subSurface = new PBRSubSurfaceConfiguration(this);
702
+ this.detailMap = new DetailMapConfiguration(this);
703
+ // Setup the default processing configuration to the scene.
704
+ this._attachImageProcessingConfiguration(null);
705
+ this.getRenderTargetTextures = () => {
706
+ this._renderTargets.reset();
707
+ if (MaterialFlags.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
708
+ this._renderTargets.push(this._reflectionTexture);
815
709
  }
710
+ this._eventInfo.renderTargets = this._renderTargets;
711
+ this._callbackPluginEventFillRenderTargetTextures(this._eventInfo);
712
+ return this._renderTargets;
713
+ };
714
+ this._environmentBRDFTexture = GetEnvironmentBRDFTexture(this.getScene());
715
+ this.prePassConfiguration = new PrePassConfiguration();
716
+ }
717
+ /**
718
+ * Gets a boolean indicating that current material needs to register RTT
719
+ */
720
+ get hasRenderTargetTextures() {
721
+ if (MaterialFlags.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
722
+ return true;
816
723
  }
817
- if (this._baseWeightTexture && MaterialFlags.BaseWeightTextureEnabled) {
818
- if (!this._baseWeightTexture.isReadyOrNotBlocking()) {
819
- return false;
820
- }
724
+ return this._cacheHasRenderTargetTextures;
725
+ }
726
+ /**
727
+ * Can this material render to prepass
728
+ */
729
+ get isPrePassCapable() {
730
+ return !this.disableDepthWrite;
731
+ }
732
+ /**
733
+ * @returns the name of the material class.
734
+ */
735
+ getClassName() {
736
+ return "PBRBaseMaterial";
737
+ }
738
+ /**
739
+ * Returns true if alpha blending should be disabled.
740
+ */
741
+ get _disableAlphaBlending() {
742
+ return (this._transparencyMode === _a.PBRMATERIAL_OPAQUE ||
743
+ this._transparencyMode === _a.PBRMATERIAL_ALPHATEST ||
744
+ this.subSurface?.disableAlphaBlending);
745
+ }
746
+ /**
747
+ * @returns whether or not this material should be rendered in alpha blend mode.
748
+ */
749
+ needAlphaBlending() {
750
+ if (this._hasTransparencyMode) {
751
+ return this._transparencyModeIsBlend;
821
752
  }
822
- if (this._baseDiffuseRoughnessTexture && MaterialFlags.BaseDiffuseRoughnessTextureEnabled) {
823
- if (!this._baseDiffuseRoughnessTexture.isReadyOrNotBlocking()) {
824
- return false;
825
- }
753
+ if (this._disableAlphaBlending) {
754
+ return false;
826
755
  }
827
- if (this._ambientTexture && MaterialFlags.AmbientTextureEnabled) {
828
- if (!this._ambientTexture.isReadyOrNotBlocking()) {
829
- return false;
830
- }
756
+ return this.alpha < 1.0 || this._opacityTexture != null || this._shouldUseAlphaFromAlbedoTexture();
757
+ }
758
+ /**
759
+ * @returns whether or not this material should be rendered in alpha test mode.
760
+ */
761
+ needAlphaTesting() {
762
+ if (this._hasTransparencyMode) {
763
+ return this._transparencyModeIsTest;
831
764
  }
832
- if (this._opacityTexture && MaterialFlags.OpacityTextureEnabled) {
833
- if (!this._opacityTexture.isReadyOrNotBlocking()) {
834
- return false;
835
- }
765
+ if (this.subSurface?.disableAlphaBlending) {
766
+ return false;
836
767
  }
837
- const reflectionTexture = this._getReflectionTexture();
838
- if (reflectionTexture && MaterialFlags.ReflectionTextureEnabled) {
839
- if (!reflectionTexture.isReadyOrNotBlocking()) {
840
- return false;
768
+ return this._hasAlphaChannel() && (this._transparencyMode == null || this._transparencyMode === _a.PBRMATERIAL_ALPHATEST);
769
+ }
770
+ /**
771
+ * @returns whether or not the alpha value of the albedo texture should be used for alpha blending.
772
+ */
773
+ _shouldUseAlphaFromAlbedoTexture() {
774
+ return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== _a.PBRMATERIAL_OPAQUE;
775
+ }
776
+ /**
777
+ * @returns whether or not there is a usable alpha channel for transparency.
778
+ */
779
+ _hasAlphaChannel() {
780
+ return (this._albedoTexture != null && this._albedoTexture.hasAlpha) || this._opacityTexture != null;
781
+ }
782
+ /**
783
+ * @returns the texture used for the alpha test.
784
+ */
785
+ getAlphaTestTexture() {
786
+ return this._albedoTexture;
787
+ }
788
+ /**
789
+ * Specifies that the submesh is ready to be used.
790
+ * @param mesh - BJS mesh.
791
+ * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
792
+ * @param useInstances - Specifies that instances should be used.
793
+ * @returns - boolean indicating that the submesh is ready or not.
794
+ */
795
+ isReadyForSubMesh(mesh, subMesh, useInstances) {
796
+ if (!this._uniformBufferLayoutBuilt) {
797
+ this.buildUniformLayout();
798
+ }
799
+ const drawWrapper = subMesh._drawWrapper;
800
+ if (drawWrapper.effect && this.isFrozen) {
801
+ if (drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {
802
+ return true;
841
803
  }
842
- if (reflectionTexture.irradianceTexture) {
843
- if (!reflectionTexture.irradianceTexture.isReadyOrNotBlocking()) {
844
- return false;
804
+ }
805
+ if (!subMesh.materialDefines) {
806
+ this._callbackPluginEventGeneric(4 /* MaterialPluginEvent.GetDefineNames */, this._eventInfo);
807
+ subMesh.materialDefines = new PBRMaterialDefines(this._eventInfo.defineNames);
808
+ }
809
+ const defines = subMesh.materialDefines;
810
+ if (this._isReadyForSubMesh(subMesh)) {
811
+ return true;
812
+ }
813
+ const scene = this.getScene();
814
+ const engine = scene.getEngine();
815
+ if (defines._areTexturesDirty) {
816
+ this._eventInfo.hasRenderTargetTextures = false;
817
+ this._callbackPluginEventHasRenderTargetTextures(this._eventInfo);
818
+ this._cacheHasRenderTargetTextures = this._eventInfo.hasRenderTargetTextures;
819
+ if (scene.texturesEnabled) {
820
+ if (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled) {
821
+ if (!this._albedoTexture.isReadyOrNotBlocking()) {
822
+ return false;
823
+ }
845
824
  }
846
- }
847
- else {
848
- // Not ready until spherical are ready too.
849
- if (!reflectionTexture.sphericalPolynomial && reflectionTexture.getInternalTexture()?._sphericalPolynomialPromise) {
850
- return false;
825
+ if (this._baseWeightTexture && MaterialFlags.BaseWeightTextureEnabled) {
826
+ if (!this._baseWeightTexture.isReadyOrNotBlocking()) {
827
+ return false;
828
+ }
829
+ }
830
+ if (this._baseDiffuseRoughnessTexture && MaterialFlags.BaseDiffuseRoughnessTextureEnabled) {
831
+ if (!this._baseDiffuseRoughnessTexture.isReadyOrNotBlocking()) {
832
+ return false;
833
+ }
834
+ }
835
+ if (this._ambientTexture && MaterialFlags.AmbientTextureEnabled) {
836
+ if (!this._ambientTexture.isReadyOrNotBlocking()) {
837
+ return false;
838
+ }
839
+ }
840
+ if (this._opacityTexture && MaterialFlags.OpacityTextureEnabled) {
841
+ if (!this._opacityTexture.isReadyOrNotBlocking()) {
842
+ return false;
843
+ }
844
+ }
845
+ const reflectionTexture = this._getReflectionTexture();
846
+ if (reflectionTexture && MaterialFlags.ReflectionTextureEnabled) {
847
+ if (!reflectionTexture.isReadyOrNotBlocking()) {
848
+ return false;
849
+ }
850
+ if (reflectionTexture.irradianceTexture) {
851
+ if (!reflectionTexture.irradianceTexture.isReadyOrNotBlocking()) {
852
+ return false;
853
+ }
854
+ }
855
+ else {
856
+ // Not ready until spherical are ready too.
857
+ if (!reflectionTexture.sphericalPolynomial && reflectionTexture.getInternalTexture()?._sphericalPolynomialPromise) {
858
+ return false;
859
+ }
860
+ }
861
+ }
862
+ if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled) {
863
+ if (!this._lightmapTexture.isReadyOrNotBlocking()) {
864
+ return false;
865
+ }
866
+ }
867
+ if (this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled) {
868
+ if (!this._emissiveTexture.isReadyOrNotBlocking()) {
869
+ return false;
870
+ }
871
+ }
872
+ if (MaterialFlags.SpecularTextureEnabled) {
873
+ if (this._metallicTexture) {
874
+ if (!this._metallicTexture.isReadyOrNotBlocking()) {
875
+ return false;
876
+ }
877
+ }
878
+ else if (this._reflectivityTexture) {
879
+ if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
880
+ return false;
881
+ }
882
+ }
883
+ if (this._metallicReflectanceTexture) {
884
+ if (!this._metallicReflectanceTexture.isReadyOrNotBlocking()) {
885
+ return false;
886
+ }
887
+ }
888
+ if (this._reflectanceTexture) {
889
+ if (!this._reflectanceTexture.isReadyOrNotBlocking()) {
890
+ return false;
891
+ }
892
+ }
893
+ if (this._microSurfaceTexture) {
894
+ if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
895
+ return false;
896
+ }
897
+ }
898
+ }
899
+ if (engine.getCaps().standardDerivatives && this._bumpTexture && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap) {
900
+ // Bump texture cannot be not blocking.
901
+ if (!this._bumpTexture.isReady()) {
902
+ return false;
903
+ }
904
+ }
905
+ if (this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled) {
906
+ // This is blocking.
907
+ if (!this._environmentBRDFTexture.isReady()) {
908
+ return false;
909
+ }
851
910
  }
852
911
  }
853
912
  }
854
- if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled) {
855
- if (!this._lightmapTexture.isReadyOrNotBlocking()) {
856
- return false;
857
- }
913
+ this._eventInfo.isReadyForSubMesh = true;
914
+ this._eventInfo.defines = defines;
915
+ this._eventInfo.subMesh = subMesh;
916
+ this._callbackPluginEventIsReadyForSubMesh(this._eventInfo);
917
+ if (!this._eventInfo.isReadyForSubMesh) {
918
+ return false;
858
919
  }
859
- if (this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled) {
860
- if (!this._emissiveTexture.isReadyOrNotBlocking()) {
920
+ if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
921
+ if (!this._imageProcessingConfiguration.isReady()) {
861
922
  return false;
862
923
  }
863
924
  }
864
- if (MaterialFlags.SpecularTextureEnabled) {
865
- if (this._metallicTexture) {
866
- if (!this._metallicTexture.isReadyOrNotBlocking()) {
925
+ // Check if Area Lights have LTC texture.
926
+ if (defines["AREALIGHTUSED"] || defines["CLUSTLIGHT_BATCH"]) {
927
+ for (let index = 0; index < mesh.lightSources.length; index++) {
928
+ if (!mesh.lightSources[index]._isReady()) {
867
929
  return false;
868
930
  }
869
931
  }
870
- else if (this._reflectivityTexture) {
871
- if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
872
- return false;
873
- }
874
- }
875
- if (this._metallicReflectanceTexture) {
876
- if (!this._metallicReflectanceTexture.isReadyOrNotBlocking()) {
877
- return false;
878
- }
879
- }
880
- if (this._reflectanceTexture) {
881
- if (!this._reflectanceTexture.isReadyOrNotBlocking()) {
882
- return false;
883
- }
932
+ }
933
+ if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {
934
+ mesh.createNormals(true);
935
+ Logger.Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
936
+ }
937
+ if (!AreLightsTexturesReady(scene, mesh, this._maxSimultaneousLights, this._disableLighting)) {
938
+ return false;
939
+ }
940
+ const previousEffect = subMesh.effect;
941
+ const lightDisposed = defines._areLightsDisposed;
942
+ const effect = this._prepareEffect(mesh, subMesh.getRenderingMesh(), defines, this.onCompiled, this.onError, useInstances, null);
943
+ let forceWasNotReadyPreviously = false;
944
+ if (effect) {
945
+ if (this._onEffectCreatedObservable) {
946
+ onCreatedEffectParameters.effect = effect;
947
+ onCreatedEffectParameters.subMesh = subMesh;
948
+ this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters);
884
949
  }
885
- if (this._microSurfaceTexture) {
886
- if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
950
+ // Use previous effect while new one is compiling
951
+ if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
952
+ defines.markAsUnprocessed();
953
+ forceWasNotReadyPreviously = this.isFrozen;
954
+ if (lightDisposed) {
955
+ // re register in case it takes more than one frame.
956
+ defines._areLightsDisposed = true;
887
957
  return false;
888
958
  }
889
959
  }
890
- }
891
- if (engine.getCaps().standardDerivatives && this._bumpTexture && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap) {
892
- // Bump texture cannot be not blocking.
893
- if (!this._bumpTexture.isReady()) {
894
- return false;
960
+ else {
961
+ scene.resetCachedMaterial();
962
+ subMesh.setEffect(effect, defines, this._materialContext);
895
963
  }
896
964
  }
897
- if (this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled) {
898
- // This is blocking.
899
- if (!this._environmentBRDFTexture.isReady()) {
900
- return false;
901
- }
965
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
966
+ return false;
902
967
  }
968
+ defines._renderId = scene.getRenderId();
969
+ drawWrapper._wasPreviouslyReady = forceWasNotReadyPreviously ? false : true;
970
+ drawWrapper._wasPreviouslyUsingInstances = !!useInstances;
971
+ this._checkScenePerformancePriority();
972
+ return true;
903
973
  }
904
- }
905
- this._eventInfo.isReadyForSubMesh = true;
906
- this._eventInfo.defines = defines;
907
- this._eventInfo.subMesh = subMesh;
908
- this._callbackPluginEventIsReadyForSubMesh(this._eventInfo);
909
- if (!this._eventInfo.isReadyForSubMesh) {
910
- return false;
911
- }
912
- if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
913
- if (!this._imageProcessingConfiguration.isReady()) {
974
+ /**
975
+ * Specifies if the material uses metallic roughness workflow.
976
+ * @returns boolean specifying if the material uses metallic roughness workflow.
977
+ */
978
+ isMetallicWorkflow() {
979
+ if (this._metallic != null || this._roughness != null || this._metallicTexture) {
980
+ return true;
981
+ }
914
982
  return false;
915
983
  }
916
- }
917
- // Check if Area Lights have LTC texture.
918
- if (defines["AREALIGHTUSED"] || defines["CLUSTLIGHT_BATCH"]) {
919
- for (let index = 0; index < mesh.lightSources.length; index++) {
920
- if (!mesh.lightSources[index]._isReady()) {
921
- return false;
984
+ _prepareEffect(mesh, renderingMesh, defines, onCompiled = null, onError = null, useInstances = null, useClipPlane = null) {
985
+ this._prepareDefines(mesh, renderingMesh, defines, useInstances, useClipPlane);
986
+ if (!defines.isDirty) {
987
+ return null;
922
988
  }
923
- }
924
- }
925
- if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {
926
- mesh.createNormals(true);
927
- Logger.Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
928
- }
929
- if (!AreLightsTexturesReady(scene, mesh, this._maxSimultaneousLights, this._disableLighting)) {
930
- return false;
931
- }
932
- const previousEffect = subMesh.effect;
933
- const lightDisposed = defines._areLightsDisposed;
934
- const effect = this._prepareEffect(mesh, subMesh.getRenderingMesh(), defines, this.onCompiled, this.onError, useInstances, null);
935
- let forceWasNotReadyPreviously = false;
936
- if (effect) {
937
- if (this._onEffectCreatedObservable) {
938
- onCreatedEffectParameters.effect = effect;
939
- onCreatedEffectParameters.subMesh = subMesh;
940
- this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters);
941
- }
942
- // Use previous effect while new one is compiling
943
- if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
944
- defines.markAsUnprocessed();
945
- forceWasNotReadyPreviously = this.isFrozen;
946
- if (lightDisposed) {
947
- // re register in case it takes more than one frame.
948
- defines._areLightsDisposed = true;
949
- return false;
989
+ defines.markAsProcessed();
990
+ const scene = this.getScene();
991
+ const engine = scene.getEngine();
992
+ // Fallbacks
993
+ const fallbacks = new EffectFallbacks();
994
+ let fallbackRank = 0;
995
+ if (defines.USESPHERICALINVERTEX) {
996
+ fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
950
997
  }
951
- }
952
- else {
953
- scene.resetCachedMaterial();
954
- subMesh.setEffect(effect, defines, this._materialContext);
955
- }
956
- }
957
- if (!subMesh.effect || !subMesh.effect.isReady()) {
958
- return false;
959
- }
960
- defines._renderId = scene.getRenderId();
961
- drawWrapper._wasPreviouslyReady = forceWasNotReadyPreviously ? false : true;
962
- drawWrapper._wasPreviouslyUsingInstances = !!useInstances;
963
- this._checkScenePerformancePriority();
964
- return true;
965
- }
966
- /**
967
- * Specifies if the material uses metallic roughness workflow.
968
- * @returns boolean specifying if the material uses metallic roughness workflow.
969
- */
970
- isMetallicWorkflow() {
971
- if (this._metallic != null || this._roughness != null || this._metallicTexture) {
972
- return true;
973
- }
974
- return false;
975
- }
976
- _prepareEffect(mesh, renderingMesh, defines, onCompiled = null, onError = null, useInstances = null, useClipPlane = null) {
977
- this._prepareDefines(mesh, renderingMesh, defines, useInstances, useClipPlane);
978
- if (!defines.isDirty) {
979
- return null;
980
- }
981
- defines.markAsProcessed();
982
- const scene = this.getScene();
983
- const engine = scene.getEngine();
984
- // Fallbacks
985
- const fallbacks = new EffectFallbacks();
986
- let fallbackRank = 0;
987
- if (defines.USESPHERICALINVERTEX) {
988
- fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
989
- }
990
- if (defines.FOG) {
991
- fallbacks.addFallback(fallbackRank, "FOG");
992
- }
993
- if (defines.SPECULARAA) {
994
- fallbacks.addFallback(fallbackRank, "SPECULARAA");
995
- }
996
- if (defines.POINTSIZE) {
997
- fallbacks.addFallback(fallbackRank, "POINTSIZE");
998
- }
999
- if (defines.LOGARITHMICDEPTH) {
1000
- fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
1001
- }
1002
- if (defines.PARALLAX) {
1003
- fallbacks.addFallback(fallbackRank, "PARALLAX");
1004
- }
1005
- if (defines.PARALLAX_RHS) {
1006
- fallbacks.addFallback(fallbackRank, "PARALLAX_RHS");
1007
- }
1008
- if (defines.PARALLAXOCCLUSION) {
1009
- fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
1010
- }
1011
- if (defines.ENVIRONMENTBRDF) {
1012
- fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
1013
- }
1014
- if (defines.TANGENT) {
1015
- fallbacks.addFallback(fallbackRank++, "TANGENT");
1016
- }
1017
- if (defines.BUMP) {
1018
- fallbacks.addFallback(fallbackRank++, "BUMP");
1019
- }
1020
- fallbackRank = HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank);
1021
- if (defines.SPECULARTERM) {
1022
- fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
1023
- }
1024
- if (defines.USESPHERICALFROMREFLECTIONMAP) {
1025
- fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
1026
- }
1027
- if (defines.USEIRRADIANCEMAP) {
1028
- fallbacks.addFallback(fallbackRank++, "USEIRRADIANCEMAP");
1029
- }
1030
- if (defines.LIGHTMAP) {
1031
- fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
1032
- }
1033
- if (defines.NORMAL) {
1034
- fallbacks.addFallback(fallbackRank++, "NORMAL");
1035
- }
1036
- if (defines.AMBIENT) {
1037
- fallbacks.addFallback(fallbackRank++, "AMBIENT");
1038
- }
1039
- if (defines.EMISSIVE) {
1040
- fallbacks.addFallback(fallbackRank++, "EMISSIVE");
1041
- }
1042
- if (defines.VERTEXCOLOR) {
1043
- fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
1044
- }
1045
- if (defines.MORPHTARGETS) {
1046
- fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
1047
- }
1048
- if (defines.MULTIVIEW) {
1049
- fallbacks.addFallback(0, "MULTIVIEW");
1050
- }
1051
- //Attributes
1052
- const attribs = [VertexBuffer.PositionKind];
1053
- if (defines.NORMAL) {
1054
- attribs.push(VertexBuffer.NormalKind);
1055
- }
1056
- if (defines.TANGENT) {
1057
- attribs.push(VertexBuffer.TangentKind);
1058
- }
1059
- for (let i = 1; i <= 6; ++i) {
1060
- if (defines["UV" + i]) {
1061
- attribs.push(`uv${i === 1 ? "" : i}`);
1062
- }
1063
- }
1064
- if (defines.VERTEXCOLOR) {
1065
- attribs.push(VertexBuffer.ColorKind);
1066
- }
1067
- PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
1068
- PrepareAttributesForInstances(attribs, defines);
1069
- PrepareAttributesForMorphTargets(attribs, mesh, defines);
1070
- PrepareAttributesForBakedVertexAnimation(attribs, mesh, defines);
1071
- let shaderName = "pbr";
1072
- const uniforms = [
1073
- "world",
1074
- "view",
1075
- "viewProjection",
1076
- "vEyePosition",
1077
- "vLightsType",
1078
- "vAmbientColor",
1079
- "vAlbedoColor",
1080
- "baseWeight",
1081
- "baseDiffuseRoughness",
1082
- "vReflectivityColor",
1083
- "vMetallicReflectanceFactors",
1084
- "vEmissiveColor",
1085
- "visibility",
1086
- "vFogInfos",
1087
- "vFogColor",
1088
- "pointSize",
1089
- "vAlbedoInfos",
1090
- "vBaseWeightInfos",
1091
- "vBaseDiffuseRoughnessInfos",
1092
- "vAmbientInfos",
1093
- "vOpacityInfos",
1094
- "vEmissiveInfos",
1095
- "vReflectivityInfos",
1096
- "vMetallicReflectanceInfos",
1097
- "vReflectanceInfos",
1098
- "vMicroSurfaceSamplerInfos",
1099
- "vBumpInfos",
1100
- "vLightmapInfos",
1101
- "mBones",
1102
- "albedoMatrix",
1103
- "baseWeightMatrix",
1104
- "baseDiffuseRoughnessMatrix",
1105
- "ambientMatrix",
1106
- "opacityMatrix",
1107
- "emissiveMatrix",
1108
- "reflectivityMatrix",
1109
- "normalMatrix",
1110
- "microSurfaceSamplerMatrix",
1111
- "bumpMatrix",
1112
- "lightmapMatrix",
1113
- "metallicReflectanceMatrix",
1114
- "reflectanceMatrix",
1115
- "vLightingIntensity",
1116
- "logarithmicDepthConstant",
1117
- "vTangentSpaceParams",
1118
- "boneTextureInfo",
1119
- "vDebugMode",
1120
- "morphTargetTextureInfo",
1121
- "morphTargetTextureIndices",
1122
- "cameraInfo",
1123
- "vTextureRepetitionHexTilingParams",
1124
- ];
1125
- const samplers = [
1126
- "albedoSampler",
1127
- "baseWeightSampler",
1128
- "baseDiffuseRoughnessSampler",
1129
- "reflectivitySampler",
1130
- "ambientSampler",
1131
- "emissiveSampler",
1132
- "bumpSampler",
1133
- "lightmapSampler",
1134
- "opacitySampler",
1135
- "microSurfaceSampler",
1136
- "environmentBrdfSampler",
1137
- "boneSampler",
1138
- "metallicReflectanceSampler",
1139
- "reflectanceSampler",
1140
- "morphTargets",
1141
- "oitDepthSampler",
1142
- "oitFrontColorSampler",
1143
- "areaLightsLTC1Sampler",
1144
- "areaLightsLTC2Sampler",
1145
- ];
1146
- PrepareUniformsAndSamplersForIBL(uniforms, samplers, true);
1147
- const uniformBuffers = ["Material", "Scene", "Mesh"];
1148
- const indexParameters = { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS };
1149
- this._eventInfo.fallbacks = fallbacks;
1150
- this._eventInfo.fallbackRank = fallbackRank;
1151
- this._eventInfo.defines = defines;
1152
- this._eventInfo.uniforms = uniforms;
1153
- this._eventInfo.attributes = attribs;
1154
- this._eventInfo.samplers = samplers;
1155
- this._eventInfo.uniformBuffersNames = uniformBuffers;
1156
- this._eventInfo.customCode = undefined;
1157
- this._eventInfo.mesh = mesh;
1158
- this._eventInfo.indexParameters = indexParameters;
1159
- this._callbackPluginEventGeneric(128 /* MaterialPluginEvent.PrepareEffect */, this._eventInfo);
1160
- MaterialHelperGeometryRendering.AddUniformsAndSamplers(uniforms, samplers);
1161
- PrePassConfiguration.AddUniforms(uniforms);
1162
- PrePassConfiguration.AddSamplers(samplers);
1163
- AddClipPlaneUniforms(uniforms);
1164
- // Vertex pulling metadata uniforms
1165
- if (this._useVertexPulling) {
1166
- const geometry = renderingMesh?.geometry;
1167
- if (geometry) {
1168
- this._vertexPullingMetadata = PrepareVertexPullingUniforms(geometry);
1169
- if (this._vertexPullingMetadata) {
1170
- this._vertexPullingMetadata.forEach((_, attribute) => {
1171
- uniforms.push(`vp_${attribute}_info`);
1172
- });
998
+ if (defines.FOG) {
999
+ fallbacks.addFallback(fallbackRank, "FOG");
1173
1000
  }
1174
- }
1175
- }
1176
- else {
1177
- this._vertexPullingMetadata = null;
1178
- }
1179
- if (ImageProcessingConfiguration) {
1180
- ImageProcessingConfiguration.PrepareUniforms(uniforms, defines);
1181
- ImageProcessingConfiguration.PrepareSamplers(samplers, defines);
1182
- }
1183
- PrepareUniformsAndSamplersList({
1184
- uniformsNames: uniforms,
1185
- uniformBuffersNames: uniformBuffers,
1186
- samplers: samplers,
1187
- defines: defines,
1188
- maxSimultaneousLights: this._maxSimultaneousLights,
1189
- shaderLanguage: this._shaderLanguage,
1190
- });
1191
- const csnrOptions = {};
1192
- if (this.customShaderNameResolve) {
1193
- shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines, attribs, csnrOptions);
1194
- }
1195
- const join = defines.toString();
1196
- const effect = engine.createEffect(shaderName, {
1197
- attributes: attribs,
1198
- uniformsNames: uniforms,
1199
- uniformBuffersNames: uniformBuffers,
1200
- samplers: samplers,
1201
- defines: join,
1202
- fallbacks: fallbacks,
1203
- onCompiled: onCompiled,
1204
- onError: onError,
1205
- indexParameters,
1206
- processFinalCode: csnrOptions.processFinalCode,
1207
- processCodeAfterIncludes: this._eventInfo.customCode,
1208
- multiTarget: defines.PREPASS,
1209
- shaderLanguage: this._shaderLanguage,
1210
- extraInitializationsAsync: this._shadersLoaded
1211
- ? undefined
1212
- : async () => {
1213
- if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
1214
- await Promise.all([import("../../ShadersWGSL/pbr.vertex.js"), import("../../ShadersWGSL/pbr.fragment.js")]);
1215
- }
1216
- else {
1217
- await Promise.all([import("../../Shaders/pbr.vertex.js"), import("../../Shaders/pbr.fragment.js")]);
1218
- }
1219
- this._shadersLoaded = true;
1220
- },
1221
- }, engine);
1222
- this._eventInfo.customCode = undefined;
1223
- return effect;
1224
- }
1225
- _prepareDefines(mesh, renderingMesh, defines, useInstances = null, useClipPlane = null) {
1226
- const useThinInstances = renderingMesh.hasThinInstances;
1227
- const scene = this.getScene();
1228
- const engine = scene.getEngine();
1229
- // Lights
1230
- PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
1231
- defines._needNormals = true;
1232
- // Multiview
1233
- PrepareDefinesForMultiview(scene, defines);
1234
- // PrePass
1235
- const oit = this.needAlphaBlendingForMesh(mesh) && this.getScene().useOrderIndependentTransparency;
1236
- PrepareDefinesForPrePass(scene, defines, this.canRenderToMRT && !oit);
1237
- // Order independant transparency
1238
- PrepareDefinesForOIT(scene, defines, oit);
1239
- MaterialHelperGeometryRendering.PrepareDefines(engine.currentRenderPassId, mesh, defines);
1240
- // Textures
1241
- defines.METALLICWORKFLOW = this.isMetallicWorkflow();
1242
- if (defines._areTexturesDirty) {
1243
- defines._needUVs = false;
1244
- for (let i = 1; i <= 6; ++i) {
1245
- defines["MAINUV" + i] = false;
1246
- }
1247
- if (scene.texturesEnabled) {
1248
- defines.ALBEDODIRECTUV = 0;
1249
- defines.BASE_WEIGHTDIRECTUV = 0;
1250
- defines.BASE_DIFFUSE_ROUGHNESSDIRECTUV = 0;
1251
- defines.AMBIENTDIRECTUV = 0;
1252
- defines.OPACITYDIRECTUV = 0;
1253
- defines.EMISSIVEDIRECTUV = 0;
1254
- defines.REFLECTIVITYDIRECTUV = 0;
1255
- defines.MICROSURFACEMAPDIRECTUV = 0;
1256
- defines.METALLIC_REFLECTANCEDIRECTUV = 0;
1257
- defines.REFLECTANCEDIRECTUV = 0;
1258
- defines.BUMPDIRECTUV = 0;
1259
- defines.LIGHTMAPDIRECTUV = 0;
1260
- if (engine.getCaps().textureLOD) {
1261
- defines.LODBASEDMICROSFURACE = true;
1262
- }
1263
- if (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled) {
1264
- PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
1265
- defines.GAMMAALBEDO = this._albedoTexture.gammaSpace;
1001
+ if (defines.SPECULARAA) {
1002
+ fallbacks.addFallback(fallbackRank, "SPECULARAA");
1266
1003
  }
1267
- else {
1268
- defines.ALBEDO = false;
1004
+ if (defines.POINTSIZE) {
1005
+ fallbacks.addFallback(fallbackRank, "POINTSIZE");
1269
1006
  }
1270
- if (this._baseWeightTexture && MaterialFlags.BaseWeightTextureEnabled) {
1271
- PrepareDefinesForMergedUV(this._baseWeightTexture, defines, "BASE_WEIGHT");
1007
+ if (defines.LOGARITHMICDEPTH) {
1008
+ fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
1272
1009
  }
1273
- else {
1274
- defines.BASE_WEIGHT = false;
1010
+ if (defines.PARALLAX) {
1011
+ fallbacks.addFallback(fallbackRank, "PARALLAX");
1275
1012
  }
1276
- if (this._baseDiffuseRoughnessTexture && MaterialFlags.BaseDiffuseRoughnessTextureEnabled) {
1277
- PrepareDefinesForMergedUV(this._baseDiffuseRoughnessTexture, defines, "BASE_DIFFUSE_ROUGHNESS");
1013
+ if (defines.PARALLAX_RHS) {
1014
+ fallbacks.addFallback(fallbackRank, "PARALLAX_RHS");
1278
1015
  }
1279
- else {
1280
- defines.BASE_DIFFUSE_ROUGHNESS = false;
1016
+ if (defines.PARALLAXOCCLUSION) {
1017
+ fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
1281
1018
  }
1282
- if (this._ambientTexture && MaterialFlags.AmbientTextureEnabled) {
1283
- PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
1284
- defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
1019
+ if (defines.ENVIRONMENTBRDF) {
1020
+ fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
1285
1021
  }
1286
- else {
1287
- defines.AMBIENT = false;
1022
+ if (defines.TANGENT) {
1023
+ fallbacks.addFallback(fallbackRank++, "TANGENT");
1288
1024
  }
1289
- if (this._opacityTexture && MaterialFlags.OpacityTextureEnabled) {
1290
- PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
1291
- defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
1025
+ if (defines.BUMP) {
1026
+ fallbacks.addFallback(fallbackRank++, "BUMP");
1292
1027
  }
1293
- else {
1294
- defines.OPACITY = false;
1295
- }
1296
- const reflectionTexture = this._getReflectionTexture();
1297
- const useSHInFragment = this._forceIrradianceInFragment ||
1298
- this.realTimeFiltering ||
1299
- this._twoSidedLighting ||
1300
- engine.getCaps().maxVaryingVectors <= 8 ||
1301
- this._baseDiffuseRoughnessTexture != null;
1302
- PrepareDefinesForIBL(scene, reflectionTexture, defines, this.realTimeFiltering, this.realTimeFilteringQuality, !useSHInFragment);
1303
- if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled) {
1304
- PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
1305
- defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
1306
- defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
1307
- defines.RGBDLIGHTMAP = this._lightmapTexture.isRGBD;
1028
+ fallbackRank = HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank);
1029
+ if (defines.SPECULARTERM) {
1030
+ fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
1308
1031
  }
1309
- else {
1310
- defines.LIGHTMAP = false;
1032
+ if (defines.USESPHERICALFROMREFLECTIONMAP) {
1033
+ fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
1311
1034
  }
1312
- if (this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled) {
1313
- PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
1314
- defines.GAMMAEMISSIVE = this._emissiveTexture.gammaSpace;
1035
+ if (defines.USEIRRADIANCEMAP) {
1036
+ fallbacks.addFallback(fallbackRank++, "USEIRRADIANCEMAP");
1315
1037
  }
1316
- else {
1317
- defines.EMISSIVE = false;
1318
- }
1319
- if (MaterialFlags.SpecularTextureEnabled) {
1320
- if (this._metallicTexture) {
1321
- PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
1322
- defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
1323
- defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
1324
- defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
1325
- defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
1326
- defines.REFLECTIVITY_GAMMA = false;
1038
+ if (defines.LIGHTMAP) {
1039
+ fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
1040
+ }
1041
+ if (defines.NORMAL) {
1042
+ fallbacks.addFallback(fallbackRank++, "NORMAL");
1043
+ }
1044
+ if (defines.AMBIENT) {
1045
+ fallbacks.addFallback(fallbackRank++, "AMBIENT");
1046
+ }
1047
+ if (defines.EMISSIVE) {
1048
+ fallbacks.addFallback(fallbackRank++, "EMISSIVE");
1049
+ }
1050
+ if (defines.VERTEXCOLOR) {
1051
+ fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
1052
+ }
1053
+ if (defines.MORPHTARGETS) {
1054
+ fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
1055
+ }
1056
+ if (defines.MULTIVIEW) {
1057
+ fallbacks.addFallback(0, "MULTIVIEW");
1058
+ }
1059
+ //Attributes
1060
+ const attribs = [VertexBuffer.PositionKind];
1061
+ if (defines.NORMAL) {
1062
+ attribs.push(VertexBuffer.NormalKind);
1063
+ }
1064
+ if (defines.TANGENT) {
1065
+ attribs.push(VertexBuffer.TangentKind);
1066
+ }
1067
+ for (let i = 1; i <= 6; ++i) {
1068
+ if (defines["UV" + i]) {
1069
+ attribs.push(`uv${i === 1 ? "" : i}`);
1327
1070
  }
1328
- else if (this._reflectivityTexture) {
1329
- PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
1330
- defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
1331
- defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
1332
- defines.REFLECTIVITY_GAMMA = this._reflectivityTexture.gammaSpace;
1071
+ }
1072
+ if (defines.VERTEXCOLOR) {
1073
+ attribs.push(VertexBuffer.ColorKind);
1074
+ }
1075
+ PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
1076
+ PrepareAttributesForInstances(attribs, defines);
1077
+ PrepareAttributesForMorphTargets(attribs, mesh, defines);
1078
+ PrepareAttributesForBakedVertexAnimation(attribs, mesh, defines);
1079
+ let shaderName = "pbr";
1080
+ const uniforms = [
1081
+ "world",
1082
+ "view",
1083
+ "viewProjection",
1084
+ "vEyePosition",
1085
+ "vLightsType",
1086
+ "vAmbientColor",
1087
+ "vAlbedoColor",
1088
+ "baseWeight",
1089
+ "baseDiffuseRoughness",
1090
+ "vReflectivityColor",
1091
+ "vMetallicReflectanceFactors",
1092
+ "vEmissiveColor",
1093
+ "visibility",
1094
+ "vFogInfos",
1095
+ "vFogColor",
1096
+ "pointSize",
1097
+ "vAlbedoInfos",
1098
+ "vBaseWeightInfos",
1099
+ "vBaseDiffuseRoughnessInfos",
1100
+ "vAmbientInfos",
1101
+ "vOpacityInfos",
1102
+ "vEmissiveInfos",
1103
+ "vReflectivityInfos",
1104
+ "vMetallicReflectanceInfos",
1105
+ "vReflectanceInfos",
1106
+ "vMicroSurfaceSamplerInfos",
1107
+ "vBumpInfos",
1108
+ "vLightmapInfos",
1109
+ "mBones",
1110
+ "albedoMatrix",
1111
+ "baseWeightMatrix",
1112
+ "baseDiffuseRoughnessMatrix",
1113
+ "ambientMatrix",
1114
+ "opacityMatrix",
1115
+ "emissiveMatrix",
1116
+ "reflectivityMatrix",
1117
+ "normalMatrix",
1118
+ "microSurfaceSamplerMatrix",
1119
+ "bumpMatrix",
1120
+ "lightmapMatrix",
1121
+ "metallicReflectanceMatrix",
1122
+ "reflectanceMatrix",
1123
+ "vLightingIntensity",
1124
+ "logarithmicDepthConstant",
1125
+ "vTangentSpaceParams",
1126
+ "boneTextureInfo",
1127
+ "vDebugMode",
1128
+ "morphTargetTextureInfo",
1129
+ "morphTargetTextureIndices",
1130
+ "cameraInfo",
1131
+ "vTextureRepetitionHexTilingParams",
1132
+ ];
1133
+ const samplers = [
1134
+ "albedoSampler",
1135
+ "baseWeightSampler",
1136
+ "baseDiffuseRoughnessSampler",
1137
+ "reflectivitySampler",
1138
+ "ambientSampler",
1139
+ "emissiveSampler",
1140
+ "bumpSampler",
1141
+ "lightmapSampler",
1142
+ "opacitySampler",
1143
+ "microSurfaceSampler",
1144
+ "environmentBrdfSampler",
1145
+ "boneSampler",
1146
+ "metallicReflectanceSampler",
1147
+ "reflectanceSampler",
1148
+ "morphTargets",
1149
+ "oitDepthSampler",
1150
+ "oitFrontColorSampler",
1151
+ "areaLightsLTC1Sampler",
1152
+ "areaLightsLTC2Sampler",
1153
+ ];
1154
+ PrepareUniformsAndSamplersForIBL(uniforms, samplers, true);
1155
+ const uniformBuffers = ["Material", "Scene", "Mesh"];
1156
+ const indexParameters = { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS };
1157
+ this._eventInfo.fallbacks = fallbacks;
1158
+ this._eventInfo.fallbackRank = fallbackRank;
1159
+ this._eventInfo.defines = defines;
1160
+ this._eventInfo.uniforms = uniforms;
1161
+ this._eventInfo.attributes = attribs;
1162
+ this._eventInfo.samplers = samplers;
1163
+ this._eventInfo.uniformBuffersNames = uniformBuffers;
1164
+ this._eventInfo.customCode = undefined;
1165
+ this._eventInfo.mesh = mesh;
1166
+ this._eventInfo.indexParameters = indexParameters;
1167
+ this._callbackPluginEventGeneric(128 /* MaterialPluginEvent.PrepareEffect */, this._eventInfo);
1168
+ MaterialHelperGeometryRendering.AddUniformsAndSamplers(uniforms, samplers);
1169
+ PrePassConfiguration.AddUniforms(uniforms);
1170
+ PrePassConfiguration.AddSamplers(samplers);
1171
+ AddClipPlaneUniforms(uniforms);
1172
+ // Vertex pulling metadata uniforms
1173
+ if (this._useVertexPulling) {
1174
+ const geometry = renderingMesh?.geometry;
1175
+ if (geometry) {
1176
+ this._vertexPullingMetadata = PrepareVertexPullingUniforms(geometry);
1177
+ if (this._vertexPullingMetadata) {
1178
+ this._vertexPullingMetadata.forEach((_, attribute) => {
1179
+ uniforms.push(`vp_${attribute}_info`);
1180
+ });
1181
+ }
1333
1182
  }
1334
- else {
1335
- defines.REFLECTIVITY = false;
1183
+ }
1184
+ else {
1185
+ this._vertexPullingMetadata = null;
1186
+ }
1187
+ if (ImageProcessingConfiguration) {
1188
+ ImageProcessingConfiguration.PrepareUniforms(uniforms, defines);
1189
+ ImageProcessingConfiguration.PrepareSamplers(samplers, defines);
1190
+ }
1191
+ PrepareUniformsAndSamplersList({
1192
+ uniformsNames: uniforms,
1193
+ uniformBuffersNames: uniformBuffers,
1194
+ samplers: samplers,
1195
+ defines: defines,
1196
+ maxSimultaneousLights: this._maxSimultaneousLights,
1197
+ shaderLanguage: this._shaderLanguage,
1198
+ });
1199
+ const csnrOptions = {};
1200
+ if (this.customShaderNameResolve) {
1201
+ shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines, attribs, csnrOptions);
1202
+ }
1203
+ const join = defines.toString();
1204
+ const effect = engine.createEffect(shaderName, {
1205
+ attributes: attribs,
1206
+ uniformsNames: uniforms,
1207
+ uniformBuffersNames: uniformBuffers,
1208
+ samplers: samplers,
1209
+ defines: join,
1210
+ fallbacks: fallbacks,
1211
+ onCompiled: onCompiled,
1212
+ onError: onError,
1213
+ indexParameters,
1214
+ processFinalCode: csnrOptions.processFinalCode,
1215
+ processCodeAfterIncludes: this._eventInfo.customCode,
1216
+ multiTarget: defines.PREPASS,
1217
+ shaderLanguage: this._shaderLanguage,
1218
+ extraInitializationsAsync: this._shadersLoaded
1219
+ ? undefined
1220
+ : async () => {
1221
+ if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
1222
+ await Promise.all([import("../../ShadersWGSL/pbr.vertex.js"), import("../../ShadersWGSL/pbr.fragment.js")]);
1223
+ }
1224
+ else {
1225
+ await Promise.all([import("../../Shaders/pbr.vertex.js"), import("../../Shaders/pbr.fragment.js")]);
1226
+ }
1227
+ this._shadersLoaded = true;
1228
+ },
1229
+ }, engine);
1230
+ this._eventInfo.customCode = undefined;
1231
+ return effect;
1232
+ }
1233
+ _prepareDefines(mesh, renderingMesh, defines, useInstances = null, useClipPlane = null) {
1234
+ const useThinInstances = renderingMesh.hasThinInstances;
1235
+ const scene = this.getScene();
1236
+ const engine = scene.getEngine();
1237
+ // Lights
1238
+ PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
1239
+ defines._needNormals = true;
1240
+ // Multiview
1241
+ PrepareDefinesForMultiview(scene, defines);
1242
+ // PrePass
1243
+ const oit = this.needAlphaBlendingForMesh(mesh) && this.getScene().useOrderIndependentTransparency;
1244
+ PrepareDefinesForPrePass(scene, defines, this.canRenderToMRT && !oit);
1245
+ // Order independant transparency
1246
+ PrepareDefinesForOIT(scene, defines, oit);
1247
+ MaterialHelperGeometryRendering.PrepareDefines(engine.currentRenderPassId, mesh, defines);
1248
+ // Textures
1249
+ defines.METALLICWORKFLOW = this.isMetallicWorkflow();
1250
+ if (defines._areTexturesDirty) {
1251
+ defines._needUVs = false;
1252
+ for (let i = 1; i <= 6; ++i) {
1253
+ defines["MAINUV" + i] = false;
1336
1254
  }
1337
- if (this._metallicReflectanceTexture || this._reflectanceTexture) {
1338
- defines.METALLIC_REFLECTANCE_USE_ALPHA_ONLY = this._useOnlyMetallicFromMetallicReflectanceTexture;
1339
- if (this._metallicReflectanceTexture) {
1340
- PrepareDefinesForMergedUV(this._metallicReflectanceTexture, defines, "METALLIC_REFLECTANCE");
1341
- defines.METALLIC_REFLECTANCE_GAMMA = this._metallicReflectanceTexture.gammaSpace;
1255
+ if (scene.texturesEnabled) {
1256
+ defines.ALBEDODIRECTUV = 0;
1257
+ defines.BASE_WEIGHTDIRECTUV = 0;
1258
+ defines.BASE_DIFFUSE_ROUGHNESSDIRECTUV = 0;
1259
+ defines.AMBIENTDIRECTUV = 0;
1260
+ defines.OPACITYDIRECTUV = 0;
1261
+ defines.EMISSIVEDIRECTUV = 0;
1262
+ defines.REFLECTIVITYDIRECTUV = 0;
1263
+ defines.MICROSURFACEMAPDIRECTUV = 0;
1264
+ defines.METALLIC_REFLECTANCEDIRECTUV = 0;
1265
+ defines.REFLECTANCEDIRECTUV = 0;
1266
+ defines.BUMPDIRECTUV = 0;
1267
+ defines.LIGHTMAPDIRECTUV = 0;
1268
+ if (engine.getCaps().textureLOD) {
1269
+ defines.LODBASEDMICROSFURACE = true;
1270
+ }
1271
+ if (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled) {
1272
+ PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
1273
+ defines.GAMMAALBEDO = this._albedoTexture.gammaSpace;
1274
+ }
1275
+ else {
1276
+ defines.ALBEDO = false;
1277
+ }
1278
+ if (this._baseWeightTexture && MaterialFlags.BaseWeightTextureEnabled) {
1279
+ PrepareDefinesForMergedUV(this._baseWeightTexture, defines, "BASE_WEIGHT");
1280
+ }
1281
+ else {
1282
+ defines.BASE_WEIGHT = false;
1283
+ }
1284
+ if (this._baseDiffuseRoughnessTexture && MaterialFlags.BaseDiffuseRoughnessTextureEnabled) {
1285
+ PrepareDefinesForMergedUV(this._baseDiffuseRoughnessTexture, defines, "BASE_DIFFUSE_ROUGHNESS");
1286
+ }
1287
+ else {
1288
+ defines.BASE_DIFFUSE_ROUGHNESS = false;
1289
+ }
1290
+ if (this._ambientTexture && MaterialFlags.AmbientTextureEnabled) {
1291
+ PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
1292
+ defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
1293
+ }
1294
+ else {
1295
+ defines.AMBIENT = false;
1296
+ }
1297
+ if (this._opacityTexture && MaterialFlags.OpacityTextureEnabled) {
1298
+ PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
1299
+ defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
1300
+ }
1301
+ else {
1302
+ defines.OPACITY = false;
1303
+ }
1304
+ const reflectionTexture = this._getReflectionTexture();
1305
+ const useSHInFragment = this._forceIrradianceInFragment ||
1306
+ this.realTimeFiltering ||
1307
+ this._twoSidedLighting ||
1308
+ engine.getCaps().maxVaryingVectors <= 8 ||
1309
+ this._baseDiffuseRoughnessTexture != null;
1310
+ PrepareDefinesForIBL(scene, reflectionTexture, defines, this.realTimeFiltering, this.realTimeFilteringQuality, !useSHInFragment);
1311
+ if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled) {
1312
+ PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
1313
+ defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
1314
+ defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
1315
+ defines.RGBDLIGHTMAP = this._lightmapTexture.isRGBD;
1316
+ }
1317
+ else {
1318
+ defines.LIGHTMAP = false;
1319
+ }
1320
+ if (this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled) {
1321
+ PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
1322
+ defines.GAMMAEMISSIVE = this._emissiveTexture.gammaSpace;
1323
+ }
1324
+ else {
1325
+ defines.EMISSIVE = false;
1326
+ }
1327
+ if (MaterialFlags.SpecularTextureEnabled) {
1328
+ if (this._metallicTexture) {
1329
+ PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
1330
+ defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
1331
+ defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
1332
+ defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
1333
+ defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
1334
+ defines.REFLECTIVITY_GAMMA = false;
1335
+ }
1336
+ else if (this._reflectivityTexture) {
1337
+ PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
1338
+ defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
1339
+ defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
1340
+ defines.REFLECTIVITY_GAMMA = this._reflectivityTexture.gammaSpace;
1341
+ }
1342
+ else {
1343
+ defines.REFLECTIVITY = false;
1344
+ }
1345
+ if (this._metallicReflectanceTexture || this._reflectanceTexture) {
1346
+ defines.METALLIC_REFLECTANCE_USE_ALPHA_ONLY = this._useOnlyMetallicFromMetallicReflectanceTexture;
1347
+ if (this._metallicReflectanceTexture) {
1348
+ PrepareDefinesForMergedUV(this._metallicReflectanceTexture, defines, "METALLIC_REFLECTANCE");
1349
+ defines.METALLIC_REFLECTANCE_GAMMA = this._metallicReflectanceTexture.gammaSpace;
1350
+ }
1351
+ else {
1352
+ defines.METALLIC_REFLECTANCE = false;
1353
+ }
1354
+ if (this._reflectanceTexture &&
1355
+ (!this._metallicReflectanceTexture || (this._metallicReflectanceTexture && this._useOnlyMetallicFromMetallicReflectanceTexture))) {
1356
+ PrepareDefinesForMergedUV(this._reflectanceTexture, defines, "REFLECTANCE");
1357
+ defines.REFLECTANCE_GAMMA = this._reflectanceTexture.gammaSpace;
1358
+ }
1359
+ else {
1360
+ defines.REFLECTANCE = false;
1361
+ }
1362
+ }
1363
+ else {
1364
+ defines.METALLIC_REFLECTANCE = false;
1365
+ defines.REFLECTANCE = false;
1366
+ }
1367
+ if (this._microSurfaceTexture) {
1368
+ PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
1369
+ }
1370
+ else {
1371
+ defines.MICROSURFACEMAP = false;
1372
+ }
1373
+ }
1374
+ else {
1375
+ defines.REFLECTIVITY = false;
1376
+ defines.MICROSURFACEMAP = false;
1377
+ }
1378
+ if (engine.getCaps().standardDerivatives && this._bumpTexture && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap) {
1379
+ PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
1380
+ if (this._useParallax && this._albedoTexture && MaterialFlags.DiffuseTextureEnabled) {
1381
+ defines.PARALLAX = true;
1382
+ defines.PARALLAX_RHS = scene.useRightHandedSystem;
1383
+ defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
1384
+ }
1385
+ else {
1386
+ defines.PARALLAX = false;
1387
+ }
1388
+ defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
1342
1389
  }
1343
1390
  else {
1344
- defines.METALLIC_REFLECTANCE = false;
1391
+ defines.BUMP = false;
1392
+ defines.PARALLAX = false;
1393
+ defines.PARALLAX_RHS = false;
1394
+ defines.PARALLAXOCCLUSION = false;
1395
+ defines.OBJECTSPACE_NORMALMAP = false;
1345
1396
  }
1346
- if (this._reflectanceTexture &&
1347
- (!this._metallicReflectanceTexture || (this._metallicReflectanceTexture && this._useOnlyMetallicFromMetallicReflectanceTexture))) {
1348
- PrepareDefinesForMergedUV(this._reflectanceTexture, defines, "REFLECTANCE");
1349
- defines.REFLECTANCE_GAMMA = this._reflectanceTexture.gammaSpace;
1397
+ if (this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled) {
1398
+ defines.ENVIRONMENTBRDF = true;
1399
+ defines.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD;
1350
1400
  }
1351
1401
  else {
1352
- defines.REFLECTANCE = false;
1402
+ defines.ENVIRONMENTBRDF = false;
1403
+ defines.ENVIRONMENTBRDF_RGBD = false;
1404
+ }
1405
+ if (this._shouldUseAlphaFromAlbedoTexture()) {
1406
+ defines.ALPHAFROMALBEDO = true;
1407
+ }
1408
+ else {
1409
+ defines.ALPHAFROMALBEDO = false;
1353
1410
  }
1354
1411
  }
1355
- else {
1356
- defines.METALLIC_REFLECTANCE = false;
1357
- defines.REFLECTANCE = false;
1412
+ defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
1413
+ if (this._lightFalloff === _a.LIGHTFALLOFF_STANDARD) {
1414
+ defines.USEPHYSICALLIGHTFALLOFF = false;
1415
+ defines.USEGLTFLIGHTFALLOFF = false;
1358
1416
  }
1359
- if (this._microSurfaceTexture) {
1360
- PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
1417
+ else if (this._lightFalloff === _a.LIGHTFALLOFF_GLTF) {
1418
+ defines.USEPHYSICALLIGHTFALLOFF = false;
1419
+ defines.USEGLTFLIGHTFALLOFF = true;
1361
1420
  }
1362
1421
  else {
1363
- defines.MICROSURFACEMAP = false;
1422
+ defines.USEPHYSICALLIGHTFALLOFF = true;
1423
+ defines.USEGLTFLIGHTFALLOFF = false;
1364
1424
  }
1365
- }
1366
- else {
1367
- defines.REFLECTIVITY = false;
1368
- defines.MICROSURFACEMAP = false;
1369
- }
1370
- if (engine.getCaps().standardDerivatives && this._bumpTexture && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap) {
1371
- PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
1372
- if (this._useParallax && this._albedoTexture && MaterialFlags.DiffuseTextureEnabled) {
1373
- defines.PARALLAX = true;
1374
- defines.PARALLAX_RHS = scene.useRightHandedSystem;
1375
- defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
1425
+ defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
1426
+ if (!this.backFaceCulling && this._twoSidedLighting) {
1427
+ defines.TWOSIDEDLIGHTING = true;
1376
1428
  }
1377
1429
  else {
1378
- defines.PARALLAX = false;
1430
+ defines.TWOSIDEDLIGHTING = false;
1379
1431
  }
1380
- defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
1381
- }
1382
- else {
1383
- defines.BUMP = false;
1384
- defines.PARALLAX = false;
1385
- defines.PARALLAX_RHS = false;
1386
- defines.PARALLAXOCCLUSION = false;
1387
- defines.OBJECTSPACE_NORMALMAP = false;
1432
+ // We need it to not invert normals in two sided lighting mode (based on the winding of the face)
1433
+ defines.MIRRORED = !!scene._mirroredCameraPosition;
1434
+ defines.SPECULARAA = engine.getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
1388
1435
  }
1389
- if (this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled) {
1390
- defines.ENVIRONMENTBRDF = true;
1391
- defines.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD;
1436
+ if (defines._areTexturesDirty || defines._areMiscDirty) {
1437
+ defines.ALPHATESTVALUE = `${this._alphaCutOff}${this._alphaCutOff % 1 === 0 ? "." : ""}`;
1438
+ defines.PREMULTIPLYALPHA = this.alphaMode === 7 || this.alphaMode === 8;
1439
+ defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
1440
+ defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
1441
+ defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
1392
1442
  }
1393
- else {
1394
- defines.ENVIRONMENTBRDF = false;
1395
- defines.ENVIRONMENTBRDF_RGBD = false;
1443
+ if (defines._areTexturesDirty) {
1444
+ defines.TEXTURE_REPETITION_MODE = engine.version > 1 || engine.isWebGPU ? this.textureRepetitionMode : 0;
1396
1445
  }
1397
- if (this._shouldUseAlphaFromAlbedoTexture()) {
1398
- defines.ALPHAFROMALBEDO = true;
1446
+ if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
1447
+ this._imageProcessingConfiguration.prepareDefines(defines);
1399
1448
  }
1400
- else {
1401
- defines.ALPHAFROMALBEDO = false;
1449
+ defines.FORCENORMALFORWARD = this._forceNormalForward;
1450
+ defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
1451
+ defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
1452
+ // Misc.
1453
+ if (defines._areMiscDirty) {
1454
+ PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines, this._applyDecalMapAfterDetailMap, this._useVertexPulling, renderingMesh, this._isVertexOutputInvariant);
1455
+ defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(VertexBuffer.NormalKind));
1456
+ defines.DEBUGMODE = this._debugMode;
1402
1457
  }
1458
+ // Values that need to be evaluated on every frame
1459
+ PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false, useClipPlane, useThinInstances);
1460
+ // External config
1461
+ this._eventInfo.defines = defines;
1462
+ this._eventInfo.mesh = mesh;
1463
+ this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo);
1464
+ // Attribs
1465
+ PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== _a.PBRMATERIAL_OPAQUE);
1466
+ // External config
1467
+ this._callbackPluginEventPrepareDefines(this._eventInfo);
1403
1468
  }
1404
- defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
1405
- if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
1406
- defines.USEPHYSICALLIGHTFALLOFF = false;
1407
- defines.USEGLTFLIGHTFALLOFF = false;
1408
- }
1409
- else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
1410
- defines.USEPHYSICALLIGHTFALLOFF = false;
1411
- defines.USEGLTFLIGHTFALLOFF = true;
1412
- }
1413
- else {
1414
- defines.USEPHYSICALLIGHTFALLOFF = true;
1415
- defines.USEGLTFLIGHTFALLOFF = false;
1416
- }
1417
- defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
1418
- if (!this.backFaceCulling && this._twoSidedLighting) {
1419
- defines.TWOSIDEDLIGHTING = true;
1420
- }
1421
- else {
1422
- defines.TWOSIDEDLIGHTING = false;
1423
- }
1424
- // We need it to not invert normals in two sided lighting mode (based on the winding of the face)
1425
- defines.MIRRORED = !!scene._mirroredCameraPosition;
1426
- defines.SPECULARAA = engine.getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
1427
- }
1428
- if (defines._areTexturesDirty || defines._areMiscDirty) {
1429
- defines.ALPHATESTVALUE = `${this._alphaCutOff}${this._alphaCutOff % 1 === 0 ? "." : ""}`;
1430
- defines.PREMULTIPLYALPHA = this.alphaMode === 7 || this.alphaMode === 8;
1431
- defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
1432
- defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
1433
- defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
1434
- }
1435
- if (defines._areTexturesDirty) {
1436
- defines.TEXTURE_REPETITION_MODE = engine.version > 1 || engine.isWebGPU ? this.textureRepetitionMode : 0;
1437
- }
1438
- if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
1439
- this._imageProcessingConfiguration.prepareDefines(defines);
1440
- }
1441
- defines.FORCENORMALFORWARD = this._forceNormalForward;
1442
- defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
1443
- defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
1444
- // Misc.
1445
- if (defines._areMiscDirty) {
1446
- PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines, this._applyDecalMapAfterDetailMap, this._useVertexPulling, renderingMesh, this._isVertexOutputInvariant);
1447
- defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(VertexBuffer.NormalKind));
1448
- defines.DEBUGMODE = this._debugMode;
1449
- }
1450
- // Values that need to be evaluated on every frame
1451
- PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false, useClipPlane, useThinInstances);
1452
- // External config
1453
- this._eventInfo.defines = defines;
1454
- this._eventInfo.mesh = mesh;
1455
- this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo);
1456
- // Attribs
1457
- PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
1458
- // External config
1459
- this._callbackPluginEventPrepareDefines(this._eventInfo);
1460
- }
1461
- /**
1462
- * Force shader compilation
1463
- * @param mesh - Define the mesh we want to force the compilation for
1464
- * @param onCompiled - Define a callback triggered when the compilation completes
1465
- * @param options - Define the options used to create the compilation
1466
- */
1467
- forceCompilation(mesh, onCompiled, options) {
1468
- const localOptions = {
1469
- clipPlane: false,
1470
- useInstances: false,
1471
- ...options,
1472
- };
1473
- if (!this._uniformBufferLayoutBuilt) {
1474
- this.buildUniformLayout();
1475
- }
1476
- this._callbackPluginEventGeneric(4 /* MaterialPluginEvent.GetDefineNames */, this._eventInfo);
1477
- const checkReady = () => {
1478
- if (this._breakShaderLoadedCheck) {
1479
- return;
1480
- }
1481
- const defines = new PBRMaterialDefines(this._eventInfo.defineNames);
1482
- const effect = this._prepareEffect(mesh, mesh, defines, undefined, undefined, localOptions.useInstances, localOptions.clipPlane);
1483
- if (this._onEffectCreatedObservable) {
1484
- onCreatedEffectParameters.effect = effect;
1485
- onCreatedEffectParameters.subMesh = null;
1486
- this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters);
1487
- }
1488
- if (effect.isReady()) {
1489
- if (onCompiled) {
1490
- onCompiled(this);
1469
+ /**
1470
+ * Force shader compilation
1471
+ * @param mesh - Define the mesh we want to force the compilation for
1472
+ * @param onCompiled - Define a callback triggered when the compilation completes
1473
+ * @param options - Define the options used to create the compilation
1474
+ */
1475
+ forceCompilation(mesh, onCompiled, options) {
1476
+ const localOptions = {
1477
+ clipPlane: false,
1478
+ useInstances: false,
1479
+ ...options,
1480
+ };
1481
+ if (!this._uniformBufferLayoutBuilt) {
1482
+ this.buildUniformLayout();
1491
1483
  }
1492
- }
1493
- else {
1494
- effect.onCompileObservable.add(() => {
1495
- if (onCompiled) {
1496
- onCompiled(this);
1484
+ this._callbackPluginEventGeneric(4 /* MaterialPluginEvent.GetDefineNames */, this._eventInfo);
1485
+ const checkReady = () => {
1486
+ if (this._breakShaderLoadedCheck) {
1487
+ return;
1497
1488
  }
1498
- });
1499
- }
1500
- };
1501
- checkReady();
1502
- }
1503
- /**
1504
- * Initializes the uniform buffer layout for the shader.
1505
- */
1506
- buildUniformLayout() {
1507
- // Order is important !
1508
- const ubo = this._uniformBuffer;
1509
- ubo.addUniform("vAlbedoInfos", 2);
1510
- ubo.addUniform("vBaseWeightInfos", 2);
1511
- ubo.addUniform("vBaseDiffuseRoughnessInfos", 2);
1512
- ubo.addUniform("vAmbientInfos", 4);
1513
- ubo.addUniform("vOpacityInfos", 2);
1514
- ubo.addUniform("vEmissiveInfos", 2);
1515
- ubo.addUniform("vLightmapInfos", 2);
1516
- ubo.addUniform("vReflectivityInfos", 3);
1517
- ubo.addUniform("vMicroSurfaceSamplerInfos", 2);
1518
- ubo.addUniform("vBumpInfos", 3);
1519
- ubo.addUniform("albedoMatrix", 16);
1520
- ubo.addUniform("baseWeightMatrix", 16);
1521
- ubo.addUniform("baseDiffuseRoughnessMatrix", 16);
1522
- ubo.addUniform("ambientMatrix", 16);
1523
- ubo.addUniform("opacityMatrix", 16);
1524
- ubo.addUniform("emissiveMatrix", 16);
1525
- ubo.addUniform("lightmapMatrix", 16);
1526
- ubo.addUniform("reflectivityMatrix", 16);
1527
- ubo.addUniform("microSurfaceSamplerMatrix", 16);
1528
- ubo.addUniform("bumpMatrix", 16);
1529
- ubo.addUniform("vTangentSpaceParams", 2);
1530
- ubo.addUniform("vAlbedoColor", 4);
1531
- ubo.addUniform("baseWeight", 1);
1532
- ubo.addUniform("baseDiffuseRoughness", 1);
1533
- ubo.addUniform("vLightingIntensity", 4);
1534
- ubo.addUniform("pointSize", 1);
1535
- ubo.addUniform("vReflectivityColor", 4);
1536
- ubo.addUniform("vEmissiveColor", 3);
1537
- ubo.addUniform("vAmbientColor", 3);
1538
- ubo.addUniform("vDebugMode", 2);
1539
- ubo.addUniform("vMetallicReflectanceFactors", 4);
1540
- ubo.addUniform("vMetallicReflectanceInfos", 2);
1541
- ubo.addUniform("metallicReflectanceMatrix", 16);
1542
- ubo.addUniform("vReflectanceInfos", 2);
1543
- ubo.addUniform("reflectanceMatrix", 16);
1544
- ubo.addUniform("cameraInfo", 4);
1545
- ubo.addUniform("vTextureRepetitionHexTilingParams", 4);
1546
- PrepareUniformLayoutForIBL(ubo, true, true, true, true, true);
1547
- super.buildUniformLayout();
1548
- }
1549
- /**
1550
- * Binds the submesh data.
1551
- * @param world - The world matrix.
1552
- * @param mesh - The BJS mesh.
1553
- * @param subMesh - A submesh of the BJS mesh.
1554
- */
1555
- bindForSubMesh(world, mesh, subMesh) {
1556
- const scene = this.getScene();
1557
- const defines = subMesh.materialDefines;
1558
- if (!defines) {
1559
- return;
1560
- }
1561
- const effect = subMesh.effect;
1562
- if (!effect) {
1563
- return;
1564
- }
1565
- this._activeEffect = effect;
1566
- // Matrices Mesh.
1567
- mesh.getMeshUniformBuffer().bindToEffect(effect, "Mesh");
1568
- mesh.transferToEffect(world);
1569
- const engine = scene.getEngine();
1570
- // Binding unconditionally
1571
- this._uniformBuffer.bindToEffect(effect, "Material");
1572
- this.prePassConfiguration.bindForSubMesh(this._activeEffect, scene, mesh, world, this.isFrozen);
1573
- MaterialHelperGeometryRendering.Bind(engine.currentRenderPassId, this._activeEffect, mesh, world, this);
1574
- const camera = scene.activeCamera;
1575
- if (camera) {
1576
- this._uniformBuffer.updateFloat4("cameraInfo", camera.minZ, camera.maxZ, 0, 0);
1577
- }
1578
- else {
1579
- this._uniformBuffer.updateFloat4("cameraInfo", 0, 0, 0, 0);
1580
- }
1581
- const hexParams = this.textureRepetitionHexTilingParams;
1582
- this._uniformBuffer.updateFloat4("vTextureRepetitionHexTilingParams", hexParams[0], hexParams[1], hexParams[2], hexParams[3]);
1583
- this._eventInfo.subMesh = subMesh;
1584
- this._callbackPluginEventHardBindForSubMesh(this._eventInfo);
1585
- // Normal Matrix
1586
- if (defines.OBJECTSPACE_NORMALMAP) {
1587
- world.toNormalMatrix(this._normalMatrix);
1588
- this.bindOnlyNormalMatrix(this._normalMatrix);
1589
- }
1590
- const mustRebind = this._mustRebind(scene, effect, subMesh, mesh.visibility);
1591
- const needToAlwaysBindUniformBuffers = engine._features.needToAlwaysBindUniformBuffers;
1592
- // Bones
1593
- BindBonesParameters(mesh, this._activeEffect, this.prePassConfiguration);
1594
- // Vertex pulling
1595
- if (this._vertexPullingMetadata) {
1596
- BindVertexPullingUniforms(this._activeEffect, this._vertexPullingMetadata);
1597
- }
1598
- let reflectionTexture = null;
1599
- const ubo = this._uniformBuffer;
1600
- if (mustRebind) {
1601
- this.bindViewProjection(effect);
1602
- reflectionTexture = this._getReflectionTexture();
1603
- if (!ubo.useUbo || !this.isFrozen || !ubo.isSync || subMesh._drawWrapper._forceRebindOnNextCall) {
1604
- // Texture uniforms
1605
- if (scene.texturesEnabled) {
1606
- if (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled) {
1607
- ubo.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
1608
- BindTextureMatrix(this._albedoTexture, ubo, "albedo");
1609
- }
1610
- if (this._baseWeightTexture && MaterialFlags.BaseWeightTextureEnabled) {
1611
- ubo.updateFloat2("vBaseWeightInfos", this._baseWeightTexture.coordinatesIndex, this._baseWeightTexture.level);
1612
- BindTextureMatrix(this._baseWeightTexture, ubo, "baseWeight");
1613
- }
1614
- if (this._baseDiffuseRoughnessTexture && MaterialFlags.BaseDiffuseRoughnessTextureEnabled) {
1615
- ubo.updateFloat2("vBaseDiffuseRoughnessInfos", this._baseDiffuseRoughnessTexture.coordinatesIndex, this._baseDiffuseRoughnessTexture.level);
1616
- BindTextureMatrix(this._baseDiffuseRoughnessTexture, ubo, "baseDiffuseRoughness");
1617
- }
1618
- if (this._ambientTexture && MaterialFlags.AmbientTextureEnabled) {
1619
- ubo.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
1620
- BindTextureMatrix(this._ambientTexture, ubo, "ambient");
1489
+ const defines = new PBRMaterialDefines(this._eventInfo.defineNames);
1490
+ const effect = this._prepareEffect(mesh, mesh, defines, undefined, undefined, localOptions.useInstances, localOptions.clipPlane);
1491
+ if (this._onEffectCreatedObservable) {
1492
+ onCreatedEffectParameters.effect = effect;
1493
+ onCreatedEffectParameters.subMesh = null;
1494
+ this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters);
1621
1495
  }
1622
- if (this._opacityTexture && MaterialFlags.OpacityTextureEnabled) {
1623
- ubo.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
1624
- BindTextureMatrix(this._opacityTexture, ubo, "opacity");
1625
- }
1626
- if (this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled) {
1627
- ubo.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
1628
- BindTextureMatrix(this._emissiveTexture, ubo, "emissive");
1496
+ if (effect.isReady()) {
1497
+ if (onCompiled) {
1498
+ onCompiled(this);
1499
+ }
1629
1500
  }
1630
- if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled) {
1631
- ubo.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
1632
- BindTextureMatrix(this._lightmapTexture, ubo, "lightmap");
1501
+ else {
1502
+ effect.onCompileObservable.add(() => {
1503
+ if (onCompiled) {
1504
+ onCompiled(this);
1505
+ }
1506
+ });
1633
1507
  }
1634
- if (MaterialFlags.SpecularTextureEnabled) {
1635
- if (this._metallicTexture) {
1636
- ubo.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
1637
- BindTextureMatrix(this._metallicTexture, ubo, "reflectivity");
1508
+ };
1509
+ checkReady();
1510
+ }
1511
+ /**
1512
+ * Initializes the uniform buffer layout for the shader.
1513
+ */
1514
+ buildUniformLayout() {
1515
+ // Order is important !
1516
+ const ubo = this._uniformBuffer;
1517
+ ubo.addUniform("vAlbedoInfos", 2);
1518
+ ubo.addUniform("vBaseWeightInfos", 2);
1519
+ ubo.addUniform("vBaseDiffuseRoughnessInfos", 2);
1520
+ ubo.addUniform("vAmbientInfos", 4);
1521
+ ubo.addUniform("vOpacityInfos", 2);
1522
+ ubo.addUniform("vEmissiveInfos", 2);
1523
+ ubo.addUniform("vLightmapInfos", 2);
1524
+ ubo.addUniform("vReflectivityInfos", 3);
1525
+ ubo.addUniform("vMicroSurfaceSamplerInfos", 2);
1526
+ ubo.addUniform("vBumpInfos", 3);
1527
+ ubo.addUniform("albedoMatrix", 16);
1528
+ ubo.addUniform("baseWeightMatrix", 16);
1529
+ ubo.addUniform("baseDiffuseRoughnessMatrix", 16);
1530
+ ubo.addUniform("ambientMatrix", 16);
1531
+ ubo.addUniform("opacityMatrix", 16);
1532
+ ubo.addUniform("emissiveMatrix", 16);
1533
+ ubo.addUniform("lightmapMatrix", 16);
1534
+ ubo.addUniform("reflectivityMatrix", 16);
1535
+ ubo.addUniform("microSurfaceSamplerMatrix", 16);
1536
+ ubo.addUniform("bumpMatrix", 16);
1537
+ ubo.addUniform("vTangentSpaceParams", 2);
1538
+ ubo.addUniform("vAlbedoColor", 4);
1539
+ ubo.addUniform("baseWeight", 1);
1540
+ ubo.addUniform("baseDiffuseRoughness", 1);
1541
+ ubo.addUniform("vLightingIntensity", 4);
1542
+ ubo.addUniform("pointSize", 1);
1543
+ ubo.addUniform("vReflectivityColor", 4);
1544
+ ubo.addUniform("vEmissiveColor", 3);
1545
+ ubo.addUniform("vAmbientColor", 3);
1546
+ ubo.addUniform("vDebugMode", 2);
1547
+ ubo.addUniform("vMetallicReflectanceFactors", 4);
1548
+ ubo.addUniform("vMetallicReflectanceInfos", 2);
1549
+ ubo.addUniform("metallicReflectanceMatrix", 16);
1550
+ ubo.addUniform("vReflectanceInfos", 2);
1551
+ ubo.addUniform("reflectanceMatrix", 16);
1552
+ ubo.addUniform("cameraInfo", 4);
1553
+ ubo.addUniform("vTextureRepetitionHexTilingParams", 4);
1554
+ PrepareUniformLayoutForIBL(ubo, true, true, true, true, true);
1555
+ super.buildUniformLayout();
1556
+ }
1557
+ /**
1558
+ * Binds the submesh data.
1559
+ * @param world - The world matrix.
1560
+ * @param mesh - The BJS mesh.
1561
+ * @param subMesh - A submesh of the BJS mesh.
1562
+ */
1563
+ bindForSubMesh(world, mesh, subMesh) {
1564
+ const scene = this.getScene();
1565
+ const defines = subMesh.materialDefines;
1566
+ if (!defines) {
1567
+ return;
1568
+ }
1569
+ const effect = subMesh.effect;
1570
+ if (!effect) {
1571
+ return;
1572
+ }
1573
+ this._activeEffect = effect;
1574
+ // Matrices Mesh.
1575
+ mesh.getMeshUniformBuffer().bindToEffect(effect, "Mesh");
1576
+ mesh.transferToEffect(world);
1577
+ const engine = scene.getEngine();
1578
+ // Binding unconditionally
1579
+ this._uniformBuffer.bindToEffect(effect, "Material");
1580
+ this.prePassConfiguration.bindForSubMesh(this._activeEffect, scene, mesh, world, this.isFrozen);
1581
+ MaterialHelperGeometryRendering.Bind(engine.currentRenderPassId, this._activeEffect, mesh, world, this);
1582
+ const camera = scene.activeCamera;
1583
+ if (camera) {
1584
+ this._uniformBuffer.updateFloat4("cameraInfo", camera.minZ, camera.maxZ, 0, 0);
1585
+ }
1586
+ else {
1587
+ this._uniformBuffer.updateFloat4("cameraInfo", 0, 0, 0, 0);
1588
+ }
1589
+ const hexParams = this.textureRepetitionHexTilingParams;
1590
+ this._uniformBuffer.updateFloat4("vTextureRepetitionHexTilingParams", hexParams[0], hexParams[1], hexParams[2], hexParams[3]);
1591
+ this._eventInfo.subMesh = subMesh;
1592
+ this._callbackPluginEventHardBindForSubMesh(this._eventInfo);
1593
+ // Normal Matrix
1594
+ if (defines.OBJECTSPACE_NORMALMAP) {
1595
+ world.toNormalMatrix(this._normalMatrix);
1596
+ this.bindOnlyNormalMatrix(this._normalMatrix);
1597
+ }
1598
+ const mustRebind = this._mustRebind(scene, effect, subMesh, mesh.visibility);
1599
+ const needToAlwaysBindUniformBuffers = engine._features.needToAlwaysBindUniformBuffers;
1600
+ // Bones
1601
+ BindBonesParameters(mesh, this._activeEffect, this.prePassConfiguration);
1602
+ // Vertex pulling
1603
+ if (this._vertexPullingMetadata) {
1604
+ BindVertexPullingUniforms(this._activeEffect, this._vertexPullingMetadata);
1605
+ }
1606
+ let reflectionTexture = null;
1607
+ const ubo = this._uniformBuffer;
1608
+ if (mustRebind) {
1609
+ this.bindViewProjection(effect);
1610
+ reflectionTexture = this._getReflectionTexture();
1611
+ if (!ubo.useUbo || !this.isFrozen || !ubo.isSync || subMesh._drawWrapper._forceRebindOnNextCall) {
1612
+ // Texture uniforms
1613
+ if (scene.texturesEnabled) {
1614
+ if (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled) {
1615
+ ubo.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
1616
+ BindTextureMatrix(this._albedoTexture, ubo, "albedo");
1617
+ }
1618
+ if (this._baseWeightTexture && MaterialFlags.BaseWeightTextureEnabled) {
1619
+ ubo.updateFloat2("vBaseWeightInfos", this._baseWeightTexture.coordinatesIndex, this._baseWeightTexture.level);
1620
+ BindTextureMatrix(this._baseWeightTexture, ubo, "baseWeight");
1621
+ }
1622
+ if (this._baseDiffuseRoughnessTexture && MaterialFlags.BaseDiffuseRoughnessTextureEnabled) {
1623
+ ubo.updateFloat2("vBaseDiffuseRoughnessInfos", this._baseDiffuseRoughnessTexture.coordinatesIndex, this._baseDiffuseRoughnessTexture.level);
1624
+ BindTextureMatrix(this._baseDiffuseRoughnessTexture, ubo, "baseDiffuseRoughness");
1625
+ }
1626
+ if (this._ambientTexture && MaterialFlags.AmbientTextureEnabled) {
1627
+ ubo.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
1628
+ BindTextureMatrix(this._ambientTexture, ubo, "ambient");
1629
+ }
1630
+ if (this._opacityTexture && MaterialFlags.OpacityTextureEnabled) {
1631
+ ubo.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
1632
+ BindTextureMatrix(this._opacityTexture, ubo, "opacity");
1633
+ }
1634
+ if (this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled) {
1635
+ ubo.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
1636
+ BindTextureMatrix(this._emissiveTexture, ubo, "emissive");
1637
+ }
1638
+ if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled) {
1639
+ ubo.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
1640
+ BindTextureMatrix(this._lightmapTexture, ubo, "lightmap");
1641
+ }
1642
+ if (MaterialFlags.SpecularTextureEnabled) {
1643
+ if (this._metallicTexture) {
1644
+ ubo.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
1645
+ BindTextureMatrix(this._metallicTexture, ubo, "reflectivity");
1646
+ }
1647
+ else if (this._reflectivityTexture) {
1648
+ ubo.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
1649
+ BindTextureMatrix(this._reflectivityTexture, ubo, "reflectivity");
1650
+ }
1651
+ if (this._metallicReflectanceTexture) {
1652
+ ubo.updateFloat2("vMetallicReflectanceInfos", this._metallicReflectanceTexture.coordinatesIndex, this._metallicReflectanceTexture.level);
1653
+ BindTextureMatrix(this._metallicReflectanceTexture, ubo, "metallicReflectance");
1654
+ }
1655
+ if (this._reflectanceTexture && defines.REFLECTANCE) {
1656
+ ubo.updateFloat2("vReflectanceInfos", this._reflectanceTexture.coordinatesIndex, this._reflectanceTexture.level);
1657
+ BindTextureMatrix(this._reflectanceTexture, ubo, "reflectance");
1658
+ }
1659
+ if (this._microSurfaceTexture) {
1660
+ ubo.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
1661
+ BindTextureMatrix(this._microSurfaceTexture, ubo, "microSurfaceSampler");
1662
+ }
1663
+ }
1664
+ if (this._bumpTexture && engine.getCaps().standardDerivatives && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap) {
1665
+ ubo.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
1666
+ BindTextureMatrix(this._bumpTexture, ubo, "bump");
1667
+ if (scene._mirroredCameraPosition) {
1668
+ ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
1669
+ }
1670
+ else {
1671
+ ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
1672
+ }
1673
+ }
1674
+ BindIBLParameters(scene, defines, ubo, this._reflectionColor, reflectionTexture, this.realTimeFiltering, true, true, true, true, true);
1638
1675
  }
1639
- else if (this._reflectivityTexture) {
1640
- ubo.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
1641
- BindTextureMatrix(this._reflectivityTexture, ubo, "reflectivity");
1676
+ // Point size
1677
+ if (this.pointsCloud) {
1678
+ ubo.updateFloat("pointSize", this.pointSize);
1642
1679
  }
1643
- if (this._metallicReflectanceTexture) {
1644
- ubo.updateFloat2("vMetallicReflectanceInfos", this._metallicReflectanceTexture.coordinatesIndex, this._metallicReflectanceTexture.level);
1645
- BindTextureMatrix(this._metallicReflectanceTexture, ubo, "metallicReflectance");
1680
+ // Colors
1681
+ if (defines.METALLICWORKFLOW) {
1682
+ TmpColors.Color4[0].r = this._metallic === undefined || this._metallic === null ? 1 : this._metallic;
1683
+ TmpColors.Color4[0].g = this._roughness === undefined || this._roughness === null ? 1 : this._roughness;
1684
+ const ior = this.subSurface?._indexOfRefraction ?? 1.5;
1685
+ const outsideIOR = 1; // consider air as clear coat and other layers would remap in the shader.
1686
+ TmpColors.Color4[0].b = ior;
1687
+ // We are here deriving our default reflectance from a common value for none metallic surface.
1688
+ // Based of the schlick fresnel approximation model
1689
+ // for dielectrics.
1690
+ const f0 = Math.pow((ior - outsideIOR) / (ior + outsideIOR), 2);
1691
+ TmpColors.Color4[0].a = f0;
1692
+ ubo.updateDirectColor4("vReflectivityColor", TmpColors.Color4[0]);
1693
+ ubo.updateColor4("vMetallicReflectanceFactors", this._metallicReflectanceColor, this._metallicF0Factor);
1694
+ }
1695
+ else {
1696
+ ubo.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
1646
1697
  }
1647
- if (this._reflectanceTexture && defines.REFLECTANCE) {
1648
- ubo.updateFloat2("vReflectanceInfos", this._reflectanceTexture.coordinatesIndex, this._reflectanceTexture.level);
1649
- BindTextureMatrix(this._reflectanceTexture, ubo, "reflectance");
1698
+ ubo.updateColor3("vEmissiveColor", MaterialFlags.EmissiveTextureEnabled ? this._emissiveColor : Color3.BlackReadOnly);
1699
+ if (!defines.SS_REFRACTION && this.subSurface?._linkRefractionWithTransparency) {
1700
+ ubo.updateColor4("vAlbedoColor", this._albedoColor, 1);
1650
1701
  }
1651
- if (this._microSurfaceTexture) {
1652
- ubo.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
1653
- BindTextureMatrix(this._microSurfaceTexture, ubo, "microSurfaceSampler");
1702
+ else {
1703
+ ubo.updateColor4("vAlbedoColor", this._albedoColor, this.alpha);
1654
1704
  }
1705
+ ubo.updateFloat("baseWeight", this._baseWeight);
1706
+ ubo.updateFloat("baseDiffuseRoughness", this._baseDiffuseRoughness || 0.0);
1707
+ // Misc
1708
+ this._lightingInfos.x = this._directIntensity;
1709
+ this._lightingInfos.y = this._emissiveIntensity;
1710
+ this._lightingInfos.z = this._environmentIntensity * scene.environmentIntensity;
1711
+ this._lightingInfos.w = this._specularIntensity;
1712
+ ubo.updateVector4("vLightingIntensity", this._lightingInfos);
1713
+ // Colors
1714
+ scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
1715
+ ubo.updateColor3("vAmbientColor", this._globalAmbientColor);
1716
+ ubo.updateFloat2("vDebugMode", this.debugLimit, this.debugFactor);
1655
1717
  }
1656
- if (this._bumpTexture && engine.getCaps().standardDerivatives && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap) {
1657
- ubo.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
1658
- BindTextureMatrix(this._bumpTexture, ubo, "bump");
1659
- if (scene._mirroredCameraPosition) {
1660
- ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
1718
+ // Textures
1719
+ if (scene.texturesEnabled) {
1720
+ if (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled) {
1721
+ ubo.setTexture("albedoSampler", this._albedoTexture);
1661
1722
  }
1662
- else {
1663
- ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
1723
+ if (this._baseWeightTexture && MaterialFlags.BaseWeightTextureEnabled) {
1724
+ ubo.setTexture("baseWeightSampler", this._baseWeightTexture);
1725
+ }
1726
+ if (this._baseDiffuseRoughnessTexture && MaterialFlags.BaseDiffuseRoughnessTextureEnabled) {
1727
+ ubo.setTexture("baseDiffuseRoughnessSampler", this._baseDiffuseRoughnessTexture);
1728
+ }
1729
+ if (this._ambientTexture && MaterialFlags.AmbientTextureEnabled) {
1730
+ ubo.setTexture("ambientSampler", this._ambientTexture);
1731
+ }
1732
+ if (this._opacityTexture && MaterialFlags.OpacityTextureEnabled) {
1733
+ ubo.setTexture("opacitySampler", this._opacityTexture);
1734
+ }
1735
+ BindIBLSamplers(scene, defines, ubo, reflectionTexture, this.realTimeFiltering);
1736
+ if (defines.ENVIRONMENTBRDF) {
1737
+ ubo.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
1738
+ }
1739
+ if (this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled) {
1740
+ ubo.setTexture("emissiveSampler", this._emissiveTexture);
1741
+ }
1742
+ if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled) {
1743
+ ubo.setTexture("lightmapSampler", this._lightmapTexture);
1744
+ }
1745
+ if (MaterialFlags.SpecularTextureEnabled) {
1746
+ if (this._metallicTexture) {
1747
+ ubo.setTexture("reflectivitySampler", this._metallicTexture);
1748
+ }
1749
+ else if (this._reflectivityTexture) {
1750
+ ubo.setTexture("reflectivitySampler", this._reflectivityTexture);
1751
+ }
1752
+ if (this._metallicReflectanceTexture) {
1753
+ ubo.setTexture("metallicReflectanceSampler", this._metallicReflectanceTexture);
1754
+ }
1755
+ if (this._reflectanceTexture && defines.REFLECTANCE) {
1756
+ ubo.setTexture("reflectanceSampler", this._reflectanceTexture);
1757
+ }
1758
+ if (this._microSurfaceTexture) {
1759
+ ubo.setTexture("microSurfaceSampler", this._microSurfaceTexture);
1760
+ }
1761
+ }
1762
+ if (this._bumpTexture && engine.getCaps().standardDerivatives && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap) {
1763
+ ubo.setTexture("bumpSampler", this._bumpTexture);
1664
1764
  }
1665
1765
  }
1666
- BindIBLParameters(scene, defines, ubo, this._reflectionColor, reflectionTexture, this.realTimeFiltering, true, true, true, true, true);
1667
- }
1668
- // Point size
1669
- if (this.pointsCloud) {
1670
- ubo.updateFloat("pointSize", this.pointSize);
1671
- }
1672
- // Colors
1673
- if (defines.METALLICWORKFLOW) {
1674
- TmpColors.Color4[0].r = this._metallic === undefined || this._metallic === null ? 1 : this._metallic;
1675
- TmpColors.Color4[0].g = this._roughness === undefined || this._roughness === null ? 1 : this._roughness;
1676
- const ior = this.subSurface?._indexOfRefraction ?? 1.5;
1677
- const outsideIOR = 1; // consider air as clear coat and other layers would remap in the shader.
1678
- TmpColors.Color4[0].b = ior;
1679
- // We are here deriving our default reflectance from a common value for none metallic surface.
1680
- // Based of the schlick fresnel approximation model
1681
- // for dielectrics.
1682
- const f0 = Math.pow((ior - outsideIOR) / (ior + outsideIOR), 2);
1683
- TmpColors.Color4[0].a = f0;
1684
- ubo.updateDirectColor4("vReflectivityColor", TmpColors.Color4[0]);
1685
- ubo.updateColor4("vMetallicReflectanceFactors", this._metallicReflectanceColor, this._metallicF0Factor);
1766
+ // OIT with depth peeling
1767
+ if (this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(mesh)) {
1768
+ this.getScene().depthPeelingRenderer.bind(effect);
1769
+ }
1770
+ this._eventInfo.subMesh = subMesh;
1771
+ this._callbackPluginEventBindForSubMesh(this._eventInfo);
1772
+ // Clip plane
1773
+ BindClipPlane(this._activeEffect, this, scene);
1774
+ this.bindEyePosition(effect);
1686
1775
  }
1687
- else {
1688
- ubo.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
1776
+ else if (needToAlwaysBindUniformBuffers) {
1777
+ this._needToBindSceneUbo = true;
1689
1778
  }
1690
- ubo.updateColor3("vEmissiveColor", MaterialFlags.EmissiveTextureEnabled ? this._emissiveColor : Color3.BlackReadOnly);
1691
- if (!defines.SS_REFRACTION && this.subSurface?._linkRefractionWithTransparency) {
1692
- ubo.updateColor4("vAlbedoColor", this._albedoColor, 1);
1779
+ // Lights
1780
+ if ((mustRebind || !this.isFrozen || needToAlwaysBindUniformBuffers) && scene.lightsEnabled && !this._disableLighting) {
1781
+ BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights);
1693
1782
  }
1694
- else {
1695
- ubo.updateColor4("vAlbedoColor", this._albedoColor, this.alpha);
1696
- }
1697
- ubo.updateFloat("baseWeight", this._baseWeight);
1698
- ubo.updateFloat("baseDiffuseRoughness", this._baseDiffuseRoughness || 0.0);
1699
- // Misc
1700
- this._lightingInfos.x = this._directIntensity;
1701
- this._lightingInfos.y = this._emissiveIntensity;
1702
- this._lightingInfos.z = this._environmentIntensity * scene.environmentIntensity;
1703
- this._lightingInfos.w = this._specularIntensity;
1704
- ubo.updateVector4("vLightingIntensity", this._lightingInfos);
1705
- // Colors
1706
- scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
1707
- ubo.updateColor3("vAmbientColor", this._globalAmbientColor);
1708
- ubo.updateFloat2("vDebugMode", this.debugLimit, this.debugFactor);
1783
+ if (mustRebind || !this.isFrozen) {
1784
+ // View
1785
+ if ((scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) ||
1786
+ reflectionTexture ||
1787
+ this.subSurface.refractionTexture ||
1788
+ mesh.receiveShadows ||
1789
+ defines.PREPASS ||
1790
+ defines["CLUSTLIGHT_BATCH"]) {
1791
+ this.bindView(effect);
1792
+ }
1793
+ // Fog
1794
+ BindFogParameters(scene, mesh, this._activeEffect, true);
1795
+ // Morph targets
1796
+ if (defines.NUM_MORPH_INFLUENCERS) {
1797
+ BindMorphTargetParameters(mesh, this._activeEffect);
1798
+ }
1799
+ if (defines.BAKED_VERTEX_ANIMATION_TEXTURE) {
1800
+ mesh.bakedVertexAnimationManager?.bind(effect, defines.INSTANCES);
1801
+ }
1802
+ // image processing
1803
+ this._imageProcessingConfiguration.bind(this._activeEffect);
1804
+ // Log. depth
1805
+ BindLogDepth(defines, this._activeEffect, scene);
1806
+ }
1807
+ this._afterBind(mesh, this._activeEffect, subMesh);
1808
+ ubo.update();
1709
1809
  }
1710
- // Textures
1711
- if (scene.texturesEnabled) {
1712
- if (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled) {
1713
- ubo.setTexture("albedoSampler", this._albedoTexture);
1810
+ /**
1811
+ * Returns the animatable textures.
1812
+ * If material have animatable metallic texture, then reflectivity texture will not be returned, even if it has animations.
1813
+ * @returns - Array of animatable textures.
1814
+ */
1815
+ getAnimatables() {
1816
+ const results = super.getAnimatables();
1817
+ if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
1818
+ results.push(this._albedoTexture);
1714
1819
  }
1715
- if (this._baseWeightTexture && MaterialFlags.BaseWeightTextureEnabled) {
1716
- ubo.setTexture("baseWeightSampler", this._baseWeightTexture);
1820
+ if (this._baseWeightTexture && this._baseWeightTexture.animations && this._baseWeightTexture.animations.length > 0) {
1821
+ results.push(this._baseWeightTexture);
1717
1822
  }
1718
- if (this._baseDiffuseRoughnessTexture && MaterialFlags.BaseDiffuseRoughnessTextureEnabled) {
1719
- ubo.setTexture("baseDiffuseRoughnessSampler", this._baseDiffuseRoughnessTexture);
1823
+ if (this._baseDiffuseRoughnessTexture && this._baseDiffuseRoughnessTexture.animations && this._baseDiffuseRoughnessTexture.animations.length > 0) {
1824
+ results.push(this._baseDiffuseRoughnessTexture);
1720
1825
  }
1721
- if (this._ambientTexture && MaterialFlags.AmbientTextureEnabled) {
1722
- ubo.setTexture("ambientSampler", this._ambientTexture);
1826
+ if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
1827
+ results.push(this._ambientTexture);
1723
1828
  }
1724
- if (this._opacityTexture && MaterialFlags.OpacityTextureEnabled) {
1725
- ubo.setTexture("opacitySampler", this._opacityTexture);
1829
+ if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
1830
+ results.push(this._opacityTexture);
1726
1831
  }
1727
- BindIBLSamplers(scene, defines, ubo, reflectionTexture, this.realTimeFiltering);
1728
- if (defines.ENVIRONMENTBRDF) {
1729
- ubo.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
1832
+ if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
1833
+ results.push(this._reflectionTexture);
1730
1834
  }
1731
- if (this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled) {
1732
- ubo.setTexture("emissiveSampler", this._emissiveTexture);
1835
+ if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
1836
+ results.push(this._emissiveTexture);
1733
1837
  }
1734
- if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled) {
1735
- ubo.setTexture("lightmapSampler", this._lightmapTexture);
1838
+ if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
1839
+ results.push(this._metallicTexture);
1736
1840
  }
1737
- if (MaterialFlags.SpecularTextureEnabled) {
1738
- if (this._metallicTexture) {
1739
- ubo.setTexture("reflectivitySampler", this._metallicTexture);
1740
- }
1741
- else if (this._reflectivityTexture) {
1742
- ubo.setTexture("reflectivitySampler", this._reflectivityTexture);
1743
- }
1744
- if (this._metallicReflectanceTexture) {
1745
- ubo.setTexture("metallicReflectanceSampler", this._metallicReflectanceTexture);
1746
- }
1747
- if (this._reflectanceTexture && defines.REFLECTANCE) {
1748
- ubo.setTexture("reflectanceSampler", this._reflectanceTexture);
1749
- }
1750
- if (this._microSurfaceTexture) {
1751
- ubo.setTexture("microSurfaceSampler", this._microSurfaceTexture);
1752
- }
1841
+ else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
1842
+ results.push(this._reflectivityTexture);
1843
+ }
1844
+ if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
1845
+ results.push(this._bumpTexture);
1753
1846
  }
1754
- if (this._bumpTexture && engine.getCaps().standardDerivatives && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap) {
1755
- ubo.setTexture("bumpSampler", this._bumpTexture);
1847
+ if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
1848
+ results.push(this._lightmapTexture);
1756
1849
  }
1850
+ if (this._metallicReflectanceTexture && this._metallicReflectanceTexture.animations && this._metallicReflectanceTexture.animations.length > 0) {
1851
+ results.push(this._metallicReflectanceTexture);
1852
+ }
1853
+ if (this._reflectanceTexture && this._reflectanceTexture.animations && this._reflectanceTexture.animations.length > 0) {
1854
+ results.push(this._reflectanceTexture);
1855
+ }
1856
+ if (this._microSurfaceTexture && this._microSurfaceTexture.animations && this._microSurfaceTexture.animations.length > 0) {
1857
+ results.push(this._microSurfaceTexture);
1858
+ }
1859
+ return results;
1757
1860
  }
1758
- // OIT with depth peeling
1759
- if (this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(mesh)) {
1760
- this.getScene().depthPeelingRenderer.bind(effect);
1861
+ /**
1862
+ * Returns the texture used for reflections.
1863
+ * @returns - Reflection texture if present. Otherwise, returns the environment texture.
1864
+ */
1865
+ _getReflectionTexture() {
1866
+ if (this._reflectionTexture) {
1867
+ return this._reflectionTexture;
1868
+ }
1869
+ return this.getScene().environmentTexture;
1761
1870
  }
1762
- this._eventInfo.subMesh = subMesh;
1763
- this._callbackPluginEventBindForSubMesh(this._eventInfo);
1764
- // Clip plane
1765
- BindClipPlane(this._activeEffect, this, scene);
1766
- this.bindEyePosition(effect);
1767
- }
1768
- else if (needToAlwaysBindUniformBuffers) {
1769
- this._needToBindSceneUbo = true;
1770
- }
1771
- // Lights
1772
- if ((mustRebind || !this.isFrozen || needToAlwaysBindUniformBuffers) && scene.lightsEnabled && !this._disableLighting) {
1773
- BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights);
1774
- }
1775
- if (mustRebind || !this.isFrozen) {
1776
- // View
1777
- if ((scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) ||
1778
- reflectionTexture ||
1779
- this.subSurface.refractionTexture ||
1780
- mesh.receiveShadows ||
1781
- defines.PREPASS ||
1782
- defines["CLUSTLIGHT_BATCH"]) {
1783
- this.bindView(effect);
1871
+ /**
1872
+ * Returns an array of the actively used textures.
1873
+ * @returns - Array of BaseTextures
1874
+ */
1875
+ getActiveTextures() {
1876
+ const activeTextures = super.getActiveTextures();
1877
+ if (this._albedoTexture) {
1878
+ activeTextures.push(this._albedoTexture);
1879
+ }
1880
+ if (this._baseWeightTexture) {
1881
+ activeTextures.push(this._baseWeightTexture);
1882
+ }
1883
+ if (this._baseDiffuseRoughnessTexture) {
1884
+ activeTextures.push(this._baseDiffuseRoughnessTexture);
1885
+ }
1886
+ if (this._ambientTexture) {
1887
+ activeTextures.push(this._ambientTexture);
1888
+ }
1889
+ if (this._opacityTexture) {
1890
+ activeTextures.push(this._opacityTexture);
1891
+ }
1892
+ if (this._reflectionTexture) {
1893
+ activeTextures.push(this._reflectionTexture);
1894
+ }
1895
+ if (this._emissiveTexture) {
1896
+ activeTextures.push(this._emissiveTexture);
1897
+ }
1898
+ if (this._reflectivityTexture) {
1899
+ activeTextures.push(this._reflectivityTexture);
1900
+ }
1901
+ if (this._metallicTexture) {
1902
+ activeTextures.push(this._metallicTexture);
1903
+ }
1904
+ if (this._metallicReflectanceTexture) {
1905
+ activeTextures.push(this._metallicReflectanceTexture);
1906
+ }
1907
+ if (this._reflectanceTexture) {
1908
+ activeTextures.push(this._reflectanceTexture);
1909
+ }
1910
+ if (this._microSurfaceTexture) {
1911
+ activeTextures.push(this._microSurfaceTexture);
1912
+ }
1913
+ if (this._bumpTexture) {
1914
+ activeTextures.push(this._bumpTexture);
1915
+ }
1916
+ if (this._lightmapTexture) {
1917
+ activeTextures.push(this._lightmapTexture);
1918
+ }
1919
+ return activeTextures;
1784
1920
  }
1785
- // Fog
1786
- BindFogParameters(scene, mesh, this._activeEffect, true);
1787
- // Morph targets
1788
- if (defines.NUM_MORPH_INFLUENCERS) {
1789
- BindMorphTargetParameters(mesh, this._activeEffect);
1921
+ /**
1922
+ * Checks to see if a texture is used in the material.
1923
+ * @param texture - Base texture to use.
1924
+ * @returns - Boolean specifying if a texture is used in the material.
1925
+ */
1926
+ hasTexture(texture) {
1927
+ if (super.hasTexture(texture)) {
1928
+ return true;
1929
+ }
1930
+ if (this._albedoTexture === texture) {
1931
+ return true;
1932
+ }
1933
+ if (this._baseWeightTexture === texture) {
1934
+ return true;
1935
+ }
1936
+ if (this._baseDiffuseRoughnessTexture === texture) {
1937
+ return true;
1938
+ }
1939
+ if (this._ambientTexture === texture) {
1940
+ return true;
1941
+ }
1942
+ if (this._opacityTexture === texture) {
1943
+ return true;
1944
+ }
1945
+ if (this._reflectionTexture === texture) {
1946
+ return true;
1947
+ }
1948
+ if (this._emissiveTexture === texture) {
1949
+ return true;
1950
+ }
1951
+ if (this._reflectivityTexture === texture) {
1952
+ return true;
1953
+ }
1954
+ if (this._metallicTexture === texture) {
1955
+ return true;
1956
+ }
1957
+ if (this._metallicReflectanceTexture === texture) {
1958
+ return true;
1959
+ }
1960
+ if (this._reflectanceTexture === texture) {
1961
+ return true;
1962
+ }
1963
+ if (this._microSurfaceTexture === texture) {
1964
+ return true;
1965
+ }
1966
+ if (this._bumpTexture === texture) {
1967
+ return true;
1968
+ }
1969
+ if (this._lightmapTexture === texture) {
1970
+ return true;
1971
+ }
1972
+ return false;
1790
1973
  }
1791
- if (defines.BAKED_VERTEX_ANIMATION_TEXTURE) {
1792
- mesh.bakedVertexAnimationManager?.bind(effect, defines.INSTANCES);
1974
+ /**
1975
+ * Sets the required values to the prepass renderer.
1976
+ * It can't be sets when subsurface scattering of this material is disabled.
1977
+ * When scene have ability to enable subsurface prepass effect, it will enable.
1978
+ * @returns - If prepass is enabled or not.
1979
+ */
1980
+ setPrePassRenderer() {
1981
+ if (!this.subSurface?.isScatteringEnabled) {
1982
+ return false;
1983
+ }
1984
+ const subSurfaceConfiguration = this.getScene().enableSubSurfaceForPrePass();
1985
+ if (subSurfaceConfiguration) {
1986
+ subSurfaceConfiguration.enabled = true;
1987
+ }
1988
+ return true;
1793
1989
  }
1794
- // image processing
1795
- this._imageProcessingConfiguration.bind(this._activeEffect);
1796
- // Log. depth
1797
- BindLogDepth(defines, this._activeEffect, scene);
1798
- }
1799
- this._afterBind(mesh, this._activeEffect, subMesh);
1800
- ubo.update();
1801
- }
1802
- /**
1803
- * Returns the animatable textures.
1804
- * If material have animatable metallic texture, then reflectivity texture will not be returned, even if it has animations.
1805
- * @returns - Array of animatable textures.
1806
- */
1807
- getAnimatables() {
1808
- const results = super.getAnimatables();
1809
- if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
1810
- results.push(this._albedoTexture);
1811
- }
1812
- if (this._baseWeightTexture && this._baseWeightTexture.animations && this._baseWeightTexture.animations.length > 0) {
1813
- results.push(this._baseWeightTexture);
1814
- }
1815
- if (this._baseDiffuseRoughnessTexture && this._baseDiffuseRoughnessTexture.animations && this._baseDiffuseRoughnessTexture.animations.length > 0) {
1816
- results.push(this._baseDiffuseRoughnessTexture);
1817
- }
1818
- if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
1819
- results.push(this._ambientTexture);
1820
- }
1821
- if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
1822
- results.push(this._opacityTexture);
1823
- }
1824
- if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
1825
- results.push(this._reflectionTexture);
1826
- }
1827
- if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
1828
- results.push(this._emissiveTexture);
1829
- }
1830
- if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
1831
- results.push(this._metallicTexture);
1832
- }
1833
- else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
1834
- results.push(this._reflectivityTexture);
1835
- }
1836
- if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
1837
- results.push(this._bumpTexture);
1838
- }
1839
- if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
1840
- results.push(this._lightmapTexture);
1841
- }
1842
- if (this._metallicReflectanceTexture && this._metallicReflectanceTexture.animations && this._metallicReflectanceTexture.animations.length > 0) {
1843
- results.push(this._metallicReflectanceTexture);
1844
- }
1845
- if (this._reflectanceTexture && this._reflectanceTexture.animations && this._reflectanceTexture.animations.length > 0) {
1846
- results.push(this._reflectanceTexture);
1847
- }
1848
- if (this._microSurfaceTexture && this._microSurfaceTexture.animations && this._microSurfaceTexture.animations.length > 0) {
1849
- results.push(this._microSurfaceTexture);
1850
- }
1851
- return results;
1852
- }
1853
- /**
1854
- * Returns the texture used for reflections.
1855
- * @returns - Reflection texture if present. Otherwise, returns the environment texture.
1856
- */
1857
- _getReflectionTexture() {
1858
- if (this._reflectionTexture) {
1859
- return this._reflectionTexture;
1860
- }
1861
- return this.getScene().environmentTexture;
1862
- }
1863
- /**
1864
- * Returns an array of the actively used textures.
1865
- * @returns - Array of BaseTextures
1866
- */
1867
- getActiveTextures() {
1868
- const activeTextures = super.getActiveTextures();
1869
- if (this._albedoTexture) {
1870
- activeTextures.push(this._albedoTexture);
1871
- }
1872
- if (this._baseWeightTexture) {
1873
- activeTextures.push(this._baseWeightTexture);
1874
- }
1875
- if (this._baseDiffuseRoughnessTexture) {
1876
- activeTextures.push(this._baseDiffuseRoughnessTexture);
1877
- }
1878
- if (this._ambientTexture) {
1879
- activeTextures.push(this._ambientTexture);
1880
- }
1881
- if (this._opacityTexture) {
1882
- activeTextures.push(this._opacityTexture);
1883
- }
1884
- if (this._reflectionTexture) {
1885
- activeTextures.push(this._reflectionTexture);
1886
- }
1887
- if (this._emissiveTexture) {
1888
- activeTextures.push(this._emissiveTexture);
1889
- }
1890
- if (this._reflectivityTexture) {
1891
- activeTextures.push(this._reflectivityTexture);
1892
- }
1893
- if (this._metallicTexture) {
1894
- activeTextures.push(this._metallicTexture);
1895
- }
1896
- if (this._metallicReflectanceTexture) {
1897
- activeTextures.push(this._metallicReflectanceTexture);
1898
- }
1899
- if (this._reflectanceTexture) {
1900
- activeTextures.push(this._reflectanceTexture);
1901
- }
1902
- if (this._microSurfaceTexture) {
1903
- activeTextures.push(this._microSurfaceTexture);
1904
- }
1905
- if (this._bumpTexture) {
1906
- activeTextures.push(this._bumpTexture);
1907
- }
1908
- if (this._lightmapTexture) {
1909
- activeTextures.push(this._lightmapTexture);
1910
- }
1911
- return activeTextures;
1912
- }
1913
- /**
1914
- * Checks to see if a texture is used in the material.
1915
- * @param texture - Base texture to use.
1916
- * @returns - Boolean specifying if a texture is used in the material.
1917
- */
1918
- hasTexture(texture) {
1919
- if (super.hasTexture(texture)) {
1920
- return true;
1921
- }
1922
- if (this._albedoTexture === texture) {
1923
- return true;
1924
- }
1925
- if (this._baseWeightTexture === texture) {
1926
- return true;
1927
- }
1928
- if (this._baseDiffuseRoughnessTexture === texture) {
1929
- return true;
1930
- }
1931
- if (this._ambientTexture === texture) {
1932
- return true;
1933
- }
1934
- if (this._opacityTexture === texture) {
1935
- return true;
1936
- }
1937
- if (this._reflectionTexture === texture) {
1938
- return true;
1939
- }
1940
- if (this._emissiveTexture === texture) {
1941
- return true;
1942
- }
1943
- if (this._reflectivityTexture === texture) {
1944
- return true;
1945
- }
1946
- if (this._metallicTexture === texture) {
1947
- return true;
1948
- }
1949
- if (this._metallicReflectanceTexture === texture) {
1950
- return true;
1951
- }
1952
- if (this._reflectanceTexture === texture) {
1953
- return true;
1954
- }
1955
- if (this._microSurfaceTexture === texture) {
1956
- return true;
1957
- }
1958
- if (this._bumpTexture === texture) {
1959
- return true;
1960
- }
1961
- if (this._lightmapTexture === texture) {
1962
- return true;
1963
- }
1964
- return false;
1965
- }
1966
- /**
1967
- * Sets the required values to the prepass renderer.
1968
- * It can't be sets when subsurface scattering of this material is disabled.
1969
- * When scene have ability to enable subsurface prepass effect, it will enable.
1970
- * @returns - If prepass is enabled or not.
1971
- */
1972
- setPrePassRenderer() {
1973
- if (!this.subSurface?.isScatteringEnabled) {
1974
- return false;
1975
- }
1976
- const subSurfaceConfiguration = this.getScene().enableSubSurfaceForPrePass();
1977
- if (subSurfaceConfiguration) {
1978
- subSurfaceConfiguration.enabled = true;
1979
- }
1980
- return true;
1981
- }
1982
- /**
1983
- * Disposes the resources of the material.
1984
- * @param forceDisposeEffect - Forces the disposal of effects.
1985
- * @param forceDisposeTextures - Forces the disposal of all textures.
1986
- */
1987
- dispose(forceDisposeEffect, forceDisposeTextures) {
1988
- this._breakShaderLoadedCheck = true;
1989
- if (forceDisposeTextures) {
1990
- if (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture) {
1991
- this._environmentBRDFTexture.dispose();
1990
+ /**
1991
+ * Disposes the resources of the material.
1992
+ * @param forceDisposeEffect - Forces the disposal of effects.
1993
+ * @param forceDisposeTextures - Forces the disposal of all textures.
1994
+ */
1995
+ dispose(forceDisposeEffect, forceDisposeTextures) {
1996
+ this._breakShaderLoadedCheck = true;
1997
+ if (forceDisposeTextures) {
1998
+ if (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture) {
1999
+ this._environmentBRDFTexture.dispose();
2000
+ }
2001
+ this._albedoTexture?.dispose();
2002
+ this._baseWeightTexture?.dispose();
2003
+ this._baseDiffuseRoughnessTexture?.dispose();
2004
+ this._ambientTexture?.dispose();
2005
+ this._opacityTexture?.dispose();
2006
+ this._reflectionTexture?.dispose();
2007
+ this._emissiveTexture?.dispose();
2008
+ this._metallicTexture?.dispose();
2009
+ this._reflectivityTexture?.dispose();
2010
+ this._bumpTexture?.dispose();
2011
+ this._lightmapTexture?.dispose();
2012
+ this._metallicReflectanceTexture?.dispose();
2013
+ this._reflectanceTexture?.dispose();
2014
+ this._microSurfaceTexture?.dispose();
2015
+ }
2016
+ this._renderTargets.dispose();
2017
+ if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
2018
+ this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
2019
+ }
2020
+ super.dispose(forceDisposeEffect, forceDisposeTextures);
1992
2021
  }
1993
- this._albedoTexture?.dispose();
1994
- this._baseWeightTexture?.dispose();
1995
- this._baseDiffuseRoughnessTexture?.dispose();
1996
- this._ambientTexture?.dispose();
1997
- this._opacityTexture?.dispose();
1998
- this._reflectionTexture?.dispose();
1999
- this._emissiveTexture?.dispose();
2000
- this._metallicTexture?.dispose();
2001
- this._reflectivityTexture?.dispose();
2002
- this._bumpTexture?.dispose();
2003
- this._lightmapTexture?.dispose();
2004
- this._metallicReflectanceTexture?.dispose();
2005
- this._reflectanceTexture?.dispose();
2006
- this._microSurfaceTexture?.dispose();
2007
- }
2008
- this._renderTargets.dispose();
2009
- if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
2010
- this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
2011
- }
2012
- super.dispose(forceDisposeEffect, forceDisposeTextures);
2013
- }
2014
- }
2015
- /**
2016
- * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
2017
- */
2018
- PBRBaseMaterial.PBRMATERIAL_OPAQUE = Material.MATERIAL_OPAQUE;
2019
- /**
2020
- * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
2021
- */
2022
- PBRBaseMaterial.PBRMATERIAL_ALPHATEST = Material.MATERIAL_ALPHATEST;
2023
- /**
2024
- * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
2025
- */
2026
- PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = Material.MATERIAL_ALPHABLEND;
2027
- /**
2028
- * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
2029
- * They are also discarded below the alpha cutoff threshold to improve performances.
2030
- */
2031
- PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = Material.MATERIAL_ALPHATESTANDBLEND;
2032
- /**
2033
- * Defines the default value of how much AO map is occluding the analytical lights
2034
- * (point spot...).
2035
- */
2036
- PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0;
2037
- /**
2038
- * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
2039
- */
2040
- PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
2041
- /**
2042
- * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
2043
- * to enhance interoperability with other engines.
2044
- */
2045
- PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
2046
- /**
2047
- * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
2048
- * to enhance interoperability with other materials.
2049
- */
2050
- PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
2051
- /**
2052
- * Force all the PBR materials to compile to glsl even on WebGPU engines.
2053
- * False by default. This is mostly meant for backward compatibility.
2054
- */
2055
- PBRBaseMaterial.ForceGLSL = false;
2056
- __decorate([
2057
- expandToProperty("_markAllSubMeshesAsMiscDirty")
2058
- ], PBRBaseMaterial.prototype, "debugMode", void 0);
2022
+ },
2023
+ _PBRBaseMaterial_debugMode_accessor_storage = new WeakMap(),
2024
+ (() => {
2025
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
2026
+ _debugMode_decorators = [expandToProperty("_markAllSubMeshesAsMiscDirty")];
2027
+ __esDecorate(_a, null, _debugMode_decorators, { kind: "accessor", name: "debugMode", static: false, private: false, access: { has: obj => "debugMode" in obj, get: obj => obj.debugMode, set: (obj, value) => { obj.debugMode = value; } }, metadata: _metadata }, _debugMode_initializers, _debugMode_extraInitializers);
2028
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
2029
+ })(),
2030
+ /**
2031
+ * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
2032
+ */
2033
+ _a.PBRMATERIAL_OPAQUE = Material.MATERIAL_OPAQUE,
2034
+ /**
2035
+ * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
2036
+ */
2037
+ _a.PBRMATERIAL_ALPHATEST = Material.MATERIAL_ALPHATEST,
2038
+ /**
2039
+ * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
2040
+ */
2041
+ _a.PBRMATERIAL_ALPHABLEND = Material.MATERIAL_ALPHABLEND,
2042
+ /**
2043
+ * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
2044
+ * They are also discarded below the alpha cutoff threshold to improve performances.
2045
+ */
2046
+ _a.PBRMATERIAL_ALPHATESTANDBLEND = Material.MATERIAL_ALPHATESTANDBLEND,
2047
+ /**
2048
+ * Defines the default value of how much AO map is occluding the analytical lights
2049
+ * (point spot...).
2050
+ */
2051
+ _a.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0,
2052
+ /**
2053
+ * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
2054
+ */
2055
+ _a.LIGHTFALLOFF_PHYSICAL = 0,
2056
+ /**
2057
+ * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
2058
+ * to enhance interoperability with other engines.
2059
+ */
2060
+ _a.LIGHTFALLOFF_GLTF = 1,
2061
+ /**
2062
+ * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
2063
+ * to enhance interoperability with other materials.
2064
+ */
2065
+ _a.LIGHTFALLOFF_STANDARD = 2,
2066
+ /**
2067
+ * Force all the PBR materials to compile to glsl even on WebGPU engines.
2068
+ * False by default. This is mostly meant for backward compatibility.
2069
+ */
2070
+ _a.ForceGLSL = false,
2071
+ _a;
2072
+ })();
2073
+ export { PBRBaseMaterial };
2059
2074
  // #region GENERATED_SIDE_EFFECT_STUBS — do not edit, regenerate with `npm run generate:side-effect-stubs`
2060
2075
  import { _MissingSideEffectProperty } from "../../Misc/devTools.js";
2061
2076
  if (!Object.getOwnPropertyDescriptor(PBRBaseMaterial.prototype, "decalMap")) {