@onerjs/core 9.0.1 → 9.0.3

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 (476) hide show
  1. package/Animations/animationGroup.pure.js.map +1 -1
  2. package/Buffers/buffer.pure.js +4 -0
  3. package/Buffers/buffer.pure.js.map +1 -1
  4. package/Cameras/camera.pure.d.ts +14 -0
  5. package/Cameras/camera.pure.js +15 -0
  6. package/Cameras/camera.pure.js.map +1 -1
  7. package/Compute/computeShader.pure.d.ts +2 -1
  8. package/Compute/computeShader.pure.js +29 -10
  9. package/Compute/computeShader.pure.js.map +1 -1
  10. package/Culling/ray.core.js +22 -9
  11. package/Culling/ray.core.js.map +1 -1
  12. package/Engines/IDrawContext.d.ts +2 -0
  13. package/Engines/IDrawContext.js.map +1 -1
  14. package/Engines/Native/nativeInterfaces.d.ts +55 -4
  15. package/Engines/Native/nativeInterfaces.js.map +1 -1
  16. package/Engines/Native/nativeRenderTargetWrapper.d.ts +1 -0
  17. package/Engines/Native/nativeRenderTargetWrapper.js +5 -1
  18. package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
  19. package/Engines/Processors/shaderCodeInliner.d.ts +2 -0
  20. package/Engines/Processors/shaderCodeInliner.js +251 -6
  21. package/Engines/Processors/shaderCodeInliner.js.map +1 -1
  22. package/Engines/Processors/shaderProcessor.js +10 -1
  23. package/Engines/Processors/shaderProcessor.js.map +1 -1
  24. package/Engines/WebGPU/Extensions/engine.debugging.pure.js +12 -0
  25. package/Engines/WebGPU/Extensions/engine.debugging.pure.js.map +1 -1
  26. package/Engines/WebGPU/Extensions/engine.multiRender.pure.js +0 -1
  27. package/Engines/WebGPU/Extensions/engine.multiRender.pure.js.map +1 -1
  28. package/Engines/WebGPU/Extensions/engine.query.pure.js +5 -0
  29. package/Engines/WebGPU/Extensions/engine.query.pure.js.map +1 -1
  30. package/Engines/WebGPU/webgpuBufferManager.js +7 -0
  31. package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
  32. package/Engines/WebGPU/webgpuCacheTextureView.d.ts +1 -1
  33. package/Engines/WebGPU/webgpuCacheTextureView.js +20 -8
  34. package/Engines/WebGPU/webgpuCacheTextureView.js.map +1 -1
  35. package/Engines/WebGPU/webgpuDrawContext.d.ts +2 -0
  36. package/Engines/WebGPU/webgpuDrawContext.js +6 -0
  37. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  38. package/Engines/WebGPU/webgpuQuerySet.d.ts +3 -3
  39. package/Engines/WebGPU/webgpuQuerySet.js +23 -9
  40. package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
  41. package/Engines/WebGPU/webgpuRenderPassCommandStream.d.ts +156 -0
  42. package/Engines/WebGPU/webgpuRenderPassCommandStream.js +323 -0
  43. package/Engines/WebGPU/webgpuRenderPassCommandStream.js.map +1 -0
  44. package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
  45. package/Engines/WebGPU/webgpuTextureManager.js +4 -3
  46. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  47. package/Engines/WebGPU/webgpuTimestampQuery.d.ts +3 -1
  48. package/Engines/WebGPU/webgpuTimestampQuery.js +9 -6
  49. package/Engines/WebGPU/webgpuTimestampQuery.js.map +1 -1
  50. package/Engines/abstractEngine.pure.d.ts +2 -0
  51. package/Engines/abstractEngine.pure.js +14 -5
  52. package/Engines/abstractEngine.pure.js.map +1 -1
  53. package/Engines/constants.d.ts +6 -0
  54. package/Engines/constants.js +6 -0
  55. package/Engines/constants.js.map +1 -1
  56. package/Engines/engine.d.ts +198 -24
  57. package/Engines/pure.d.ts +1 -0
  58. package/Engines/pure.js +1 -0
  59. package/Engines/pure.js.map +1 -1
  60. package/Engines/renderCommandBatcher.pure.d.ts +16 -0
  61. package/Engines/renderCommandBatcher.pure.js +24 -0
  62. package/Engines/renderCommandBatcher.pure.js.map +1 -0
  63. package/Engines/thinEngine.functions.js +3 -2
  64. package/Engines/thinEngine.functions.js.map +1 -1
  65. package/Engines/thinEngine.pure.js +18 -2
  66. package/Engines/thinEngine.pure.js.map +1 -1
  67. package/Engines/thinNativeEngine.pure.d.ts +10 -7
  68. package/Engines/thinNativeEngine.pure.js +117 -46
  69. package/Engines/thinNativeEngine.pure.js.map +1 -1
  70. package/Engines/thinWebGPUEngine.d.ts +8 -0
  71. package/Engines/thinWebGPUEngine.js +11 -0
  72. package/Engines/thinWebGPUEngine.js.map +1 -1
  73. package/Engines/webgpuEngine.pure.d.ts +60 -1
  74. package/Engines/webgpuEngine.pure.js +238 -42
  75. package/Engines/webgpuEngine.pure.js.map +1 -1
  76. package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.d.ts +3 -3
  77. package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.js +2 -1
  78. package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.js.map +1 -1
  79. package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.d.ts +3 -3
  80. package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.js +2 -1
  81. package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.js.map +1 -1
  82. package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.d.ts +5 -0
  83. package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.js +8 -0
  84. package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.js.map +1 -0
  85. package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.d.ts +77 -0
  86. package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.js +141 -0
  87. package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.js.map +1 -0
  88. package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.d.ts +5 -3
  89. package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.js +38 -7
  90. package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.js.map +1 -1
  91. package/FlowGraph/Blocks/Event/index.d.ts +1 -0
  92. package/FlowGraph/Blocks/Event/index.js +1 -0
  93. package/FlowGraph/Blocks/Event/index.js.map +1 -1
  94. package/FlowGraph/Blocks/Event/pure.d.ts +1 -0
  95. package/FlowGraph/Blocks/Event/pure.js +1 -0
  96. package/FlowGraph/Blocks/Event/pure.js.map +1 -1
  97. package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.d.ts +3 -3
  98. package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.js +2 -1
  99. package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.js.map +1 -1
  100. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.d.ts +3 -3
  101. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.js +2 -1
  102. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.js.map +1 -1
  103. package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.d.ts +3 -3
  104. package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.js +2 -1
  105. package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.js.map +1 -1
  106. package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.d.ts +3 -3
  107. package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.js +2 -1
  108. package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.js.map +1 -1
  109. package/FlowGraph/Blocks/allBlocks.pure.js +2 -0
  110. package/FlowGraph/Blocks/allBlocks.pure.js.map +1 -1
  111. package/FlowGraph/Blocks/flowGraphBlockFactory.js +2 -0
  112. package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
  113. package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +1 -0
  114. package/FlowGraph/Blocks/flowGraphBlockNames.js +1 -0
  115. package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
  116. package/FlowGraph/flowGraph.d.ts +12 -1
  117. package/FlowGraph/flowGraph.js +38 -0
  118. package/FlowGraph/flowGraph.js.map +1 -1
  119. package/FlowGraph/flowGraphCoordinator.d.ts +44 -0
  120. package/FlowGraph/flowGraphCoordinator.js +141 -0
  121. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  122. package/FlowGraph/flowGraphDataConnection.pure.js +41 -14
  123. package/FlowGraph/flowGraphDataConnection.pure.js.map +1 -1
  124. package/FlowGraph/flowGraphParser.js +105 -5
  125. package/FlowGraph/flowGraphParser.js.map +1 -1
  126. package/FlowGraph/flowGraphSoundAssets.d.ts +40 -0
  127. package/FlowGraph/flowGraphSoundAssets.js +33 -0
  128. package/FlowGraph/flowGraphSoundAssets.js.map +1 -0
  129. package/FlowGraph/index.d.ts +1 -0
  130. package/FlowGraph/index.js +1 -0
  131. package/FlowGraph/index.js.map +1 -1
  132. package/FlowGraph/pure.d.ts +1 -0
  133. package/FlowGraph/pure.js +1 -0
  134. package/FlowGraph/pure.js.map +1 -1
  135. package/FlowGraph/serialization.d.ts +8 -0
  136. package/FlowGraph/serialization.js +31 -12
  137. package/FlowGraph/serialization.js.map +1 -1
  138. package/FlowGraph/typeDefinitions.d.ts +25 -0
  139. package/FlowGraph/typeDefinitions.js.map +1 -1
  140. package/FrameGraph/Tasks/PostProcesses/taaTask.js +2 -0
  141. package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
  142. package/Instrumentation/engineInstrumentation.d.ts +1 -0
  143. package/Instrumentation/engineInstrumentation.js +25 -6
  144. package/Instrumentation/engineInstrumentation.js.map +1 -1
  145. package/Lights/Clustered/clusteredLightContainer.pure.js +2 -0
  146. package/Lights/Clustered/clusteredLightContainer.pure.js.map +1 -1
  147. package/Lights/Shadows/cascadedShadowGenerator.pure.d.ts +36 -1
  148. package/Lights/Shadows/cascadedShadowGenerator.pure.js +202 -27
  149. package/Lights/Shadows/cascadedShadowGenerator.pure.js.map +1 -1
  150. package/Lights/directionalLight.pure.d.ts +24 -10
  151. package/Lights/directionalLight.pure.js +29 -11
  152. package/Lights/directionalLight.pure.js.map +1 -1
  153. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +4 -4
  154. package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
  155. package/Materials/Node/Blocks/Dual/lightBlock.pure.js +1 -1
  156. package/Materials/Node/Blocks/Dual/lightBlock.pure.js.map +1 -1
  157. package/Materials/Node/Blocks/Input/inputBlock.pure.js +4 -0
  158. package/Materials/Node/Blocks/Input/inputBlock.pure.js.map +1 -1
  159. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.d.ts +9 -0
  160. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js +23 -3
  161. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js.map +1 -1
  162. package/Materials/PBR/openpbrMaterial.pure.js +1 -1
  163. package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
  164. package/Materials/PBR/pbrBaseMaterial.pure.d.ts +9 -0
  165. package/Materials/PBR/pbrBaseMaterial.pure.js +60 -1
  166. package/Materials/PBR/pbrBaseMaterial.pure.js.map +1 -1
  167. package/Materials/PBR/pbrBaseSimpleMaterial.d.ts +11 -0
  168. package/Materials/PBR/pbrBaseSimpleMaterial.js +21 -2
  169. package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
  170. package/Materials/PBR/pbrMaterial.pure.d.ts +12 -0
  171. package/Materials/PBR/pbrMaterial.pure.js +23 -3
  172. package/Materials/PBR/pbrMaterial.pure.js.map +1 -1
  173. package/Materials/Textures/Filtering/hdrIrradianceFiltering.d.ts +1 -0
  174. package/Materials/Textures/Filtering/hdrIrradianceFiltering.js +10 -0
  175. package/Materials/Textures/Filtering/hdrIrradianceFiltering.js.map +1 -1
  176. package/Materials/Textures/HTML/htmlInCanvasPolyfill.d.ts +5 -0
  177. package/Materials/Textures/HTML/htmlInCanvasPolyfill.js +7 -0
  178. package/Materials/Textures/HTML/htmlInCanvasPolyfill.js.map +1 -1
  179. package/Materials/Textures/HTML/htmlInteractionManager.d.ts +9 -3
  180. package/Materials/Textures/HTML/htmlInteractionManager.js +64 -5
  181. package/Materials/Textures/HTML/htmlInteractionManager.js.map +1 -1
  182. package/Materials/Textures/HTML/htmlTexture.d.ts +11 -11
  183. package/Materials/Textures/HTML/htmlTexture.js +106 -65
  184. package/Materials/Textures/HTML/htmlTexture.js.map +1 -1
  185. package/Materials/Textures/Loaders/internalTextureLoader.d.ts +2 -1
  186. package/Materials/Textures/Loaders/internalTextureLoader.js.map +1 -1
  187. package/Materials/Textures/Loaders/ktxTextureLoader.d.ts +2 -1
  188. package/Materials/Textures/Loaders/ktxTextureLoader.js +4 -50
  189. package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
  190. package/Materials/Textures/Procedurals/proceduralTexture.pure.js +10 -0
  191. package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
  192. package/Materials/Textures/dynamicTexture.pure.js +6 -0
  193. package/Materials/Textures/dynamicTexture.pure.js.map +1 -1
  194. package/Materials/Textures/ktx2encoderTypes.d.ts +51 -0
  195. package/Materials/Textures/ktx2encoderTypes.js +2 -0
  196. package/Materials/Textures/ktx2encoderTypes.js.map +1 -0
  197. package/Materials/Textures/renderTargetTexture.pure.js +10 -2
  198. package/Materials/Textures/renderTargetTexture.pure.js.map +1 -1
  199. package/Materials/Textures/texture.pure.js +7 -1
  200. package/Materials/Textures/texture.pure.js.map +1 -1
  201. package/Materials/Textures/textureMerger.d.ts +11 -0
  202. package/Materials/Textures/textureMerger.js +34 -19
  203. package/Materials/Textures/textureMerger.js.map +1 -1
  204. package/Materials/Textures/textureProcessor.d.ts +145 -0
  205. package/Materials/Textures/textureProcessor.js +445 -45
  206. package/Materials/Textures/textureProcessor.js.map +1 -1
  207. package/Materials/Textures/textureSampling.functions.d.ts +41 -0
  208. package/Materials/Textures/textureSampling.functions.js +82 -0
  209. package/Materials/Textures/textureSampling.functions.js.map +1 -0
  210. package/Materials/drawWrapper.d.ts +8 -0
  211. package/Materials/drawWrapper.js +19 -0
  212. package/Materials/drawWrapper.js.map +1 -1
  213. package/Materials/effect.pure.d.ts +6 -0
  214. package/Materials/effect.pure.js +28 -6
  215. package/Materials/effect.pure.js.map +1 -1
  216. package/Materials/effect.webgl.functions.pure.js +1 -1
  217. package/Materials/effect.webgl.functions.pure.js.map +1 -1
  218. package/Materials/material.pure.d.ts +5 -0
  219. package/Materials/material.pure.js +9 -2
  220. package/Materials/material.pure.js.map +1 -1
  221. package/Materials/materialFlags.d.ts +6 -0
  222. package/Materials/materialFlags.js +14 -0
  223. package/Materials/materialFlags.js.map +1 -1
  224. package/Materials/materialHelper.functions.d.ts +2 -1
  225. package/Materials/materialHelper.functions.js +36 -2
  226. package/Materials/materialHelper.functions.js.map +1 -1
  227. package/Materials/materialHelper.geometryrendering.js +19 -16
  228. package/Materials/materialHelper.geometryrendering.js.map +1 -1
  229. package/Materials/materialPluginManager.pure.js +12 -8
  230. package/Materials/materialPluginManager.pure.js.map +1 -1
  231. package/Materials/prePassConfiguration.js +19 -16
  232. package/Materials/prePassConfiguration.js.map +1 -1
  233. package/Materials/shaderMaterial.pure.js +19 -6
  234. package/Materials/shaderMaterial.pure.js.map +1 -1
  235. package/Materials/shadowDepthWrapper.d.ts +6 -0
  236. package/Materials/shadowDepthWrapper.js +17 -0
  237. package/Materials/shadowDepthWrapper.js.map +1 -1
  238. package/Meshes/Compression/dracoCodec.d.ts +14 -0
  239. package/Meshes/Compression/dracoCodec.js +22 -0
  240. package/Meshes/Compression/dracoCodec.js.map +1 -1
  241. package/Meshes/Compression/dracoDecoder.d.ts +1 -0
  242. package/Meshes/Compression/dracoDecoder.js +27 -0
  243. package/Meshes/Compression/dracoDecoder.js.map +1 -1
  244. package/Meshes/Compression/dracoEncoder.d.ts +1 -0
  245. package/Meshes/Compression/dracoEncoder.js +8 -0
  246. package/Meshes/Compression/dracoEncoder.js.map +1 -1
  247. package/Meshes/Compression/meshoptCompression.d.ts +1 -0
  248. package/Meshes/Compression/meshoptCompression.js +9 -0
  249. package/Meshes/Compression/meshoptCompression.js.map +1 -1
  250. package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.d.ts +415 -0
  251. package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.js +912 -0
  252. package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.js.map +1 -0
  253. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +3 -0
  254. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +40 -9
  255. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
  256. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +112 -8
  257. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +696 -74
  258. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
  259. package/Meshes/abstractMesh.pure.js +12 -4
  260. package/Meshes/abstractMesh.pure.js.map +1 -1
  261. package/Meshes/geometry.d.ts +5 -0
  262. package/Meshes/geometry.js +25 -0
  263. package/Meshes/geometry.js.map +1 -1
  264. package/Meshes/index.d.ts +1 -0
  265. package/Meshes/index.js +1 -0
  266. package/Meshes/index.js.map +1 -1
  267. package/Meshes/mesh.pure.d.ts +7 -0
  268. package/Meshes/mesh.pure.js +18 -13
  269. package/Meshes/mesh.pure.js.map +1 -1
  270. package/Meshes/pure.d.ts +1 -0
  271. package/Meshes/pure.js +1 -0
  272. package/Meshes/pure.js.map +1 -1
  273. package/Meshes/subMesh.pure.d.ts +3 -0
  274. package/Meshes/subMesh.pure.js +26 -0
  275. package/Meshes/subMesh.pure.js.map +1 -1
  276. package/Meshes/thinInstanceMesh.pure.js +5 -3
  277. package/Meshes/thinInstanceMesh.pure.js.map +1 -1
  278. package/Misc/index.d.ts +1 -0
  279. package/Misc/index.js +1 -0
  280. package/Misc/index.js.map +1 -1
  281. package/Misc/khronosTextureContainer2.d.ts +3 -2
  282. package/Misc/khronosTextureContainer2.js +24 -6
  283. package/Misc/khronosTextureContainer2.js.map +1 -1
  284. package/Misc/khronosTextureContainer2Encoder.d.ts +166 -0
  285. package/Misc/khronosTextureContainer2Encoder.js +556 -0
  286. package/Misc/khronosTextureContainer2Encoder.js.map +1 -0
  287. package/Misc/khronosTextureContainer2EncoderWorker.d.ts +61 -0
  288. package/Misc/khronosTextureContainer2EncoderWorker.js +55 -0
  289. package/Misc/khronosTextureContainer2EncoderWorker.js.map +1 -0
  290. package/Misc/pure.d.ts +1 -0
  291. package/Misc/pure.js +1 -0
  292. package/Misc/pure.js.map +1 -1
  293. package/Misc/textureFormat.functions.d.ts +6 -0
  294. package/Misc/textureFormat.functions.js +54 -0
  295. package/Misc/textureFormat.functions.js.map +1 -0
  296. package/Misc/textureTools.d.ts +6 -2
  297. package/Misc/textureTools.js +100 -42
  298. package/Misc/textureTools.js.map +1 -1
  299. package/Misc/tools.pure.js +1 -1
  300. package/Misc/tools.pure.js.map +1 -1
  301. package/Particles/Node/Blocks/systemBlock.pure.d.ts +1 -1
  302. package/Particles/Node/Blocks/systemBlock.pure.js +6 -3
  303. package/Particles/Node/Blocks/systemBlock.pure.js.map +1 -1
  304. package/Particles/computeShaderParticleSystem.pure.js +5 -0
  305. package/Particles/computeShaderParticleSystem.pure.js.map +1 -1
  306. package/Particles/gpuParticleSystem.pure.d.ts +2 -0
  307. package/Particles/gpuParticleSystem.pure.js +25 -1
  308. package/Particles/gpuParticleSystem.pure.js.map +1 -1
  309. package/Particles/solidParticle.d.ts +5 -0
  310. package/Particles/solidParticle.js +5 -0
  311. package/Particles/solidParticle.js.map +1 -1
  312. package/Particles/solidParticleSystem.d.ts +10 -0
  313. package/Particles/solidParticleSystem.js +72 -13
  314. package/Particles/solidParticleSystem.js.map +1 -1
  315. package/Particles/thinParticleSystem.pure.js +4 -0
  316. package/Particles/thinParticleSystem.pure.js.map +1 -1
  317. package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.d.ts +27 -6
  318. package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.js +60 -5
  319. package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.js.map +1 -1
  320. package/PostProcesses/thinTAAPostProcess.d.ts +1 -0
  321. package/PostProcesses/thinTAAPostProcess.js +17 -1
  322. package/PostProcesses/thinTAAPostProcess.js.map +1 -1
  323. package/PostProcesses/volumetricLightScatteringPostProcess.pure.d.ts +2 -1
  324. package/PostProcesses/volumetricLightScatteringPostProcess.pure.js +6 -5
  325. package/PostProcesses/volumetricLightScatteringPostProcess.pure.js.map +1 -1
  326. package/Rendering/boundingBoxRenderer.pure.js +2 -3
  327. package/Rendering/boundingBoxRenderer.pure.js.map +1 -1
  328. package/Rendering/geometryBufferRenderer.pure.js +8 -2
  329. package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
  330. package/Rendering/objectRenderer.d.ts +1 -0
  331. package/Rendering/objectRenderer.js +14 -0
  332. package/Rendering/objectRenderer.js.map +1 -1
  333. package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js +2 -2
  334. package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
  335. package/Shaders/ShadersInclude/bumpVertex.js +1 -1
  336. package/Shaders/ShadersInclude/bumpVertex.js.map +1 -1
  337. package/Shaders/ShadersInclude/bumpVertexDeclaration.js +1 -1
  338. package/Shaders/ShadersInclude/bumpVertexDeclaration.js.map +1 -1
  339. package/Shaders/ShadersInclude/hdrFilteringFunctions.js +5 -1
  340. package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
  341. package/Shaders/ShadersInclude/helperFunctions.js +2 -2
  342. package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
  343. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
  344. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
  345. package/Shaders/ShadersInclude/openpbrVertexDeclaration.js +6 -0
  346. package/Shaders/ShadersInclude/openpbrVertexDeclaration.js.map +1 -1
  347. package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js +11 -1
  348. package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
  349. package/Shaders/ShadersInclude/pbrBlockNormalFinal.js +9 -0
  350. package/Shaders/ShadersInclude/pbrBlockNormalFinal.js.map +1 -1
  351. package/Shaders/ShadersInclude/pbrBlockReflectance.js +1 -1
  352. package/Shaders/ShadersInclude/pbrBlockReflectance.js.map +1 -1
  353. package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js +1 -1
  354. package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
  355. package/Shaders/ShadersInclude/pbrFragmentDeclaration.js +7 -1
  356. package/Shaders/ShadersInclude/pbrFragmentDeclaration.js.map +1 -1
  357. package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
  358. package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
  359. package/Shaders/ShadersInclude/pbrIBLFunctions.js +12 -0
  360. package/Shaders/ShadersInclude/pbrIBLFunctions.js.map +1 -1
  361. package/Shaders/ShadersInclude/pbrUboDeclaration.js +1 -1
  362. package/Shaders/ShadersInclude/pbrUboDeclaration.js.map +1 -1
  363. package/Shaders/ShadersInclude/pbrVertexDeclaration.js +3 -0
  364. package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
  365. package/Shaders/geometry.vertex.js +6 -6
  366. package/Shaders/geometry.vertex.js.map +1 -1
  367. package/Shaders/gpuUpdateParticles.vertex.js +1 -1
  368. package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
  369. package/Shaders/lod.fragment.js +15 -2
  370. package/Shaders/lod.fragment.js.map +1 -1
  371. package/Shaders/lod3D.fragment.js +15 -2
  372. package/Shaders/lod3D.fragment.js.map +1 -1
  373. package/Shaders/lodCube.fragment.js +15 -2
  374. package/Shaders/lodCube.fragment.js.map +1 -1
  375. package/Shaders/openpbr.vertex.js +2 -0
  376. package/Shaders/openpbr.vertex.js.map +1 -1
  377. package/Shaders/pbr.fragment.js +12 -1
  378. package/Shaders/pbr.fragment.js.map +1 -1
  379. package/Shaders/pbr.vertex.js +2 -0
  380. package/Shaders/pbr.vertex.js.map +1 -1
  381. package/Shaders/textureMerger.fragment.js +28 -0
  382. package/Shaders/textureMerger.fragment.js.map +1 -1
  383. package/Shaders/textureProcessor.fragment.js +26 -4
  384. package/Shaders/textureProcessor.fragment.js.map +1 -1
  385. package/Shaders/volumetricLightScattering.fragment.js +1 -1
  386. package/Shaders/volumetricLightScattering.fragment.js.map +1 -1
  387. package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js +2 -2
  388. package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
  389. package/ShadersWGSL/ShadersInclude/bumpVertex.js +1 -1
  390. package/ShadersWGSL/ShadersInclude/bumpVertex.js.map +1 -1
  391. package/ShadersWGSL/ShadersInclude/bumpVertexDeclaration.js +1 -1
  392. package/ShadersWGSL/ShadersInclude/bumpVertexDeclaration.js.map +1 -1
  393. package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +1 -1
  394. package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
  395. package/ShadersWGSL/ShadersInclude/helperFunctions.js +2 -2
  396. package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
  397. package/ShadersWGSL/ShadersInclude/lightFragment.js +44 -2
  398. package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
  399. package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +17 -3
  400. package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
  401. package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +12 -1
  402. package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
  403. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
  404. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
  405. package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js +11 -1
  406. package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
  407. package/ShadersWGSL/ShadersInclude/pbrBlockNormalFinal.js +9 -0
  408. package/ShadersWGSL/ShadersInclude/pbrBlockNormalFinal.js.map +1 -1
  409. package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js +1 -1
  410. package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js.map +1 -1
  411. package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js +1 -1
  412. package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
  413. package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js +1 -1
  414. package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
  415. package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
  416. package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
  417. package/ShadersWGSL/ShadersInclude/pbrIBLFunctions.js +8 -0
  418. package/ShadersWGSL/ShadersInclude/pbrIBLFunctions.js.map +1 -1
  419. package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js +1 -1
  420. package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js.map +1 -1
  421. package/ShadersWGSL/ShadersInclude/prePassVertex.js +2 -2
  422. package/ShadersWGSL/ShadersInclude/prePassVertex.js.map +1 -1
  423. package/ShadersWGSL/ShadersInclude/prePassVertexDeclaration.js +1 -1
  424. package/ShadersWGSL/ShadersInclude/prePassVertexDeclaration.js.map +1 -1
  425. package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js +3 -1
  426. package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js.map +1 -1
  427. package/ShadersWGSL/ShadersInclude/shadowsVertex.js +16 -0
  428. package/ShadersWGSL/ShadersInclude/shadowsVertex.js.map +1 -1
  429. package/ShadersWGSL/default.fragment.js +4 -4
  430. package/ShadersWGSL/default.fragment.js.map +1 -1
  431. package/ShadersWGSL/default.vertex.js +1 -1
  432. package/ShadersWGSL/default.vertex.js.map +1 -1
  433. package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
  434. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  435. package/ShadersWGSL/gpuUpdateParticles.compute.js +1 -1
  436. package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
  437. package/ShadersWGSL/gsSortCount.compute.d.ts +5 -0
  438. package/ShadersWGSL/gsSortCount.compute.js +19 -0
  439. package/ShadersWGSL/gsSortCount.compute.js.map +1 -0
  440. package/ShadersWGSL/gsSortKeys.compute.d.ts +5 -0
  441. package/ShadersWGSL/gsSortKeys.compute.js +49 -0
  442. package/ShadersWGSL/gsSortKeys.compute.js.map +1 -0
  443. package/ShadersWGSL/gsSortOutput.compute.d.ts +5 -0
  444. package/ShadersWGSL/gsSortOutput.compute.js +28 -0
  445. package/ShadersWGSL/gsSortOutput.compute.js.map +1 -0
  446. package/ShadersWGSL/gsSortScanLocal.compute.d.ts +5 -0
  447. package/ShadersWGSL/gsSortScanLocal.compute.js +23 -0
  448. package/ShadersWGSL/gsSortScanLocal.compute.js.map +1 -0
  449. package/ShadersWGSL/gsSortScanSums.compute.d.ts +5 -0
  450. package/ShadersWGSL/gsSortScanSums.compute.js +19 -0
  451. package/ShadersWGSL/gsSortScanSums.compute.js.map +1 -0
  452. package/ShadersWGSL/gsSortScatter.compute.d.ts +5 -0
  453. package/ShadersWGSL/gsSortScatter.compute.js +33 -0
  454. package/ShadersWGSL/gsSortScatter.compute.js.map +1 -0
  455. package/ShadersWGSL/lod.fragment.js +14 -2
  456. package/ShadersWGSL/lod.fragment.js.map +1 -1
  457. package/ShadersWGSL/lod3D.fragment.js +14 -2
  458. package/ShadersWGSL/lod3D.fragment.js.map +1 -1
  459. package/ShadersWGSL/lodCube.fragment.js +14 -2
  460. package/ShadersWGSL/lodCube.fragment.js.map +1 -1
  461. package/ShadersWGSL/openpbr.vertex.js +3 -1
  462. package/ShadersWGSL/openpbr.vertex.js.map +1 -1
  463. package/ShadersWGSL/pbr.fragment.js +11 -0
  464. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  465. package/ShadersWGSL/pbr.vertex.js +3 -1
  466. package/ShadersWGSL/pbr.vertex.js.map +1 -1
  467. package/ShadersWGSL/textureMerger.fragment.js +40 -4
  468. package/ShadersWGSL/textureMerger.fragment.js.map +1 -1
  469. package/ShadersWGSL/textureProcessor.fragment.js +26 -4
  470. package/ShadersWGSL/textureProcessor.fragment.js.map +1 -1
  471. package/Sprites/spriteRenderer.js +15 -5
  472. package/Sprites/spriteRenderer.js.map +1 -1
  473. package/package.json +1 -1
  474. package/scene.pure.d.ts +23 -1
  475. package/scene.pure.js +83 -1
  476. package/scene.pure.js.map +1 -1
@@ -1,6 +1,7 @@
1
1
  import { ProceduralTexture } from "./Procedurals/proceduralTexture.pure.js";
2
2
 
3
3
  import { Color4 } from "../../Maths/math.color.pure.js";
4
+ import { _AllTransformsMatch, _CopyTextureMetadata, _HasNonIdentityTransform, _KeepMatchingCoordinates } from "./textureSampling.functions.js";
4
5
  const _ShaderName = "textureProcessor";
5
6
  /**
6
7
  * Specifies the color space of a texture operand.
@@ -136,9 +137,43 @@ function _MaxConstants(a, b) {
136
137
  return new Color4(Math.max(a.r, b.r), Math.max(a.g, b.g), Math.max(a.b, b.b), Math.max(a.a, b.a));
137
138
  }
138
139
  /** @internal */
140
+ function _DivideConstants(a, b) {
141
+ const eps = 0.00001;
142
+ return new Color4(a.r / Math.max(b.r, eps), a.g / Math.max(b.g, eps), a.b / Math.max(b.b, eps), a.a / Math.max(b.a, eps));
143
+ }
144
+ /** @internal */
139
145
  function _LerpConstants(a, b, t) {
140
146
  return new Color4(a.r + (b.r - a.r) * t.r, a.g + (b.g - a.g) * t.g, a.b + (b.b - a.b) * t.b, a.a + (b.a - a.a) * t.a);
141
147
  }
148
+ /**
149
+ * Clamps a scatter anisotropy the same way the renderer does before converting between single- and
150
+ * multi-scatter albedo, so that |aniso| = 1 doesn't collapse the conversion.
151
+ * @internal
152
+ */
153
+ function _EffectiveScatterAnisotropy(aniso) {
154
+ return Math.min(Math.max(aniso, -0.9999), 0.9999);
155
+ }
156
+ /** @internal */
157
+ function _MultiScatterToSingleScatterAlbedoConstant(multiScatter, aniso) {
158
+ const convert = (value) => {
159
+ const rhoMs = Math.min(Math.max(value, 0), 1);
160
+ let s = 4.09712 + 4.20863 * rhoMs - Math.sqrt(9.59217 + 41.6808 * rhoMs + 17.7126 * rhoMs * rhoMs);
161
+ if (rhoMs === 0) {
162
+ s = 1;
163
+ }
164
+ return (1 - s * s) / Math.max(1 - aniso * s * s, 0.0000001);
165
+ };
166
+ return new Color4(convert(multiScatter.r), convert(multiScatter.g), convert(multiScatter.b), multiScatter.a);
167
+ }
168
+ /** @internal */
169
+ function _SingleScatterToMultiScatterAlbedoConstant(singleScatter, aniso) {
170
+ const convert = (value) => {
171
+ const ssAlbedo = Math.min(Math.max(value, 0), 1);
172
+ const s = Math.sqrt(Math.max((1 - ssAlbedo) / Math.max(1 - aniso * ssAlbedo, 0.0000001), 0));
173
+ return ((1 - s) * (1 - 0.139 * s)) / (1 + 1.17 * s);
174
+ };
175
+ return new Color4(convert(singleScatter.r), convert(singleScatter.g), convert(singleScatter.b), singleScatter.a);
176
+ }
142
177
  /**
143
178
  * @internal
144
179
  * Determine the output texture size from a list of operands, using the largest input texture.
@@ -158,49 +193,8 @@ function _ResolveOutputSize(operands) {
158
193
  }
159
194
  return result;
160
195
  }
161
- /**
162
- * @internal
163
- * Returns true when the texture has a non-identity UV transform (offset, scale, or rotation).
164
- */
165
- function _HasNonIdentityTransform(texture) {
166
- return !texture.getTextureMatrix().isIdentity();
167
- }
168
- /**
169
- * @internal
170
- * Returns true when every texture in the list shares the same UV transform matrix.
171
- * A single texture (or empty list) trivially satisfies this.
172
- */
173
- function _AllTransformsMatch(textures) {
174
- if (textures.length <= 1) {
175
- return true;
176
- }
177
- const ref = textures[0].getTextureMatrix();
178
- for (let i = 1; i < textures.length; i++) {
179
- if (!ref.equals(textures[i].getTextureMatrix())) {
180
- return false;
181
- }
182
- }
183
- return true;
184
- }
185
- /**
186
- * @internal
187
- * Copy sampling metadata from a source texture onto the output ProceduralTexture.
188
- * `coordinatesIndex` and wrap modes are always copied.
189
- * When `includeTransform` is true the UV offset/scale/rotation are also copied
190
- * (used when all inputs share the same transform and it is propagated rather than baked).
191
- */
192
- function _CopyTextureMetadata(from, to, includeTransform) {
193
- to.coordinatesIndex = from.coordinatesIndex;
194
- to.wrapU = from.wrapU;
195
- to.wrapV = from.wrapV;
196
- if (includeTransform) {
197
- const src = from;
198
- to.uOffset = src.uOffset ?? 0;
199
- to.vOffset = src.vOffset ?? 0;
200
- to.uScale = src.uScale ?? 1;
201
- to.vScale = src.vScale ?? 1;
202
- to.wAng = src.wAng ?? 0;
203
- }
196
+ function _KeepMatchingOperandCoordinates(name, operands) {
197
+ return _KeepMatchingCoordinates(`Texture processor '${name}'`, operands, (operand) => operand.texture, (operand) => ({ ...operand, texture: null }));
204
198
  }
205
199
  /**
206
200
  * @internal
@@ -458,6 +452,7 @@ export async function MultiplyTexturesAsync(name, a, b, scene, outputColorSpace,
458
452
  const factor = _MultiplyConstants(_EvalConstant(a), _EvalConstant(b));
459
453
  return { texture: null, factor: outputChannelMask ? _ApplyOutputChannelMask(factor, outputChannelMask) : factor };
460
454
  }
455
+ [a, b] = _KeepMatchingOperandCoordinates(name, [a, b]);
461
456
  const allTextures = [];
462
457
  if (a.texture) {
463
458
  allTextures.push(a.texture);
@@ -524,6 +519,7 @@ export async function MaxTexturesAsync(name, a, b, scene, outputColorSpace, outp
524
519
  const factor = _MaxConstants(_EvalConstant(a), _EvalConstant(b));
525
520
  return { texture: null, factor: outputChannelMask ? _ApplyOutputChannelMask(factor, outputChannelMask) : factor };
526
521
  }
522
+ [a, b] = _KeepMatchingOperandCoordinates(name, [a, b]);
527
523
  const allTextures = [];
528
524
  if (a.texture) {
529
525
  allTextures.push(a.texture);
@@ -562,6 +558,218 @@ export async function MaxTexturesAsync(name, a, b, scene, outputColorSpace, outp
562
558
  }
563
559
  return result;
564
560
  }
561
+ /**
562
+ * Component-wise safe division of two texture operands: `result = a / max(b, 0.00001)`.
563
+ *
564
+ * Each operand can be a texture, a constant factor, or a texture scaled by a factor.
565
+ * Division by zero is guarded with a small epsilon so the result is always finite.
566
+ *
567
+ * If both operands are constant (no textures), the operation is performed on the CPU and
568
+ * the result is returned as a factor-only operand with no texture allocated.
569
+ *
570
+ * When operands are results of previous operations (i.e. they carry a `dispose` function),
571
+ * their intermediate textures are automatically released after the GPU pass completes.
572
+ *
573
+ * @param name - Name for the resulting procedural texture (used only when a GPU pass is needed)
574
+ * @param a - Numerator operand
575
+ * @param b - Denominator operand
576
+ * @param scene - Scene to create the texture in (used only when a GPU pass is needed)
577
+ * @param outputColorSpace - Optional output color space.
578
+ * @param outputChannelMask - Optional bitmask of channels to write.
579
+ * @param outputOptions - Optional render-target type, sampling, and mipmap settings.
580
+ * @returns An operand whose `texture` holds the GPU result, or whose `factor` holds the CPU-folded constant
581
+ */
582
+ export async function DivideTexturesAsync(name, a, b, scene, outputColorSpace, outputChannelMask, outputOptions) {
583
+ if (!a.texture && !b.texture) {
584
+ const factor = _DivideConstants(_EvalConstant(a), _EvalConstant(b));
585
+ return { texture: null, factor: outputChannelMask ? _ApplyOutputChannelMask(factor, outputChannelMask) : factor };
586
+ }
587
+ [a, b] = _KeepMatchingOperandCoordinates(name, [a, b]);
588
+ const allTextures = [];
589
+ if (a.texture) {
590
+ allTextures.push(a.texture);
591
+ }
592
+ if (b.texture) {
593
+ allTextures.push(b.texture);
594
+ }
595
+ const canPropagate = _AllTransformsMatch(allTextures);
596
+ const bakeTransform = !canPropagate;
597
+ const defines = [
598
+ "OP_DIVIDE",
599
+ ..._BuildOperandDefines(a, "A", bakeTransform),
600
+ ..._BuildOperandDefines(b, "B", bakeTransform),
601
+ ...(outputChannelMask ? _BuildOutputChannelMaskDefines(outputChannelMask) : []),
602
+ ];
603
+ if (outputColorSpace) {
604
+ defines.push("OUTPUT_SRGB");
605
+ }
606
+ const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize([a, b]), scene, outputColorSpace, outputOptions);
607
+ _SetOperandUniforms(pt, a, "textureA", "factorA", bakeTransform);
608
+ _SetOperandUniforms(pt, b, "textureB", "factorB", bakeTransform);
609
+ try {
610
+ await _RenderAsync(pt);
611
+ }
612
+ catch (error) {
613
+ a.dispose?.();
614
+ b.dispose?.();
615
+ throw error;
616
+ }
617
+ a.dispose?.();
618
+ b.dispose?.();
619
+ _CopyTextureMetadata(allTextures[0], pt, canPropagate);
620
+ const result = { texture: pt, dispose: () => pt.dispose() };
621
+ if (outputColorSpace) {
622
+ result.colorSpace = outputColorSpace;
623
+ }
624
+ return result;
625
+ }
626
+ /**
627
+ * Compute the component-wise fraction `result = a / (a + b * (1 - a))` in a single GPU pass.
628
+ *
629
+ * For OpenPBR this is the transmission fraction of the dielectric's transmitted light, where `a` is
630
+ * the transmission weight T and `b` the subsurface weight S (subsurface covers only the remaining
631
+ * `1 - T`). The subsurface fraction is `1 - result`. The denominator `T + S(1 - T)` equals
632
+ * `1 - (1 - T)(1 - S)` but avoids subtracting values near one, and fusing the whole expression into
633
+ * one pass means no intermediate is quantized; only the final output is. The denominator is guarded
634
+ * with `max(..., 0.00001)`, so the result is 0 where both inputs are 0.
635
+ *
636
+ * If both operands are constant (no textures), the operation is performed on the CPU and
637
+ * the result is returned as a factor-only operand with no texture allocated.
638
+ *
639
+ * When operands are results of previous operations (i.e. they carry a `dispose` function),
640
+ * their intermediate textures are automatically released after the GPU pass completes.
641
+ *
642
+ * @param name - Name for the resulting procedural texture (used only when a GPU pass is needed)
643
+ * @param a - Transmission weight operand (T)
644
+ * @param b - Subsurface weight operand (S)
645
+ * @param scene - Scene to create the texture in (used only when a GPU pass is needed)
646
+ * @param outputColorSpace - Optional output color space.
647
+ * @param outputChannelMask - Optional bitmask of channels to write.
648
+ * @param outputOptions - Optional render-target type, sampling, and mipmap settings.
649
+ * @returns An operand whose `texture` holds the GPU result, or whose `factor` holds the CPU-folded constant
650
+ */
651
+ export async function TransmissionFractionAsync(name, a, b, scene, outputColorSpace, outputChannelMask, outputOptions) {
652
+ if (!a.texture && !b.texture) {
653
+ const ca = _EvalConstant(a);
654
+ const cb = _EvalConstant(b);
655
+ const fraction = (x, y) => x / Math.max(x + y * (1 - x), 0.00001);
656
+ const factor = new Color4(fraction(ca.r, cb.r), fraction(ca.g, cb.g), fraction(ca.b, cb.b), fraction(ca.a, cb.a));
657
+ return { texture: null, factor: outputChannelMask ? _ApplyOutputChannelMask(factor, outputChannelMask) : factor };
658
+ }
659
+ [a, b] = _KeepMatchingOperandCoordinates(name, [a, b]);
660
+ const allTextures = [];
661
+ if (a.texture) {
662
+ allTextures.push(a.texture);
663
+ }
664
+ if (b.texture) {
665
+ allTextures.push(b.texture);
666
+ }
667
+ const canPropagate = _AllTransformsMatch(allTextures);
668
+ const bakeTransform = !canPropagate;
669
+ const defines = [
670
+ "OP_TRANSMISSION_FRACTION",
671
+ ..._BuildOperandDefines(a, "A", bakeTransform),
672
+ ..._BuildOperandDefines(b, "B", bakeTransform),
673
+ ...(outputChannelMask ? _BuildOutputChannelMaskDefines(outputChannelMask) : []),
674
+ ];
675
+ if (outputColorSpace) {
676
+ defines.push("OUTPUT_SRGB");
677
+ }
678
+ const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize([a, b]), scene, outputColorSpace, outputOptions);
679
+ _SetOperandUniforms(pt, a, "textureA", "factorA", bakeTransform);
680
+ _SetOperandUniforms(pt, b, "textureB", "factorB", bakeTransform);
681
+ try {
682
+ await _RenderAsync(pt);
683
+ }
684
+ catch (error) {
685
+ a.dispose?.();
686
+ b.dispose?.();
687
+ throw error;
688
+ }
689
+ a.dispose?.();
690
+ b.dispose?.();
691
+ _CopyTextureMetadata(allTextures[0], pt, canPropagate);
692
+ const result = { texture: pt, dispose: () => pt.dispose() };
693
+ if (outputColorSpace) {
694
+ result.colorSpace = outputColorSpace;
695
+ }
696
+ return result;
697
+ }
698
+ /** @internal */
699
+ function _TransmissionScatterAlbedoConstant(transmissionColor, transmissionScatter) {
700
+ const extinction = [transmissionColor.r, transmissionColor.g, transmissionColor.b].map((value) => -Math.log(Math.max(value, 0.0000001)));
701
+ const scatter = [transmissionScatter.r, transmissionScatter.g, transmissionScatter.b];
702
+ const shift = Math.min(0, ...extinction.map((value, i) => value - scatter[i]));
703
+ const albedo = scatter.map((value, i) => value / Math.max(extinction[i] - shift, 0.00001));
704
+ return new Color4(albedo[0], albedo[1], albedo[2], transmissionScatter.a);
705
+ }
706
+ /**
707
+ * Recover the single-scatter albedo of an OpenPBR 1.1 transmission volume, `scatter / extinction`, using the
708
+ * renderer's extinction: the absorption `-log(transmissionColor) - transmissionScatter` is shifted so its
709
+ * smallest channel is non-negative, and the extinction is recomputed from it. The transmission depth cancels
710
+ * out of the ratio, so both operands are given per unit depth. The result alpha is taken from the scatter operand.
711
+ *
712
+ * If both operands are constant (no textures), the operation is performed on the CPU and
713
+ * the result is returned as a factor-only operand with no texture allocated.
714
+ *
715
+ * When operands are results of previous operations (i.e. they carry a `dispose` function),
716
+ * their intermediate textures are automatically released after the GPU pass completes.
717
+ *
718
+ * @param name - Name for the resulting procedural texture (used only when a GPU pass is needed)
719
+ * @param transmissionColor - Linear transmission color operand
720
+ * @param transmissionScatter - Transmission scatter operand
721
+ * @param scene - Scene to create the texture in (used only when a GPU pass is needed)
722
+ * @param outputColorSpace - Optional output color space.
723
+ * @param outputChannelMask - Optional bitmask of channels to write.
724
+ * @param outputOptions - Optional render-target type, sampling, and mipmap settings.
725
+ * @returns An operand whose `texture` holds the GPU result, or whose `factor` holds the CPU-folded constant
726
+ */
727
+ export async function TransmissionScatterToSingleScatterAlbedoAsync(name, transmissionColor, transmissionScatter, scene, outputColorSpace, outputChannelMask, outputOptions) {
728
+ let a = transmissionColor;
729
+ let b = transmissionScatter;
730
+ if (!a.texture && !b.texture) {
731
+ const factor = _TransmissionScatterAlbedoConstant(_EvalConstant(a), _EvalConstant(b));
732
+ return { texture: null, factor: outputChannelMask ? _ApplyOutputChannelMask(factor, outputChannelMask) : factor };
733
+ }
734
+ [a, b] = _KeepMatchingOperandCoordinates(name, [a, b]);
735
+ const allTextures = [];
736
+ if (a.texture) {
737
+ allTextures.push(a.texture);
738
+ }
739
+ if (b.texture) {
740
+ allTextures.push(b.texture);
741
+ }
742
+ const canPropagate = _AllTransformsMatch(allTextures);
743
+ const bakeTransform = !canPropagate;
744
+ const defines = [
745
+ "OP_TRANSMISSION_SCATTER_ALBEDO",
746
+ ..._BuildOperandDefines(a, "A", bakeTransform),
747
+ ..._BuildOperandDefines(b, "B", bakeTransform),
748
+ ...(outputChannelMask ? _BuildOutputChannelMaskDefines(outputChannelMask) : []),
749
+ ];
750
+ if (outputColorSpace) {
751
+ defines.push("OUTPUT_SRGB");
752
+ }
753
+ const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize([a, b]), scene, outputColorSpace, outputOptions);
754
+ _SetOperandUniforms(pt, a, "textureA", "factorA", bakeTransform);
755
+ _SetOperandUniforms(pt, b, "textureB", "factorB", bakeTransform);
756
+ try {
757
+ await _RenderAsync(pt);
758
+ }
759
+ catch (error) {
760
+ a.dispose?.();
761
+ b.dispose?.();
762
+ throw error;
763
+ }
764
+ a.dispose?.();
765
+ b.dispose?.();
766
+ _CopyTextureMetadata(allTextures[0], pt, canPropagate);
767
+ const result = { texture: pt, dispose: () => pt.dispose() };
768
+ if (outputColorSpace) {
769
+ result.colorSpace = outputColorSpace;
770
+ }
771
+ return result;
772
+ }
565
773
  /**
566
774
  * Linearly interpolate between two texture operands: `result = mix(a, b, t)`.
567
775
  *
@@ -588,11 +796,12 @@ export async function MaxTexturesAsync(name, a, b, scene, outputColorSpace, outp
588
796
  * @param outputOptions - Optional render-target type, sampling, and mipmap settings.
589
797
  * @returns An operand whose `texture` holds the GPU result, or whose `factor` holds the CPU-folded constant
590
798
  */
591
- export async function LerpTexturesAsync(name, a, b, t, scene, outputColorSpace, outputChannelMask, outputOptions) {
799
+ export async function LerpTexturesAsync(name, a, b, t, scene, outputColorSpace = TextureColorSpace.Linear, outputChannelMask, outputOptions) {
592
800
  if (!a.texture && !b.texture && !t.texture) {
593
801
  const factor = _LerpConstants(_EvalConstant(a), _EvalConstant(b), _EvalConstant(t));
594
802
  return { texture: null, factor: outputChannelMask ? _ApplyOutputChannelMask(factor, outputChannelMask) : factor };
595
803
  }
804
+ [a, b, t] = _KeepMatchingOperandCoordinates(name, [a, b, t]);
596
805
  const allTextures = [];
597
806
  if (a.texture) {
598
807
  allTextures.push(a.texture);
@@ -612,7 +821,7 @@ export async function LerpTexturesAsync(name, a, b, t, scene, outputColorSpace,
612
821
  ..._BuildLerpBlendDefines(t, bakeTransform),
613
822
  ...(outputChannelMask ? _BuildOutputChannelMaskDefines(outputChannelMask) : []),
614
823
  ];
615
- if (outputColorSpace) {
824
+ if (outputColorSpace == TextureColorSpace.SRGB) {
616
825
  defines.push("OUTPUT_SRGB");
617
826
  }
618
827
  const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize([a, b, t]), scene, outputColorSpace, outputOptions);
@@ -795,4 +1004,195 @@ export async function ExtractChannelAsync(name, input, channel, scene, outputCol
795
1004
  }
796
1005
  return await MultiplyTexturesAsync(name, { ...input, channel }, CreateFactorOperand(new Color4(1, 1, 1, 1)), scene, outputColorSpace, outputChannelMask, outputOptions);
797
1006
  }
1007
+ /**
1008
+ * Convert a multi-scatter albedo operand to single-scatter albedo using the OpenPBR/KHR
1009
+ * approximation. RGB is clamped to `[0, 1]` before conversion and alpha is preserved.
1010
+ *
1011
+ * If the operand is constant, the conversion is performed on the CPU. Otherwise it is baked
1012
+ * into a linear procedural texture. Input color-space conversion, channel selection, factors,
1013
+ * UV transforms, metadata propagation, and intermediate disposal follow the other unary texture
1014
+ * processor operations.
1015
+ *
1016
+ * @param name - Name for the resulting procedural texture (used only when a GPU pass is needed)
1017
+ * @param input - Multi-scatter albedo operand to convert
1018
+ * @param scene - Scene to create the texture in (used only when a GPU pass is needed)
1019
+ * @param aniso - Scattering anisotropy in `[-1, 1]`. `0` (default) is isotropic; positive values are
1020
+ * forward-scattering. Matches `multiScatterToSingleScatterAlbedo(rho_ms, aniso)` in helperFunctions.
1021
+ * Clamped to `[-0.9999, 0.9999]`, as in the renderer.
1022
+ * @param scale - Optional operand multiplied into `input` (RGBA) before conversion, in the same pass. Use it
1023
+ * instead of a separate {@link MultiplyTexturesAsync} so that the product (e.g. scatter strength times
1024
+ * multi-scatter color) isn't quantized before the nonlinear conversion.
1025
+ * @returns An operand containing the converted single-scatter albedo
1026
+ */
1027
+ export async function MultiScatterToSingleScatterAlbedoAsync(name, input, scene, aniso = 0, scale) {
1028
+ aniso = _EffectiveScatterAnisotropy(aniso);
1029
+ if (!input.texture && !scale?.texture) {
1030
+ const multiScatter = scale ? _MultiplyConstants(_EvalConstant(input), _EvalConstant(scale)) : _EvalConstant(input);
1031
+ return { texture: null, factor: _MultiScatterToSingleScatterAlbedoConstant(multiScatter, aniso) };
1032
+ }
1033
+ const operands = scale ? _KeepMatchingOperandCoordinates(name, [input, scale]) : [input];
1034
+ const allTextures = operands.map((operand) => operand.texture).filter((texture) => !!texture);
1035
+ const canPropagate = _AllTransformsMatch(allTextures);
1036
+ const bakeTransform = !canPropagate;
1037
+ const defines = [..._BuildOperandDefines(operands[0], "A", bakeTransform), "OP_MULTI_SCATTER_TO_SINGLE_SCATTER"];
1038
+ if (operands[1]) {
1039
+ defines.push(..._BuildOperandDefines(operands[1], "B", bakeTransform), "MULTI_SCATTER_SCALE_B");
1040
+ }
1041
+ const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize(operands), scene);
1042
+ _SetOperandUniforms(pt, operands[0], "textureA", "factorA", bakeTransform);
1043
+ if (operands[1]) {
1044
+ _SetOperandUniforms(pt, operands[1], "textureB", "factorB", bakeTransform);
1045
+ }
1046
+ pt.setFloat("scatterAniso", aniso);
1047
+ const disposeOperands = () => operands.forEach((operand) => operand.dispose?.());
1048
+ try {
1049
+ await _RenderAsync(pt);
1050
+ }
1051
+ catch (error) {
1052
+ disposeOperands();
1053
+ throw error;
1054
+ }
1055
+ disposeOperands();
1056
+ _CopyTextureMetadata(allTextures[0], pt, canPropagate);
1057
+ return { texture: pt, dispose: () => pt.dispose() };
1058
+ }
1059
+ /**
1060
+ * Convert a single-scatter albedo operand to multi-scatter albedo using the OpenPBR/KHR
1061
+ * approximation. This is the inverse of {@link MultiScatterToSingleScatterAlbedoAsync}.
1062
+ * RGB is clamped to `[0, 1]` before conversion and alpha is preserved.
1063
+ *
1064
+ * If the operand is constant, the conversion is performed on the CPU. Otherwise it is baked
1065
+ * into a linear procedural texture. Input color-space conversion, channel selection, factors,
1066
+ * UV transforms, metadata propagation, and intermediate disposal follow the other unary texture
1067
+ * processor operations.
1068
+ *
1069
+ * @param name - Name for the resulting procedural texture (used only when a GPU pass is needed)
1070
+ * @param input - Single-scatter albedo operand to convert
1071
+ * @param scene - Scene to create the texture in (used only when a GPU pass is needed)
1072
+ * @param aniso - Scattering anisotropy in `[-1, 1]`. `0` (default) is isotropic; positive values are
1073
+ * forward-scattering. This inverts the anisotropic multi→single mapping: `s^2 = (1 - rho_ss) /
1074
+ * (1 - aniso * rho_ss)`, then `rho_ms = (1 - s)(1 - 0.139 s)/(1 + 1.17 s)`. Clamped to
1075
+ * `[-0.9999, 0.9999]`, as in the renderer.
1076
+ * @param outputOptions - Optional render-target type, sampling, and mipmap settings.
1077
+ * @returns An operand containing the converted multi-scatter albedo
1078
+ */
1079
+ export async function SingleScatterToMultiScatterAlbedoAsync(name, input, scene, aniso = 0, outputOptions) {
1080
+ aniso = _EffectiveScatterAnisotropy(aniso);
1081
+ if (!input.texture) {
1082
+ return { texture: null, factor: _SingleScatterToMultiScatterAlbedoConstant(_EvalConstant(input), aniso) };
1083
+ }
1084
+ const defines = [..._BuildOperandDefines(input, "A", false), "OP_SINGLE_SCATTER_TO_MULTI_SCATTER"];
1085
+ const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize([input]), scene, undefined, outputOptions);
1086
+ _SetOperandUniforms(pt, input, "textureA", "factorA", false);
1087
+ pt.setFloat("scatterAniso", aniso);
1088
+ try {
1089
+ await _RenderAsync(pt);
1090
+ }
1091
+ catch (error) {
1092
+ input.dispose?.();
1093
+ throw error;
1094
+ }
1095
+ input.dispose?.();
1096
+ _CopyTextureMetadata(input.texture, pt, true);
1097
+ return { texture: pt, dispose: () => pt.dispose() };
1098
+ }
1099
+ /**
1100
+ * Compute the OpenPBR thin-walled scatter weights from a transmission operand (T) and a
1101
+ * scatter-strength operand (S). Both operands are read from their R channel (after the operand's
1102
+ * channel swizzle and factor), and each weight is broadcast to all four output channels.
1103
+ *
1104
+ * For each texel:
1105
+ * ```
1106
+ * transmission_weight = T * (1 - S)
1107
+ * subsurface_weight = T * S / (1 - T*(1-S))
1108
+ * ```
1109
+ *
1110
+ * These are the OpenPBR weight values when a thin-walled glTF material combines
1111
+ * KHR_materials_transmission (T = transmissionFactor * transmissionTexture) and
1112
+ * KHR_materials_scatter (S = scatterStrengthFactor * scatterStrengthTexture):
1113
+ * `scatterStrengthFactor` converts a fraction of the coherent transmission budget into
1114
+ * scattered (subsurface) transmission while keeping the total translucency constant.
1115
+ *
1116
+ * When both operands are constants the computation is performed entirely on the CPU.
1117
+ * When either operand has a texture, each weight is computed from T and S in a single GPU pass, so
1118
+ * only the two outputs are quantized. Near T = 1 the subsurface weight divides two small values, and
1119
+ * quantizing intermediates (e.g. T * S or 1 - S to 8 bits) would change it drastically.
1120
+ *
1121
+ * @param name - Base name for any procedural textures created
1122
+ * @param transmission - T operand (transmissionFactor × optional transmissionTexture, R channel)
1123
+ * @param scatter - S operand (scatterStrengthFactor × optional scatterStrengthTexture, R channel)
1124
+ * @param scene - Scene used for GPU passes when textures are involved
1125
+ * @returns `{ transmission, subsurface }` – two operands ready to assign to
1126
+ * `transmissionWeightTexture` / `subsurfaceWeightTexture` (and the corresponding scalar factors)
1127
+ */
1128
+ export async function ThinWalledScatterWeightsAsync(name, transmission, scatter, scene) {
1129
+ [transmission, scatter] = _KeepMatchingOperandCoordinates(name, [transmission, scatter]);
1130
+ // Constant-only fast path — compute entirely on the CPU.
1131
+ if (!transmission.texture && !scatter.texture) {
1132
+ const transmissionFactor = _EvalConstant(transmission).r;
1133
+ const scatterStrength = _EvalConstant(scatter).r;
1134
+ const transW = transmissionFactor * (1.0 - scatterStrength);
1135
+ const transmittedScatter = transmissionFactor * scatterStrength;
1136
+ // 1 - T(1 - S), written to avoid cancellation near T = 1.
1137
+ const denom = 1.0 - transmissionFactor + transmittedScatter;
1138
+ const ssW = denom > 0.00001 ? transmittedScatter / denom : 0.0;
1139
+ transmission.dispose?.();
1140
+ scatter.dispose?.();
1141
+ return {
1142
+ transmission: { texture: null, factor: new Color4(transW, transW, transW, transW) },
1143
+ subsurface: { texture: null, factor: new Color4(ssW, ssW, ssW, ssW) },
1144
+ };
1145
+ }
1146
+ // GPU path. Each weight is computed from T and S in one pass, so there are no intermediate textures to
1147
+ // quantize. T and S are consumed by both passes and released only after both have run.
1148
+ try {
1149
+ const transW = await _RenderThinWalledWeightAsync(`${name}_transWeight`, "OP_THIN_WALLED_TRANSMISSION_WEIGHT", transmission, scatter, scene);
1150
+ try {
1151
+ const ssW = await _RenderThinWalledWeightAsync(`${name}_subWeight`, "OP_THIN_WALLED_SUBSURFACE_WEIGHT", transmission, scatter, scene);
1152
+ return { transmission: transW, subsurface: ssW };
1153
+ }
1154
+ catch (error) {
1155
+ transW.dispose?.();
1156
+ throw error;
1157
+ }
1158
+ }
1159
+ finally {
1160
+ transmission.dispose?.();
1161
+ scatter.dispose?.();
1162
+ }
1163
+ }
1164
+ /**
1165
+ * Renders one thin-walled scatter weight from the transmission and scatter strength operands. The operands
1166
+ * are not disposed, since both weights are computed from them.
1167
+ * @param name - Name for the resulting procedural texture
1168
+ * @param op - Shader operation define
1169
+ * @param transmission - T operand
1170
+ * @param scatter - S operand
1171
+ * @param scene - Scene to create the texture in
1172
+ * @returns An operand whose `texture` holds the weight
1173
+ */
1174
+ async function _RenderThinWalledWeightAsync(name, op, transmission, scatter, scene) {
1175
+ const allTextures = [];
1176
+ if (transmission.texture) {
1177
+ allTextures.push(transmission.texture);
1178
+ }
1179
+ if (scatter.texture) {
1180
+ allTextures.push(scatter.texture);
1181
+ }
1182
+ const canPropagate = _AllTransformsMatch(allTextures);
1183
+ const bakeTransform = !canPropagate;
1184
+ const defines = [op, ..._BuildOperandDefines(transmission, "A", bakeTransform), ..._BuildOperandDefines(scatter, "B", bakeTransform)];
1185
+ const pt = _CreateProcessorTexture(name, defines, _ResolveOutputSize([transmission, scatter]), scene);
1186
+ _SetOperandUniforms(pt, transmission, "textureA", "factorA", bakeTransform);
1187
+ _SetOperandUniforms(pt, scatter, "textureB", "factorB", bakeTransform);
1188
+ try {
1189
+ await _RenderAsync(pt);
1190
+ }
1191
+ catch (error) {
1192
+ pt.dispose();
1193
+ throw error;
1194
+ }
1195
+ _CopyTextureMetadata(allTextures[0], pt, canPropagate);
1196
+ return { texture: pt, dispose: () => pt.dispose() };
1197
+ }
798
1198
  //# sourceMappingURL=textureProcessor.js.map