@onerjs/core 8.53.4 → 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 { __esDecorate, __runInitializers } from "../../../../tslib.es6.js";
3
3
  import { NodeMaterialBlock } from "../../nodeMaterialBlock.js";
4
4
  import { NodeMaterialBlockConnectionPointTypes } from "../../Enums/nodeMaterialBlockConnectionPointTypes.js";
5
5
  import { NodeMaterialBlockTargets } from "../../Enums/nodeMaterialBlockTargets.js";
@@ -40,682 +40,752 @@ const MapOutputToVariable = {
40
40
  * Block used to implement the PBR metallic/roughness model
41
41
  * @see https://playground.babylonjs.com/#D8AK3Z#80
42
42
  */
43
- export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
44
- static _OnGenerateOnlyFragmentCodeChanged(block, _propertyName) {
45
- const that = block;
46
- if (that.worldPosition.isConnected || that.worldNormal.isConnected) {
47
- that.generateOnlyFragmentCode = !that.generateOnlyFragmentCode;
48
- Logger.Error("The worldPosition and worldNormal inputs must not be connected to be able to switch!");
49
- return false;
50
- }
51
- that._setTarget();
52
- return true;
53
- }
54
- _setTarget() {
55
- this._setInitialTarget(this.generateOnlyFragmentCode ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.VertexAndFragment);
56
- this.getInputByName("worldPosition").target = this.generateOnlyFragmentCode ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.Vertex;
57
- this.getInputByName("worldNormal").target = this.generateOnlyFragmentCode ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.Vertex;
58
- }
59
- /**
60
- * Create a new ReflectionBlock
61
- * @param name defines the block name
62
- */
63
- constructor(name) {
64
- super(name, NodeMaterialBlockTargets.VertexAndFragment);
65
- this._environmentBRDFTexture = null;
66
- this._metallicReflectanceColor = Color3.White();
67
- this._metallicF0Factor = 1;
68
- /**
69
- * Intensity of the direct lights e.g. the four lights available in your scene.
70
- * This impacts both the direct diffuse and specular highlights.
71
- */
72
- this.directIntensity = 1.0;
73
- /**
74
- * Intensity of the environment e.g. how much the environment will light the object
75
- * either through harmonics for rough material or through the reflection for shiny ones.
76
- */
77
- this.environmentIntensity = 1.0;
78
- /**
79
- * This is a special control allowing the reduction of the specular highlights coming from the
80
- * four lights of the scene. Those highlights may not be needed in full environment lighting.
81
- */
82
- this.specularIntensity = 1.0;
83
- /**
84
- * Defines the falloff type used in this material.
85
- * It by default is Physical.
86
- */
87
- this.lightFalloff = 0;
88
- /**
89
- * Specifies that alpha test should be used
90
- */
91
- this.useAlphaTest = false;
92
- /**
93
- * Defines the alpha limits in alpha test mode.
94
- */
95
- this.alphaTestCutoff = 0.5;
96
- /**
97
- * Specifies that alpha blending should be used
98
- */
99
- this.useAlphaBlending = false;
100
- /**
101
- * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
102
- * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
103
- */
104
- this.useRadianceOverAlpha = true;
105
- /**
106
- * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
107
- * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
108
- */
109
- this.useSpecularOverAlpha = true;
110
- /**
111
- * Enables specular anti aliasing in the PBR shader.
112
- * It will both interacts on the Geometry for analytical and IBL lighting.
113
- * It also prefilter the roughness map based on the bump values.
114
- */
115
- this.enableSpecularAntiAliasing = false;
116
- /**
117
- * Enables realtime filtering on the texture.
118
- */
119
- this.realTimeFiltering = false;
120
- /**
121
- * Quality switch for realtime filtering
122
- */
123
- this.realTimeFilteringQuality = 8;
124
- /**
125
- * Base Diffuse Model
126
- */
127
- this.baseDiffuseModel = 0;
128
- /**
129
- * Defines if the material uses energy conservation.
130
- */
131
- this.useEnergyConservation = true;
132
- /**
133
- * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
134
- * too much the area relying on ambient texture to define their ambient occlusion.
135
- */
136
- this.useRadianceOcclusion = true;
137
- /**
138
- * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
139
- * makes the reflect vector face the model (under horizon).
140
- */
141
- this.useHorizonOcclusion = true;
142
- /**
143
- * If set to true, no lighting calculations will be applied.
144
- */
145
- this.unlit = false;
146
- /**
147
- * Force normal to face away from face.
148
- */
149
- this.forceNormalForward = false;
150
- /** Indicates that no code should be generated in the vertex shader. Can be useful in some specific circumstances (like when doing ray marching for eg) */
151
- this.generateOnlyFragmentCode = false;
152
- /**
153
- * Defines the material debug mode.
154
- * It helps seeing only some components of the material while troubleshooting.
155
- */
156
- this.debugMode = 0;
157
- /**
158
- * Specify from where on screen the debug mode should start.
159
- * The value goes from -1 (full screen) to 1 (not visible)
160
- * It helps with side by side comparison against the final render
161
- * This defaults to 0
162
- */
163
- this.debugLimit = 0;
164
- /**
165
- * As the default viewing range might not be enough (if the ambient is really small for instance)
166
- * You can use the factor to better multiply the final value.
167
- */
168
- this.debugFactor = 1;
169
- this._isUnique = true;
170
- this.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, false, NodeMaterialBlockTargets.Vertex);
171
- this.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, false, NodeMaterialBlockTargets.Vertex);
172
- this.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, false);
173
- this.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3, false, NodeMaterialBlockTargets.Fragment);
174
- this.registerInput("perturbedNormal", NodeMaterialBlockConnectionPointTypes.Vector4, true, NodeMaterialBlockTargets.Fragment);
175
- this.registerInput("baseColor", NodeMaterialBlockConnectionPointTypes.Color3, true, NodeMaterialBlockTargets.Fragment);
176
- this.registerInput("metallic", NodeMaterialBlockConnectionPointTypes.Float, false, NodeMaterialBlockTargets.Fragment);
177
- this.registerInput("roughness", NodeMaterialBlockConnectionPointTypes.Float, false, NodeMaterialBlockTargets.Fragment);
178
- this.registerInput("ambientOcc", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);
179
- this.registerInput("opacity", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);
180
- this.registerInput("indexOfRefraction", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);
181
- this.registerInput("ambientColor", NodeMaterialBlockConnectionPointTypes.Color3, true, NodeMaterialBlockTargets.Fragment);
182
- this.registerInput("reflection", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("reflection", this, 0 /* NodeMaterialConnectionPointDirection.Input */, ReflectionBlock, "ReflectionBlock"));
183
- this.registerInput("clearcoat", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("clearcoat", this, 0 /* NodeMaterialConnectionPointDirection.Input */, ClearCoatBlock, "ClearCoatBlock"));
184
- this.registerInput("sheen", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("sheen", this, 0 /* NodeMaterialConnectionPointDirection.Input */, SheenBlock, "SheenBlock"));
185
- this.registerInput("subsurface", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("subsurface", this, 0 /* NodeMaterialConnectionPointDirection.Input */, SubSurfaceBlock, "SubSurfaceBlock"));
186
- this.registerInput("anisotropy", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("anisotropy", this, 0 /* NodeMaterialConnectionPointDirection.Input */, AnisotropyBlock, "AnisotropyBlock"));
187
- this.registerInput("iridescence", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("iridescence", this, 0 /* NodeMaterialConnectionPointDirection.Input */, IridescenceBlock, "IridescenceBlock"));
188
- this.registerOutput("ambientClr", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
189
- this.registerOutput("diffuseDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
190
- this.registerOutput("specularDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
191
- this.registerOutput("clearcoatDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
192
- this.registerOutput("sheenDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
193
- this.registerOutput("diffuseInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
194
- this.registerOutput("specularInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
195
- this.registerOutput("clearcoatInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
196
- this.registerOutput("sheenInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
197
- this.registerOutput("refraction", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
198
- this.registerOutput("lighting", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
199
- this.registerOutput("shadow", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);
200
- this.registerOutput("alpha", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);
201
- }
202
- /**
203
- * Initialize the block and prepare the context for build
204
- * @param state defines the state that will be used for the build
205
- */
206
- initialize(state) {
207
- state._excludeVariableName("vLightingIntensity");
208
- state._excludeVariableName("geometricNormalW");
209
- state._excludeVariableName("normalW");
210
- state._excludeVariableName("faceNormal");
211
- state._excludeVariableName("albedoOpacityOut");
212
- state._excludeVariableName("surfaceAlbedo");
213
- state._excludeVariableName("alpha");
214
- state._excludeVariableName("aoOut");
215
- state._excludeVariableName("baseColor");
216
- state._excludeVariableName("reflectivityOut");
217
- state._excludeVariableName("microSurface");
218
- state._excludeVariableName("roughness");
219
- state._excludeVariableName("vReflectivityColor");
220
- state._excludeVariableName("NdotVUnclamped");
221
- state._excludeVariableName("NdotV");
222
- state._excludeVariableName("alphaG");
223
- state._excludeVariableName("AARoughnessFactors");
224
- state._excludeVariableName("environmentBrdf");
225
- state._excludeVariableName("ambientMonochrome");
226
- state._excludeVariableName("seo");
227
- state._excludeVariableName("eho");
228
- state._excludeVariableName("environmentRadiance");
229
- state._excludeVariableName("irradianceVector");
230
- state._excludeVariableName("environmentIrradiance");
231
- state._excludeVariableName("diffuseBase");
232
- state._excludeVariableName("specularBase");
233
- state._excludeVariableName("preInfo");
234
- state._excludeVariableName("info");
235
- state._excludeVariableName("shadow");
236
- state._excludeVariableName("finalDiffuse");
237
- state._excludeVariableName("finalAmbient");
238
- state._excludeVariableName("ambientOcclusionForDirectDiffuse");
239
- state._excludeVariableName("finalColor");
240
- state._excludeVariableName("vClipSpacePosition");
241
- state._excludeVariableName("vDebugMode");
242
- state._excludeVariableName("vViewDepth");
243
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
244
- this._initShaderSourceAsync(state.shaderLanguage);
245
- }
246
- async _initShaderSourceAsync(shaderLanguage) {
247
- this._codeIsReady = false;
248
- if (shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
249
- await Promise.all([import("../../../../ShadersWGSL/pbr.vertex.js"), import("../../../../ShadersWGSL/pbr.fragment.js")]);
250
- }
251
- else {
252
- await Promise.all([import("../../../../Shaders/pbr.vertex.js"), import("../../../../Shaders/pbr.fragment.js")]);
253
- }
254
- this._codeIsReady = true;
255
- this.onCodeIsReadyObservable.notifyObservers(this);
256
- }
257
- /**
258
- * Gets the current class name
259
- * @returns the class name
260
- */
261
- getClassName() {
262
- return "PBRMetallicRoughnessBlock";
263
- }
264
- /**
265
- * Gets the world position input component
266
- */
267
- get worldPosition() {
268
- return this._inputs[0];
269
- }
270
- /**
271
- * Gets the world normal input component
272
- */
273
- get worldNormal() {
274
- return this._inputs[1];
275
- }
276
- /**
277
- * Gets the view matrix parameter
278
- */
279
- get view() {
280
- return this._inputs[2];
281
- }
282
- /**
283
- * Gets the camera position input component
284
- */
285
- get cameraPosition() {
286
- return this._inputs[3];
287
- }
288
- /**
289
- * Gets the perturbed normal input component
290
- */
291
- get perturbedNormal() {
292
- return this._inputs[4];
293
- }
294
- /**
295
- * Gets the base color input component
296
- */
297
- get baseColor() {
298
- return this._inputs[5];
299
- }
300
- /**
301
- * Gets the metallic input component
302
- */
303
- get metallic() {
304
- return this._inputs[6];
305
- }
306
- /**
307
- * Gets the roughness input component
308
- */
309
- get roughness() {
310
- return this._inputs[7];
311
- }
312
- /**
313
- * Gets the ambient occlusion input component
314
- */
315
- get ambientOcc() {
316
- return this._inputs[8];
317
- }
318
- /**
319
- * Gets the opacity input component
320
- */
321
- get opacity() {
322
- return this._inputs[9];
323
- }
324
- /**
325
- * Gets the index of refraction input component
326
- */
327
- get indexOfRefraction() {
328
- return this._inputs[10];
329
- }
330
- /**
331
- * Gets the ambient color input component
332
- */
333
- get ambientColor() {
334
- return this._inputs[11];
335
- }
336
- /**
337
- * Gets the reflection object parameters
338
- */
339
- get reflection() {
340
- return this._inputs[12];
341
- }
342
- /**
343
- * Gets the clear coat object parameters
344
- */
345
- get clearcoat() {
346
- return this._inputs[13];
347
- }
348
- /**
349
- * Gets the sheen object parameters
350
- */
351
- get sheen() {
352
- return this._inputs[14];
353
- }
354
- /**
355
- * Gets the sub surface object parameters
356
- */
357
- get subsurface() {
358
- return this._inputs[15];
359
- }
360
- /**
361
- * Gets the anisotropy object parameters
362
- */
363
- get anisotropy() {
364
- return this._inputs[16];
365
- }
366
- /**
367
- * Gets the iridescence object parameters
368
- */
369
- get iridescence() {
370
- return this._inputs[17];
371
- }
372
- /**
373
- * Gets the ambient output component
374
- */
375
- get ambientClr() {
376
- return this._outputs[0];
377
- }
378
- /**
379
- * Gets the diffuse output component
380
- */
381
- get diffuseDir() {
382
- return this._outputs[1];
383
- }
384
- /**
385
- * Gets the specular output component
386
- */
387
- get specularDir() {
388
- return this._outputs[2];
389
- }
390
- /**
391
- * Gets the clear coat output component
392
- */
393
- get clearcoatDir() {
394
- return this._outputs[3];
395
- }
396
- /**
397
- * Gets the sheen output component
398
- */
399
- get sheenDir() {
400
- return this._outputs[4];
401
- }
402
- /**
403
- * Gets the indirect diffuse output component
404
- */
405
- get diffuseInd() {
406
- return this._outputs[5];
407
- }
408
- /**
409
- * Gets the indirect specular output component
410
- */
411
- get specularInd() {
412
- return this._outputs[6];
413
- }
414
- /**
415
- * Gets the indirect clear coat output component
416
- */
417
- get clearcoatInd() {
418
- return this._outputs[7];
419
- }
420
- /**
421
- * Gets the indirect sheen output component
422
- */
423
- get sheenInd() {
424
- return this._outputs[8];
425
- }
426
- /**
427
- * Gets the refraction output component
428
- */
429
- get refraction() {
430
- return this._outputs[9];
431
- }
432
- /**
433
- * Gets the global lighting output component
434
- */
435
- get lighting() {
436
- return this._outputs[10];
437
- }
438
- /**
439
- * Gets the shadow output component
440
- */
441
- get shadow() {
442
- return this._outputs[11];
443
- }
444
- /**
445
- * Gets the alpha output component
446
- */
447
- get alpha() {
448
- return this._outputs[12];
449
- }
450
- /**
451
- * Auto configure the block based on the material
452
- * @param material - the node material
453
- * @param additionalFilteringInfo - additional filtering info
454
- */
455
- autoConfigure(material, additionalFilteringInfo = () => true) {
456
- if (!this.cameraPosition.isConnected) {
457
- let cameraPositionInput = material.getInputBlockByPredicate((b) => b.systemValue === NodeMaterialSystemValues.CameraPosition && additionalFilteringInfo(b));
458
- if (!cameraPositionInput) {
459
- cameraPositionInput = new InputBlock("cameraPosition");
460
- cameraPositionInput.setAsSystemValue(NodeMaterialSystemValues.CameraPosition);
43
+ let PBRMetallicRoughnessBlock = (() => {
44
+ var _a;
45
+ let _classSuper = NodeMaterialBlock;
46
+ let _directIntensity_decorators;
47
+ let _directIntensity_initializers = [];
48
+ let _directIntensity_extraInitializers = [];
49
+ let _environmentIntensity_decorators;
50
+ let _environmentIntensity_initializers = [];
51
+ let _environmentIntensity_extraInitializers = [];
52
+ let _specularIntensity_decorators;
53
+ let _specularIntensity_initializers = [];
54
+ let _specularIntensity_extraInitializers = [];
55
+ let _lightFalloff_decorators;
56
+ let _lightFalloff_initializers = [];
57
+ let _lightFalloff_extraInitializers = [];
58
+ let _useAlphaTest_decorators;
59
+ let _useAlphaTest_initializers = [];
60
+ let _useAlphaTest_extraInitializers = [];
61
+ let _alphaTestCutoff_decorators;
62
+ let _alphaTestCutoff_initializers = [];
63
+ let _alphaTestCutoff_extraInitializers = [];
64
+ let _useAlphaBlending_decorators;
65
+ let _useAlphaBlending_initializers = [];
66
+ let _useAlphaBlending_extraInitializers = [];
67
+ let _useRadianceOverAlpha_decorators;
68
+ let _useRadianceOverAlpha_initializers = [];
69
+ let _useRadianceOverAlpha_extraInitializers = [];
70
+ let _useSpecularOverAlpha_decorators;
71
+ let _useSpecularOverAlpha_initializers = [];
72
+ let _useSpecularOverAlpha_extraInitializers = [];
73
+ let _enableSpecularAntiAliasing_decorators;
74
+ let _enableSpecularAntiAliasing_initializers = [];
75
+ let _enableSpecularAntiAliasing_extraInitializers = [];
76
+ let _realTimeFiltering_decorators;
77
+ let _realTimeFiltering_initializers = [];
78
+ let _realTimeFiltering_extraInitializers = [];
79
+ let _realTimeFilteringQuality_decorators;
80
+ let _realTimeFilteringQuality_initializers = [];
81
+ let _realTimeFilteringQuality_extraInitializers = [];
82
+ let _baseDiffuseModel_decorators;
83
+ let _baseDiffuseModel_initializers = [];
84
+ let _baseDiffuseModel_extraInitializers = [];
85
+ let _useEnergyConservation_decorators;
86
+ let _useEnergyConservation_initializers = [];
87
+ let _useEnergyConservation_extraInitializers = [];
88
+ let _useRadianceOcclusion_decorators;
89
+ let _useRadianceOcclusion_initializers = [];
90
+ let _useRadianceOcclusion_extraInitializers = [];
91
+ let _useHorizonOcclusion_decorators;
92
+ let _useHorizonOcclusion_initializers = [];
93
+ let _useHorizonOcclusion_extraInitializers = [];
94
+ let _unlit_decorators;
95
+ let _unlit_initializers = [];
96
+ let _unlit_extraInitializers = [];
97
+ let _forceNormalForward_decorators;
98
+ let _forceNormalForward_initializers = [];
99
+ let _forceNormalForward_extraInitializers = [];
100
+ let _generateOnlyFragmentCode_decorators;
101
+ let _generateOnlyFragmentCode_initializers = [];
102
+ let _generateOnlyFragmentCode_extraInitializers = [];
103
+ let _debugMode_decorators;
104
+ let _debugMode_initializers = [];
105
+ let _debugMode_extraInitializers = [];
106
+ let _debugLimit_decorators;
107
+ let _debugLimit_initializers = [];
108
+ let _debugLimit_extraInitializers = [];
109
+ let _debugFactor_decorators;
110
+ let _debugFactor_initializers = [];
111
+ let _debugFactor_extraInitializers = [];
112
+ return _a = class PBRMetallicRoughnessBlock extends _classSuper {
113
+ static _OnGenerateOnlyFragmentCodeChanged(block, _propertyName) {
114
+ const that = block;
115
+ if (that.worldPosition.isConnected || that.worldNormal.isConnected) {
116
+ that.generateOnlyFragmentCode = !that.generateOnlyFragmentCode;
117
+ Logger.Error("The worldPosition and worldNormal inputs must not be connected to be able to switch!");
118
+ return false;
119
+ }
120
+ that._setTarget();
121
+ return true;
461
122
  }
462
- cameraPositionInput.output.connectTo(this.cameraPosition);
463
- }
464
- if (!this.view.isConnected) {
465
- let viewInput = material.getInputBlockByPredicate((b) => b.systemValue === NodeMaterialSystemValues.View && additionalFilteringInfo(b));
466
- if (!viewInput) {
467
- viewInput = new InputBlock("view");
468
- viewInput.setAsSystemValue(NodeMaterialSystemValues.View);
123
+ _setTarget() {
124
+ this._setInitialTarget(this.generateOnlyFragmentCode ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.VertexAndFragment);
125
+ this.getInputByName("worldPosition").target = this.generateOnlyFragmentCode ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.Vertex;
126
+ this.getInputByName("worldNormal").target = this.generateOnlyFragmentCode ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.Vertex;
469
127
  }
470
- viewInput.output.connectTo(this.view);
471
- }
472
- }
473
- /**
474
- * Prepare the list of defines
475
- * @param defines - the list of defines to update
476
- * @param nodeMaterial - the node material
477
- * @param mesh - the mesh to prepare defines for
478
- */
479
- prepareDefines(defines, nodeMaterial, mesh) {
480
- if (!mesh) {
481
- return;
482
- }
483
- // General
484
- defines.setValue("PBR", true);
485
- defines.setValue("METALLICWORKFLOW", true);
486
- defines.setValue("DEBUGMODE", this.debugMode, true);
487
- defines.setValue("DEBUGMODE_FORCERETURN", true);
488
- defines.setValue("NORMALXYSCALE", true);
489
- defines.setValue("BUMP", this.perturbedNormal.isConnected, true);
490
- defines.setValue("LODBASEDMICROSFURACE", this._scene.getEngine().getCaps().textureLOD);
491
- // Albedo & Opacity
492
- defines.setValue("ALBEDO", false, true);
493
- defines.setValue("OPACITY", this.opacity.isConnected, true);
494
- // Ambient occlusion
495
- defines.setValue("AMBIENT", true, true);
496
- defines.setValue("AMBIENTINGRAYSCALE", false, true);
497
- // Reflectivity
498
- defines.setValue("REFLECTIVITY", false, true);
499
- defines.setValue("AOSTOREINMETALMAPRED", false, true);
500
- defines.setValue("METALLNESSSTOREINMETALMAPBLUE", false, true);
501
- defines.setValue("ROUGHNESSSTOREINMETALMAPALPHA", false, true);
502
- defines.setValue("ROUGHNESSSTOREINMETALMAPGREEN", false, true);
503
- // Lighting & colors
504
- if (this.lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
505
- defines.setValue("USEPHYSICALLIGHTFALLOFF", false);
506
- defines.setValue("USEGLTFLIGHTFALLOFF", false);
507
- }
508
- else if (this.lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
509
- defines.setValue("USEPHYSICALLIGHTFALLOFF", false);
510
- defines.setValue("USEGLTFLIGHTFALLOFF", true);
511
- }
512
- else {
513
- defines.setValue("USEPHYSICALLIGHTFALLOFF", true);
514
- defines.setValue("USEGLTFLIGHTFALLOFF", false);
515
- }
516
- // Transparency
517
- const alphaTestCutOffString = this.alphaTestCutoff.toString();
518
- defines.setValue("ALPHABLEND", this.useAlphaBlending, true);
519
- defines.setValue("ALPHAFROMALBEDO", false, true);
520
- defines.setValue("ALPHATEST", this.useAlphaTest, true);
521
- defines.setValue("ALPHATESTVALUE", alphaTestCutOffString.indexOf(".") < 0 ? alphaTestCutOffString + "." : alphaTestCutOffString, true);
522
- defines.setValue("OPACITYRGB", false, true);
523
- // Rendering
524
- defines.setValue("RADIANCEOVERALPHA", this.useRadianceOverAlpha, true);
525
- defines.setValue("SPECULAROVERALPHA", this.useSpecularOverAlpha, true);
526
- defines.setValue("SPECULARAA", this._scene.getEngine().getCaps().standardDerivatives && this.enableSpecularAntiAliasing, true);
527
- defines.setValue("REALTIME_FILTERING", this.realTimeFiltering, true);
528
- const scene = mesh.getScene();
529
- const engine = scene.getEngine();
530
- if (engine._features.needTypeSuffixInShaderConstants) {
531
- defines.setValue("NUM_SAMPLES", this.realTimeFilteringQuality + "u", true);
532
- }
533
- else {
534
- defines.setValue("NUM_SAMPLES", "" + this.realTimeFilteringQuality, true);
535
- }
536
- defines.setValue("BASE_DIFFUSE_MODEL", this.baseDiffuseModel, true);
537
- // Advanced
538
- defines.setValue("BRDF_V_HEIGHT_CORRELATED", true);
539
- defines.setValue("LEGACY_SPECULAR_ENERGY_CONSERVATION", true);
540
- defines.setValue("MS_BRDF_ENERGY_CONSERVATION", this.useEnergyConservation, true);
541
- defines.setValue("RADIANCEOCCLUSION", this.useRadianceOcclusion, true);
542
- defines.setValue("HORIZONOCCLUSION", this.useHorizonOcclusion, true);
543
- defines.setValue("UNLIT", this.unlit, true);
544
- defines.setValue("FORCENORMALFORWARD", this.forceNormalForward, true);
545
- if (this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled) {
546
- defines.setValue("ENVIRONMENTBRDF", true);
547
- defines.setValue("ENVIRONMENTBRDF_RGBD", this._environmentBRDFTexture.isRGBD, true);
548
- }
549
- else {
550
- defines.setValue("ENVIRONMENTBRDF", false);
551
- defines.setValue("ENVIRONMENTBRDF_RGBD", false);
552
- }
553
- if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {
554
- nodeMaterial.imageProcessingConfiguration.prepareDefines(defines);
555
- }
556
- if (!defines._areLightsDirty) {
557
- return;
558
- }
559
- if (!this.light) {
560
- // Lights
561
- PrepareDefinesForLights(scene, mesh, defines, true, nodeMaterial.maxSimultaneousLights);
562
- defines._needNormals = true;
563
- // Multiview
564
- PrepareDefinesForMultiview(scene, defines);
565
- }
566
- else {
567
- const state = {
568
- needNormals: false,
569
- needRebuild: false,
570
- lightmapMode: false,
571
- shadowEnabled: false,
572
- specularEnabled: false,
573
- };
574
- PrepareDefinesForLight(scene, mesh, this.light, this._lightId, defines, true, state);
575
- if (state.needRebuild) {
576
- defines.rebuild();
128
+ /**
129
+ * Create a new ReflectionBlock
130
+ * @param name defines the block name
131
+ */
132
+ constructor(name) {
133
+ super(name, NodeMaterialBlockTargets.VertexAndFragment);
134
+ this._environmentBRDFTexture = null;
135
+ this._metallicReflectanceColor = Color3.White();
136
+ this._metallicF0Factor = 1;
137
+ /**
138
+ * Intensity of the direct lights e.g. the four lights available in your scene.
139
+ * This impacts both the direct diffuse and specular highlights.
140
+ */
141
+ this.directIntensity = __runInitializers(this, _directIntensity_initializers, 1.0);
142
+ /**
143
+ * Intensity of the environment e.g. how much the environment will light the object
144
+ * either through harmonics for rough material or through the reflection for shiny ones.
145
+ */
146
+ this.environmentIntensity = (__runInitializers(this, _directIntensity_extraInitializers), __runInitializers(this, _environmentIntensity_initializers, 1.0));
147
+ /**
148
+ * This is a special control allowing the reduction of the specular highlights coming from the
149
+ * four lights of the scene. Those highlights may not be needed in full environment lighting.
150
+ */
151
+ this.specularIntensity = (__runInitializers(this, _environmentIntensity_extraInitializers), __runInitializers(this, _specularIntensity_initializers, 1.0));
152
+ /**
153
+ * Defines the falloff type used in this material.
154
+ * It by default is Physical.
155
+ */
156
+ this.lightFalloff = (__runInitializers(this, _specularIntensity_extraInitializers), __runInitializers(this, _lightFalloff_initializers, 0));
157
+ /**
158
+ * Specifies that alpha test should be used
159
+ */
160
+ this.useAlphaTest = (__runInitializers(this, _lightFalloff_extraInitializers), __runInitializers(this, _useAlphaTest_initializers, false));
161
+ /**
162
+ * Defines the alpha limits in alpha test mode.
163
+ */
164
+ this.alphaTestCutoff = (__runInitializers(this, _useAlphaTest_extraInitializers), __runInitializers(this, _alphaTestCutoff_initializers, 0.5));
165
+ /**
166
+ * Specifies that alpha blending should be used
167
+ */
168
+ this.useAlphaBlending = (__runInitializers(this, _alphaTestCutoff_extraInitializers), __runInitializers(this, _useAlphaBlending_initializers, false));
169
+ /**
170
+ * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
171
+ * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
172
+ */
173
+ this.useRadianceOverAlpha = (__runInitializers(this, _useAlphaBlending_extraInitializers), __runInitializers(this, _useRadianceOverAlpha_initializers, true));
174
+ /**
175
+ * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
176
+ * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
177
+ */
178
+ this.useSpecularOverAlpha = (__runInitializers(this, _useRadianceOverAlpha_extraInitializers), __runInitializers(this, _useSpecularOverAlpha_initializers, true));
179
+ /**
180
+ * Enables specular anti aliasing in the PBR shader.
181
+ * It will both interacts on the Geometry for analytical and IBL lighting.
182
+ * It also prefilter the roughness map based on the bump values.
183
+ */
184
+ this.enableSpecularAntiAliasing = (__runInitializers(this, _useSpecularOverAlpha_extraInitializers), __runInitializers(this, _enableSpecularAntiAliasing_initializers, false));
185
+ /**
186
+ * Enables realtime filtering on the texture.
187
+ */
188
+ this.realTimeFiltering = (__runInitializers(this, _enableSpecularAntiAliasing_extraInitializers), __runInitializers(this, _realTimeFiltering_initializers, false));
189
+ /**
190
+ * Quality switch for realtime filtering
191
+ */
192
+ this.realTimeFilteringQuality = (__runInitializers(this, _realTimeFiltering_extraInitializers), __runInitializers(this, _realTimeFilteringQuality_initializers, 8));
193
+ /**
194
+ * Base Diffuse Model
195
+ */
196
+ this.baseDiffuseModel = (__runInitializers(this, _realTimeFilteringQuality_extraInitializers), __runInitializers(this, _baseDiffuseModel_initializers, 0));
197
+ /**
198
+ * Defines if the material uses energy conservation.
199
+ */
200
+ this.useEnergyConservation = (__runInitializers(this, _baseDiffuseModel_extraInitializers), __runInitializers(this, _useEnergyConservation_initializers, true));
201
+ /**
202
+ * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
203
+ * too much the area relying on ambient texture to define their ambient occlusion.
204
+ */
205
+ this.useRadianceOcclusion = (__runInitializers(this, _useEnergyConservation_extraInitializers), __runInitializers(this, _useRadianceOcclusion_initializers, true));
206
+ /**
207
+ * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
208
+ * makes the reflect vector face the model (under horizon).
209
+ */
210
+ this.useHorizonOcclusion = (__runInitializers(this, _useRadianceOcclusion_extraInitializers), __runInitializers(this, _useHorizonOcclusion_initializers, true));
211
+ /**
212
+ * If set to true, no lighting calculations will be applied.
213
+ */
214
+ this.unlit = (__runInitializers(this, _useHorizonOcclusion_extraInitializers), __runInitializers(this, _unlit_initializers, false));
215
+ /**
216
+ * Force normal to face away from face.
217
+ */
218
+ this.forceNormalForward = (__runInitializers(this, _unlit_extraInitializers), __runInitializers(this, _forceNormalForward_initializers, false));
219
+ /** Indicates that no code should be generated in the vertex shader. Can be useful in some specific circumstances (like when doing ray marching for eg) */
220
+ this.generateOnlyFragmentCode = (__runInitializers(this, _forceNormalForward_extraInitializers), __runInitializers(this, _generateOnlyFragmentCode_initializers, false));
221
+ /**
222
+ * Defines the material debug mode.
223
+ * It helps seeing only some components of the material while troubleshooting.
224
+ */
225
+ this.debugMode = (__runInitializers(this, _generateOnlyFragmentCode_extraInitializers), __runInitializers(this, _debugMode_initializers, 0));
226
+ /**
227
+ * Specify from where on screen the debug mode should start.
228
+ * The value goes from -1 (full screen) to 1 (not visible)
229
+ * It helps with side by side comparison against the final render
230
+ * This defaults to 0
231
+ */
232
+ this.debugLimit = (__runInitializers(this, _debugMode_extraInitializers), __runInitializers(this, _debugLimit_initializers, 0));
233
+ /**
234
+ * As the default viewing range might not be enough (if the ambient is really small for instance)
235
+ * You can use the factor to better multiply the final value.
236
+ */
237
+ this.debugFactor = (__runInitializers(this, _debugLimit_extraInitializers), __runInitializers(this, _debugFactor_initializers, 1));
238
+ __runInitializers(this, _debugFactor_extraInitializers);
239
+ this._isUnique = true;
240
+ this.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, false, NodeMaterialBlockTargets.Vertex);
241
+ this.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, false, NodeMaterialBlockTargets.Vertex);
242
+ this.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, false);
243
+ this.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3, false, NodeMaterialBlockTargets.Fragment);
244
+ this.registerInput("perturbedNormal", NodeMaterialBlockConnectionPointTypes.Vector4, true, NodeMaterialBlockTargets.Fragment);
245
+ this.registerInput("baseColor", NodeMaterialBlockConnectionPointTypes.Color3, true, NodeMaterialBlockTargets.Fragment);
246
+ this.registerInput("metallic", NodeMaterialBlockConnectionPointTypes.Float, false, NodeMaterialBlockTargets.Fragment);
247
+ this.registerInput("roughness", NodeMaterialBlockConnectionPointTypes.Float, false, NodeMaterialBlockTargets.Fragment);
248
+ this.registerInput("ambientOcc", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);
249
+ this.registerInput("opacity", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);
250
+ this.registerInput("indexOfRefraction", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);
251
+ this.registerInput("ambientColor", NodeMaterialBlockConnectionPointTypes.Color3, true, NodeMaterialBlockTargets.Fragment);
252
+ this.registerInput("reflection", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("reflection", this, 0 /* NodeMaterialConnectionPointDirection.Input */, ReflectionBlock, "ReflectionBlock"));
253
+ this.registerInput("clearcoat", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("clearcoat", this, 0 /* NodeMaterialConnectionPointDirection.Input */, ClearCoatBlock, "ClearCoatBlock"));
254
+ this.registerInput("sheen", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("sheen", this, 0 /* NodeMaterialConnectionPointDirection.Input */, SheenBlock, "SheenBlock"));
255
+ this.registerInput("subsurface", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("subsurface", this, 0 /* NodeMaterialConnectionPointDirection.Input */, SubSurfaceBlock, "SubSurfaceBlock"));
256
+ this.registerInput("anisotropy", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("anisotropy", this, 0 /* NodeMaterialConnectionPointDirection.Input */, AnisotropyBlock, "AnisotropyBlock"));
257
+ this.registerInput("iridescence", NodeMaterialBlockConnectionPointTypes.Object, true, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("iridescence", this, 0 /* NodeMaterialConnectionPointDirection.Input */, IridescenceBlock, "IridescenceBlock"));
258
+ this.registerOutput("ambientClr", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
259
+ this.registerOutput("diffuseDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
260
+ this.registerOutput("specularDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
261
+ this.registerOutput("clearcoatDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
262
+ this.registerOutput("sheenDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
263
+ this.registerOutput("diffuseInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
264
+ this.registerOutput("specularInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
265
+ this.registerOutput("clearcoatInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
266
+ this.registerOutput("sheenInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
267
+ this.registerOutput("refraction", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
268
+ this.registerOutput("lighting", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
269
+ this.registerOutput("shadow", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);
270
+ this.registerOutput("alpha", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);
577
271
  }
578
- }
579
- }
580
- /**
581
- * Update the uniforms and samples
582
- * @param state - the build state
583
- * @param nodeMaterial - the node material
584
- * @param defines - the list of defines
585
- * @param uniformBuffers - the uniform buffers
586
- */
587
- updateUniformsAndSamples(state, nodeMaterial, defines, uniformBuffers) {
588
- for (let lightIndex = 0; lightIndex < nodeMaterial.maxSimultaneousLights; lightIndex++) {
589
- if (!defines["LIGHT" + lightIndex]) {
590
- break;
272
+ /**
273
+ * Initialize the block and prepare the context for build
274
+ * @param state defines the state that will be used for the build
275
+ */
276
+ initialize(state) {
277
+ state._excludeVariableName("vLightingIntensity");
278
+ state._excludeVariableName("geometricNormalW");
279
+ state._excludeVariableName("normalW");
280
+ state._excludeVariableName("faceNormal");
281
+ state._excludeVariableName("albedoOpacityOut");
282
+ state._excludeVariableName("surfaceAlbedo");
283
+ state._excludeVariableName("alpha");
284
+ state._excludeVariableName("aoOut");
285
+ state._excludeVariableName("baseColor");
286
+ state._excludeVariableName("reflectivityOut");
287
+ state._excludeVariableName("microSurface");
288
+ state._excludeVariableName("roughness");
289
+ state._excludeVariableName("vReflectivityColor");
290
+ state._excludeVariableName("NdotVUnclamped");
291
+ state._excludeVariableName("NdotV");
292
+ state._excludeVariableName("alphaG");
293
+ state._excludeVariableName("AARoughnessFactors");
294
+ state._excludeVariableName("environmentBrdf");
295
+ state._excludeVariableName("ambientMonochrome");
296
+ state._excludeVariableName("seo");
297
+ state._excludeVariableName("eho");
298
+ state._excludeVariableName("environmentRadiance");
299
+ state._excludeVariableName("irradianceVector");
300
+ state._excludeVariableName("environmentIrradiance");
301
+ state._excludeVariableName("diffuseBase");
302
+ state._excludeVariableName("specularBase");
303
+ state._excludeVariableName("preInfo");
304
+ state._excludeVariableName("info");
305
+ state._excludeVariableName("shadow");
306
+ state._excludeVariableName("finalDiffuse");
307
+ state._excludeVariableName("finalAmbient");
308
+ state._excludeVariableName("ambientOcclusionForDirectDiffuse");
309
+ state._excludeVariableName("finalColor");
310
+ state._excludeVariableName("vClipSpacePosition");
311
+ state._excludeVariableName("vDebugMode");
312
+ state._excludeVariableName("vViewDepth");
313
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
314
+ this._initShaderSourceAsync(state.shaderLanguage);
591
315
  }
592
- const onlyUpdateBuffersList = state.uniforms.indexOf("vLightData" + lightIndex) >= 0;
593
- PrepareUniformsAndSamplersForLight(lightIndex, state.uniforms, state.samplers, defines["PROJECTEDLIGHTTEXTURE" + lightIndex], uniformBuffers, onlyUpdateBuffersList, defines["IESLIGHTTEXTURE" + lightIndex], defines["CLUSTLIGHT" + lightIndex], defines["RECTAREALIGHTEMISSIONTEXTURE" + lightIndex], state.shaderLanguage === 1 /* ShaderLanguage.WGSL */);
594
- }
595
- }
596
- /**
597
- * Checks if the block is ready
598
- * @param mesh - the mesh to check
599
- * @param nodeMaterial - the node material
600
- * @param defines - the list of defines
601
- * @returns true if ready
602
- */
603
- isReady(mesh, nodeMaterial, defines) {
604
- if (this._environmentBRDFTexture && !this._environmentBRDFTexture.isReady()) {
605
- return false;
606
- }
607
- if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {
608
- if (!nodeMaterial.imageProcessingConfiguration.isReady()) {
609
- return false;
316
+ async _initShaderSourceAsync(shaderLanguage) {
317
+ this._codeIsReady = false;
318
+ if (shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
319
+ await Promise.all([import("../../../../ShadersWGSL/pbr.vertex.js"), import("../../../../ShadersWGSL/pbr.fragment.js")]);
320
+ }
321
+ else {
322
+ await Promise.all([import("../../../../Shaders/pbr.vertex.js"), import("../../../../Shaders/pbr.fragment.js")]);
323
+ }
324
+ this._codeIsReady = true;
325
+ this.onCodeIsReadyObservable.notifyObservers(this);
610
326
  }
611
- }
612
- if (this.light && !this.light.areLightTexturesReady()) {
613
- return false;
614
- }
615
- return true;
616
- }
617
- /**
618
- * Bind data to effect
619
- * @param effect - the effect to bind data to
620
- * @param nodeMaterial - the node material
621
- * @param mesh - the mesh to bind data for
622
- */
623
- bind(effect, nodeMaterial, mesh) {
624
- if (!mesh) {
625
- return;
626
- }
627
- const scene = mesh.getScene();
628
- if (!this.light) {
629
- BindLights(scene, mesh, effect, true, nodeMaterial.maxSimultaneousLights);
630
- }
631
- else {
632
- BindLight(this.light, this._lightId, scene, effect, true);
633
- }
634
- effect.setTexture(this._environmentBrdfSamplerName, this._environmentBRDFTexture);
635
- effect.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
636
- const ambientScene = this._scene.ambientColor;
637
- if (ambientScene) {
638
- effect.setColor3("ambientFromScene", ambientScene);
639
- }
640
- const invertNormal = scene.useRightHandedSystem === (scene._mirroredCameraPosition != null);
641
- effect.setFloat(this._invertNormalName, invertNormal ? -1 : 1);
642
- effect.setFloat4("vLightingIntensity", this.directIntensity, 1, this.environmentIntensity * this._scene.environmentIntensity, this.specularIntensity);
643
- // reflectivity bindings
644
- const metallicF90 = this._metallicF0Factor;
645
- effect.setColor4(this._vMetallicReflectanceFactorsName, this._metallicReflectanceColor, metallicF90);
646
- if (nodeMaterial.imageProcessingConfiguration) {
647
- nodeMaterial.imageProcessingConfiguration.bind(effect);
648
- }
649
- }
650
- _injectVertexCode(state) {
651
- const worldPos = this.worldPosition;
652
- const worldNormal = this.worldNormal;
653
- const comments = `//${this.name}`;
654
- const isWebGPU = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */;
655
- const scene = state.sharedData.nodeMaterial.getScene();
656
- // Declaration
657
- if (!this.light) {
658
- // Emit for all lights
659
- state._emitFunctionFromInclude(state.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", comments, {
660
- repeatKey: "maxSimultaneousLights",
661
- });
662
- this._lightId = 0;
663
- state.sharedData.dynamicUniformBlocks.push(this);
664
- }
665
- else {
666
- this._lightId = (state.counters["lightCounter"] !== undefined ? state.counters["lightCounter"] : -1) + 1;
667
- state.counters["lightCounter"] = this._lightId;
668
- state._emitFunctionFromInclude(state.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", comments, {
669
- replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }],
670
- }, this._lightId.toString());
671
- }
672
- // Inject code in vertex
673
- const worldPosVaryingName = "v_" + worldPos.associatedVariableName;
674
- if (state._emitVaryingFromString(worldPosVaryingName, NodeMaterialBlockConnectionPointTypes.Vector4)) {
675
- state.compilationString += (isWebGPU ? "vertexOutputs." : "") + `${worldPosVaryingName} = ${worldPos.associatedVariableName};\n`;
676
- }
677
- const worldNormalVaryingName = "v_" + worldNormal.associatedVariableName;
678
- if (state._emitVaryingFromString(worldNormalVaryingName, NodeMaterialBlockConnectionPointTypes.Vector4)) {
679
- state.compilationString += (isWebGPU ? "vertexOutputs." : "") + `${worldNormalVaryingName} = ${worldNormal.associatedVariableName};\n`;
680
- }
681
- const reflectionBlock = this.reflection.isConnected ? this.reflection.connectedPoint?.ownerBlock : null;
682
- if (reflectionBlock) {
683
- reflectionBlock.viewConnectionPoint = this.view;
684
- }
685
- state.compilationString += reflectionBlock?.handleVertexSide(state) ?? "";
686
- if (state._emitVaryingFromString("vClipSpacePosition", NodeMaterialBlockConnectionPointTypes.Vector4, "defined(IGNORE) || DEBUGMODE > 0")) {
687
- state._injectAtEnd += `#if DEBUGMODE > 0\n`;
688
- state._injectAtEnd += (isWebGPU ? "vertexOutputs." : "") + `vClipSpacePosition = ${isWebGPU ? "vertexOutputs.position" : "gl_Position"};\n`;
689
- state._injectAtEnd += `#endif\n`;
690
- }
691
- if (this.light) {
692
- state.compilationString += state._emitCodeFromInclude("shadowsVertex", comments, {
693
- replaceStrings: [
694
- { search: /{X}/g, replace: this._lightId.toString() },
695
- { search: /worldPos/g, replace: worldPos.associatedVariableName },
696
- ],
697
- });
698
- }
699
- else {
700
- state.compilationString += `${state._declareLocalVar("worldPos", NodeMaterialBlockConnectionPointTypes.Vector4)} = ${worldPos.associatedVariableName};\n`;
701
- if (this.view.isConnected) {
702
- state.compilationString += `${state._declareLocalVar("view", NodeMaterialBlockConnectionPointTypes.Matrix)} = ${this.view.associatedVariableName};\n`;
703
- state._emitVaryingFromString("vViewDepth", NodeMaterialBlockConnectionPointTypes.Float);
704
- state.compilationString +=
705
- (state.shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? "vertexOutputs." : "") +
706
- `vViewDepth = ${scene.useRightHandedSystem ? "-" : ""}(${this.view.associatedVariableName} * ${worldPos.associatedVariableName}).z;\n`;
327
+ /**
328
+ * Gets the current class name
329
+ * @returns the class name
330
+ */
331
+ getClassName() {
332
+ return "PBRMetallicRoughnessBlock";
707
333
  }
708
- state.compilationString += state._emitCodeFromInclude("shadowsVertex", comments, {
709
- repeatKey: "maxSimultaneousLights",
710
- });
711
- }
712
- }
713
- _getAlbedoOpacityCode(state) {
714
- const isWebGPU = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */;
715
- let code = isWebGPU ? "var albedoOpacityOut: albedoOpacityOutParams;\n" : `albedoOpacityOutParams albedoOpacityOut;\n`;
716
- const albedoColor = this.baseColor.isConnected ? this.baseColor.associatedVariableName : "vec3(1.)";
717
- const opacity = this.opacity.isConnected ? this.opacity.associatedVariableName : "1.";
718
- code += `albedoOpacityOut = albedoOpacityBlock(
334
+ /**
335
+ * Gets the world position input component
336
+ */
337
+ get worldPosition() {
338
+ return this._inputs[0];
339
+ }
340
+ /**
341
+ * Gets the world normal input component
342
+ */
343
+ get worldNormal() {
344
+ return this._inputs[1];
345
+ }
346
+ /**
347
+ * Gets the view matrix parameter
348
+ */
349
+ get view() {
350
+ return this._inputs[2];
351
+ }
352
+ /**
353
+ * Gets the camera position input component
354
+ */
355
+ get cameraPosition() {
356
+ return this._inputs[3];
357
+ }
358
+ /**
359
+ * Gets the perturbed normal input component
360
+ */
361
+ get perturbedNormal() {
362
+ return this._inputs[4];
363
+ }
364
+ /**
365
+ * Gets the base color input component
366
+ */
367
+ get baseColor() {
368
+ return this._inputs[5];
369
+ }
370
+ /**
371
+ * Gets the metallic input component
372
+ */
373
+ get metallic() {
374
+ return this._inputs[6];
375
+ }
376
+ /**
377
+ * Gets the roughness input component
378
+ */
379
+ get roughness() {
380
+ return this._inputs[7];
381
+ }
382
+ /**
383
+ * Gets the ambient occlusion input component
384
+ */
385
+ get ambientOcc() {
386
+ return this._inputs[8];
387
+ }
388
+ /**
389
+ * Gets the opacity input component
390
+ */
391
+ get opacity() {
392
+ return this._inputs[9];
393
+ }
394
+ /**
395
+ * Gets the index of refraction input component
396
+ */
397
+ get indexOfRefraction() {
398
+ return this._inputs[10];
399
+ }
400
+ /**
401
+ * Gets the ambient color input component
402
+ */
403
+ get ambientColor() {
404
+ return this._inputs[11];
405
+ }
406
+ /**
407
+ * Gets the reflection object parameters
408
+ */
409
+ get reflection() {
410
+ return this._inputs[12];
411
+ }
412
+ /**
413
+ * Gets the clear coat object parameters
414
+ */
415
+ get clearcoat() {
416
+ return this._inputs[13];
417
+ }
418
+ /**
419
+ * Gets the sheen object parameters
420
+ */
421
+ get sheen() {
422
+ return this._inputs[14];
423
+ }
424
+ /**
425
+ * Gets the sub surface object parameters
426
+ */
427
+ get subsurface() {
428
+ return this._inputs[15];
429
+ }
430
+ /**
431
+ * Gets the anisotropy object parameters
432
+ */
433
+ get anisotropy() {
434
+ return this._inputs[16];
435
+ }
436
+ /**
437
+ * Gets the iridescence object parameters
438
+ */
439
+ get iridescence() {
440
+ return this._inputs[17];
441
+ }
442
+ /**
443
+ * Gets the ambient output component
444
+ */
445
+ get ambientClr() {
446
+ return this._outputs[0];
447
+ }
448
+ /**
449
+ * Gets the diffuse output component
450
+ */
451
+ get diffuseDir() {
452
+ return this._outputs[1];
453
+ }
454
+ /**
455
+ * Gets the specular output component
456
+ */
457
+ get specularDir() {
458
+ return this._outputs[2];
459
+ }
460
+ /**
461
+ * Gets the clear coat output component
462
+ */
463
+ get clearcoatDir() {
464
+ return this._outputs[3];
465
+ }
466
+ /**
467
+ * Gets the sheen output component
468
+ */
469
+ get sheenDir() {
470
+ return this._outputs[4];
471
+ }
472
+ /**
473
+ * Gets the indirect diffuse output component
474
+ */
475
+ get diffuseInd() {
476
+ return this._outputs[5];
477
+ }
478
+ /**
479
+ * Gets the indirect specular output component
480
+ */
481
+ get specularInd() {
482
+ return this._outputs[6];
483
+ }
484
+ /**
485
+ * Gets the indirect clear coat output component
486
+ */
487
+ get clearcoatInd() {
488
+ return this._outputs[7];
489
+ }
490
+ /**
491
+ * Gets the indirect sheen output component
492
+ */
493
+ get sheenInd() {
494
+ return this._outputs[8];
495
+ }
496
+ /**
497
+ * Gets the refraction output component
498
+ */
499
+ get refraction() {
500
+ return this._outputs[9];
501
+ }
502
+ /**
503
+ * Gets the global lighting output component
504
+ */
505
+ get lighting() {
506
+ return this._outputs[10];
507
+ }
508
+ /**
509
+ * Gets the shadow output component
510
+ */
511
+ get shadow() {
512
+ return this._outputs[11];
513
+ }
514
+ /**
515
+ * Gets the alpha output component
516
+ */
517
+ get alpha() {
518
+ return this._outputs[12];
519
+ }
520
+ /**
521
+ * Auto configure the block based on the material
522
+ * @param material - the node material
523
+ * @param additionalFilteringInfo - additional filtering info
524
+ */
525
+ autoConfigure(material, additionalFilteringInfo = () => true) {
526
+ if (!this.cameraPosition.isConnected) {
527
+ let cameraPositionInput = material.getInputBlockByPredicate((b) => b.systemValue === NodeMaterialSystemValues.CameraPosition && additionalFilteringInfo(b));
528
+ if (!cameraPositionInput) {
529
+ cameraPositionInput = new InputBlock("cameraPosition");
530
+ cameraPositionInput.setAsSystemValue(NodeMaterialSystemValues.CameraPosition);
531
+ }
532
+ cameraPositionInput.output.connectTo(this.cameraPosition);
533
+ }
534
+ if (!this.view.isConnected) {
535
+ let viewInput = material.getInputBlockByPredicate((b) => b.systemValue === NodeMaterialSystemValues.View && additionalFilteringInfo(b));
536
+ if (!viewInput) {
537
+ viewInput = new InputBlock("view");
538
+ viewInput.setAsSystemValue(NodeMaterialSystemValues.View);
539
+ }
540
+ viewInput.output.connectTo(this.view);
541
+ }
542
+ }
543
+ /**
544
+ * Prepare the list of defines
545
+ * @param defines - the list of defines to update
546
+ * @param nodeMaterial - the node material
547
+ * @param mesh - the mesh to prepare defines for
548
+ */
549
+ prepareDefines(defines, nodeMaterial, mesh) {
550
+ if (!mesh) {
551
+ return;
552
+ }
553
+ // General
554
+ defines.setValue("PBR", true);
555
+ defines.setValue("METALLICWORKFLOW", true);
556
+ defines.setValue("DEBUGMODE", this.debugMode, true);
557
+ defines.setValue("DEBUGMODE_FORCERETURN", true);
558
+ defines.setValue("NORMALXYSCALE", true);
559
+ defines.setValue("BUMP", this.perturbedNormal.isConnected, true);
560
+ defines.setValue("LODBASEDMICROSFURACE", this._scene.getEngine().getCaps().textureLOD);
561
+ // Albedo & Opacity
562
+ defines.setValue("ALBEDO", false, true);
563
+ defines.setValue("OPACITY", this.opacity.isConnected, true);
564
+ // Ambient occlusion
565
+ defines.setValue("AMBIENT", true, true);
566
+ defines.setValue("AMBIENTINGRAYSCALE", false, true);
567
+ // Reflectivity
568
+ defines.setValue("REFLECTIVITY", false, true);
569
+ defines.setValue("AOSTOREINMETALMAPRED", false, true);
570
+ defines.setValue("METALLNESSSTOREINMETALMAPBLUE", false, true);
571
+ defines.setValue("ROUGHNESSSTOREINMETALMAPALPHA", false, true);
572
+ defines.setValue("ROUGHNESSSTOREINMETALMAPGREEN", false, true);
573
+ // Lighting & colors
574
+ if (this.lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
575
+ defines.setValue("USEPHYSICALLIGHTFALLOFF", false);
576
+ defines.setValue("USEGLTFLIGHTFALLOFF", false);
577
+ }
578
+ else if (this.lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
579
+ defines.setValue("USEPHYSICALLIGHTFALLOFF", false);
580
+ defines.setValue("USEGLTFLIGHTFALLOFF", true);
581
+ }
582
+ else {
583
+ defines.setValue("USEPHYSICALLIGHTFALLOFF", true);
584
+ defines.setValue("USEGLTFLIGHTFALLOFF", false);
585
+ }
586
+ // Transparency
587
+ const alphaTestCutOffString = this.alphaTestCutoff.toString();
588
+ defines.setValue("ALPHABLEND", this.useAlphaBlending, true);
589
+ defines.setValue("ALPHAFROMALBEDO", false, true);
590
+ defines.setValue("ALPHATEST", this.useAlphaTest, true);
591
+ defines.setValue("ALPHATESTVALUE", alphaTestCutOffString.indexOf(".") < 0 ? alphaTestCutOffString + "." : alphaTestCutOffString, true);
592
+ defines.setValue("OPACITYRGB", false, true);
593
+ // Rendering
594
+ defines.setValue("RADIANCEOVERALPHA", this.useRadianceOverAlpha, true);
595
+ defines.setValue("SPECULAROVERALPHA", this.useSpecularOverAlpha, true);
596
+ defines.setValue("SPECULARAA", this._scene.getEngine().getCaps().standardDerivatives && this.enableSpecularAntiAliasing, true);
597
+ defines.setValue("REALTIME_FILTERING", this.realTimeFiltering, true);
598
+ const scene = mesh.getScene();
599
+ const engine = scene.getEngine();
600
+ if (engine._features.needTypeSuffixInShaderConstants) {
601
+ defines.setValue("NUM_SAMPLES", this.realTimeFilteringQuality + "u", true);
602
+ }
603
+ else {
604
+ defines.setValue("NUM_SAMPLES", "" + this.realTimeFilteringQuality, true);
605
+ }
606
+ defines.setValue("BASE_DIFFUSE_MODEL", this.baseDiffuseModel, true);
607
+ // Advanced
608
+ defines.setValue("BRDF_V_HEIGHT_CORRELATED", true);
609
+ defines.setValue("LEGACY_SPECULAR_ENERGY_CONSERVATION", true);
610
+ defines.setValue("MS_BRDF_ENERGY_CONSERVATION", this.useEnergyConservation, true);
611
+ defines.setValue("RADIANCEOCCLUSION", this.useRadianceOcclusion, true);
612
+ defines.setValue("HORIZONOCCLUSION", this.useHorizonOcclusion, true);
613
+ defines.setValue("UNLIT", this.unlit, true);
614
+ defines.setValue("FORCENORMALFORWARD", this.forceNormalForward, true);
615
+ if (this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled) {
616
+ defines.setValue("ENVIRONMENTBRDF", true);
617
+ defines.setValue("ENVIRONMENTBRDF_RGBD", this._environmentBRDFTexture.isRGBD, true);
618
+ }
619
+ else {
620
+ defines.setValue("ENVIRONMENTBRDF", false);
621
+ defines.setValue("ENVIRONMENTBRDF_RGBD", false);
622
+ }
623
+ if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {
624
+ nodeMaterial.imageProcessingConfiguration.prepareDefines(defines);
625
+ }
626
+ if (!defines._areLightsDirty) {
627
+ return;
628
+ }
629
+ if (!this.light) {
630
+ // Lights
631
+ PrepareDefinesForLights(scene, mesh, defines, true, nodeMaterial.maxSimultaneousLights);
632
+ defines._needNormals = true;
633
+ // Multiview
634
+ PrepareDefinesForMultiview(scene, defines);
635
+ }
636
+ else {
637
+ const state = {
638
+ needNormals: false,
639
+ needRebuild: false,
640
+ lightmapMode: false,
641
+ shadowEnabled: false,
642
+ specularEnabled: false,
643
+ };
644
+ PrepareDefinesForLight(scene, mesh, this.light, this._lightId, defines, true, state);
645
+ if (state.needRebuild) {
646
+ defines.rebuild();
647
+ }
648
+ }
649
+ }
650
+ /**
651
+ * Update the uniforms and samples
652
+ * @param state - the build state
653
+ * @param nodeMaterial - the node material
654
+ * @param defines - the list of defines
655
+ * @param uniformBuffers - the uniform buffers
656
+ */
657
+ updateUniformsAndSamples(state, nodeMaterial, defines, uniformBuffers) {
658
+ for (let lightIndex = 0; lightIndex < nodeMaterial.maxSimultaneousLights; lightIndex++) {
659
+ if (!defines["LIGHT" + lightIndex]) {
660
+ break;
661
+ }
662
+ const onlyUpdateBuffersList = state.uniforms.indexOf("vLightData" + lightIndex) >= 0;
663
+ PrepareUniformsAndSamplersForLight(lightIndex, state.uniforms, state.samplers, defines["PROJECTEDLIGHTTEXTURE" + lightIndex], uniformBuffers, onlyUpdateBuffersList, defines["IESLIGHTTEXTURE" + lightIndex], defines["CLUSTLIGHT" + lightIndex], defines["RECTAREALIGHTEMISSIONTEXTURE" + lightIndex], state.shaderLanguage === 1 /* ShaderLanguage.WGSL */);
664
+ }
665
+ }
666
+ /**
667
+ * Checks if the block is ready
668
+ * @param mesh - the mesh to check
669
+ * @param nodeMaterial - the node material
670
+ * @param defines - the list of defines
671
+ * @returns true if ready
672
+ */
673
+ isReady(mesh, nodeMaterial, defines) {
674
+ if (this._environmentBRDFTexture && !this._environmentBRDFTexture.isReady()) {
675
+ return false;
676
+ }
677
+ if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {
678
+ if (!nodeMaterial.imageProcessingConfiguration.isReady()) {
679
+ return false;
680
+ }
681
+ }
682
+ if (this.light && !this.light.areLightTexturesReady()) {
683
+ return false;
684
+ }
685
+ return true;
686
+ }
687
+ /**
688
+ * Bind data to effect
689
+ * @param effect - the effect to bind data to
690
+ * @param nodeMaterial - the node material
691
+ * @param mesh - the mesh to bind data for
692
+ */
693
+ bind(effect, nodeMaterial, mesh) {
694
+ if (!mesh) {
695
+ return;
696
+ }
697
+ const scene = mesh.getScene();
698
+ if (!this.light) {
699
+ BindLights(scene, mesh, effect, true, nodeMaterial.maxSimultaneousLights);
700
+ }
701
+ else {
702
+ BindLight(this.light, this._lightId, scene, effect, true);
703
+ }
704
+ effect.setTexture(this._environmentBrdfSamplerName, this._environmentBRDFTexture);
705
+ effect.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
706
+ const ambientScene = this._scene.ambientColor;
707
+ if (ambientScene) {
708
+ effect.setColor3("ambientFromScene", ambientScene);
709
+ }
710
+ const invertNormal = scene.useRightHandedSystem === (scene._mirroredCameraPosition != null);
711
+ effect.setFloat(this._invertNormalName, invertNormal ? -1 : 1);
712
+ effect.setFloat4("vLightingIntensity", this.directIntensity, 1, this.environmentIntensity * this._scene.environmentIntensity, this.specularIntensity);
713
+ // reflectivity bindings
714
+ const metallicF90 = this._metallicF0Factor;
715
+ effect.setColor4(this._vMetallicReflectanceFactorsName, this._metallicReflectanceColor, metallicF90);
716
+ if (nodeMaterial.imageProcessingConfiguration) {
717
+ nodeMaterial.imageProcessingConfiguration.bind(effect);
718
+ }
719
+ }
720
+ _injectVertexCode(state) {
721
+ const worldPos = this.worldPosition;
722
+ const worldNormal = this.worldNormal;
723
+ const comments = `//${this.name}`;
724
+ const isWebGPU = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */;
725
+ const scene = state.sharedData.nodeMaterial.getScene();
726
+ // Declaration
727
+ if (!this.light) {
728
+ // Emit for all lights
729
+ state._emitFunctionFromInclude(state.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", comments, {
730
+ repeatKey: "maxSimultaneousLights",
731
+ });
732
+ this._lightId = 0;
733
+ state.sharedData.dynamicUniformBlocks.push(this);
734
+ }
735
+ else {
736
+ this._lightId = (state.counters["lightCounter"] !== undefined ? state.counters["lightCounter"] : -1) + 1;
737
+ state.counters["lightCounter"] = this._lightId;
738
+ state._emitFunctionFromInclude(state.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", comments, {
739
+ replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }],
740
+ }, this._lightId.toString());
741
+ }
742
+ // Inject code in vertex
743
+ const worldPosVaryingName = "v_" + worldPos.associatedVariableName;
744
+ if (state._emitVaryingFromString(worldPosVaryingName, NodeMaterialBlockConnectionPointTypes.Vector4)) {
745
+ state.compilationString += (isWebGPU ? "vertexOutputs." : "") + `${worldPosVaryingName} = ${worldPos.associatedVariableName};\n`;
746
+ }
747
+ const worldNormalVaryingName = "v_" + worldNormal.associatedVariableName;
748
+ if (state._emitVaryingFromString(worldNormalVaryingName, NodeMaterialBlockConnectionPointTypes.Vector4)) {
749
+ state.compilationString += (isWebGPU ? "vertexOutputs." : "") + `${worldNormalVaryingName} = ${worldNormal.associatedVariableName};\n`;
750
+ }
751
+ const reflectionBlock = this.reflection.isConnected ? this.reflection.connectedPoint?.ownerBlock : null;
752
+ if (reflectionBlock) {
753
+ reflectionBlock.viewConnectionPoint = this.view;
754
+ }
755
+ state.compilationString += reflectionBlock?.handleVertexSide(state) ?? "";
756
+ if (state._emitVaryingFromString("vClipSpacePosition", NodeMaterialBlockConnectionPointTypes.Vector4, "defined(IGNORE) || DEBUGMODE > 0")) {
757
+ state._injectAtEnd += `#if DEBUGMODE > 0\n`;
758
+ state._injectAtEnd += (isWebGPU ? "vertexOutputs." : "") + `vClipSpacePosition = ${isWebGPU ? "vertexOutputs.position" : "gl_Position"};\n`;
759
+ state._injectAtEnd += `#endif\n`;
760
+ }
761
+ if (this.light) {
762
+ state.compilationString += state._emitCodeFromInclude("shadowsVertex", comments, {
763
+ replaceStrings: [
764
+ { search: /{X}/g, replace: this._lightId.toString() },
765
+ { search: /worldPos/g, replace: worldPos.associatedVariableName },
766
+ ],
767
+ });
768
+ }
769
+ else {
770
+ state.compilationString += `${state._declareLocalVar("worldPos", NodeMaterialBlockConnectionPointTypes.Vector4)} = ${worldPos.associatedVariableName};\n`;
771
+ if (this.view.isConnected) {
772
+ state.compilationString += `${state._declareLocalVar("view", NodeMaterialBlockConnectionPointTypes.Matrix)} = ${this.view.associatedVariableName};\n`;
773
+ state._emitVaryingFromString("vViewDepth", NodeMaterialBlockConnectionPointTypes.Float);
774
+ state.compilationString +=
775
+ (state.shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? "vertexOutputs." : "") +
776
+ `vViewDepth = ${scene.useRightHandedSystem ? "-" : ""}(${this.view.associatedVariableName} * ${worldPos.associatedVariableName}).z;\n`;
777
+ }
778
+ state.compilationString += state._emitCodeFromInclude("shadowsVertex", comments, {
779
+ repeatKey: "maxSimultaneousLights",
780
+ });
781
+ }
782
+ }
783
+ _getAlbedoOpacityCode(state) {
784
+ const isWebGPU = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */;
785
+ let code = isWebGPU ? "var albedoOpacityOut: albedoOpacityOutParams;\n" : `albedoOpacityOutParams albedoOpacityOut;\n`;
786
+ const albedoColor = this.baseColor.isConnected ? this.baseColor.associatedVariableName : "vec3(1.)";
787
+ const opacity = this.opacity.isConnected ? this.opacity.associatedVariableName : "1.";
788
+ code += `albedoOpacityOut = albedoOpacityBlock(
719
789
  vec4${state.fSuffix}(${albedoColor}, 1.)
720
790
  #ifdef ALBEDO
721
791
  ,vec4${state.fSuffix}(1.)
@@ -730,34 +800,34 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
730
800
 
731
801
  ${state._declareLocalVar("surfaceAlbedo", NodeMaterialBlockConnectionPointTypes.Vector3)} = albedoOpacityOut.surfaceAlbedo;
732
802
  ${state._declareLocalVar("alpha", NodeMaterialBlockConnectionPointTypes.Float)} = albedoOpacityOut.alpha;\n`;
733
- return code;
734
- }
735
- _getAmbientOcclusionCode(state) {
736
- const isWebGPU = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */;
737
- let code = isWebGPU ? "var aoOut: ambientOcclusionOutParams;\n" : `ambientOcclusionOutParams aoOut;\n`;
738
- const ao = this.ambientOcc.isConnected ? this.ambientOcc.associatedVariableName : "1.";
739
- code += `aoOut = ambientOcclusionBlock(
803
+ return code;
804
+ }
805
+ _getAmbientOcclusionCode(state) {
806
+ const isWebGPU = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */;
807
+ let code = isWebGPU ? "var aoOut: ambientOcclusionOutParams;\n" : `ambientOcclusionOutParams aoOut;\n`;
808
+ const ao = this.ambientOcc.isConnected ? this.ambientOcc.associatedVariableName : "1.";
809
+ code += `aoOut = ambientOcclusionBlock(
740
810
  #ifdef AMBIENT
741
811
  vec3${state.fSuffix}(${ao}),
742
812
  vec4${state.fSuffix}(0., 1.0, 1.0, 0.)
743
813
  #endif
744
814
  );\n`;
745
- return code;
746
- }
747
- _getReflectivityCode(state) {
748
- const isWebGPU = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */;
749
- let code = isWebGPU ? "var reflectivityOut: reflectivityOutParams;\n" : `reflectivityOutParams reflectivityOut;\n`;
750
- const aoIntensity = "1.";
751
- this._vMetallicReflectanceFactorsName = state._getFreeVariableName("vMetallicReflectanceFactors");
752
- state._emitUniformFromString(this._vMetallicReflectanceFactorsName, NodeMaterialBlockConnectionPointTypes.Vector4);
753
- this._baseDiffuseRoughnessName = state._getFreeVariableName("baseDiffuseRoughness");
754
- state._emitUniformFromString(this._baseDiffuseRoughnessName, NodeMaterialBlockConnectionPointTypes.Float);
755
- const outsideIOR = 1; // consider air as clear coat and other layers would remap in the shader.
756
- const ior = this.indexOfRefraction.connectInputBlock?.value ?? 1.5;
757
- // Based of the schlick fresnel approximation model
758
- // for dielectrics.
759
- const f0 = Math.pow((ior - outsideIOR) / (ior + outsideIOR), 2);
760
- code += `${state._declareLocalVar("baseColor", NodeMaterialBlockConnectionPointTypes.Vector3)} = surfaceAlbedo;
815
+ return code;
816
+ }
817
+ _getReflectivityCode(state) {
818
+ const isWebGPU = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */;
819
+ let code = isWebGPU ? "var reflectivityOut: reflectivityOutParams;\n" : `reflectivityOutParams reflectivityOut;\n`;
820
+ const aoIntensity = "1.";
821
+ this._vMetallicReflectanceFactorsName = state._getFreeVariableName("vMetallicReflectanceFactors");
822
+ state._emitUniformFromString(this._vMetallicReflectanceFactorsName, NodeMaterialBlockConnectionPointTypes.Vector4);
823
+ this._baseDiffuseRoughnessName = state._getFreeVariableName("baseDiffuseRoughness");
824
+ state._emitUniformFromString(this._baseDiffuseRoughnessName, NodeMaterialBlockConnectionPointTypes.Float);
825
+ const outsideIOR = 1; // consider air as clear coat and other layers would remap in the shader.
826
+ const ior = this.indexOfRefraction.connectInputBlock?.value ?? 1.5;
827
+ // Based of the schlick fresnel approximation model
828
+ // for dielectrics.
829
+ const f0 = Math.pow((ior - outsideIOR) / (ior + outsideIOR), 2);
830
+ code += `${state._declareLocalVar("baseColor", NodeMaterialBlockConnectionPointTypes.Vector3)} = surfaceAlbedo;
761
831
  ${isWebGPU ? "let" : `vec4${state.fSuffix}`} vReflectivityColor = vec4${state.fSuffix}(${this.metallic.associatedVariableName}, ${this.roughness.associatedVariableName}, ${this.indexOfRefraction.associatedVariableName || "1.5"}, ${f0});
762
832
  reflectivityOut = reflectivityBlock(
763
833
  vReflectivityColor
@@ -792,593 +862,578 @@ export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
792
862
  #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
793
863
  aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor;
794
864
  #endif\n`;
795
- return code;
796
- }
797
- _buildBlock(state) {
798
- super._buildBlock(state);
799
- this._scene = state.sharedData.scene;
800
- const isWebGPU = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */;
801
- if (!this._environmentBRDFTexture) {
802
- this._environmentBRDFTexture = GetEnvironmentBRDFTexture(this._scene);
803
- }
804
- const reflectionBlock = this.reflection.isConnected ? this.reflection.connectedPoint?.ownerBlock : null;
805
- if (reflectionBlock) {
806
- // Need those variables to be setup when calling _injectVertexCode
807
- reflectionBlock.worldPositionConnectionPoint = this.worldPosition;
808
- reflectionBlock.cameraPositionConnectionPoint = this.cameraPosition;
809
- reflectionBlock.worldNormalConnectionPoint = this.worldNormal;
810
- reflectionBlock.viewConnectionPoint = this.view;
811
- }
812
- if (state.target !== NodeMaterialBlockTargets.Fragment) {
813
- // Vertex
814
- this._injectVertexCode(state);
815
- return this;
816
- }
817
- // Fragment
818
- state.sharedData.forcedBindableBlocks.push(this);
819
- state.sharedData.blocksWithDefines.push(this);
820
- state.sharedData.blockingBlocks.push(this);
821
- if (this.generateOnlyFragmentCode) {
822
- state.sharedData.dynamicUniformBlocks.push(this);
823
- }
824
- const comments = `//${this.name}`;
825
- const normalShading = this.perturbedNormal;
826
- let worldPosVarName = this.worldPosition.associatedVariableName;
827
- let worldPosVarName4 = this.worldPosition.associatedVariableName;
828
- let worldNormalVarName = this.worldNormal.associatedVariableName;
829
- if (this.generateOnlyFragmentCode) {
830
- worldPosVarName = state._getFreeVariableName("globalWorldPos");
831
- state._emitFunction("pbr_globalworldpos", `${state._declareLocalVar(worldPosVarName, NodeMaterialBlockConnectionPointTypes.Vector3, false, true)};\n`, comments);
832
- state.compilationString += `${worldPosVarName} = ${this.worldPosition.associatedVariableName}.xyz;\n`;
833
- worldPosVarName4 = state._getFreeVariableName("globalWorldPos4");
834
- state._emitFunction("pbr_globalworldpos4", `${state._declareLocalVar(worldPosVarName4, NodeMaterialBlockConnectionPointTypes.Vector4, false, true)};\n`, comments);
835
- state.compilationString += `${worldPosVarName4} = ${this.worldPosition.associatedVariableName};\n`;
836
- worldNormalVarName = state._getFreeVariableName("globalWorldNormal");
837
- state._emitFunction("pbr_globalworldnorm", `${state._declareLocalVar(worldNormalVarName, NodeMaterialBlockConnectionPointTypes.Vector4, false, true)};\n`, comments);
838
- state.compilationString += `${worldNormalVarName} = ${this.worldNormal.associatedVariableName};\n`;
839
- state.compilationString += state._emitCodeFromInclude("shadowsVertex", comments, {
840
- repeatKey: "maxSimultaneousLights",
841
- substitutionVars: `worldPos,${this.worldPosition.associatedVariableName}`,
842
- });
843
- state.compilationString += `#if DEBUGMODE > 0\n`;
844
- state.compilationString += `${state._declareLocalVar("vClipSpacePosition", NodeMaterialBlockConnectionPointTypes.Vector4)} = vec4${state.fSuffix}((vec2${state.fSuffix}(${isWebGPU ? "fragmentInputs.position" : "gl_FragCoord.xy"}) / vec2${state.fSuffix}(1.0)) * 2.0 - 1.0, 0.0, 1.0);\n`;
845
- state.compilationString += `#endif\n`;
846
- }
847
- else {
848
- worldPosVarName = (isWebGPU ? "input." : "") + "v_" + worldPosVarName;
849
- worldNormalVarName = (isWebGPU ? "input." : "") + "v_" + worldNormalVarName;
850
- }
851
- this._environmentBrdfSamplerName = state._getFreeVariableName("environmentBrdfSampler");
852
- state._emit2DSampler(this._environmentBrdfSamplerName);
853
- state.sharedData.hints.needAlphaBlending = state.sharedData.hints.needAlphaBlending || this.useAlphaBlending;
854
- state.sharedData.hints.needAlphaTesting = state.sharedData.hints.needAlphaTesting || this.useAlphaTest;
855
- state._emitExtension("lod", "#extension GL_EXT_shader_texture_lod : enable", "defined(LODBASEDMICROSFURACE)");
856
- state._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
857
- state._emitUniformFromString("vDebugMode", NodeMaterialBlockConnectionPointTypes.Vector2, "defined(IGNORE) || DEBUGMODE > 0");
858
- state._emitUniformFromString("ambientFromScene", NodeMaterialBlockConnectionPointTypes.Vector3);
859
- // Image processing uniforms
860
- state.uniforms.push("exposureLinear");
861
- state.uniforms.push("contrast");
862
- state.uniforms.push("vInverseScreenSize");
863
- state.uniforms.push("vignetteSettings1");
864
- state.uniforms.push("vignetteSettings2");
865
- state.uniforms.push("vCameraColorCurveNegative");
866
- state.uniforms.push("vCameraColorCurveNeutral");
867
- state.uniforms.push("vCameraColorCurvePositive");
868
- state.uniforms.push("txColorTransform");
869
- state.uniforms.push("colorTransformSettings");
870
- state.uniforms.push("ditherIntensity");
871
- //
872
- // Includes
873
- //
874
- if (!this.light) {
875
- if (this.generateOnlyFragmentCode && this.view.isConnected) {
876
- state.compilationString += `${state._declareLocalVar("vViewDepth", NodeMaterialBlockConnectionPointTypes.Float)} = (${this.view.associatedVariableName} * ${worldPosVarName4}).z;\n`;
865
+ return code;
877
866
  }
878
- // Emit for all lights
879
- state._emitFunctionFromInclude(state.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", comments, {
880
- repeatKey: "maxSimultaneousLights",
881
- substitutionVars: this.generateOnlyFragmentCode ? "varying," : undefined,
882
- });
883
- }
884
- else {
885
- state._emitFunctionFromInclude(state.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", comments, {
886
- replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }],
887
- }, this._lightId.toString());
888
- }
889
- state._emitFunctionFromInclude("helperFunctions", comments);
890
- state._emitFunctionFromInclude("importanceSampling", comments);
891
- state._emitFunctionFromInclude("pbrHelperFunctions", comments);
892
- state._emitFunctionFromInclude("imageProcessingDeclaration", comments);
893
- state._emitFunctionFromInclude("imageProcessingFunctions", comments);
894
- state._emitFunctionFromInclude("shadowsFragmentFunctions", comments);
895
- state._emitFunctionFromInclude("pbrDirectLightingSetupFunctions", comments);
896
- state._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions", comments);
897
- state._emitFunctionFromInclude("pbrBRDFFunctions", comments, {
898
- replaceStrings: [{ search: /REFLECTIONMAP_SKYBOX/g, replace: reflectionBlock?._defineSkyboxName ?? "REFLECTIONMAP_SKYBOX" }],
899
- });
900
- state._emitFunctionFromInclude("hdrFilteringFunctions", comments);
901
- if (!isWebGPU) {
902
- state._emitFunctionFromInclude("pbrDirectLightingFunctions", comments);
903
- }
904
- state._emitFunctionFromInclude("pbrIBLFunctions", comments);
905
- state._emitFunctionFromInclude("pbrBlockAlbedoOpacity", comments);
906
- state._emitFunctionFromInclude("pbrBlockReflectivity", comments);
907
- state._emitFunctionFromInclude("pbrBlockAmbientOcclusion", comments);
908
- state._emitFunctionFromInclude("pbrBlockAlphaFresnel", comments);
909
- state._emitFunctionFromInclude("pbrBlockAnisotropic", comments);
910
- //
911
- // code
912
- //
913
- state._emitUniformFromString("vLightingIntensity", NodeMaterialBlockConnectionPointTypes.Vector4);
914
- if (reflectionBlock?.generateOnlyFragmentCode) {
915
- state.compilationString += reflectionBlock.handleVertexSide(state);
916
- }
917
- // _____________________________ Geometry Information ____________________________
918
- this._vNormalWName = state._getFreeVariableName("vNormalW");
919
- state.compilationString += `${state._declareLocalVar(this._vNormalWName, NodeMaterialBlockConnectionPointTypes.Vector4)} = normalize(${worldNormalVarName});\n`;
920
- if (state._registerTempVariable("viewDirectionW")) {
921
- state.compilationString += `${state._declareLocalVar("viewDirectionW", NodeMaterialBlockConnectionPointTypes.Vector3)} = normalize(${this.cameraPosition.associatedVariableName} - ${worldPosVarName}.xyz);\n`;
922
- }
923
- state.compilationString += `${state._declareLocalVar("geometricNormalW", NodeMaterialBlockConnectionPointTypes.Vector3)} = ${this._vNormalWName}.xyz;\n`;
924
- state.compilationString += `${state._declareLocalVar("normalW", NodeMaterialBlockConnectionPointTypes.Vector3)} = ${normalShading.isConnected ? "normalize(" + normalShading.associatedVariableName + ".xyz)" : "geometricNormalW"};\n`;
925
- this._invertNormalName = state._getFreeVariableName("invertNormal");
926
- state._emitUniformFromString(this._invertNormalName, NodeMaterialBlockConnectionPointTypes.Float);
927
- state.compilationString += state._emitCodeFromInclude("pbrBlockNormalFinal", comments, {
928
- replaceStrings: [
929
- { search: /vPositionW/g, replace: worldPosVarName + ".xyz" },
930
- { search: /vEyePosition.w/g, replace: this._invertNormalName },
931
- ],
932
- });
933
- // _____________________________ Albedo & Opacity ______________________________
934
- state.compilationString += this._getAlbedoOpacityCode(state);
935
- state.compilationString += state._emitCodeFromInclude("depthPrePass", comments);
936
- // _____________________________ AO _______________________________
937
- state.compilationString += this._getAmbientOcclusionCode(state);
938
- state.compilationString += state._emitCodeFromInclude("pbrBlockLightmapInit", comments);
939
- // _____________________________ UNLIT _______________________________
940
- state.compilationString += `#ifdef UNLIT
941
- ${state._declareLocalVar("diffuseBase", NodeMaterialBlockConnectionPointTypes.Vector3)} = vec3${state.fSuffix}(1., 1., 1.);
942
- #else\n`;
943
- // _____________________________ Reflectivity _______________________________
944
- state.compilationString += this._getReflectivityCode(state);
945
- // _____________________________ Geometry info _________________________________
946
- state.compilationString += state._emitCodeFromInclude("pbrBlockGeometryInfo", comments, {
947
- replaceStrings: [
948
- { search: /REFLECTIONMAP_SKYBOX/g, replace: reflectionBlock?._defineSkyboxName ?? "REFLECTIONMAP_SKYBOX" },
949
- { search: /REFLECTIONMAP_3D/g, replace: reflectionBlock?._define3DName ?? "REFLECTIONMAP_3D" },
950
- ],
951
- });
952
- // _____________________________ Anisotropy _______________________________________
953
- const anisotropyBlock = this.anisotropy.isConnected ? this.anisotropy.connectedPoint?.ownerBlock : null;
954
- if (anisotropyBlock) {
955
- anisotropyBlock.worldPositionConnectionPoint = this.worldPosition;
956
- anisotropyBlock.worldNormalConnectionPoint = this.worldNormal;
957
- state.compilationString += anisotropyBlock.getCode(state, !this.perturbedNormal.isConnected);
958
- }
959
- // _____________________________ Reflection _______________________________________
960
- if (reflectionBlock && reflectionBlock.hasTexture) {
961
- state.compilationString += reflectionBlock.getCode(state, anisotropyBlock ? "anisotropicOut.anisotropicNormal" : "normalW");
962
- }
963
- state._emitFunctionFromInclude("pbrBlockReflection", comments, {
964
- replaceStrings: [
965
- { search: /computeReflectionCoords/g, replace: "computeReflectionCoordsPBR" },
966
- { search: /REFLECTIONMAP_3D/g, replace: reflectionBlock?._define3DName ?? "REFLECTIONMAP_3D" },
967
- { search: /REFLECTIONMAP_OPPOSITEZ/g, replace: reflectionBlock?._defineOppositeZ ?? "REFLECTIONMAP_OPPOSITEZ" },
968
- { search: /REFLECTIONMAP_PROJECTION/g, replace: reflectionBlock?._defineProjectionName ?? "REFLECTIONMAP_PROJECTION" },
969
- { search: /REFLECTIONMAP_SKYBOX/g, replace: reflectionBlock?._defineSkyboxName ?? "REFLECTIONMAP_SKYBOX" },
970
- { search: /LODINREFLECTIONALPHA/g, replace: reflectionBlock?._defineLODReflectionAlpha ?? "LODINREFLECTIONALPHA" },
971
- { search: /LINEARSPECULARREFLECTION/g, replace: reflectionBlock?._defineLinearSpecularReflection ?? "LINEARSPECULARREFLECTION" },
972
- { search: /vReflectionFilteringInfo/g, replace: reflectionBlock?._vReflectionFilteringInfoName ?? "vReflectionFilteringInfo" },
973
- ],
974
- });
975
- // ___________________ Compute Reflectance aka R0 F0 info _________________________
976
- state.compilationString += state._emitCodeFromInclude("pbrBlockReflectance0", comments, {
977
- replaceStrings: [{ search: /metallicReflectanceFactors/g, replace: (isWebGPU ? "uniforms." : "") + this._vMetallicReflectanceFactorsName }],
978
- });
979
- // ________________________________ Sheen ______________________________
980
- const sheenBlock = this.sheen.isConnected ? this.sheen.connectedPoint?.ownerBlock : null;
981
- if (sheenBlock) {
982
- state.compilationString += sheenBlock.getCode(reflectionBlock, state);
983
- }
984
- state._emitFunctionFromInclude("pbrBlockSheen", comments, {
985
- replaceStrings: [
986
- { search: /REFLECTIONMAP_3D/g, replace: reflectionBlock?._define3DName ?? "REFLECTIONMAP_3D" },
987
- { search: /REFLECTIONMAP_SKYBOX/g, replace: reflectionBlock?._defineSkyboxName ?? "REFLECTIONMAP_SKYBOX" },
988
- { search: /LODINREFLECTIONALPHA/g, replace: reflectionBlock?._defineLODReflectionAlpha ?? "LODINREFLECTIONALPHA" },
989
- { search: /LINEARSPECULARREFLECTION/g, replace: reflectionBlock?._defineLinearSpecularReflection ?? "LINEARSPECULARREFLECTION" },
990
- ],
991
- });
992
- // ____________________ Clear Coat Initialization Code _____________________
993
- const clearcoatBlock = this.clearcoat.isConnected ? this.clearcoat.connectedPoint?.ownerBlock : null;
994
- state.compilationString += ClearCoatBlock._GetInitializationCode(state, clearcoatBlock);
995
- // _____________________________ Iridescence _______________________________
996
- const iridescenceBlock = this.iridescence.isConnected ? this.iridescence.connectedPoint?.ownerBlock : null;
997
- state.compilationString += IridescenceBlock.GetCode(iridescenceBlock, state);
998
- state._emitFunctionFromInclude("pbrBlockIridescence", comments, {
999
- replaceStrings: [],
1000
- });
1001
- // _____________________________ Clear Coat ____________________________
1002
- const generateTBNSpace = !this.perturbedNormal.isConnected && !this.anisotropy.isConnected;
1003
- const isTangentConnectedToPerturbNormal = this.perturbedNormal.isConnected && (this.perturbedNormal.connectedPoint?.ownerBlock).worldTangent?.isConnected;
1004
- const isTangentConnectedToAnisotropy = this.anisotropy.isConnected && (this.anisotropy.connectedPoint?.ownerBlock).worldTangent.isConnected;
1005
- let vTBNAvailable = isTangentConnectedToPerturbNormal || (!this.perturbedNormal.isConnected && isTangentConnectedToAnisotropy);
1006
- state.compilationString += ClearCoatBlock.GetCode(state, clearcoatBlock, reflectionBlock, worldPosVarName, generateTBNSpace, vTBNAvailable, worldNormalVarName);
1007
- if (generateTBNSpace) {
1008
- vTBNAvailable = clearcoatBlock?.worldTangent.isConnected ?? false;
1009
- }
1010
- state._emitFunctionFromInclude("pbrBlockClearcoat", comments, {
1011
- replaceStrings: [
1012
- { search: /computeReflectionCoords/g, replace: "computeReflectionCoordsPBR" },
1013
- { search: /REFLECTIONMAP_3D/g, replace: reflectionBlock?._define3DName ?? "REFLECTIONMAP_3D" },
1014
- { search: /REFLECTIONMAP_OPPOSITEZ/g, replace: reflectionBlock?._defineOppositeZ ?? "REFLECTIONMAP_OPPOSITEZ" },
1015
- { search: /REFLECTIONMAP_PROJECTION/g, replace: reflectionBlock?._defineProjectionName ?? "REFLECTIONMAP_PROJECTION" },
1016
- { search: /REFLECTIONMAP_SKYBOX/g, replace: reflectionBlock?._defineSkyboxName ?? "REFLECTIONMAP_SKYBOX" },
1017
- { search: /LODINREFLECTIONALPHA/g, replace: reflectionBlock?._defineLODReflectionAlpha ?? "LODINREFLECTIONALPHA" },
1018
- { search: /LINEARSPECULARREFLECTION/g, replace: reflectionBlock?._defineLinearSpecularReflection ?? "LINEARSPECULARREFLECTION" },
1019
- { search: /defined\(TANGENT\)/g, replace: vTBNAvailable ? "defined(TANGENT)" : "defined(IGNORE)" },
1020
- ],
1021
- });
1022
- // _________________________ Specular Environment Reflectance __________________________
1023
- state.compilationString += state._emitCodeFromInclude("pbrBlockReflectance", comments, {
1024
- replaceStrings: [
1025
- { search: /REFLECTIONMAP_SKYBOX/g, replace: reflectionBlock?._defineSkyboxName ?? "REFLECTIONMAP_SKYBOX" },
1026
- { search: /REFLECTIONMAP_3D/g, replace: reflectionBlock?._define3DName ?? "REFLECTIONMAP_3D" },
1027
- { search: /uniforms\.vReflectivityColor/g, replace: "vReflectivityColor" },
1028
- ],
1029
- });
1030
- // ___________________________________ SubSurface ______________________________________
1031
- const subsurfaceBlock = this.subsurface.isConnected ? this.subsurface.connectedPoint?.ownerBlock : null;
1032
- const refractionBlock = this.subsurface.isConnected
1033
- ? (this.subsurface.connectedPoint?.ownerBlock).refraction.connectedPoint?.ownerBlock
1034
- : null;
1035
- if (refractionBlock) {
1036
- refractionBlock.viewConnectionPoint = this.view;
1037
- refractionBlock.indexOfRefractionConnectionPoint = this.indexOfRefraction;
1038
- }
1039
- state.compilationString += SubSurfaceBlock.GetCode(state, subsurfaceBlock, reflectionBlock, worldPosVarName);
1040
- state._emitFunctionFromInclude("pbrBlockSubSurface", comments, {
1041
- replaceStrings: [
1042
- { search: /REFLECTIONMAP_3D/g, replace: reflectionBlock?._define3DName ?? "REFLECTIONMAP_3D" },
1043
- { search: /REFLECTIONMAP_OPPOSITEZ/g, replace: reflectionBlock?._defineOppositeZ ?? "REFLECTIONMAP_OPPOSITEZ" },
1044
- { search: /REFLECTIONMAP_PROJECTION/g, replace: reflectionBlock?._defineProjectionName ?? "REFLECTIONMAP_PROJECTION" },
1045
- { search: /SS_REFRACTIONMAP_3D/g, replace: refractionBlock?._define3DName ?? "SS_REFRACTIONMAP_3D" },
1046
- { search: /SS_LODINREFRACTIONALPHA/g, replace: refractionBlock?._defineLODRefractionAlpha ?? "SS_LODINREFRACTIONALPHA" },
1047
- { search: /SS_LINEARSPECULARREFRACTION/g, replace: refractionBlock?._defineLinearSpecularRefraction ?? "SS_LINEARSPECULARREFRACTION" },
1048
- { search: /SS_REFRACTIONMAP_OPPOSITEZ/g, replace: refractionBlock?._defineOppositeZ ?? "SS_REFRACTIONMAP_OPPOSITEZ" },
1049
- ],
1050
- });
1051
- if (isWebGPU) {
1052
- state._emitFunctionFromInclude("pbrDirectLightingFunctions", comments);
1053
- }
1054
- if (!isWebGPU) {
1055
- // In WebGPU, those functions are part of pbrDirectLightingFunctions
1056
- state._emitFunctionFromInclude("pbrClusteredLightingFunctions", comments);
1057
- }
1058
- // _____________________________ Direct Lighting Info __________________________________
1059
- state.compilationString += state._emitCodeFromInclude("pbrBlockDirectLighting", comments);
1060
- if (this.light) {
1061
- state.compilationString += state._emitCodeFromInclude("lightFragment", comments, {
1062
- replaceStrings: [
1063
- { search: /{X}/g, replace: this._lightId.toString() },
1064
- { search: new RegExp(`${isWebGPU ? "fragmentInputs." : ""}vPositionW`, "g"), replace: worldPosVarName + ".xyz" },
1065
- { search: /uniforms\.vReflectivityColor/g, replace: "vReflectivityColor" },
1066
- ],
1067
- });
1068
- }
1069
- else {
1070
- let substitutionVars = `vPositionW,${worldPosVarName}.xyz`;
1071
- if (isWebGPU) {
1072
- substitutionVars = "fragmentInputs." + substitutionVars;
867
+ _buildBlock(state) {
868
+ super._buildBlock(state);
869
+ this._scene = state.sharedData.scene;
870
+ const isWebGPU = state.shaderLanguage === 1 /* ShaderLanguage.WGSL */;
871
+ if (!this._environmentBRDFTexture) {
872
+ this._environmentBRDFTexture = GetEnvironmentBRDFTexture(this._scene);
873
+ }
874
+ const reflectionBlock = this.reflection.isConnected ? this.reflection.connectedPoint?.ownerBlock : null;
875
+ if (reflectionBlock) {
876
+ // Need those variables to be setup when calling _injectVertexCode
877
+ reflectionBlock.worldPositionConnectionPoint = this.worldPosition;
878
+ reflectionBlock.cameraPositionConnectionPoint = this.cameraPosition;
879
+ reflectionBlock.worldNormalConnectionPoint = this.worldNormal;
880
+ reflectionBlock.viewConnectionPoint = this.view;
881
+ }
882
+ if (state.target !== NodeMaterialBlockTargets.Fragment) {
883
+ // Vertex
884
+ this._injectVertexCode(state);
885
+ return this;
886
+ }
887
+ // Fragment
888
+ state.sharedData.forcedBindableBlocks.push(this);
889
+ state.sharedData.blocksWithDefines.push(this);
890
+ state.sharedData.blockingBlocks.push(this);
1073
891
  if (this.generateOnlyFragmentCode) {
1074
- substitutionVars += `,fragmentInputs.vViewDepth,vViewDepth`;
892
+ state.sharedData.dynamicUniformBlocks.push(this);
1075
893
  }
1076
- }
1077
- state.compilationString += state._emitCodeFromInclude("lightFragment", comments, {
1078
- repeatKey: "maxSimultaneousLights",
1079
- substitutionVars: substitutionVars + ",uniforms.vReflectivityColor,vReflectivityColor",
1080
- });
1081
- }
1082
- // _____________________________ Compute Final Lit Components ________________________
1083
- state.compilationString += state._emitCodeFromInclude("pbrBlockFinalLitComponents", comments);
1084
- // _____________________________ UNLIT (2) ________________________
1085
- state.compilationString += `#endif\n`; // UNLIT
1086
- // _____________________________ Compute Final Unlit Components ________________________
1087
- const aoColor = this.ambientColor.isConnected ? this.ambientColor.associatedVariableName : `vec3${state.fSuffix}(0., 0., 0.)`;
1088
- let aoDirectLightIntensity = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();
1089
- if (aoDirectLightIntensity.indexOf(".") === -1) {
1090
- aoDirectLightIntensity += ".";
1091
- }
1092
- let replaceStrings = [
1093
- { search: /vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g, replace: "" },
1094
- { search: new RegExp(`${isWebGPU ? "uniforms." : ""}vAmbientColor`, "g"), replace: aoColor + ` * ${isWebGPU ? "uniforms." : ""}ambientFromScene` },
1095
- { search: new RegExp(`${isWebGPU ? "uniforms." : ""}vAmbientInfos.w`, "g"), replace: aoDirectLightIntensity },
1096
- ];
1097
- if (isWebGPU) {
1098
- replaceStrings[0] = { search: /var finalEmissive[\s\S]*?finalEmissive\*=uniforms.vLightingIntensity\.y;/g, replace: "" };
1099
- }
1100
- state.compilationString += state._emitCodeFromInclude("pbrBlockFinalUnlitComponents", comments, {
1101
- replaceStrings: replaceStrings,
1102
- });
1103
- // _____________________________ Output Final Color Composition ________________________
1104
- state.compilationString += state._emitCodeFromInclude("pbrBlockFinalColorComposition", comments, {
1105
- replaceStrings: [{ search: /finalEmissive/g, replace: `vec3${state.fSuffix}(0.)` }],
1106
- });
1107
- // _____________________________ Apply image processing ________________________
1108
- if (isWebGPU) {
1109
- replaceStrings = [{ search: /mesh.visibility/g, replace: "1." }];
1110
- }
1111
- else {
1112
- replaceStrings = [{ search: /visibility/g, replace: "1." }];
1113
- }
1114
- state.compilationString += state._emitCodeFromInclude("pbrBlockImageProcessing", comments, {
1115
- replaceStrings: replaceStrings,
1116
- });
1117
- // _____________________________ Generate debug code ________________________
1118
- const colorOutput = isWebGPU ? "fragmentOutputs.color" : "gl_FragColor";
1119
- replaceStrings = [
1120
- { search: new RegExp(`${isWebGPU ? "fragmentInputs." : ""}vNormalW`, "g"), replace: this._vNormalWName },
1121
- { search: new RegExp(`${isWebGPU ? "fragmentInputs." : ""}vPositionW`, "g"), replace: worldPosVarName },
1122
- { search: /uniforms\.vReflectivityColor/g, replace: "vReflectivityColor" },
1123
- {
1124
- search: /albedoTexture\.rgb;/g,
1125
- replace: `vec3${state.fSuffix}(1.);\n${colorOutput}.rgb = toGammaSpace(${colorOutput}.rgb);\n`,
1126
- },
1127
- ];
1128
- state.compilationString += state._emitCodeFromInclude("pbrDebug", comments, {
1129
- replaceStrings: replaceStrings,
1130
- });
1131
- // _____________________________ Generate end points ________________________
1132
- for (const output of this._outputs) {
1133
- if (output.hasEndpoints) {
1134
- const remap = MapOutputToVariable[output.name];
1135
- if (remap) {
1136
- const [varName, conditions] = remap;
1137
- if (conditions) {
1138
- state.compilationString += `#if ${conditions}\n`;
894
+ const comments = `//${this.name}`;
895
+ const normalShading = this.perturbedNormal;
896
+ let worldPosVarName = this.worldPosition.associatedVariableName;
897
+ let worldPosVarName4 = this.worldPosition.associatedVariableName;
898
+ let worldNormalVarName = this.worldNormal.associatedVariableName;
899
+ if (this.generateOnlyFragmentCode) {
900
+ worldPosVarName = state._getFreeVariableName("globalWorldPos");
901
+ state._emitFunction("pbr_globalworldpos", `${state._declareLocalVar(worldPosVarName, NodeMaterialBlockConnectionPointTypes.Vector3, false, true)};\n`, comments);
902
+ state.compilationString += `${worldPosVarName} = ${this.worldPosition.associatedVariableName}.xyz;\n`;
903
+ worldPosVarName4 = state._getFreeVariableName("globalWorldPos4");
904
+ state._emitFunction("pbr_globalworldpos4", `${state._declareLocalVar(worldPosVarName4, NodeMaterialBlockConnectionPointTypes.Vector4, false, true)};\n`, comments);
905
+ state.compilationString += `${worldPosVarName4} = ${this.worldPosition.associatedVariableName};\n`;
906
+ worldNormalVarName = state._getFreeVariableName("globalWorldNormal");
907
+ state._emitFunction("pbr_globalworldnorm", `${state._declareLocalVar(worldNormalVarName, NodeMaterialBlockConnectionPointTypes.Vector4, false, true)};\n`, comments);
908
+ state.compilationString += `${worldNormalVarName} = ${this.worldNormal.associatedVariableName};\n`;
909
+ state.compilationString += state._emitCodeFromInclude("shadowsVertex", comments, {
910
+ repeatKey: "maxSimultaneousLights",
911
+ substitutionVars: `worldPos,${this.worldPosition.associatedVariableName}`,
912
+ });
913
+ state.compilationString += `#if DEBUGMODE > 0\n`;
914
+ state.compilationString += `${state._declareLocalVar("vClipSpacePosition", NodeMaterialBlockConnectionPointTypes.Vector4)} = vec4${state.fSuffix}((vec2${state.fSuffix}(${isWebGPU ? "fragmentInputs.position" : "gl_FragCoord.xy"}) / vec2${state.fSuffix}(1.0)) * 2.0 - 1.0, 0.0, 1.0);\n`;
915
+ state.compilationString += `#endif\n`;
916
+ }
917
+ else {
918
+ worldPosVarName = (isWebGPU ? "input." : "") + "v_" + worldPosVarName;
919
+ worldNormalVarName = (isWebGPU ? "input." : "") + "v_" + worldNormalVarName;
920
+ }
921
+ this._environmentBrdfSamplerName = state._getFreeVariableName("environmentBrdfSampler");
922
+ state._emit2DSampler(this._environmentBrdfSamplerName);
923
+ state.sharedData.hints.needAlphaBlending = state.sharedData.hints.needAlphaBlending || this.useAlphaBlending;
924
+ state.sharedData.hints.needAlphaTesting = state.sharedData.hints.needAlphaTesting || this.useAlphaTest;
925
+ state._emitExtension("lod", "#extension GL_EXT_shader_texture_lod : enable", "defined(LODBASEDMICROSFURACE)");
926
+ state._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
927
+ state._emitUniformFromString("vDebugMode", NodeMaterialBlockConnectionPointTypes.Vector2, "defined(IGNORE) || DEBUGMODE > 0");
928
+ state._emitUniformFromString("ambientFromScene", NodeMaterialBlockConnectionPointTypes.Vector3);
929
+ // Image processing uniforms
930
+ state.uniforms.push("exposureLinear");
931
+ state.uniforms.push("contrast");
932
+ state.uniforms.push("vInverseScreenSize");
933
+ state.uniforms.push("vignetteSettings1");
934
+ state.uniforms.push("vignetteSettings2");
935
+ state.uniforms.push("vCameraColorCurveNegative");
936
+ state.uniforms.push("vCameraColorCurveNeutral");
937
+ state.uniforms.push("vCameraColorCurvePositive");
938
+ state.uniforms.push("txColorTransform");
939
+ state.uniforms.push("colorTransformSettings");
940
+ state.uniforms.push("ditherIntensity");
941
+ //
942
+ // Includes
943
+ //
944
+ if (!this.light) {
945
+ if (this.generateOnlyFragmentCode && this.view.isConnected) {
946
+ state.compilationString += `${state._declareLocalVar("vViewDepth", NodeMaterialBlockConnectionPointTypes.Float)} = (${this.view.associatedVariableName} * ${worldPosVarName4}).z;\n`;
1139
947
  }
1140
- state.compilationString += `${state._declareOutput(output)} = ${varName};\n`;
1141
- if (conditions) {
1142
- state.compilationString += `#else\n`;
1143
- state.compilationString += `${state._declareOutput(output)} = vec3${state.fSuffix}(0.);\n`;
1144
- state.compilationString += `#endif\n`;
948
+ // Emit for all lights
949
+ state._emitFunctionFromInclude(state.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", comments, {
950
+ repeatKey: "maxSimultaneousLights",
951
+ substitutionVars: this.generateOnlyFragmentCode ? "varying," : undefined,
952
+ });
953
+ }
954
+ else {
955
+ state._emitFunctionFromInclude(state.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", comments, {
956
+ replaceStrings: [{ search: /{X}/g, replace: this._lightId.toString() }],
957
+ }, this._lightId.toString());
958
+ }
959
+ state._emitFunctionFromInclude("helperFunctions", comments);
960
+ state._emitFunctionFromInclude("importanceSampling", comments);
961
+ state._emitFunctionFromInclude("pbrHelperFunctions", comments);
962
+ state._emitFunctionFromInclude("imageProcessingDeclaration", comments);
963
+ state._emitFunctionFromInclude("imageProcessingFunctions", comments);
964
+ state._emitFunctionFromInclude("shadowsFragmentFunctions", comments);
965
+ state._emitFunctionFromInclude("pbrDirectLightingSetupFunctions", comments);
966
+ state._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions", comments);
967
+ state._emitFunctionFromInclude("pbrBRDFFunctions", comments, {
968
+ replaceStrings: [{ search: /REFLECTIONMAP_SKYBOX/g, replace: reflectionBlock?._defineSkyboxName ?? "REFLECTIONMAP_SKYBOX" }],
969
+ });
970
+ state._emitFunctionFromInclude("hdrFilteringFunctions", comments);
971
+ if (!isWebGPU) {
972
+ state._emitFunctionFromInclude("pbrDirectLightingFunctions", comments);
973
+ }
974
+ state._emitFunctionFromInclude("pbrIBLFunctions", comments);
975
+ state._emitFunctionFromInclude("pbrBlockAlbedoOpacity", comments);
976
+ state._emitFunctionFromInclude("pbrBlockReflectivity", comments);
977
+ state._emitFunctionFromInclude("pbrBlockAmbientOcclusion", comments);
978
+ state._emitFunctionFromInclude("pbrBlockAlphaFresnel", comments);
979
+ state._emitFunctionFromInclude("pbrBlockAnisotropic", comments);
980
+ //
981
+ // code
982
+ //
983
+ state._emitUniformFromString("vLightingIntensity", NodeMaterialBlockConnectionPointTypes.Vector4);
984
+ if (reflectionBlock?.generateOnlyFragmentCode) {
985
+ state.compilationString += reflectionBlock.handleVertexSide(state);
986
+ }
987
+ // _____________________________ Geometry Information ____________________________
988
+ this._vNormalWName = state._getFreeVariableName("vNormalW");
989
+ state.compilationString += `${state._declareLocalVar(this._vNormalWName, NodeMaterialBlockConnectionPointTypes.Vector4)} = normalize(${worldNormalVarName});\n`;
990
+ if (state._registerTempVariable("viewDirectionW")) {
991
+ state.compilationString += `${state._declareLocalVar("viewDirectionW", NodeMaterialBlockConnectionPointTypes.Vector3)} = normalize(${this.cameraPosition.associatedVariableName} - ${worldPosVarName}.xyz);\n`;
992
+ }
993
+ state.compilationString += `${state._declareLocalVar("geometricNormalW", NodeMaterialBlockConnectionPointTypes.Vector3)} = ${this._vNormalWName}.xyz;\n`;
994
+ state.compilationString += `${state._declareLocalVar("normalW", NodeMaterialBlockConnectionPointTypes.Vector3)} = ${normalShading.isConnected ? "normalize(" + normalShading.associatedVariableName + ".xyz)" : "geometricNormalW"};\n`;
995
+ this._invertNormalName = state._getFreeVariableName("invertNormal");
996
+ state._emitUniformFromString(this._invertNormalName, NodeMaterialBlockConnectionPointTypes.Float);
997
+ state.compilationString += state._emitCodeFromInclude("pbrBlockNormalFinal", comments, {
998
+ replaceStrings: [
999
+ { search: /vPositionW/g, replace: worldPosVarName + ".xyz" },
1000
+ { search: /vEyePosition.w/g, replace: this._invertNormalName },
1001
+ ],
1002
+ });
1003
+ // _____________________________ Albedo & Opacity ______________________________
1004
+ state.compilationString += this._getAlbedoOpacityCode(state);
1005
+ state.compilationString += state._emitCodeFromInclude("depthPrePass", comments);
1006
+ // _____________________________ AO _______________________________
1007
+ state.compilationString += this._getAmbientOcclusionCode(state);
1008
+ state.compilationString += state._emitCodeFromInclude("pbrBlockLightmapInit", comments);
1009
+ // _____________________________ UNLIT _______________________________
1010
+ state.compilationString += `#ifdef UNLIT
1011
+ ${state._declareLocalVar("diffuseBase", NodeMaterialBlockConnectionPointTypes.Vector3)} = vec3${state.fSuffix}(1., 1., 1.);
1012
+ #else\n`;
1013
+ // _____________________________ Reflectivity _______________________________
1014
+ state.compilationString += this._getReflectivityCode(state);
1015
+ // _____________________________ Geometry info _________________________________
1016
+ state.compilationString += state._emitCodeFromInclude("pbrBlockGeometryInfo", comments, {
1017
+ replaceStrings: [
1018
+ { search: /REFLECTIONMAP_SKYBOX/g, replace: reflectionBlock?._defineSkyboxName ?? "REFLECTIONMAP_SKYBOX" },
1019
+ { search: /REFLECTIONMAP_3D/g, replace: reflectionBlock?._define3DName ?? "REFLECTIONMAP_3D" },
1020
+ ],
1021
+ });
1022
+ // _____________________________ Anisotropy _______________________________________
1023
+ const anisotropyBlock = this.anisotropy.isConnected ? this.anisotropy.connectedPoint?.ownerBlock : null;
1024
+ if (anisotropyBlock) {
1025
+ anisotropyBlock.worldPositionConnectionPoint = this.worldPosition;
1026
+ anisotropyBlock.worldNormalConnectionPoint = this.worldNormal;
1027
+ state.compilationString += anisotropyBlock.getCode(state, !this.perturbedNormal.isConnected);
1028
+ }
1029
+ // _____________________________ Reflection _______________________________________
1030
+ if (reflectionBlock && reflectionBlock.hasTexture) {
1031
+ state.compilationString += reflectionBlock.getCode(state, anisotropyBlock ? "anisotropicOut.anisotropicNormal" : "normalW");
1032
+ }
1033
+ state._emitFunctionFromInclude("pbrBlockReflection", comments, {
1034
+ replaceStrings: [
1035
+ { search: /computeReflectionCoords/g, replace: "computeReflectionCoordsPBR" },
1036
+ { search: /REFLECTIONMAP_3D/g, replace: reflectionBlock?._define3DName ?? "REFLECTIONMAP_3D" },
1037
+ { search: /REFLECTIONMAP_OPPOSITEZ/g, replace: reflectionBlock?._defineOppositeZ ?? "REFLECTIONMAP_OPPOSITEZ" },
1038
+ { search: /REFLECTIONMAP_PROJECTION/g, replace: reflectionBlock?._defineProjectionName ?? "REFLECTIONMAP_PROJECTION" },
1039
+ { search: /REFLECTIONMAP_SKYBOX/g, replace: reflectionBlock?._defineSkyboxName ?? "REFLECTIONMAP_SKYBOX" },
1040
+ { search: /LODINREFLECTIONALPHA/g, replace: reflectionBlock?._defineLODReflectionAlpha ?? "LODINREFLECTIONALPHA" },
1041
+ { search: /LINEARSPECULARREFLECTION/g, replace: reflectionBlock?._defineLinearSpecularReflection ?? "LINEARSPECULARREFLECTION" },
1042
+ { search: /vReflectionFilteringInfo/g, replace: reflectionBlock?._vReflectionFilteringInfoName ?? "vReflectionFilteringInfo" },
1043
+ ],
1044
+ });
1045
+ // ___________________ Compute Reflectance aka R0 F0 info _________________________
1046
+ state.compilationString += state._emitCodeFromInclude("pbrBlockReflectance0", comments, {
1047
+ replaceStrings: [{ search: /metallicReflectanceFactors/g, replace: (isWebGPU ? "uniforms." : "") + this._vMetallicReflectanceFactorsName }],
1048
+ });
1049
+ // ________________________________ Sheen ______________________________
1050
+ const sheenBlock = this.sheen.isConnected ? this.sheen.connectedPoint?.ownerBlock : null;
1051
+ if (sheenBlock) {
1052
+ state.compilationString += sheenBlock.getCode(reflectionBlock, state);
1053
+ }
1054
+ state._emitFunctionFromInclude("pbrBlockSheen", comments, {
1055
+ replaceStrings: [
1056
+ { search: /REFLECTIONMAP_3D/g, replace: reflectionBlock?._define3DName ?? "REFLECTIONMAP_3D" },
1057
+ { search: /REFLECTIONMAP_SKYBOX/g, replace: reflectionBlock?._defineSkyboxName ?? "REFLECTIONMAP_SKYBOX" },
1058
+ { search: /LODINREFLECTIONALPHA/g, replace: reflectionBlock?._defineLODReflectionAlpha ?? "LODINREFLECTIONALPHA" },
1059
+ { search: /LINEARSPECULARREFLECTION/g, replace: reflectionBlock?._defineLinearSpecularReflection ?? "LINEARSPECULARREFLECTION" },
1060
+ ],
1061
+ });
1062
+ // ____________________ Clear Coat Initialization Code _____________________
1063
+ const clearcoatBlock = this.clearcoat.isConnected ? this.clearcoat.connectedPoint?.ownerBlock : null;
1064
+ state.compilationString += ClearCoatBlock._GetInitializationCode(state, clearcoatBlock);
1065
+ // _____________________________ Iridescence _______________________________
1066
+ const iridescenceBlock = this.iridescence.isConnected ? this.iridescence.connectedPoint?.ownerBlock : null;
1067
+ state.compilationString += IridescenceBlock.GetCode(iridescenceBlock, state);
1068
+ state._emitFunctionFromInclude("pbrBlockIridescence", comments, {
1069
+ replaceStrings: [],
1070
+ });
1071
+ // _____________________________ Clear Coat ____________________________
1072
+ const generateTBNSpace = !this.perturbedNormal.isConnected && !this.anisotropy.isConnected;
1073
+ const isTangentConnectedToPerturbNormal = this.perturbedNormal.isConnected && (this.perturbedNormal.connectedPoint?.ownerBlock).worldTangent?.isConnected;
1074
+ const isTangentConnectedToAnisotropy = this.anisotropy.isConnected && (this.anisotropy.connectedPoint?.ownerBlock).worldTangent.isConnected;
1075
+ let vTBNAvailable = isTangentConnectedToPerturbNormal || (!this.perturbedNormal.isConnected && isTangentConnectedToAnisotropy);
1076
+ state.compilationString += ClearCoatBlock.GetCode(state, clearcoatBlock, reflectionBlock, worldPosVarName, generateTBNSpace, vTBNAvailable, worldNormalVarName);
1077
+ if (generateTBNSpace) {
1078
+ vTBNAvailable = clearcoatBlock?.worldTangent.isConnected ?? false;
1079
+ }
1080
+ state._emitFunctionFromInclude("pbrBlockClearcoat", comments, {
1081
+ replaceStrings: [
1082
+ { search: /computeReflectionCoords/g, replace: "computeReflectionCoordsPBR" },
1083
+ { search: /REFLECTIONMAP_3D/g, replace: reflectionBlock?._define3DName ?? "REFLECTIONMAP_3D" },
1084
+ { search: /REFLECTIONMAP_OPPOSITEZ/g, replace: reflectionBlock?._defineOppositeZ ?? "REFLECTIONMAP_OPPOSITEZ" },
1085
+ { search: /REFLECTIONMAP_PROJECTION/g, replace: reflectionBlock?._defineProjectionName ?? "REFLECTIONMAP_PROJECTION" },
1086
+ { search: /REFLECTIONMAP_SKYBOX/g, replace: reflectionBlock?._defineSkyboxName ?? "REFLECTIONMAP_SKYBOX" },
1087
+ { search: /LODINREFLECTIONALPHA/g, replace: reflectionBlock?._defineLODReflectionAlpha ?? "LODINREFLECTIONALPHA" },
1088
+ { search: /LINEARSPECULARREFLECTION/g, replace: reflectionBlock?._defineLinearSpecularReflection ?? "LINEARSPECULARREFLECTION" },
1089
+ { search: /defined\(TANGENT\)/g, replace: vTBNAvailable ? "defined(TANGENT)" : "defined(IGNORE)" },
1090
+ ],
1091
+ });
1092
+ // _________________________ Specular Environment Reflectance __________________________
1093
+ state.compilationString += state._emitCodeFromInclude("pbrBlockReflectance", comments, {
1094
+ replaceStrings: [
1095
+ { search: /REFLECTIONMAP_SKYBOX/g, replace: reflectionBlock?._defineSkyboxName ?? "REFLECTIONMAP_SKYBOX" },
1096
+ { search: /REFLECTIONMAP_3D/g, replace: reflectionBlock?._define3DName ?? "REFLECTIONMAP_3D" },
1097
+ { search: /uniforms\.vReflectivityColor/g, replace: "vReflectivityColor" },
1098
+ ],
1099
+ });
1100
+ // ___________________________________ SubSurface ______________________________________
1101
+ const subsurfaceBlock = this.subsurface.isConnected ? this.subsurface.connectedPoint?.ownerBlock : null;
1102
+ const refractionBlock = this.subsurface.isConnected
1103
+ ? (this.subsurface.connectedPoint?.ownerBlock).refraction.connectedPoint?.ownerBlock
1104
+ : null;
1105
+ if (refractionBlock) {
1106
+ refractionBlock.viewConnectionPoint = this.view;
1107
+ refractionBlock.indexOfRefractionConnectionPoint = this.indexOfRefraction;
1108
+ }
1109
+ state.compilationString += SubSurfaceBlock.GetCode(state, subsurfaceBlock, reflectionBlock, worldPosVarName);
1110
+ state._emitFunctionFromInclude("pbrBlockSubSurface", comments, {
1111
+ replaceStrings: [
1112
+ { search: /REFLECTIONMAP_3D/g, replace: reflectionBlock?._define3DName ?? "REFLECTIONMAP_3D" },
1113
+ { search: /REFLECTIONMAP_OPPOSITEZ/g, replace: reflectionBlock?._defineOppositeZ ?? "REFLECTIONMAP_OPPOSITEZ" },
1114
+ { search: /REFLECTIONMAP_PROJECTION/g, replace: reflectionBlock?._defineProjectionName ?? "REFLECTIONMAP_PROJECTION" },
1115
+ { search: /SS_REFRACTIONMAP_3D/g, replace: refractionBlock?._define3DName ?? "SS_REFRACTIONMAP_3D" },
1116
+ { search: /SS_LODINREFRACTIONALPHA/g, replace: refractionBlock?._defineLODRefractionAlpha ?? "SS_LODINREFRACTIONALPHA" },
1117
+ { search: /SS_LINEARSPECULARREFRACTION/g, replace: refractionBlock?._defineLinearSpecularRefraction ?? "SS_LINEARSPECULARREFRACTION" },
1118
+ { search: /SS_REFRACTIONMAP_OPPOSITEZ/g, replace: refractionBlock?._defineOppositeZ ?? "SS_REFRACTIONMAP_OPPOSITEZ" },
1119
+ ],
1120
+ });
1121
+ if (isWebGPU) {
1122
+ state._emitFunctionFromInclude("pbrDirectLightingFunctions", comments);
1123
+ }
1124
+ if (!isWebGPU) {
1125
+ // In WebGPU, those functions are part of pbrDirectLightingFunctions
1126
+ state._emitFunctionFromInclude("pbrClusteredLightingFunctions", comments);
1127
+ }
1128
+ // _____________________________ Direct Lighting Info __________________________________
1129
+ state.compilationString += state._emitCodeFromInclude("pbrBlockDirectLighting", comments);
1130
+ if (this.light) {
1131
+ state.compilationString += state._emitCodeFromInclude("lightFragment", comments, {
1132
+ replaceStrings: [
1133
+ { search: /{X}/g, replace: this._lightId.toString() },
1134
+ { search: new RegExp(`${isWebGPU ? "fragmentInputs." : ""}vPositionW`, "g"), replace: worldPosVarName + ".xyz" },
1135
+ { search: /uniforms\.vReflectivityColor/g, replace: "vReflectivityColor" },
1136
+ ],
1137
+ });
1138
+ }
1139
+ else {
1140
+ let substitutionVars = `vPositionW,${worldPosVarName}.xyz`;
1141
+ if (isWebGPU) {
1142
+ substitutionVars = "fragmentInputs." + substitutionVars;
1143
+ if (this.generateOnlyFragmentCode) {
1144
+ substitutionVars += `,fragmentInputs.vViewDepth,vViewDepth`;
1145
+ }
1145
1146
  }
1147
+ state.compilationString += state._emitCodeFromInclude("lightFragment", comments, {
1148
+ repeatKey: "maxSimultaneousLights",
1149
+ substitutionVars: substitutionVars + ",uniforms.vReflectivityColor,vReflectivityColor",
1150
+ });
1151
+ }
1152
+ // _____________________________ Compute Final Lit Components ________________________
1153
+ state.compilationString += state._emitCodeFromInclude("pbrBlockFinalLitComponents", comments);
1154
+ // _____________________________ UNLIT (2) ________________________
1155
+ state.compilationString += `#endif\n`; // UNLIT
1156
+ // _____________________________ Compute Final Unlit Components ________________________
1157
+ const aoColor = this.ambientColor.isConnected ? this.ambientColor.associatedVariableName : `vec3${state.fSuffix}(0., 0., 0.)`;
1158
+ let aoDirectLightIntensity = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();
1159
+ if (aoDirectLightIntensity.indexOf(".") === -1) {
1160
+ aoDirectLightIntensity += ".";
1161
+ }
1162
+ let replaceStrings = [
1163
+ { search: /vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g, replace: "" },
1164
+ { search: new RegExp(`${isWebGPU ? "uniforms." : ""}vAmbientColor`, "g"), replace: aoColor + ` * ${isWebGPU ? "uniforms." : ""}ambientFromScene` },
1165
+ { search: new RegExp(`${isWebGPU ? "uniforms." : ""}vAmbientInfos.w`, "g"), replace: aoDirectLightIntensity },
1166
+ ];
1167
+ if (isWebGPU) {
1168
+ replaceStrings[0] = { search: /var finalEmissive[\s\S]*?finalEmissive\*=uniforms.vLightingIntensity\.y;/g, replace: "" };
1169
+ }
1170
+ state.compilationString += state._emitCodeFromInclude("pbrBlockFinalUnlitComponents", comments, {
1171
+ replaceStrings: replaceStrings,
1172
+ });
1173
+ // _____________________________ Output Final Color Composition ________________________
1174
+ state.compilationString += state._emitCodeFromInclude("pbrBlockFinalColorComposition", comments, {
1175
+ replaceStrings: [{ search: /finalEmissive/g, replace: `vec3${state.fSuffix}(0.)` }],
1176
+ });
1177
+ // _____________________________ Apply image processing ________________________
1178
+ if (isWebGPU) {
1179
+ replaceStrings = [{ search: /mesh.visibility/g, replace: "1." }];
1146
1180
  }
1147
1181
  else {
1148
- state.sharedData.raiseBuildError(`There's no remapping for the ${output.name} end point! No code generated`);
1182
+ replaceStrings = [{ search: /visibility/g, replace: "1." }];
1183
+ }
1184
+ state.compilationString += state._emitCodeFromInclude("pbrBlockImageProcessing", comments, {
1185
+ replaceStrings: replaceStrings,
1186
+ });
1187
+ // _____________________________ Generate debug code ________________________
1188
+ const colorOutput = isWebGPU ? "fragmentOutputs.color" : "gl_FragColor";
1189
+ replaceStrings = [
1190
+ { search: new RegExp(`${isWebGPU ? "fragmentInputs." : ""}vNormalW`, "g"), replace: this._vNormalWName },
1191
+ { search: new RegExp(`${isWebGPU ? "fragmentInputs." : ""}vPositionW`, "g"), replace: worldPosVarName },
1192
+ { search: /uniforms\.vReflectivityColor/g, replace: "vReflectivityColor" },
1193
+ {
1194
+ search: /albedoTexture\.rgb;/g,
1195
+ replace: `vec3${state.fSuffix}(1.);\n${colorOutput}.rgb = toGammaSpace(${colorOutput}.rgb);\n`,
1196
+ },
1197
+ ];
1198
+ state.compilationString += state._emitCodeFromInclude("pbrDebug", comments, {
1199
+ replaceStrings: replaceStrings,
1200
+ });
1201
+ // _____________________________ Generate end points ________________________
1202
+ for (const output of this._outputs) {
1203
+ if (output.hasEndpoints) {
1204
+ const remap = MapOutputToVariable[output.name];
1205
+ if (remap) {
1206
+ const [varName, conditions] = remap;
1207
+ if (conditions) {
1208
+ state.compilationString += `#if ${conditions}\n`;
1209
+ }
1210
+ state.compilationString += `${state._declareOutput(output)} = ${varName};\n`;
1211
+ if (conditions) {
1212
+ state.compilationString += `#else\n`;
1213
+ state.compilationString += `${state._declareOutput(output)} = vec3${state.fSuffix}(0.);\n`;
1214
+ state.compilationString += `#endif\n`;
1215
+ }
1216
+ }
1217
+ else {
1218
+ state.sharedData.raiseBuildError(`There's no remapping for the ${output.name} end point! No code generated`);
1219
+ }
1220
+ }
1149
1221
  }
1222
+ return this;
1150
1223
  }
1151
- }
1152
- return this;
1153
- }
1154
- _dumpPropertiesCode() {
1155
- let codeString = super._dumpPropertiesCode();
1156
- codeString += `${this._codeVariableName}.lightFalloff = ${this.lightFalloff};\n`;
1157
- codeString += `${this._codeVariableName}.useAlphaTest = ${this.useAlphaTest};\n`;
1158
- codeString += `${this._codeVariableName}.alphaTestCutoff = ${this.alphaTestCutoff};\n`;
1159
- codeString += `${this._codeVariableName}.useAlphaBlending = ${this.useAlphaBlending};\n`;
1160
- codeString += `${this._codeVariableName}.useRadianceOverAlpha = ${this.useRadianceOverAlpha};\n`;
1161
- codeString += `${this._codeVariableName}.useSpecularOverAlpha = ${this.useSpecularOverAlpha};\n`;
1162
- codeString += `${this._codeVariableName}.enableSpecularAntiAliasing = ${this.enableSpecularAntiAliasing};\n`;
1163
- codeString += `${this._codeVariableName}.realTimeFiltering = ${this.realTimeFiltering};\n`;
1164
- codeString += `${this._codeVariableName}.realTimeFilteringQuality = ${this.realTimeFilteringQuality};\n`;
1165
- codeString += `${this._codeVariableName}.useEnergyConservation = ${this.useEnergyConservation};\n`;
1166
- codeString += `${this._codeVariableName}.useRadianceOcclusion = ${this.useRadianceOcclusion};\n`;
1167
- codeString += `${this._codeVariableName}.useHorizonOcclusion = ${this.useHorizonOcclusion};\n`;
1168
- codeString += `${this._codeVariableName}.unlit = ${this.unlit};\n`;
1169
- codeString += `${this._codeVariableName}.forceNormalForward = ${this.forceNormalForward};\n`;
1170
- codeString += `${this._codeVariableName}.debugMode = ${this.debugMode};\n`;
1171
- codeString += `${this._codeVariableName}.debugLimit = ${this.debugLimit};\n`;
1172
- codeString += `${this._codeVariableName}.debugFactor = ${this.debugFactor};\n`;
1173
- return codeString;
1174
- }
1175
- /**
1176
- * Serializes the block
1177
- * @returns the serialized object
1178
- */
1179
- serialize() {
1180
- const serializationObject = super.serialize();
1181
- if (this.light) {
1182
- serializationObject.lightId = this.light.id;
1183
- }
1184
- serializationObject.lightFalloff = this.lightFalloff;
1185
- serializationObject.useAlphaTest = this.useAlphaTest;
1186
- serializationObject.alphaTestCutoff = this.alphaTestCutoff;
1187
- serializationObject.useAlphaBlending = this.useAlphaBlending;
1188
- serializationObject.useRadianceOverAlpha = this.useRadianceOverAlpha;
1189
- serializationObject.useSpecularOverAlpha = this.useSpecularOverAlpha;
1190
- serializationObject.enableSpecularAntiAliasing = this.enableSpecularAntiAliasing;
1191
- serializationObject.realTimeFiltering = this.realTimeFiltering;
1192
- serializationObject.realTimeFilteringQuality = this.realTimeFilteringQuality;
1193
- serializationObject.useEnergyConservation = this.useEnergyConservation;
1194
- serializationObject.useRadianceOcclusion = this.useRadianceOcclusion;
1195
- serializationObject.useHorizonOcclusion = this.useHorizonOcclusion;
1196
- serializationObject.unlit = this.unlit;
1197
- serializationObject.forceNormalForward = this.forceNormalForward;
1198
- serializationObject.debugMode = this.debugMode;
1199
- serializationObject.debugLimit = this.debugLimit;
1200
- serializationObject.debugFactor = this.debugFactor;
1201
- serializationObject.generateOnlyFragmentCode = this.generateOnlyFragmentCode;
1202
- return serializationObject;
1203
- }
1204
- /**
1205
- * Deserializes the block
1206
- * @param serializationObject - the object to deserialize from
1207
- * @param scene - the scene to deserialize in
1208
- * @param rootUrl - the root URL for assets
1209
- */
1210
- _deserialize(serializationObject, scene, rootUrl) {
1211
- super._deserialize(serializationObject, scene, rootUrl);
1212
- if (serializationObject.lightId) {
1213
- this.light = scene.getLightById(serializationObject.lightId);
1214
- }
1215
- this.lightFalloff = serializationObject.lightFalloff ?? 0;
1216
- this.useAlphaTest = serializationObject.useAlphaTest;
1217
- this.alphaTestCutoff = serializationObject.alphaTestCutoff;
1218
- this.useAlphaBlending = serializationObject.useAlphaBlending;
1219
- this.useRadianceOverAlpha = serializationObject.useRadianceOverAlpha;
1220
- this.useSpecularOverAlpha = serializationObject.useSpecularOverAlpha;
1221
- this.enableSpecularAntiAliasing = serializationObject.enableSpecularAntiAliasing;
1222
- this.realTimeFiltering = !!serializationObject.realTimeFiltering;
1223
- this.realTimeFilteringQuality = serializationObject.realTimeFilteringQuality ?? 8;
1224
- this.useEnergyConservation = serializationObject.useEnergyConservation;
1225
- this.useRadianceOcclusion = serializationObject.useRadianceOcclusion;
1226
- this.useHorizonOcclusion = serializationObject.useHorizonOcclusion;
1227
- this.unlit = serializationObject.unlit;
1228
- this.forceNormalForward = !!serializationObject.forceNormalForward;
1229
- this.debugMode = serializationObject.debugMode;
1230
- this.debugLimit = serializationObject.debugLimit;
1231
- this.debugFactor = serializationObject.debugFactor;
1232
- this.generateOnlyFragmentCode = !!serializationObject.generateOnlyFragmentCode;
1233
- this._setTarget();
1234
- }
1235
- }
1236
- __decorate([
1237
- editableInPropertyPage("Direct lights", 1 /* PropertyTypeForEdition.Float */, "INTENSITY", { min: 0, max: 1, notifiers: { update: true } })
1238
- ], PBRMetallicRoughnessBlock.prototype, "directIntensity", void 0);
1239
- __decorate([
1240
- editableInPropertyPage("Environment lights", 1 /* PropertyTypeForEdition.Float */, "INTENSITY", { min: 0, max: 1, notifiers: { update: true } })
1241
- ], PBRMetallicRoughnessBlock.prototype, "environmentIntensity", void 0);
1242
- __decorate([
1243
- editableInPropertyPage("Specular highlights", 1 /* PropertyTypeForEdition.Float */, "INTENSITY", { min: 0, max: 1, notifiers: { update: true } })
1244
- ], PBRMetallicRoughnessBlock.prototype, "specularIntensity", void 0);
1245
- __decorate([
1246
- editableInPropertyPage("Light falloff", 5 /* PropertyTypeForEdition.List */, "LIGHTING & COLORS", {
1247
- notifiers: { update: true },
1248
- options: [
1249
- { label: "Physical", value: PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL },
1250
- { label: "GLTF", value: PBRBaseMaterial.LIGHTFALLOFF_GLTF },
1251
- { label: "Standard", value: PBRBaseMaterial.LIGHTFALLOFF_STANDARD },
1252
- ],
1253
- })
1254
- ], PBRMetallicRoughnessBlock.prototype, "lightFalloff", void 0);
1255
- __decorate([
1256
- editableInPropertyPage("Alpha Testing", 0 /* PropertyTypeForEdition.Boolean */, "OPACITY")
1257
- ], PBRMetallicRoughnessBlock.prototype, "useAlphaTest", void 0);
1258
- __decorate([
1259
- editableInPropertyPage("Alpha CutOff", 1 /* PropertyTypeForEdition.Float */, "OPACITY", { min: 0, max: 1, notifiers: { update: true } })
1260
- ], PBRMetallicRoughnessBlock.prototype, "alphaTestCutoff", void 0);
1261
- __decorate([
1262
- editableInPropertyPage("Alpha blending", 0 /* PropertyTypeForEdition.Boolean */, "OPACITY")
1263
- ], PBRMetallicRoughnessBlock.prototype, "useAlphaBlending", void 0);
1264
- __decorate([
1265
- editableInPropertyPage("Radiance over alpha", 0 /* PropertyTypeForEdition.Boolean */, "RENDERING", { notifiers: { update: true } })
1266
- ], PBRMetallicRoughnessBlock.prototype, "useRadianceOverAlpha", void 0);
1267
- __decorate([
1268
- editableInPropertyPage("Specular over alpha", 0 /* PropertyTypeForEdition.Boolean */, "RENDERING", { notifiers: { update: true } })
1269
- ], PBRMetallicRoughnessBlock.prototype, "useSpecularOverAlpha", void 0);
1270
- __decorate([
1271
- editableInPropertyPage("Specular anti-aliasing", 0 /* PropertyTypeForEdition.Boolean */, "RENDERING", { notifiers: { update: true } })
1272
- ], PBRMetallicRoughnessBlock.prototype, "enableSpecularAntiAliasing", void 0);
1273
- __decorate([
1274
- editableInPropertyPage("Realtime filtering", 0 /* PropertyTypeForEdition.Boolean */, "RENDERING", { notifiers: { update: true } })
1275
- ], PBRMetallicRoughnessBlock.prototype, "realTimeFiltering", void 0);
1276
- __decorate([
1277
- editableInPropertyPage("Realtime filtering quality", 5 /* PropertyTypeForEdition.List */, "RENDERING", {
1278
- notifiers: { update: true },
1279
- options: [
1280
- { label: "Low", value: 8 },
1281
- { label: "Medium", value: 16 },
1282
- { label: "High", value: 64 },
1283
- ],
1284
- })
1285
- ], PBRMetallicRoughnessBlock.prototype, "realTimeFilteringQuality", void 0);
1286
- __decorate([
1287
- editableInPropertyPage("Diffuse Model", 5 /* PropertyTypeForEdition.List */, "RENDERING", {
1288
- notifiers: { update: true },
1289
- options: [
1290
- { label: "Lambert", value: 2 },
1291
- { label: "Burley", value: 1 },
1292
- { label: "Oren-Nayar", value: 0 },
1293
- { label: "Legacy", value: 3 },
1294
- ],
1295
- })
1296
- ], PBRMetallicRoughnessBlock.prototype, "baseDiffuseModel", void 0);
1297
- __decorate([
1298
- editableInPropertyPage("Energy Conservation", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { notifiers: { update: true } })
1299
- ], PBRMetallicRoughnessBlock.prototype, "useEnergyConservation", void 0);
1300
- __decorate([
1301
- editableInPropertyPage("Radiance occlusion", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { notifiers: { update: true } })
1302
- ], PBRMetallicRoughnessBlock.prototype, "useRadianceOcclusion", void 0);
1303
- __decorate([
1304
- editableInPropertyPage("Horizon occlusion", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { notifiers: { update: true } })
1305
- ], PBRMetallicRoughnessBlock.prototype, "useHorizonOcclusion", void 0);
1306
- __decorate([
1307
- editableInPropertyPage("Unlit", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { notifiers: { update: true } })
1308
- ], PBRMetallicRoughnessBlock.prototype, "unlit", void 0);
1309
- __decorate([
1310
- editableInPropertyPage("Force normal forward", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { notifiers: { update: true } })
1311
- ], PBRMetallicRoughnessBlock.prototype, "forceNormalForward", void 0);
1312
- __decorate([
1313
- editableInPropertyPage("Generate only fragment code", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", {
1314
- notifiers: { rebuild: true, update: true, onValidation: PBRMetallicRoughnessBlock._OnGenerateOnlyFragmentCodeChanged },
1315
- })
1316
- ], PBRMetallicRoughnessBlock.prototype, "generateOnlyFragmentCode", void 0);
1317
- __decorate([
1318
- editableInPropertyPage("Debug mode", 5 /* PropertyTypeForEdition.List */, "DEBUG", {
1319
- notifiers: { update: true },
1320
- options: [
1321
- { label: "None", value: 0 },
1322
- // Geometry
1323
- { label: "Normalized position", value: 1 },
1324
- { label: "Normals", value: 2 },
1325
- { label: "Tangents", value: 3 },
1326
- { label: "Bitangents", value: 4 },
1327
- { label: "Bump Normals", value: 5 },
1328
- //{ label: "UV1", value: 6 },
1329
- //{ label: "UV2", value: 7 },
1330
- { label: "ClearCoat Normals", value: 8 },
1331
- { label: "ClearCoat Tangents", value: 9 },
1332
- { label: "ClearCoat Bitangents", value: 10 },
1333
- { label: "Anisotropic Normals", value: 11 },
1334
- { label: "Anisotropic Tangents", value: 12 },
1335
- { label: "Anisotropic Bitangents", value: 13 },
1336
- // Maps
1337
- //{ label: "Emissive Map", value: 23 },
1338
- //{ label: "Light Map", value: 24 },
1339
- // Env
1340
- { label: "Env Refraction", value: 40 },
1341
- { label: "Env Reflection", value: 41 },
1342
- { label: "Env Clear Coat", value: 42 },
1343
- // Lighting
1344
- { label: "Direct Diffuse", value: 50 },
1345
- { label: "Direct Specular", value: 51 },
1346
- { label: "Direct Clear Coat", value: 52 },
1347
- { label: "Direct Sheen", value: 53 },
1348
- { label: "Env Irradiance", value: 54 },
1349
- // Lighting Params
1350
- { label: "Surface Albedo", value: 60 },
1351
- { label: "Reflectance 0", value: 61 },
1352
- { label: "Metallic", value: 62 },
1353
- { label: "Metallic F0", value: 71 },
1354
- { label: "Roughness", value: 63 },
1355
- { label: "AlphaG", value: 64 },
1356
- { label: "NdotV", value: 65 },
1357
- { label: "ClearCoat Color", value: 66 },
1358
- { label: "ClearCoat Roughness", value: 67 },
1359
- { label: "ClearCoat NdotV", value: 68 },
1360
- { label: "Transmittance", value: 69 },
1361
- { label: "Refraction Transmittance", value: 70 },
1362
- // Misc
1363
- { label: "SEO", value: 80 },
1364
- { label: "EHO", value: 81 },
1365
- { label: "Energy Factor", value: 82 },
1366
- { label: "Specular Reflectance", value: 83 },
1367
- { label: "Clear Coat Reflectance", value: 84 },
1368
- { label: "Sheen Reflectance", value: 85 },
1369
- { label: "Luminance Over Alpha", value: 86 },
1370
- { label: "Alpha", value: 87 },
1371
- { label: "Albedo color", value: 88 },
1372
- { label: "Ambient occlusion color", value: 89 },
1373
- ],
1374
- })
1375
- ], PBRMetallicRoughnessBlock.prototype, "debugMode", void 0);
1376
- __decorate([
1377
- editableInPropertyPage("Split position", 1 /* PropertyTypeForEdition.Float */, "DEBUG", { min: -1, max: 1, notifiers: { update: true } })
1378
- ], PBRMetallicRoughnessBlock.prototype, "debugLimit", void 0);
1379
- __decorate([
1380
- editableInPropertyPage("Output factor", 1 /* PropertyTypeForEdition.Float */, "DEBUG", { min: 0, max: 5, notifiers: { update: true } })
1381
- ], PBRMetallicRoughnessBlock.prototype, "debugFactor", void 0);
1224
+ _dumpPropertiesCode() {
1225
+ let codeString = super._dumpPropertiesCode();
1226
+ codeString += `${this._codeVariableName}.lightFalloff = ${this.lightFalloff};\n`;
1227
+ codeString += `${this._codeVariableName}.useAlphaTest = ${this.useAlphaTest};\n`;
1228
+ codeString += `${this._codeVariableName}.alphaTestCutoff = ${this.alphaTestCutoff};\n`;
1229
+ codeString += `${this._codeVariableName}.useAlphaBlending = ${this.useAlphaBlending};\n`;
1230
+ codeString += `${this._codeVariableName}.useRadianceOverAlpha = ${this.useRadianceOverAlpha};\n`;
1231
+ codeString += `${this._codeVariableName}.useSpecularOverAlpha = ${this.useSpecularOverAlpha};\n`;
1232
+ codeString += `${this._codeVariableName}.enableSpecularAntiAliasing = ${this.enableSpecularAntiAliasing};\n`;
1233
+ codeString += `${this._codeVariableName}.realTimeFiltering = ${this.realTimeFiltering};\n`;
1234
+ codeString += `${this._codeVariableName}.realTimeFilteringQuality = ${this.realTimeFilteringQuality};\n`;
1235
+ codeString += `${this._codeVariableName}.useEnergyConservation = ${this.useEnergyConservation};\n`;
1236
+ codeString += `${this._codeVariableName}.useRadianceOcclusion = ${this.useRadianceOcclusion};\n`;
1237
+ codeString += `${this._codeVariableName}.useHorizonOcclusion = ${this.useHorizonOcclusion};\n`;
1238
+ codeString += `${this._codeVariableName}.unlit = ${this.unlit};\n`;
1239
+ codeString += `${this._codeVariableName}.forceNormalForward = ${this.forceNormalForward};\n`;
1240
+ codeString += `${this._codeVariableName}.debugMode = ${this.debugMode};\n`;
1241
+ codeString += `${this._codeVariableName}.debugLimit = ${this.debugLimit};\n`;
1242
+ codeString += `${this._codeVariableName}.debugFactor = ${this.debugFactor};\n`;
1243
+ return codeString;
1244
+ }
1245
+ /**
1246
+ * Serializes the block
1247
+ * @returns the serialized object
1248
+ */
1249
+ serialize() {
1250
+ const serializationObject = super.serialize();
1251
+ if (this.light) {
1252
+ serializationObject.lightId = this.light.id;
1253
+ }
1254
+ serializationObject.lightFalloff = this.lightFalloff;
1255
+ serializationObject.useAlphaTest = this.useAlphaTest;
1256
+ serializationObject.alphaTestCutoff = this.alphaTestCutoff;
1257
+ serializationObject.useAlphaBlending = this.useAlphaBlending;
1258
+ serializationObject.useRadianceOverAlpha = this.useRadianceOverAlpha;
1259
+ serializationObject.useSpecularOverAlpha = this.useSpecularOverAlpha;
1260
+ serializationObject.enableSpecularAntiAliasing = this.enableSpecularAntiAliasing;
1261
+ serializationObject.realTimeFiltering = this.realTimeFiltering;
1262
+ serializationObject.realTimeFilteringQuality = this.realTimeFilteringQuality;
1263
+ serializationObject.useEnergyConservation = this.useEnergyConservation;
1264
+ serializationObject.useRadianceOcclusion = this.useRadianceOcclusion;
1265
+ serializationObject.useHorizonOcclusion = this.useHorizonOcclusion;
1266
+ serializationObject.unlit = this.unlit;
1267
+ serializationObject.forceNormalForward = this.forceNormalForward;
1268
+ serializationObject.debugMode = this.debugMode;
1269
+ serializationObject.debugLimit = this.debugLimit;
1270
+ serializationObject.debugFactor = this.debugFactor;
1271
+ serializationObject.generateOnlyFragmentCode = this.generateOnlyFragmentCode;
1272
+ return serializationObject;
1273
+ }
1274
+ /**
1275
+ * Deserializes the block
1276
+ * @param serializationObject - the object to deserialize from
1277
+ * @param scene - the scene to deserialize in
1278
+ * @param rootUrl - the root URL for assets
1279
+ */
1280
+ _deserialize(serializationObject, scene, rootUrl) {
1281
+ super._deserialize(serializationObject, scene, rootUrl);
1282
+ if (serializationObject.lightId) {
1283
+ this.light = scene.getLightById(serializationObject.lightId);
1284
+ }
1285
+ this.lightFalloff = serializationObject.lightFalloff ?? 0;
1286
+ this.useAlphaTest = serializationObject.useAlphaTest;
1287
+ this.alphaTestCutoff = serializationObject.alphaTestCutoff;
1288
+ this.useAlphaBlending = serializationObject.useAlphaBlending;
1289
+ this.useRadianceOverAlpha = serializationObject.useRadianceOverAlpha;
1290
+ this.useSpecularOverAlpha = serializationObject.useSpecularOverAlpha;
1291
+ this.enableSpecularAntiAliasing = serializationObject.enableSpecularAntiAliasing;
1292
+ this.realTimeFiltering = !!serializationObject.realTimeFiltering;
1293
+ this.realTimeFilteringQuality = serializationObject.realTimeFilteringQuality ?? 8;
1294
+ this.useEnergyConservation = serializationObject.useEnergyConservation;
1295
+ this.useRadianceOcclusion = serializationObject.useRadianceOcclusion;
1296
+ this.useHorizonOcclusion = serializationObject.useHorizonOcclusion;
1297
+ this.unlit = serializationObject.unlit;
1298
+ this.forceNormalForward = !!serializationObject.forceNormalForward;
1299
+ this.debugMode = serializationObject.debugMode;
1300
+ this.debugLimit = serializationObject.debugLimit;
1301
+ this.debugFactor = serializationObject.debugFactor;
1302
+ this.generateOnlyFragmentCode = !!serializationObject.generateOnlyFragmentCode;
1303
+ this._setTarget();
1304
+ }
1305
+ },
1306
+ (() => {
1307
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
1308
+ _directIntensity_decorators = [editableInPropertyPage("Direct lights", 1 /* PropertyTypeForEdition.Float */, "INTENSITY", { min: 0, max: 1, notifiers: { update: true } })];
1309
+ _environmentIntensity_decorators = [editableInPropertyPage("Environment lights", 1 /* PropertyTypeForEdition.Float */, "INTENSITY", { min: 0, max: 1, notifiers: { update: true } })];
1310
+ _specularIntensity_decorators = [editableInPropertyPage("Specular highlights", 1 /* PropertyTypeForEdition.Float */, "INTENSITY", { min: 0, max: 1, notifiers: { update: true } })];
1311
+ _lightFalloff_decorators = [editableInPropertyPage("Light falloff", 5 /* PropertyTypeForEdition.List */, "LIGHTING & COLORS", {
1312
+ notifiers: { update: true },
1313
+ options: [
1314
+ { label: "Physical", value: PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL },
1315
+ { label: "GLTF", value: PBRBaseMaterial.LIGHTFALLOFF_GLTF },
1316
+ { label: "Standard", value: PBRBaseMaterial.LIGHTFALLOFF_STANDARD },
1317
+ ],
1318
+ })];
1319
+ _useAlphaTest_decorators = [editableInPropertyPage("Alpha Testing", 0 /* PropertyTypeForEdition.Boolean */, "OPACITY")];
1320
+ _alphaTestCutoff_decorators = [editableInPropertyPage("Alpha CutOff", 1 /* PropertyTypeForEdition.Float */, "OPACITY", { min: 0, max: 1, notifiers: { update: true } })];
1321
+ _useAlphaBlending_decorators = [editableInPropertyPage("Alpha blending", 0 /* PropertyTypeForEdition.Boolean */, "OPACITY")];
1322
+ _useRadianceOverAlpha_decorators = [editableInPropertyPage("Radiance over alpha", 0 /* PropertyTypeForEdition.Boolean */, "RENDERING", { notifiers: { update: true } })];
1323
+ _useSpecularOverAlpha_decorators = [editableInPropertyPage("Specular over alpha", 0 /* PropertyTypeForEdition.Boolean */, "RENDERING", { notifiers: { update: true } })];
1324
+ _enableSpecularAntiAliasing_decorators = [editableInPropertyPage("Specular anti-aliasing", 0 /* PropertyTypeForEdition.Boolean */, "RENDERING", { notifiers: { update: true } })];
1325
+ _realTimeFiltering_decorators = [editableInPropertyPage("Realtime filtering", 0 /* PropertyTypeForEdition.Boolean */, "RENDERING", { notifiers: { update: true } })];
1326
+ _realTimeFilteringQuality_decorators = [editableInPropertyPage("Realtime filtering quality", 5 /* PropertyTypeForEdition.List */, "RENDERING", {
1327
+ notifiers: { update: true },
1328
+ options: [
1329
+ { label: "Low", value: 8 },
1330
+ { label: "Medium", value: 16 },
1331
+ { label: "High", value: 64 },
1332
+ ],
1333
+ })];
1334
+ _baseDiffuseModel_decorators = [editableInPropertyPage("Diffuse Model", 5 /* PropertyTypeForEdition.List */, "RENDERING", {
1335
+ notifiers: { update: true },
1336
+ options: [
1337
+ { label: "Lambert", value: 2 },
1338
+ { label: "Burley", value: 1 },
1339
+ { label: "Oren-Nayar", value: 0 },
1340
+ { label: "Legacy", value: 3 },
1341
+ ],
1342
+ })];
1343
+ _useEnergyConservation_decorators = [editableInPropertyPage("Energy Conservation", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { notifiers: { update: true } })];
1344
+ _useRadianceOcclusion_decorators = [editableInPropertyPage("Radiance occlusion", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { notifiers: { update: true } })];
1345
+ _useHorizonOcclusion_decorators = [editableInPropertyPage("Horizon occlusion", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { notifiers: { update: true } })];
1346
+ _unlit_decorators = [editableInPropertyPage("Unlit", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { notifiers: { update: true } })];
1347
+ _forceNormalForward_decorators = [editableInPropertyPage("Force normal forward", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { notifiers: { update: true } })];
1348
+ _generateOnlyFragmentCode_decorators = [editableInPropertyPage("Generate only fragment code", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", {
1349
+ notifiers: { rebuild: true, update: true, onValidation: (block, prop) => PBRMetallicRoughnessBlock._OnGenerateOnlyFragmentCodeChanged(block, prop) },
1350
+ })];
1351
+ _debugMode_decorators = [editableInPropertyPage("Debug mode", 5 /* PropertyTypeForEdition.List */, "DEBUG", {
1352
+ notifiers: { update: true },
1353
+ options: [
1354
+ { label: "None", value: 0 },
1355
+ // Geometry
1356
+ { label: "Normalized position", value: 1 },
1357
+ { label: "Normals", value: 2 },
1358
+ { label: "Tangents", value: 3 },
1359
+ { label: "Bitangents", value: 4 },
1360
+ { label: "Bump Normals", value: 5 },
1361
+ //{ label: "UV1", value: 6 },
1362
+ //{ label: "UV2", value: 7 },
1363
+ { label: "ClearCoat Normals", value: 8 },
1364
+ { label: "ClearCoat Tangents", value: 9 },
1365
+ { label: "ClearCoat Bitangents", value: 10 },
1366
+ { label: "Anisotropic Normals", value: 11 },
1367
+ { label: "Anisotropic Tangents", value: 12 },
1368
+ { label: "Anisotropic Bitangents", value: 13 },
1369
+ // Maps
1370
+ //{ label: "Emissive Map", value: 23 },
1371
+ //{ label: "Light Map", value: 24 },
1372
+ // Env
1373
+ { label: "Env Refraction", value: 40 },
1374
+ { label: "Env Reflection", value: 41 },
1375
+ { label: "Env Clear Coat", value: 42 },
1376
+ // Lighting
1377
+ { label: "Direct Diffuse", value: 50 },
1378
+ { label: "Direct Specular", value: 51 },
1379
+ { label: "Direct Clear Coat", value: 52 },
1380
+ { label: "Direct Sheen", value: 53 },
1381
+ { label: "Env Irradiance", value: 54 },
1382
+ // Lighting Params
1383
+ { label: "Surface Albedo", value: 60 },
1384
+ { label: "Reflectance 0", value: 61 },
1385
+ { label: "Metallic", value: 62 },
1386
+ { label: "Metallic F0", value: 71 },
1387
+ { label: "Roughness", value: 63 },
1388
+ { label: "AlphaG", value: 64 },
1389
+ { label: "NdotV", value: 65 },
1390
+ { label: "ClearCoat Color", value: 66 },
1391
+ { label: "ClearCoat Roughness", value: 67 },
1392
+ { label: "ClearCoat NdotV", value: 68 },
1393
+ { label: "Transmittance", value: 69 },
1394
+ { label: "Refraction Transmittance", value: 70 },
1395
+ // Misc
1396
+ { label: "SEO", value: 80 },
1397
+ { label: "EHO", value: 81 },
1398
+ { label: "Energy Factor", value: 82 },
1399
+ { label: "Specular Reflectance", value: 83 },
1400
+ { label: "Clear Coat Reflectance", value: 84 },
1401
+ { label: "Sheen Reflectance", value: 85 },
1402
+ { label: "Luminance Over Alpha", value: 86 },
1403
+ { label: "Alpha", value: 87 },
1404
+ { label: "Albedo color", value: 88 },
1405
+ { label: "Ambient occlusion color", value: 89 },
1406
+ ],
1407
+ })];
1408
+ _debugLimit_decorators = [editableInPropertyPage("Split position", 1 /* PropertyTypeForEdition.Float */, "DEBUG", { min: -1, max: 1, notifiers: { update: true } })];
1409
+ _debugFactor_decorators = [editableInPropertyPage("Output factor", 1 /* PropertyTypeForEdition.Float */, "DEBUG", { min: 0, max: 5, notifiers: { update: true } })];
1410
+ __esDecorate(null, null, _directIntensity_decorators, { kind: "field", name: "directIntensity", static: false, private: false, access: { has: obj => "directIntensity" in obj, get: obj => obj.directIntensity, set: (obj, value) => { obj.directIntensity = value; } }, metadata: _metadata }, _directIntensity_initializers, _directIntensity_extraInitializers);
1411
+ __esDecorate(null, null, _environmentIntensity_decorators, { kind: "field", name: "environmentIntensity", static: false, private: false, access: { has: obj => "environmentIntensity" in obj, get: obj => obj.environmentIntensity, set: (obj, value) => { obj.environmentIntensity = value; } }, metadata: _metadata }, _environmentIntensity_initializers, _environmentIntensity_extraInitializers);
1412
+ __esDecorate(null, null, _specularIntensity_decorators, { kind: "field", name: "specularIntensity", static: false, private: false, access: { has: obj => "specularIntensity" in obj, get: obj => obj.specularIntensity, set: (obj, value) => { obj.specularIntensity = value; } }, metadata: _metadata }, _specularIntensity_initializers, _specularIntensity_extraInitializers);
1413
+ __esDecorate(null, null, _lightFalloff_decorators, { kind: "field", name: "lightFalloff", static: false, private: false, access: { has: obj => "lightFalloff" in obj, get: obj => obj.lightFalloff, set: (obj, value) => { obj.lightFalloff = value; } }, metadata: _metadata }, _lightFalloff_initializers, _lightFalloff_extraInitializers);
1414
+ __esDecorate(null, null, _useAlphaTest_decorators, { kind: "field", name: "useAlphaTest", static: false, private: false, access: { has: obj => "useAlphaTest" in obj, get: obj => obj.useAlphaTest, set: (obj, value) => { obj.useAlphaTest = value; } }, metadata: _metadata }, _useAlphaTest_initializers, _useAlphaTest_extraInitializers);
1415
+ __esDecorate(null, null, _alphaTestCutoff_decorators, { kind: "field", name: "alphaTestCutoff", static: false, private: false, access: { has: obj => "alphaTestCutoff" in obj, get: obj => obj.alphaTestCutoff, set: (obj, value) => { obj.alphaTestCutoff = value; } }, metadata: _metadata }, _alphaTestCutoff_initializers, _alphaTestCutoff_extraInitializers);
1416
+ __esDecorate(null, null, _useAlphaBlending_decorators, { kind: "field", name: "useAlphaBlending", static: false, private: false, access: { has: obj => "useAlphaBlending" in obj, get: obj => obj.useAlphaBlending, set: (obj, value) => { obj.useAlphaBlending = value; } }, metadata: _metadata }, _useAlphaBlending_initializers, _useAlphaBlending_extraInitializers);
1417
+ __esDecorate(null, null, _useRadianceOverAlpha_decorators, { kind: "field", name: "useRadianceOverAlpha", static: false, private: false, access: { has: obj => "useRadianceOverAlpha" in obj, get: obj => obj.useRadianceOverAlpha, set: (obj, value) => { obj.useRadianceOverAlpha = value; } }, metadata: _metadata }, _useRadianceOverAlpha_initializers, _useRadianceOverAlpha_extraInitializers);
1418
+ __esDecorate(null, null, _useSpecularOverAlpha_decorators, { kind: "field", name: "useSpecularOverAlpha", static: false, private: false, access: { has: obj => "useSpecularOverAlpha" in obj, get: obj => obj.useSpecularOverAlpha, set: (obj, value) => { obj.useSpecularOverAlpha = value; } }, metadata: _metadata }, _useSpecularOverAlpha_initializers, _useSpecularOverAlpha_extraInitializers);
1419
+ __esDecorate(null, null, _enableSpecularAntiAliasing_decorators, { kind: "field", name: "enableSpecularAntiAliasing", static: false, private: false, access: { has: obj => "enableSpecularAntiAliasing" in obj, get: obj => obj.enableSpecularAntiAliasing, set: (obj, value) => { obj.enableSpecularAntiAliasing = value; } }, metadata: _metadata }, _enableSpecularAntiAliasing_initializers, _enableSpecularAntiAliasing_extraInitializers);
1420
+ __esDecorate(null, null, _realTimeFiltering_decorators, { kind: "field", name: "realTimeFiltering", static: false, private: false, access: { has: obj => "realTimeFiltering" in obj, get: obj => obj.realTimeFiltering, set: (obj, value) => { obj.realTimeFiltering = value; } }, metadata: _metadata }, _realTimeFiltering_initializers, _realTimeFiltering_extraInitializers);
1421
+ __esDecorate(null, null, _realTimeFilteringQuality_decorators, { kind: "field", name: "realTimeFilteringQuality", static: false, private: false, access: { has: obj => "realTimeFilteringQuality" in obj, get: obj => obj.realTimeFilteringQuality, set: (obj, value) => { obj.realTimeFilteringQuality = value; } }, metadata: _metadata }, _realTimeFilteringQuality_initializers, _realTimeFilteringQuality_extraInitializers);
1422
+ __esDecorate(null, null, _baseDiffuseModel_decorators, { kind: "field", name: "baseDiffuseModel", static: false, private: false, access: { has: obj => "baseDiffuseModel" in obj, get: obj => obj.baseDiffuseModel, set: (obj, value) => { obj.baseDiffuseModel = value; } }, metadata: _metadata }, _baseDiffuseModel_initializers, _baseDiffuseModel_extraInitializers);
1423
+ __esDecorate(null, null, _useEnergyConservation_decorators, { kind: "field", name: "useEnergyConservation", static: false, private: false, access: { has: obj => "useEnergyConservation" in obj, get: obj => obj.useEnergyConservation, set: (obj, value) => { obj.useEnergyConservation = value; } }, metadata: _metadata }, _useEnergyConservation_initializers, _useEnergyConservation_extraInitializers);
1424
+ __esDecorate(null, null, _useRadianceOcclusion_decorators, { kind: "field", name: "useRadianceOcclusion", static: false, private: false, access: { has: obj => "useRadianceOcclusion" in obj, get: obj => obj.useRadianceOcclusion, set: (obj, value) => { obj.useRadianceOcclusion = value; } }, metadata: _metadata }, _useRadianceOcclusion_initializers, _useRadianceOcclusion_extraInitializers);
1425
+ __esDecorate(null, null, _useHorizonOcclusion_decorators, { kind: "field", name: "useHorizonOcclusion", static: false, private: false, access: { has: obj => "useHorizonOcclusion" in obj, get: obj => obj.useHorizonOcclusion, set: (obj, value) => { obj.useHorizonOcclusion = value; } }, metadata: _metadata }, _useHorizonOcclusion_initializers, _useHorizonOcclusion_extraInitializers);
1426
+ __esDecorate(null, null, _unlit_decorators, { kind: "field", name: "unlit", static: false, private: false, access: { has: obj => "unlit" in obj, get: obj => obj.unlit, set: (obj, value) => { obj.unlit = value; } }, metadata: _metadata }, _unlit_initializers, _unlit_extraInitializers);
1427
+ __esDecorate(null, null, _forceNormalForward_decorators, { kind: "field", name: "forceNormalForward", static: false, private: false, access: { has: obj => "forceNormalForward" in obj, get: obj => obj.forceNormalForward, set: (obj, value) => { obj.forceNormalForward = value; } }, metadata: _metadata }, _forceNormalForward_initializers, _forceNormalForward_extraInitializers);
1428
+ __esDecorate(null, null, _generateOnlyFragmentCode_decorators, { kind: "field", name: "generateOnlyFragmentCode", static: false, private: false, access: { has: obj => "generateOnlyFragmentCode" in obj, get: obj => obj.generateOnlyFragmentCode, set: (obj, value) => { obj.generateOnlyFragmentCode = value; } }, metadata: _metadata }, _generateOnlyFragmentCode_initializers, _generateOnlyFragmentCode_extraInitializers);
1429
+ __esDecorate(null, null, _debugMode_decorators, { kind: "field", 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);
1430
+ __esDecorate(null, null, _debugLimit_decorators, { kind: "field", name: "debugLimit", static: false, private: false, access: { has: obj => "debugLimit" in obj, get: obj => obj.debugLimit, set: (obj, value) => { obj.debugLimit = value; } }, metadata: _metadata }, _debugLimit_initializers, _debugLimit_extraInitializers);
1431
+ __esDecorate(null, null, _debugFactor_decorators, { kind: "field", name: "debugFactor", static: false, private: false, access: { has: obj => "debugFactor" in obj, get: obj => obj.debugFactor, set: (obj, value) => { obj.debugFactor = value; } }, metadata: _metadata }, _debugFactor_initializers, _debugFactor_extraInitializers);
1432
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
1433
+ })(),
1434
+ _a;
1435
+ })();
1436
+ export { PBRMetallicRoughnessBlock };
1382
1437
  let _Registered = false;
1383
1438
  /**
1384
1439
  * Register side effects for pbrMetallicRoughnessBlock.