@onerjs/core 8.41.5 → 8.41.7

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 (579) hide show
  1. package/Animations/animation.d.ts +6 -2
  2. package/Animations/animation.js +28 -4
  3. package/Animations/animation.js.map +1 -1
  4. package/Animations/animationGroup.d.ts +2 -1
  5. package/Animations/animationGroup.js +3 -2
  6. package/Animations/animationGroup.js.map +1 -1
  7. package/Animations/animatorAvatar.d.ts +161 -0
  8. package/Animations/animatorAvatar.js +573 -0
  9. package/Animations/animatorAvatar.js.map +1 -0
  10. package/Animations/index.d.ts +1 -0
  11. package/Animations/index.js +1 -0
  12. package/Animations/index.js.map +1 -1
  13. package/AudioV2/webAudio/webAudioSoundSource.d.ts +2 -2
  14. package/AudioV2/webAudio/webAudioSoundSource.js +12 -2
  15. package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -1
  16. package/Bones/index.d.ts +1 -0
  17. package/Bones/index.js +1 -0
  18. package/Bones/index.js.map +1 -1
  19. package/Bones/skeleton.d.ts +13 -0
  20. package/Bones/skeleton.functions.d.ts +26 -0
  21. package/Bones/skeleton.functions.js +91 -0
  22. package/Bones/skeleton.functions.js.map +1 -0
  23. package/Bones/skeleton.js +26 -0
  24. package/Bones/skeleton.js.map +1 -1
  25. package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +16 -0
  26. package/Cameras/Inputs/geospatialCameraPointersInput.js +19 -3
  27. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  28. package/Cameras/Limits/geospatialLimits.d.ts +0 -6
  29. package/Cameras/Limits/geospatialLimits.js +0 -6
  30. package/Cameras/Limits/geospatialLimits.js.map +1 -1
  31. package/Cameras/geospatialCamera.d.ts +5 -0
  32. package/Cameras/geospatialCamera.js +54 -25
  33. package/Cameras/geospatialCamera.js.map +1 -1
  34. package/Cameras/geospatialCameraMovement.d.ts +8 -1
  35. package/Cameras/geospatialCameraMovement.js +29 -8
  36. package/Cameras/geospatialCameraMovement.js.map +1 -1
  37. package/Collisions/gpuPicker.d.ts +11 -0
  38. package/Collisions/gpuPicker.js +148 -19
  39. package/Collisions/gpuPicker.js.map +1 -1
  40. package/Debug/skeletonViewer.d.ts +4 -8
  41. package/Debug/skeletonViewer.js +13 -22
  42. package/Debug/skeletonViewer.js.map +1 -1
  43. package/Engines/Extensions/engine.multiview.d.ts +2 -0
  44. package/Engines/Extensions/engine.multiview.js +7 -3
  45. package/Engines/Extensions/engine.multiview.js.map +1 -1
  46. package/Engines/abstractEngine.d.ts +2 -2
  47. package/Engines/abstractEngine.js +2 -2
  48. package/Engines/abstractEngine.js.map +1 -1
  49. package/Engines/constants.d.ts +4 -0
  50. package/Engines/constants.js +4 -0
  51. package/Engines/constants.js.map +1 -1
  52. package/Engines/webgpuEngine.d.ts +1 -4
  53. package/Engines/webgpuEngine.js +8 -6
  54. package/Engines/webgpuEngine.js.map +1 -1
  55. package/FrameGraph/frameGraphContext.js +1 -1
  56. package/FrameGraph/frameGraphContext.js.map +1 -1
  57. package/FrameGraph/frameGraphRenderContext.js +2 -2
  58. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  59. package/Instrumentation/engineInstrumentation.js +2 -1
  60. package/Instrumentation/engineInstrumentation.js.map +1 -1
  61. package/Layers/effectLayer.js +1 -3
  62. package/Layers/effectLayer.js.map +1 -1
  63. package/Lights/Shadows/cascadedShadowGenerator.js +2 -2
  64. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  65. package/Lights/Shadows/shadowGenerator.js +3 -4
  66. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  67. package/Lights/lightingVolume.js +1 -1
  68. package/Lights/lightingVolume.js.map +1 -1
  69. package/Materials/Background/backgroundMaterial.js +37 -2
  70. package/Materials/Background/backgroundMaterial.js.map +1 -1
  71. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.d.ts +109 -0
  72. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js +210 -0
  73. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js.map +1 -0
  74. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +1 -0
  75. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +71 -15
  76. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  77. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.d.ts +86 -0
  78. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js +161 -0
  79. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js.map +1 -0
  80. package/Materials/GreasedLine/greasedLinePluginMaterial.js +0 -6
  81. package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
  82. package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js +0 -1
  83. package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js.map +1 -1
  84. package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js +0 -1
  85. package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js.map +1 -1
  86. package/Materials/Node/Blocks/Dual/clipPlanesBlock.d.ts +14 -0
  87. package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +14 -0
  88. package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
  89. package/Materials/Node/Blocks/Dual/currentScreenBlock.d.ts +20 -1
  90. package/Materials/Node/Blocks/Dual/currentScreenBlock.js +20 -1
  91. package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
  92. package/Materials/Node/Blocks/Dual/depthSourceBlock.d.ts +13 -0
  93. package/Materials/Node/Blocks/Dual/depthSourceBlock.js +13 -0
  94. package/Materials/Node/Blocks/Dual/depthSourceBlock.js.map +1 -1
  95. package/Materials/Node/Blocks/Dual/fogBlock.d.ts +21 -0
  96. package/Materials/Node/Blocks/Dual/fogBlock.js +21 -0
  97. package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
  98. package/Materials/Node/Blocks/Dual/imageSourceBlock.d.ts +21 -0
  99. package/Materials/Node/Blocks/Dual/imageSourceBlock.js +21 -0
  100. package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
  101. package/Materials/Node/Blocks/Dual/lightBlock.d.ts +38 -0
  102. package/Materials/Node/Blocks/Dual/lightBlock.js +38 -0
  103. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  104. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.d.ts +29 -0
  105. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +29 -0
  106. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
  107. package/Materials/Node/Blocks/Dual/reflectionTextureBlock.d.ts +5 -0
  108. package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js +5 -0
  109. package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js.map +1 -1
  110. package/Materials/Node/Blocks/Dual/sceneDepthBlock.d.ts +16 -0
  111. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +16 -0
  112. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
  113. package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.d.ts +16 -0
  114. package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js +16 -0
  115. package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js.map +1 -1
  116. package/Materials/Node/Blocks/Dual/textureBlock.d.ts +34 -0
  117. package/Materials/Node/Blocks/Dual/textureBlock.js +34 -0
  118. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  119. package/Materials/Node/Blocks/Fragment/TBNBlock.d.ts +17 -0
  120. package/Materials/Node/Blocks/Fragment/TBNBlock.js +17 -2
  121. package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
  122. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.d.ts +7 -0
  123. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.js +7 -0
  124. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.js.map +1 -1
  125. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.d.ts +21 -0
  126. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +21 -0
  127. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  128. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.d.ts +10 -0
  129. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +10 -0
  130. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
  131. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.d.ts +28 -0
  132. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +28 -0
  133. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
  134. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.d.ts +30 -0
  135. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +30 -1
  136. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
  137. package/Materials/Node/Blocks/Fragment/screenSizeBlock.d.ts +4 -0
  138. package/Materials/Node/Blocks/Fragment/screenSizeBlock.js +4 -0
  139. package/Materials/Node/Blocks/Fragment/screenSizeBlock.js.map +1 -1
  140. package/Materials/Node/Blocks/Fragment/screenSpaceBlock.d.ts +5 -0
  141. package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js +5 -0
  142. package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js.map +1 -1
  143. package/Materials/Node/Blocks/Fragment/twirlBlock.d.ts +3 -0
  144. package/Materials/Node/Blocks/Fragment/twirlBlock.js +3 -0
  145. package/Materials/Node/Blocks/Fragment/twirlBlock.js.map +1 -1
  146. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.d.ts +6 -0
  147. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +6 -0
  148. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
  149. package/Materials/Node/Blocks/Input/inputBlock.d.ts +16 -0
  150. package/Materials/Node/Blocks/Input/inputBlock.js +16 -1
  151. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  152. package/Materials/Node/Blocks/Input/prePassTextureBlock.d.ts +5 -0
  153. package/Materials/Node/Blocks/Input/prePassTextureBlock.js +5 -0
  154. package/Materials/Node/Blocks/Input/prePassTextureBlock.js.map +1 -1
  155. package/Materials/Node/Blocks/PBR/anisotropyBlock.d.ts +10 -0
  156. package/Materials/Node/Blocks/PBR/anisotropyBlock.js +10 -1
  157. package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
  158. package/Materials/Node/Blocks/PBR/clearCoatBlock.d.ts +23 -0
  159. package/Materials/Node/Blocks/PBR/clearCoatBlock.js +23 -1
  160. package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
  161. package/Materials/Node/Blocks/PBR/iridescenceBlock.d.ts +17 -0
  162. package/Materials/Node/Blocks/PBR/iridescenceBlock.js +17 -0
  163. package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
  164. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.d.ts +41 -0
  165. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +41 -0
  166. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  167. package/Materials/Node/Blocks/PBR/reflectionBlock.d.ts +21 -0
  168. package/Materials/Node/Blocks/PBR/reflectionBlock.js +21 -0
  169. package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
  170. package/Materials/Node/Blocks/PBR/refractionBlock.d.ts +29 -0
  171. package/Materials/Node/Blocks/PBR/refractionBlock.js +29 -0
  172. package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
  173. package/Materials/Node/Blocks/PBR/sheenBlock.d.ts +14 -0
  174. package/Materials/Node/Blocks/PBR/sheenBlock.js +14 -0
  175. package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
  176. package/Materials/Node/Blocks/PBR/subSurfaceBlock.d.ts +7 -0
  177. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +7 -0
  178. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
  179. package/Materials/Node/Blocks/Particle/particleTextureBlock.d.ts +23 -0
  180. package/Materials/Node/Blocks/Particle/particleTextureBlock.js +23 -0
  181. package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
  182. package/Materials/Node/Blocks/Teleport/teleportInBlock.d.ts +6 -0
  183. package/Materials/Node/Blocks/Teleport/teleportInBlock.js +6 -0
  184. package/Materials/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
  185. package/Materials/Node/Blocks/Teleport/teleportOutBlock.d.ts +17 -0
  186. package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +17 -0
  187. package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
  188. package/Materials/Node/Blocks/Vertex/bonesBlock.d.ts +22 -0
  189. package/Materials/Node/Blocks/Vertex/bonesBlock.js +22 -0
  190. package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
  191. package/Materials/Node/Blocks/Vertex/instancesBlock.d.ts +13 -0
  192. package/Materials/Node/Blocks/Vertex/instancesBlock.js +13 -0
  193. package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
  194. package/Materials/Node/Blocks/Vertex/lightInformationBlock.d.ts +20 -0
  195. package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +20 -0
  196. package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
  197. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.d.ts +27 -0
  198. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +27 -0
  199. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  200. package/Materials/Node/Blocks/clampBlock.d.ts +10 -0
  201. package/Materials/Node/Blocks/clampBlock.js +10 -0
  202. package/Materials/Node/Blocks/clampBlock.js.map +1 -1
  203. package/Materials/Node/Blocks/cloudBlock.d.ts +10 -0
  204. package/Materials/Node/Blocks/cloudBlock.js +10 -0
  205. package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
  206. package/Materials/Node/Blocks/colorMergerBlock.d.ts +10 -0
  207. package/Materials/Node/Blocks/colorMergerBlock.js +10 -0
  208. package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
  209. package/Materials/Node/Blocks/conditionalBlock.d.ts +14 -0
  210. package/Materials/Node/Blocks/conditionalBlock.js +14 -0
  211. package/Materials/Node/Blocks/conditionalBlock.js.map +1 -1
  212. package/Materials/Node/Blocks/curveBlock.d.ts +10 -0
  213. package/Materials/Node/Blocks/curveBlock.js +10 -0
  214. package/Materials/Node/Blocks/curveBlock.js.map +1 -1
  215. package/Materials/Node/Blocks/customBlock.d.ts +10 -0
  216. package/Materials/Node/Blocks/customBlock.js +10 -0
  217. package/Materials/Node/Blocks/customBlock.js.map +1 -1
  218. package/Materials/Node/Blocks/debugBlock.d.ts +10 -0
  219. package/Materials/Node/Blocks/debugBlock.js +10 -0
  220. package/Materials/Node/Blocks/debugBlock.js.map +1 -1
  221. package/Materials/Node/Blocks/fresnelBlock.d.ts +4 -0
  222. package/Materials/Node/Blocks/fresnelBlock.js +4 -0
  223. package/Materials/Node/Blocks/fresnelBlock.js.map +1 -1
  224. package/Materials/Node/Blocks/gradientBlock.d.ts +10 -0
  225. package/Materials/Node/Blocks/gradientBlock.js +10 -0
  226. package/Materials/Node/Blocks/gradientBlock.js.map +1 -1
  227. package/Materials/Node/Blocks/loopBlock.d.ts +10 -0
  228. package/Materials/Node/Blocks/loopBlock.js +10 -0
  229. package/Materials/Node/Blocks/loopBlock.js.map +1 -1
  230. package/Materials/Node/Blocks/matrixBuilderBlock.d.ts +1 -0
  231. package/Materials/Node/Blocks/matrixBuilderBlock.js +1 -0
  232. package/Materials/Node/Blocks/matrixBuilderBlock.js.map +1 -1
  233. package/Materials/Node/Blocks/meshAttributeExistsBlock.d.ts +10 -0
  234. package/Materials/Node/Blocks/meshAttributeExistsBlock.js +10 -0
  235. package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
  236. package/Materials/Node/Blocks/pannerBlock.d.ts +5 -0
  237. package/Materials/Node/Blocks/pannerBlock.js +5 -0
  238. package/Materials/Node/Blocks/pannerBlock.js.map +1 -1
  239. package/Materials/Node/Blocks/remapBlock.d.ts +10 -0
  240. package/Materials/Node/Blocks/remapBlock.js +10 -0
  241. package/Materials/Node/Blocks/remapBlock.js.map +1 -1
  242. package/Materials/Node/Blocks/rotate2dBlock.d.ts +1 -0
  243. package/Materials/Node/Blocks/rotate2dBlock.js +1 -0
  244. package/Materials/Node/Blocks/rotate2dBlock.js.map +1 -1
  245. package/Materials/Node/Blocks/transformBlock.d.ts +10 -0
  246. package/Materials/Node/Blocks/transformBlock.js +10 -0
  247. package/Materials/Node/Blocks/transformBlock.js.map +1 -1
  248. package/Materials/Node/Blocks/triPlanarBlock.d.ts +22 -0
  249. package/Materials/Node/Blocks/triPlanarBlock.js +22 -0
  250. package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
  251. package/Materials/Node/Blocks/trigonometryBlock.d.ts +10 -0
  252. package/Materials/Node/Blocks/trigonometryBlock.js +10 -0
  253. package/Materials/Node/Blocks/trigonometryBlock.js.map +1 -1
  254. package/Materials/Node/Blocks/vectorMergerBlock.d.ts +10 -0
  255. package/Materials/Node/Blocks/vectorMergerBlock.js +10 -0
  256. package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
  257. package/Materials/Node/Blocks/viewDirectionBlock.d.ts +5 -0
  258. package/Materials/Node/Blocks/viewDirectionBlock.js +5 -0
  259. package/Materials/Node/Blocks/viewDirectionBlock.js.map +1 -1
  260. package/Materials/Node/Blocks/waveBlock.d.ts +10 -0
  261. package/Materials/Node/Blocks/waveBlock.js +10 -0
  262. package/Materials/Node/Blocks/waveBlock.js.map +1 -1
  263. package/Materials/Node/Blocks/worleyNoise3DBlock.d.ts +1 -0
  264. package/Materials/Node/Blocks/worleyNoise3DBlock.js +1 -0
  265. package/Materials/Node/Blocks/worleyNoise3DBlock.js.map +1 -1
  266. package/Materials/Node/nodeMaterial.d.ts +13 -0
  267. package/Materials/Node/nodeMaterial.js +14 -2
  268. package/Materials/Node/nodeMaterial.js.map +1 -1
  269. package/Materials/Node/nodeMaterialBlock.d.ts +0 -3
  270. package/Materials/Node/nodeMaterialBlock.js +1 -6
  271. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  272. package/Materials/Node/nodeMaterialBlockConnectionPoint.js +1 -2
  273. package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
  274. package/Materials/Textures/Procedurals/proceduralTexture.js +1 -1
  275. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  276. package/Materials/Textures/mirrorTexture.js +1 -1
  277. package/Materials/Textures/mirrorTexture.js.map +1 -1
  278. package/Materials/index.d.ts +2 -0
  279. package/Materials/index.js +2 -0
  280. package/Materials/index.js.map +1 -1
  281. package/Maths/math.constants.d.ts +2 -1
  282. package/Maths/math.constants.js +3 -2
  283. package/Maths/math.constants.js.map +1 -1
  284. package/Meshes/Builders/capsuleBuilder.js +0 -3
  285. package/Meshes/Builders/capsuleBuilder.js.map +1 -1
  286. package/Meshes/Builders/cylinderBuilder.d.ts +1 -1
  287. package/Meshes/Builders/cylinderBuilder.js +1 -2
  288. package/Meshes/Builders/cylinderBuilder.js.map +1 -1
  289. package/Meshes/Builders/decalBuilder.js +2 -0
  290. package/Meshes/Builders/decalBuilder.js.map +1 -1
  291. package/Meshes/Builders/discBuilder.js +0 -1
  292. package/Meshes/Builders/discBuilder.js.map +1 -1
  293. package/Meshes/Builders/groundBuilder.d.ts +50 -54
  294. package/Meshes/Builders/groundBuilder.js +50 -54
  295. package/Meshes/Builders/groundBuilder.js.map +1 -1
  296. package/Meshes/Builders/tiledBoxBuilder.d.ts +0 -26
  297. package/Meshes/Builders/tiledBoxBuilder.js +0 -26
  298. package/Meshes/Builders/tiledBoxBuilder.js.map +1 -1
  299. package/Meshes/Builders/tiledPlaneBuilder.d.ts +0 -25
  300. package/Meshes/Builders/tiledPlaneBuilder.js +0 -25
  301. package/Meshes/Builders/tiledPlaneBuilder.js.map +1 -1
  302. package/Meshes/Builders/torusBuilder.d.ts +0 -13
  303. package/Meshes/Builders/torusBuilder.js +0 -13
  304. package/Meshes/Builders/torusBuilder.js.map +1 -1
  305. package/Meshes/Builders/torusKnotBuilder.d.ts +0 -19
  306. package/Meshes/Builders/torusKnotBuilder.js +0 -19
  307. package/Meshes/Builders/torusKnotBuilder.js.map +1 -1
  308. package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
  309. package/Meshes/Compression/dracoDecoder.js.map +1 -1
  310. package/Meshes/Compression/dracoDecoder.types.d.ts +11 -0
  311. package/Meshes/Compression/dracoDecoder.types.js.map +1 -1
  312. package/Meshes/Compression/dracoEncoder.js.map +1 -1
  313. package/Meshes/Compression/meshoptCompression.js +0 -2
  314. package/Meshes/Compression/meshoptCompression.js.map +1 -1
  315. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +17 -1
  316. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  317. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +0 -8
  318. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  319. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.d.ts +1 -0
  320. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js +1 -0
  321. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js.map +1 -1
  322. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +1 -0
  323. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +1 -0
  324. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
  325. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.d.ts +1 -0
  326. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +1 -0
  327. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
  328. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.d.ts +1 -0
  329. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +1 -0
  330. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
  331. package/Meshes/Node/Blocks/Matrices/scalingBlock.d.ts +1 -0
  332. package/Meshes/Node/Blocks/Matrices/scalingBlock.js +1 -0
  333. package/Meshes/Node/Blocks/Matrices/scalingBlock.js.map +1 -1
  334. package/Meshes/Node/Blocks/Matrices/translationBlock.d.ts +1 -0
  335. package/Meshes/Node/Blocks/Matrices/translationBlock.js +1 -0
  336. package/Meshes/Node/Blocks/Matrices/translationBlock.js.map +1 -1
  337. package/Meshes/Node/Blocks/Set/aggregatorBlock.d.ts +1 -0
  338. package/Meshes/Node/Blocks/Set/aggregatorBlock.js +1 -0
  339. package/Meshes/Node/Blocks/Set/aggregatorBlock.js.map +1 -1
  340. package/Meshes/Node/Blocks/Set/latticeBlock.d.ts +1 -0
  341. package/Meshes/Node/Blocks/Set/latticeBlock.js +1 -0
  342. package/Meshes/Node/Blocks/Set/latticeBlock.js.map +1 -1
  343. package/Meshes/Node/Blocks/Set/setColorsBlock.d.ts +1 -0
  344. package/Meshes/Node/Blocks/Set/setColorsBlock.js +1 -0
  345. package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
  346. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.d.ts +1 -0
  347. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js +1 -0
  348. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js.map +1 -1
  349. package/Meshes/Node/Blocks/Set/setNormalsBlock.d.ts +1 -0
  350. package/Meshes/Node/Blocks/Set/setNormalsBlock.js +1 -0
  351. package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -1
  352. package/Meshes/Node/Blocks/Set/setPositionsBlock.d.ts +1 -0
  353. package/Meshes/Node/Blocks/Set/setPositionsBlock.js +1 -0
  354. package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
  355. package/Meshes/Node/Blocks/Set/setTangentsBlock.d.ts +1 -0
  356. package/Meshes/Node/Blocks/Set/setTangentsBlock.js +1 -0
  357. package/Meshes/Node/Blocks/Set/setTangentsBlock.js.map +1 -1
  358. package/Meshes/Node/Blocks/Set/setUVsBlock.d.ts +1 -0
  359. package/Meshes/Node/Blocks/Set/setUVsBlock.js +1 -0
  360. package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -1
  361. package/Meshes/Node/Blocks/Sources/boxBlock.d.ts +2 -0
  362. package/Meshes/Node/Blocks/Sources/boxBlock.js +2 -0
  363. package/Meshes/Node/Blocks/Sources/boxBlock.js.map +1 -1
  364. package/Meshes/Node/Blocks/Sources/capsuleBlock.d.ts +2 -0
  365. package/Meshes/Node/Blocks/Sources/capsuleBlock.js +2 -0
  366. package/Meshes/Node/Blocks/Sources/capsuleBlock.js.map +1 -1
  367. package/Meshes/Node/Blocks/Sources/cylinderBlock.d.ts +2 -0
  368. package/Meshes/Node/Blocks/Sources/cylinderBlock.js +2 -0
  369. package/Meshes/Node/Blocks/Sources/cylinderBlock.js.map +1 -1
  370. package/Meshes/Node/Blocks/Sources/discBlock.d.ts +2 -0
  371. package/Meshes/Node/Blocks/Sources/discBlock.js +2 -0
  372. package/Meshes/Node/Blocks/Sources/discBlock.js.map +1 -1
  373. package/Meshes/Node/Blocks/Sources/gridBlock.d.ts +2 -0
  374. package/Meshes/Node/Blocks/Sources/gridBlock.js +2 -0
  375. package/Meshes/Node/Blocks/Sources/gridBlock.js.map +1 -1
  376. package/Meshes/Node/Blocks/Sources/icoSphereBlock.d.ts +2 -0
  377. package/Meshes/Node/Blocks/Sources/icoSphereBlock.js +2 -0
  378. package/Meshes/Node/Blocks/Sources/icoSphereBlock.js.map +1 -1
  379. package/Meshes/Node/Blocks/Sources/meshBlock.d.ts +1 -0
  380. package/Meshes/Node/Blocks/Sources/meshBlock.js +1 -0
  381. package/Meshes/Node/Blocks/Sources/meshBlock.js.map +1 -1
  382. package/Meshes/Node/Blocks/Sources/planeBlock.d.ts +2 -0
  383. package/Meshes/Node/Blocks/Sources/planeBlock.js +2 -0
  384. package/Meshes/Node/Blocks/Sources/planeBlock.js.map +1 -1
  385. package/Meshes/Node/Blocks/Sources/pointListBlock.d.ts +2 -1
  386. package/Meshes/Node/Blocks/Sources/pointListBlock.js +2 -1
  387. package/Meshes/Node/Blocks/Sources/pointListBlock.js.map +1 -1
  388. package/Meshes/Node/Blocks/Sources/sphereBlock.d.ts +2 -0
  389. package/Meshes/Node/Blocks/Sources/sphereBlock.js +2 -0
  390. package/Meshes/Node/Blocks/Sources/sphereBlock.js.map +1 -1
  391. package/Meshes/Node/Blocks/Sources/torusBlock.d.ts +2 -0
  392. package/Meshes/Node/Blocks/Sources/torusBlock.js +2 -0
  393. package/Meshes/Node/Blocks/Sources/torusBlock.js.map +1 -1
  394. package/Meshes/Node/Blocks/Teleport/teleportInBlock.d.ts +1 -0
  395. package/Meshes/Node/Blocks/Teleport/teleportInBlock.js +1 -0
  396. package/Meshes/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
  397. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.d.ts +3 -0
  398. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js +3 -0
  399. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
  400. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.d.ts +1 -0
  401. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js +1 -1
  402. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
  403. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.d.ts +1 -0
  404. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js +1 -0
  405. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js.map +1 -1
  406. package/Meshes/Node/Blocks/booleanGeometryBlock.d.ts +1 -0
  407. package/Meshes/Node/Blocks/booleanGeometryBlock.js +1 -1
  408. package/Meshes/Node/Blocks/booleanGeometryBlock.js.map +1 -1
  409. package/Meshes/Node/Blocks/cleanGeometryBlock.d.ts +1 -0
  410. package/Meshes/Node/Blocks/cleanGeometryBlock.js +1 -0
  411. package/Meshes/Node/Blocks/cleanGeometryBlock.js.map +1 -1
  412. package/Meshes/Node/Blocks/conditionBlock.d.ts +2 -0
  413. package/Meshes/Node/Blocks/conditionBlock.js +2 -0
  414. package/Meshes/Node/Blocks/conditionBlock.js.map +1 -1
  415. package/Meshes/Node/Blocks/geometryClampBlock.d.ts +1 -0
  416. package/Meshes/Node/Blocks/geometryClampBlock.js +1 -0
  417. package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -1
  418. package/Meshes/Node/Blocks/geometryCollectionBlock.d.ts +1 -0
  419. package/Meshes/Node/Blocks/geometryCollectionBlock.js +1 -0
  420. package/Meshes/Node/Blocks/geometryCollectionBlock.js.map +1 -1
  421. package/Meshes/Node/Blocks/geometryCurveBlock.d.ts +2 -0
  422. package/Meshes/Node/Blocks/geometryCurveBlock.js +2 -0
  423. package/Meshes/Node/Blocks/geometryCurveBlock.js.map +1 -1
  424. package/Meshes/Node/Blocks/geometryEaseBlock.d.ts +2 -0
  425. package/Meshes/Node/Blocks/geometryEaseBlock.js +2 -0
  426. package/Meshes/Node/Blocks/geometryEaseBlock.js.map +1 -1
  427. package/Meshes/Node/Blocks/geometryInputBlock.d.ts +3 -0
  428. package/Meshes/Node/Blocks/geometryInputBlock.js +3 -0
  429. package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
  430. package/Meshes/Node/Blocks/geometryOptimizeBlock.d.ts +1 -0
  431. package/Meshes/Node/Blocks/geometryOptimizeBlock.js +1 -0
  432. package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -1
  433. package/Meshes/Node/Blocks/geometryTransformBlock.d.ts +1 -0
  434. package/Meshes/Node/Blocks/geometryTransformBlock.js +1 -0
  435. package/Meshes/Node/Blocks/geometryTransformBlock.js.map +1 -1
  436. package/Meshes/Node/Blocks/geometryTrigonometryBlock.d.ts +2 -0
  437. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +2 -0
  438. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
  439. package/Meshes/Node/Blocks/mappingBlock.d.ts +1 -0
  440. package/Meshes/Node/Blocks/mappingBlock.js +1 -0
  441. package/Meshes/Node/Blocks/mappingBlock.js.map +1 -1
  442. package/Meshes/Node/Blocks/mathBlock.d.ts +1 -0
  443. package/Meshes/Node/Blocks/mathBlock.js +1 -0
  444. package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
  445. package/Meshes/Node/Blocks/mergeGeometryBlock.d.ts +1 -0
  446. package/Meshes/Node/Blocks/mergeGeometryBlock.js +1 -0
  447. package/Meshes/Node/Blocks/mergeGeometryBlock.js.map +1 -1
  448. package/Meshes/Node/Blocks/randomBlock.d.ts +2 -0
  449. package/Meshes/Node/Blocks/randomBlock.js +2 -0
  450. package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
  451. package/Meshes/Node/Blocks/subdivideBlock.d.ts +1 -0
  452. package/Meshes/Node/Blocks/subdivideBlock.js +1 -0
  453. package/Meshes/Node/Blocks/subdivideBlock.js.map +1 -1
  454. package/Meshes/Node/Interfaces/nodeGeometryTextureData.d.ts +3 -0
  455. package/Meshes/Node/Interfaces/nodeGeometryTextureData.js.map +1 -1
  456. package/Meshes/Node/nodeGeometry.js +0 -2
  457. package/Meshes/Node/nodeGeometry.js.map +1 -1
  458. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +0 -1
  459. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
  460. package/Meshes/Node/nodeGeometryBuildState.js +0 -1
  461. package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
  462. package/Meshes/WebGL/webGLDataBuffer.d.ts +2 -0
  463. package/Meshes/WebGL/webGLDataBuffer.js +2 -0
  464. package/Meshes/WebGL/webGLDataBuffer.js.map +1 -1
  465. package/Meshes/WebGPU/webgpuDataBuffer.d.ts +4 -0
  466. package/Meshes/WebGPU/webgpuDataBuffer.js +4 -0
  467. package/Meshes/WebGPU/webgpuDataBuffer.js.map +1 -1
  468. package/Meshes/abstractMesh.d.ts +1 -0
  469. package/Meshes/abstractMesh.decalMap.d.ts +1 -0
  470. package/Meshes/abstractMesh.decalMap.js.map +1 -1
  471. package/Meshes/abstractMesh.js +1 -6
  472. package/Meshes/abstractMesh.js.map +1 -1
  473. package/Meshes/csg.js +0 -6
  474. package/Meshes/csg.js.map +1 -1
  475. package/Meshes/csg2.js +1 -2
  476. package/Meshes/csg2.js.map +1 -1
  477. package/Meshes/geodesicMesh.d.ts +26 -0
  478. package/Meshes/geodesicMesh.js +18 -3
  479. package/Meshes/geodesicMesh.js.map +1 -1
  480. package/Meshes/groundMesh.d.ts +1 -0
  481. package/Meshes/groundMesh.js +1 -0
  482. package/Meshes/groundMesh.js.map +1 -1
  483. package/Meshes/index.js +0 -2
  484. package/Meshes/index.js.map +1 -1
  485. package/Meshes/instancedMesh.d.ts +18 -3
  486. package/Meshes/instancedMesh.js +11 -3
  487. package/Meshes/instancedMesh.js.map +1 -1
  488. package/Meshes/mesh.d.ts +291 -204
  489. package/Meshes/mesh.js +290 -213
  490. package/Meshes/mesh.js.map +1 -1
  491. package/Meshes/mesh.vertexData.d.ts +15 -19
  492. package/Meshes/mesh.vertexData.js +15 -19
  493. package/Meshes/mesh.vertexData.js.map +1 -1
  494. package/Meshes/meshSimplification.d.ts +0 -1
  495. package/Meshes/meshSimplification.js +6 -1
  496. package/Meshes/meshSimplification.js.map +1 -1
  497. package/Meshes/meshSimplificationSceneComponent.d.ts +2 -0
  498. package/Meshes/meshSimplificationSceneComponent.js.map +1 -1
  499. package/Meshes/meshUVSpaceRenderer.d.ts +1 -0
  500. package/Meshes/meshUVSpaceRenderer.js.map +1 -1
  501. package/Meshes/polygonMesh.js +4 -0
  502. package/Meshes/polygonMesh.js.map +1 -1
  503. package/Meshes/subMesh.project.d.ts +1 -0
  504. package/Meshes/subMesh.project.js.map +1 -1
  505. package/Meshes/thinInstanceMesh.d.ts +5 -0
  506. package/Meshes/thinInstanceMesh.js.map +1 -1
  507. package/Meshes/transformNode.d.ts +1 -1
  508. package/Meshes/transformNode.js +1 -1
  509. package/Meshes/transformNode.js.map +1 -1
  510. package/Misc/dataStorage.d.ts +13 -0
  511. package/Misc/dataStorage.js +25 -0
  512. package/Misc/dataStorage.js.map +1 -1
  513. package/Morph/morphTarget.d.ts +9 -5
  514. package/Morph/morphTarget.js +15 -7
  515. package/Morph/morphTarget.js.map +1 -1
  516. package/Morph/morphTargetManager.d.ts +3 -1
  517. package/Morph/morphTargetManager.js +5 -2
  518. package/Morph/morphTargetManager.js.map +1 -1
  519. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +1 -1
  520. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
  521. package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +1 -1
  522. package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -1
  523. package/Particles/Node/Blocks/Emitters/customShapeBlock.js +1 -1
  524. package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
  525. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +1 -1
  526. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
  527. package/Particles/Node/Blocks/Emitters/emitters.functions.js +3 -3
  528. package/Particles/Node/Blocks/Emitters/emitters.functions.js.map +1 -1
  529. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +1 -1
  530. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
  531. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +1 -1
  532. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
  533. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +1 -1
  534. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
  535. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +2 -2
  536. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
  537. package/Particles/Node/Blocks/Update/updateNoiseBlock.js +7 -7
  538. package/Particles/Node/Blocks/Update/updateNoiseBlock.js.map +1 -1
  539. package/Particles/Node/Blocks/particleLocalVariableBlock.js +2 -2
  540. package/Particles/Node/Blocks/particleLocalVariableBlock.js.map +1 -1
  541. package/Particles/Node/nodeParticleBuildState.js +7 -7
  542. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  543. package/Particles/Node/nodeParticleSystemSet.helper.js +9 -4
  544. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  545. package/Particles/particle.d.ts +73 -61
  546. package/Particles/particle.js +106 -91
  547. package/Particles/particle.js.map +1 -1
  548. package/Particles/particleSystem.js +5 -5
  549. package/Particles/particleSystem.js.map +1 -1
  550. package/Particles/thinParticleSystem.function.js +83 -83
  551. package/Particles/thinParticleSystem.function.js.map +1 -1
  552. package/Particles/thinParticleSystem.js +8 -8
  553. package/Particles/thinParticleSystem.js.map +1 -1
  554. package/Physics/v2/Plugins/havokPlugin.d.ts +89 -3
  555. package/Physics/v2/Plugins/havokPlugin.js +388 -53
  556. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  557. package/Probes/reflectionProbe.js +10 -7
  558. package/Probes/reflectionProbe.js.map +1 -1
  559. package/Rendering/depthRenderer.js +1 -1
  560. package/Rendering/depthRenderer.js.map +1 -1
  561. package/Rendering/objectRenderer.d.ts +3 -1
  562. package/Rendering/objectRenderer.js +28 -8
  563. package/Rendering/objectRenderer.js.map +1 -1
  564. package/Rendering/reflectiveShadowMap.js +1 -1
  565. package/Rendering/reflectiveShadowMap.js.map +1 -1
  566. package/Rendering/thinDepthPeelingRenderer.js +8 -0
  567. package/Rendering/thinDepthPeelingRenderer.js.map +1 -1
  568. package/Shaders/gaussianSplatting.fragment.js +8 -2
  569. package/Shaders/gaussianSplatting.fragment.js.map +1 -1
  570. package/Shaders/gaussianSplatting.vertex.js +8 -2
  571. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  572. package/ShadersWGSL/gaussianSplatting.fragment.js +7 -1
  573. package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -1
  574. package/ShadersWGSL/gaussianSplatting.vertex.js +8 -2
  575. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  576. package/package.json +1 -1
  577. package/scene.d.ts +22 -4
  578. package/scene.js +33 -20
  579. package/scene.js.map +1 -1
@@ -44,8 +44,15 @@ export declare class AmbientOcclusionBlock extends NodeMaterialBlock {
44
44
  * Gets the occlusion output
45
45
  */
46
46
  get occlusion(): NodeMaterialConnectionPoint;
47
+ /**
48
+ * Bind data to effect
49
+ * @param effect - the effect to bind to
50
+ */
47
51
  bind(effect: Effect): void;
48
52
  private _createRandomTexture;
49
53
  protected _buildBlock(state: NodeMaterialBuildState): this;
54
+ /**
55
+ * Releases the resources held by the block
56
+ */
50
57
  dispose(): void;
51
58
  }
@@ -63,6 +63,10 @@ export class AmbientOcclusionBlock extends NodeMaterialBlock {
63
63
  get occlusion() {
64
64
  return this._outputs[0];
65
65
  }
66
+ /**
67
+ * Bind data to effect
68
+ * @param effect - the effect to bind to
69
+ */
66
70
  bind(effect) {
67
71
  if (!this._randomTexture) {
68
72
  this._createRandomTexture(effect.getEngine());
@@ -241,6 +245,9 @@ export class AmbientOcclusionBlock extends NodeMaterialBlock {
241
245
  state.compilationString += state._declareOutput(occlusion) + ` = computeOcclusion(${screenSize.associatedVariableName});`;
242
246
  return this;
243
247
  }
248
+ /**
249
+ * Releases the resources held by the block
250
+ */
244
251
  dispose() {
245
252
  if (this._randomTexture) {
246
253
  this._randomTexture.dispose();
@@ -1 +1 @@
1
- {"version":3,"file":"amb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CAAC,kBAAkB,EAAE,cAAc,EAAE,8BAA8B,CAAC,CAAC;QAExF,KAAK,CAAC,iBAAiB,IAAI,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,GAAG,uBAAuB,UAAU,CAAC,sBAAsB,IAAI,CAAC;QAE1H,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,OAAO;QACnB,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;YAC9B,IAAI,CAAC,cAAc,GAAG,IAAK,CAAC;QAChC,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ;AA3QU;IAHN,sBAAsB,CAAC,QAAQ,wCAAgC,UAAU,EAAE;QACxE,GAAG,EAAE,MAAM;KACd,CAAC;qDACqB;AAShB;IAHN,sBAAsB,CAAC,MAAM,wCAAgC,UAAU,EAAE;QACtE,GAAG,EAAE,CAAC;KACT,CAAC;mDACmB;AASd;IAHN,sBAAsB,CAAC,SAAS,wCAAgC,UAAU,EAAE;QACzE,GAAG,EAAE,CAAC;KACT,CAAC;sDACwB;AA2P9B,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport { NodeMaterialConnectionPointDirection, type NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { NodeMaterialConnectionPointCustomObject } from \"../../nodeMaterialConnectionPointCustomObject\";\r\nimport { RandomRange } from \"../../../../Maths/math.scalar.functions\";\r\nimport { RawTexture } from \"../../../Textures/rawTexture\";\r\nimport { Constants } from \"../../../../Engines/constants\";\r\nimport { Texture } from \"../../../Textures/texture\";\r\nimport type { Effect } from \"../../../effect\";\r\nimport type { AbstractEngine } from \"../../../../Engines/abstractEngine\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\nimport { ImageSourceBlock } from \"../Dual/imageSourceBlock\";\r\nimport type { DepthSourceBlock } from \"../Dual/depthSourceBlock\";\r\n\r\n/**\r\n * Block used to evaluate screen spaceambient occlusion in a shader\r\n */\r\nexport class AmbientOcclusionBlock extends NodeMaterialBlock {\r\n private _randomTexture: Texture;\r\n private _randomSamplerName: string;\r\n\r\n /**\r\n * Defines the radius around the analyzed pixel used by the SSAO post-process\r\n */\r\n @editableInPropertyPage(\"radius\", PropertyTypeForEdition.Float, \"ADVANCED\", {\r\n min: 0.0001,\r\n })\r\n public radius = 0.0001;\r\n\r\n /**\r\n * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel\r\n * Must not be equal to fallOff and superior to fallOff.\r\n */\r\n @editableInPropertyPage(\"area\", PropertyTypeForEdition.Float, \"ADVANCED\", {\r\n min: 0,\r\n })\r\n public area = 0.0075;\r\n\r\n /**\r\n * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel\r\n * Must not be equal to area and inferior to area.\r\n */\r\n @editableInPropertyPage(\"fallOff\", PropertyTypeForEdition.Float, \"ADVANCED\", {\r\n min: 0,\r\n })\r\n public fallOff = 0.000001;\r\n\r\n /**\r\n * Create a new AmbientOcclusionBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment);\r\n\r\n this.registerInput(\r\n \"source\",\r\n NodeMaterialBlockConnectionPointTypes.Object,\r\n true,\r\n NodeMaterialBlockTargets.VertexAndFragment,\r\n new NodeMaterialConnectionPointCustomObject(\"source\", this, NodeMaterialConnectionPointDirection.Input, ImageSourceBlock, \"ImageSourceBlock\")\r\n );\r\n this.registerInput(\"screenSize\", NodeMaterialBlockConnectionPointTypes.Vector2);\r\n this.registerOutput(\"occlusion\", NodeMaterialBlockConnectionPointTypes.Float);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"AmbientOcclusionBlock\";\r\n }\r\n\r\n /**\r\n * Gets the source component\r\n */\r\n public get source(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the screenSize component\r\n */\r\n public get screenSize(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the occlusion output\r\n */\r\n public get occlusion(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override bind(effect: Effect) {\r\n if (!this._randomTexture) {\r\n this._createRandomTexture(effect.getEngine());\r\n }\r\n\r\n effect.setTexture(this._randomSamplerName, this._randomTexture);\r\n }\r\n\r\n private _createRandomTexture(engine: AbstractEngine): void {\r\n const size = 512;\r\n\r\n const data = new Uint8Array(size * size * 4);\r\n for (let index = 0; index < data.length; ) {\r\n data[index++] = Math.floor(Math.max(0.0, RandomRange(-1.0, 1.0)) * 255);\r\n data[index++] = Math.floor(Math.max(0.0, RandomRange(-1.0, 1.0)) * 255);\r\n data[index++] = Math.floor(Math.max(0.0, RandomRange(-1.0, 1.0)) * 255);\r\n data[index++] = 255;\r\n }\r\n\r\n const texture = RawTexture.CreateRGBATexture(data, size, size, engine, false, false, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n texture.name = \"SSAORandomTexture\";\r\n texture.wrapU = Texture.WRAP_ADDRESSMODE;\r\n texture.wrapV = Texture.WRAP_ADDRESSMODE;\r\n this._randomTexture = texture;\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n if (!this.source.connectedPoint) {\r\n return this;\r\n }\r\n\r\n state.sharedData.bindableBlocks.push(this);\r\n const depthSource = this.source.connectedPoint!.ownerBlock as DepthSourceBlock;\r\n\r\n const occlusion = this._outputs[0];\r\n const screenSize = this.screenSize;\r\n\r\n let functionString: string;\r\n\r\n // Get view position from depth\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n functionString = `fn normalFromDepth(depth: f32, coords: vec2f, radius: f32) -> vec3f {\r\n let offset1: vec2f = vec2f(0.0, radius);\r\n let offset2: vec2f = vec2f(radius, 0.0);\r\n\r\n let depth1: f32 = textureSampleLevel(${depthSource.samplerName}, ${depthSource.samplerName}Sampler, coords + offset1, 0.0).r;\r\n let depth2: f32 = textureSampleLevel(${depthSource.samplerName}, ${depthSource.samplerName}Sampler, coords + offset2, 0.0).r;\r\n\r\n let p1: vec3f = vec3f(offset1, depth1 - depth);\r\n let p2: vec3f = vec3f(offset2, depth2 - depth);\r\n\r\n var normal: vec3f = cross(p1, p2);\r\n normal.z = -normal.z;\r\n\r\n return normalize(normal);\r\n }\r\n `;\r\n } else {\r\n functionString = `vec3 normalFromDepth(float depth, vec2 coords, float radius) {\r\n vec2 offset1 = vec2(0.0, radius);\r\n vec2 offset2 = vec2(radius, 0.0);\r\n\r\n float depth1 = textureLod(${depthSource.samplerName}, coords + offset1, 0.0).r;\r\n float depth2 = textureLod(${depthSource.samplerName}, coords + offset2, 0.0).r;\r\n\r\n vec3 p1 = vec3(offset1, depth1 - depth);\r\n vec3 p2 = vec3(offset2, depth2 - depth);\r\n\r\n vec3 normal = cross(p1, p2);\r\n normal.z = -normal.z;\r\n\r\n return normalize(normal);\r\n }\r\n `;\r\n }\r\n\r\n state._emitFunction(\"normalFromDepth\", functionString, \"// normalFromDepth function\");\r\n\r\n // Calculate ambient occlusion\r\n this._randomSamplerName = state._getFreeVariableName(\"randomSampler\");\r\n\r\n state._emit2DSampler(this._randomSamplerName);\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n functionString = `\r\n const sampleSphere: array<vec3f, 16> = array<vec3f, 16>(\r\n vec3f( 0.5381, 0.1856, -0.4319),\r\n vec3f( 0.1379, 0.2486, 0.4430),\r\n vec3f( 0.3371, 0.5679, -0.0057),\r\n vec3f(-0.6999, -0.0451, -0.0019),\r\n vec3f( 0.0689, -0.1598, -0.8547),\r\n vec3f( 0.0560, 0.0069, -0.1843),\r\n vec3f(-0.0146, 0.1402, 0.0762),\r\n vec3f( 0.0100, -0.1924, -0.0344),\r\n vec3f(-0.3577, -0.5301, -0.4358),\r\n vec3f(-0.3169, 0.1063, 0.0158),\r\n vec3f( 0.0103, -0.5869, 0.0046),\r\n vec3f(-0.0897, -0.4940, 0.3287),\r\n vec3f( 0.7119, -0.0154, -0.0918),\r\n vec3f(-0.0533, 0.0596, -0.5411),\r\n vec3f( 0.0352, -0.0631, 0.5460),\r\n vec3f(-0.4776, 0.2847, -0.0271)\r\n );\r\n\r\n fn computeOcclusion(screenSize: vec2f) -> f32 {\r\n let uv: vec2f = fragmentInputs.position.xy / screenSize;\r\n let random: vec3f = normalize(textureSampleLevel(${this._randomSamplerName}, ${this._randomSamplerName}Sampler, uv * 4.0, 0.0).rgb);\r\n let depth: f32 = textureSampleLevel(${depthSource.samplerName}, ${depthSource.samplerName}Sampler, uv, 0.0).r;\r\n let position: vec3f = vec3f(uv, depth);\r\n let normal: vec3f = normalFromDepth(depth, uv, ${this.radius}f);\r\n\r\n let radiusDepth: f32 = ${this.radius}f / depth;\r\n var occlusion: f32 = 0.0;\r\n\r\n var ray: vec3f;\r\n var hemiRay: vec3f;\r\n var occlusionDepth: f32;\r\n var difference: f32;\r\n\r\n for (var i: i32 = 0; i < 16; i++)\r\n {\r\n ray = radiusDepth * reflect(sampleSphere[i], random);\r\n hemiRay = position + sign(dot(ray, normal)) * ray;\r\n\r\n occlusionDepth = textureSample(${depthSource.samplerName}, ${depthSource.samplerName}Sampler, clamp(hemiRay.xy, vec2f(0.001, 0.001), vec2f(0.999, 0.999))).r;\r\n difference = depth - occlusionDepth;\r\n\r\n occlusion += step(${this.fallOff}f, difference) * (1.0 - smoothstep(${this.fallOff}f, ${this.area}f, difference));\r\n }\r\n\r\n return clamp(1.0 - occlusion / 16.0, 0.0, 1.0);\r\n }\r\n `;\r\n } else {\r\n functionString = `\r\n const vec3 sampleSphere[16] = vec3[](\r\n vec3( 0.5381, 0.1856, -0.4319),\r\n vec3( 0.1379, 0.2486, 0.4430),\r\n vec3( 0.3371, 0.5679, -0.0057),\r\n vec3(-0.6999, -0.0451, -0.0019),\r\n vec3( 0.0689, -0.1598, -0.8547),\r\n vec3( 0.0560, 0.0069, -0.1843),\r\n vec3(-0.0146, 0.1402, 0.0762),\r\n vec3( 0.0100, -0.1924, -0.0344),\r\n vec3(-0.3577, -0.5301, -0.4358),\r\n vec3(-0.3169, 0.1063, 0.0158),\r\n vec3( 0.0103, -0.5869, 0.0046),\r\n vec3(-0.0897, -0.4940, 0.3287),\r\n vec3( 0.7119, -0.0154, -0.0918),\r\n vec3(-0.0533, 0.0596, -0.5411),\r\n vec3( 0.0352, -0.0631, 0.5460),\r\n vec3(-0.4776, 0.2847, -0.0271)\r\n );\r\n\r\n float computeOcclusion(vec2 screenSize) {\r\n vec2 uv = gl_FragCoord.xy / screenSize;\r\n vec3 random = normalize(textureLod(${this._randomSamplerName}, uv * 4., 0.0).rgb);\r\n float depth = textureLod(${depthSource.samplerName}, uv, 0.0).r; \r\n vec3 position = vec3(uv, depth);\r\n vec3 normal = normalFromDepth(depth, uv, ${this.radius} );\r\n\r\n float radiusDepth = ${this.radius} / depth;\r\n float occlusion = 0.0;\r\n\r\n vec3 ray;\r\n vec3 hemiRay;\r\n float occlusionDepth;\r\n float difference;\r\n\r\n for (int i = 0; i < 16; i++)\r\n {\r\n ray = radiusDepth * reflect(sampleSphere[i], random);\r\n hemiRay = position + sign(dot(ray, normal)) * ray;\r\n\r\n occlusionDepth = texture2D(${depthSource.samplerName}, clamp(hemiRay.xy, vec2(0.001, 0.001), vec2(0.999, 0.999))).r;\r\n difference = depth - occlusionDepth;\r\n\r\n occlusion += step(${this.fallOff}, difference) * (1.0 - smoothstep(${this.fallOff}, ${this.area}, difference));\r\n }\r\n\r\n return clamp(1.0 - occlusion / 16.0, 0.0, 1.0);\r\n }\r\n `;\r\n }\r\n\r\n state._emitFunction(\"computeOcclusion\", functionString, \"// computeOcclusion function\");\r\n\r\n state.compilationString += state._declareOutput(occlusion) + ` = computeOcclusion(${screenSize.associatedVariableName});`;\r\n\r\n return this;\r\n }\r\n\r\n public override dispose(): void {\r\n if (this._randomTexture) {\r\n this._randomTexture.dispose();\r\n this._randomTexture = null!;\r\n }\r\n super.dispose();\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.AmbientOcclusionBlock\", AmbientOcclusionBlock);\r\n"]}
1
+ {"version":3,"file":"ambientOcclusionBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,uCAAuC,EAAE,MAAM,+CAA+C,CAAC;AACxG,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGpD,OAAO,EAAE,sBAAsB,EAA0B,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IA8B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,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport { NodeMaterialConnectionPointDirection, type NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { NodeMaterialConnectionPointCustomObject } from \"../../nodeMaterialConnectionPointCustomObject\";\r\nimport { RandomRange } from \"../../../../Maths/math.scalar.functions\";\r\nimport { RawTexture } from \"../../../Textures/rawTexture\";\r\nimport { Constants } from \"../../../../Engines/constants\";\r\nimport { Texture } from \"../../../Textures/texture\";\r\nimport type { Effect } from \"../../../effect\";\r\nimport type { AbstractEngine } from \"../../../../Engines/abstractEngine\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\nimport { ImageSourceBlock } from \"../Dual/imageSourceBlock\";\r\nimport type { DepthSourceBlock } from \"../Dual/depthSourceBlock\";\r\n\r\n/**\r\n * Block used to evaluate screen spaceambient occlusion in a shader\r\n */\r\nexport class AmbientOcclusionBlock extends NodeMaterialBlock {\r\n private _randomTexture: Texture;\r\n private _randomSamplerName: string;\r\n\r\n /**\r\n * Defines the radius around the analyzed pixel used by the SSAO post-process\r\n */\r\n @editableInPropertyPage(\"radius\", PropertyTypeForEdition.Float, \"ADVANCED\", {\r\n min: 0.0001,\r\n })\r\n public radius = 0.0001;\r\n\r\n /**\r\n * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel\r\n * Must not be equal to fallOff and superior to fallOff.\r\n */\r\n @editableInPropertyPage(\"area\", PropertyTypeForEdition.Float, \"ADVANCED\", {\r\n min: 0,\r\n })\r\n public area = 0.0075;\r\n\r\n /**\r\n * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel\r\n * Must not be equal to area and inferior to area.\r\n */\r\n @editableInPropertyPage(\"fallOff\", PropertyTypeForEdition.Float, \"ADVANCED\", {\r\n min: 0,\r\n })\r\n public fallOff = 0.000001;\r\n\r\n /**\r\n * Create a new AmbientOcclusionBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment);\r\n\r\n this.registerInput(\r\n \"source\",\r\n NodeMaterialBlockConnectionPointTypes.Object,\r\n true,\r\n NodeMaterialBlockTargets.VertexAndFragment,\r\n new NodeMaterialConnectionPointCustomObject(\"source\", this, NodeMaterialConnectionPointDirection.Input, ImageSourceBlock, \"ImageSourceBlock\")\r\n );\r\n this.registerInput(\"screenSize\", NodeMaterialBlockConnectionPointTypes.Vector2);\r\n this.registerOutput(\"occlusion\", NodeMaterialBlockConnectionPointTypes.Float);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"AmbientOcclusionBlock\";\r\n }\r\n\r\n /**\r\n * Gets the source component\r\n */\r\n public get source(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the screenSize component\r\n */\r\n public get screenSize(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the occlusion output\r\n */\r\n public get occlusion(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Bind data to effect\r\n * @param effect - the effect to bind to\r\n */\r\n public override bind(effect: Effect) {\r\n if (!this._randomTexture) {\r\n this._createRandomTexture(effect.getEngine());\r\n }\r\n\r\n effect.setTexture(this._randomSamplerName, this._randomTexture);\r\n }\r\n\r\n private _createRandomTexture(engine: AbstractEngine): void {\r\n const size = 512;\r\n\r\n const data = new Uint8Array(size * size * 4);\r\n for (let index = 0; index < data.length; ) {\r\n data[index++] = Math.floor(Math.max(0.0, RandomRange(-1.0, 1.0)) * 255);\r\n data[index++] = Math.floor(Math.max(0.0, RandomRange(-1.0, 1.0)) * 255);\r\n data[index++] = Math.floor(Math.max(0.0, RandomRange(-1.0, 1.0)) * 255);\r\n data[index++] = 255;\r\n }\r\n\r\n const texture = RawTexture.CreateRGBATexture(data, size, size, engine, false, false, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n texture.name = \"SSAORandomTexture\";\r\n texture.wrapU = Texture.WRAP_ADDRESSMODE;\r\n texture.wrapV = Texture.WRAP_ADDRESSMODE;\r\n this._randomTexture = texture;\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n if (!this.source.connectedPoint) {\r\n return this;\r\n }\r\n\r\n state.sharedData.bindableBlocks.push(this);\r\n const depthSource = this.source.connectedPoint!.ownerBlock as DepthSourceBlock;\r\n\r\n const occlusion = this._outputs[0];\r\n const screenSize = this.screenSize;\r\n\r\n let functionString: string;\r\n\r\n // Get view position from depth\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n functionString = `fn normalFromDepth(depth: f32, coords: vec2f, radius: f32) -> vec3f {\r\n let offset1: vec2f = vec2f(0.0, radius);\r\n let offset2: vec2f = vec2f(radius, 0.0);\r\n\r\n let depth1: f32 = textureSampleLevel(${depthSource.samplerName}, ${depthSource.samplerName}Sampler, coords + offset1, 0.0).r;\r\n let depth2: f32 = textureSampleLevel(${depthSource.samplerName}, ${depthSource.samplerName}Sampler, coords + offset2, 0.0).r;\r\n\r\n let p1: vec3f = vec3f(offset1, depth1 - depth);\r\n let p2: vec3f = vec3f(offset2, depth2 - depth);\r\n\r\n var normal: vec3f = cross(p1, p2);\r\n normal.z = -normal.z;\r\n\r\n return normalize(normal);\r\n }\r\n `;\r\n } else {\r\n functionString = `vec3 normalFromDepth(float depth, vec2 coords, float radius) {\r\n vec2 offset1 = vec2(0.0, radius);\r\n vec2 offset2 = vec2(radius, 0.0);\r\n\r\n float depth1 = textureLod(${depthSource.samplerName}, coords + offset1, 0.0).r;\r\n float depth2 = textureLod(${depthSource.samplerName}, coords + offset2, 0.0).r;\r\n\r\n vec3 p1 = vec3(offset1, depth1 - depth);\r\n vec3 p2 = vec3(offset2, depth2 - depth);\r\n\r\n vec3 normal = cross(p1, p2);\r\n normal.z = -normal.z;\r\n\r\n return normalize(normal);\r\n }\r\n `;\r\n }\r\n\r\n state._emitFunction(\"normalFromDepth\", functionString, \"// normalFromDepth function\");\r\n\r\n // Calculate ambient occlusion\r\n this._randomSamplerName = state._getFreeVariableName(\"randomSampler\");\r\n\r\n state._emit2DSampler(this._randomSamplerName);\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n functionString = `\r\n const sampleSphere: array<vec3f, 16> = array<vec3f, 16>(\r\n vec3f( 0.5381, 0.1856, -0.4319),\r\n vec3f( 0.1379, 0.2486, 0.4430),\r\n vec3f( 0.3371, 0.5679, -0.0057),\r\n vec3f(-0.6999, -0.0451, -0.0019),\r\n vec3f( 0.0689, -0.1598, -0.8547),\r\n vec3f( 0.0560, 0.0069, -0.1843),\r\n vec3f(-0.0146, 0.1402, 0.0762),\r\n vec3f( 0.0100, -0.1924, -0.0344),\r\n vec3f(-0.3577, -0.5301, -0.4358),\r\n vec3f(-0.3169, 0.1063, 0.0158),\r\n vec3f( 0.0103, -0.5869, 0.0046),\r\n vec3f(-0.0897, -0.4940, 0.3287),\r\n vec3f( 0.7119, -0.0154, -0.0918),\r\n vec3f(-0.0533, 0.0596, -0.5411),\r\n vec3f( 0.0352, -0.0631, 0.5460),\r\n vec3f(-0.4776, 0.2847, -0.0271)\r\n );\r\n\r\n fn computeOcclusion(screenSize: vec2f) -> f32 {\r\n let uv: vec2f = fragmentInputs.position.xy / screenSize;\r\n let random: vec3f = normalize(textureSampleLevel(${this._randomSamplerName}, ${this._randomSamplerName}Sampler, uv * 4.0, 0.0).rgb);\r\n let depth: f32 = textureSampleLevel(${depthSource.samplerName}, ${depthSource.samplerName}Sampler, uv, 0.0).r;\r\n let position: vec3f = vec3f(uv, depth);\r\n let normal: vec3f = normalFromDepth(depth, uv, ${this.radius}f);\r\n\r\n let radiusDepth: f32 = ${this.radius}f / depth;\r\n var occlusion: f32 = 0.0;\r\n\r\n var ray: vec3f;\r\n var hemiRay: vec3f;\r\n var occlusionDepth: f32;\r\n var difference: f32;\r\n\r\n for (var i: i32 = 0; i < 16; i++)\r\n {\r\n ray = radiusDepth * reflect(sampleSphere[i], random);\r\n hemiRay = position + sign(dot(ray, normal)) * ray;\r\n\r\n occlusionDepth = textureSample(${depthSource.samplerName}, ${depthSource.samplerName}Sampler, clamp(hemiRay.xy, vec2f(0.001, 0.001), vec2f(0.999, 0.999))).r;\r\n difference = depth - occlusionDepth;\r\n\r\n occlusion += step(${this.fallOff}f, difference) * (1.0 - smoothstep(${this.fallOff}f, ${this.area}f, difference));\r\n }\r\n\r\n return clamp(1.0 - occlusion / 16.0, 0.0, 1.0);\r\n }\r\n `;\r\n } else {\r\n functionString = `\r\n const vec3 sampleSphere[16] = vec3[](\r\n vec3( 0.5381, 0.1856, -0.4319),\r\n vec3( 0.1379, 0.2486, 0.4430),\r\n vec3( 0.3371, 0.5679, -0.0057),\r\n vec3(-0.6999, -0.0451, -0.0019),\r\n vec3( 0.0689, -0.1598, -0.8547),\r\n vec3( 0.0560, 0.0069, -0.1843),\r\n vec3(-0.0146, 0.1402, 0.0762),\r\n vec3( 0.0100, -0.1924, -0.0344),\r\n vec3(-0.3577, -0.5301, -0.4358),\r\n vec3(-0.3169, 0.1063, 0.0158),\r\n vec3( 0.0103, -0.5869, 0.0046),\r\n vec3(-0.0897, -0.4940, 0.3287),\r\n vec3( 0.7119, -0.0154, -0.0918),\r\n vec3(-0.0533, 0.0596, -0.5411),\r\n vec3( 0.0352, -0.0631, 0.5460),\r\n vec3(-0.4776, 0.2847, -0.0271)\r\n );\r\n\r\n float computeOcclusion(vec2 screenSize) {\r\n vec2 uv = gl_FragCoord.xy / screenSize;\r\n vec3 random = normalize(textureLod(${this._randomSamplerName}, uv * 4., 0.0).rgb);\r\n float depth = textureLod(${depthSource.samplerName}, uv, 0.0).r; \r\n vec3 position = vec3(uv, depth);\r\n vec3 normal = normalFromDepth(depth, uv, ${this.radius} );\r\n\r\n float radiusDepth = ${this.radius} / depth;\r\n float occlusion = 0.0;\r\n\r\n vec3 ray;\r\n vec3 hemiRay;\r\n float occlusionDepth;\r\n float difference;\r\n\r\n for (int i = 0; i < 16; i++)\r\n {\r\n ray = radiusDepth * reflect(sampleSphere[i], random);\r\n hemiRay = position + sign(dot(ray, normal)) * ray;\r\n\r\n occlusionDepth = texture2D(${depthSource.samplerName}, clamp(hemiRay.xy, vec2(0.001, 0.001), vec2(0.999, 0.999))).r;\r\n difference = depth - occlusionDepth;\r\n\r\n occlusion += step(${this.fallOff}, difference) * (1.0 - smoothstep(${this.fallOff}, ${this.area}, difference));\r\n }\r\n\r\n return clamp(1.0 - occlusion / 16.0, 0.0, 1.0);\r\n }\r\n `;\r\n }\r\n\r\n state._emitFunction(\"computeOcclusion\", functionString, \"// computeOcclusion function\");\r\n\r\n state.compilationString += state._declareOutput(occlusion) + ` = computeOcclusion(${screenSize.associatedVariableName});`;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Releases the resources held by the block\r\n */\r\n public override dispose(): void {\r\n if (this._randomTexture) {\r\n this._randomTexture.dispose();\r\n this._randomTexture = null!;\r\n }\r\n super.dispose();\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.AmbientOcclusionBlock\", AmbientOcclusionBlock);\r\n"]}
@@ -71,10 +71,31 @@ export declare class FragmentOutputBlock extends NodeMaterialBlock {
71
71
  */
72
72
  get glow(): NodeMaterialConnectionPoint;
73
73
  protected _getOutputString(state: NodeMaterialBuildState): string;
74
+ /**
75
+ * Prepare the list of defines
76
+ * @param defines - the material defines
77
+ * @param nodeMaterial - the node material
78
+ */
74
79
  prepareDefines(defines: NodeMaterialDefines, nodeMaterial: NodeMaterial): void;
80
+ /**
81
+ * Bind data to effect
82
+ * @param effect - the effect to bind to
83
+ * @param nodeMaterial - the node material
84
+ * @param mesh - the mesh to bind for
85
+ */
75
86
  bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
76
87
  protected _buildBlock(state: NodeMaterialBuildState): this;
77
88
  protected _dumpPropertiesCode(): string;
89
+ /**
90
+ * Serializes the block
91
+ * @returns the serialized object
92
+ */
78
93
  serialize(): any;
94
+ /**
95
+ * Deserializes the block
96
+ * @param serializationObject - the serialization object
97
+ * @param scene - the scene
98
+ * @param rootUrl - the root url
99
+ */
79
100
  _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
80
101
  }
@@ -106,11 +106,22 @@ export class FragmentOutputBlock extends NodeMaterialBlock {
106
106
  _getOutputString(state) {
107
107
  return state.shaderLanguage === 1 /* ShaderLanguage.WGSL */ ? "fragmentOutputsColor" : "gl_FragColor";
108
108
  }
109
+ /**
110
+ * Prepare the list of defines
111
+ * @param defines - the material defines
112
+ * @param nodeMaterial - the node material
113
+ */
109
114
  prepareDefines(defines, nodeMaterial) {
110
115
  defines.setValue(this._linearDefineName, this.convertToLinearSpace, true);
111
116
  defines.setValue(this._gammaDefineName, this.convertToGammaSpace, true);
112
117
  defines.setValue(this._additionalColorDefineName, this.additionalColor.connectedPoint && nodeMaterial._useAdditionalColor, true);
113
118
  }
119
+ /**
120
+ * Bind data to effect
121
+ * @param effect - the effect to bind to
122
+ * @param nodeMaterial - the node material
123
+ * @param mesh - the mesh to bind for
124
+ */
114
125
  bind(effect, nodeMaterial, mesh) {
115
126
  if ((this.useLogarithmicDepth || nodeMaterial.useLogarithmicDepth) && mesh) {
116
127
  BindLogDepth(undefined, effect, mesh.getScene());
@@ -213,6 +224,10 @@ export class FragmentOutputBlock extends NodeMaterialBlock {
213
224
  codeString += `${this._codeVariableName}.useLogarithmicDepth = ${this.useLogarithmicDepth};\n`;
214
225
  return codeString;
215
226
  }
227
+ /**
228
+ * Serializes the block
229
+ * @returns the serialized object
230
+ */
216
231
  serialize() {
217
232
  const serializationObject = super.serialize();
218
233
  serializationObject.convertToGammaSpace = this.convertToGammaSpace;
@@ -220,6 +235,12 @@ export class FragmentOutputBlock extends NodeMaterialBlock {
220
235
  serializationObject.useLogarithmicDepth = this.useLogarithmicDepth;
221
236
  return serializationObject;
222
237
  }
238
+ /**
239
+ * Deserializes the block
240
+ * @param serializationObject - the serialization object
241
+ * @param scene - the scene
242
+ * @param rootUrl - the root url
243
+ */
223
244
  _deserialize(serializationObject, scene, rootUrl) {
224
245
  super._deserialize(serializationObject, scene, rootUrl);
225
246
  this.convertToGammaSpace = !!serializationObject.convertToGammaSpace;
@@ -1 +1 @@
1
- {"version":3,"file":"fragmentOutputBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/Fragment/fragmentOutputBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,sBAAsB,EAA0B,MAAM,sCAAsC,CAAC;AAGtG,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAGjE;;GAEG;AACH,MAAM,CAAN,IAAY,6BAOX;AAPD,WAAY,6BAA6B;IACrC,kBAAkB;IAClB,iGAAY,CAAA;IACZ,YAAY;IACZ,mFAAK,CAAA;IACL,aAAa;IACb,qFAAM,CAAA;AACV,CAAC,EAPW,6BAA6B,KAA7B,6BAA6B,QAOxC;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IAMtD;;;O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,CAAC,mBAAmB,CAAC;QACrE,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,mBAAmB,CAAC,oBAAoB,CAAC;QACvE,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC,mBAAmB,IAAI,KAAK,CAAC;IAChF,CAAC;CACJ;AAtOU;IADN,sBAAsB,CAAC,uBAAuB,0CAAkC,YAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gEAC/E;AAcnC;IATC,sBAAsB,CAAC,aAAa,uCAA+B,UAAU,EAAE;QAC5E,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,6BAA6B,CAAC,YAAY,EAAE;YAC9E,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,6BAA6B,CAAC,KAAK,EAAE;YACjE,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,6BAA6B,CAAC,MAAM,EAAE;SACtE;KACJ,CAAC;qDASD;AAkNL,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { Scene } from \"../../../../scene\";\r\nimport type { NodeMaterialDefines, NodeMaterial } from \"../../nodeMaterial\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\nimport type { Effect } from \"../../../effect\";\r\nimport type { Mesh } from \"../../../../Meshes/mesh\";\r\nimport { BindLogDepth } from \"../../../materialHelper.functions\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Color spaces supported by the fragment output block\r\n */\r\nexport enum FragmentOutputBlockColorSpace {\r\n /** Unspecified */\r\n NoColorSpace,\r\n /** Gamma */\r\n Gamma,\r\n /** Linear */\r\n Linear,\r\n}\r\n\r\n/**\r\n * Block used to output the final color\r\n */\r\nexport class FragmentOutputBlock extends NodeMaterialBlock {\r\n private _linearDefineName: string;\r\n private _gammaDefineName: string;\r\n private _additionalColorDefineName: string;\r\n protected _outputString: string;\r\n\r\n /**\r\n * Create a new FragmentOutputBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment, true, true);\r\n\r\n this.registerInput(\"rgba\", NodeMaterialBlockConnectionPointTypes.Color4, true);\r\n this.registerInput(\"rgb\", NodeMaterialBlockConnectionPointTypes.Color3, true);\r\n this.registerInput(\"a\", NodeMaterialBlockConnectionPointTypes.Float, true);\r\n this.registerInput(\"glow\", NodeMaterialBlockConnectionPointTypes.Color3, true);\r\n\r\n this.rgb.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3);\r\n this.rgb.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float);\r\n\r\n this.additionalColor.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3);\r\n this.additionalColor.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float);\r\n }\r\n\r\n /** Gets or sets a boolean indicating if content needs to be converted to gamma space */\r\n public convertToGammaSpace = false;\r\n\r\n /** Gets or sets a boolean indicating if content needs to be converted to linear space */\r\n public convertToLinearSpace = false;\r\n\r\n /** Gets or sets a boolean indicating if logarithmic depth should be used */\r\n @editableInPropertyPage(\"Use logarithmic depth\", PropertyTypeForEdition.Boolean, \"PROPERTIES\", { embedded: true })\r\n public useLogarithmicDepth = false;\r\n\r\n /**\r\n * Gets or sets the color space used for the block\r\n */\r\n @editableInPropertyPage(\"Color space\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n embedded: true,\r\n options: [\r\n { label: \"No color space\", value: FragmentOutputBlockColorSpace.NoColorSpace },\r\n { label: \"To Gamma\", value: FragmentOutputBlockColorSpace.Gamma },\r\n { label: \"To Linear\", value: FragmentOutputBlockColorSpace.Linear },\r\n ],\r\n })\r\n public get colorSpace() {\r\n if (this.convertToGammaSpace) {\r\n return FragmentOutputBlockColorSpace.Gamma;\r\n }\r\n if (this.convertToLinearSpace) {\r\n return FragmentOutputBlockColorSpace.Linear;\r\n }\r\n return FragmentOutputBlockColorSpace.NoColorSpace;\r\n }\r\n\r\n public set colorSpace(value: FragmentOutputBlockColorSpace) {\r\n this.convertToGammaSpace = value === FragmentOutputBlockColorSpace.Gamma;\r\n this.convertToLinearSpace = value === FragmentOutputBlockColorSpace.Linear;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"FragmentOutputBlock\";\r\n }\r\n\r\n /**\r\n * Initialize the block and prepare the context for build\r\n * @param state defines the state that will be used for the build\r\n */\r\n public override initialize(state: NodeMaterialBuildState) {\r\n state._excludeVariableName(\"logarithmicDepthConstant\");\r\n state._excludeVariableName(\"vFragmentDepth\");\r\n }\r\n\r\n /**\r\n * Gets the rgba input component\r\n */\r\n public get rgba(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the rgb input component\r\n */\r\n public get rgb(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the a input component\r\n */\r\n public get a(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the additionalColor input component (named glow in the UI for now)\r\n */\r\n public get additionalColor(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the glow input component\r\n */\r\n public get glow(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n protected _getOutputString(state: NodeMaterialBuildState): string {\r\n return state.shaderLanguage === ShaderLanguage.WGSL ? \"fragmentOutputsColor\" : \"gl_FragColor\";\r\n }\r\n\r\n public override prepareDefines(defines: NodeMaterialDefines, nodeMaterial: NodeMaterial) {\r\n defines.setValue(this._linearDefineName, this.convertToLinearSpace, true);\r\n defines.setValue(this._gammaDefineName, this.convertToGammaSpace, true);\r\n defines.setValue(this._additionalColorDefineName, this.additionalColor.connectedPoint && nodeMaterial._useAdditionalColor, true);\r\n }\r\n\r\n public override bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh) {\r\n if ((this.useLogarithmicDepth || nodeMaterial.useLogarithmicDepth) && mesh) {\r\n BindLogDepth(undefined, effect, mesh.getScene());\r\n }\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const rgba = this.rgba;\r\n const rgb = this.rgb;\r\n const a = this.a;\r\n const additionalColor = this.additionalColor;\r\n\r\n const isWebGPU = state.shaderLanguage === ShaderLanguage.WGSL;\r\n state.sharedData.hints.needAlphaBlending = rgba.isConnected || a.isConnected;\r\n state.sharedData.blocksWithDefines.push(this);\r\n\r\n if (this.useLogarithmicDepth || state.sharedData.nodeMaterial.useLogarithmicDepth) {\r\n state._emitUniformFromString(\"logarithmicDepthConstant\", NodeMaterialBlockConnectionPointTypes.Float);\r\n state._emitVaryingFromString(\"vFragmentDepth\", NodeMaterialBlockConnectionPointTypes.Float);\r\n state.sharedData.bindableBlocks.push(this);\r\n }\r\n\r\n if (additionalColor.connectedPoint) {\r\n state._excludeVariableName(\"useAdditionalColor\");\r\n state._emitUniformFromString(\"useAdditionalColor\", NodeMaterialBlockConnectionPointTypes.Float);\r\n this._additionalColorDefineName = state._getFreeDefineName(\"USEADDITIONALCOLOR\");\r\n }\r\n\r\n this._linearDefineName = state._getFreeDefineName(\"CONVERTTOLINEAR\");\r\n this._gammaDefineName = state._getFreeDefineName(\"CONVERTTOGAMMA\");\r\n\r\n const comments = `//${this.name}`;\r\n state._emitFunctionFromInclude(\"helperFunctions\", comments);\r\n\r\n const outputString = this._getOutputString(state);\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n state.compilationString += `var ${outputString} : vec4<f32>;\\r\\n`;\r\n }\r\n\r\n const vec4 = state._getShaderType(NodeMaterialBlockConnectionPointTypes.Vector4);\r\n\r\n if (additionalColor.connectedPoint) {\r\n let aValue = \"1.0\";\r\n\r\n if (a.connectedPoint) {\r\n aValue = a.associatedVariableName;\r\n }\r\n state.compilationString += `#ifdef ${this._additionalColorDefineName}\\n`;\r\n if (additionalColor.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Float) {\r\n state.compilationString += `${outputString} = ${vec4}(${additionalColor.associatedVariableName}, ${additionalColor.associatedVariableName}, ${additionalColor.associatedVariableName}, ${aValue});\\n`;\r\n } else {\r\n state.compilationString += `${outputString} = ${vec4}(${additionalColor.associatedVariableName}, ${aValue});\\n`;\r\n }\r\n state.compilationString += `#else\\n`;\r\n }\r\n\r\n if (rgba.connectedPoint) {\r\n if (a.isConnected) {\r\n state.compilationString += `${outputString} = ${vec4}(${rgba.associatedVariableName}.rgb, ${a.associatedVariableName});\\n`;\r\n } else {\r\n state.compilationString += `${outputString} = ${rgba.associatedVariableName};\\n`;\r\n }\r\n } else if (rgb.connectedPoint) {\r\n let aValue = \"1.0\";\r\n\r\n if (a.connectedPoint) {\r\n aValue = a.associatedVariableName;\r\n }\r\n\r\n if (rgb.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Float) {\r\n state.compilationString += `${outputString} = ${vec4}(${rgb.associatedVariableName}, ${rgb.associatedVariableName}, ${rgb.associatedVariableName}, ${aValue});\\n`;\r\n } else {\r\n state.compilationString += `${outputString} = ${vec4}(${rgb.associatedVariableName}, ${aValue});\\n`;\r\n }\r\n } else {\r\n state.sharedData.checks.notConnectedNonOptionalInputs.push(rgba);\r\n }\r\n\r\n if (additionalColor.connectedPoint) {\r\n state.compilationString += `#endif\\n`;\r\n }\r\n\r\n state.compilationString += `#ifdef ${this._linearDefineName}\\n`;\r\n state.compilationString += `${outputString} = toLinearSpace${state.shaderLanguage === ShaderLanguage.WGSL ? \"Vec4\" : \"\"}(${outputString});\\n`;\r\n state.compilationString += `#endif\\n`;\r\n\r\n state.compilationString += `#ifdef ${this._gammaDefineName}\\n`;\r\n state.compilationString += `${outputString} = toGammaSpace(${outputString});\\n`;\r\n state.compilationString += `#endif\\n`;\r\n\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n state.compilationString += `#if !defined(PREPASS)\\r\\n`;\r\n state.compilationString += `fragmentOutputs.color = ${outputString};\\r\\n`;\r\n state.compilationString += `#endif\\r\\n`;\r\n }\r\n\r\n if (this.useLogarithmicDepth || state.sharedData.nodeMaterial.useLogarithmicDepth) {\r\n const fragDepth = isWebGPU ? \"input.vFragmentDepth\" : \"vFragmentDepth\";\r\n const uniformP = isWebGPU ? \"uniforms.\" : \"\";\r\n const output = isWebGPU ? \"fragmentOutputs.fragDepth\" : \"gl_FragDepthEXT\";\r\n\r\n state.compilationString += `${output} = log2(${fragDepth}) * ${uniformP}logarithmicDepthConstant * 0.5;\\n`;\r\n }\r\n\r\n state.compilationString += `#if defined(PREPASS)\\r\\n`;\r\n state.compilationString += `${isWebGPU ? \"fragmentOutputs.fragData0\" : \"gl_FragData[0]\"} = ${outputString};\\r\\n`;\r\n state.compilationString += `#endif\\r\\n`;\r\n\r\n return this;\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode();\r\n codeString += `${this._codeVariableName}.convertToGammaSpace = ${this.convertToGammaSpace};\\n`;\r\n codeString += `${this._codeVariableName}.convertToLinearSpace = ${this.convertToLinearSpace};\\n`;\r\n codeString += `${this._codeVariableName}.useLogarithmicDepth = ${this.useLogarithmicDepth};\\n`;\r\n\r\n return codeString;\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.convertToGammaSpace = this.convertToGammaSpace;\r\n serializationObject.convertToLinearSpace = this.convertToLinearSpace;\r\n serializationObject.useLogarithmicDepth = this.useLogarithmicDepth;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {\r\n super._deserialize(serializationObject, scene, rootUrl);\r\n\r\n this.convertToGammaSpace = !!serializationObject.convertToGammaSpace;\r\n this.convertToLinearSpace = !!serializationObject.convertToLinearSpace;\r\n this.useLogarithmicDepth = serializationObject.useLogarithmicDepth ?? false;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.FragmentOutputBlock\", FragmentOutputBlock);\r\n"]}
1
+ {"version":3,"file":"fragmentOutputBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/Fragment/fragmentOutputBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,sBAAsB,EAA0B,MAAM,sCAAsC,CAAC;AAGtG,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAGjE;;GAEG;AACH,MAAM,CAAN,IAAY,6BAOX;AAPD,WAAY,6BAA6B;IACrC,kBAAkB;IAClB,iGAAY,CAAA;IACZ,YAAY;IACZ,mFAAK,CAAA;IACL,aAAa;IACb,qFAAM,CAAA;AACV,CAAC,EAPW,6BAA6B,KAA7B,6BAA6B,QAOxC;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IAMtD;;;OAGG;IACH,YAA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,CAAC,mBAAmB,GAAG,CAAC,CAAC,mBAAmB,CAAC,mBAAmB,CAAC;QACrE,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,mBAAmB,CAAC,oBAAoB,CAAC;QACvE,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC,mBAAmB,IAAI,KAAK,CAAC;IAChF,CAAC;CACJ;AA3PU;IADN,sBAAsB,CAAC,uBAAuB,0CAAkC,YAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gEAC/E;AAcnC;IATC,sBAAsB,CAAC,aAAa,uCAA+B,UAAU,EAAE;QAC5E,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,6BAA6B,CAAC,YAAY,EAAE;YAC9E,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,6BAA6B,CAAC,KAAK,EAAE;YACjE,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,6BAA6B,CAAC,MAAM,EAAE;SACtE;KACJ,CAAC;qDASD;AAuOL,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { Scene } from \"../../../../scene\";\r\nimport type { NodeMaterialDefines, NodeMaterial } from \"../../nodeMaterial\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\nimport type { Effect } from \"../../../effect\";\r\nimport type { Mesh } from \"../../../../Meshes/mesh\";\r\nimport { BindLogDepth } from \"../../../materialHelper.functions\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Color spaces supported by the fragment output block\r\n */\r\nexport enum FragmentOutputBlockColorSpace {\r\n /** Unspecified */\r\n NoColorSpace,\r\n /** Gamma */\r\n Gamma,\r\n /** Linear */\r\n Linear,\r\n}\r\n\r\n/**\r\n * Block used to output the final color\r\n */\r\nexport class FragmentOutputBlock extends NodeMaterialBlock {\r\n private _linearDefineName: string;\r\n private _gammaDefineName: string;\r\n private _additionalColorDefineName: string;\r\n protected _outputString: string;\r\n\r\n /**\r\n * Create a new FragmentOutputBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment, true, true);\r\n\r\n this.registerInput(\"rgba\", NodeMaterialBlockConnectionPointTypes.Color4, true);\r\n this.registerInput(\"rgb\", NodeMaterialBlockConnectionPointTypes.Color3, true);\r\n this.registerInput(\"a\", NodeMaterialBlockConnectionPointTypes.Float, true);\r\n this.registerInput(\"glow\", NodeMaterialBlockConnectionPointTypes.Color3, true);\r\n\r\n this.rgb.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3);\r\n this.rgb.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float);\r\n\r\n this.additionalColor.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3);\r\n this.additionalColor.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float);\r\n }\r\n\r\n /** Gets or sets a boolean indicating if content needs to be converted to gamma space */\r\n public convertToGammaSpace = false;\r\n\r\n /** Gets or sets a boolean indicating if content needs to be converted to linear space */\r\n public convertToLinearSpace = false;\r\n\r\n /** Gets or sets a boolean indicating if logarithmic depth should be used */\r\n @editableInPropertyPage(\"Use logarithmic depth\", PropertyTypeForEdition.Boolean, \"PROPERTIES\", { embedded: true })\r\n public useLogarithmicDepth = false;\r\n\r\n /**\r\n * Gets or sets the color space used for the block\r\n */\r\n @editableInPropertyPage(\"Color space\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n embedded: true,\r\n options: [\r\n { label: \"No color space\", value: FragmentOutputBlockColorSpace.NoColorSpace },\r\n { label: \"To Gamma\", value: FragmentOutputBlockColorSpace.Gamma },\r\n { label: \"To Linear\", value: FragmentOutputBlockColorSpace.Linear },\r\n ],\r\n })\r\n public get colorSpace() {\r\n if (this.convertToGammaSpace) {\r\n return FragmentOutputBlockColorSpace.Gamma;\r\n }\r\n if (this.convertToLinearSpace) {\r\n return FragmentOutputBlockColorSpace.Linear;\r\n }\r\n return FragmentOutputBlockColorSpace.NoColorSpace;\r\n }\r\n\r\n public set colorSpace(value: FragmentOutputBlockColorSpace) {\r\n this.convertToGammaSpace = value === FragmentOutputBlockColorSpace.Gamma;\r\n this.convertToLinearSpace = value === FragmentOutputBlockColorSpace.Linear;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"FragmentOutputBlock\";\r\n }\r\n\r\n /**\r\n * Initialize the block and prepare the context for build\r\n * @param state defines the state that will be used for the build\r\n */\r\n public override initialize(state: NodeMaterialBuildState) {\r\n state._excludeVariableName(\"logarithmicDepthConstant\");\r\n state._excludeVariableName(\"vFragmentDepth\");\r\n }\r\n\r\n /**\r\n * Gets the rgba input component\r\n */\r\n public get rgba(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the rgb input component\r\n */\r\n public get rgb(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the a input component\r\n */\r\n public get a(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the additionalColor input component (named glow in the UI for now)\r\n */\r\n public get additionalColor(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the glow input component\r\n */\r\n public get glow(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n protected _getOutputString(state: NodeMaterialBuildState): string {\r\n return state.shaderLanguage === ShaderLanguage.WGSL ? \"fragmentOutputsColor\" : \"gl_FragColor\";\r\n }\r\n\r\n /**\r\n * Prepare the list of defines\r\n * @param defines - the material defines\r\n * @param nodeMaterial - the node material\r\n */\r\n public override prepareDefines(defines: NodeMaterialDefines, nodeMaterial: NodeMaterial) {\r\n defines.setValue(this._linearDefineName, this.convertToLinearSpace, true);\r\n defines.setValue(this._gammaDefineName, this.convertToGammaSpace, true);\r\n defines.setValue(this._additionalColorDefineName, this.additionalColor.connectedPoint && nodeMaterial._useAdditionalColor, true);\r\n }\r\n\r\n /**\r\n * Bind data to effect\r\n * @param effect - the effect to bind to\r\n * @param nodeMaterial - the node material\r\n * @param mesh - the mesh to bind for\r\n */\r\n public override bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh) {\r\n if ((this.useLogarithmicDepth || nodeMaterial.useLogarithmicDepth) && mesh) {\r\n BindLogDepth(undefined, effect, mesh.getScene());\r\n }\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const rgba = this.rgba;\r\n const rgb = this.rgb;\r\n const a = this.a;\r\n const additionalColor = this.additionalColor;\r\n\r\n const isWebGPU = state.shaderLanguage === ShaderLanguage.WGSL;\r\n state.sharedData.hints.needAlphaBlending = rgba.isConnected || a.isConnected;\r\n state.sharedData.blocksWithDefines.push(this);\r\n\r\n if (this.useLogarithmicDepth || state.sharedData.nodeMaterial.useLogarithmicDepth) {\r\n state._emitUniformFromString(\"logarithmicDepthConstant\", NodeMaterialBlockConnectionPointTypes.Float);\r\n state._emitVaryingFromString(\"vFragmentDepth\", NodeMaterialBlockConnectionPointTypes.Float);\r\n state.sharedData.bindableBlocks.push(this);\r\n }\r\n\r\n if (additionalColor.connectedPoint) {\r\n state._excludeVariableName(\"useAdditionalColor\");\r\n state._emitUniformFromString(\"useAdditionalColor\", NodeMaterialBlockConnectionPointTypes.Float);\r\n this._additionalColorDefineName = state._getFreeDefineName(\"USEADDITIONALCOLOR\");\r\n }\r\n\r\n this._linearDefineName = state._getFreeDefineName(\"CONVERTTOLINEAR\");\r\n this._gammaDefineName = state._getFreeDefineName(\"CONVERTTOGAMMA\");\r\n\r\n const comments = `//${this.name}`;\r\n state._emitFunctionFromInclude(\"helperFunctions\", comments);\r\n\r\n const outputString = this._getOutputString(state);\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n state.compilationString += `var ${outputString} : vec4<f32>;\\r\\n`;\r\n }\r\n\r\n const vec4 = state._getShaderType(NodeMaterialBlockConnectionPointTypes.Vector4);\r\n\r\n if (additionalColor.connectedPoint) {\r\n let aValue = \"1.0\";\r\n\r\n if (a.connectedPoint) {\r\n aValue = a.associatedVariableName;\r\n }\r\n state.compilationString += `#ifdef ${this._additionalColorDefineName}\\n`;\r\n if (additionalColor.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Float) {\r\n state.compilationString += `${outputString} = ${vec4}(${additionalColor.associatedVariableName}, ${additionalColor.associatedVariableName}, ${additionalColor.associatedVariableName}, ${aValue});\\n`;\r\n } else {\r\n state.compilationString += `${outputString} = ${vec4}(${additionalColor.associatedVariableName}, ${aValue});\\n`;\r\n }\r\n state.compilationString += `#else\\n`;\r\n }\r\n\r\n if (rgba.connectedPoint) {\r\n if (a.isConnected) {\r\n state.compilationString += `${outputString} = ${vec4}(${rgba.associatedVariableName}.rgb, ${a.associatedVariableName});\\n`;\r\n } else {\r\n state.compilationString += `${outputString} = ${rgba.associatedVariableName};\\n`;\r\n }\r\n } else if (rgb.connectedPoint) {\r\n let aValue = \"1.0\";\r\n\r\n if (a.connectedPoint) {\r\n aValue = a.associatedVariableName;\r\n }\r\n\r\n if (rgb.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Float) {\r\n state.compilationString += `${outputString} = ${vec4}(${rgb.associatedVariableName}, ${rgb.associatedVariableName}, ${rgb.associatedVariableName}, ${aValue});\\n`;\r\n } else {\r\n state.compilationString += `${outputString} = ${vec4}(${rgb.associatedVariableName}, ${aValue});\\n`;\r\n }\r\n } else {\r\n state.sharedData.checks.notConnectedNonOptionalInputs.push(rgba);\r\n }\r\n\r\n if (additionalColor.connectedPoint) {\r\n state.compilationString += `#endif\\n`;\r\n }\r\n\r\n state.compilationString += `#ifdef ${this._linearDefineName}\\n`;\r\n state.compilationString += `${outputString} = toLinearSpace${state.shaderLanguage === ShaderLanguage.WGSL ? \"Vec4\" : \"\"}(${outputString});\\n`;\r\n state.compilationString += `#endif\\n`;\r\n\r\n state.compilationString += `#ifdef ${this._gammaDefineName}\\n`;\r\n state.compilationString += `${outputString} = toGammaSpace(${outputString});\\n`;\r\n state.compilationString += `#endif\\n`;\r\n\r\n if (state.shaderLanguage === ShaderLanguage.WGSL) {\r\n state.compilationString += `#if !defined(PREPASS)\\r\\n`;\r\n state.compilationString += `fragmentOutputs.color = ${outputString};\\r\\n`;\r\n state.compilationString += `#endif\\r\\n`;\r\n }\r\n\r\n if (this.useLogarithmicDepth || state.sharedData.nodeMaterial.useLogarithmicDepth) {\r\n const fragDepth = isWebGPU ? \"input.vFragmentDepth\" : \"vFragmentDepth\";\r\n const uniformP = isWebGPU ? \"uniforms.\" : \"\";\r\n const output = isWebGPU ? \"fragmentOutputs.fragDepth\" : \"gl_FragDepthEXT\";\r\n\r\n state.compilationString += `${output} = log2(${fragDepth}) * ${uniformP}logarithmicDepthConstant * 0.5;\\n`;\r\n }\r\n\r\n state.compilationString += `#if defined(PREPASS)\\r\\n`;\r\n state.compilationString += `${isWebGPU ? \"fragmentOutputs.fragData0\" : \"gl_FragData[0]\"} = ${outputString};\\r\\n`;\r\n state.compilationString += `#endif\\r\\n`;\r\n\r\n return this;\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode();\r\n codeString += `${this._codeVariableName}.convertToGammaSpace = ${this.convertToGammaSpace};\\n`;\r\n codeString += `${this._codeVariableName}.convertToLinearSpace = ${this.convertToLinearSpace};\\n`;\r\n codeString += `${this._codeVariableName}.useLogarithmicDepth = ${this.useLogarithmicDepth};\\n`;\r\n\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes the block\r\n * @returns the serialized object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.convertToGammaSpace = this.convertToGammaSpace;\r\n serializationObject.convertToLinearSpace = this.convertToLinearSpace;\r\n serializationObject.useLogarithmicDepth = this.useLogarithmicDepth;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Deserializes the block\r\n * @param serializationObject - the serialization object\r\n * @param scene - the scene\r\n * @param rootUrl - the root url\r\n */\r\n public override _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {\r\n super._deserialize(serializationObject, scene, rootUrl);\r\n\r\n this.convertToGammaSpace = !!serializationObject.convertToGammaSpace;\r\n this.convertToLinearSpace = !!serializationObject.convertToLinearSpace;\r\n this.useLogarithmicDepth = serializationObject.useLogarithmicDepth ?? false;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.FragmentOutputBlock\", FragmentOutputBlock);\r\n"]}
@@ -55,6 +55,16 @@ export declare class HeightToNormalBlock extends NodeMaterialBlock {
55
55
  get xyz(): NodeMaterialConnectionPoint;
56
56
  protected _buildBlock(state: NodeMaterialBuildState): this;
57
57
  protected _dumpPropertiesCode(): string;
58
+ /**
59
+ * Serializes the block
60
+ * @returns the serialized object
61
+ */
58
62
  serialize(): any;
63
+ /**
64
+ * Deserializes the block
65
+ * @param serializationObject - the serialization object
66
+ * @param scene - the scene
67
+ * @param rootUrl - the root url
68
+ */
59
69
  _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
60
70
  }
@@ -136,6 +136,10 @@ export class HeightToNormalBlock extends NodeMaterialBlock {
136
136
  codeString += `${this._codeVariableName}.automaticNormalizationTangent = ${this.automaticNormalizationTangent};\n`;
137
137
  return codeString;
138
138
  }
139
+ /**
140
+ * Serializes the block
141
+ * @returns the serialized object
142
+ */
139
143
  serialize() {
140
144
  const serializationObject = super.serialize();
141
145
  serializationObject.generateInWorldSpace = this.generateInWorldSpace;
@@ -143,6 +147,12 @@ export class HeightToNormalBlock extends NodeMaterialBlock {
143
147
  serializationObject.automaticNormalizationTangent = this.automaticNormalizationTangent;
144
148
  return serializationObject;
145
149
  }
150
+ /**
151
+ * Deserializes the block
152
+ * @param serializationObject - the serialization object
153
+ * @param scene - the scene
154
+ * @param rootUrl - the root url
155
+ */
146
156
  _deserialize(serializationObject, scene, rootUrl) {
147
157
  super._deserialize(serializationObject, scene, rootUrl);
148
158
  this.generateInWorldSpace = serializationObject.generateInWorldSpace;
@@ -1 +1 @@
1
- {"version":3,"file":"heightToNormalBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/Fragment/heightToNormalBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAG1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAA0B,MAAM,sCAAsC,CAAC;AAItG;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QAcnD;;;WAGG;QAEI,yBAAoB,GAAY,KAAK,CAAC;QAE7C;;WAEG;QAEI,iCAA4B,GAAY,IAAI,CAAC;QAEpD;;WAEG;QAEI,kCAA6B,GAAY,IAAI,CAA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AAe;QAChF,KAAK,CAAC,YAAY,CAAC,mBAAmB,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAExD,IAAI,CAAC,oBAAoB,GAAG,mBAAmB,CAAC,oBAAoB,CAAC;QACrE,IAAI,CAAC,4BAA4B,GAAG,mBAAmB,CAAC,4BAA4B,CAAC;QACrF,IAAI,CAAC,6BAA6B,GAAG,mBAAmB,CAAC,6BAA6B,CAAC;IAC3F,CAAC;CACJ;AAvJU;IADN,sBAAsB,CAAC,kDAAkD,0CAAkC,YAAY,EAAE,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;iEAC7G;AAMtC;IADN,sBAAsB,CAAC,+CAA+C,0CAAkC,YAAY,EAAE,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;yEACnG;AAM7C;IADN,sBAAsB,CAAC,gDAAgD,0CAAkC,YAAY,EAAE,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;0EACnG;AA6IzD,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\nimport type { Scene } from \"../../../../scene\";\r\nimport { ShaderLanguage } from \"../../../../Materials/shaderLanguage\";\r\n\r\n/**\r\n * Block used to convert a height vector to a normal\r\n */\r\nexport class HeightToNormalBlock extends NodeMaterialBlock {\r\n /**\r\n * Creates a new HeightToNormalBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment);\r\n\r\n this.registerInput(\"input\", NodeMaterialBlockConnectionPointTypes.Float);\r\n this.registerInput(\"worldPosition\", NodeMaterialBlockConnectionPointTypes.Vector3);\r\n this.registerInput(\"worldNormal\", NodeMaterialBlockConnectionPointTypes.Vector3);\r\n this.registerInput(\"worldTangent\", NodeMaterialBlockConnectionPointTypes.AutoDetect, true);\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Vector4);\r\n this.registerOutput(\"xyz\", NodeMaterialBlockConnectionPointTypes.Vector3);\r\n\r\n this._inputs[3].addExcludedConnectionPointFromAllowedTypes(\r\n NodeMaterialBlockConnectionPointTypes.Color3 | NodeMaterialBlockConnectionPointTypes.Vector3 | NodeMaterialBlockConnectionPointTypes.Vector4\r\n );\r\n }\r\n\r\n /**\r\n * Defines if the output should be generated in world or tangent space.\r\n * Note that in tangent space the result is also scaled by 0.5 and offsetted by 0.5 so that it can directly be used as a PerturbNormal.normalMapColor input\r\n */\r\n @editableInPropertyPage(\"Generate in world space instead of tangent space\", PropertyTypeForEdition.Boolean, \"PROPERTIES\", { notifiers: { update: true } })\r\n public generateInWorldSpace: boolean = false;\r\n\r\n /**\r\n * Defines that the worldNormal input will be normalized by the HeightToNormal block before being used\r\n */\r\n @editableInPropertyPage(\"Force normalization for the worldNormal input\", PropertyTypeForEdition.Boolean, \"PROPERTIES\", { notifiers: { update: true } })\r\n public automaticNormalizationNormal: boolean = true;\r\n\r\n /**\r\n * Defines that the worldTangent input will be normalized by the HeightToNormal block before being used\r\n */\r\n @editableInPropertyPage(\"Force normalization for the worldTangent input\", PropertyTypeForEdition.Boolean, \"PROPERTIES\", { notifiers: { update: true } })\r\n public automaticNormalizationTangent: boolean = true;\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"HeightToNormalBlock\";\r\n }\r\n\r\n /**\r\n * Gets the input component\r\n */\r\n public get input(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the position component\r\n */\r\n public get worldPosition(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the normal component\r\n */\r\n public get worldNormal(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the tangent component\r\n */\r\n public get worldTangent(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the xyz component\r\n */\r\n public get xyz(): NodeMaterialConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const output = this._outputs[0];\r\n const isWebGPU = state.shaderLanguage === ShaderLanguage.WGSL;\r\n const fPrefix = state.fSuffix;\r\n\r\n if (!this.generateInWorldSpace && !this.worldTangent.isConnected) {\r\n state.sharedData.raiseBuildError(`You must connect the 'worldTangent' input of the ${this.name} block!`);\r\n }\r\n\r\n const startCode = this.generateInWorldSpace\r\n ? \"\"\r\n : `\r\n vec3 biTangent = cross(norm, tgt);\r\n mat3 TBN = mat3(tgt, biTangent, norm);\r\n `;\r\n\r\n const endCode = this.generateInWorldSpace\r\n ? \"\"\r\n : `\r\n result = TBN * result;\r\n result = result * vec3(0.5) + vec3(0.5);\r\n `;\r\n\r\n let heightToNormal = `\r\n vec4 heightToNormal(float height, vec3 position, vec3 tangent, vec3 normal) {\r\n vec3 tgt = ${this.automaticNormalizationTangent ? \"normalize(tangent);\" : \"tangent;\"}\r\n vec3 norm = ${this.automaticNormalizationNormal ? \"normalize(normal);\" : \"normal;\"}\r\n ${startCode}\r\n vec3 worlddX = dFdx(position);\r\n vec3 worlddY = dFdy(position);\r\n vec3 crossX = cross(norm, worlddX);\r\n vec3 crossY = cross(worlddY, norm);\r\n float d = abs(dot(crossY, worlddX));\r\n vec3 inToNormal = vec3(((((height + dFdx(height)) - height) * crossY) + (((height + dFdy(height)) - height) * crossX)) * sign(d));\r\n inToNormal.y *= -1.0;\r\n vec3 result = normalize((d * norm) - inToNormal);\r\n ${endCode}\r\n return vec4(result, 0.);\r\n }`;\r\n\r\n if (isWebGPU) {\r\n heightToNormal = state._babylonSLtoWGSL(heightToNormal);\r\n } else {\r\n state._emitExtension(\"derivatives\", \"#extension GL_OES_standard_derivatives : enable\");\r\n }\r\n state._emitFunction(\"heightToNormal\", heightToNormal, \"// heightToNormal\");\r\n state.compilationString +=\r\n state._declareOutput(output) +\r\n ` = heightToNormal(${this.input.associatedVariableName}, ${this.worldPosition.associatedVariableName}, ${\r\n this.worldTangent.isConnected ? this.worldTangent.associatedVariableName : `vec3${fPrefix}(0.)`\r\n }.xyz, ${this.worldNormal.associatedVariableName});\\n`;\r\n\r\n if (this.xyz.hasEndpoints) {\r\n state.compilationString += state._declareOutput(this.xyz) + ` = ${this.output.associatedVariableName}.xyz;\\n`;\r\n }\r\n\r\n return this;\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode();\r\n codeString += `${this._codeVariableName}.generateInWorldSpace = ${this.generateInWorldSpace};\\n`;\r\n codeString += `${this._codeVariableName}.automaticNormalizationNormal = ${this.automaticNormalizationNormal};\\n`;\r\n codeString += `${this._codeVariableName}.automaticNormalizationTangent = ${this.automaticNormalizationTangent};\\n`;\r\n\r\n return codeString;\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.generateInWorldSpace = this.generateInWorldSpace;\r\n serializationObject.automaticNormalizationNormal = this.automaticNormalizationNormal;\r\n serializationObject.automaticNormalizationTangent = this.automaticNormalizationTangent;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {\r\n super._deserialize(serializationObject, scene, rootUrl);\r\n\r\n this.generateInWorldSpace = serializationObject.generateInWorldSpace;\r\n this.automaticNormalizationNormal = serializationObject.automaticNormalizationNormal;\r\n this.automaticNormalizationTangent = serializationObject.automaticNormalizationTangent;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.HeightToNormalBlock\", HeightToNormalBlock);\r\n"]}
1
+ {"version":3,"file":"heightToNormalBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/Fragment/heightToNormalBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAG1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAA0B,MAAM,sCAAsC,CAAC;AAItG;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QAcnD;;;WAGG;QAEI,yBAAoB,GAAY,KAAK,CAAC;QAE7C;;WAEG;QAEI,iCAA4B,GAAY,IAAI,CAAC;QAEpD;;WAEG;QAEI,kCAA6B,GAAY,IAAI,CAAC;QA7BjD,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,KAAK,CAAC,CAAC;QACzE,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,qCAAqC,CAAC,OAAO,CAAC,CAAC;QACnF,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,qCAAqC,CAAC,OAAO,CAAC,CAAC;QACjF,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,qCAAqC,CAAC,UAAU,EAAE,IAAI,CAA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;AAjKU;IADN,sBAAsB,CAAC,kDAAkD,0CAAkC,YAAY,EAAE,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;iEAC7G;AAMtC;IADN,sBAAsB,CAAC,+CAA+C,0CAAkC,YAAY,EAAE,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;yEACnG;AAM7C;IADN,sBAAsB,CAAC,gDAAgD,0CAAkC,YAAY,EAAE,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;0EACnG;AAuJzD,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\nimport type { Scene } from \"../../../../scene\";\r\nimport { ShaderLanguage } from \"../../../../Materials/shaderLanguage\";\r\n\r\n/**\r\n * Block used to convert a height vector to a normal\r\n */\r\nexport class HeightToNormalBlock extends NodeMaterialBlock {\r\n /**\r\n * Creates a new HeightToNormalBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment);\r\n\r\n this.registerInput(\"input\", NodeMaterialBlockConnectionPointTypes.Float);\r\n this.registerInput(\"worldPosition\", NodeMaterialBlockConnectionPointTypes.Vector3);\r\n this.registerInput(\"worldNormal\", NodeMaterialBlockConnectionPointTypes.Vector3);\r\n this.registerInput(\"worldTangent\", NodeMaterialBlockConnectionPointTypes.AutoDetect, true);\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Vector4);\r\n this.registerOutput(\"xyz\", NodeMaterialBlockConnectionPointTypes.Vector3);\r\n\r\n this._inputs[3].addExcludedConnectionPointFromAllowedTypes(\r\n NodeMaterialBlockConnectionPointTypes.Color3 | NodeMaterialBlockConnectionPointTypes.Vector3 | NodeMaterialBlockConnectionPointTypes.Vector4\r\n );\r\n }\r\n\r\n /**\r\n * Defines if the output should be generated in world or tangent space.\r\n * Note that in tangent space the result is also scaled by 0.5 and offsetted by 0.5 so that it can directly be used as a PerturbNormal.normalMapColor input\r\n */\r\n @editableInPropertyPage(\"Generate in world space instead of tangent space\", PropertyTypeForEdition.Boolean, \"PROPERTIES\", { notifiers: { update: true } })\r\n public generateInWorldSpace: boolean = false;\r\n\r\n /**\r\n * Defines that the worldNormal input will be normalized by the HeightToNormal block before being used\r\n */\r\n @editableInPropertyPage(\"Force normalization for the worldNormal input\", PropertyTypeForEdition.Boolean, \"PROPERTIES\", { notifiers: { update: true } })\r\n public automaticNormalizationNormal: boolean = true;\r\n\r\n /**\r\n * Defines that the worldTangent input will be normalized by the HeightToNormal block before being used\r\n */\r\n @editableInPropertyPage(\"Force normalization for the worldTangent input\", PropertyTypeForEdition.Boolean, \"PROPERTIES\", { notifiers: { update: true } })\r\n public automaticNormalizationTangent: boolean = true;\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"HeightToNormalBlock\";\r\n }\r\n\r\n /**\r\n * Gets the input component\r\n */\r\n public get input(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the position component\r\n */\r\n public get worldPosition(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the normal component\r\n */\r\n public get worldNormal(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the tangent component\r\n */\r\n public get worldTangent(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the xyz component\r\n */\r\n public get xyz(): NodeMaterialConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const output = this._outputs[0];\r\n const isWebGPU = state.shaderLanguage === ShaderLanguage.WGSL;\r\n const fPrefix = state.fSuffix;\r\n\r\n if (!this.generateInWorldSpace && !this.worldTangent.isConnected) {\r\n state.sharedData.raiseBuildError(`You must connect the 'worldTangent' input of the ${this.name} block!`);\r\n }\r\n\r\n const startCode = this.generateInWorldSpace\r\n ? \"\"\r\n : `\r\n vec3 biTangent = cross(norm, tgt);\r\n mat3 TBN = mat3(tgt, biTangent, norm);\r\n `;\r\n\r\n const endCode = this.generateInWorldSpace\r\n ? \"\"\r\n : `\r\n result = TBN * result;\r\n result = result * vec3(0.5) + vec3(0.5);\r\n `;\r\n\r\n let heightToNormal = `\r\n vec4 heightToNormal(float height, vec3 position, vec3 tangent, vec3 normal) {\r\n vec3 tgt = ${this.automaticNormalizationTangent ? \"normalize(tangent);\" : \"tangent;\"}\r\n vec3 norm = ${this.automaticNormalizationNormal ? \"normalize(normal);\" : \"normal;\"}\r\n ${startCode}\r\n vec3 worlddX = dFdx(position);\r\n vec3 worlddY = dFdy(position);\r\n vec3 crossX = cross(norm, worlddX);\r\n vec3 crossY = cross(worlddY, norm);\r\n float d = abs(dot(crossY, worlddX));\r\n vec3 inToNormal = vec3(((((height + dFdx(height)) - height) * crossY) + (((height + dFdy(height)) - height) * crossX)) * sign(d));\r\n inToNormal.y *= -1.0;\r\n vec3 result = normalize((d * norm) - inToNormal);\r\n ${endCode}\r\n return vec4(result, 0.);\r\n }`;\r\n\r\n if (isWebGPU) {\r\n heightToNormal = state._babylonSLtoWGSL(heightToNormal);\r\n } else {\r\n state._emitExtension(\"derivatives\", \"#extension GL_OES_standard_derivatives : enable\");\r\n }\r\n state._emitFunction(\"heightToNormal\", heightToNormal, \"// heightToNormal\");\r\n state.compilationString +=\r\n state._declareOutput(output) +\r\n ` = heightToNormal(${this.input.associatedVariableName}, ${this.worldPosition.associatedVariableName}, ${\r\n this.worldTangent.isConnected ? this.worldTangent.associatedVariableName : `vec3${fPrefix}(0.)`\r\n }.xyz, ${this.worldNormal.associatedVariableName});\\n`;\r\n\r\n if (this.xyz.hasEndpoints) {\r\n state.compilationString += state._declareOutput(this.xyz) + ` = ${this.output.associatedVariableName}.xyz;\\n`;\r\n }\r\n\r\n return this;\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode();\r\n codeString += `${this._codeVariableName}.generateInWorldSpace = ${this.generateInWorldSpace};\\n`;\r\n codeString += `${this._codeVariableName}.automaticNormalizationNormal = ${this.automaticNormalizationNormal};\\n`;\r\n codeString += `${this._codeVariableName}.automaticNormalizationTangent = ${this.automaticNormalizationTangent};\\n`;\r\n\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes the block\r\n * @returns the serialized object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.generateInWorldSpace = this.generateInWorldSpace;\r\n serializationObject.automaticNormalizationNormal = this.automaticNormalizationNormal;\r\n serializationObject.automaticNormalizationTangent = this.automaticNormalizationTangent;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Deserializes the block\r\n * @param serializationObject - the serialization object\r\n * @param scene - the scene\r\n * @param rootUrl - the root url\r\n */\r\n public override _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {\r\n super._deserialize(serializationObject, scene, rootUrl);\r\n\r\n this.generateInWorldSpace = serializationObject.generateInWorldSpace;\r\n this.automaticNormalizationNormal = serializationObject.automaticNormalizationNormal;\r\n this.automaticNormalizationTangent = serializationObject.automaticNormalizationTangent;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.HeightToNormalBlock\", HeightToNormalBlock);\r\n"]}
@@ -42,11 +42,39 @@ export declare class ImageProcessingBlock extends NodeMaterialBlock {
42
42
  */
43
43
  initialize(state: NodeMaterialBuildState): void;
44
44
  private _initShaderSourceAsync;
45
+ /**
46
+ * Checks if the block is ready
47
+ * @param mesh - the mesh to check
48
+ * @param nodeMaterial - the node material
49
+ * @param defines - the material defines
50
+ * @returns true if ready
51
+ */
45
52
  isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
53
+ /**
54
+ * Prepare the list of defines
55
+ * @param defines - the material defines
56
+ * @param nodeMaterial - the node material
57
+ */
46
58
  prepareDefines(defines: NodeMaterialDefines, nodeMaterial: NodeMaterial): void;
59
+ /**
60
+ * Bind data to effect
61
+ * @param effect - the effect to bind to
62
+ * @param nodeMaterial - the node material
63
+ * @param mesh - the mesh to bind for
64
+ */
47
65
  bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
48
66
  protected _buildBlock(state: NodeMaterialBuildState): this;
49
67
  protected _dumpPropertiesCode(): string;
68
+ /**
69
+ * Serializes the block
70
+ * @returns the serialized object
71
+ */
50
72
  serialize(): any;
73
+ /**
74
+ * Deserializes the block
75
+ * @param serializationObject - the serialization object
76
+ * @param scene - the scene
77
+ * @param rootUrl - the root url
78
+ */
51
79
  _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
52
80
  }
@@ -89,6 +89,13 @@ export class ImageProcessingBlock extends NodeMaterialBlock {
89
89
  this._codeIsReady = true;
90
90
  this.onCodeIsReadyObservable.notifyObservers(this);
91
91
  }
92
+ /**
93
+ * Checks if the block is ready
94
+ * @param mesh - the mesh to check
95
+ * @param nodeMaterial - the node material
96
+ * @param defines - the material defines
97
+ * @returns true if ready
98
+ */
92
99
  isReady(mesh, nodeMaterial, defines) {
93
100
  if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {
94
101
  if (!nodeMaterial.imageProcessingConfiguration.isReady()) {
@@ -97,11 +104,22 @@ export class ImageProcessingBlock extends NodeMaterialBlock {
97
104
  }
98
105
  return true;
99
106
  }
107
+ /**
108
+ * Prepare the list of defines
109
+ * @param defines - the material defines
110
+ * @param nodeMaterial - the node material
111
+ */
100
112
  prepareDefines(defines, nodeMaterial) {
101
113
  if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {
102
114
  nodeMaterial.imageProcessingConfiguration.prepareDefines(defines);
103
115
  }
104
116
  }
117
+ /**
118
+ * Bind data to effect
119
+ * @param effect - the effect to bind to
120
+ * @param nodeMaterial - the node material
121
+ * @param mesh - the mesh to bind for
122
+ */
105
123
  bind(effect, nodeMaterial, mesh) {
106
124
  if (!mesh) {
107
125
  return;
@@ -172,11 +190,21 @@ export class ImageProcessingBlock extends NodeMaterialBlock {
172
190
  codeString += `${this._codeVariableName}.convertInputToLinearSpace = ${this.convertInputToLinearSpace};\n`;
173
191
  return codeString;
174
192
  }
193
+ /**
194
+ * Serializes the block
195
+ * @returns the serialized object
196
+ */
175
197
  serialize() {
176
198
  const serializationObject = super.serialize();
177
199
  serializationObject.convertInputToLinearSpace = this.convertInputToLinearSpace;
178
200
  return serializationObject;
179
201
  }
202
+ /**
203
+ * Deserializes the block
204
+ * @param serializationObject - the serialization object
205
+ * @param scene - the scene
206
+ * @param rootUrl - the root url
207
+ */
180
208
  _deserialize(serializationObject, scene, rootUrl) {
181
209
  super._deserialize(serializationObject, scene, rootUrl);
182
210
  this.convertInputToLinearSpace = serializationObject.convertInputToLinearSpace ?? true;
@@ -1 +1 @@
1
- {"version":3,"file":"imageProcessingBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/Fragment/imageProcessingBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,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ACxB,KAAK,CAAC,iBAAiB,IAAI,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,sBAAsB,SAAS,CAAC;YAClH,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEkB,mBAAmB;QAClC,IAAI,UAAU,GAAG,KAAK,CAAC,mBAAmB,EAAE,CAAC;QAE7C,UAAU,IAAI,GAAG,IAAI,CAAC,iBAAiB,gCAAgC,IAAI,CAAC,yBAAyB,KAAK,CAAC;QAE3G,OAAO,UAAU,CAAC;IACtB,CAAC;IAEe,SAAS;QACrB,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,CAAC;QAE/E,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEe,YAAY,CAAC,mBAAwB,EAAE,KAAY,EAAE,OAAe;QAChF,KAAK,CAAC,YAAY,CAAC,mBAAmB,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAExD,IAAI,CAAC,yBAAyB,GAAG,mBAAmB,CAAC,yBAAyB,IAAI,IAAI,CAAC;IAC3F,CAAC;CACJ;AA3LU;IADN,sBAAsB,CAAC,+BAA+B,0CAAkC,UAAU,CAAC;uEACnD;AA6LrD,aAAa,CAAC,8BAA8B,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport type { AbstractMesh } from \"../../../../Meshes/abstractMesh\";\r\nimport type { NodeMaterial, NodeMaterialDefines } from \"../../nodeMaterial\";\r\nimport type { Effect } from \"../../../effect\";\r\nimport type { Mesh } from \"../../../../Meshes/mesh\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { Scene } from \"../../../../scene\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Block used to add image processing support to fragment shader\r\n */\r\nexport class ImageProcessingBlock extends NodeMaterialBlock {\r\n /**\r\n * Create a new ImageProcessingBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment);\r\n\r\n this.registerInput(\"color\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Color4);\r\n this.registerOutput(\"rgb\", NodeMaterialBlockConnectionPointTypes.Color3);\r\n\r\n this._inputs[0].addExcludedConnectionPointFromAllowedTypes(\r\n NodeMaterialBlockConnectionPointTypes.Color3 |\r\n NodeMaterialBlockConnectionPointTypes.Color4 |\r\n NodeMaterialBlockConnectionPointTypes.Vector3 |\r\n NodeMaterialBlockConnectionPointTypes.Vector4\r\n );\r\n }\r\n\r\n /**\r\n * Defines if the input should be converted to linear space (default: true)\r\n */\r\n @editableInPropertyPage(\"Convert input to linear space\", PropertyTypeForEdition.Boolean, \"ADVANCED\")\r\n public convertInputToLinearSpace: boolean = true;\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ImageProcessingBlock\";\r\n }\r\n\r\n /**\r\n * Gets the color input component\r\n */\r\n public get color(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the rgb component\r\n */\r\n public get rgb(): NodeMaterialConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n /**\r\n * Initialize the block and prepare the context for build\r\n * @param state defines the state that will be used for the build\r\n */\r\n public override initialize(state: NodeMaterialBuildState) {\r\n state._excludeVariableName(\"exposureLinear\");\r\n state._excludeVariableName(\"contrast\");\r\n state._excludeVariableName(\"vInverseScreenSize\");\r\n state._excludeVariableName(\"vignetteSettings1\");\r\n state._excludeVariableName(\"vignetteSettings2\");\r\n state._excludeVariableName(\"vCameraColorCurveNegative\");\r\n state._excludeVariableName(\"vCameraColorCurveNeutral\");\r\n state._excludeVariableName(\"vCameraColorCurvePositive\");\r\n state._excludeVariableName(\"txColorTransform\");\r\n state._excludeVariableName(\"colorTransformSettings\");\r\n state._excludeVariableName(\"ditherIntensity\");\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._initShaderSourceAsync(state.shaderLanguage);\r\n }\r\n\r\n private async _initShaderSourceAsync(shaderLanguage: ShaderLanguage) {\r\n this._codeIsReady = false;\r\n\r\n if (shaderLanguage === ShaderLanguage.WGSL) {\r\n await Promise.all([\r\n import(\"../../../../ShadersWGSL/ShadersInclude/helperFunctions\"),\r\n import(\"../../../../ShadersWGSL/ShadersInclude/imageProcessingDeclaration\"),\r\n import(\"../../../../ShadersWGSL/ShadersInclude/imageProcessingFunctions\"),\r\n ]);\r\n } else {\r\n await Promise.all([\r\n import(\"../../../../Shaders/ShadersInclude/helperFunctions\"),\r\n import(\"../../../../Shaders/ShadersInclude/imageProcessingDeclaration\"),\r\n import(\"../../../../Shaders/ShadersInclude/imageProcessingFunctions\"),\r\n ]);\r\n }\r\n\r\n this._codeIsReady = true;\r\n this.onCodeIsReadyObservable.notifyObservers(this);\r\n }\r\n\r\n public override isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines) {\r\n if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {\r\n if (!nodeMaterial.imageProcessingConfiguration.isReady()) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n public override prepareDefines(defines: NodeMaterialDefines, nodeMaterial: NodeMaterial) {\r\n if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {\r\n nodeMaterial.imageProcessingConfiguration.prepareDefines(defines);\r\n }\r\n }\r\n\r\n public override bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh) {\r\n if (!mesh) {\r\n return;\r\n }\r\n\r\n if (!nodeMaterial.imageProcessingConfiguration) {\r\n return;\r\n }\r\n\r\n nodeMaterial.imageProcessingConfiguration.bind(effect);\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n // Register for defines\r\n state.sharedData.blocksWithDefines.push(this);\r\n\r\n // Register for blocking\r\n state.sharedData.blockingBlocks.push(this);\r\n\r\n // Register for binding\r\n state.sharedData.bindableBlocks.push(this);\r\n\r\n // Uniforms\r\n state.uniforms.push(\"exposureLinear\");\r\n state.uniforms.push(\"contrast\");\r\n state.uniforms.push(\"vInverseScreenSize\");\r\n state.uniforms.push(\"vignetteSettings1\");\r\n state.uniforms.push(\"vignetteSettings2\");\r\n state.uniforms.push(\"vCameraColorCurveNegative\");\r\n state.uniforms.push(\"vCameraColorCurveNeutral\");\r\n state.uniforms.push(\"vCameraColorCurvePositive\");\r\n state.uniforms.push(\"txColorTransform\");\r\n state.uniforms.push(\"colorTransformSettings\");\r\n state.uniforms.push(\"ditherIntensity\");\r\n\r\n // Emit code\r\n const color = this.color;\r\n const output = this._outputs[0];\r\n const comments = `//${this.name}`;\r\n const overrideText = state.shaderLanguage === ShaderLanguage.WGSL ? \"Vec3\" : \"\";\r\n\r\n state._emitFunctionFromInclude(\"helperFunctions\", comments);\r\n state._emitFunctionFromInclude(\"imageProcessingDeclaration\", comments);\r\n state._emitFunctionFromInclude(\"imageProcessingFunctions\", comments);\r\n\r\n if (color.connectedPoint?.isConnected) {\r\n const isVec4Input =\r\n color.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Color4 || color.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Vector4;\r\n // For vec3 inputs (Color3/Vector3), use 1.0 for alpha since they have no .a component\r\n const alpha = isVec4Input ? `${color.associatedVariableName}.a` : \"1.0\";\r\n\r\n if (isVec4Input) {\r\n state.compilationString += `${state._declareOutput(output)} = ${color.associatedVariableName};\\n`;\r\n } else {\r\n state.compilationString += `${state._declareOutput(output)} = vec4${state.fSuffix}(${color.associatedVariableName}, 1.0);\\n`;\r\n }\r\n state.compilationString += `#ifdef IMAGEPROCESSINGPOSTPROCESS\\n`;\r\n if (this.convertInputToLinearSpace) {\r\n state.compilationString += `${output.associatedVariableName} = vec4${state.fSuffix}(toLinearSpace${overrideText}(${color.associatedVariableName}.rgb), ${alpha});\\n`;\r\n }\r\n state.compilationString += `#else\\n`;\r\n state.compilationString += `#ifdef IMAGEPROCESSING\\n`;\r\n if (this.convertInputToLinearSpace) {\r\n state.compilationString += `${output.associatedVariableName} = vec4${state.fSuffix}(toLinearSpace${overrideText}(${color.associatedVariableName}.rgb), ${alpha});\\n`;\r\n }\r\n state.compilationString += `${output.associatedVariableName} = applyImageProcessing(${output.associatedVariableName});\\n`;\r\n state.compilationString += `#endif\\n`;\r\n state.compilationString += `#endif\\n`;\r\n\r\n if (this.rgb.hasEndpoints) {\r\n state.compilationString += state._declareOutput(this.rgb) + ` = ${this.output.associatedVariableName}.xyz;\\n`;\r\n }\r\n }\r\n\r\n return this;\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode();\r\n\r\n codeString += `${this._codeVariableName}.convertInputToLinearSpace = ${this.convertInputToLinearSpace};\\n`;\r\n\r\n return codeString;\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.convertInputToLinearSpace = this.convertInputToLinearSpace;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {\r\n super._deserialize(serializationObject, scene, rootUrl);\r\n\r\n this.convertInputToLinearSpace = serializationObject.convertInputToLinearSpace ?? true;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ImageProcessingBlock\", ImageProcessingBlock);\r\n"]}
1
+ {"version":3,"file":"imageProcessingBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/Fragment/imageProcessingBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAMhF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,sBAAsB,EAA0B,MAAM,sCAAsC,CAAC;AAItG;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,iBAAiB;IACvD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QAcnD;;WAEG;QAEI,8BAAyB,GAAY,IAAI,CAAC;QAhB7C,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC9E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,MAAM,CAAC,CAAC;QAC5E,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,qCAAqC,CAAC,MAAM,CAAC,CAAC;QAEzE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,0CAA0C,CACtD,qCAAqC,CAAC,MAAM;YACxC,qCAAqC,CAAC,MAAM;YAC5C,qCAAqC,CAAC,OAAO;YAC7C,qCAAqC,CAAC,OAAO,CACpD,CAAC;IACN,CAAC;IAQD;;;OAGG;IACa,YAAY;QACxB,OAAO,sBAAsB,CAAC;IAClC,CAAC;IAED;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B,CAAC,+BAA+B,0CAAkC,UAAU,CAAC;uEACnD;AAyNrD,aAAa,CAAC,8BAA8B,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport type { AbstractMesh } from \"../../../../Meshes/abstractMesh\";\r\nimport type { NodeMaterial, NodeMaterialDefines } from \"../../nodeMaterial\";\r\nimport type { Effect } from \"../../../effect\";\r\nimport type { Mesh } from \"../../../../Meshes/mesh\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { Scene } from \"../../../../scene\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Block used to add image processing support to fragment shader\r\n */\r\nexport class ImageProcessingBlock extends NodeMaterialBlock {\r\n /**\r\n * Create a new ImageProcessingBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment);\r\n\r\n this.registerInput(\"color\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Color4);\r\n this.registerOutput(\"rgb\", NodeMaterialBlockConnectionPointTypes.Color3);\r\n\r\n this._inputs[0].addExcludedConnectionPointFromAllowedTypes(\r\n NodeMaterialBlockConnectionPointTypes.Color3 |\r\n NodeMaterialBlockConnectionPointTypes.Color4 |\r\n NodeMaterialBlockConnectionPointTypes.Vector3 |\r\n NodeMaterialBlockConnectionPointTypes.Vector4\r\n );\r\n }\r\n\r\n /**\r\n * Defines if the input should be converted to linear space (default: true)\r\n */\r\n @editableInPropertyPage(\"Convert input to linear space\", PropertyTypeForEdition.Boolean, \"ADVANCED\")\r\n public convertInputToLinearSpace: boolean = true;\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ImageProcessingBlock\";\r\n }\r\n\r\n /**\r\n * Gets the color input component\r\n */\r\n public get color(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the rgb component\r\n */\r\n public get rgb(): NodeMaterialConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n /**\r\n * Initialize the block and prepare the context for build\r\n * @param state defines the state that will be used for the build\r\n */\r\n public override initialize(state: NodeMaterialBuildState) {\r\n state._excludeVariableName(\"exposureLinear\");\r\n state._excludeVariableName(\"contrast\");\r\n state._excludeVariableName(\"vInverseScreenSize\");\r\n state._excludeVariableName(\"vignetteSettings1\");\r\n state._excludeVariableName(\"vignetteSettings2\");\r\n state._excludeVariableName(\"vCameraColorCurveNegative\");\r\n state._excludeVariableName(\"vCameraColorCurveNeutral\");\r\n state._excludeVariableName(\"vCameraColorCurvePositive\");\r\n state._excludeVariableName(\"txColorTransform\");\r\n state._excludeVariableName(\"colorTransformSettings\");\r\n state._excludeVariableName(\"ditherIntensity\");\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._initShaderSourceAsync(state.shaderLanguage);\r\n }\r\n\r\n private async _initShaderSourceAsync(shaderLanguage: ShaderLanguage) {\r\n this._codeIsReady = false;\r\n\r\n if (shaderLanguage === ShaderLanguage.WGSL) {\r\n await Promise.all([\r\n import(\"../../../../ShadersWGSL/ShadersInclude/helperFunctions\"),\r\n import(\"../../../../ShadersWGSL/ShadersInclude/imageProcessingDeclaration\"),\r\n import(\"../../../../ShadersWGSL/ShadersInclude/imageProcessingFunctions\"),\r\n ]);\r\n } else {\r\n await Promise.all([\r\n import(\"../../../../Shaders/ShadersInclude/helperFunctions\"),\r\n import(\"../../../../Shaders/ShadersInclude/imageProcessingDeclaration\"),\r\n import(\"../../../../Shaders/ShadersInclude/imageProcessingFunctions\"),\r\n ]);\r\n }\r\n\r\n this._codeIsReady = true;\r\n this.onCodeIsReadyObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Checks if the block is ready\r\n * @param mesh - the mesh to check\r\n * @param nodeMaterial - the node material\r\n * @param defines - the material defines\r\n * @returns true if ready\r\n */\r\n public override isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines) {\r\n if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {\r\n if (!nodeMaterial.imageProcessingConfiguration.isReady()) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Prepare the list of defines\r\n * @param defines - the material defines\r\n * @param nodeMaterial - the node material\r\n */\r\n public override prepareDefines(defines: NodeMaterialDefines, nodeMaterial: NodeMaterial) {\r\n if (defines._areImageProcessingDirty && nodeMaterial.imageProcessingConfiguration) {\r\n nodeMaterial.imageProcessingConfiguration.prepareDefines(defines);\r\n }\r\n }\r\n\r\n /**\r\n * Bind data to effect\r\n * @param effect - the effect to bind to\r\n * @param nodeMaterial - the node material\r\n * @param mesh - the mesh to bind for\r\n */\r\n public override bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh) {\r\n if (!mesh) {\r\n return;\r\n }\r\n\r\n if (!nodeMaterial.imageProcessingConfiguration) {\r\n return;\r\n }\r\n\r\n nodeMaterial.imageProcessingConfiguration.bind(effect);\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n // Register for defines\r\n state.sharedData.blocksWithDefines.push(this);\r\n\r\n // Register for blocking\r\n state.sharedData.blockingBlocks.push(this);\r\n\r\n // Register for binding\r\n state.sharedData.bindableBlocks.push(this);\r\n\r\n // Uniforms\r\n state.uniforms.push(\"exposureLinear\");\r\n state.uniforms.push(\"contrast\");\r\n state.uniforms.push(\"vInverseScreenSize\");\r\n state.uniforms.push(\"vignetteSettings1\");\r\n state.uniforms.push(\"vignetteSettings2\");\r\n state.uniforms.push(\"vCameraColorCurveNegative\");\r\n state.uniforms.push(\"vCameraColorCurveNeutral\");\r\n state.uniforms.push(\"vCameraColorCurvePositive\");\r\n state.uniforms.push(\"txColorTransform\");\r\n state.uniforms.push(\"colorTransformSettings\");\r\n state.uniforms.push(\"ditherIntensity\");\r\n\r\n // Emit code\r\n const color = this.color;\r\n const output = this._outputs[0];\r\n const comments = `//${this.name}`;\r\n const overrideText = state.shaderLanguage === ShaderLanguage.WGSL ? \"Vec3\" : \"\";\r\n\r\n state._emitFunctionFromInclude(\"helperFunctions\", comments);\r\n state._emitFunctionFromInclude(\"imageProcessingDeclaration\", comments);\r\n state._emitFunctionFromInclude(\"imageProcessingFunctions\", comments);\r\n\r\n if (color.connectedPoint?.isConnected) {\r\n const isVec4Input =\r\n color.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Color4 || color.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Vector4;\r\n // For vec3 inputs (Color3/Vector3), use 1.0 for alpha since they have no .a component\r\n const alpha = isVec4Input ? `${color.associatedVariableName}.a` : \"1.0\";\r\n\r\n if (isVec4Input) {\r\n state.compilationString += `${state._declareOutput(output)} = ${color.associatedVariableName};\\n`;\r\n } else {\r\n state.compilationString += `${state._declareOutput(output)} = vec4${state.fSuffix}(${color.associatedVariableName}, 1.0);\\n`;\r\n }\r\n state.compilationString += `#ifdef IMAGEPROCESSINGPOSTPROCESS\\n`;\r\n if (this.convertInputToLinearSpace) {\r\n state.compilationString += `${output.associatedVariableName} = vec4${state.fSuffix}(toLinearSpace${overrideText}(${color.associatedVariableName}.rgb), ${alpha});\\n`;\r\n }\r\n state.compilationString += `#else\\n`;\r\n state.compilationString += `#ifdef IMAGEPROCESSING\\n`;\r\n if (this.convertInputToLinearSpace) {\r\n state.compilationString += `${output.associatedVariableName} = vec4${state.fSuffix}(toLinearSpace${overrideText}(${color.associatedVariableName}.rgb), ${alpha});\\n`;\r\n }\r\n state.compilationString += `${output.associatedVariableName} = applyImageProcessing(${output.associatedVariableName});\\n`;\r\n state.compilationString += `#endif\\n`;\r\n state.compilationString += `#endif\\n`;\r\n\r\n if (this.rgb.hasEndpoints) {\r\n state.compilationString += state._declareOutput(this.rgb) + ` = ${this.output.associatedVariableName}.xyz;\\n`;\r\n }\r\n }\r\n\r\n return this;\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode();\r\n\r\n codeString += `${this._codeVariableName}.convertInputToLinearSpace = ${this.convertInputToLinearSpace};\\n`;\r\n\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes the block\r\n * @returns the serialized object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.convertInputToLinearSpace = this.convertInputToLinearSpace;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Deserializes the block\r\n * @param serializationObject - the serialization object\r\n * @param scene - the scene\r\n * @param rootUrl - the root url\r\n */\r\n public override _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {\r\n super._deserialize(serializationObject, scene, rootUrl);\r\n\r\n this.convertInputToLinearSpace = serializationObject.convertInputToLinearSpace ?? true;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ImageProcessingBlock\", ImageProcessingBlock);\r\n"]}