@babylonjs/core 7.32.0 → 7.32.1

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 (367) hide show
  1. package/Behaviors/Cameras/autoRotationBehavior.js +1 -0
  2. package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
  3. package/Cameras/camera.d.ts +5 -2
  4. package/Cameras/camera.js +1 -0
  5. package/Cameras/camera.js.map +1 -1
  6. package/Decorators/nodeDecorator.d.ts +9 -1
  7. package/Decorators/nodeDecorator.js +8 -0
  8. package/Decorators/nodeDecorator.js.map +1 -1
  9. package/Engines/Extensions/engine.multiRender.js +40 -53
  10. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  11. package/Engines/Extensions/engine.renderTarget.js +20 -8
  12. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  13. package/Engines/WebGPU/Extensions/engine.debugging.js +16 -7
  14. package/Engines/WebGPU/Extensions/engine.debugging.js.map +1 -1
  15. package/Engines/WebGPU/Extensions/engine.multiRender.js +43 -44
  16. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  17. package/Engines/WebGPU/Extensions/engine.renderTarget.js +8 -6
  18. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  19. package/Engines/WebGPU/webgpuHardwareTexture.d.ts +3 -3
  20. package/Engines/WebGPU/webgpuHardwareTexture.js +12 -9
  21. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  22. package/Engines/WebGPU/webgpuTextureHelper.js +25 -19
  23. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  24. package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
  25. package/Engines/WebGPU/webgpuTextureManager.js +5 -3
  26. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  27. package/Engines/abstractEngine.d.ts +6 -1
  28. package/Engines/abstractEngine.js +2 -2
  29. package/Engines/abstractEngine.js.map +1 -1
  30. package/Engines/constants.d.ts +6 -1
  31. package/Engines/constants.js +6 -1
  32. package/Engines/constants.js.map +1 -1
  33. package/Engines/renderTargetWrapper.d.ts +7 -0
  34. package/Engines/renderTargetWrapper.js +15 -0
  35. package/Engines/renderTargetWrapper.js.map +1 -1
  36. package/Engines/webgpuEngine.d.ts +3 -1
  37. package/Engines/webgpuEngine.js +9 -8
  38. package/Engines/webgpuEngine.js.map +1 -1
  39. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.d.ts +47 -0
  40. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +113 -0
  41. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -0
  42. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.d.ts +62 -0
  43. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +171 -0
  44. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -0
  45. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.d.ts +51 -0
  46. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +127 -0
  47. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -0
  48. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.d.ts +67 -0
  49. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +187 -0
  50. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -0
  51. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.d.ts +77 -0
  52. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +232 -0
  53. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js.map +1 -0
  54. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.d.ts +47 -0
  55. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +113 -0
  56. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -0
  57. package/FrameGraph/Node/Blocks/Rendering/cullObjectsBlock.d.ts +41 -0
  58. package/FrameGraph/Node/Blocks/Rendering/cullObjectsBlock.js +79 -0
  59. package/FrameGraph/Node/Blocks/Rendering/cullObjectsBlock.js.map +1 -0
  60. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +119 -0
  61. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +451 -0
  62. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -0
  63. package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.d.ts +63 -0
  64. package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js +154 -0
  65. package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js.map +1 -0
  66. package/FrameGraph/Node/Blocks/Teleport/teleportInBlock.d.ts +59 -0
  67. package/FrameGraph/Node/Blocks/Teleport/teleportInBlock.js +131 -0
  68. package/FrameGraph/Node/Blocks/Teleport/teleportInBlock.js.map +1 -0
  69. package/FrameGraph/Node/Blocks/Teleport/teleportOutBlock.d.ts +49 -0
  70. package/FrameGraph/Node/Blocks/Teleport/teleportOutBlock.js +107 -0
  71. package/FrameGraph/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -0
  72. package/FrameGraph/Node/Blocks/Textures/clearBlock.d.ts +50 -0
  73. package/FrameGraph/Node/Blocks/Textures/clearBlock.js +125 -0
  74. package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -0
  75. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +38 -0
  76. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +71 -0
  77. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -0
  78. package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.d.ts +34 -0
  79. package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +59 -0
  80. package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +1 -0
  81. package/FrameGraph/Node/Blocks/elbowBlock.d.ts +28 -0
  82. package/FrameGraph/Node/Blocks/elbowBlock.js +47 -0
  83. package/FrameGraph/Node/Blocks/elbowBlock.js.map +1 -0
  84. package/FrameGraph/Node/Blocks/index.d.ts +17 -0
  85. package/FrameGraph/Node/Blocks/index.js +18 -0
  86. package/FrameGraph/Node/Blocks/index.js.map +1 -0
  87. package/FrameGraph/Node/Blocks/inputBlock.d.ts +94 -0
  88. package/FrameGraph/Node/Blocks/inputBlock.js +270 -0
  89. package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -0
  90. package/FrameGraph/Node/Blocks/outputBlock.d.ts +30 -0
  91. package/FrameGraph/Node/Blocks/outputBlock.js +51 -0
  92. package/FrameGraph/Node/Blocks/outputBlock.js.map +1 -0
  93. package/FrameGraph/Node/Types/nodeRenderGraphTypes.d.ts +110 -0
  94. package/FrameGraph/Node/Types/nodeRenderGraphTypes.js +78 -0
  95. package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -0
  96. package/FrameGraph/Node/nodeRenderGraph.d.ts +196 -0
  97. package/FrameGraph/Node/nodeRenderGraph.js +614 -0
  98. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -0
  99. package/FrameGraph/Node/nodeRenderGraphBlock.d.ts +190 -0
  100. package/FrameGraph/Node/nodeRenderGraphBlock.js +495 -0
  101. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -0
  102. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.d.ts +143 -0
  103. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js +275 -0
  104. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js.map +1 -0
  105. package/FrameGraph/Node/nodeRenderGraphBuildState.d.ts +21 -0
  106. package/FrameGraph/Node/nodeRenderGraphBuildState.js +35 -0
  107. package/FrameGraph/Node/nodeRenderGraphBuildState.js.map +1 -0
  108. package/FrameGraph/Passes/cullPass.d.ts +28 -0
  109. package/FrameGraph/Passes/cullPass.js +38 -0
  110. package/FrameGraph/Passes/cullPass.js.map +1 -0
  111. package/FrameGraph/Passes/pass.d.ts +14 -0
  112. package/FrameGraph/Passes/pass.js +20 -0
  113. package/FrameGraph/Passes/pass.js.map +1 -0
  114. package/FrameGraph/Passes/renderPass.d.ts +49 -0
  115. package/FrameGraph/Passes/renderPass.js +72 -0
  116. package/FrameGraph/Passes/renderPass.js.map +1 -0
  117. package/FrameGraph/Tasks/PostProcesses/blackAndWhiteTask.d.ts +16 -0
  118. package/FrameGraph/Tasks/PostProcesses/blackAndWhiteTask.js +17 -0
  119. package/FrameGraph/Tasks/PostProcesses/blackAndWhiteTask.js.map +1 -0
  120. package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.d.ts +12 -0
  121. package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js +21 -0
  122. package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js.map +1 -0
  123. package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +54 -0
  124. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +114 -0
  125. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -0
  126. package/FrameGraph/Tasks/PostProcesses/blurTask.d.ts +17 -0
  127. package/FrameGraph/Tasks/PostProcesses/blurTask.js +24 -0
  128. package/FrameGraph/Tasks/PostProcesses/blurTask.js.map +1 -0
  129. package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.d.ts +30 -0
  130. package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js +35 -0
  131. package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js.map +1 -0
  132. package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.d.ts +12 -0
  133. package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js +26 -0
  134. package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js.map +1 -0
  135. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.d.ts +12 -0
  136. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +29 -0
  137. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -0
  138. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.d.ts +65 -0
  139. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +134 -0
  140. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -0
  141. package/FrameGraph/Tasks/PostProcesses/extractHighlightsTask.d.ts +16 -0
  142. package/FrameGraph/Tasks/PostProcesses/extractHighlightsTask.js +17 -0
  143. package/FrameGraph/Tasks/PostProcesses/extractHighlightsTask.js.map +1 -0
  144. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +41 -0
  145. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +64 -0
  146. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -0
  147. package/FrameGraph/Tasks/Rendering/cullObjectsTask.d.ts +28 -0
  148. package/FrameGraph/Tasks/Rendering/cullObjectsTask.js +52 -0
  149. package/FrameGraph/Tasks/Rendering/cullObjectsTask.js.map +1 -0
  150. package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +145 -0
  151. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +259 -0
  152. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -0
  153. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +66 -0
  154. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +127 -0
  155. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -0
  156. package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +34 -0
  157. package/FrameGraph/Tasks/Texture/clearTextureTask.js +42 -0
  158. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -0
  159. package/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.d.ts +12 -0
  160. package/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.js +23 -0
  161. package/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.js.map +1 -0
  162. package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +26 -0
  163. package/FrameGraph/Tasks/Texture/copyToTextureTask.js +31 -0
  164. package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -0
  165. package/FrameGraph/Tasks/Texture/generateMipMapsTask.d.ts +22 -0
  166. package/FrameGraph/Tasks/Texture/generateMipMapsTask.js +34 -0
  167. package/FrameGraph/Tasks/Texture/generateMipMapsTask.js.map +1 -0
  168. package/FrameGraph/frameGraph.d.ts +143 -0
  169. package/FrameGraph/frameGraph.js +275 -0
  170. package/FrameGraph/frameGraph.js.map +1 -0
  171. package/FrameGraph/frameGraphContext.d.ts +5 -0
  172. package/FrameGraph/frameGraphContext.js +6 -0
  173. package/FrameGraph/frameGraphContext.js.map +1 -0
  174. package/FrameGraph/frameGraphObjectList.d.ts +15 -0
  175. package/FrameGraph/frameGraphObjectList.js +7 -0
  176. package/FrameGraph/frameGraphObjectList.js.map +1 -0
  177. package/FrameGraph/frameGraphRenderContext.d.ts +110 -0
  178. package/FrameGraph/frameGraphRenderContext.js +237 -0
  179. package/FrameGraph/frameGraphRenderContext.js.map +1 -0
  180. package/FrameGraph/frameGraphTask.d.ts +49 -0
  181. package/FrameGraph/frameGraphTask.js +117 -0
  182. package/FrameGraph/frameGraphTask.js.map +1 -0
  183. package/FrameGraph/frameGraphTextureManager.d.ts +50 -0
  184. package/FrameGraph/frameGraphTextureManager.js +277 -0
  185. package/FrameGraph/frameGraphTextureManager.js.map +1 -0
  186. package/FrameGraph/frameGraphTypes.d.ts +59 -0
  187. package/FrameGraph/frameGraphTypes.js +9 -0
  188. package/FrameGraph/frameGraphTypes.js.map +1 -0
  189. package/FrameGraph/index.d.ts +28 -0
  190. package/FrameGraph/index.js +30 -0
  191. package/FrameGraph/index.js.map +1 -0
  192. package/Gamepads/gamepadSceneComponent.d.ts +0 -1
  193. package/Gamepads/gamepadSceneComponent.js +1 -7
  194. package/Gamepads/gamepadSceneComponent.js.map +1 -1
  195. package/Gizmos/boundingBoxGizmo.d.ts +7 -0
  196. package/Gizmos/boundingBoxGizmo.js +19 -6
  197. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  198. package/Inputs/scene.inputManager.d.ts +3 -1
  199. package/Inputs/scene.inputManager.js +20 -8
  200. package/Inputs/scene.inputManager.js.map +1 -1
  201. package/Layers/layer.d.ts +1 -1
  202. package/Layers/layer.js +1 -1
  203. package/Layers/layer.js.map +1 -1
  204. package/Materials/PBR/pbrBaseMaterial.d.ts +4 -0
  205. package/Materials/PBR/pbrBaseMaterial.js +8 -0
  206. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  207. package/Materials/Textures/dynamicTexture.d.ts +32 -2
  208. package/Materials/Textures/dynamicTexture.js +13 -18
  209. package/Materials/Textures/dynamicTexture.js.map +1 -1
  210. package/Materials/Textures/index.d.ts +1 -0
  211. package/Materials/Textures/index.js +1 -0
  212. package/Materials/Textures/index.js.map +1 -1
  213. package/Materials/Textures/mirrorTexture.js +0 -6
  214. package/Materials/Textures/mirrorTexture.js.map +1 -1
  215. package/Materials/Textures/multiRenderTarget.d.ts +20 -8
  216. package/Materials/Textures/multiRenderTarget.js +2 -0
  217. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  218. package/Materials/Textures/renderTargetTexture.d.ts +8 -1
  219. package/Materials/Textures/renderTargetTexture.js +28 -10
  220. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  221. package/Materials/Textures/textureCreationOptions.d.ts +20 -2
  222. package/Materials/Textures/textureCreationOptions.js +20 -1
  223. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  224. package/Materials/effectRenderer.d.ts +132 -14
  225. package/Materials/effectRenderer.js +229 -33
  226. package/Materials/effectRenderer.js.map +1 -1
  227. package/Materials/index.d.ts +1 -0
  228. package/Materials/index.js +1 -0
  229. package/Materials/index.js.map +1 -1
  230. package/Materials/materialHelper.functions.js +2 -0
  231. package/Materials/materialHelper.functions.js.map +1 -1
  232. package/Materials/materialHelper.geometryrendering.d.ts +122 -0
  233. package/Materials/materialHelper.geometryrendering.js +259 -0
  234. package/Materials/materialHelper.geometryrendering.js.map +1 -0
  235. package/Materials/standardMaterial.d.ts +4 -0
  236. package/Materials/standardMaterial.js +8 -0
  237. package/Materials/standardMaterial.js.map +1 -1
  238. package/Maths/index.d.ts +1 -0
  239. package/Maths/index.js +1 -0
  240. package/Maths/index.js.map +1 -1
  241. package/Meshes/Builders/greasedLineBuilder.d.ts +1 -1
  242. package/Meshes/Node/Blocks/geometryOptimizeBlock.d.ts +22 -1
  243. package/Meshes/Node/Blocks/geometryOptimizeBlock.js +39 -0
  244. package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -1
  245. package/Misc/copyTextureToTexture.d.ts +3 -2
  246. package/Misc/copyTextureToTexture.js +11 -5
  247. package/Misc/copyTextureToTexture.js.map +1 -1
  248. package/PostProcesses/blackAndWhitePostProcess.d.ts +5 -3
  249. package/PostProcesses/blackAndWhitePostProcess.js +24 -19
  250. package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
  251. package/PostProcesses/bloomEffect.d.ts +7 -5
  252. package/PostProcesses/bloomEffect.js +49 -23
  253. package/PostProcesses/bloomEffect.js.map +1 -1
  254. package/PostProcesses/bloomMergePostProcess.d.ts +5 -5
  255. package/PostProcesses/bloomMergePostProcess.js +28 -19
  256. package/PostProcesses/bloomMergePostProcess.js.map +1 -1
  257. package/PostProcesses/blurPostProcess.d.ts +7 -43
  258. package/PostProcesses/blurPostProcess.js +47 -185
  259. package/PostProcesses/blurPostProcess.js.map +1 -1
  260. package/PostProcesses/circleOfConfusionPostProcess.d.ts +13 -6
  261. package/PostProcesses/circleOfConfusionPostProcess.js +59 -38
  262. package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
  263. package/PostProcesses/depthOfFieldBlurPostProcess.d.ts +2 -6
  264. package/PostProcesses/depthOfFieldBlurPostProcess.js +14 -11
  265. package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
  266. package/PostProcesses/depthOfFieldEffect.d.ts +5 -2
  267. package/PostProcesses/depthOfFieldEffect.js +53 -45
  268. package/PostProcesses/depthOfFieldEffect.js.map +1 -1
  269. package/PostProcesses/depthOfFieldMergePostProcess.d.ts +0 -1
  270. package/PostProcesses/depthOfFieldMergePostProcess.js +18 -12
  271. package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
  272. package/PostProcesses/extractHighlightsPostProcess.d.ts +8 -4
  273. package/PostProcesses/extractHighlightsPostProcess.js +35 -22
  274. package/PostProcesses/extractHighlightsPostProcess.js.map +1 -1
  275. package/PostProcesses/index.d.ts +6 -0
  276. package/PostProcesses/index.js +6 -0
  277. package/PostProcesses/index.js.map +1 -1
  278. package/PostProcesses/postProcess.d.ts +15 -70
  279. package/PostProcesses/postProcess.js +80 -97
  280. package/PostProcesses/postProcess.js.map +1 -1
  281. package/PostProcesses/thinBlackAndWhitePostProcess.d.ts +28 -0
  282. package/PostProcesses/thinBlackAndWhitePostProcess.js +50 -0
  283. package/PostProcesses/thinBlackAndWhitePostProcess.js.map +1 -0
  284. package/PostProcesses/thinBloomEffect.d.ts +49 -0
  285. package/PostProcesses/thinBloomEffect.js +59 -0
  286. package/PostProcesses/thinBloomEffect.js.map +1 -0
  287. package/PostProcesses/thinBloomMergePostProcess.d.ts +15 -0
  288. package/PostProcesses/thinBloomMergePostProcess.js +38 -0
  289. package/PostProcesses/thinBloomMergePostProcess.js.map +1 -0
  290. package/PostProcesses/thinBlurPostProcess.d.ts +89 -0
  291. package/PostProcesses/thinBlurPostProcess.js +242 -0
  292. package/PostProcesses/thinBlurPostProcess.js.map +1 -0
  293. package/PostProcesses/thinCircleOfConfusionPostProcess.d.ts +62 -0
  294. package/PostProcesses/thinCircleOfConfusionPostProcess.js +81 -0
  295. package/PostProcesses/thinCircleOfConfusionPostProcess.js.map +1 -0
  296. package/PostProcesses/thinDepthOfFieldBlurPostProcess.d.ts +8 -0
  297. package/PostProcesses/thinDepthOfFieldBlurPostProcess.js +13 -0
  298. package/PostProcesses/thinDepthOfFieldBlurPostProcess.js.map +1 -0
  299. package/PostProcesses/thinDepthOfFieldEffect.d.ts +70 -0
  300. package/PostProcesses/thinDepthOfFieldEffect.js +115 -0
  301. package/PostProcesses/thinDepthOfFieldEffect.js.map +1 -0
  302. package/PostProcesses/thinDepthOfFieldMergePostProcess.d.ts +11 -0
  303. package/PostProcesses/thinDepthOfFieldMergePostProcess.js +30 -0
  304. package/PostProcesses/thinDepthOfFieldMergePostProcess.js.map +1 -0
  305. package/PostProcesses/thinExtractHighlightsPostProcess.d.ts +30 -0
  306. package/PostProcesses/thinExtractHighlightsPostProcess.js +55 -0
  307. package/PostProcesses/thinExtractHighlightsPostProcess.js.map +1 -0
  308. package/Rendering/depthPeelingRenderer.js +2 -2
  309. package/Rendering/depthPeelingRenderer.js.map +1 -1
  310. package/Rendering/fluidRenderer/fluidRenderingObject.js +4 -4
  311. package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
  312. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +1 -1
  313. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -1
  314. package/Shaders/ShadersInclude/pbrBlockPrePass.d.ts +5 -0
  315. package/Shaders/ShadersInclude/pbrBlockPrePass.js +75 -0
  316. package/Shaders/ShadersInclude/pbrBlockPrePass.js.map +1 -0
  317. package/Shaders/ShadersInclude/prePassVertex.js +1 -2
  318. package/Shaders/ShadersInclude/prePassVertex.js.map +1 -1
  319. package/Shaders/circleOfConfusion.fragment.js +9 -1
  320. package/Shaders/circleOfConfusion.fragment.js.map +1 -1
  321. package/Shaders/colorCorrection.fragment.js +1 -0
  322. package/Shaders/colorCorrection.fragment.js.map +1 -1
  323. package/Shaders/default.fragment.js +17 -25
  324. package/Shaders/default.fragment.js.map +1 -1
  325. package/Shaders/default.vertex.js +4 -6
  326. package/Shaders/default.vertex.js.map +1 -1
  327. package/Shaders/pbr.fragment.d.ts +1 -0
  328. package/Shaders/pbr.fragment.js +2 -74
  329. package/Shaders/pbr.fragment.js.map +1 -1
  330. package/Shaders/pbr.vertex.js +3 -3
  331. package/Shaders/pbr.vertex.js.map +1 -1
  332. package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.d.ts +5 -0
  333. package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js +100 -0
  334. package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js.map +1 -0
  335. package/ShadersWGSL/ShadersInclude/prePassVertex.js +1 -2
  336. package/ShadersWGSL/ShadersInclude/prePassVertex.js.map +1 -1
  337. package/ShadersWGSL/background.vertex.js +1 -1
  338. package/ShadersWGSL/background.vertex.js.map +1 -1
  339. package/ShadersWGSL/circleOfConfusion.fragment.js +10 -2
  340. package/ShadersWGSL/circleOfConfusion.fragment.js.map +1 -1
  341. package/ShadersWGSL/default.fragment.js +20 -31
  342. package/ShadersWGSL/default.fragment.js.map +1 -1
  343. package/ShadersWGSL/default.vertex.js +4 -5
  344. package/ShadersWGSL/default.vertex.js.map +1 -1
  345. package/ShadersWGSL/glowMapGeneration.fragment.js +1 -1
  346. package/ShadersWGSL/glowMapGeneration.fragment.js.map +1 -1
  347. package/ShadersWGSL/glowMapGeneration.vertex.js +1 -1
  348. package/ShadersWGSL/glowMapGeneration.vertex.js.map +1 -1
  349. package/ShadersWGSL/pbr.fragment.d.ts +1 -0
  350. package/ShadersWGSL/pbr.fragment.js +2 -100
  351. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  352. package/ShadersWGSL/pbr.vertex.js +4 -2
  353. package/ShadersWGSL/pbr.vertex.js.map +1 -1
  354. package/XR/features/WebXRRawCameraAccess.js +1 -1
  355. package/XR/features/WebXRRawCameraAccess.js.map +1 -1
  356. package/index.d.ts +1 -0
  357. package/index.js +1 -0
  358. package/index.js.map +1 -1
  359. package/package.json +1 -1
  360. package/scene.d.ts +19 -2
  361. package/scene.js +110 -13
  362. package/scene.js.map +1 -1
  363. package/sceneComponent.d.ts +0 -1
  364. package/sceneComponent.js +0 -1
  365. package/sceneComponent.js.map +1 -1
  366. package/types.d.ts +12 -0
  367. package/types.js.map +1 -1
@@ -1,11 +1,12 @@
1
- import type { Nullable } from "../types";
1
+ import type { NonNullableFields, Nullable } from "../types";
2
2
  import type { AbstractEngine } from "../Engines/abstractEngine";
3
3
  import { Viewport } from "../Maths/math.viewport";
4
4
  import { Observable } from "../Misc/observable";
5
+ import type { IShaderPath } from "./effect";
5
6
  import { Effect } from "./effect";
6
7
  import { DrawWrapper } from "./drawWrapper";
7
8
  import type { IRenderTargetTexture, RenderTargetWrapper } from "../Engines/renderTargetWrapper";
8
- import type { ShaderLanguage } from "./shaderLanguage";
9
+ import { ShaderLanguage } from "./shaderLanguage";
9
10
  import "../Shaders/postprocess.vertex";
10
11
  /**
11
12
  * Effect Render Options
@@ -74,7 +75,7 @@ export declare class EffectRenderer {
74
75
  /**
75
76
  * renders one or more effects to a specified texture
76
77
  * @param effectWrapper the effect to renderer
77
- * @param outputTexture texture to draw to, if null it will render to the screen.
78
+ * @param outputTexture texture to draw to, if null it will render to the currently bound frame buffer
78
79
  */
79
80
  render(effectWrapper: EffectWrapper, outputTexture?: Nullable<RenderTargetWrapper | IRenderTargetTexture>): void;
80
81
  /**
@@ -82,65 +83,160 @@ export declare class EffectRenderer {
82
83
  */
83
84
  dispose(): void;
84
85
  }
86
+ /**
87
+ * Allows for custom processing of the shader code used by an effect wrapper
88
+ */
89
+ export type EffectWrapperCustomShaderCodeProcessing = {
90
+ /**
91
+ * If provided, will be called two times with the vertex and fragment code so that this code can be updated after the #include have been processed
92
+ */
93
+ processCodeAfterIncludes?: (postProcessName: string, shaderType: string, code: string) => string;
94
+ /**
95
+ * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
96
+ */
97
+ processFinalCode?: (postProcessName: string, shaderType: string, code: string) => string;
98
+ /**
99
+ * If provided, will be called before creating the effect to collect additional custom bindings (defines, uniforms, samplers)
100
+ */
101
+ defineCustomBindings?: (postProcessName: string, defines: Nullable<string>, uniforms: string[], samplers: string[]) => Nullable<string>;
102
+ /**
103
+ * If provided, will be called when binding inputs to the shader code to allow the user to add custom bindings
104
+ */
105
+ bindCustomBindings?: (postProcessName: string, effect: Effect) => void;
106
+ };
85
107
  /**
86
108
  * Options to create an EffectWrapper
87
109
  */
88
- interface EffectWrapperCreationOptions {
110
+ export interface EffectWrapperCreationOptions {
89
111
  /**
90
112
  * Engine to use to create the effect
91
113
  */
92
- engine: AbstractEngine;
114
+ engine?: AbstractEngine;
93
115
  /**
94
116
  * Fragment shader for the effect
95
117
  */
96
- fragmentShader: string;
118
+ fragmentShader?: string;
97
119
  /**
98
120
  * Use the shader store instead of direct source code
99
121
  */
100
122
  useShaderStore?: boolean;
101
123
  /**
102
- * Vertex shader for the effect
124
+ * Vertex shader for the effect (default: "postprocess")
103
125
  */
104
126
  vertexShader?: string;
105
127
  /**
106
- * Attributes to use in the shader
128
+ * Alias for vertexShader
129
+ */
130
+ vertexUrl?: string;
131
+ /**
132
+ * Attributes to use in the shader (default: ["position"])
107
133
  */
108
134
  attributeNames?: Array<string>;
109
135
  /**
110
136
  * Uniforms to use in the shader
111
137
  */
112
138
  uniformNames?: Array<string>;
139
+ /**
140
+ * Alias for uniformNames. Note that if it is provided, it takes precedence over uniformNames.
141
+ */
142
+ uniforms?: Nullable<string[]>;
113
143
  /**
114
144
  * Texture sampler names to use in the shader
115
145
  */
116
146
  samplerNames?: Array<string>;
147
+ /**
148
+ * Alias for samplerNames. Note that if it is provided, it takes precedence over samplerNames.
149
+ */
150
+ samplers?: Nullable<string[]>;
151
+ /**
152
+ * The list of uniform buffers used in the shader (if any)
153
+ */
154
+ uniformBuffers?: Nullable<string[]>;
117
155
  /**
118
156
  * Defines to use in the shader
119
157
  */
120
- defines?: Array<string>;
158
+ defines?: Nullable<string | Array<string>>;
159
+ /**
160
+ * The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined)
161
+ * See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
162
+ */
163
+ indexParameters?: any;
164
+ /**
165
+ * If the shader should not be compiled immediately. (default: false)
166
+ */
167
+ blockCompilation?: boolean;
121
168
  /**
122
169
  * Callback when effect is compiled
123
170
  */
124
171
  onCompiled?: Nullable<(effect: Effect) => void>;
125
172
  /**
126
- * The friendly name of the effect displayed in Spector.
173
+ * The friendly name of the effect (default: "effectWrapper")
127
174
  */
128
175
  name?: string;
129
176
  /**
130
177
  * The language the shader is written in (default: GLSL)
131
178
  */
132
179
  shaderLanguage?: ShaderLanguage;
180
+ /**
181
+ * Defines additional code to call to prepare the shader code
182
+ */
183
+ extraInitializations?: (useWebGPU: boolean, list: Promise<any>[]) => void;
133
184
  /**
134
185
  * Additional async code to run before preparing the effect
135
186
  */
136
187
  extraInitializationsAsync?: () => Promise<void>;
188
+ /**
189
+ * If the effect should be used as a post process (default: false). If true, the effect will be created with a "scale" uniform and a "textureSampler" sampler
190
+ */
191
+ useAsPostProcess?: boolean;
137
192
  }
138
193
  /**
139
194
  * Wraps an effect to be used for rendering
140
195
  */
141
196
  export declare class EffectWrapper {
142
197
  /**
143
- * Event that is fired right before the effect is drawn (should be used to update uniforms)
198
+ * Force code to compile to glsl even on WebGPU engines.
199
+ * False by default. This is mostly meant for backward compatibility.
200
+ */
201
+ static ForceGLSL: boolean;
202
+ private static _CustomShaderCodeProcessing;
203
+ /**
204
+ * Registers a shader code processing with an effect wrapper name.
205
+ * @param effectWrapperName name of the effect wrapper. Use null for the fallback shader code processing. This is the shader code processing that will be used in case no specific shader code processing has been associated to an effect wrapper name
206
+ * @param customShaderCodeProcessing shader code processing to associate to the effect wrapper name
207
+ */
208
+ static RegisterShaderCodeProcessing(effectWrapperName: Nullable<string>, customShaderCodeProcessing?: EffectWrapperCustomShaderCodeProcessing): void;
209
+ private static _GetShaderCodeProcessing;
210
+ /**
211
+ * Gets or sets the name of the effect wrapper
212
+ */
213
+ get name(): string;
214
+ set name(value: string);
215
+ /**
216
+ * Type of alpha mode to use when applying the effect (default: Engine.ALPHA_DISABLE)
217
+ */
218
+ alphaMode: number;
219
+ /**
220
+ * Executed when the effect is created
221
+ * @returns effect that was created for this effect wrapper
222
+ */
223
+ onEffectCreatedObservable: Observable<Effect>;
224
+ /**
225
+ * Options used to create the effect wrapper
226
+ */
227
+ readonly options: Required<NonNullableFields<EffectWrapperCreationOptions>>;
228
+ /**
229
+ * Get a value indicating if the effect is ready to be used
230
+ * @returns true if the post-process is ready (shader is compiled)
231
+ */
232
+ isReady(): boolean;
233
+ /**
234
+ * Get the draw wrapper associated with the effect wrapper
235
+ * @returns the draw wrapper associated with the effect wrapper
236
+ */
237
+ get drawWrapper(): DrawWrapper;
238
+ /**
239
+ * Event that is fired (only when the EffectWrapper is used with an EffectRenderer) right before the effect is drawn (should be used to update uniforms)
144
240
  */
145
241
  onApplyObservable: Observable<{}>;
146
242
  /**
@@ -148,18 +244,40 @@ export declare class EffectWrapper {
148
244
  */
149
245
  get effect(): Effect;
150
246
  set effect(effect: Effect);
247
+ protected readonly _drawWrapper: DrawWrapper;
248
+ protected _shadersLoaded: boolean;
249
+ protected readonly _shaderPath: IShaderPath;
151
250
  /** @internal */
152
- _drawWrapper: DrawWrapper;
251
+ _webGPUReady: boolean;
153
252
  private _onContextRestoredObserver;
154
253
  /**
155
- * Creates an effect to be renderer
254
+ * Creates an effect to be rendered
156
255
  * @param creationOptions options to create the effect
157
256
  */
158
257
  constructor(creationOptions: EffectWrapperCreationOptions);
258
+ protected _gatherImports(useWebGPU: boolean | undefined, list: Promise<any>[]): void;
259
+ private _importPromises;
260
+ /** @internal */
261
+ _postConstructor(blockCompilation: boolean, defines?: Nullable<string>, extraInitializations?: (useWebGPU: boolean, list: Promise<any>[]) => void, importPromises?: Array<Promise<any>>): void;
262
+ /**
263
+ * Updates the effect with the current effect wrapper compile time values and recompiles the shader.
264
+ * @param defines Define statements that should be added at the beginning of the shader. (default: null)
265
+ * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
266
+ * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
267
+ * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
268
+ * @param onCompiled Called when the shader has been compiled.
269
+ * @param onError Called if there is an error when compiling a shader.
270
+ * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
271
+ * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
272
+ */
273
+ updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
274
+ /**
275
+ * Binds the data to the effect.
276
+ */
277
+ bind(): void;
159
278
  /**
160
279
  * Disposes of the effect wrapper
161
280
  * @param _ignored kept for backward compatibility
162
281
  */
163
282
  dispose(_ignored?: boolean): void;
164
283
  }
165
- export {};
@@ -62,7 +62,7 @@ export class EffectRenderer {
62
62
  this.engine.setState(true);
63
63
  this.engine.depthCullingState.depthTest = false;
64
64
  this.engine.stencilState.stencilTest = false;
65
- this.engine.enableEffect(effectWrapper._drawWrapper);
65
+ this.engine.enableEffect(effectWrapper.drawWrapper);
66
66
  this.bindBuffers(effectWrapper.effect);
67
67
  effectWrapper.onApplyObservable.notifyObservers({});
68
68
  }
@@ -92,7 +92,7 @@ export class EffectRenderer {
92
92
  /**
93
93
  * renders one or more effects to a specified texture
94
94
  * @param effectWrapper the effect to renderer
95
- * @param outputTexture texture to draw to, if null it will render to the screen.
95
+ * @param outputTexture texture to draw to, if null it will render to the currently bound frame buffer
96
96
  */
97
97
  render(effectWrapper, outputTexture = null) {
98
98
  // Ensure effect is ready
@@ -135,6 +135,44 @@ export class EffectRenderer {
135
135
  * Wraps an effect to be used for rendering
136
136
  */
137
137
  export class EffectWrapper {
138
+ /**
139
+ * Registers a shader code processing with an effect wrapper name.
140
+ * @param effectWrapperName name of the effect wrapper. Use null for the fallback shader code processing. This is the shader code processing that will be used in case no specific shader code processing has been associated to an effect wrapper name
141
+ * @param customShaderCodeProcessing shader code processing to associate to the effect wrapper name
142
+ */
143
+ static RegisterShaderCodeProcessing(effectWrapperName, customShaderCodeProcessing) {
144
+ if (!customShaderCodeProcessing) {
145
+ delete EffectWrapper._CustomShaderCodeProcessing[effectWrapperName ?? ""];
146
+ return;
147
+ }
148
+ EffectWrapper._CustomShaderCodeProcessing[effectWrapperName ?? ""] = customShaderCodeProcessing;
149
+ }
150
+ static _GetShaderCodeProcessing(effectWrapperName) {
151
+ return EffectWrapper._CustomShaderCodeProcessing[effectWrapperName] ?? EffectWrapper._CustomShaderCodeProcessing[""];
152
+ }
153
+ /**
154
+ * Gets or sets the name of the effect wrapper
155
+ */
156
+ get name() {
157
+ return this.options.name;
158
+ }
159
+ set name(value) {
160
+ this.options.name = value;
161
+ }
162
+ /**
163
+ * Get a value indicating if the effect is ready to be used
164
+ * @returns true if the post-process is ready (shader is compiled)
165
+ */
166
+ isReady() {
167
+ return this._drawWrapper.effect?.isReady() ?? false;
168
+ }
169
+ /**
170
+ * Get the draw wrapper associated with the effect wrapper
171
+ * @returns the draw wrapper associated with the effect wrapper
172
+ */
173
+ get drawWrapper() {
174
+ return this._drawWrapper;
175
+ }
138
176
  /**
139
177
  * The underlying effect
140
178
  */
@@ -145,54 +183,205 @@ export class EffectWrapper {
145
183
  this._drawWrapper.effect = effect;
146
184
  }
147
185
  /**
148
- * Creates an effect to be renderer
186
+ * Creates an effect to be rendered
149
187
  * @param creationOptions options to create the effect
150
188
  */
151
189
  constructor(creationOptions) {
152
190
  /**
153
- * Event that is fired right before the effect is drawn (should be used to update uniforms)
191
+ * Type of alpha mode to use when applying the effect (default: Engine.ALPHA_DISABLE)
192
+ */
193
+ this.alphaMode = 0;
194
+ /**
195
+ * Executed when the effect is created
196
+ * @returns effect that was created for this effect wrapper
197
+ */
198
+ this.onEffectCreatedObservable = new Observable(undefined, true);
199
+ /**
200
+ * Event that is fired (only when the EffectWrapper is used with an EffectRenderer) right before the effect is drawn (should be used to update uniforms)
154
201
  */
155
202
  this.onApplyObservable = new Observable();
156
- let shaderPath;
157
- const uniformNames = creationOptions.uniformNames || [];
158
- if (creationOptions.vertexShader) {
159
- shaderPath = {
160
- fragmentSource: creationOptions.fragmentShader,
161
- vertexSource: creationOptions.vertexShader,
162
- spectorName: creationOptions.name || "effectWrapper",
203
+ this._shadersLoaded = false;
204
+ /** @internal */
205
+ this._webGPUReady = false;
206
+ this._importPromises = [];
207
+ this.options = {
208
+ ...creationOptions,
209
+ name: creationOptions.name || "effectWrapper",
210
+ engine: creationOptions.engine,
211
+ uniforms: creationOptions.uniforms || creationOptions.uniformNames || [],
212
+ uniformNames: undefined,
213
+ samplers: creationOptions.samplers || creationOptions.samplerNames || [],
214
+ samplerNames: undefined,
215
+ attributeNames: creationOptions.attributeNames || ["position"],
216
+ uniformBuffers: creationOptions.uniformBuffers || [],
217
+ defines: creationOptions.defines || "",
218
+ useShaderStore: creationOptions.useShaderStore || false,
219
+ vertexUrl: creationOptions.vertexUrl || creationOptions.vertexShader || "postprocess",
220
+ vertexShader: undefined,
221
+ fragmentShader: creationOptions.fragmentShader || "pass",
222
+ indexParameters: creationOptions.indexParameters,
223
+ blockCompilation: creationOptions.blockCompilation || false,
224
+ shaderLanguage: creationOptions.shaderLanguage || 0 /* ShaderLanguage.GLSL */,
225
+ onCompiled: creationOptions.onCompiled || undefined,
226
+ extraInitializations: creationOptions.extraInitializations || undefined,
227
+ extraInitializationsAsync: creationOptions.extraInitializationsAsync || undefined,
228
+ useAsPostProcess: creationOptions.useAsPostProcess ?? false,
229
+ };
230
+ this.options.uniformNames = this.options.uniforms;
231
+ this.options.samplerNames = this.options.samplers;
232
+ this.options.vertexShader = this.options.vertexUrl;
233
+ if (this.options.useAsPostProcess) {
234
+ if (this.options.samplers.indexOf("textureSampler") === -1) {
235
+ this.options.samplers.push("textureSampler");
236
+ }
237
+ if (this.options.uniforms.indexOf("scale") === -1) {
238
+ this.options.uniforms.push("scale");
239
+ }
240
+ }
241
+ if (creationOptions.vertexUrl || creationOptions.vertexShader) {
242
+ this._shaderPath = {
243
+ vertexSource: this.options.vertexShader,
163
244
  };
164
245
  }
165
246
  else {
166
- // Default scale to use in post process vertex shader.
167
- uniformNames.push("scale");
168
- shaderPath = {
169
- fragmentSource: creationOptions.fragmentShader,
170
- vertex: "postprocess",
171
- spectorName: creationOptions.name || "effectWrapper",
247
+ if (!this.options.useAsPostProcess) {
248
+ this.options.uniforms.push("scale");
249
+ this.onApplyObservable.add(() => {
250
+ this.effect.setFloat2("scale", 1, 1);
251
+ });
252
+ }
253
+ this._shaderPath = {
254
+ vertex: this.options.vertexShader,
172
255
  };
173
- // Sets the default scale to identity for the post process vertex shader.
174
- this.onApplyObservable.add(() => {
175
- this.effect.setFloat2("scale", 1, 1);
176
- });
177
256
  }
178
- const defines = creationOptions.defines ? creationOptions.defines.join("\n") : "";
179
- this._drawWrapper = new DrawWrapper(creationOptions.engine);
180
- if (creationOptions.useShaderStore) {
181
- shaderPath.fragment = shaderPath.fragmentSource;
182
- if (!shaderPath.vertex) {
183
- shaderPath.vertex = shaderPath.vertexSource;
257
+ this._shaderPath.fragmentSource = this.options.fragmentShader;
258
+ this._shaderPath.spectorName = this.options.name;
259
+ if (this.options.useShaderStore) {
260
+ this._shaderPath.fragment = this._shaderPath.fragmentSource;
261
+ if (!this._shaderPath.vertex) {
262
+ this._shaderPath.vertex = this._shaderPath.vertexSource;
184
263
  }
185
- delete shaderPath.fragmentSource;
186
- delete shaderPath.vertexSource;
187
- this.effect = creationOptions.engine.createEffect(shaderPath, creationOptions.attributeNames || ["position"], uniformNames, creationOptions.samplerNames, defines, undefined, creationOptions.onCompiled, undefined, undefined, creationOptions.shaderLanguage, creationOptions.extraInitializationsAsync);
264
+ delete this._shaderPath.fragmentSource;
265
+ delete this._shaderPath.vertexSource;
188
266
  }
189
- else {
190
- this.effect = new Effect(shaderPath, creationOptions.attributeNames || ["position"], uniformNames, creationOptions.samplerNames, creationOptions.engine, defines, undefined, creationOptions.onCompiled, undefined, undefined, undefined, creationOptions.shaderLanguage, creationOptions.extraInitializationsAsync);
191
- this._onContextRestoredObserver = creationOptions.engine.onContextRestoredObservable.add(() => {
267
+ this.onApplyObservable.add(() => {
268
+ this.bind();
269
+ });
270
+ if (!this.options.useShaderStore) {
271
+ this._onContextRestoredObserver = this.options.engine.onContextRestoredObservable.add(() => {
192
272
  this.effect._pipelineContext = null; // because _prepareEffect will try to dispose this pipeline before recreating it and that would lead to webgl errors
193
273
  this.effect._prepareEffect();
194
274
  });
195
275
  }
276
+ this._drawWrapper = new DrawWrapper(this.options.engine);
277
+ this._webGPUReady = this.options.shaderLanguage === 1 /* ShaderLanguage.WGSL */;
278
+ const defines = Array.isArray(this.options.defines) ? this.options.defines.join("\n") : this.options.defines;
279
+ this._postConstructor(this.options.blockCompilation, defines, this.options.extraInitializations);
280
+ }
281
+ _gatherImports(useWebGPU = false, list) {
282
+ if (!this.options.useAsPostProcess) {
283
+ return;
284
+ }
285
+ // this._webGPUReady is used to detect when an effect wrapper is intended to be used with WebGPU
286
+ if (useWebGPU && this._webGPUReady) {
287
+ list.push(Promise.all([import("../ShadersWGSL/postprocess.vertex.js")]));
288
+ }
289
+ else {
290
+ list.push(Promise.all([import("../Shaders/postprocess.vertex.js")]));
291
+ }
292
+ }
293
+ /** @internal */
294
+ _postConstructor(blockCompilation, defines = null, extraInitializations, importPromises) {
295
+ this._importPromises.length = 0;
296
+ if (importPromises) {
297
+ this._importPromises.push(...importPromises);
298
+ }
299
+ const useWebGPU = this.options.engine.isWebGPU && !EffectWrapper.ForceGLSL;
300
+ this._gatherImports(useWebGPU, this._importPromises);
301
+ if (extraInitializations !== undefined) {
302
+ extraInitializations(useWebGPU, this._importPromises);
303
+ }
304
+ if (useWebGPU && this._webGPUReady) {
305
+ this.options.shaderLanguage = 1 /* ShaderLanguage.WGSL */;
306
+ }
307
+ if (!blockCompilation) {
308
+ this.updateEffect(defines);
309
+ }
310
+ }
311
+ /**
312
+ * Updates the effect with the current effect wrapper compile time values and recompiles the shader.
313
+ * @param defines Define statements that should be added at the beginning of the shader. (default: null)
314
+ * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
315
+ * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
316
+ * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
317
+ * @param onCompiled Called when the shader has been compiled.
318
+ * @param onError Called if there is an error when compiling a shader.
319
+ * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
320
+ * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
321
+ */
322
+ updateEffect(defines = null, uniforms = null, samplers = null, indexParameters, onCompiled, onError, vertexUrl, fragmentUrl) {
323
+ const customShaderCodeProcessing = EffectWrapper._GetShaderCodeProcessing(this.name);
324
+ if (customShaderCodeProcessing?.defineCustomBindings) {
325
+ const newUniforms = uniforms?.slice() ?? [];
326
+ newUniforms.push(...this.options.uniforms);
327
+ const newSamplers = samplers?.slice() ?? [];
328
+ newSamplers.push(...this.options.samplers);
329
+ defines = customShaderCodeProcessing.defineCustomBindings(this.name, defines, newUniforms, newSamplers);
330
+ uniforms = newUniforms;
331
+ samplers = newSamplers;
332
+ }
333
+ this.options.defines = defines || "";
334
+ const waitImportsLoaded = this._shadersLoaded || this._importPromises.length === 0
335
+ ? undefined
336
+ : async () => {
337
+ await Promise.all(this._importPromises);
338
+ this._shadersLoaded = true;
339
+ };
340
+ let extraInitializationsAsync;
341
+ if (this.options.extraInitializationsAsync) {
342
+ extraInitializationsAsync = async () => {
343
+ waitImportsLoaded?.();
344
+ await this.options.extraInitializationsAsync;
345
+ };
346
+ }
347
+ else {
348
+ extraInitializationsAsync = waitImportsLoaded;
349
+ }
350
+ if (this.options.useShaderStore) {
351
+ this._drawWrapper.effect = this.options.engine.createEffect({ vertex: vertexUrl ?? this._shaderPath.vertex, fragment: fragmentUrl ?? this._shaderPath.fragment }, {
352
+ attributes: this.options.attributeNames,
353
+ uniformsNames: uniforms || this.options.uniforms,
354
+ uniformBuffersNames: this.options.uniformBuffers,
355
+ samplers: samplers || this.options.samplers,
356
+ defines: defines !== null ? defines : "",
357
+ fallbacks: null,
358
+ onCompiled: onCompiled ?? this.options.onCompiled,
359
+ onError: onError ?? null,
360
+ indexParameters: indexParameters || this.options.indexParameters,
361
+ processCodeAfterIncludes: customShaderCodeProcessing?.processCodeAfterIncludes
362
+ ? (shaderType, code) => customShaderCodeProcessing.processCodeAfterIncludes(this.name, shaderType, code)
363
+ : null,
364
+ processFinalCode: customShaderCodeProcessing?.processFinalCode
365
+ ? (shaderType, code) => customShaderCodeProcessing.processFinalCode(this.name, shaderType, code)
366
+ : null,
367
+ shaderLanguage: this.options.shaderLanguage,
368
+ extraInitializationsAsync,
369
+ }, this.options.engine);
370
+ }
371
+ else {
372
+ this._drawWrapper.effect = new Effect(this._shaderPath, this.options.attributeNames, uniforms || this.options.uniforms, samplers || this.options.samplerNames, this.options.engine, defines, undefined, onCompiled || this.options.onCompiled, undefined, undefined, undefined, this.options.shaderLanguage, extraInitializationsAsync);
373
+ }
374
+ this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect);
375
+ }
376
+ /**
377
+ * Binds the data to the effect.
378
+ */
379
+ bind() {
380
+ this.options.engine.setAlphaMode(this.alphaMode);
381
+ if (this.options.useAsPostProcess) {
382
+ this.drawWrapper.effect.setFloat2("scale", 1, 1);
383
+ }
384
+ EffectWrapper._GetShaderCodeProcessing(this.name)?.bindCustomBindings?.(this.name, this._drawWrapper.effect);
196
385
  }
197
386
  /**
198
387
  * Disposes of the effect wrapper
@@ -203,7 +392,14 @@ export class EffectWrapper {
203
392
  this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);
204
393
  this._onContextRestoredObserver = null;
205
394
  }
395
+ this.onEffectCreatedObservable.clear();
206
396
  this.effect.dispose();
207
397
  }
208
398
  }
399
+ /**
400
+ * Force code to compile to glsl even on WebGPU engines.
401
+ * False by default. This is mostly meant for backward compatibility.
402
+ */
403
+ EffectWrapper.ForceGLSL = false;
404
+ EffectWrapper._CustomShaderCodeProcessing = {};
209
405
  //# sourceMappingURL=effectRenderer.js.map