@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
@@ -5,48 +5,42 @@ import { Texture } from "../Materials/Textures/texture.js";
5
5
  import { RegisterClass } from "../Misc/typeStore.js";
6
6
  import { serialize, serializeAsVector2 } from "../Misc/decorators.js";
7
7
  import { SerializationHelper } from "../Misc/decorators.serialization.js";
8
+ import { ThinBlurPostProcess } from "./thinBlurPostProcess.js";
8
9
  /**
9
10
  * The Blur Post Process which blurs an image based on a kernel and direction.
10
11
  * Can be used twice in x and y directions to perform a gaussian blur in two passes.
11
12
  */
12
13
  export class BlurPostProcess extends PostProcess {
14
+ /** The direction in which to blur the image. */
15
+ get direction() {
16
+ return this._effectWrapper.direction;
17
+ }
18
+ set direction(value) {
19
+ this._effectWrapper.direction = value;
20
+ }
13
21
  /**
14
22
  * Sets the length in pixels of the blur sample region
15
23
  */
16
24
  set kernel(v) {
17
- if (this._idealKernel === v) {
18
- return;
19
- }
20
- v = Math.max(v, 1);
21
- this._idealKernel = v;
22
- this._kernel = this._nearestBestKernel(v);
23
- if (!this._blockCompilation) {
24
- this._updateParameters();
25
- }
25
+ this._effectWrapper.kernel = v;
26
26
  }
27
27
  /**
28
28
  * Gets the length in pixels of the blur sample region
29
29
  */
30
30
  get kernel() {
31
- return this._idealKernel;
31
+ return this._effectWrapper.kernel;
32
32
  }
33
33
  /**
34
34
  * Sets whether or not the blur needs to unpack/repack floats
35
35
  */
36
36
  set packedFloat(v) {
37
- if (this._packedFloat === v) {
38
- return;
39
- }
40
- this._packedFloat = v;
41
- if (!this._blockCompilation) {
42
- this._updateParameters();
43
- }
37
+ this._effectWrapper.packedFloat = v;
44
38
  }
45
39
  /**
46
40
  * Gets whether or not the blur is unpacking/repacking floats
47
41
  */
48
42
  get packedFloat() {
49
- return this._packedFloat;
43
+ return this._effectWrapper.packedFloat;
50
44
  }
51
45
  /**
52
46
  * Gets a string identifying the name of the class
@@ -67,173 +61,41 @@ export class BlurPostProcess extends PostProcess {
67
61
  * @param reusable If the post process can be reused on the same frame. (default: false)
68
62
  * @param textureType Type of textures used when performing the post process. (default: 0)
69
63
  * @param defines
70
- * @param _blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
64
+ * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
71
65
  * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
72
66
  */
73
- constructor(name, direction, kernel, options, camera, samplingMode = Texture.BILINEAR_SAMPLINGMODE, engine, reusable, textureType = 0, defines = "", _blockCompilation = false, textureFormat = 5) {
74
- super(name, "kernelBlur", ["delta", "direction"], ["circleOfConfusionSampler"], options, camera, samplingMode, engine, reusable, null, textureType, "kernelBlur", { varyingCount: 0, depCount: 0 }, true, textureFormat);
75
- this._blockCompilation = _blockCompilation;
76
- this._packedFloat = false;
77
- this._staticDefines = "";
78
- this._staticDefines = defines;
67
+ constructor(name, direction, kernel, options, camera = null, samplingMode = Texture.BILINEAR_SAMPLINGMODE, engine, reusable, textureType = 0, defines = "", blockCompilation = false, textureFormat = 5) {
68
+ const blockCompilationFinal = typeof options === "number" ? blockCompilation : !!options.blockCompilation;
69
+ const localOptions = {
70
+ uniforms: ThinBlurPostProcess.Uniforms,
71
+ samplers: ThinBlurPostProcess.Samplers,
72
+ size: typeof options === "number" ? options : undefined,
73
+ camera,
74
+ samplingMode,
75
+ engine,
76
+ reusable,
77
+ textureType,
78
+ vertexUrl: ThinBlurPostProcess.VertexUrl,
79
+ indexParameters: { varyingCount: 0, depCount: 0 },
80
+ textureFormat,
81
+ defines,
82
+ ...options,
83
+ blockCompilation: true,
84
+ };
85
+ super(name, ThinBlurPostProcess.FragmentUrl, {
86
+ effectWrapper: typeof options === "number" || !options.effectWrapper ? new ThinBlurPostProcess(name, engine, undefined, undefined, localOptions) : undefined,
87
+ ...localOptions,
88
+ });
89
+ this._effectWrapper.options.blockCompilation = blockCompilationFinal;
79
90
  this.direction = direction;
80
- this.onApplyObservable.add((effect) => {
81
- if (this._outputTexture) {
82
- effect.setFloat2("delta", (1 / this._outputTexture.width) * this.direction.x, (1 / this._outputTexture.height) * this.direction.y);
83
- }
84
- else {
85
- effect.setFloat2("delta", (1 / this.width) * this.direction.x, (1 / this.height) * this.direction.y);
86
- }
91
+ this.onApplyObservable.add(() => {
92
+ this._effectWrapper.textureWidth = this._outputTexture ? this._outputTexture.width : this.width;
93
+ this._effectWrapper.textureHeight = this._outputTexture ? this._outputTexture.height : this.height;
87
94
  });
88
95
  this.kernel = kernel;
89
96
  }
90
- _gatherImports(useWebGPU, list) {
91
- if (useWebGPU) {
92
- this._webGPUReady = true;
93
- list.push(Promise.all([import("../ShadersWGSL/kernelBlur.fragment.js"), import("../ShadersWGSL/kernelBlur.vertex.js")]));
94
- }
95
- else {
96
- list.push(Promise.all([import("../Shaders/kernelBlur.fragment.js"), import("../Shaders/kernelBlur.vertex.js")]));
97
- }
98
- super._gatherImports(useWebGPU, list);
99
- }
100
- /**
101
- * Updates the effect with the current post process compile time values and recompiles the shader.
102
- * @param defines Define statements that should be added at the beginning of the shader. (default: null)
103
- * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
104
- * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
105
- * @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
106
- * @param onCompiled Called when the shader has been compiled.
107
- * @param onError Called if there is an error when compiling a shader.
108
- */
109
- updateEffect(defines = null, uniforms = null, samplers = null, indexParameters, onCompiled, onError) {
110
- this._updateParameters(onCompiled, onError);
111
- }
112
- _updateParameters(onCompiled, onError) {
113
- // Generate sampling offsets and weights
114
- const N = this._kernel;
115
- const centerIndex = (N - 1) / 2;
116
- // Generate Gaussian sampling weights over kernel
117
- let offsets = [];
118
- let weights = [];
119
- let totalWeight = 0;
120
- for (let i = 0; i < N; i++) {
121
- const u = i / (N - 1);
122
- const w = this._gaussianWeight(u * 2.0 - 1);
123
- offsets[i] = i - centerIndex;
124
- weights[i] = w;
125
- totalWeight += w;
126
- }
127
- // Normalize weights
128
- for (let i = 0; i < weights.length; i++) {
129
- weights[i] /= totalWeight;
130
- }
131
- // Optimize: combine samples to take advantage of hardware linear sampling
132
- // Walk from left to center, combining pairs (symmetrically)
133
- const linearSamplingWeights = [];
134
- const linearSamplingOffsets = [];
135
- const linearSamplingMap = [];
136
- for (let i = 0; i <= centerIndex; i += 2) {
137
- const j = Math.min(i + 1, Math.floor(centerIndex));
138
- const singleCenterSample = i === j;
139
- if (singleCenterSample) {
140
- linearSamplingMap.push({ o: offsets[i], w: weights[i] });
141
- }
142
- else {
143
- const sharedCell = j === centerIndex;
144
- const weightLinear = weights[i] + weights[j] * (sharedCell ? 0.5 : 1);
145
- const offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
146
- if (offsetLinear === 0) {
147
- linearSamplingMap.push({ o: offsets[i], w: weights[i] });
148
- linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
149
- }
150
- else {
151
- linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
152
- linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
153
- }
154
- }
155
- }
156
- for (let i = 0; i < linearSamplingMap.length; i++) {
157
- linearSamplingOffsets[i] = linearSamplingMap[i].o;
158
- linearSamplingWeights[i] = linearSamplingMap[i].w;
159
- }
160
- // Replace with optimized
161
- offsets = linearSamplingOffsets;
162
- weights = linearSamplingWeights;
163
- // Generate shaders
164
- const maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors - (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? 1 : 0); // Because of the additional builtins
165
- const freeVaryingVec2 = Math.max(maxVaryingRows, 0) - 1; // Because of sampleCenter
166
- let varyingCount = Math.min(offsets.length, freeVaryingVec2);
167
- let defines = "";
168
- defines += this._staticDefines;
169
- // The DOF fragment should ignore the center pixel when looping as it is handled manually in the fragment shader.
170
- if (this._staticDefines.indexOf("DOF") != -1) {
171
- defines += `#define CENTER_WEIGHT ${this._glslFloat(weights[varyingCount - 1])}\n`;
172
- varyingCount--;
173
- }
174
- for (let i = 0; i < varyingCount; i++) {
175
- defines += `#define KERNEL_OFFSET${i} ${this._glslFloat(offsets[i])}\n`;
176
- defines += `#define KERNEL_WEIGHT${i} ${this._glslFloat(weights[i])}\n`;
177
- }
178
- let depCount = 0;
179
- for (let i = freeVaryingVec2; i < offsets.length; i++) {
180
- defines += `#define KERNEL_DEP_OFFSET${depCount} ${this._glslFloat(offsets[i])}\n`;
181
- defines += `#define KERNEL_DEP_WEIGHT${depCount} ${this._glslFloat(weights[i])}\n`;
182
- depCount++;
183
- }
184
- if (this.packedFloat) {
185
- defines += `#define PACKEDFLOAT 1`;
186
- }
187
- this._blockCompilation = false;
188
- super.updateEffect(defines, null, null, {
189
- varyingCount: varyingCount,
190
- depCount: depCount,
191
- }, onCompiled, onError);
192
- }
193
- /**
194
- * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
195
- * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
196
- * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
197
- * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
198
- * The gaps between physical kernels are compensated for in the weighting of the samples
199
- * @param idealKernel Ideal blur kernel.
200
- * @returns Nearest best kernel.
201
- */
202
- _nearestBestKernel(idealKernel) {
203
- const v = Math.round(idealKernel);
204
- for (const k of [v, v - 1, v + 1, v - 2, v + 2]) {
205
- if (k % 2 !== 0 && Math.floor(k / 2) % 2 === 0 && k > 0) {
206
- return Math.max(k, 3);
207
- }
208
- }
209
- return Math.max(v, 3);
210
- }
211
- /**
212
- * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
213
- * @param x The point on the Gaussian distribution to sample.
214
- * @returns the value of the Gaussian function at x.
215
- */
216
- _gaussianWeight(x) {
217
- //reference: Engines/ImageProcessingBlur.cpp #dcc760
218
- // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
219
- // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
220
- // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
221
- // truncated at around 1.3% of peak strength.
222
- //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
223
- const sigma = 1 / 3;
224
- const denominator = Math.sqrt(2.0 * Math.PI) * sigma;
225
- const exponent = -((x * x) / (2.0 * sigma * sigma));
226
- const weight = (1.0 / denominator) * Math.exp(exponent);
227
- return weight;
228
- }
229
- /**
230
- * Generates a string that can be used as a floating point number in GLSL.
231
- * @param x Value to print.
232
- * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
233
- * @returns GLSL float string.
234
- */
235
- _glslFloat(x, decimalFigures = 8) {
236
- return x.toFixed(decimalFigures).replace(/0+$/, "");
97
+ updateEffect(_defines = null, _uniforms = null, _samplers = null, _indexParameters, onCompiled, onError) {
98
+ this._effectWrapper._updateParameters(onCompiled, onError);
237
99
  }
238
100
  /**
239
101
  * @internal
@@ -245,13 +107,13 @@ export class BlurPostProcess extends PostProcess {
245
107
  }
246
108
  }
247
109
  __decorate([
248
- serialize("kernel")
249
- ], BlurPostProcess.prototype, "_kernel", void 0);
110
+ serializeAsVector2()
111
+ ], BlurPostProcess.prototype, "direction", null);
250
112
  __decorate([
251
- serialize("packedFloat")
252
- ], BlurPostProcess.prototype, "_packedFloat", void 0);
113
+ serialize()
114
+ ], BlurPostProcess.prototype, "kernel", null);
253
115
  __decorate([
254
- serializeAsVector2()
255
- ], BlurPostProcess.prototype, "direction", void 0);
116
+ serialize()
117
+ ], BlurPostProcess.prototype, "packedFloat", null);
256
118
  RegisterClass("BABYLON.BlurPostProcess", BlurPostProcess);
257
119
  //# sourceMappingURL=blurPostProcess.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"blurPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/blurPostProcess.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAMvE;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAY5C;;OAEG;IACH,IAAW,MAAM,CAAC,CAAS;QACvB,IAAI,IAAI,CAAC,YAAY,KAAK,CAAC,EAAE;YACzB,OAAO;SACV;QAED,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YACzB,IAAI,CAAC,iBAAiB,EAAE,CAAC;SAC5B;IACL,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAW,WAAW,CAAC,CAAU;QAC7B,IAAI,IAAI,CAAC,YAAY,KAAK,CAAC,EAAE;YACzB,OAAO;SACV;QACD,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YACzB,IAAI,CAAC,iBAAiB,EAA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C,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport type { Vector2 } from \"../Maths/math.vector\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { serialize, serializeAsVector2 } from \"../Misc/decorators\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * The Blur Post Process which blurs an image based on a kernel and direction.\r\n * Can be used twice in x and y directions to perform a gaussian blur in two passes.\r\n */\r\nexport class BlurPostProcess extends PostProcess {\r\n @serialize(\"kernel\")\r\n protected _kernel: number;\r\n protected _idealKernel: number;\r\n @serialize(\"packedFloat\")\r\n protected _packedFloat: boolean = false;\r\n private _staticDefines: string = \"\";\r\n\r\n /** The direction in which to blur the image. */\r\n @serializeAsVector2()\r\n public direction: Vector2;\r\n\r\n /**\r\n * Sets the length in pixels of the blur sample region\r\n */\r\n public set kernel(v: number) {\r\n if (this._idealKernel === v) {\r\n return;\r\n }\r\n\r\n v = Math.max(v, 1);\r\n this._idealKernel = v;\r\n this._kernel = this._nearestBestKernel(v);\r\n if (!this._blockCompilation) {\r\n this._updateParameters();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the length in pixels of the blur sample region\r\n */\r\n public get kernel(): number {\r\n return this._idealKernel;\r\n }\r\n\r\n /**\r\n * Sets whether or not the blur needs to unpack/repack floats\r\n */\r\n public set packedFloat(v: boolean) {\r\n if (this._packedFloat === v) {\r\n return;\r\n }\r\n this._packedFloat = v;\r\n if (!this._blockCompilation) {\r\n this._updateParameters();\r\n }\r\n }\r\n\r\n /**\r\n * Gets whether or not the blur is unpacking/repacking floats\r\n */\r\n public get packedFloat(): boolean {\r\n return this._packedFloat;\r\n }\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"BlurPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"BlurPostProcess\";\r\n }\r\n\r\n /**\r\n * Creates a new instance BlurPostProcess\r\n * @param name The name of the effect.\r\n * @param direction The direction in which to blur the image.\r\n * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.\r\n * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)\r\n * @param camera The camera to apply the render pass to.\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)\r\n * @param engine The engine which the post process will be applied. (default: current engine)\r\n * @param reusable If the post process can be reused on the same frame. (default: false)\r\n * @param textureType Type of textures used when performing the post process. (default: 0)\r\n * @param defines\r\n * @param _blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)\r\n * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)\r\n */\r\n constructor(\r\n name: string,\r\n direction: Vector2,\r\n kernel: number,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode: number = Texture.BILINEAR_SAMPLINGMODE,\r\n engine?: AbstractEngine,\r\n reusable?: boolean,\r\n textureType = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n defines = \"\",\r\n private _blockCompilation = false,\r\n textureFormat = Constants.TEXTUREFORMAT_RGBA\r\n ) {\r\n super(\r\n name,\r\n \"kernelBlur\",\r\n [\"delta\", \"direction\"],\r\n [\"circleOfConfusionSampler\"],\r\n options,\r\n camera,\r\n samplingMode,\r\n engine,\r\n reusable,\r\n null,\r\n textureType,\r\n \"kernelBlur\",\r\n { varyingCount: 0, depCount: 0 },\r\n true,\r\n textureFormat\r\n );\r\n this._staticDefines = defines;\r\n this.direction = direction;\r\n this.onApplyObservable.add((effect: Effect) => {\r\n if (this._outputTexture) {\r\n effect.setFloat2(\"delta\", (1 / this._outputTexture.width) * this.direction.x, (1 / this._outputTexture.height) * this.direction.y);\r\n } else {\r\n effect.setFloat2(\"delta\", (1 / this.width) * this.direction.x, (1 / this.height) * this.direction.y);\r\n }\r\n });\r\n\r\n this.kernel = kernel;\r\n }\r\n\r\n protected override _gatherImports(useWebGPU: boolean, list: Promise<any>[]) {\r\n if (useWebGPU) {\r\n this._webGPUReady = true;\r\n list.push(Promise.all([import(\"../ShadersWGSL/kernelBlur.fragment\"), import(\"../ShadersWGSL/kernelBlur.vertex\")]));\r\n } else {\r\n list.push(Promise.all([import(\"../Shaders/kernelBlur.fragment\"), import(\"../Shaders/kernelBlur.vertex\")]));\r\n }\r\n\r\n super._gatherImports(useWebGPU, list);\r\n }\r\n\r\n /**\r\n * Updates the effect with the current post process compile time values and recompiles the shader.\r\n * @param defines Define statements that should be added at the beginning of the shader. (default: null)\r\n * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)\r\n * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)\r\n * @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\r\n * @param onCompiled Called when the shader has been compiled.\r\n * @param onError Called if there is an error when compiling a shader.\r\n */\r\n public override updateEffect(\r\n defines: Nullable<string> = null,\r\n uniforms: Nullable<string[]> = null,\r\n samplers: Nullable<string[]> = null,\r\n indexParameters?: any,\r\n onCompiled?: (effect: Effect) => void,\r\n onError?: (effect: Effect, errors: string) => void\r\n ) {\r\n this._updateParameters(onCompiled, onError);\r\n }\r\n\r\n protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void {\r\n // Generate sampling offsets and weights\r\n const N = this._kernel;\r\n const centerIndex = (N - 1) / 2;\r\n\r\n // Generate Gaussian sampling weights over kernel\r\n let offsets = [];\r\n let weights = [];\r\n let totalWeight = 0;\r\n for (let i = 0; i < N; i++) {\r\n const u = i / (N - 1);\r\n const w = this._gaussianWeight(u * 2.0 - 1);\r\n offsets[i] = i - centerIndex;\r\n weights[i] = w;\r\n totalWeight += w;\r\n }\r\n\r\n // Normalize weights\r\n for (let i = 0; i < weights.length; i++) {\r\n weights[i] /= totalWeight;\r\n }\r\n\r\n // Optimize: combine samples to take advantage of hardware linear sampling\r\n // Walk from left to center, combining pairs (symmetrically)\r\n const linearSamplingWeights = [];\r\n const linearSamplingOffsets = [];\r\n\r\n const linearSamplingMap = [];\r\n\r\n for (let i = 0; i <= centerIndex; i += 2) {\r\n const j = Math.min(i + 1, Math.floor(centerIndex));\r\n\r\n const singleCenterSample = i === j;\r\n\r\n if (singleCenterSample) {\r\n linearSamplingMap.push({ o: offsets[i], w: weights[i] });\r\n } else {\r\n const sharedCell = j === centerIndex;\r\n\r\n const weightLinear = weights[i] + weights[j] * (sharedCell ? 0.5 : 1);\r\n const offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);\r\n\r\n if (offsetLinear === 0) {\r\n linearSamplingMap.push({ o: offsets[i], w: weights[i] });\r\n linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });\r\n } else {\r\n linearSamplingMap.push({ o: offsetLinear, w: weightLinear });\r\n linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });\r\n }\r\n }\r\n }\r\n\r\n for (let i = 0; i < linearSamplingMap.length; i++) {\r\n linearSamplingOffsets[i] = linearSamplingMap[i].o;\r\n linearSamplingWeights[i] = linearSamplingMap[i].w;\r\n }\r\n\r\n // Replace with optimized\r\n offsets = linearSamplingOffsets;\r\n weights = linearSamplingWeights;\r\n\r\n // Generate shaders\r\n const maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors - (this.shaderLanguage === ShaderLanguage.WGSL ? 1 : 0); // Because of the additional builtins\r\n const freeVaryingVec2 = Math.max(maxVaryingRows, 0) - 1; // Because of sampleCenter\r\n\r\n let varyingCount = Math.min(offsets.length, freeVaryingVec2);\r\n\r\n let defines = \"\";\r\n defines += this._staticDefines;\r\n\r\n // The DOF fragment should ignore the center pixel when looping as it is handled manually in the fragment shader.\r\n if (this._staticDefines.indexOf(\"DOF\") != -1) {\r\n defines += `#define CENTER_WEIGHT ${this._glslFloat(weights[varyingCount - 1])}\\n`;\r\n varyingCount--;\r\n }\r\n\r\n for (let i = 0; i < varyingCount; i++) {\r\n defines += `#define KERNEL_OFFSET${i} ${this._glslFloat(offsets[i])}\\n`;\r\n defines += `#define KERNEL_WEIGHT${i} ${this._glslFloat(weights[i])}\\n`;\r\n }\r\n\r\n let depCount = 0;\r\n for (let i = freeVaryingVec2; i < offsets.length; i++) {\r\n defines += `#define KERNEL_DEP_OFFSET${depCount} ${this._glslFloat(offsets[i])}\\n`;\r\n defines += `#define KERNEL_DEP_WEIGHT${depCount} ${this._glslFloat(weights[i])}\\n`;\r\n depCount++;\r\n }\r\n\r\n if (this.packedFloat) {\r\n defines += `#define PACKEDFLOAT 1`;\r\n }\r\n\r\n this._blockCompilation = false;\r\n super.updateEffect(\r\n defines,\r\n null,\r\n null,\r\n {\r\n varyingCount: varyingCount,\r\n depCount: depCount,\r\n },\r\n onCompiled,\r\n onError\r\n );\r\n }\r\n\r\n /**\r\n * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.\r\n * Other odd kernels optimize correctly but require proportionally more samples, even kernels are\r\n * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we\r\n * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.\r\n * The gaps between physical kernels are compensated for in the weighting of the samples\r\n * @param idealKernel Ideal blur kernel.\r\n * @returns Nearest best kernel.\r\n */\r\n protected _nearestBestKernel(idealKernel: number): number {\r\n const v = Math.round(idealKernel);\r\n for (const k of [v, v - 1, v + 1, v - 2, v + 2]) {\r\n if (k % 2 !== 0 && Math.floor(k / 2) % 2 === 0 && k > 0) {\r\n return Math.max(k, 3);\r\n }\r\n }\r\n return Math.max(v, 3);\r\n }\r\n\r\n /**\r\n * Calculates the value of a Gaussian distribution with sigma 3 at a given point.\r\n * @param x The point on the Gaussian distribution to sample.\r\n * @returns the value of the Gaussian function at x.\r\n */\r\n protected _gaussianWeight(x: number): number {\r\n //reference: Engines/ImageProcessingBlur.cpp #dcc760\r\n // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],\r\n // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.\r\n // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is\r\n // truncated at around 1.3% of peak strength.\r\n\r\n //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size\r\n const sigma = 1 / 3;\r\n const denominator = Math.sqrt(2.0 * Math.PI) * sigma;\r\n const exponent = -((x * x) / (2.0 * sigma * sigma));\r\n const weight = (1.0 / denominator) * Math.exp(exponent);\r\n return weight;\r\n }\r\n\r\n /**\r\n * Generates a string that can be used as a floating point number in GLSL.\r\n * @param x Value to print.\r\n * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).\r\n * @returns GLSL float string.\r\n */\r\n protected _glslFloat(x: number, decimalFigures = 8) {\r\n return x.toFixed(decimalFigures).replace(/0+$/, \"\");\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static override _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess> {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new BlurPostProcess(\r\n parsedPostProcess.name,\r\n parsedPostProcess.direction,\r\n parsedPostProcess.kernel,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n scene.getEngine(),\r\n parsedPostProcess.reusable,\r\n parsedPostProcess.textureType,\r\n undefined,\r\n false\r\n );\r\n },\r\n parsedPostProcess,\r\n scene,\r\n rootUrl\r\n );\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BlurPostProcess\", BlurPostProcess);\r\n"]}
1
+ {"version":3,"file":"blurPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/blurPostProcess.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAIvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC5C,gDAAgD;IAEhD,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;IACzC,CAAC;IAED,IAAW,SAAS,CAAC,KAAc;QAC/B,IAAI,CAAC,cAAc,CAAC,SAAS,GAAG,KAAK,CAAC;IAC1C,CAAC;IAED;;OAEG;IAEH,IAAW,MAAM,CAAC,CAAS;QACvB,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;IACtC,CAAC;IAED;;OAEG;IAEH,IAAW,WAAW,CAAC,CAAU;QAC7B,IAAI,CAAC,cAAc,CAAC,WAAW,GAAG,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IAID;;;;;;;;;;;;;;OAcG;IACH,YAC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AAE;kDAGX;AAwHL,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import type { Vector2 } from \"../Maths/math.vector\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { serialize, serializeAsVector2 } from \"../Misc/decorators\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\n\r\nimport type { Scene } from \"../scene\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { ThinBlurPostProcess } from \"./thinBlurPostProcess\";\r\n\r\n/**\r\n * The Blur Post Process which blurs an image based on a kernel and direction.\r\n * Can be used twice in x and y directions to perform a gaussian blur in two passes.\r\n */\r\nexport class BlurPostProcess extends PostProcess {\r\n /** The direction in which to blur the image. */\r\n @serializeAsVector2()\r\n public get direction() {\r\n return this._effectWrapper.direction;\r\n }\r\n\r\n public set direction(value: Vector2) {\r\n this._effectWrapper.direction = value;\r\n }\r\n\r\n /**\r\n * Sets the length in pixels of the blur sample region\r\n */\r\n @serialize()\r\n public set kernel(v: number) {\r\n this._effectWrapper.kernel = v;\r\n }\r\n\r\n /**\r\n * Gets the length in pixels of the blur sample region\r\n */\r\n public get kernel(): number {\r\n return this._effectWrapper.kernel;\r\n }\r\n\r\n /**\r\n * Sets whether or not the blur needs to unpack/repack floats\r\n */\r\n @serialize()\r\n public set packedFloat(v: boolean) {\r\n this._effectWrapper.packedFloat = v;\r\n }\r\n\r\n /**\r\n * Gets whether or not the blur is unpacking/repacking floats\r\n */\r\n public get packedFloat(): boolean {\r\n return this._effectWrapper.packedFloat;\r\n }\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"BlurPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"BlurPostProcess\";\r\n }\r\n\r\n protected override _effectWrapper: ThinBlurPostProcess;\r\n\r\n /**\r\n * Creates a new instance BlurPostProcess\r\n * @param name The name of the effect.\r\n * @param direction The direction in which to blur the image.\r\n * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.\r\n * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)\r\n * @param camera The camera to apply the render pass to.\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)\r\n * @param engine The engine which the post process will be applied. (default: current engine)\r\n * @param reusable If the post process can be reused on the same frame. (default: false)\r\n * @param textureType Type of textures used when performing the post process. (default: 0)\r\n * @param defines\r\n * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)\r\n * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)\r\n */\r\n constructor(\r\n name: string,\r\n direction: Vector2,\r\n kernel: number,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera> = null,\r\n samplingMode: number = Texture.BILINEAR_SAMPLINGMODE,\r\n engine?: AbstractEngine,\r\n reusable?: boolean,\r\n textureType = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n defines = \"\",\r\n blockCompilation = false,\r\n textureFormat = Constants.TEXTUREFORMAT_RGBA\r\n ) {\r\n const blockCompilationFinal = typeof options === \"number\" ? blockCompilation : !!options.blockCompilation;\r\n const localOptions = {\r\n uniforms: ThinBlurPostProcess.Uniforms,\r\n samplers: ThinBlurPostProcess.Samplers,\r\n size: typeof options === \"number\" ? options : undefined,\r\n camera,\r\n samplingMode,\r\n engine,\r\n reusable,\r\n textureType,\r\n vertexUrl: ThinBlurPostProcess.VertexUrl,\r\n indexParameters: { varyingCount: 0, depCount: 0 },\r\n textureFormat,\r\n defines,\r\n ...(options as PostProcessOptions),\r\n blockCompilation: true,\r\n };\r\n\r\n super(name, ThinBlurPostProcess.FragmentUrl, {\r\n effectWrapper: typeof options === \"number\" || !options.effectWrapper ? new ThinBlurPostProcess(name, engine, undefined, undefined, localOptions) : undefined,\r\n ...localOptions,\r\n });\r\n\r\n this._effectWrapper.options.blockCompilation = blockCompilationFinal;\r\n\r\n this.direction = direction;\r\n this.onApplyObservable.add(() => {\r\n this._effectWrapper.textureWidth = this._outputTexture ? this._outputTexture.width : this.width;\r\n this._effectWrapper.textureHeight = this._outputTexture ? this._outputTexture.height : this.height;\r\n });\r\n\r\n this.kernel = kernel;\r\n }\r\n\r\n public override updateEffect(\r\n _defines: Nullable<string> = null,\r\n _uniforms: Nullable<string[]> = null,\r\n _samplers: Nullable<string[]> = null,\r\n _indexParameters?: any,\r\n onCompiled?: (effect: Effect) => void,\r\n onError?: (effect: Effect, errors: string) => void\r\n ) {\r\n this._effectWrapper._updateParameters(onCompiled, onError);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static override _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess> {\r\n return SerializationHelper.Parse(\r\n () => {\r\n return new BlurPostProcess(\r\n parsedPostProcess.name,\r\n parsedPostProcess.direction,\r\n parsedPostProcess.kernel,\r\n parsedPostProcess.options,\r\n targetCamera,\r\n parsedPostProcess.renderTargetSamplingMode,\r\n scene.getEngine(),\r\n parsedPostProcess.reusable,\r\n parsedPostProcess.textureType,\r\n undefined,\r\n false\r\n );\r\n },\r\n parsedPostProcess,\r\n scene,\r\n rootUrl\r\n );\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BlurPostProcess\", BlurPostProcess);\r\n"]}
@@ -4,6 +4,9 @@ import { PostProcess } from "./postProcess";
4
4
  import type { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture";
5
5
  import type { Camera } from "../Cameras/camera";
6
6
  import type { AbstractEngine } from "../Engines/abstractEngine.js";
7
+ import type { ThinCircleOfConfusionPostProcessOptions } from "./thinCircleOfConfusionPostProcess";
8
+ import { ThinCircleOfConfusionPostProcess } from "./thinCircleOfConfusionPostProcess";
9
+ export type CircleOfConfusionPostProcessOptions = ThinCircleOfConfusionPostProcessOptions & PostProcessOptions;
7
10
  /**
8
11
  * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
9
12
  */
@@ -11,24 +14,29 @@ export declare class CircleOfConfusionPostProcess extends PostProcess {
11
14
  /**
12
15
  * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.
13
16
  */
14
- lensSize: number;
17
+ get lensSize(): number;
18
+ set lensSize(value: number);
15
19
  /**
16
20
  * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
17
21
  */
18
- fStop: number;
22
+ get fStop(): number;
23
+ set fStop(value: number);
19
24
  /**
20
25
  * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
21
26
  */
22
- focusDistance: number;
27
+ get focusDistance(): number;
28
+ set focusDistance(value: number);
23
29
  /**
24
30
  * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
25
31
  */
26
- focalLength: number;
32
+ get focalLength(): number;
33
+ set focalLength(value: number);
27
34
  /**
28
35
  * Gets a string identifying the name of the class
29
36
  * @returns "CircleOfConfusionPostProcess" string
30
37
  */
31
38
  getClassName(): string;
39
+ protected _effectWrapper: ThinCircleOfConfusionPostProcess;
32
40
  private _depthTexture;
33
41
  /**
34
42
  * Creates a new instance CircleOfConfusionPostProcess
@@ -42,8 +50,7 @@ export declare class CircleOfConfusionPostProcess extends PostProcess {
42
50
  * @param textureType Type of textures used when performing the post process. (default: 0)
43
51
  * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
44
52
  */
45
- constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
46
- protected _gatherImports(useWebGPU: boolean, list: Promise<any>[]): void;
53
+ constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | CircleOfConfusionPostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: AbstractEngine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
47
54
  /**
48
55
  * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
49
56
  */
@@ -4,10 +4,47 @@ import { Logger } from "../Misc/logger.js";
4
4
 
5
5
  import { RegisterClass } from "../Misc/typeStore.js";
6
6
  import { serialize } from "../Misc/decorators.js";
7
+ import { ThinCircleOfConfusionPostProcess } from "./thinCircleOfConfusionPostProcess.js";
7
8
  /**
8
9
  * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
9
10
  */
10
11
  export class CircleOfConfusionPostProcess extends PostProcess {
12
+ /**
13
+ * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.
14
+ */
15
+ get lensSize() {
16
+ return this._effectWrapper.lensSize;
17
+ }
18
+ set lensSize(value) {
19
+ this._effectWrapper.lensSize = value;
20
+ }
21
+ /**
22
+ * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
23
+ */
24
+ get fStop() {
25
+ return this._effectWrapper.fStop;
26
+ }
27
+ set fStop(value) {
28
+ this._effectWrapper.fStop = value;
29
+ }
30
+ /**
31
+ * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
32
+ */
33
+ get focusDistance() {
34
+ return this._effectWrapper.focusDistance;
35
+ }
36
+ set focusDistance(value) {
37
+ this._effectWrapper.focusDistance = value;
38
+ }
39
+ /**
40
+ * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
41
+ */
42
+ get focalLength() {
43
+ return this._effectWrapper.focalLength;
44
+ }
45
+ set focalLength(value) {
46
+ this._effectWrapper.focalLength = value;
47
+ }
11
48
  /**
12
49
  * Gets a string identifying the name of the class
13
50
  * @returns "CircleOfConfusionPostProcess" string
@@ -28,23 +65,23 @@ export class CircleOfConfusionPostProcess extends PostProcess {
28
65
  * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
29
66
  */
30
67
  constructor(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType = 0, blockCompilation = false) {
31
- super(name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation);
32
- /**
33
- * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.
34
- */
35
- this.lensSize = 50;
36
- /**
37
- * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
38
- */
39
- this.fStop = 1.4;
40
- /**
41
- * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
42
- */
43
- this.focusDistance = 2000;
44
- /**
45
- * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
46
- */
47
- this.focalLength = 50;
68
+ const localOptions = {
69
+ uniforms: ThinCircleOfConfusionPostProcess.Uniforms,
70
+ samplers: ThinCircleOfConfusionPostProcess.Samplers,
71
+ defines: typeof options === "object" && options.depthNotNormalized ? ThinCircleOfConfusionPostProcess.DefinesDepthNotNormalized : undefined,
72
+ size: typeof options === "number" ? options : undefined,
73
+ camera,
74
+ samplingMode,
75
+ engine,
76
+ reusable,
77
+ textureType,
78
+ blockCompilation,
79
+ ...options,
80
+ };
81
+ super(name, ThinCircleOfConfusionPostProcess.FragmentUrl, {
82
+ effectWrapper: typeof options === "number" || !options.effectWrapper ? new ThinCircleOfConfusionPostProcess(name, engine, localOptions) : undefined,
83
+ ...localOptions,
84
+ });
48
85
  this._depthTexture = null;
49
86
  this._depthTexture = depthTexture;
50
87
  this.onApplyObservable.add((effect) => {
@@ -53,25 +90,9 @@ export class CircleOfConfusionPostProcess extends PostProcess {
53
90
  return;
54
91
  }
55
92
  effect.setTexture("depthSampler", this._depthTexture);
56
- // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
57
- const aperture = this.lensSize / this.fStop;
58
- const cocPrecalculation = (aperture * this.focalLength) / (this.focusDistance - this.focalLength); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
59
- effect.setFloat("focusDistance", this.focusDistance);
60
- effect.setFloat("cocPrecalculation", cocPrecalculation);
61
- const activeCamera = this._depthTexture.activeCamera;
62
- effect.setFloat2("cameraMinMaxZ", activeCamera.minZ, activeCamera.maxZ - activeCamera.minZ);
93
+ this._effectWrapper.camera = this._depthTexture.activeCamera;
63
94
  });
64
95
  }
65
- _gatherImports(useWebGPU, list) {
66
- if (useWebGPU) {
67
- this._webGPUReady = true;
68
- list.push(import("../ShadersWGSL/circleOfConfusion.fragment.js"));
69
- }
70
- else {
71
- list.push(import("../Shaders/circleOfConfusion.fragment.js"));
72
- }
73
- super._gatherImports(useWebGPU, list);
74
- }
75
96
  /**
76
97
  * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
77
98
  */
@@ -81,15 +102,15 @@ export class CircleOfConfusionPostProcess extends PostProcess {
81
102
  }
82
103
  __decorate([
83
104
  serialize()
84
- ], CircleOfConfusionPostProcess.prototype, "lensSize", void 0);
105
+ ], CircleOfConfusionPostProcess.prototype, "lensSize", null);
85
106
  __decorate([
86
107
  serialize()
87
- ], CircleOfConfusionPostProcess.prototype, "fStop", void 0);
108
+ ], CircleOfConfusionPostProcess.prototype, "fStop", null);
88
109
  __decorate([
89
110
  serialize()
90
- ], CircleOfConfusionPostProcess.prototype, "focusDistance", void 0);
111
+ ], CircleOfConfusionPostProcess.prototype, "focusDistance", null);
91
112
  __decorate([
92
113
  serialize()
93
- ], CircleOfConfusionPostProcess.prototype, "focalLength", void 0);
114
+ ], CircleOfConfusionPostProcess.prototype, "focalLength", null);
94
115
  RegisterClass("BABYLON.CircleOfConfusionPostProcess", CircleOfConfusionPostProcess);
95
116
  //# sourceMappingURL=circleOfConfusionPostProcess.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"circleOfConfusionPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/circleOfConfusionPostProcess.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,WAAW;IAsBzD;;;OAGG;IACa,YAAY;QACxB,OAAO,8BAA8B,CAAC;IAC1C,CAAC;IAGD;;;;;;;;;;;OAWG;IACH,YACI,IAAY,EACZ,YAA2C,EAC3C,OAAoC,EACpC,MAAwB,EACxB,YAAqB,EACrB,MAAuB,EACvB,QAAkB,EAClB,WAAW,GAAG,SAAS,CAAC,wBAAwB,EAChD,gBAAgB,GAAG,KAAK;QAExB,KAAK,CACD,IAAI,EACJ,mBAAmB,EACnB,CAAC,eAAe,EAAE,eAAe,EAAE,mBAAmB,CAAC,EACvD,CAAC,cAAc,CAAC,EAChB,OAAO,EACP,MAAM,EACN,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,SAAS,EACT,IAAI,EACJ,gBAAgB,CACnB,CAAC;QApEN;;WAEG;QAEI,aAAQ,GAAG,EAAE,CAAC;QACrB;;WAEG;QAEI,UAAK,GAAG,GAAG,CAA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AC,MAAM,CAAC,uCAAuC,CAAC,CAAC,CAAC;SAC9D;QAED,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,IAAW,YAAY,CAAC,KAA0B;QAC9C,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC/B,CAAC;CACJ;AArGU;IADN,SAAS,EAAE;8DACS;AAKd;IADN,SAAS,EAAE;2DACO;AAKZ;IADN,SAAS,EAAE;mEACgB;AAKrB;IADN,SAAS,EAAE;iEACY;AAwF5B,aAAa,CAAC,sCAAsC,EAAE,4BAA4B,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { Constants } from \"../Engines/constants\";\r\n\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { serialize } from \"../Misc/decorators\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\n\r\n/**\r\n * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion\r\n */\r\nexport class CircleOfConfusionPostProcess extends PostProcess {\r\n /**\r\n * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.\r\n */\r\n @serialize()\r\n public lensSize = 50;\r\n /**\r\n * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)\r\n */\r\n @serialize()\r\n public fStop = 1.4;\r\n /**\r\n * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)\r\n */\r\n @serialize()\r\n public focusDistance = 2000;\r\n /**\r\n * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)\r\n */\r\n @serialize()\r\n public focalLength = 50;\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"CircleOfConfusionPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"CircleOfConfusionPostProcess\";\r\n }\r\n\r\n private _depthTexture: Nullable<RenderTargetTexture> = null;\r\n /**\r\n * Creates a new instance CircleOfConfusionPostProcess\r\n * @param name The name of the effect.\r\n * @param depthTexture The depth texture of the scene to compute the circle of confusion. This must be set in order for this to function but may be set after initialization if needed.\r\n * @param options The required width/height ratio to downsize to before computing the render pass.\r\n * @param camera The camera to apply the render pass to.\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)\r\n * @param engine The engine which the post process will be applied. (default: current engine)\r\n * @param reusable If the post process can be reused on the same frame. (default: false)\r\n * @param textureType Type of textures used when performing the post process. (default: 0)\r\n * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)\r\n */\r\n constructor(\r\n name: string,\r\n depthTexture: Nullable<RenderTargetTexture>,\r\n options: number | PostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode?: number,\r\n engine?: AbstractEngine,\r\n reusable?: boolean,\r\n textureType = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n blockCompilation = false\r\n ) {\r\n super(\r\n name,\r\n \"circleOfConfusion\",\r\n [\"cameraMinMaxZ\", \"focusDistance\", \"cocPrecalculation\"],\r\n [\"depthSampler\"],\r\n options,\r\n camera,\r\n samplingMode,\r\n engine,\r\n reusable,\r\n null,\r\n textureType,\r\n undefined,\r\n null,\r\n blockCompilation\r\n );\r\n this._depthTexture = depthTexture;\r\n this.onApplyObservable.add((effect: Effect) => {\r\n if (!this._depthTexture) {\r\n Logger.Warn(\"No depth texture set on CircleOfConfusionPostProcess\");\r\n return;\r\n }\r\n effect.setTexture(\"depthSampler\", this._depthTexture);\r\n\r\n // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html\r\n const aperture = this.lensSize / this.fStop;\r\n const cocPrecalculation = (aperture * this.focalLength) / (this.focusDistance - this.focalLength); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]\r\n\r\n effect.setFloat(\"focusDistance\", this.focusDistance);\r\n effect.setFloat(\"cocPrecalculation\", cocPrecalculation);\r\n const activeCamera = this._depthTexture.activeCamera!;\r\n effect.setFloat2(\"cameraMinMaxZ\", activeCamera.minZ, activeCamera.maxZ - activeCamera.minZ);\r\n });\r\n }\r\n\r\n protected override _gatherImports(useWebGPU: boolean, list: Promise<any>[]) {\r\n if (useWebGPU) {\r\n this._webGPUReady = true;\r\n list.push(import(\"../ShadersWGSL/circleOfConfusion.fragment\"));\r\n } else {\r\n list.push(import(\"../Shaders/circleOfConfusion.fragment\"));\r\n }\r\n\r\n super._gatherImports(useWebGPU, list);\r\n }\r\n\r\n /**\r\n * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.\r\n */\r\n public set depthTexture(value: RenderTargetTexture) {\r\n this._depthTexture = value;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CircleOfConfusionPostProcess\", CircleOfConfusionPostProcess);\r\n"]}
1
+ {"version":3,"file":"circleOfConfusionPostProcess.js","sourceRoot":"","sources":["../../../../dev/core/src/PostProcesses/circleOfConfusionPostProcess.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAItF;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,W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nimport type { PostProcessOptions } from \"./postProcess\";\r\nimport { PostProcess } from \"./postProcess\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { Constants } from \"../Engines/constants\";\r\n\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { serialize } from \"../Misc/decorators\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { ThinCircleOfConfusionPostProcessOptions } from \"./thinCircleOfConfusionPostProcess\";\r\nimport { ThinCircleOfConfusionPostProcess } from \"./thinCircleOfConfusionPostProcess\";\r\n\r\nexport type CircleOfConfusionPostProcessOptions = ThinCircleOfConfusionPostProcessOptions & PostProcessOptions;\r\n\r\n/**\r\n * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion\r\n */\r\nexport class CircleOfConfusionPostProcess extends PostProcess {\r\n /**\r\n * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diameter of the resulting aperture can be computed by lensSize/fStop.\r\n */\r\n @serialize()\r\n public get lensSize() {\r\n return this._effectWrapper.lensSize;\r\n }\r\n\r\n public set lensSize(value: number) {\r\n this._effectWrapper.lensSize = value;\r\n }\r\n\r\n /**\r\n * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)\r\n */\r\n @serialize()\r\n public get fStop() {\r\n return this._effectWrapper.fStop;\r\n }\r\n\r\n public set fStop(value: number) {\r\n this._effectWrapper.fStop = value;\r\n }\r\n\r\n /**\r\n * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)\r\n */\r\n @serialize()\r\n public get focusDistance() {\r\n return this._effectWrapper.focusDistance;\r\n }\r\n\r\n public set focusDistance(value: number) {\r\n this._effectWrapper.focusDistance = value;\r\n }\r\n\r\n /**\r\n * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)\r\n */\r\n @serialize()\r\n public get focalLength() {\r\n return this._effectWrapper.focalLength;\r\n }\r\n\r\n public set focalLength(value: number) {\r\n this._effectWrapper.focalLength = value;\r\n }\r\n\r\n /**\r\n * Gets a string identifying the name of the class\r\n * @returns \"CircleOfConfusionPostProcess\" string\r\n */\r\n public override getClassName(): string {\r\n return \"CircleOfConfusionPostProcess\";\r\n }\r\n\r\n protected override _effectWrapper: ThinCircleOfConfusionPostProcess;\r\n private _depthTexture: Nullable<RenderTargetTexture> = null;\r\n\r\n /**\r\n * Creates a new instance CircleOfConfusionPostProcess\r\n * @param name The name of the effect.\r\n * @param depthTexture The depth texture of the scene to compute the circle of confusion. This must be set in order for this to function but may be set after initialization if needed.\r\n * @param options The required width/height ratio to downsize to before computing the render pass.\r\n * @param camera The camera to apply the render pass to.\r\n * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)\r\n * @param engine The engine which the post process will be applied. (default: current engine)\r\n * @param reusable If the post process can be reused on the same frame. (default: false)\r\n * @param textureType Type of textures used when performing the post process. (default: 0)\r\n * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)\r\n */\r\n constructor(\r\n name: string,\r\n depthTexture: Nullable<RenderTargetTexture>,\r\n options: number | CircleOfConfusionPostProcessOptions,\r\n camera: Nullable<Camera>,\r\n samplingMode?: number,\r\n engine?: AbstractEngine,\r\n reusable?: boolean,\r\n textureType = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n blockCompilation = false\r\n ) {\r\n const localOptions = {\r\n uniforms: ThinCircleOfConfusionPostProcess.Uniforms,\r\n samplers: ThinCircleOfConfusionPostProcess.Samplers,\r\n defines: typeof options === \"object\" && options.depthNotNormalized ? ThinCircleOfConfusionPostProcess.DefinesDepthNotNormalized : undefined,\r\n size: typeof options === \"number\" ? options : undefined,\r\n camera,\r\n samplingMode,\r\n engine,\r\n reusable,\r\n textureType,\r\n blockCompilation,\r\n ...(options as PostProcessOptions),\r\n };\r\n\r\n super(name, ThinCircleOfConfusionPostProcess.FragmentUrl, {\r\n effectWrapper: typeof options === \"number\" || !options.effectWrapper ? new ThinCircleOfConfusionPostProcess(name, engine, localOptions) : undefined,\r\n ...localOptions,\r\n });\r\n\r\n this._depthTexture = depthTexture;\r\n this.onApplyObservable.add((effect: Effect) => {\r\n if (!this._depthTexture) {\r\n Logger.Warn(\"No depth texture set on CircleOfConfusionPostProcess\");\r\n return;\r\n }\r\n\r\n effect.setTexture(\"depthSampler\", this._depthTexture);\r\n\r\n this._effectWrapper.camera = this._depthTexture.activeCamera!;\r\n });\r\n }\r\n\r\n /**\r\n * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.\r\n */\r\n public set depthTexture(value: RenderTargetTexture) {\r\n this._depthTexture = value;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CircleOfConfusionPostProcess\", CircleOfConfusionPostProcess);\r\n"]}