@aura3d/rendering 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1433) hide show
  1. package/README.md +18 -0
  2. package/dist/ArchitecturalLightingFixtures.d.ts +40 -0
  3. package/dist/ArchitecturalLightingFixtures.d.ts.map +1 -0
  4. package/dist/ArchitecturalLightingFixtures.js +171 -0
  5. package/dist/ArchitecturalLightingFixtures.js.map +1 -0
  6. package/dist/ArchitecturalMaterialCatalog.d.ts +30 -0
  7. package/dist/ArchitecturalMaterialCatalog.d.ts.map +1 -0
  8. package/dist/ArchitecturalMaterialCatalog.js +90 -0
  9. package/dist/ArchitecturalMaterialCatalog.js.map +1 -0
  10. package/dist/ArchitecturalMeasurementFixtures.d.ts +30 -0
  11. package/dist/ArchitecturalMeasurementFixtures.d.ts.map +1 -0
  12. package/dist/ArchitecturalMeasurementFixtures.js +115 -0
  13. package/dist/ArchitecturalMeasurementFixtures.js.map +1 -0
  14. package/dist/BRDFLut.d.ts +13 -0
  15. package/dist/BRDFLut.d.ts.map +1 -0
  16. package/dist/BRDFLut.js +34 -0
  17. package/dist/BRDFLut.js.map +1 -0
  18. package/dist/CameraFraming.d.ts +31 -0
  19. package/dist/CameraFraming.d.ts.map +1 -0
  20. package/dist/CameraFraming.js +143 -0
  21. package/dist/CameraFraming.js.map +1 -0
  22. package/dist/CanonicalSceneFixtures.d.ts +13 -0
  23. package/dist/CanonicalSceneFixtures.d.ts.map +1 -0
  24. package/dist/CanonicalSceneFixtures.js +78 -0
  25. package/dist/CanonicalSceneFixtures.js.map +1 -0
  26. package/dist/CascadedShadowMaps.d.ts +121 -0
  27. package/dist/CascadedShadowMaps.d.ts.map +1 -0
  28. package/dist/CascadedShadowMaps.js +315 -0
  29. package/dist/CascadedShadowMaps.js.map +1 -0
  30. package/dist/ColorManagement.d.ts +33 -0
  31. package/dist/ColorManagement.d.ts.map +1 -0
  32. package/dist/ColorManagement.js +71 -0
  33. package/dist/ColorManagement.js.map +1 -0
  34. package/dist/CullingFixtures.d.ts +70 -0
  35. package/dist/CullingFixtures.d.ts.map +1 -0
  36. package/dist/CullingFixtures.js +191 -0
  37. package/dist/CullingFixtures.js.map +1 -0
  38. package/dist/DecalGeometry.d.ts +3 -0
  39. package/dist/DecalGeometry.d.ts.map +1 -0
  40. package/dist/DecalGeometry.js +2 -0
  41. package/dist/DecalGeometry.js.map +1 -0
  42. package/dist/DepthPass.d.ts +23 -0
  43. package/dist/DepthPass.d.ts.map +1 -0
  44. package/dist/DepthPass.js +99 -0
  45. package/dist/DepthPass.js.map +1 -0
  46. package/dist/EnvironmentBackgroundPass.d.ts +27 -0
  47. package/dist/EnvironmentBackgroundPass.d.ts.map +1 -0
  48. package/dist/EnvironmentBackgroundPass.js +167 -0
  49. package/dist/EnvironmentBackgroundPass.js.map +1 -0
  50. package/dist/EnvironmentBackgroundResources.d.ts +31 -0
  51. package/dist/EnvironmentBackgroundResources.d.ts.map +1 -0
  52. package/dist/EnvironmentBackgroundResources.js +237 -0
  53. package/dist/EnvironmentBackgroundResources.js.map +1 -0
  54. package/dist/EnvironmentLighting.d.ts +10 -0
  55. package/dist/EnvironmentLighting.d.ts.map +1 -0
  56. package/dist/EnvironmentLighting.js +64 -0
  57. package/dist/EnvironmentLighting.js.map +1 -0
  58. package/dist/EnvironmentMapResources.d.ts +98 -0
  59. package/dist/EnvironmentMapResources.d.ts.map +1 -0
  60. package/dist/EnvironmentMapResources.js +794 -0
  61. package/dist/EnvironmentMapResources.js.map +1 -0
  62. package/dist/EnvironmentPipeline.d.ts +21 -0
  63. package/dist/EnvironmentPipeline.d.ts.map +1 -0
  64. package/dist/EnvironmentPipeline.js +43 -0
  65. package/dist/EnvironmentPipeline.js.map +1 -0
  66. package/dist/EnvironmentPlatform.d.ts +185 -0
  67. package/dist/EnvironmentPlatform.d.ts.map +1 -0
  68. package/dist/EnvironmentPlatform.js +922 -0
  69. package/dist/EnvironmentPlatform.js.map +1 -0
  70. package/dist/EnvironmentPreset.d.ts +35 -0
  71. package/dist/EnvironmentPreset.d.ts.map +1 -0
  72. package/dist/EnvironmentPreset.js +96 -0
  73. package/dist/EnvironmentPreset.js.map +1 -0
  74. package/dist/Exposure.d.ts +19 -0
  75. package/dist/Exposure.d.ts.map +1 -0
  76. package/dist/Exposure.js +34 -0
  77. package/dist/Exposure.js.map +1 -0
  78. package/dist/ExternalParityRenderPreset.d.ts +149 -0
  79. package/dist/ExternalParityRenderPreset.d.ts.map +1 -0
  80. package/dist/ExternalParityRenderPreset.js +519 -0
  81. package/dist/ExternalParityRenderPreset.js.map +1 -0
  82. package/dist/ForwardPass.d.ts +122 -0
  83. package/dist/ForwardPass.d.ts.map +1 -0
  84. package/dist/ForwardPass.js +1352 -0
  85. package/dist/ForwardPass.js.map +1 -0
  86. package/dist/FrameVisualMetrics.d.ts +60 -0
  87. package/dist/FrameVisualMetrics.d.ts.map +1 -0
  88. package/dist/FrameVisualMetrics.js +146 -0
  89. package/dist/FrameVisualMetrics.js.map +1 -0
  90. package/dist/Geometry.d.ts +50 -0
  91. package/dist/Geometry.d.ts.map +1 -0
  92. package/dist/Geometry.js +385 -0
  93. package/dist/Geometry.js.map +1 -0
  94. package/dist/GeometryPrimitives.d.ts +3 -0
  95. package/dist/GeometryPrimitives.d.ts.map +1 -0
  96. package/dist/GeometryPrimitives.js +2 -0
  97. package/dist/GeometryPrimitives.js.map +1 -0
  98. package/dist/HDRRenderPipeline.d.ts +27 -0
  99. package/dist/HDRRenderPipeline.d.ts.map +1 -0
  100. package/dist/HDRRenderPipeline.js +67 -0
  101. package/dist/HDRRenderPipeline.js.map +1 -0
  102. package/dist/IBL.d.ts +37 -0
  103. package/dist/IBL.d.ts.map +1 -0
  104. package/dist/IBL.js +48 -0
  105. package/dist/IBL.js.map +1 -0
  106. package/dist/IndexBuffer.d.ts +15 -0
  107. package/dist/IndexBuffer.d.ts.map +1 -0
  108. package/dist/IndexBuffer.js +51 -0
  109. package/dist/IndexBuffer.js.map +1 -0
  110. package/dist/InstancedPBRMaterial.d.ts +33 -0
  111. package/dist/InstancedPBRMaterial.d.ts.map +1 -0
  112. package/dist/InstancedPBRMaterial.js +147 -0
  113. package/dist/InstancedPBRMaterial.js.map +1 -0
  114. package/dist/InstancedUnlitMaterial.d.ts +11 -0
  115. package/dist/InstancedUnlitMaterial.d.ts.map +1 -0
  116. package/dist/InstancedUnlitMaterial.js +50 -0
  117. package/dist/InstancedUnlitMaterial.js.map +1 -0
  118. package/dist/Instancing.d.ts +7 -0
  119. package/dist/Instancing.d.ts.map +1 -0
  120. package/dist/Instancing.js +14 -0
  121. package/dist/Instancing.js.map +1 -0
  122. package/dist/LightCollector.d.ts +24 -0
  123. package/dist/LightCollector.d.ts.map +1 -0
  124. package/dist/LightCollector.js +56 -0
  125. package/dist/LightCollector.js.map +1 -0
  126. package/dist/LightUniforms.d.ts +14 -0
  127. package/dist/LightUniforms.d.ts.map +1 -0
  128. package/dist/LightUniforms.js +37 -0
  129. package/dist/LightUniforms.js.map +1 -0
  130. package/dist/LightingDebug.d.ts +13 -0
  131. package/dist/LightingDebug.d.ts.map +1 -0
  132. package/dist/LightingDebug.js +69 -0
  133. package/dist/LightingDebug.js.map +1 -0
  134. package/dist/LightingDefaults.d.ts +13 -0
  135. package/dist/LightingDefaults.d.ts.map +1 -0
  136. package/dist/LightingDefaults.js +64 -0
  137. package/dist/LightingDefaults.js.map +1 -0
  138. package/dist/LightingRig.d.ts +53 -0
  139. package/dist/LightingRig.d.ts.map +1 -0
  140. package/dist/LightingRig.js +197 -0
  141. package/dist/LightingRig.js.map +1 -0
  142. package/dist/LineGeometry.d.ts +3 -0
  143. package/dist/LineGeometry.d.ts.map +1 -0
  144. package/dist/LineGeometry.js +2 -0
  145. package/dist/LineGeometry.js.map +1 -0
  146. package/dist/Material.d.ts +77 -0
  147. package/dist/Material.d.ts.map +1 -0
  148. package/dist/Material.js +137 -0
  149. package/dist/Material.js.map +1 -0
  150. package/dist/MaterialBinding.d.ts +17 -0
  151. package/dist/MaterialBinding.d.ts.map +1 -0
  152. package/dist/MaterialBinding.js +119 -0
  153. package/dist/MaterialBinding.js.map +1 -0
  154. package/dist/MaterialInstance.d.ts +16 -0
  155. package/dist/MaterialInstance.d.ts.map +1 -0
  156. package/dist/MaterialInstance.js +53 -0
  157. package/dist/MaterialInstance.js.map +1 -0
  158. package/dist/MaterialPresets.d.ts +31 -0
  159. package/dist/MaterialPresets.d.ts.map +1 -0
  160. package/dist/MaterialPresets.js +219 -0
  161. package/dist/MaterialPresets.js.map +1 -0
  162. package/dist/MorphTarget.d.ts +10 -0
  163. package/dist/MorphTarget.d.ts.map +1 -0
  164. package/dist/MorphTarget.js +101 -0
  165. package/dist/MorphTarget.js.map +1 -0
  166. package/dist/MorphUnlitMaterial.d.ts +11 -0
  167. package/dist/MorphUnlitMaterial.d.ts.map +1 -0
  168. package/dist/MorphUnlitMaterial.js +45 -0
  169. package/dist/MorphUnlitMaterial.js.map +1 -0
  170. package/dist/NormalMappedPBRMaterial.d.ts +37 -0
  171. package/dist/NormalMappedPBRMaterial.d.ts.map +1 -0
  172. package/dist/NormalMappedPBRMaterial.js +148 -0
  173. package/dist/NormalMappedPBRMaterial.js.map +1 -0
  174. package/dist/OceanFixtures.d.ts +62 -0
  175. package/dist/OceanFixtures.d.ts.map +1 -0
  176. package/dist/OceanFixtures.js +240 -0
  177. package/dist/OceanFixtures.js.map +1 -0
  178. package/dist/PBRLightingDefaults.d.ts +4 -0
  179. package/dist/PBRLightingDefaults.d.ts.map +1 -0
  180. package/dist/PBRLightingDefaults.js +10 -0
  181. package/dist/PBRLightingDefaults.js.map +1 -0
  182. package/dist/PBRMaterial.d.ts +84 -0
  183. package/dist/PBRMaterial.d.ts.map +1 -0
  184. package/dist/PBRMaterial.js +349 -0
  185. package/dist/PBRMaterial.js.map +1 -0
  186. package/dist/PMREM.d.ts +26 -0
  187. package/dist/PMREM.d.ts.map +1 -0
  188. package/dist/PMREM.js +26 -0
  189. package/dist/PMREM.js.map +1 -0
  190. package/dist/PbrReference.d.ts +153 -0
  191. package/dist/PbrReference.d.ts.map +1 -0
  192. package/dist/PbrReference.js +500 -0
  193. package/dist/PbrReference.js.map +1 -0
  194. package/dist/PostProcessPass.d.ts +439 -0
  195. package/dist/PostProcessPass.d.ts.map +1 -0
  196. package/dist/PostProcessPass.js +1834 -0
  197. package/dist/PostProcessPass.js.map +1 -0
  198. package/dist/ProceduralTextureFixtures.d.ts +27 -0
  199. package/dist/ProceduralTextureFixtures.d.ts.map +1 -0
  200. package/dist/ProceduralTextureFixtures.js +336 -0
  201. package/dist/ProceduralTextureFixtures.js.map +1 -0
  202. package/dist/ProductTurntableFixtures.d.ts +96 -0
  203. package/dist/ProductTurntableFixtures.d.ts.map +1 -0
  204. package/dist/ProductTurntableFixtures.js +559 -0
  205. package/dist/ProductTurntableFixtures.js.map +1 -0
  206. package/dist/Raycaster.d.ts +14 -0
  207. package/dist/Raycaster.d.ts.map +1 -0
  208. package/dist/Raycaster.js +10 -0
  209. package/dist/Raycaster.js.map +1 -0
  210. package/dist/ReflectionProbe.d.ts +8 -0
  211. package/dist/ReflectionProbe.d.ts.map +1 -0
  212. package/dist/ReflectionProbe.js +10 -0
  213. package/dist/ReflectionProbe.js.map +1 -0
  214. package/dist/ReflectionSurfaces.d.ts +35 -0
  215. package/dist/ReflectionSurfaces.d.ts.map +1 -0
  216. package/dist/ReflectionSurfaces.js +155 -0
  217. package/dist/ReflectionSurfaces.js.map +1 -0
  218. package/dist/RenderBackend.d.ts +14 -0
  219. package/dist/RenderBackend.d.ts.map +1 -0
  220. package/dist/RenderBackend.js +33 -0
  221. package/dist/RenderBackend.js.map +1 -0
  222. package/dist/RenderDebugViews.d.ts +26 -0
  223. package/dist/RenderDebugViews.d.ts.map +1 -0
  224. package/dist/RenderDebugViews.js +97 -0
  225. package/dist/RenderDebugViews.js.map +1 -0
  226. package/dist/RenderDevice.d.ts +280 -0
  227. package/dist/RenderDevice.d.ts.map +1 -0
  228. package/dist/RenderDevice.js +561 -0
  229. package/dist/RenderDevice.js.map +1 -0
  230. package/dist/RenderGraph.d.ts +22 -0
  231. package/dist/RenderGraph.d.ts.map +1 -0
  232. package/dist/RenderGraph.js +159 -0
  233. package/dist/RenderGraph.js.map +1 -0
  234. package/dist/RenderPass.d.ts +23 -0
  235. package/dist/RenderPass.d.ts.map +1 -0
  236. package/dist/RenderPass.js +14 -0
  237. package/dist/RenderPass.js.map +1 -0
  238. package/dist/RenderPipeline.d.ts +39 -0
  239. package/dist/RenderPipeline.d.ts.map +1 -0
  240. package/dist/RenderPipeline.js +67 -0
  241. package/dist/RenderPipeline.js.map +1 -0
  242. package/dist/RenderQueue.d.ts +3 -0
  243. package/dist/RenderQueue.d.ts.map +1 -0
  244. package/dist/RenderQueue.js +2 -0
  245. package/dist/RenderQueue.js.map +1 -0
  246. package/dist/RenderState.d.ts +3 -0
  247. package/dist/RenderState.d.ts.map +1 -0
  248. package/dist/RenderState.js +2 -0
  249. package/dist/RenderState.js.map +1 -0
  250. package/dist/Renderer.d.ts +265 -0
  251. package/dist/Renderer.d.ts.map +1 -0
  252. package/dist/Renderer.js +2094 -0
  253. package/dist/Renderer.js.map +1 -0
  254. package/dist/RendererDebugOverlay.d.ts +20 -0
  255. package/dist/RendererDebugOverlay.d.ts.map +1 -0
  256. package/dist/RendererDebugOverlay.js +54 -0
  257. package/dist/RendererDebugOverlay.js.map +1 -0
  258. package/dist/RendererFeatureGates.d.ts +17 -0
  259. package/dist/RendererFeatureGates.d.ts.map +1 -0
  260. package/dist/RendererFeatureGates.js +92 -0
  261. package/dist/RendererFeatureGates.js.map +1 -0
  262. package/dist/RendererPostprocessPlan.d.ts +59 -0
  263. package/dist/RendererPostprocessPlan.d.ts.map +1 -0
  264. package/dist/RendererPostprocessPlan.js +155 -0
  265. package/dist/RendererPostprocessPlan.js.map +1 -0
  266. package/dist/RendererTiming.d.ts +53 -0
  267. package/dist/RendererTiming.d.ts.map +1 -0
  268. package/dist/RendererTiming.js +186 -0
  269. package/dist/RendererTiming.js.map +1 -0
  270. package/dist/RendererVisualPipelineReport.d.ts +224 -0
  271. package/dist/RendererVisualPipelineReport.d.ts.map +1 -0
  272. package/dist/RendererVisualPipelineReport.js +499 -0
  273. package/dist/RendererVisualPipelineReport.js.map +1 -0
  274. package/dist/ResourceLifecycle.d.ts +8 -0
  275. package/dist/ResourceLifecycle.d.ts.map +1 -0
  276. package/dist/ResourceLifecycle.js +18 -0
  277. package/dist/ResourceLifecycle.js.map +1 -0
  278. package/dist/Sampler.d.ts +20 -0
  279. package/dist/Sampler.d.ts.map +1 -0
  280. package/dist/Sampler.js +19 -0
  281. package/dist/Sampler.js.map +1 -0
  282. package/dist/SceneOptimization.d.ts +127 -0
  283. package/dist/SceneOptimization.d.ts.map +1 -0
  284. package/dist/SceneOptimization.js +342 -0
  285. package/dist/SceneOptimization.js.map +1 -0
  286. package/dist/ShaderChunks.d.ts +8 -0
  287. package/dist/ShaderChunks.d.ts.map +1 -0
  288. package/dist/ShaderChunks.js +386 -0
  289. package/dist/ShaderChunks.js.map +1 -0
  290. package/dist/ShaderLibrary.d.ts +63 -0
  291. package/dist/ShaderLibrary.d.ts.map +1 -0
  292. package/dist/ShaderLibrary.js +2707 -0
  293. package/dist/ShaderLibrary.js.map +1 -0
  294. package/dist/ShaderModule.d.ts +14 -0
  295. package/dist/ShaderModule.d.ts.map +1 -0
  296. package/dist/ShaderModule.js +33 -0
  297. package/dist/ShaderModule.js.map +1 -0
  298. package/dist/ShaderPreprocessor.d.ts +19 -0
  299. package/dist/ShaderPreprocessor.d.ts.map +1 -0
  300. package/dist/ShaderPreprocessor.js +212 -0
  301. package/dist/ShaderPreprocessor.js.map +1 -0
  302. package/dist/ShaderReflection.d.ts +23 -0
  303. package/dist/ShaderReflection.d.ts.map +1 -0
  304. package/dist/ShaderReflection.js +134 -0
  305. package/dist/ShaderReflection.js.map +1 -0
  306. package/dist/ShadowMap.d.ts +58 -0
  307. package/dist/ShadowMap.d.ts.map +1 -0
  308. package/dist/ShadowMap.js +183 -0
  309. package/dist/ShadowMap.js.map +1 -0
  310. package/dist/ShadowPass.d.ts +44 -0
  311. package/dist/ShadowPass.d.ts.map +1 -0
  312. package/dist/ShadowPass.js +162 -0
  313. package/dist/ShadowPass.js.map +1 -0
  314. package/dist/ShadowProjection.d.ts +15 -0
  315. package/dist/ShadowProjection.d.ts.map +1 -0
  316. package/dist/ShadowProjection.js +90 -0
  317. package/dist/ShadowProjection.js.map +1 -0
  318. package/dist/SkinnedLitMaterial.d.ts +63 -0
  319. package/dist/SkinnedLitMaterial.d.ts.map +1 -0
  320. package/dist/SkinnedLitMaterial.js +296 -0
  321. package/dist/SkinnedLitMaterial.js.map +1 -0
  322. package/dist/SkinnedUnlitMaterial.d.ts +13 -0
  323. package/dist/SkinnedUnlitMaterial.d.ts.map +1 -0
  324. package/dist/SkinnedUnlitMaterial.js +52 -0
  325. package/dist/SkinnedUnlitMaterial.js.map +1 -0
  326. package/dist/SkinningBounds.d.ts +10 -0
  327. package/dist/SkinningBounds.d.ts.map +1 -0
  328. package/dist/SkinningBounds.js +107 -0
  329. package/dist/SkinningBounds.js.map +1 -0
  330. package/dist/SpaceEnvironmentFixtures.d.ts +59 -0
  331. package/dist/SpaceEnvironmentFixtures.d.ts.map +1 -0
  332. package/dist/SpaceEnvironmentFixtures.js +132 -0
  333. package/dist/SpaceEnvironmentFixtures.js.map +1 -0
  334. package/dist/SpriteGeometry.d.ts +3 -0
  335. package/dist/SpriteGeometry.d.ts.map +1 -0
  336. package/dist/SpriteGeometry.js +21 -0
  337. package/dist/SpriteGeometry.js.map +1 -0
  338. package/dist/StereoCameraRig.d.ts +34 -0
  339. package/dist/StereoCameraRig.d.ts.map +1 -0
  340. package/dist/StereoCameraRig.js +79 -0
  341. package/dist/StereoCameraRig.js.map +1 -0
  342. package/dist/StereoEffects.d.ts +90 -0
  343. package/dist/StereoEffects.d.ts.map +1 -0
  344. package/dist/StereoEffects.js +171 -0
  345. package/dist/StereoEffects.js.map +1 -0
  346. package/dist/TerrainFixtures.d.ts +36 -0
  347. package/dist/TerrainFixtures.d.ts.map +1 -0
  348. package/dist/TerrainFixtures.js +143 -0
  349. package/dist/TerrainFixtures.js.map +1 -0
  350. package/dist/Texture.d.ts +64 -0
  351. package/dist/Texture.d.ts.map +1 -0
  352. package/dist/Texture.js +257 -0
  353. package/dist/Texture.js.map +1 -0
  354. package/dist/TextureBinding.d.ts +38 -0
  355. package/dist/TextureBinding.d.ts.map +1 -0
  356. package/dist/TextureBinding.js +66 -0
  357. package/dist/TextureBinding.js.map +1 -0
  358. package/dist/TexturedPBRMaterial.d.ts +206 -0
  359. package/dist/TexturedPBRMaterial.d.ts.map +1 -0
  360. package/dist/TexturedPBRMaterial.js +842 -0
  361. package/dist/TexturedPBRMaterial.js.map +1 -0
  362. package/dist/TexturedUnlitMaterial.d.ts +19 -0
  363. package/dist/TexturedUnlitMaterial.d.ts.map +1 -0
  364. package/dist/TexturedUnlitMaterial.js +52 -0
  365. package/dist/TexturedUnlitMaterial.js.map +1 -0
  366. package/dist/ToneMapping.d.ts +19 -0
  367. package/dist/ToneMapping.d.ts.map +1 -0
  368. package/dist/ToneMapping.js +53 -0
  369. package/dist/ToneMapping.js.map +1 -0
  370. package/dist/UniformBinder.d.ts +7 -0
  371. package/dist/UniformBinder.d.ts.map +1 -0
  372. package/dist/UniformBinder.js +14 -0
  373. package/dist/UniformBinder.js.map +1 -0
  374. package/dist/UniformLayout.d.ts +19 -0
  375. package/dist/UniformLayout.d.ts.map +1 -0
  376. package/dist/UniformLayout.js +107 -0
  377. package/dist/UniformLayout.js.map +1 -0
  378. package/dist/UnlitMaterial.d.ts +16 -0
  379. package/dist/UnlitMaterial.d.ts.map +1 -0
  380. package/dist/UnlitMaterial.js +60 -0
  381. package/dist/UnlitMaterial.js.map +1 -0
  382. package/dist/VegetationFixtures.d.ts +68 -0
  383. package/dist/VegetationFixtures.d.ts.map +1 -0
  384. package/dist/VegetationFixtures.js +241 -0
  385. package/dist/VegetationFixtures.js.map +1 -0
  386. package/dist/VertexBuffer.d.ts +29 -0
  387. package/dist/VertexBuffer.d.ts.map +1 -0
  388. package/dist/VertexBuffer.js +106 -0
  389. package/dist/VertexBuffer.js.map +1 -0
  390. package/dist/VertexFormat.d.ts +36 -0
  391. package/dist/VertexFormat.d.ts.map +1 -0
  392. package/dist/VertexFormat.js +127 -0
  393. package/dist/VertexFormat.js.map +1 -0
  394. package/dist/VoxelWorldFixtures.d.ts +54 -0
  395. package/dist/VoxelWorldFixtures.d.ts.map +1 -0
  396. package/dist/VoxelWorldFixtures.js +186 -0
  397. package/dist/VoxelWorldFixtures.js.map +1 -0
  398. package/dist/WeatherFixtures.d.ts +46 -0
  399. package/dist/WeatherFixtures.d.ts.map +1 -0
  400. package/dist/WeatherFixtures.js +142 -0
  401. package/dist/WeatherFixtures.js.map +1 -0
  402. package/dist/WebGL2Device.d.ts +137 -0
  403. package/dist/WebGL2Device.d.ts.map +1 -0
  404. package/dist/WebGL2Device.js +2107 -0
  405. package/dist/WebGL2Device.js.map +1 -0
  406. package/dist/WebGL2StateCache.d.ts +89 -0
  407. package/dist/WebGL2StateCache.d.ts.map +1 -0
  408. package/dist/WebGL2StateCache.js +265 -0
  409. package/dist/WebGL2StateCache.js.map +1 -0
  410. package/dist/WebGPUDevice.d.ts +287 -0
  411. package/dist/WebGPUDevice.d.ts.map +1 -0
  412. package/dist/WebGPUDevice.js +2403 -0
  413. package/dist/WebGPUDevice.js.map +1 -0
  414. package/dist/WebGPURenderToTextureProof.d.ts +29 -0
  415. package/dist/WebGPURenderToTextureProof.d.ts.map +1 -0
  416. package/dist/WebGPURenderToTextureProof.js +96 -0
  417. package/dist/WebGPURenderToTextureProof.js.map +1 -0
  418. package/dist/advanced-runtime/AdvancedRenderer.d.ts +23 -0
  419. package/dist/advanced-runtime/AdvancedRenderer.d.ts.map +1 -0
  420. package/dist/advanced-runtime/AdvancedRenderer.js +45 -0
  421. package/dist/advanced-runtime/AdvancedRenderer.js.map +1 -0
  422. package/dist/advanced-runtime/index.d.ts +10 -0
  423. package/dist/advanced-runtime/index.d.ts.map +1 -0
  424. package/dist/advanced-runtime/index.js +9 -0
  425. package/dist/advanced-runtime/index.js.map +1 -0
  426. package/dist/cinematic/BloomPass.d.ts +10 -0
  427. package/dist/cinematic/BloomPass.d.ts.map +1 -0
  428. package/dist/cinematic/BloomPass.js +18 -0
  429. package/dist/cinematic/BloomPass.js.map +1 -0
  430. package/dist/cinematic/CinematicDepthComposition.d.ts +12 -0
  431. package/dist/cinematic/CinematicDepthComposition.d.ts.map +1 -0
  432. package/dist/cinematic/CinematicDepthComposition.js +22 -0
  433. package/dist/cinematic/CinematicDepthComposition.js.map +1 -0
  434. package/dist/cinematic/CinematicEvidence.d.ts +43 -0
  435. package/dist/cinematic/CinematicEvidence.d.ts.map +1 -0
  436. package/dist/cinematic/CinematicEvidence.js +55 -0
  437. package/dist/cinematic/CinematicEvidence.js.map +1 -0
  438. package/dist/cinematic/CinematicLightingRig.d.ts +32 -0
  439. package/dist/cinematic/CinematicLightingRig.d.ts.map +1 -0
  440. package/dist/cinematic/CinematicLightingRig.js +90 -0
  441. package/dist/cinematic/CinematicLightingRig.js.map +1 -0
  442. package/dist/cinematic/CinematicMaterialPresets.d.ts +16 -0
  443. package/dist/cinematic/CinematicMaterialPresets.d.ts.map +1 -0
  444. package/dist/cinematic/CinematicMaterialPresets.js +114 -0
  445. package/dist/cinematic/CinematicMaterialPresets.js.map +1 -0
  446. package/dist/cinematic/CinematicPostProcess.d.ts +25 -0
  447. package/dist/cinematic/CinematicPostProcess.d.ts.map +1 -0
  448. package/dist/cinematic/CinematicPostProcess.js +64 -0
  449. package/dist/cinematic/CinematicPostProcess.js.map +1 -0
  450. package/dist/cinematic/DepthHazePass.d.ts +12 -0
  451. package/dist/cinematic/DepthHazePass.d.ts.map +1 -0
  452. package/dist/cinematic/DepthHazePass.js +20 -0
  453. package/dist/cinematic/DepthHazePass.js.map +1 -0
  454. package/dist/cinematic/EmissivePracticalLightSystem.d.ts +18 -0
  455. package/dist/cinematic/EmissivePracticalLightSystem.d.ts.map +1 -0
  456. package/dist/cinematic/EmissivePracticalLightSystem.js +25 -0
  457. package/dist/cinematic/EmissivePracticalLightSystem.js.map +1 -0
  458. package/dist/cinematic/FilmGrainPass.d.ts +9 -0
  459. package/dist/cinematic/FilmGrainPass.d.ts.map +1 -0
  460. package/dist/cinematic/FilmGrainPass.js +17 -0
  461. package/dist/cinematic/FilmGrainPass.js.map +1 -0
  462. package/dist/cinematic/FogVolumeSystem.d.ts +12 -0
  463. package/dist/cinematic/FogVolumeSystem.d.ts.map +1 -0
  464. package/dist/cinematic/FogVolumeSystem.js +20 -0
  465. package/dist/cinematic/FogVolumeSystem.js.map +1 -0
  466. package/dist/cinematic/GlowCardSystem.d.ts +17 -0
  467. package/dist/cinematic/GlowCardSystem.d.ts.map +1 -0
  468. package/dist/cinematic/GlowCardSystem.js +28 -0
  469. package/dist/cinematic/GlowCardSystem.js.map +1 -0
  470. package/dist/cinematic/RainParticleSystem.d.ts +22 -0
  471. package/dist/cinematic/RainParticleSystem.d.ts.map +1 -0
  472. package/dist/cinematic/RainParticleSystem.js +114 -0
  473. package/dist/cinematic/RainParticleSystem.js.map +1 -0
  474. package/dist/cinematic/VignettePass.d.ts +10 -0
  475. package/dist/cinematic/VignettePass.d.ts.map +1 -0
  476. package/dist/cinematic/VignettePass.js +17 -0
  477. package/dist/cinematic/VignettePass.js.map +1 -0
  478. package/dist/cinematic/WetReflectionApproximation.d.ts +13 -0
  479. package/dist/cinematic/WetReflectionApproximation.d.ts.map +1 -0
  480. package/dist/cinematic/WetReflectionApproximation.js +18 -0
  481. package/dist/cinematic/WetReflectionApproximation.js.map +1 -0
  482. package/dist/cinematic/index.d.ts +15 -0
  483. package/dist/cinematic/index.d.ts.map +1 -0
  484. package/dist/cinematic/index.js +15 -0
  485. package/dist/cinematic/index.js.map +1 -0
  486. package/dist/effects/CollisionModule.d.ts +15 -0
  487. package/dist/effects/CollisionModule.d.ts.map +1 -0
  488. package/dist/effects/CollisionModule.js +46 -0
  489. package/dist/effects/CollisionModule.js.map +1 -0
  490. package/dist/effects/ColorModule.d.ts +15 -0
  491. package/dist/effects/ColorModule.d.ts.map +1 -0
  492. package/dist/effects/ColorModule.js +45 -0
  493. package/dist/effects/ColorModule.js.map +1 -0
  494. package/dist/effects/ForceModule.d.ts +11 -0
  495. package/dist/effects/ForceModule.d.ts.map +1 -0
  496. package/dist/effects/ForceModule.js +17 -0
  497. package/dist/effects/ForceModule.js.map +1 -0
  498. package/dist/effects/GPUParticleBackend.d.ts +153 -0
  499. package/dist/effects/GPUParticleBackend.d.ts.map +1 -0
  500. package/dist/effects/GPUParticleBackend.js +397 -0
  501. package/dist/effects/GPUParticleBackend.js.map +1 -0
  502. package/dist/effects/Particle.d.ts +49 -0
  503. package/dist/effects/Particle.d.ts.map +1 -0
  504. package/dist/effects/Particle.js +56 -0
  505. package/dist/effects/Particle.js.map +1 -0
  506. package/dist/effects/ParticleDiagnostics.d.ts +58 -0
  507. package/dist/effects/ParticleDiagnostics.d.ts.map +1 -0
  508. package/dist/effects/ParticleDiagnostics.js +145 -0
  509. package/dist/effects/ParticleDiagnostics.js.map +1 -0
  510. package/dist/effects/ParticleEffectPresets.d.ts +8 -0
  511. package/dist/effects/ParticleEffectPresets.d.ts.map +1 -0
  512. package/dist/effects/ParticleEffectPresets.js +137 -0
  513. package/dist/effects/ParticleEffectPresets.js.map +1 -0
  514. package/dist/effects/ParticleEmitter.d.ts +87 -0
  515. package/dist/effects/ParticleEmitter.d.ts.map +1 -0
  516. package/dist/effects/ParticleEmitter.js +254 -0
  517. package/dist/effects/ParticleEmitter.js.map +1 -0
  518. package/dist/effects/ParticleModule.d.ts +15 -0
  519. package/dist/effects/ParticleModule.d.ts.map +1 -0
  520. package/dist/effects/ParticleModule.js +6 -0
  521. package/dist/effects/ParticleModule.js.map +1 -0
  522. package/dist/effects/ParticleRenderPass.d.ts +35 -0
  523. package/dist/effects/ParticleRenderPass.d.ts.map +1 -0
  524. package/dist/effects/ParticleRenderPass.js +91 -0
  525. package/dist/effects/ParticleRenderPass.js.map +1 -0
  526. package/dist/effects/ParticleRenderer.d.ts +34 -0
  527. package/dist/effects/ParticleRenderer.d.ts.map +1 -0
  528. package/dist/effects/ParticleRenderer.js +93 -0
  529. package/dist/effects/ParticleRenderer.js.map +1 -0
  530. package/dist/effects/ParticleSystem.d.ts +51 -0
  531. package/dist/effects/ParticleSystem.d.ts.map +1 -0
  532. package/dist/effects/ParticleSystem.js +261 -0
  533. package/dist/effects/ParticleSystem.js.map +1 -0
  534. package/dist/effects/SizeModule.d.ts +14 -0
  535. package/dist/effects/SizeModule.d.ts.map +1 -0
  536. package/dist/effects/SizeModule.js +42 -0
  537. package/dist/effects/SizeModule.js.map +1 -0
  538. package/dist/effects/TrailModule.d.ts +22 -0
  539. package/dist/effects/TrailModule.d.ts.map +1 -0
  540. package/dist/effects/TrailModule.js +50 -0
  541. package/dist/effects/TrailModule.js.map +1 -0
  542. package/dist/effects/VelocityModule.d.ts +15 -0
  543. package/dist/effects/VelocityModule.d.ts.map +1 -0
  544. package/dist/effects/VelocityModule.js +57 -0
  545. package/dist/effects/VelocityModule.js.map +1 -0
  546. package/dist/effects/index.d.ts +16 -0
  547. package/dist/effects/index.d.ts.map +1 -0
  548. package/dist/effects/index.js +16 -0
  549. package/dist/effects/index.js.map +1 -0
  550. package/dist/index.d.ts +260 -0
  551. package/dist/index.d.ts.map +1 -0
  552. package/dist/index.js +155 -0
  553. package/dist/index.js.map +1 -0
  554. package/dist/materials/AlphaSorting.d.ts +8 -0
  555. package/dist/materials/AlphaSorting.d.ts.map +1 -0
  556. package/dist/materials/AlphaSorting.js +26 -0
  557. package/dist/materials/AlphaSorting.js.map +1 -0
  558. package/dist/materials/MaterialExtensions.d.ts +10 -0
  559. package/dist/materials/MaterialExtensions.d.ts.map +1 -0
  560. package/dist/materials/MaterialExtensions.js +20 -0
  561. package/dist/materials/MaterialExtensions.js.map +1 -0
  562. package/dist/materials/PhysicalMaterial.d.ts +36 -0
  563. package/dist/materials/PhysicalMaterial.d.ts.map +1 -0
  564. package/dist/materials/PhysicalMaterial.js +79 -0
  565. package/dist/materials/PhysicalMaterial.js.map +1 -0
  566. package/dist/materials/TransmissionPass.d.ts +16 -0
  567. package/dist/materials/TransmissionPass.d.ts.map +1 -0
  568. package/dist/materials/TransmissionPass.js +30 -0
  569. package/dist/materials/TransmissionPass.js.map +1 -0
  570. package/dist/performance/BVH.d.ts +3 -0
  571. package/dist/performance/BVH.d.ts.map +1 -0
  572. package/dist/performance/BVH.js +2 -0
  573. package/dist/performance/BVH.js.map +1 -0
  574. package/dist/performance/Batcher.d.ts +3 -0
  575. package/dist/performance/Batcher.d.ts.map +1 -0
  576. package/dist/performance/Batcher.js +2 -0
  577. package/dist/performance/Batcher.js.map +1 -0
  578. package/dist/performance/FrustumCuller.d.ts +3 -0
  579. package/dist/performance/FrustumCuller.d.ts.map +1 -0
  580. package/dist/performance/FrustumCuller.js +5 -0
  581. package/dist/performance/FrustumCuller.js.map +1 -0
  582. package/dist/performance/LOD.d.ts +8 -0
  583. package/dist/performance/LOD.d.ts.map +1 -0
  584. package/dist/performance/LOD.js +15 -0
  585. package/dist/performance/LOD.js.map +1 -0
  586. package/dist/performance/Octree.d.ts +7 -0
  587. package/dist/performance/Octree.d.ts.map +1 -0
  588. package/dist/performance/Octree.js +4 -0
  589. package/dist/performance/Octree.js.map +1 -0
  590. package/dist/performance/RenderItemSorting.d.ts +43 -0
  591. package/dist/performance/RenderItemSorting.d.ts.map +1 -0
  592. package/dist/performance/RenderItemSorting.js +111 -0
  593. package/dist/performance/RenderItemSorting.js.map +1 -0
  594. package/dist/performance/RendererStats.d.ts +23 -0
  595. package/dist/performance/RendererStats.d.ts.map +1 -0
  596. package/dist/performance/RendererStats.js +23 -0
  597. package/dist/performance/RendererStats.js.map +1 -0
  598. package/dist/performance/ResourceBudget.d.ts +19 -0
  599. package/dist/performance/ResourceBudget.d.ts.map +1 -0
  600. package/dist/performance/ResourceBudget.js +21 -0
  601. package/dist/performance/ResourceBudget.js.map +1 -0
  602. package/dist/postprocess/BloomPass.d.ts +11 -0
  603. package/dist/postprocess/BloomPass.d.ts.map +1 -0
  604. package/dist/postprocess/BloomPass.js +14 -0
  605. package/dist/postprocess/BloomPass.js.map +1 -0
  606. package/dist/postprocess/CinematicDiagnostics.d.ts +112 -0
  607. package/dist/postprocess/CinematicDiagnostics.d.ts.map +1 -0
  608. package/dist/postprocess/CinematicDiagnostics.js +492 -0
  609. package/dist/postprocess/CinematicDiagnostics.js.map +1 -0
  610. package/dist/postprocess/ColorGradingPass.d.ts +4 -0
  611. package/dist/postprocess/ColorGradingPass.d.ts.map +1 -0
  612. package/dist/postprocess/ColorGradingPass.js +15 -0
  613. package/dist/postprocess/ColorGradingPass.js.map +1 -0
  614. package/dist/postprocess/DepthOfFieldPass.d.ts +3 -0
  615. package/dist/postprocess/DepthOfFieldPass.d.ts.map +1 -0
  616. package/dist/postprocess/DepthOfFieldPass.js +7 -0
  617. package/dist/postprocess/DepthOfFieldPass.js.map +1 -0
  618. package/dist/postprocess/EffectComposer.d.ts +110 -0
  619. package/dist/postprocess/EffectComposer.d.ts.map +1 -0
  620. package/dist/postprocess/EffectComposer.js +249 -0
  621. package/dist/postprocess/EffectComposer.js.map +1 -0
  622. package/dist/postprocess/SSAOPass.d.ts +6 -0
  623. package/dist/postprocess/SSAOPass.d.ts.map +1 -0
  624. package/dist/postprocess/SSAOPass.js +18 -0
  625. package/dist/postprocess/SSAOPass.js.map +1 -0
  626. package/dist/postprocess/index.d.ts +11 -0
  627. package/dist/postprocess/index.d.ts.map +1 -0
  628. package/dist/postprocess/index.js +7 -0
  629. package/dist/postprocess/index.js.map +1 -0
  630. package/dist/production-runtime/AnimationControlsPipeline.d.ts +37 -0
  631. package/dist/production-runtime/AnimationControlsPipeline.d.ts.map +1 -0
  632. package/dist/production-runtime/AnimationControlsPipeline.js +41 -0
  633. package/dist/production-runtime/AnimationControlsPipeline.js.map +1 -0
  634. package/dist/production-runtime/PBRHDRPipeline.d.ts +81 -0
  635. package/dist/production-runtime/PBRHDRPipeline.d.ts.map +1 -0
  636. package/dist/production-runtime/PBRHDRPipeline.js +279 -0
  637. package/dist/production-runtime/PBRHDRPipeline.js.map +1 -0
  638. package/dist/production-runtime/ProductionEffectsPipeline.d.ts +20 -0
  639. package/dist/production-runtime/ProductionEffectsPipeline.d.ts.map +1 -0
  640. package/dist/production-runtime/ProductionEffectsPipeline.js +65 -0
  641. package/dist/production-runtime/ProductionEffectsPipeline.js.map +1 -0
  642. package/dist/production-runtime/ProductionRendererTypes.d.ts +97 -0
  643. package/dist/production-runtime/ProductionRendererTypes.d.ts.map +1 -0
  644. package/dist/production-runtime/ProductionRendererTypes.js +29 -0
  645. package/dist/production-runtime/ProductionRendererTypes.js.map +1 -0
  646. package/dist/production-runtime/ProductionRuntimeRenderer.d.ts +36 -0
  647. package/dist/production-runtime/ProductionRuntimeRenderer.d.ts.map +1 -0
  648. package/dist/production-runtime/ProductionRuntimeRenderer.js +124 -0
  649. package/dist/production-runtime/ProductionRuntimeRenderer.js.map +1 -0
  650. package/dist/production-runtime/ProductionWebGL2Renderer.d.ts +51 -0
  651. package/dist/production-runtime/ProductionWebGL2Renderer.d.ts.map +1 -0
  652. package/dist/production-runtime/ProductionWebGL2Renderer.js +269 -0
  653. package/dist/production-runtime/ProductionWebGL2Renderer.js.map +1 -0
  654. package/dist/production-runtime/ProductionWebGPURenderer.d.ts +69 -0
  655. package/dist/production-runtime/ProductionWebGPURenderer.d.ts.map +1 -0
  656. package/dist/production-runtime/ProductionWebGPURenderer.js +313 -0
  657. package/dist/production-runtime/ProductionWebGPURenderer.js.map +1 -0
  658. package/dist/production-runtime/TransmissionBackdropCapture.d.ts +11 -0
  659. package/dist/production-runtime/TransmissionBackdropCapture.d.ts.map +1 -0
  660. package/dist/production-runtime/TransmissionBackdropCapture.js +119 -0
  661. package/dist/production-runtime/TransmissionBackdropCapture.js.map +1 -0
  662. package/dist/production-runtime/animation/MorphTargetRenderer.d.ts +7 -0
  663. package/dist/production-runtime/animation/MorphTargetRenderer.d.ts.map +1 -0
  664. package/dist/production-runtime/animation/MorphTargetRenderer.js +2 -0
  665. package/dist/production-runtime/animation/MorphTargetRenderer.js.map +1 -0
  666. package/dist/production-runtime/animation/SkinningRenderer.d.ts +7 -0
  667. package/dist/production-runtime/animation/SkinningRenderer.d.ts.map +1 -0
  668. package/dist/production-runtime/animation/SkinningRenderer.js +2 -0
  669. package/dist/production-runtime/animation/SkinningRenderer.js.map +1 -0
  670. package/dist/production-runtime/backends/RendererBackend.d.ts +16 -0
  671. package/dist/production-runtime/backends/RendererBackend.d.ts.map +1 -0
  672. package/dist/production-runtime/backends/RendererBackend.js +2 -0
  673. package/dist/production-runtime/backends/RendererBackend.js.map +1 -0
  674. package/dist/production-runtime/backends/WebGL2RendererBackend.d.ts +15 -0
  675. package/dist/production-runtime/backends/WebGL2RendererBackend.d.ts.map +1 -0
  676. package/dist/production-runtime/backends/WebGL2RendererBackend.js +25 -0
  677. package/dist/production-runtime/backends/WebGL2RendererBackend.js.map +1 -0
  678. package/dist/production-runtime/backends/WebGPURendererBackend.d.ts +20 -0
  679. package/dist/production-runtime/backends/WebGPURendererBackend.d.ts.map +1 -0
  680. package/dist/production-runtime/backends/WebGPURendererBackend.js +19 -0
  681. package/dist/production-runtime/backends/WebGPURendererBackend.js.map +1 -0
  682. package/dist/production-runtime/backends/webgl2/WebGL2Buffer.d.ts +11 -0
  683. package/dist/production-runtime/backends/webgl2/WebGL2Buffer.d.ts.map +1 -0
  684. package/dist/production-runtime/backends/webgl2/WebGL2Buffer.js +8 -0
  685. package/dist/production-runtime/backends/webgl2/WebGL2Buffer.js.map +1 -0
  686. package/dist/production-runtime/backends/webgl2/WebGL2Capabilities.d.ts +11 -0
  687. package/dist/production-runtime/backends/webgl2/WebGL2Capabilities.d.ts.map +1 -0
  688. package/dist/production-runtime/backends/webgl2/WebGL2Capabilities.js +8 -0
  689. package/dist/production-runtime/backends/webgl2/WebGL2Capabilities.js.map +1 -0
  690. package/dist/production-runtime/backends/webgl2/WebGL2RenderTarget.d.ts +11 -0
  691. package/dist/production-runtime/backends/webgl2/WebGL2RenderTarget.d.ts.map +1 -0
  692. package/dist/production-runtime/backends/webgl2/WebGL2RenderTarget.js +8 -0
  693. package/dist/production-runtime/backends/webgl2/WebGL2RenderTarget.js.map +1 -0
  694. package/dist/production-runtime/backends/webgl2/WebGL2Shader.d.ts +11 -0
  695. package/dist/production-runtime/backends/webgl2/WebGL2Shader.d.ts.map +1 -0
  696. package/dist/production-runtime/backends/webgl2/WebGL2Shader.js +8 -0
  697. package/dist/production-runtime/backends/webgl2/WebGL2Shader.js.map +1 -0
  698. package/dist/production-runtime/backends/webgl2/WebGL2StateCache.d.ts +2 -0
  699. package/dist/production-runtime/backends/webgl2/WebGL2StateCache.d.ts.map +1 -0
  700. package/dist/production-runtime/backends/webgl2/WebGL2StateCache.js +2 -0
  701. package/dist/production-runtime/backends/webgl2/WebGL2StateCache.js.map +1 -0
  702. package/dist/production-runtime/backends/webgl2/WebGL2Texture.d.ts +11 -0
  703. package/dist/production-runtime/backends/webgl2/WebGL2Texture.d.ts.map +1 -0
  704. package/dist/production-runtime/backends/webgl2/WebGL2Texture.js +8 -0
  705. package/dist/production-runtime/backends/webgl2/WebGL2Texture.js.map +1 -0
  706. package/dist/production-runtime/backends/webgpu/WebGPUBuffer.d.ts +11 -0
  707. package/dist/production-runtime/backends/webgpu/WebGPUBuffer.d.ts.map +1 -0
  708. package/dist/production-runtime/backends/webgpu/WebGPUBuffer.js +8 -0
  709. package/dist/production-runtime/backends/webgpu/WebGPUBuffer.js.map +1 -0
  710. package/dist/production-runtime/backends/webgpu/WebGPUCapabilities.d.ts +11 -0
  711. package/dist/production-runtime/backends/webgpu/WebGPUCapabilities.d.ts.map +1 -0
  712. package/dist/production-runtime/backends/webgpu/WebGPUCapabilities.js +8 -0
  713. package/dist/production-runtime/backends/webgpu/WebGPUCapabilities.js.map +1 -0
  714. package/dist/production-runtime/backends/webgpu/WebGPURenderTarget.d.ts +11 -0
  715. package/dist/production-runtime/backends/webgpu/WebGPURenderTarget.d.ts.map +1 -0
  716. package/dist/production-runtime/backends/webgpu/WebGPURenderTarget.js +8 -0
  717. package/dist/production-runtime/backends/webgpu/WebGPURenderTarget.js.map +1 -0
  718. package/dist/production-runtime/backends/webgpu/WebGPUShader.d.ts +11 -0
  719. package/dist/production-runtime/backends/webgpu/WebGPUShader.d.ts.map +1 -0
  720. package/dist/production-runtime/backends/webgpu/WebGPUShader.js +8 -0
  721. package/dist/production-runtime/backends/webgpu/WebGPUShader.js.map +1 -0
  722. package/dist/production-runtime/backends/webgpu/WebGPUTexture.d.ts +11 -0
  723. package/dist/production-runtime/backends/webgpu/WebGPUTexture.d.ts.map +1 -0
  724. package/dist/production-runtime/backends/webgpu/WebGPUTexture.js +8 -0
  725. package/dist/production-runtime/backends/webgpu/WebGPUTexture.js.map +1 -0
  726. package/dist/production-runtime/color/ColorManagement.d.ts +4 -0
  727. package/dist/production-runtime/color/ColorManagement.d.ts.map +1 -0
  728. package/dist/production-runtime/color/ColorManagement.js +3 -0
  729. package/dist/production-runtime/color/ColorManagement.js.map +1 -0
  730. package/dist/production-runtime/color/ToneMapping.d.ts +3 -0
  731. package/dist/production-runtime/color/ToneMapping.d.ts.map +1 -0
  732. package/dist/production-runtime/color/ToneMapping.js +9 -0
  733. package/dist/production-runtime/color/ToneMapping.js.map +1 -0
  734. package/dist/production-runtime/diagnostics/FrameCapture.d.ts +7 -0
  735. package/dist/production-runtime/diagnostics/FrameCapture.d.ts.map +1 -0
  736. package/dist/production-runtime/diagnostics/FrameCapture.js +2 -0
  737. package/dist/production-runtime/diagnostics/FrameCapture.js.map +1 -0
  738. package/dist/production-runtime/diagnostics/GPUCapabilities.d.ts +9 -0
  739. package/dist/production-runtime/diagnostics/GPUCapabilities.d.ts.map +1 -0
  740. package/dist/production-runtime/diagnostics/GPUCapabilities.js +2 -0
  741. package/dist/production-runtime/diagnostics/GPUCapabilities.js.map +1 -0
  742. package/dist/production-runtime/diagnostics/RendererStats.d.ts +9 -0
  743. package/dist/production-runtime/diagnostics/RendererStats.d.ts.map +1 -0
  744. package/dist/production-runtime/diagnostics/RendererStats.js +2 -0
  745. package/dist/production-runtime/diagnostics/RendererStats.js.map +1 -0
  746. package/dist/production-runtime/environment/EnvironmentMap.d.ts +8 -0
  747. package/dist/production-runtime/environment/EnvironmentMap.d.ts.map +1 -0
  748. package/dist/production-runtime/environment/EnvironmentMap.js +2 -0
  749. package/dist/production-runtime/environment/EnvironmentMap.js.map +1 -0
  750. package/dist/production-runtime/environment/HDRLoader.d.ts +19 -0
  751. package/dist/production-runtime/environment/HDRLoader.d.ts.map +1 -0
  752. package/dist/production-runtime/environment/HDRLoader.js +22 -0
  753. package/dist/production-runtime/environment/HDRLoader.js.map +1 -0
  754. package/dist/production-runtime/environment/PMREMGenerator.d.ts +99 -0
  755. package/dist/production-runtime/environment/PMREMGenerator.d.ts.map +1 -0
  756. package/dist/production-runtime/environment/PMREMGenerator.js +534 -0
  757. package/dist/production-runtime/environment/PMREMGenerator.js.map +1 -0
  758. package/dist/production-runtime/framegraph/FrameGraph.d.ts +8 -0
  759. package/dist/production-runtime/framegraph/FrameGraph.d.ts.map +1 -0
  760. package/dist/production-runtime/framegraph/FrameGraph.js +14 -0
  761. package/dist/production-runtime/framegraph/FrameGraph.js.map +1 -0
  762. package/dist/production-runtime/framegraph/RenderPass.d.ts +14 -0
  763. package/dist/production-runtime/framegraph/RenderPass.d.ts.map +1 -0
  764. package/dist/production-runtime/framegraph/RenderPass.js +2 -0
  765. package/dist/production-runtime/framegraph/RenderPass.js.map +1 -0
  766. package/dist/production-runtime/geometry/ProjectedDecalGeometry.d.ts +53 -0
  767. package/dist/production-runtime/geometry/ProjectedDecalGeometry.d.ts.map +1 -0
  768. package/dist/production-runtime/geometry/ProjectedDecalGeometry.js +340 -0
  769. package/dist/production-runtime/geometry/ProjectedDecalGeometry.js.map +1 -0
  770. package/dist/production-runtime/index.d.ts +73 -0
  771. package/dist/production-runtime/index.d.ts.map +1 -0
  772. package/dist/production-runtime/index.js +67 -0
  773. package/dist/production-runtime/index.js.map +1 -0
  774. package/dist/production-runtime/lights/LightManager.d.ts +8 -0
  775. package/dist/production-runtime/lights/LightManager.d.ts.map +1 -0
  776. package/dist/production-runtime/lights/LightManager.js +7 -0
  777. package/dist/production-runtime/lights/LightManager.js.map +1 -0
  778. package/dist/production-runtime/lights/ShadowMapRenderer.d.ts +8 -0
  779. package/dist/production-runtime/lights/ShadowMapRenderer.d.ts.map +1 -0
  780. package/dist/production-runtime/lights/ShadowMapRenderer.js +4 -0
  781. package/dist/production-runtime/lights/ShadowMapRenderer.js.map +1 -0
  782. package/dist/production-runtime/materials/GLTFMaterialAdapter.d.ts +14 -0
  783. package/dist/production-runtime/materials/GLTFMaterialAdapter.d.ts.map +1 -0
  784. package/dist/production-runtime/materials/GLTFMaterialAdapter.js +5 -0
  785. package/dist/production-runtime/materials/GLTFMaterialAdapter.js.map +1 -0
  786. package/dist/production-runtime/materials/GLTFPBRMaterialAdapter.d.ts +3 -0
  787. package/dist/production-runtime/materials/GLTFPBRMaterialAdapter.d.ts.map +1 -0
  788. package/dist/production-runtime/materials/GLTFPBRMaterialAdapter.js +2 -0
  789. package/dist/production-runtime/materials/GLTFPBRMaterialAdapter.js.map +1 -0
  790. package/dist/production-runtime/materials/MaterialCompiler.d.ts +9 -0
  791. package/dist/production-runtime/materials/MaterialCompiler.d.ts.map +1 -0
  792. package/dist/production-runtime/materials/MaterialCompiler.js +5 -0
  793. package/dist/production-runtime/materials/MaterialCompiler.js.map +1 -0
  794. package/dist/production-runtime/materials/MaterialTextureBindings.d.ts +8 -0
  795. package/dist/production-runtime/materials/MaterialTextureBindings.d.ts.map +1 -0
  796. package/dist/production-runtime/materials/MaterialTextureBindings.js +4 -0
  797. package/dist/production-runtime/materials/MaterialTextureBindings.js.map +1 -0
  798. package/dist/production-runtime/materials/PBRMaterial.d.ts +23 -0
  799. package/dist/production-runtime/materials/PBRMaterial.d.ts.map +1 -0
  800. package/dist/production-runtime/materials/PBRMaterial.js +2 -0
  801. package/dist/production-runtime/materials/PBRMaterial.js.map +1 -0
  802. package/dist/production-runtime/materials/PBRShaderFeatures.d.ts +13 -0
  803. package/dist/production-runtime/materials/PBRShaderFeatures.d.ts.map +1 -0
  804. package/dist/production-runtime/materials/PBRShaderFeatures.js +2 -0
  805. package/dist/production-runtime/materials/PBRShaderFeatures.js.map +1 -0
  806. package/dist/production-runtime/passes/ContactShadowPass.d.ts +40 -0
  807. package/dist/production-runtime/passes/ContactShadowPass.d.ts.map +1 -0
  808. package/dist/production-runtime/passes/ContactShadowPass.js +126 -0
  809. package/dist/production-runtime/passes/ContactShadowPass.js.map +1 -0
  810. package/dist/production-runtime/passes/DepthPrepass.d.ts +8 -0
  811. package/dist/production-runtime/passes/DepthPrepass.d.ts.map +1 -0
  812. package/dist/production-runtime/passes/DepthPrepass.js +7 -0
  813. package/dist/production-runtime/passes/DepthPrepass.js.map +1 -0
  814. package/dist/production-runtime/passes/OpaquePass.d.ts +8 -0
  815. package/dist/production-runtime/passes/OpaquePass.d.ts.map +1 -0
  816. package/dist/production-runtime/passes/OpaquePass.js +7 -0
  817. package/dist/production-runtime/passes/OpaquePass.js.map +1 -0
  818. package/dist/production-runtime/passes/ShadowPass.d.ts +8 -0
  819. package/dist/production-runtime/passes/ShadowPass.d.ts.map +1 -0
  820. package/dist/production-runtime/passes/ShadowPass.js +7 -0
  821. package/dist/production-runtime/passes/ShadowPass.js.map +1 -0
  822. package/dist/production-runtime/passes/SkyboxPass.d.ts +8 -0
  823. package/dist/production-runtime/passes/SkyboxPass.d.ts.map +1 -0
  824. package/dist/production-runtime/passes/SkyboxPass.js +7 -0
  825. package/dist/production-runtime/passes/SkyboxPass.js.map +1 -0
  826. package/dist/production-runtime/passes/ToneMappingPass.d.ts +8 -0
  827. package/dist/production-runtime/passes/ToneMappingPass.d.ts.map +1 -0
  828. package/dist/production-runtime/passes/ToneMappingPass.js +7 -0
  829. package/dist/production-runtime/passes/ToneMappingPass.js.map +1 -0
  830. package/dist/production-runtime/passes/TransparentPass.d.ts +8 -0
  831. package/dist/production-runtime/passes/TransparentPass.d.ts.map +1 -0
  832. package/dist/production-runtime/passes/TransparentPass.js +7 -0
  833. package/dist/production-runtime/passes/TransparentPass.js.map +1 -0
  834. package/dist/production-runtime/postprocess/BloomPass.d.ts +15 -0
  835. package/dist/production-runtime/postprocess/BloomPass.d.ts.map +1 -0
  836. package/dist/production-runtime/postprocess/BloomPass.js +37 -0
  837. package/dist/production-runtime/postprocess/BloomPass.js.map +1 -0
  838. package/dist/production-runtime/postprocess/ColorGradingPass.d.ts +16 -0
  839. package/dist/production-runtime/postprocess/ColorGradingPass.d.ts.map +1 -0
  840. package/dist/production-runtime/postprocess/ColorGradingPass.js +34 -0
  841. package/dist/production-runtime/postprocess/ColorGradingPass.js.map +1 -0
  842. package/dist/production-runtime/postprocess/DOFPass.d.ts +16 -0
  843. package/dist/production-runtime/postprocess/DOFPass.d.ts.map +1 -0
  844. package/dist/production-runtime/postprocess/DOFPass.js +31 -0
  845. package/dist/production-runtime/postprocess/DOFPass.js.map +1 -0
  846. package/dist/production-runtime/postprocess/FXAAPass.d.ts +16 -0
  847. package/dist/production-runtime/postprocess/FXAAPass.d.ts.map +1 -0
  848. package/dist/production-runtime/postprocess/FXAAPass.js +39 -0
  849. package/dist/production-runtime/postprocess/FXAAPass.js.map +1 -0
  850. package/dist/production-runtime/postprocess/ProductionEffectComposer.d.ts +21 -0
  851. package/dist/production-runtime/postprocess/ProductionEffectComposer.d.ts.map +1 -0
  852. package/dist/production-runtime/postprocess/ProductionEffectComposer.js +53 -0
  853. package/dist/production-runtime/postprocess/ProductionEffectComposer.js.map +1 -0
  854. package/dist/production-runtime/postprocess/ProductionPostProcessTypes.d.ts +37 -0
  855. package/dist/production-runtime/postprocess/ProductionPostProcessTypes.d.ts.map +1 -0
  856. package/dist/production-runtime/postprocess/ProductionPostProcessTypes.js +124 -0
  857. package/dist/production-runtime/postprocess/ProductionPostProcessTypes.js.map +1 -0
  858. package/dist/production-runtime/postprocess/SSAOPass.d.ts +15 -0
  859. package/dist/production-runtime/postprocess/SSAOPass.d.ts.map +1 -0
  860. package/dist/production-runtime/postprocess/SSAOPass.js +30 -0
  861. package/dist/production-runtime/postprocess/SSAOPass.js.map +1 -0
  862. package/dist/production-runtime/resources/GPUBuffer.d.ts +10 -0
  863. package/dist/production-runtime/resources/GPUBuffer.d.ts.map +1 -0
  864. package/dist/production-runtime/resources/GPUBuffer.js +7 -0
  865. package/dist/production-runtime/resources/GPUBuffer.js.map +1 -0
  866. package/dist/production-runtime/resources/GPUTexture.d.ts +12 -0
  867. package/dist/production-runtime/resources/GPUTexture.d.ts.map +1 -0
  868. package/dist/production-runtime/resources/GPUTexture.js +7 -0
  869. package/dist/production-runtime/resources/GPUTexture.js.map +1 -0
  870. package/dist/production-runtime/resources/RenderTarget.d.ts +11 -0
  871. package/dist/production-runtime/resources/RenderTarget.d.ts.map +1 -0
  872. package/dist/production-runtime/resources/RenderTarget.js +7 -0
  873. package/dist/production-runtime/resources/RenderTarget.js.map +1 -0
  874. package/dist/production-runtime/resources/ResourceCache.d.ts +8 -0
  875. package/dist/production-runtime/resources/ResourceCache.d.ts.map +1 -0
  876. package/dist/production-runtime/resources/ResourceCache.js +8 -0
  877. package/dist/production-runtime/resources/ResourceCache.js.map +1 -0
  878. package/dist/production-runtime/scene/Camera.d.ts +8 -0
  879. package/dist/production-runtime/scene/Camera.d.ts.map +1 -0
  880. package/dist/production-runtime/scene/Camera.js +2 -0
  881. package/dist/production-runtime/scene/Camera.js.map +1 -0
  882. package/dist/production-runtime/scene/Lights.d.ts +9 -0
  883. package/dist/production-runtime/scene/Lights.d.ts.map +1 -0
  884. package/dist/production-runtime/scene/Lights.js +2 -0
  885. package/dist/production-runtime/scene/Lights.js.map +1 -0
  886. package/dist/production-runtime/scene/RenderableMesh.d.ts +8 -0
  887. package/dist/production-runtime/scene/RenderableMesh.d.ts.map +1 -0
  888. package/dist/production-runtime/scene/RenderableMesh.js +2 -0
  889. package/dist/production-runtime/scene/RenderableMesh.js.map +1 -0
  890. package/dist/production-runtime/scene/RenderablePrimitive.d.ts +8 -0
  891. package/dist/production-runtime/scene/RenderablePrimitive.d.ts.map +1 -0
  892. package/dist/production-runtime/scene/RenderablePrimitive.js +2 -0
  893. package/dist/production-runtime/scene/RenderablePrimitive.js.map +1 -0
  894. package/dist/production-runtime/scene/RenderableScene.d.ts +11 -0
  895. package/dist/production-runtime/scene/RenderableScene.d.ts.map +1 -0
  896. package/dist/production-runtime/scene/RenderableScene.js +2 -0
  897. package/dist/production-runtime/scene/RenderableScene.js.map +1 -0
  898. package/dist/production-runtime/shaders/ShaderProgramLibrary.d.ts +12 -0
  899. package/dist/production-runtime/shaders/ShaderProgramLibrary.d.ts.map +1 -0
  900. package/dist/production-runtime/shaders/ShaderProgramLibrary.js +7 -0
  901. package/dist/production-runtime/shaders/ShaderProgramLibrary.js.map +1 -0
  902. package/dist/shadows/CascadedShadowPipeline.d.ts +25 -0
  903. package/dist/shadows/CascadedShadowPipeline.d.ts.map +1 -0
  904. package/dist/shadows/CascadedShadowPipeline.js +31 -0
  905. package/dist/shadows/CascadedShadowPipeline.js.map +1 -0
  906. package/dist/shadows/ContactShadows.d.ts +37 -0
  907. package/dist/shadows/ContactShadows.d.ts.map +1 -0
  908. package/dist/shadows/ContactShadows.js +68 -0
  909. package/dist/shadows/ContactShadows.js.map +1 -0
  910. package/dist/shadows/ShadowDebugViews.d.ts +12 -0
  911. package/dist/shadows/ShadowDebugViews.d.ts.map +1 -0
  912. package/dist/shadows/ShadowDebugViews.js +35 -0
  913. package/dist/shadows/ShadowDebugViews.js.map +1 -0
  914. package/dist/threejs-compatibility/InstancingSystem.d.ts +10 -0
  915. package/dist/threejs-compatibility/InstancingSystem.d.ts.map +1 -0
  916. package/dist/threejs-compatibility/InstancingSystem.js +11 -0
  917. package/dist/threejs-compatibility/InstancingSystem.js.map +1 -0
  918. package/dist/threejs-compatibility/LightingSystem.d.ts +11 -0
  919. package/dist/threejs-compatibility/LightingSystem.d.ts.map +1 -0
  920. package/dist/threejs-compatibility/LightingSystem.js +14 -0
  921. package/dist/threejs-compatibility/LightingSystem.js.map +1 -0
  922. package/dist/threejs-compatibility/MaterialSystem.d.ts +6 -0
  923. package/dist/threejs-compatibility/MaterialSystem.d.ts.map +1 -0
  924. package/dist/threejs-compatibility/MaterialSystem.js +7 -0
  925. package/dist/threejs-compatibility/MaterialSystem.js.map +1 -0
  926. package/dist/threejs-compatibility/RenderTargetSystem.d.ts +16 -0
  927. package/dist/threejs-compatibility/RenderTargetSystem.d.ts.map +1 -0
  928. package/dist/threejs-compatibility/RenderTargetSystem.js +23 -0
  929. package/dist/threejs-compatibility/RenderTargetSystem.js.map +1 -0
  930. package/dist/threejs-compatibility/RendererDiagnostics.d.ts +27 -0
  931. package/dist/threejs-compatibility/RendererDiagnostics.d.ts.map +1 -0
  932. package/dist/threejs-compatibility/RendererDiagnostics.js +41 -0
  933. package/dist/threejs-compatibility/RendererDiagnostics.js.map +1 -0
  934. package/dist/threejs-compatibility/SceneRenderer.d.ts +19 -0
  935. package/dist/threejs-compatibility/SceneRenderer.d.ts.map +1 -0
  936. package/dist/threejs-compatibility/SceneRenderer.js +18 -0
  937. package/dist/threejs-compatibility/SceneRenderer.js.map +1 -0
  938. package/dist/threejs-compatibility/ShadowSystem.d.ts +11 -0
  939. package/dist/threejs-compatibility/ShadowSystem.d.ts.map +1 -0
  940. package/dist/threejs-compatibility/ShadowSystem.js +12 -0
  941. package/dist/threejs-compatibility/ShadowSystem.js.map +1 -0
  942. package/dist/threejs-compatibility/TextureSystem.d.ts +9 -0
  943. package/dist/threejs-compatibility/TextureSystem.d.ts.map +1 -0
  944. package/dist/threejs-compatibility/TextureSystem.js +14 -0
  945. package/dist/threejs-compatibility/TextureSystem.js.map +1 -0
  946. package/dist/threejs-compatibility/ThreeCompatRenderer.d.ts +37 -0
  947. package/dist/threejs-compatibility/ThreeCompatRenderer.d.ts.map +1 -0
  948. package/dist/threejs-compatibility/ThreeCompatRenderer.js +77 -0
  949. package/dist/threejs-compatibility/ThreeCompatRenderer.js.map +1 -0
  950. package/dist/threejs-compatibility/TransparencySystem.d.ts +11 -0
  951. package/dist/threejs-compatibility/TransparencySystem.d.ts.map +1 -0
  952. package/dist/threejs-compatibility/TransparencySystem.js +12 -0
  953. package/dist/threejs-compatibility/TransparencySystem.js.map +1 -0
  954. package/dist/threejs-compatibility/index.d.ts +25 -0
  955. package/dist/threejs-compatibility/index.d.ts.map +1 -0
  956. package/dist/threejs-compatibility/index.js +15 -0
  957. package/dist/threejs-compatibility/index.js.map +1 -0
  958. package/dist/threejs-compatibility/performance/BVH.d.ts +11 -0
  959. package/dist/threejs-compatibility/performance/BVH.d.ts.map +1 -0
  960. package/dist/threejs-compatibility/performance/BVH.js +10 -0
  961. package/dist/threejs-compatibility/performance/BVH.js.map +1 -0
  962. package/dist/threejs-compatibility/performance/FrustumCulling.d.ts +7 -0
  963. package/dist/threejs-compatibility/performance/FrustumCulling.d.ts.map +1 -0
  964. package/dist/threejs-compatibility/performance/FrustumCulling.js +5 -0
  965. package/dist/threejs-compatibility/performance/FrustumCulling.js.map +1 -0
  966. package/dist/threejs-compatibility/performance/Instancing.d.ts +7 -0
  967. package/dist/threejs-compatibility/performance/Instancing.d.ts.map +1 -0
  968. package/dist/threejs-compatibility/performance/Instancing.js +10 -0
  969. package/dist/threejs-compatibility/performance/Instancing.js.map +1 -0
  970. package/dist/threejs-compatibility/performance/LODSystem.d.ts +9 -0
  971. package/dist/threejs-compatibility/performance/LODSystem.d.ts.map +1 -0
  972. package/dist/threejs-compatibility/performance/LODSystem.js +11 -0
  973. package/dist/threejs-compatibility/performance/LODSystem.js.map +1 -0
  974. package/dist/threejs-compatibility/performance/OcclusionCulling.d.ts +3 -0
  975. package/dist/threejs-compatibility/performance/OcclusionCulling.d.ts.map +1 -0
  976. package/dist/threejs-compatibility/performance/OcclusionCulling.js +5 -0
  977. package/dist/threejs-compatibility/performance/OcclusionCulling.js.map +1 -0
  978. package/dist/threejs-compatibility/performance/RaycastAcceleration.d.ts +8 -0
  979. package/dist/threejs-compatibility/performance/RaycastAcceleration.d.ts.map +1 -0
  980. package/dist/threejs-compatibility/performance/RaycastAcceleration.js +11 -0
  981. package/dist/threejs-compatibility/performance/RaycastAcceleration.js.map +1 -0
  982. package/dist/threejs-compatibility/performance/RendererProfiler.d.ts +11 -0
  983. package/dist/threejs-compatibility/performance/RendererProfiler.d.ts.map +1 -0
  984. package/dist/threejs-compatibility/performance/RendererProfiler.js +10 -0
  985. package/dist/threejs-compatibility/performance/RendererProfiler.js.map +1 -0
  986. package/dist/threejs-compatibility/performance/TextureStreaming.d.ts +7 -0
  987. package/dist/threejs-compatibility/performance/TextureStreaming.d.ts.map +1 -0
  988. package/dist/threejs-compatibility/performance/TextureStreaming.js +10 -0
  989. package/dist/threejs-compatibility/performance/TextureStreaming.js.map +1 -0
  990. package/dist/threejs-compatibility/performance/index.d.ts +13 -0
  991. package/dist/threejs-compatibility/performance/index.d.ts.map +1 -0
  992. package/dist/threejs-compatibility/performance/index.js +9 -0
  993. package/dist/threejs-compatibility/performance/index.js.map +1 -0
  994. package/dist/threejs-compatibility/postprocess/BloomPass.d.ts +9 -0
  995. package/dist/threejs-compatibility/postprocess/BloomPass.d.ts.map +1 -0
  996. package/dist/threejs-compatibility/postprocess/BloomPass.js +14 -0
  997. package/dist/threejs-compatibility/postprocess/BloomPass.js.map +1 -0
  998. package/dist/threejs-compatibility/postprocess/ColorGradingPass.d.ts +10 -0
  999. package/dist/threejs-compatibility/postprocess/ColorGradingPass.d.ts.map +1 -0
  1000. package/dist/threejs-compatibility/postprocess/ColorGradingPass.js +16 -0
  1001. package/dist/threejs-compatibility/postprocess/ColorGradingPass.js.map +1 -0
  1002. package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.d.ts +9 -0
  1003. package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.d.ts.map +1 -0
  1004. package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.js +19 -0
  1005. package/dist/threejs-compatibility/postprocess/DepthOfFieldPass.js.map +1 -0
  1006. package/dist/threejs-compatibility/postprocess/EffectComposer.d.ts +7 -0
  1007. package/dist/threejs-compatibility/postprocess/EffectComposer.d.ts.map +1 -0
  1008. package/dist/threejs-compatibility/postprocess/EffectComposer.js +11 -0
  1009. package/dist/threejs-compatibility/postprocess/EffectComposer.js.map +1 -0
  1010. package/dist/threejs-compatibility/postprocess/FXAAPass.d.ts +7 -0
  1011. package/dist/threejs-compatibility/postprocess/FXAAPass.d.ts.map +1 -0
  1012. package/dist/threejs-compatibility/postprocess/FXAAPass.js +10 -0
  1013. package/dist/threejs-compatibility/postprocess/FXAAPass.js.map +1 -0
  1014. package/dist/threejs-compatibility/postprocess/MotionBlurPass.d.ts +9 -0
  1015. package/dist/threejs-compatibility/postprocess/MotionBlurPass.d.ts.map +1 -0
  1016. package/dist/threejs-compatibility/postprocess/MotionBlurPass.js +18 -0
  1017. package/dist/threejs-compatibility/postprocess/MotionBlurPass.js.map +1 -0
  1018. package/dist/threejs-compatibility/postprocess/OutlinePass.d.ts +9 -0
  1019. package/dist/threejs-compatibility/postprocess/OutlinePass.d.ts.map +1 -0
  1020. package/dist/threejs-compatibility/postprocess/OutlinePass.js +19 -0
  1021. package/dist/threejs-compatibility/postprocess/OutlinePass.js.map +1 -0
  1022. package/dist/threejs-compatibility/postprocess/PostProcessTypes.d.ts +42 -0
  1023. package/dist/threejs-compatibility/postprocess/PostProcessTypes.d.ts.map +1 -0
  1024. package/dist/threejs-compatibility/postprocess/PostProcessTypes.js +123 -0
  1025. package/dist/threejs-compatibility/postprocess/PostProcessTypes.js.map +1 -0
  1026. package/dist/threejs-compatibility/postprocess/RenderPass.d.ts +7 -0
  1027. package/dist/threejs-compatibility/postprocess/RenderPass.d.ts.map +1 -0
  1028. package/dist/threejs-compatibility/postprocess/RenderPass.js +8 -0
  1029. package/dist/threejs-compatibility/postprocess/RenderPass.js.map +1 -0
  1030. package/dist/threejs-compatibility/postprocess/SMAAPass.d.ts +7 -0
  1031. package/dist/threejs-compatibility/postprocess/SMAAPass.d.ts.map +1 -0
  1032. package/dist/threejs-compatibility/postprocess/SMAAPass.js +10 -0
  1033. package/dist/threejs-compatibility/postprocess/SMAAPass.js.map +1 -0
  1034. package/dist/threejs-compatibility/postprocess/SSAOPass.d.ts +9 -0
  1035. package/dist/threejs-compatibility/postprocess/SSAOPass.d.ts.map +1 -0
  1036. package/dist/threejs-compatibility/postprocess/SSAOPass.js +19 -0
  1037. package/dist/threejs-compatibility/postprocess/SSAOPass.js.map +1 -0
  1038. package/dist/threejs-compatibility/postprocess/ShaderPass.d.ts +9 -0
  1039. package/dist/threejs-compatibility/postprocess/ShaderPass.d.ts.map +1 -0
  1040. package/dist/threejs-compatibility/postprocess/ShaderPass.js +11 -0
  1041. package/dist/threejs-compatibility/postprocess/ShaderPass.js.map +1 -0
  1042. package/dist/threejs-compatibility/postprocess/TAAPass.d.ts +7 -0
  1043. package/dist/threejs-compatibility/postprocess/TAAPass.d.ts.map +1 -0
  1044. package/dist/threejs-compatibility/postprocess/TAAPass.js +10 -0
  1045. package/dist/threejs-compatibility/postprocess/TAAPass.js.map +1 -0
  1046. package/dist/threejs-compatibility/postprocess/VignettePass.d.ts +9 -0
  1047. package/dist/threejs-compatibility/postprocess/VignettePass.d.ts.map +1 -0
  1048. package/dist/threejs-compatibility/postprocess/VignettePass.js +14 -0
  1049. package/dist/threejs-compatibility/postprocess/VignettePass.js.map +1 -0
  1050. package/dist/threejs-compatibility/postprocess/index.d.ts +16 -0
  1051. package/dist/threejs-compatibility/postprocess/index.d.ts.map +1 -0
  1052. package/dist/threejs-compatibility/postprocess/index.js +15 -0
  1053. package/dist/threejs-compatibility/postprocess/index.js.map +1 -0
  1054. package/dist/threejs-compatibility/shaders/NodeMaterial.d.ts +14 -0
  1055. package/dist/threejs-compatibility/shaders/NodeMaterial.d.ts.map +1 -0
  1056. package/dist/threejs-compatibility/shaders/NodeMaterial.js +15 -0
  1057. package/dist/threejs-compatibility/shaders/NodeMaterial.js.map +1 -0
  1058. package/dist/threejs-compatibility/shaders/RawShaderMaterial.d.ts +6 -0
  1059. package/dist/threejs-compatibility/shaders/RawShaderMaterial.d.ts.map +1 -0
  1060. package/dist/threejs-compatibility/shaders/RawShaderMaterial.js +6 -0
  1061. package/dist/threejs-compatibility/shaders/RawShaderMaterial.js.map +1 -0
  1062. package/dist/threejs-compatibility/shaders/ShaderDiagnostics.d.ts +7 -0
  1063. package/dist/threejs-compatibility/shaders/ShaderDiagnostics.d.ts.map +1 -0
  1064. package/dist/threejs-compatibility/shaders/ShaderDiagnostics.js +12 -0
  1065. package/dist/threejs-compatibility/shaders/ShaderDiagnostics.js.map +1 -0
  1066. package/dist/threejs-compatibility/shaders/ShaderMaterial.d.ts +12 -0
  1067. package/dist/threejs-compatibility/shaders/ShaderMaterial.d.ts.map +1 -0
  1068. package/dist/threejs-compatibility/shaders/ShaderMaterial.js +20 -0
  1069. package/dist/threejs-compatibility/shaders/ShaderMaterial.js.map +1 -0
  1070. package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.d.ts +7 -0
  1071. package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.d.ts.map +1 -0
  1072. package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.js +7 -0
  1073. package/dist/threejs-compatibility/shaders/ThreeCompatShaderChunks.js.map +1 -0
  1074. package/dist/threejs-compatibility/shaders/Uniforms.d.ts +8 -0
  1075. package/dist/threejs-compatibility/shaders/Uniforms.d.ts.map +1 -0
  1076. package/dist/threejs-compatibility/shaders/Uniforms.js +14 -0
  1077. package/dist/threejs-compatibility/shaders/Uniforms.js.map +1 -0
  1078. package/dist/threejs-compatibility/shaders/index.d.ts +10 -0
  1079. package/dist/threejs-compatibility/shaders/index.d.ts.map +1 -0
  1080. package/dist/threejs-compatibility/shaders/index.js +7 -0
  1081. package/dist/threejs-compatibility/shaders/index.js.map +1 -0
  1082. package/dist/threejs-compatibility/vfx/GPUPointCloud.d.ts +7 -0
  1083. package/dist/threejs-compatibility/vfx/GPUPointCloud.d.ts.map +1 -0
  1084. package/dist/threejs-compatibility/vfx/GPUPointCloud.js +12 -0
  1085. package/dist/threejs-compatibility/vfx/GPUPointCloud.js.map +1 -0
  1086. package/dist/threejs-compatibility/vfx/LineRenderer.d.ts +10 -0
  1087. package/dist/threejs-compatibility/vfx/LineRenderer.d.ts.map +1 -0
  1088. package/dist/threejs-compatibility/vfx/LineRenderer.js +7 -0
  1089. package/dist/threejs-compatibility/vfx/LineRenderer.js.map +1 -0
  1090. package/dist/threejs-compatibility/vfx/ParticleSystem.d.ts +12 -0
  1091. package/dist/threejs-compatibility/vfx/ParticleSystem.d.ts.map +1 -0
  1092. package/dist/threejs-compatibility/vfx/ParticleSystem.js +15 -0
  1093. package/dist/threejs-compatibility/vfx/ParticleSystem.js.map +1 -0
  1094. package/dist/threejs-compatibility/vfx/SpriteSystem.d.ts +11 -0
  1095. package/dist/threejs-compatibility/vfx/SpriteSystem.d.ts.map +1 -0
  1096. package/dist/threejs-compatibility/vfx/SpriteSystem.js +7 -0
  1097. package/dist/threejs-compatibility/vfx/SpriteSystem.js.map +1 -0
  1098. package/dist/threejs-compatibility/vfx/TrailRenderer.d.ts +5 -0
  1099. package/dist/threejs-compatibility/vfx/TrailRenderer.d.ts.map +1 -0
  1100. package/dist/threejs-compatibility/vfx/TrailRenderer.js +9 -0
  1101. package/dist/threejs-compatibility/vfx/TrailRenderer.js.map +1 -0
  1102. package/dist/threejs-compatibility/vfx/VFXDiagnostics.d.ts +21 -0
  1103. package/dist/threejs-compatibility/vfx/VFXDiagnostics.d.ts.map +1 -0
  1104. package/dist/threejs-compatibility/vfx/VFXDiagnostics.js +12 -0
  1105. package/dist/threejs-compatibility/vfx/VFXDiagnostics.js.map +1 -0
  1106. package/dist/threejs-compatibility/vfx/index.d.ts +10 -0
  1107. package/dist/threejs-compatibility/vfx/index.d.ts.map +1 -0
  1108. package/dist/threejs-compatibility/vfx/index.js +7 -0
  1109. package/dist/threejs-compatibility/vfx/index.js.map +1 -0
  1110. package/dist/threejs-example-parity/index.d.ts +57 -0
  1111. package/dist/threejs-example-parity/index.d.ts.map +1 -0
  1112. package/dist/threejs-example-parity/index.js +139 -0
  1113. package/dist/threejs-example-parity/index.js.map +1 -0
  1114. package/dist/webgpu/WebGPUBuffer.d.ts +2 -0
  1115. package/dist/webgpu/WebGPUBuffer.d.ts.map +1 -0
  1116. package/dist/webgpu/WebGPUBuffer.js +2 -0
  1117. package/dist/webgpu/WebGPUBuffer.js.map +1 -0
  1118. package/dist/webgpu/WebGPUCompute.d.ts +3 -0
  1119. package/dist/webgpu/WebGPUCompute.d.ts.map +1 -0
  1120. package/dist/webgpu/WebGPUCompute.js +2 -0
  1121. package/dist/webgpu/WebGPUCompute.js.map +1 -0
  1122. package/dist/webgpu/WebGPUPipelineCache.d.ts +6 -0
  1123. package/dist/webgpu/WebGPUPipelineCache.d.ts.map +1 -0
  1124. package/dist/webgpu/WebGPUPipelineCache.js +15 -0
  1125. package/dist/webgpu/WebGPUPipelineCache.js.map +1 -0
  1126. package/dist/webgpu/WebGPUPostProcess.d.ts +3 -0
  1127. package/dist/webgpu/WebGPUPostProcess.d.ts.map +1 -0
  1128. package/dist/webgpu/WebGPUPostProcess.js +2 -0
  1129. package/dist/webgpu/WebGPUPostProcess.js.map +1 -0
  1130. package/dist/webgpu/WebGPUTexture.d.ts +3 -0
  1131. package/dist/webgpu/WebGPUTexture.d.ts.map +1 -0
  1132. package/dist/webgpu/WebGPUTexture.js +2 -0
  1133. package/dist/webgpu/WebGPUTexture.js.map +1 -0
  1134. package/package.json +18 -0
  1135. package/src/ArchitecturalLightingFixtures.ts +241 -0
  1136. package/src/ArchitecturalMaterialCatalog.ts +130 -0
  1137. package/src/ArchitecturalMeasurementFixtures.ts +155 -0
  1138. package/src/BRDFLut.ts +47 -0
  1139. package/src/CameraFraming.ts +200 -0
  1140. package/src/CanonicalSceneFixtures.ts +95 -0
  1141. package/src/CascadedShadowMaps.ts +449 -0
  1142. package/src/ColorManagement.ts +127 -0
  1143. package/src/CullingFixtures.ts +280 -0
  1144. package/src/DecalGeometry.ts +26 -0
  1145. package/src/DepthPass.ts +110 -0
  1146. package/src/EnvironmentBackgroundPass.ts +194 -0
  1147. package/src/EnvironmentBackgroundResources.ts +309 -0
  1148. package/src/EnvironmentLighting.ts +96 -0
  1149. package/src/EnvironmentMapResources.ts +1026 -0
  1150. package/src/EnvironmentPipeline.ts +69 -0
  1151. package/src/EnvironmentPlatform.ts +1306 -0
  1152. package/src/EnvironmentPreset.ts +155 -0
  1153. package/src/Exposure.ts +66 -0
  1154. package/src/ExternalParityRenderPreset.ts +725 -0
  1155. package/src/ForwardPass.ts +1639 -0
  1156. package/src/FrameVisualMetrics.ts +218 -0
  1157. package/src/Geometry.ts +461 -0
  1158. package/src/GeometryPrimitives.ts +2 -0
  1159. package/src/HDRRenderPipeline.ts +94 -0
  1160. package/src/IBL.ts +86 -0
  1161. package/src/IndexBuffer.ts +57 -0
  1162. package/src/InstancedPBRMaterial.ts +186 -0
  1163. package/src/InstancedUnlitMaterial.ts +60 -0
  1164. package/src/Instancing.ts +19 -0
  1165. package/src/LightCollector.ts +82 -0
  1166. package/src/LightUniforms.ts +47 -0
  1167. package/src/LightingDebug.ts +80 -0
  1168. package/src/LightingDefaults.ts +79 -0
  1169. package/src/LightingRig.ts +301 -0
  1170. package/src/LineGeometry.ts +2 -0
  1171. package/src/Material.ts +209 -0
  1172. package/src/MaterialBinding.ts +131 -0
  1173. package/src/MaterialInstance.ts +59 -0
  1174. package/src/MaterialPresets.ts +272 -0
  1175. package/src/MorphTarget.ts +123 -0
  1176. package/src/MorphUnlitMaterial.ts +54 -0
  1177. package/src/NormalMappedPBRMaterial.ts +188 -0
  1178. package/src/OceanFixtures.ts +318 -0
  1179. package/src/PBRLightingDefaults.ts +12 -0
  1180. package/src/PBRMaterial.ts +442 -0
  1181. package/src/PMREM.ts +53 -0
  1182. package/src/PbrReference.ts +681 -0
  1183. package/src/PostProcessPass.ts +2507 -0
  1184. package/src/ProceduralTextureFixtures.ts +393 -0
  1185. package/src/ProductTurntableFixtures.ts +815 -0
  1186. package/src/Raycaster.ts +21 -0
  1187. package/src/ReflectionProbe.ts +13 -0
  1188. package/src/ReflectionSurfaces.ts +219 -0
  1189. package/src/RenderBackend.ts +43 -0
  1190. package/src/RenderDebugViews.ts +138 -0
  1191. package/src/RenderDevice.ts +836 -0
  1192. package/src/RenderGraph.ts +194 -0
  1193. package/src/RenderPass.ts +27 -0
  1194. package/src/RenderPipeline.ts +101 -0
  1195. package/src/RenderQueue.ts +12 -0
  1196. package/src/RenderState.ts +12 -0
  1197. package/src/Renderer.ts +2626 -0
  1198. package/src/RendererDebugOverlay.ts +80 -0
  1199. package/src/RendererFeatureGates.ts +150 -0
  1200. package/src/RendererPostprocessPlan.ts +279 -0
  1201. package/src/RendererTiming.ts +251 -0
  1202. package/src/RendererVisualPipelineReport.ts +836 -0
  1203. package/src/ResourceLifecycle.ts +21 -0
  1204. package/src/Sampler.ts +37 -0
  1205. package/src/SceneOptimization.ts +518 -0
  1206. package/src/ShaderChunks.ts +393 -0
  1207. package/src/ShaderLibrary.ts +2738 -0
  1208. package/src/ShaderModule.ts +36 -0
  1209. package/src/ShaderPreprocessor.ts +260 -0
  1210. package/src/ShaderReflection.ts +201 -0
  1211. package/src/ShadowMap.ts +237 -0
  1212. package/src/ShadowPass.ts +198 -0
  1213. package/src/ShadowProjection.ts +115 -0
  1214. package/src/SkinnedLitMaterial.ts +366 -0
  1215. package/src/SkinnedUnlitMaterial.ts +63 -0
  1216. package/src/SkinningBounds.ts +131 -0
  1217. package/src/SpaceEnvironmentFixtures.ts +200 -0
  1218. package/src/SpriteGeometry.ts +21 -0
  1219. package/src/StereoCameraRig.ts +127 -0
  1220. package/src/StereoEffects.ts +274 -0
  1221. package/src/TerrainFixtures.ts +180 -0
  1222. package/src/Texture.ts +307 -0
  1223. package/src/TextureBinding.ts +91 -0
  1224. package/src/TexturedPBRMaterial.ts +1112 -0
  1225. package/src/TexturedUnlitMaterial.ts +67 -0
  1226. package/src/ToneMapping.ts +105 -0
  1227. package/src/UniformBinder.ts +16 -0
  1228. package/src/UniformLayout.ts +129 -0
  1229. package/src/UnlitMaterial.ts +75 -0
  1230. package/src/VegetationFixtures.ts +314 -0
  1231. package/src/VertexBuffer.ts +120 -0
  1232. package/src/VertexFormat.ts +171 -0
  1233. package/src/VoxelWorldFixtures.ts +280 -0
  1234. package/src/WeatherFixtures.ts +223 -0
  1235. package/src/WebGL2Device.ts +2280 -0
  1236. package/src/WebGL2StateCache.ts +330 -0
  1237. package/src/WebGPUDevice.ts +2806 -0
  1238. package/src/WebGPURenderToTextureProof.ts +139 -0
  1239. package/src/advanced-runtime/AdvancedRenderer.ts +73 -0
  1240. package/src/advanced-runtime/index.ts +9 -0
  1241. package/src/cinematic/BloomPass.ts +26 -0
  1242. package/src/cinematic/CinematicDepthComposition.ts +30 -0
  1243. package/src/cinematic/CinematicEvidence.ts +123 -0
  1244. package/src/cinematic/CinematicLightingRig.ts +144 -0
  1245. package/src/cinematic/CinematicMaterialPresets.ts +130 -0
  1246. package/src/cinematic/CinematicPostProcess.ts +83 -0
  1247. package/src/cinematic/DepthHazePass.ts +30 -0
  1248. package/src/cinematic/EmissivePracticalLightSystem.ts +45 -0
  1249. package/src/cinematic/FilmGrainPass.ts +24 -0
  1250. package/src/cinematic/FogVolumeSystem.ts +30 -0
  1251. package/src/cinematic/GlowCardSystem.ts +44 -0
  1252. package/src/cinematic/RainParticleSystem.ts +151 -0
  1253. package/src/cinematic/VignettePass.ts +25 -0
  1254. package/src/cinematic/WetReflectionApproximation.ts +27 -0
  1255. package/src/cinematic/index.ts +14 -0
  1256. package/src/effects/CollisionModule.ts +64 -0
  1257. package/src/effects/ColorModule.ts +60 -0
  1258. package/src/effects/ForceModule.ts +25 -0
  1259. package/src/effects/GPUParticleBackend.ts +569 -0
  1260. package/src/effects/Particle.ts +108 -0
  1261. package/src/effects/ParticleDiagnostics.ts +224 -0
  1262. package/src/effects/ParticleEffectPresets.ts +147 -0
  1263. package/src/effects/ParticleEmitter.ts +326 -0
  1264. package/src/effects/ParticleModule.ts +26 -0
  1265. package/src/effects/ParticleRenderPass.ts +117 -0
  1266. package/src/effects/ParticleRenderer.ts +132 -0
  1267. package/src/effects/ParticleSystem.ts +333 -0
  1268. package/src/effects/SizeModule.ts +56 -0
  1269. package/src/effects/TrailModule.ts +72 -0
  1270. package/src/effects/VelocityModule.ts +75 -0
  1271. package/src/effects/index.ts +15 -0
  1272. package/src/index.ts +914 -0
  1273. package/src/materials/AlphaSorting.ts +30 -0
  1274. package/src/materials/MaterialExtensions.ts +42 -0
  1275. package/src/materials/PhysicalMaterial.ts +133 -0
  1276. package/src/materials/TransmissionPass.ts +51 -0
  1277. package/src/performance/BVH.ts +18 -0
  1278. package/src/performance/Batcher.ts +2 -0
  1279. package/src/performance/FrustumCuller.ts +9 -0
  1280. package/src/performance/LOD.ts +20 -0
  1281. package/src/performance/Octree.ts +10 -0
  1282. package/src/performance/RenderItemSorting.ts +167 -0
  1283. package/src/performance/RendererStats.ts +43 -0
  1284. package/src/performance/ResourceBudget.ts +44 -0
  1285. package/src/postprocess/BloomPass.ts +28 -0
  1286. package/src/postprocess/CinematicDiagnostics.ts +642 -0
  1287. package/src/postprocess/ColorGradingPass.ts +24 -0
  1288. package/src/postprocess/DepthOfFieldPass.ts +12 -0
  1289. package/src/postprocess/EffectComposer.ts +349 -0
  1290. package/src/postprocess/SSAOPass.ts +20 -0
  1291. package/src/postprocess/index.ts +34 -0
  1292. package/src/production-runtime/AnimationControlsPipeline.ts +77 -0
  1293. package/src/production-runtime/PBRHDRPipeline.ts +381 -0
  1294. package/src/production-runtime/ProductionEffectsPipeline.ts +85 -0
  1295. package/src/production-runtime/ProductionRendererTypes.ts +136 -0
  1296. package/src/production-runtime/ProductionRuntimeRenderer.ts +172 -0
  1297. package/src/production-runtime/ProductionWebGL2Renderer.ts +313 -0
  1298. package/src/production-runtime/ProductionWebGPURenderer.ts +396 -0
  1299. package/src/production-runtime/TransmissionBackdropCapture.ts +130 -0
  1300. package/src/production-runtime/animation/MorphTargetRenderer.ts +2 -0
  1301. package/src/production-runtime/animation/SkinningRenderer.ts +2 -0
  1302. package/src/production-runtime/backends/RendererBackend.ts +17 -0
  1303. package/src/production-runtime/backends/WebGL2RendererBackend.ts +30 -0
  1304. package/src/production-runtime/backends/WebGPURendererBackend.ts +24 -0
  1305. package/src/production-runtime/backends/webgl2/WebGL2Buffer.ts +2 -0
  1306. package/src/production-runtime/backends/webgl2/WebGL2Capabilities.ts +2 -0
  1307. package/src/production-runtime/backends/webgl2/WebGL2RenderTarget.ts +2 -0
  1308. package/src/production-runtime/backends/webgl2/WebGL2Shader.ts +2 -0
  1309. package/src/production-runtime/backends/webgl2/WebGL2StateCache.ts +1 -0
  1310. package/src/production-runtime/backends/webgl2/WebGL2Texture.ts +2 -0
  1311. package/src/production-runtime/backends/webgpu/WebGPUBuffer.ts +2 -0
  1312. package/src/production-runtime/backends/webgpu/WebGPUCapabilities.ts +2 -0
  1313. package/src/production-runtime/backends/webgpu/WebGPURenderTarget.ts +2 -0
  1314. package/src/production-runtime/backends/webgpu/WebGPUShader.ts +2 -0
  1315. package/src/production-runtime/backends/webgpu/WebGPUTexture.ts +2 -0
  1316. package/src/production-runtime/color/ColorManagement.ts +3 -0
  1317. package/src/production-runtime/color/ToneMapping.ts +7 -0
  1318. package/src/production-runtime/diagnostics/FrameCapture.ts +2 -0
  1319. package/src/production-runtime/diagnostics/GPUCapabilities.ts +2 -0
  1320. package/src/production-runtime/diagnostics/RendererStats.ts +2 -0
  1321. package/src/production-runtime/environment/EnvironmentMap.ts +1 -0
  1322. package/src/production-runtime/environment/HDRLoader.ts +57 -0
  1323. package/src/production-runtime/environment/PMREMGenerator.ts +713 -0
  1324. package/src/production-runtime/framegraph/FrameGraph.ts +18 -0
  1325. package/src/production-runtime/framegraph/RenderPass.ts +15 -0
  1326. package/src/production-runtime/geometry/ProjectedDecalGeometry.ts +439 -0
  1327. package/src/production-runtime/index.ts +127 -0
  1328. package/src/production-runtime/lights/LightManager.ts +7 -0
  1329. package/src/production-runtime/lights/ShadowMapRenderer.ts +5 -0
  1330. package/src/production-runtime/materials/GLTFMaterialAdapter.ts +6 -0
  1331. package/src/production-runtime/materials/GLTFPBRMaterialAdapter.ts +2 -0
  1332. package/src/production-runtime/materials/MaterialCompiler.ts +7 -0
  1333. package/src/production-runtime/materials/MaterialTextureBindings.ts +5 -0
  1334. package/src/production-runtime/materials/PBRMaterial.ts +2 -0
  1335. package/src/production-runtime/materials/PBRShaderFeatures.ts +2 -0
  1336. package/src/production-runtime/passes/ContactShadowPass.ts +184 -0
  1337. package/src/production-runtime/passes/DepthPrepass.ts +7 -0
  1338. package/src/production-runtime/passes/OpaquePass.ts +7 -0
  1339. package/src/production-runtime/passes/ShadowPass.ts +7 -0
  1340. package/src/production-runtime/passes/SkyboxPass.ts +7 -0
  1341. package/src/production-runtime/passes/ToneMappingPass.ts +7 -0
  1342. package/src/production-runtime/passes/TransparentPass.ts +7 -0
  1343. package/src/production-runtime/postprocess/BloomPass.ts +51 -0
  1344. package/src/production-runtime/postprocess/ColorGradingPass.ts +49 -0
  1345. package/src/production-runtime/postprocess/DOFPass.ts +47 -0
  1346. package/src/production-runtime/postprocess/FXAAPass.ts +53 -0
  1347. package/src/production-runtime/postprocess/ProductionEffectComposer.ts +78 -0
  1348. package/src/production-runtime/postprocess/ProductionPostProcessTypes.ts +174 -0
  1349. package/src/production-runtime/postprocess/SSAOPass.ts +45 -0
  1350. package/src/production-runtime/resources/GPUBuffer.ts +2 -0
  1351. package/src/production-runtime/resources/GPUTexture.ts +2 -0
  1352. package/src/production-runtime/resources/RenderTarget.ts +3 -0
  1353. package/src/production-runtime/resources/ResourceCache.ts +7 -0
  1354. package/src/production-runtime/scene/Camera.ts +1 -0
  1355. package/src/production-runtime/scene/Lights.ts +2 -0
  1356. package/src/production-runtime/scene/RenderableMesh.ts +2 -0
  1357. package/src/production-runtime/scene/RenderablePrimitive.ts +1 -0
  1358. package/src/production-runtime/scene/RenderableScene.ts +4 -0
  1359. package/src/production-runtime/shaders/ShaderProgramLibrary.ts +7 -0
  1360. package/src/production-runtime/shaders/chunks/brdf.glsl +2 -0
  1361. package/src/production-runtime/shaders/chunks/ibl.glsl +3 -0
  1362. package/src/production-runtime/shaders/chunks/pbr.frag.glsl +47 -0
  1363. package/src/production-runtime/shaders/chunks/pbr.vert.glsl +8 -0
  1364. package/src/production-runtime/shaders/chunks/shadows.glsl +2 -0
  1365. package/src/production-runtime/shaders/wgsl/pbr.wgsl +3 -0
  1366. package/src/production-runtime/shaders/wgsl/postprocess.wgsl +2 -0
  1367. package/src/production-runtime/shaders/wgsl/skybox.wgsl +2 -0
  1368. package/src/shaders/depth.frag.glsl +5 -0
  1369. package/src/shaders/depth.vert.glsl +8 -0
  1370. package/src/shaders/pbr-direct.frag.glsl +687 -0
  1371. package/src/shaders/pbr-direct.vert.glsl +18 -0
  1372. package/src/shaders/unlit.frag.glsl +18 -0
  1373. package/src/shaders/unlit.vert.glsl +13 -0
  1374. package/src/shadows/CascadedShadowPipeline.ts +53 -0
  1375. package/src/shadows/ContactShadows.ts +106 -0
  1376. package/src/shadows/ShadowDebugViews.ts +46 -0
  1377. package/src/threejs-compatibility/InstancingSystem.ts +17 -0
  1378. package/src/threejs-compatibility/LightingSystem.ts +22 -0
  1379. package/src/threejs-compatibility/MaterialSystem.ts +9 -0
  1380. package/src/threejs-compatibility/RenderTargetSystem.ts +35 -0
  1381. package/src/threejs-compatibility/RendererDiagnostics.ts +61 -0
  1382. package/src/threejs-compatibility/SceneRenderer.ts +34 -0
  1383. package/src/threejs-compatibility/ShadowSystem.ts +19 -0
  1384. package/src/threejs-compatibility/TextureSystem.ts +19 -0
  1385. package/src/threejs-compatibility/ThreeCompatRenderer.ts +90 -0
  1386. package/src/threejs-compatibility/TransparencySystem.ts +19 -0
  1387. package/src/threejs-compatibility/index.ts +29 -0
  1388. package/src/threejs-compatibility/performance/BVH.ts +14 -0
  1389. package/src/threejs-compatibility/performance/FrustumCulling.ts +10 -0
  1390. package/src/threejs-compatibility/performance/Instancing.ts +4 -0
  1391. package/src/threejs-compatibility/performance/LODSystem.ts +16 -0
  1392. package/src/threejs-compatibility/performance/OcclusionCulling.ts +6 -0
  1393. package/src/threejs-compatibility/performance/RaycastAcceleration.ts +12 -0
  1394. package/src/threejs-compatibility/performance/RendererProfiler.ts +19 -0
  1395. package/src/threejs-compatibility/performance/TextureStreaming.ts +4 -0
  1396. package/src/threejs-compatibility/performance/index.ts +12 -0
  1397. package/src/threejs-compatibility/postprocess/BloomPass.ts +16 -0
  1398. package/src/threejs-compatibility/postprocess/ColorGradingPass.ts +16 -0
  1399. package/src/threejs-compatibility/postprocess/DepthOfFieldPass.ts +21 -0
  1400. package/src/threejs-compatibility/postprocess/EffectComposer.ts +14 -0
  1401. package/src/threejs-compatibility/postprocess/FXAAPass.ts +15 -0
  1402. package/src/threejs-compatibility/postprocess/MotionBlurPass.ts +20 -0
  1403. package/src/threejs-compatibility/postprocess/OutlinePass.ts +21 -0
  1404. package/src/threejs-compatibility/postprocess/PostProcessTypes.ts +169 -0
  1405. package/src/threejs-compatibility/postprocess/RenderPass.ts +9 -0
  1406. package/src/threejs-compatibility/postprocess/SMAAPass.ts +15 -0
  1407. package/src/threejs-compatibility/postprocess/SSAOPass.ts +21 -0
  1408. package/src/threejs-compatibility/postprocess/ShaderPass.ts +7 -0
  1409. package/src/threejs-compatibility/postprocess/TAAPass.ts +15 -0
  1410. package/src/threejs-compatibility/postprocess/VignettePass.ts +16 -0
  1411. package/src/threejs-compatibility/postprocess/index.ts +15 -0
  1412. package/src/threejs-compatibility/shaders/NodeMaterial.ts +21 -0
  1413. package/src/threejs-compatibility/shaders/RawShaderMaterial.ts +6 -0
  1414. package/src/threejs-compatibility/shaders/ShaderDiagnostics.ts +17 -0
  1415. package/src/threejs-compatibility/shaders/ShaderMaterial.ts +18 -0
  1416. package/src/threejs-compatibility/shaders/ThreeCompatShaderChunks.ts +6 -0
  1417. package/src/threejs-compatibility/shaders/Uniforms.ts +18 -0
  1418. package/src/threejs-compatibility/shaders/index.ts +9 -0
  1419. package/src/threejs-compatibility/vfx/GPUPointCloud.ts +7 -0
  1420. package/src/threejs-compatibility/vfx/LineRenderer.ts +13 -0
  1421. package/src/threejs-compatibility/vfx/ParticleSystem.ts +23 -0
  1422. package/src/threejs-compatibility/vfx/SpriteSystem.ts +14 -0
  1423. package/src/threejs-compatibility/vfx/TrailRenderer.ts +8 -0
  1424. package/src/threejs-compatibility/vfx/VFXDiagnostics.ts +23 -0
  1425. package/src/threejs-compatibility/vfx/index.ts +9 -0
  1426. package/src/threejs-example-parity/index.ts +205 -0
  1427. package/src/webgpu/WebGPUBuffer.ts +1 -0
  1428. package/src/webgpu/WebGPUCompute.ts +2 -0
  1429. package/src/webgpu/WebGPUPipelineCache.ts +15 -0
  1430. package/src/webgpu/WebGPUPostProcess.ts +2 -0
  1431. package/src/webgpu/WebGPUTexture.ts +2 -0
  1432. package/tsconfig.json +26 -0
  1433. package/vitest.config.ts +20 -0
@@ -0,0 +1,2507 @@
1
+ import { BaseRenderPass, type RenderPassContext } from "./RenderPass";
2
+ import { RenderDeviceError, type RenderDevice, type RenderTarget } from "./RenderDevice";
3
+
4
+ export type ToneMappingOperator = "linear" | "reinhard" | "aces" | "filmic" | "uncharted2" | "agx" | "neutral";
5
+ export type PostProcessColorSpace = "linear" | "srgb";
6
+ export type DepthTextureFormat = "depth24";
7
+ export type ToneMappingPresetName = "natural" | "cinematic" | "vibrant" | "realistic" | "stylized";
8
+
9
+ export interface BloomOptions {
10
+ readonly threshold?: number;
11
+ readonly intensity?: number;
12
+ readonly radius?: number;
13
+ }
14
+
15
+ export interface FXAAOptions {
16
+ readonly edgeThreshold?: number;
17
+ readonly subpixelBlend?: number;
18
+ }
19
+
20
+ export interface ToneMappingOptions {
21
+ readonly exposure?: number;
22
+ readonly whitePoint?: number;
23
+ readonly gamma?: number;
24
+ readonly operator?: ToneMappingOperator;
25
+ readonly inputColorSpace?: PostProcessColorSpace;
26
+ readonly outputColorSpace?: PostProcessColorSpace;
27
+ }
28
+
29
+ export interface ColorGradeOptions {
30
+ readonly contrast?: number;
31
+ readonly temperature?: number;
32
+ readonly tint?: number;
33
+ readonly saturation?: number;
34
+ readonly vibrance?: number;
35
+ readonly vignette?: number;
36
+ readonly sharpening?: number;
37
+ }
38
+
39
+ export interface ColorGradeResult {
40
+ readonly width: number;
41
+ readonly height: number;
42
+ readonly pixels: Uint8Array;
43
+ readonly changedPixels: number;
44
+ readonly vignetteDarkenedPixels: number;
45
+ readonly sharpenedPixels: number;
46
+ readonly settings: Required<ColorGradeOptions>;
47
+ }
48
+
49
+ export interface ToneMappingPreset {
50
+ readonly name: ToneMappingPresetName;
51
+ readonly label: string;
52
+ readonly toneMapping: Required<ToneMappingOptions>;
53
+ readonly colorGrade: Required<ColorGradeOptions>;
54
+ readonly autoExposure: boolean;
55
+ readonly adaptationSpeed: number;
56
+ readonly minExposure: number;
57
+ readonly maxExposure: number;
58
+ }
59
+
60
+ export interface ExposureHistogramOptions {
61
+ readonly inputColorSpace?: PostProcessColorSpace;
62
+ readonly binCount?: number;
63
+ readonly minLuminance?: number;
64
+ readonly maxLuminance?: number;
65
+ }
66
+
67
+ export interface ExposureHistogram {
68
+ readonly bins: readonly number[];
69
+ readonly binCount: number;
70
+ readonly minLuminance: number;
71
+ readonly maxLuminance: number;
72
+ readonly pixelCount: number;
73
+ readonly averageLuminance: number;
74
+ readonly minObservedLuminance: number;
75
+ readonly maxObservedLuminance: number;
76
+ }
77
+
78
+ export interface AutoExposureOptions {
79
+ readonly targetLuminance?: number;
80
+ readonly previousExposure?: number;
81
+ readonly adaptationSpeed?: number;
82
+ readonly deltaTimeSeconds?: number;
83
+ readonly minExposure?: number;
84
+ readonly maxExposure?: number;
85
+ }
86
+
87
+ export interface AutoExposureResult {
88
+ readonly exposure: number;
89
+ readonly targetExposure: number;
90
+ readonly averageLuminance: number;
91
+ readonly adaptationRate: number;
92
+ readonly clamped: boolean;
93
+ }
94
+
95
+ export interface ToneMappingPresetResult {
96
+ readonly width: number;
97
+ readonly height: number;
98
+ readonly preset: ToneMappingPresetName;
99
+ readonly pixels: Uint8Array;
100
+ readonly toneMapped: ToneMappingResult;
101
+ readonly colorGraded: ColorGradeResult;
102
+ readonly histogram: ExposureHistogram;
103
+ readonly autoExposure?: AutoExposureResult;
104
+ }
105
+
106
+ export interface ChromaticAberrationOptions {
107
+ readonly strength?: number;
108
+ }
109
+
110
+ export interface ChromaticAberrationResult {
111
+ readonly width: number;
112
+ readonly height: number;
113
+ readonly pixels: Uint8Array;
114
+ readonly changedPixels: number;
115
+ readonly maxChannelOffsetPixels: number;
116
+ }
117
+
118
+ export interface OutlineOptions {
119
+ readonly color?: readonly [number, number, number, number?];
120
+ readonly width?: number;
121
+ readonly threshold?: number;
122
+ readonly opacity?: number;
123
+ }
124
+
125
+ export interface OutlineResult {
126
+ readonly width: number;
127
+ readonly height: number;
128
+ readonly pixels: Uint8Array;
129
+ readonly outlineMask: Uint8Array;
130
+ readonly outlinedPixels: number;
131
+ readonly changedPixels: number;
132
+ readonly maxGradient: number;
133
+ readonly method: "sobel-luma";
134
+ }
135
+
136
+ export interface FilmGrainOptions {
137
+ readonly intensity?: number;
138
+ readonly seed?: number;
139
+ readonly monochrome?: boolean;
140
+ }
141
+
142
+ export interface FilmGrainResult {
143
+ readonly width: number;
144
+ readonly height: number;
145
+ readonly pixels: Uint8Array;
146
+ readonly changedPixels: number;
147
+ readonly seed: number;
148
+ readonly intensity: number;
149
+ readonly monochrome: boolean;
150
+ }
151
+
152
+ export interface DepthOfFieldOptions {
153
+ readonly depth?: DepthTextureBinding;
154
+ readonly focusDepth?: number;
155
+ readonly focusRange?: number;
156
+ readonly maxRadius?: number;
157
+ }
158
+
159
+ export interface DepthOfFieldResult {
160
+ readonly width: number;
161
+ readonly height: number;
162
+ readonly pixels: Uint8Array;
163
+ readonly blurredPixels: number;
164
+ readonly maxBlurRadius: number;
165
+ readonly focusDepth: number;
166
+ readonly focusRange: number;
167
+ }
168
+
169
+ export interface MotionBlurOptions {
170
+ readonly velocity: Float32Array;
171
+ readonly samples?: number;
172
+ readonly scale?: number;
173
+ }
174
+
175
+ export interface MotionBlurResult {
176
+ readonly width: number;
177
+ readonly height: number;
178
+ readonly pixels: Uint8Array;
179
+ readonly blurredPixels: number;
180
+ readonly samples: number;
181
+ readonly maxVelocityPixels: number;
182
+ }
183
+
184
+ export interface SSAOOptions {
185
+ readonly depth?: DepthTextureBinding;
186
+ readonly radius?: number;
187
+ readonly intensity?: number;
188
+ readonly bias?: number;
189
+ }
190
+
191
+ export interface SSAOResult {
192
+ readonly width: number;
193
+ readonly height: number;
194
+ readonly pixels: Uint8Array;
195
+ readonly occludedPixels: number;
196
+ readonly averageOcclusion: number;
197
+ readonly radius: number;
198
+ readonly intensity: number;
199
+ }
200
+
201
+ export interface ContactShadowPostProcessOptions {
202
+ readonly depth?: DepthTextureBinding;
203
+ readonly radius?: number;
204
+ readonly intensity?: number;
205
+ readonly bias?: number;
206
+ readonly thickness?: number;
207
+ readonly direction?: readonly [number, number];
208
+ }
209
+
210
+ export interface ContactShadowPostProcessResult {
211
+ readonly width: number;
212
+ readonly height: number;
213
+ readonly pixels: Uint8Array;
214
+ readonly contactPixels: number;
215
+ readonly averageContactDarkening: number;
216
+ readonly radius: number;
217
+ readonly intensity: number;
218
+ readonly mode: "screen-space-depth-contact";
219
+ }
220
+
221
+ export interface SSRResult {
222
+ readonly width: number;
223
+ readonly height: number;
224
+ readonly pixels: Uint8Array;
225
+ readonly reflectedPixels: number;
226
+ readonly maxReflectionBoost: number;
227
+ readonly intensity: number;
228
+ readonly maxDistance: number;
229
+ }
230
+
231
+ export interface SSROptions {
232
+ readonly depth?: DepthTextureBinding;
233
+ readonly intensity?: number;
234
+ readonly maxDistance?: number;
235
+ }
236
+
237
+ export interface TAAOptions {
238
+ readonly history: Uint8Array;
239
+ readonly blend?: number;
240
+ }
241
+
242
+ export interface TAAResult {
243
+ readonly width: number;
244
+ readonly height: number;
245
+ readonly pixels: Uint8Array;
246
+ readonly blendedPixels: number;
247
+ readonly blend: number;
248
+ }
249
+
250
+ export interface ToneMappingResult {
251
+ readonly width: number;
252
+ readonly height: number;
253
+ readonly pixels: Uint8Array;
254
+ readonly colorSpace: PostProcessColorSpace;
255
+ readonly calibration: ToneMappingCalibration;
256
+ }
257
+
258
+ export interface HdrToneMappingResult extends ToneMappingResult {
259
+ readonly inputOverbrightPixels: number;
260
+ readonly maxInputValue: number;
261
+ }
262
+
263
+ export interface BloomResult {
264
+ readonly width: number;
265
+ readonly height: number;
266
+ readonly pixels: Uint8Array;
267
+ readonly brightPixels: Uint8Array;
268
+ readonly horizontalBlurPixels: Uint8Array;
269
+ readonly verticalBlurPixels: Uint8Array;
270
+ readonly brightPixelCount: number;
271
+ readonly brightEnergy: number;
272
+ readonly maxNeighborBoost: number;
273
+ readonly changedPixels: number;
274
+ readonly maxChannelDelta: number;
275
+ readonly pipeline: readonly ["bright-extract", "horizontal-blur", "vertical-blur", "composite"];
276
+ }
277
+
278
+ export interface HdrBloomResult {
279
+ readonly width: number;
280
+ readonly height: number;
281
+ readonly pixels: Float32Array;
282
+ readonly brightPixels: Float32Array;
283
+ readonly horizontalBlurPixels: Float32Array;
284
+ readonly verticalBlurPixels: Float32Array;
285
+ readonly brightPixelCount: number;
286
+ readonly brightEnergy: number;
287
+ readonly maxNeighborBoost: number;
288
+ readonly changedPixels: number;
289
+ readonly maxChannelDelta: number;
290
+ readonly maxInputValue: number;
291
+ readonly pipeline: readonly ["bright-extract", "horizontal-blur", "vertical-blur", "composite"];
292
+ }
293
+
294
+ export interface FXAAResult {
295
+ readonly width: number;
296
+ readonly height: number;
297
+ readonly pixels: Uint8Array;
298
+ readonly edgeMask: Uint8Array;
299
+ }
300
+
301
+ export type FusedLdrPostProcessPassName = "tone-mapping" | "color-grade" | "fxaa";
302
+
303
+ export interface FusedLdrPostProcessPass {
304
+ readonly name: FusedLdrPostProcessPassName;
305
+ readonly options: ToneMappingOptions | ColorGradeOptions | FXAAOptions;
306
+ }
307
+
308
+ export interface FusedLdrPostProcessScratch {
309
+ bufferA?: Uint8Array;
310
+ bufferB?: Uint8Array;
311
+ toneMappingLookup?: Uint8Array;
312
+ toneMappingLookupKey?: string;
313
+ vignetteFactors?: Float32Array;
314
+ vignetteFactorsKey?: string;
315
+ }
316
+
317
+ export interface FusedLdrPostProcessOptions {
318
+ readonly scratch?: FusedLdrPostProcessScratch;
319
+ readonly mutateInput?: boolean;
320
+ readonly toneMappingDefaults?: ToneMappingOptions;
321
+ }
322
+
323
+ export interface ToneMappingCalibrationSample {
324
+ readonly inputLinear: number;
325
+ readonly mappedLinear: number;
326
+ readonly encodedByte: number;
327
+ }
328
+
329
+ export interface ToneMappingCalibration {
330
+ readonly operator: ToneMappingOperator;
331
+ readonly exposure: number;
332
+ readonly whitePoint: number;
333
+ readonly gamma: number;
334
+ readonly inputColorSpace: PostProcessColorSpace;
335
+ readonly outputColorSpace: PostProcessColorSpace;
336
+ readonly samples: readonly ToneMappingCalibrationSample[];
337
+ readonly monotonic: boolean;
338
+ }
339
+
340
+ export interface DepthTextureBinding {
341
+ readonly label: string;
342
+ readonly width: number;
343
+ readonly height: number;
344
+ readonly format: DepthTextureFormat;
345
+ readonly data: Float32Array;
346
+ }
347
+
348
+ export interface DepthTextureStats {
349
+ readonly label: string;
350
+ readonly width: number;
351
+ readonly height: number;
352
+ readonly format: DepthTextureFormat;
353
+ readonly byteLength: number;
354
+ readonly minDepth: number;
355
+ readonly maxDepth: number;
356
+ readonly centerDepth: number;
357
+ readonly nearSample: number;
358
+ readonly farSample: number;
359
+ readonly edgePixelCount: number;
360
+ }
361
+
362
+ export interface DepthVisualizationResult {
363
+ readonly width: number;
364
+ readonly height: number;
365
+ readonly pixels: Uint8Array;
366
+ readonly stats: DepthTextureStats;
367
+ }
368
+
369
+ export interface ToneMappingPassOptions extends ToneMappingOptions {
370
+ readonly name?: string;
371
+ readonly source: RenderTarget;
372
+ readonly target?: RenderTarget;
373
+ readonly readResource?: string;
374
+ readonly writeResource?: string;
375
+ }
376
+
377
+ export interface BloomPassOptions extends BloomOptions {
378
+ readonly name?: string;
379
+ readonly source: RenderTarget;
380
+ readonly target?: RenderTarget;
381
+ readonly readResource?: string;
382
+ readonly writeResource?: string;
383
+ }
384
+
385
+ export interface FXAAPassOptions extends FXAAOptions {
386
+ readonly name?: string;
387
+ readonly source: RenderTarget;
388
+ readonly target?: RenderTarget;
389
+ readonly readResource?: string;
390
+ readonly writeResource?: string;
391
+ }
392
+
393
+ export interface DepthVisualizationPassOptions {
394
+ readonly name?: string;
395
+ readonly source: DepthTextureBinding;
396
+ readonly target?: RenderTarget;
397
+ readonly edgeThreshold?: number;
398
+ readonly readResource?: string;
399
+ readonly writeResource?: string;
400
+ }
401
+
402
+ export class ToneMappingPass extends BaseRenderPass {
403
+ private readonly exposure: number;
404
+ private readonly whitePoint: number;
405
+ private readonly gamma: number;
406
+ private readonly operator: ToneMappingOperator;
407
+ private readonly inputColorSpace: PostProcessColorSpace;
408
+ private readonly outputColorSpace: PostProcessColorSpace;
409
+ private lastResult: ToneMappingResult | null = null;
410
+
411
+ constructor(private readonly options: ToneMappingPassOptions) {
412
+ super(
413
+ options.name ?? "tone-mapping",
414
+ [options.readResource ?? options.source.label],
415
+ [options.writeResource ?? options.target?.label ?? "backbuffer"]
416
+ );
417
+ this.exposure = options.exposure ?? 1;
418
+ this.whitePoint = options.whitePoint ?? 1;
419
+ this.gamma = options.gamma ?? 2.2;
420
+ this.operator = options.operator ?? "reinhard";
421
+ this.inputColorSpace = options.inputColorSpace ?? "linear";
422
+ this.outputColorSpace = options.outputColorSpace ?? "linear";
423
+ if (!Number.isFinite(this.exposure) || this.exposure < 0) {
424
+ throw new Error("ToneMappingPass exposure must be finite and non-negative.");
425
+ }
426
+ if (!Number.isFinite(this.whitePoint) || this.whitePoint <= 0) {
427
+ throw new Error("ToneMappingPass whitePoint must be finite and positive.");
428
+ }
429
+ if (!Number.isFinite(this.gamma) || this.gamma <= 0) {
430
+ throw new Error("ToneMappingPass gamma must be finite and positive.");
431
+ }
432
+ }
433
+
434
+ execute(context: RenderPassContext): void {
435
+ context.device.setRenderTarget(this.options.source);
436
+ const mapped = this.options.source.colorTexture.format === "rgba16f" || this.options.source.colorTexture.format === "rgba32f"
437
+ ? toneMapFloatPixels(context.device.readFloatPixels(0, 0, this.options.source.width, this.options.source.height), this.options.source.width, this.options.source.height, {
438
+ exposure: this.exposure,
439
+ whitePoint: this.whitePoint,
440
+ gamma: this.gamma,
441
+ operator: this.operator,
442
+ outputColorSpace: this.outputColorSpace
443
+ })
444
+ : toneMapPixels(context.device.readPixels(0, 0, this.options.source.width, this.options.source.height), this.options.source.width, this.options.source.height, {
445
+ exposure: this.exposure,
446
+ whitePoint: this.whitePoint,
447
+ gamma: this.gamma,
448
+ operator: this.operator,
449
+ inputColorSpace: this.inputColorSpace,
450
+ outputColorSpace: this.outputColorSpace
451
+ });
452
+ writeRenderTarget(context.device, this.options.source, this.options.target, mapped.pixels);
453
+ this.lastResult = mapped;
454
+ }
455
+
456
+ getLastResult(): ToneMappingResult | null {
457
+ return this.lastResult ? { ...this.lastResult, pixels: new Uint8Array(this.lastResult.pixels) } : null;
458
+ }
459
+ }
460
+
461
+ export class DepthVisualizationPass extends BaseRenderPass {
462
+ private readonly edgeThreshold: number;
463
+ private lastResult: DepthVisualizationResult | null = null;
464
+
465
+ constructor(private readonly options: DepthVisualizationPassOptions) {
466
+ super(
467
+ options.name ?? "depth-visualization",
468
+ [options.readResource ?? options.source.label],
469
+ [options.writeResource ?? options.target?.label ?? "depth-visualization-output"]
470
+ );
471
+ this.edgeThreshold = options.edgeThreshold ?? 0.08;
472
+ if (!Number.isFinite(this.edgeThreshold) || this.edgeThreshold < 0 || this.edgeThreshold > 1) {
473
+ throw new Error("DepthVisualizationPass edgeThreshold must be finite and in [0, 1].");
474
+ }
475
+ }
476
+
477
+ execute(context: RenderPassContext): void {
478
+ const visualized = visualizeDepthTexture(this.options.source, { edgeThreshold: this.edgeThreshold });
479
+ writeDepthTarget(this.options.target, this.options.source.width, this.options.source.height, visualized.pixels);
480
+ context.device.setRenderTarget(this.options.target ?? null);
481
+ this.lastResult = visualized;
482
+ }
483
+
484
+ getLastResult(): DepthVisualizationResult | null {
485
+ return this.lastResult
486
+ ? {
487
+ ...this.lastResult,
488
+ pixels: new Uint8Array(this.lastResult.pixels),
489
+ stats: { ...this.lastResult.stats }
490
+ }
491
+ : null;
492
+ }
493
+ }
494
+
495
+ export class BloomPass extends BaseRenderPass {
496
+ private readonly threshold: number;
497
+ private readonly intensity: number;
498
+ private readonly radius: number;
499
+ private lastResult: BloomResult | null = null;
500
+
501
+ constructor(private readonly options: BloomPassOptions) {
502
+ super(
503
+ options.name ?? "bloom",
504
+ [options.readResource ?? options.source.label],
505
+ [options.writeResource ?? options.target?.label ?? "bloom-output"]
506
+ );
507
+ this.threshold = options.threshold ?? 0.75;
508
+ this.intensity = options.intensity ?? 0.35;
509
+ this.radius = options.radius ?? 1;
510
+ validateBloomOptions(this.threshold, this.intensity, this.radius);
511
+ }
512
+
513
+ execute(context: RenderPassContext): void {
514
+ context.device.setRenderTarget(this.options.source);
515
+ const pixels = context.device.readPixels(0, 0, this.options.source.width, this.options.source.height);
516
+ const bloomed = bloomPixels(pixels, this.options.source.width, this.options.source.height, {
517
+ threshold: this.threshold,
518
+ intensity: this.intensity,
519
+ radius: this.radius
520
+ });
521
+ writeRenderTarget(context.device, this.options.source, this.options.target, bloomed.pixels);
522
+ this.lastResult = bloomed;
523
+ }
524
+
525
+ getLastResult(): BloomResult | null {
526
+ return this.lastResult
527
+ ? {
528
+ ...this.lastResult,
529
+ pixels: new Uint8Array(this.lastResult.pixels),
530
+ brightPixels: new Uint8Array(this.lastResult.brightPixels),
531
+ horizontalBlurPixels: new Uint8Array(this.lastResult.horizontalBlurPixels),
532
+ verticalBlurPixels: new Uint8Array(this.lastResult.verticalBlurPixels)
533
+ }
534
+ : null;
535
+ }
536
+ }
537
+
538
+ export class FXAAPass extends BaseRenderPass {
539
+ private readonly edgeThreshold: number;
540
+ private readonly subpixelBlend: number;
541
+ private lastResult: FXAAResult | null = null;
542
+
543
+ constructor(private readonly options: FXAAPassOptions) {
544
+ super(
545
+ options.name ?? "fxaa",
546
+ [options.readResource ?? options.source.label],
547
+ [options.writeResource ?? options.target?.label ?? "fxaa-output"]
548
+ );
549
+ this.edgeThreshold = options.edgeThreshold ?? 0.125;
550
+ this.subpixelBlend = options.subpixelBlend ?? 0.75;
551
+ validateFXAAOptions(this.edgeThreshold, this.subpixelBlend);
552
+ }
553
+
554
+ execute(context: RenderPassContext): void {
555
+ context.device.setRenderTarget(this.options.source);
556
+ const pixels = context.device.readPixels(0, 0, this.options.source.width, this.options.source.height);
557
+ const smoothed = fxaaPixels(pixels, this.options.source.width, this.options.source.height, {
558
+ edgeThreshold: this.edgeThreshold,
559
+ subpixelBlend: this.subpixelBlend
560
+ });
561
+ writeRenderTarget(context.device, this.options.source, this.options.target, smoothed.pixels);
562
+ this.lastResult = smoothed;
563
+ }
564
+
565
+ getLastResult(): FXAAResult | null {
566
+ return this.lastResult
567
+ ? {
568
+ ...this.lastResult,
569
+ pixels: new Uint8Array(this.lastResult.pixels),
570
+ edgeMask: new Uint8Array(this.lastResult.edgeMask)
571
+ }
572
+ : null;
573
+ }
574
+ }
575
+
576
+ export function toneMapPixels(
577
+ pixels: Uint8Array,
578
+ width: number,
579
+ height: number,
580
+ options: ToneMappingOptions = {}
581
+ ): ToneMappingResult {
582
+ if (!Number.isInteger(width) || width <= 0 || !Number.isInteger(height) || height <= 0) {
583
+ throw new Error("Tone mapping dimensions must be positive integers.");
584
+ }
585
+ if (pixels.byteLength !== width * height * 4) {
586
+ throw new Error("Tone mapping input must contain width * height * 4 RGBA bytes.");
587
+ }
588
+ const exposure = options.exposure ?? 1;
589
+ const whitePoint = options.whitePoint ?? 1;
590
+ const gamma = options.gamma ?? 2.2;
591
+ const operator = options.operator ?? "reinhard";
592
+ const inputColorSpace = options.inputColorSpace ?? "linear";
593
+ const outputColorSpace = options.outputColorSpace ?? "linear";
594
+ if (!Number.isFinite(exposure) || exposure < 0) {
595
+ throw new Error("Tone mapping exposure must be finite and non-negative.");
596
+ }
597
+ if (!Number.isFinite(whitePoint) || whitePoint <= 0) {
598
+ throw new Error("Tone mapping whitePoint must be finite and positive.");
599
+ }
600
+ if (!Number.isFinite(gamma) || gamma <= 0) {
601
+ throw new Error("Tone mapping gamma must be finite and positive.");
602
+ }
603
+ const output = new Uint8Array(pixels.byteLength);
604
+ for (let index = 0; index < pixels.length; index += 4) {
605
+ output[index] = encodeToneMappedChannel(decodeColorByte(pixels[index]!, inputColorSpace), exposure, whitePoint, gamma, operator, outputColorSpace);
606
+ output[index + 1] = encodeToneMappedChannel(decodeColorByte(pixels[index + 1]!, inputColorSpace), exposure, whitePoint, gamma, operator, outputColorSpace);
607
+ output[index + 2] = encodeToneMappedChannel(decodeColorByte(pixels[index + 2]!, inputColorSpace), exposure, whitePoint, gamma, operator, outputColorSpace);
608
+ output[index + 3] = pixels[index + 3]!;
609
+ }
610
+ return {
611
+ width,
612
+ height,
613
+ pixels: output,
614
+ colorSpace: outputColorSpace,
615
+ calibration: createToneMappingCalibration({ exposure, whitePoint, gamma, operator, inputColorSpace, outputColorSpace })
616
+ };
617
+ }
618
+
619
+ export function toneMapFloatPixels(
620
+ pixels: Float32Array,
621
+ width: number,
622
+ height: number,
623
+ options: ToneMappingOptions = {}
624
+ ): HdrToneMappingResult {
625
+ if (!Number.isInteger(width) || width <= 0 || !Number.isInteger(height) || height <= 0) {
626
+ throw new Error("HDR tone mapping dimensions must be positive integers.");
627
+ }
628
+ if (pixels.length !== width * height * 4) {
629
+ throw new Error("HDR tone mapping input must contain width * height * 4 RGBA float values.");
630
+ }
631
+ const exposure = options.exposure ?? 1;
632
+ const whitePoint = options.whitePoint ?? 1;
633
+ const gamma = options.gamma ?? 2.2;
634
+ const operator = options.operator ?? "reinhard";
635
+ const outputColorSpace = options.outputColorSpace ?? "linear";
636
+ if (!Number.isFinite(exposure) || exposure < 0) {
637
+ throw new Error("HDR tone mapping exposure must be finite and non-negative.");
638
+ }
639
+ if (!Number.isFinite(whitePoint) || whitePoint <= 0) {
640
+ throw new Error("HDR tone mapping whitePoint must be finite and positive.");
641
+ }
642
+ if (!Number.isFinite(gamma) || gamma <= 0) {
643
+ throw new Error("HDR tone mapping gamma must be finite and positive.");
644
+ }
645
+ const output = new Uint8Array(pixels.length);
646
+ let inputOverbrightPixels = 0;
647
+ let maxInputValue = 0;
648
+ for (let index = 0; index < pixels.length; index += 4) {
649
+ const r = finiteHdrChannel(pixels[index]!, index);
650
+ const g = finiteHdrChannel(pixels[index + 1]!, index + 1);
651
+ const b = finiteHdrChannel(pixels[index + 2]!, index + 2);
652
+ const a = finiteHdrChannel(pixels[index + 3]!, index + 3);
653
+ if (r > 1 || g > 1 || b > 1) inputOverbrightPixels += 1;
654
+ maxInputValue = Math.max(maxInputValue, r, g, b);
655
+ output[index] = encodeToneMappedChannel(r, exposure, whitePoint, gamma, operator, outputColorSpace);
656
+ output[index + 1] = encodeToneMappedChannel(g, exposure, whitePoint, gamma, operator, outputColorSpace);
657
+ output[index + 2] = encodeToneMappedChannel(b, exposure, whitePoint, gamma, operator, outputColorSpace);
658
+ output[index + 3] = clampByte(a * 255);
659
+ }
660
+ return {
661
+ width,
662
+ height,
663
+ pixels: output,
664
+ colorSpace: outputColorSpace,
665
+ calibration: createToneMappingCalibration({ exposure, whitePoint, gamma, operator, inputColorSpace: "linear", outputColorSpace }),
666
+ inputOverbrightPixels,
667
+ maxInputValue: Number(maxInputValue.toFixed(6))
668
+ };
669
+ }
670
+
671
+ export function colorGradePixels(
672
+ pixels: Uint8Array,
673
+ width: number,
674
+ height: number,
675
+ options: ColorGradeOptions = {}
676
+ ): ColorGradeResult {
677
+ validatePixelBuffer(pixels, width, height, "Color grading");
678
+ const settings = {
679
+ contrast: options.contrast ?? 1,
680
+ temperature: options.temperature ?? 0,
681
+ tint: options.tint ?? 0,
682
+ saturation: options.saturation ?? 1,
683
+ vibrance: options.vibrance ?? 0,
684
+ vignette: options.vignette ?? 0,
685
+ sharpening: options.sharpening ?? 0
686
+ };
687
+ validateRange(settings.contrast, 0, 3, "Color grading contrast");
688
+ validateRange(settings.temperature, -1, 1, "Color grading temperature");
689
+ validateRange(settings.tint, -1, 1, "Color grading tint");
690
+ validateRange(settings.saturation, 0, 3, "Color grading saturation");
691
+ validateRange(settings.vibrance, -1, 1, "Color grading vibrance");
692
+ validateRange(settings.vignette, 0, 1, "Color grading vignette");
693
+ validateRange(settings.sharpening, 0, 2, "Color grading sharpening");
694
+
695
+ const graded = new Uint8Array(pixels.byteLength);
696
+ let changedPixels = 0;
697
+ let vignetteDarkenedPixels = 0;
698
+ for (let y = 0; y < height; y += 1) {
699
+ for (let x = 0; x < width; x += 1) {
700
+ const index = (y * width + x) * 4;
701
+ let r = (pixels[index] ?? 0) / 255;
702
+ let g = (pixels[index + 1] ?? 0) / 255;
703
+ let b = (pixels[index + 2] ?? 0) / 255;
704
+ const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
705
+ r = (r - 0.5) * settings.contrast + 0.5;
706
+ g = (g - 0.5) * settings.contrast + 0.5;
707
+ b = (b - 0.5) * settings.contrast + 0.5;
708
+ r += settings.temperature * 0.08 - settings.tint * 0.02;
709
+ g += settings.tint * 0.06;
710
+ b -= settings.temperature * 0.08 + settings.tint * 0.02;
711
+ const vibranceBoost = settings.vibrance * (1 - Math.min(1, Math.abs(r - luma) + Math.abs(g - luma) + Math.abs(b - luma)));
712
+ const saturation = settings.saturation + vibranceBoost;
713
+ r = luma + (r - luma) * saturation;
714
+ g = luma + (g - luma) * saturation;
715
+ b = luma + (b - luma) * saturation;
716
+ const centerX = width <= 1 ? 0 : (x / (width - 1)) * 2 - 1;
717
+ const centerY = height <= 1 ? 0 : (y / (height - 1)) * 2 - 1;
718
+ const vignette = 1 - settings.vignette * Math.min(1, Math.max(0, Math.hypot(centerX, centerY) - 0.28) / 1.12);
719
+ if (vignette < 0.98) vignetteDarkenedPixels += 1;
720
+ r *= vignette;
721
+ g *= vignette;
722
+ b *= vignette;
723
+ graded[index] = clampByte(r * 255);
724
+ graded[index + 1] = clampByte(g * 255);
725
+ graded[index + 2] = clampByte(b * 255);
726
+ graded[index + 3] = pixels[index + 3] ?? 255;
727
+ if (Math.abs(graded[index]! - (pixels[index] ?? 0)) + Math.abs(graded[index + 1]! - (pixels[index + 1] ?? 0)) + Math.abs(graded[index + 2]! - (pixels[index + 2] ?? 0)) > 3) {
728
+ changedPixels += 1;
729
+ }
730
+ }
731
+ }
732
+
733
+ const sharpened = settings.sharpening > 0 ? sharpenPixels(graded, width, height, settings.sharpening) : { pixels: graded, sharpenedPixels: 0 };
734
+ return {
735
+ width,
736
+ height,
737
+ pixels: sharpened.pixels,
738
+ changedPixels: Math.max(changedPixels, countChangedRgb(pixels, sharpened.pixels)),
739
+ vignetteDarkenedPixels,
740
+ sharpenedPixels: sharpened.sharpenedPixels,
741
+ settings
742
+ };
743
+ }
744
+
745
+ export const toneMappingPresets: Record<ToneMappingPresetName, ToneMappingPreset> = {
746
+ natural: createToneMappingPreset("natural", "Natural", {
747
+ operator: "neutral",
748
+ exposure: 1,
749
+ autoExposure: false
750
+ }),
751
+ cinematic: createToneMappingPreset("cinematic", "Cinematic", {
752
+ operator: "aces",
753
+ exposure: 1.2,
754
+ autoExposure: true,
755
+ adaptationSpeed: 0.3,
756
+ temperature: -0.1,
757
+ contrast: 1.1,
758
+ saturation: 0.95
759
+ }),
760
+ vibrant: createToneMappingPreset("vibrant", "Vibrant", {
761
+ operator: "uncharted2",
762
+ exposure: 1.3,
763
+ autoExposure: false,
764
+ temperature: 0.1,
765
+ contrast: 1.15,
766
+ saturation: 1.2
767
+ }),
768
+ realistic: createToneMappingPreset("realistic", "Realistic", {
769
+ operator: "agx",
770
+ exposure: 1,
771
+ autoExposure: true,
772
+ adaptationSpeed: 0.5
773
+ }),
774
+ stylized: createToneMappingPreset("stylized", "Stylized", {
775
+ operator: "filmic",
776
+ exposure: 1.4,
777
+ autoExposure: false,
778
+ temperature: 0.2,
779
+ contrast: 1.25,
780
+ saturation: 1.1
781
+ })
782
+ };
783
+
784
+ export function resolveToneMappingPreset(
785
+ name: ToneMappingPresetName,
786
+ overrides: ToneMappingOptions & ColorGradeOptions & Partial<Pick<ToneMappingPreset, "autoExposure" | "adaptationSpeed" | "minExposure" | "maxExposure">> = {}
787
+ ): ToneMappingPreset {
788
+ const preset = toneMappingPresets[name];
789
+ return {
790
+ ...preset,
791
+ toneMapping: {
792
+ ...preset.toneMapping,
793
+ exposure: overrides.exposure ?? preset.toneMapping.exposure,
794
+ whitePoint: overrides.whitePoint ?? preset.toneMapping.whitePoint,
795
+ gamma: overrides.gamma ?? preset.toneMapping.gamma,
796
+ operator: overrides.operator ?? preset.toneMapping.operator,
797
+ inputColorSpace: overrides.inputColorSpace ?? preset.toneMapping.inputColorSpace,
798
+ outputColorSpace: overrides.outputColorSpace ?? preset.toneMapping.outputColorSpace
799
+ },
800
+ colorGrade: {
801
+ ...preset.colorGrade,
802
+ contrast: overrides.contrast ?? preset.colorGrade.contrast,
803
+ temperature: overrides.temperature ?? preset.colorGrade.temperature,
804
+ tint: overrides.tint ?? preset.colorGrade.tint,
805
+ saturation: overrides.saturation ?? preset.colorGrade.saturation,
806
+ vibrance: overrides.vibrance ?? preset.colorGrade.vibrance,
807
+ vignette: overrides.vignette ?? preset.colorGrade.vignette,
808
+ sharpening: overrides.sharpening ?? preset.colorGrade.sharpening
809
+ },
810
+ autoExposure: overrides.autoExposure ?? preset.autoExposure,
811
+ adaptationSpeed: overrides.adaptationSpeed ?? preset.adaptationSpeed,
812
+ minExposure: overrides.minExposure ?? preset.minExposure,
813
+ maxExposure: overrides.maxExposure ?? preset.maxExposure
814
+ };
815
+ }
816
+
817
+ export function computeExposureHistogramFromPixels(
818
+ pixels: Uint8Array,
819
+ width: number,
820
+ height: number,
821
+ options: ExposureHistogramOptions = {}
822
+ ): ExposureHistogram {
823
+ validatePixelBuffer(pixels, width, height, "Exposure histogram");
824
+ const inputColorSpace = options.inputColorSpace ?? "linear";
825
+ const binCount = options.binCount ?? 64;
826
+ const minLuminance = options.minLuminance ?? 0.001;
827
+ const maxLuminance = options.maxLuminance ?? 16;
828
+ validateHistogramOptions(binCount, minLuminance, maxLuminance);
829
+ const bins = Array.from({ length: binCount }, () => 0);
830
+ const logMin = Math.log2(minLuminance);
831
+ const logMax = Math.log2(maxLuminance);
832
+ let luminanceSum = 0;
833
+ let minObservedLuminance = Number.POSITIVE_INFINITY;
834
+ let maxObservedLuminance = 0;
835
+ for (let index = 0; index < pixels.length; index += 4) {
836
+ const r = decodeColorByte(pixels[index] ?? 0, inputColorSpace);
837
+ const g = decodeColorByte(pixels[index + 1] ?? 0, inputColorSpace);
838
+ const b = decodeColorByte(pixels[index + 2] ?? 0, inputColorSpace);
839
+ const luminance = Math.max(0, 0.2126 * r + 0.7152 * g + 0.0722 * b);
840
+ luminanceSum += luminance;
841
+ minObservedLuminance = Math.min(minObservedLuminance, luminance);
842
+ maxObservedLuminance = Math.max(maxObservedLuminance, luminance);
843
+ const safeLuminance = Math.max(minLuminance, Math.min(maxLuminance, luminance));
844
+ const bin = clampInt(Math.round(((Math.log2(safeLuminance) - logMin) / (logMax - logMin)) * (binCount - 1)), 0, binCount - 1);
845
+ bins[bin] += 1;
846
+ }
847
+ const pixelCount = width * height;
848
+ return {
849
+ bins,
850
+ binCount,
851
+ minLuminance,
852
+ maxLuminance,
853
+ pixelCount,
854
+ averageLuminance: Number((luminanceSum / pixelCount).toFixed(6)),
855
+ minObservedLuminance: Number((minObservedLuminance === Number.POSITIVE_INFINITY ? 0 : minObservedLuminance).toFixed(6)),
856
+ maxObservedLuminance: Number(maxObservedLuminance.toFixed(6))
857
+ };
858
+ }
859
+
860
+ export function computeAutoExposureFromHistogram(histogram: ExposureHistogram, options: AutoExposureOptions = {}): AutoExposureResult {
861
+ if (histogram.pixelCount <= 0 || histogram.bins.length !== histogram.binCount) {
862
+ throw new Error("Auto exposure histogram must contain bins and a positive pixel count.");
863
+ }
864
+ const targetLuminance = options.targetLuminance ?? 0.18;
865
+ const previousExposure = options.previousExposure ?? 1;
866
+ const adaptationSpeed = options.adaptationSpeed ?? 1;
867
+ const deltaTimeSeconds = options.deltaTimeSeconds ?? 1 / 60;
868
+ const minExposure = options.minExposure ?? 0.1;
869
+ const maxExposure = options.maxExposure ?? 10;
870
+ validateRange(targetLuminance, 0.001, 4, "Auto exposure targetLuminance");
871
+ validateRange(previousExposure, 0.001, 128, "Auto exposure previousExposure");
872
+ validateRange(adaptationSpeed, 0, 1, "Auto exposure adaptationSpeed");
873
+ validateRange(deltaTimeSeconds, 0, 10, "Auto exposure deltaTimeSeconds");
874
+ validateRange(minExposure, 0.001, 128, "Auto exposure minExposure");
875
+ validateRange(maxExposure, minExposure, 128, "Auto exposure maxExposure");
876
+
877
+ const averageLuminance = histogram.averageLuminance > 0 ? histogram.averageLuminance : histogramAverageFromBins(histogram);
878
+ const unclampedTarget = targetLuminance / Math.max(0.001, averageLuminance);
879
+ const targetExposure = Math.max(minExposure, Math.min(maxExposure, unclampedTarget));
880
+ const adaptationRate = 1 - Math.pow(1 - adaptationSpeed, deltaTimeSeconds * 60);
881
+ const exposure = previousExposure + (targetExposure - previousExposure) * adaptationRate;
882
+ return {
883
+ exposure: Number(exposure.toFixed(6)),
884
+ targetExposure: Number(targetExposure.toFixed(6)),
885
+ averageLuminance: Number(averageLuminance.toFixed(6)),
886
+ adaptationRate: Number(adaptationRate.toFixed(6)),
887
+ clamped: targetExposure !== unclampedTarget
888
+ };
889
+ }
890
+
891
+ export function applyToneMappingPreset(
892
+ pixels: Uint8Array,
893
+ width: number,
894
+ height: number,
895
+ presetName: ToneMappingPresetName,
896
+ options: ToneMappingOptions & ColorGradeOptions & AutoExposureOptions & Partial<Pick<ToneMappingPreset, "autoExposure" | "adaptationSpeed" | "minExposure" | "maxExposure">> = {}
897
+ ): ToneMappingPresetResult {
898
+ const preset = resolveToneMappingPreset(presetName, options);
899
+ const histogram = computeExposureHistogramFromPixels(pixels, width, height, {
900
+ inputColorSpace: preset.toneMapping.inputColorSpace
901
+ });
902
+ const autoExposure = preset.autoExposure
903
+ ? computeAutoExposureFromHistogram(histogram, {
904
+ targetLuminance: options.targetLuminance,
905
+ previousExposure: options.previousExposure ?? preset.toneMapping.exposure,
906
+ adaptationSpeed: options.adaptationSpeed ?? preset.adaptationSpeed,
907
+ deltaTimeSeconds: options.deltaTimeSeconds,
908
+ minExposure: options.minExposure ?? preset.minExposure,
909
+ maxExposure: options.maxExposure ?? preset.maxExposure
910
+ })
911
+ : undefined;
912
+ const toneMapped = toneMapPixels(pixels, width, height, {
913
+ ...preset.toneMapping,
914
+ exposure: autoExposure?.exposure ?? preset.toneMapping.exposure
915
+ });
916
+ const colorGraded = colorGradePixels(toneMapped.pixels, width, height, preset.colorGrade);
917
+ return {
918
+ width,
919
+ height,
920
+ preset: presetName,
921
+ pixels: colorGraded.pixels,
922
+ toneMapped,
923
+ colorGraded,
924
+ histogram,
925
+ autoExposure
926
+ };
927
+ }
928
+
929
+ export function chromaticAberrationPixels(
930
+ pixels: Uint8Array,
931
+ width: number,
932
+ height: number,
933
+ options: ChromaticAberrationOptions = {}
934
+ ): ChromaticAberrationResult {
935
+ validatePixelBuffer(pixels, width, height, "Chromatic aberration");
936
+ const strength = options.strength ?? 0.35;
937
+ validateRange(strength, 0, 2, "Chromatic aberration strength");
938
+ const output = new Uint8Array(pixels);
939
+ let changedPixels = 0;
940
+ let maxChannelOffsetPixels = 0;
941
+ const centerX = (width - 1) / 2;
942
+ const centerY = (height - 1) / 2;
943
+ const maxDistance = Math.max(1, Math.hypot(centerX, centerY));
944
+ for (let y = 0; y < height; y += 1) {
945
+ for (let x = 0; x < width; x += 1) {
946
+ const index = (y * width + x) * 4;
947
+ const directionX = centerX === 0 ? 0 : (x - centerX) / maxDistance;
948
+ const directionY = centerY === 0 ? 0 : (y - centerY) / maxDistance;
949
+ const radial = Math.min(1, Math.hypot(x - centerX, y - centerY) / maxDistance);
950
+ const offset = Math.round(strength * radial * 2);
951
+ maxChannelOffsetPixels = Math.max(maxChannelOffsetPixels, offset);
952
+ const redX = clampInt(Math.round(x + directionX * offset), 0, width - 1);
953
+ const redY = clampInt(Math.round(y + directionY * offset), 0, height - 1);
954
+ const blueX = clampInt(Math.round(x - directionX * offset), 0, width - 1);
955
+ const blueY = clampInt(Math.round(y - directionY * offset), 0, height - 1);
956
+ output[index] = channelAt(pixels, width, height, redX, redY, 0);
957
+ output[index + 1] = pixels[index + 1] ?? 0;
958
+ output[index + 2] = channelAt(pixels, width, height, blueX, blueY, 2);
959
+ output[index + 3] = pixels[index + 3] ?? 255;
960
+ if (Math.abs(output[index]! - (pixels[index] ?? 0)) + Math.abs(output[index + 2]! - (pixels[index + 2] ?? 0)) > 2) {
961
+ changedPixels += 1;
962
+ }
963
+ }
964
+ }
965
+ return { width, height, pixels: output, changedPixels, maxChannelOffsetPixels };
966
+ }
967
+
968
+ export function outlinePixels(
969
+ pixels: Uint8Array,
970
+ width: number,
971
+ height: number,
972
+ options: OutlineOptions = {}
973
+ ): OutlineResult {
974
+ validatePixelBuffer(pixels, width, height, "Outline");
975
+ const outlineWidth = options.width ?? 1;
976
+ const threshold = options.threshold ?? 0.22;
977
+ const opacity = options.opacity ?? 0.85;
978
+ const color = options.color ?? [255, 188, 64, 255];
979
+ if (!Number.isInteger(outlineWidth) || outlineWidth < 1 || outlineWidth > 6) {
980
+ throw new Error("Outline width must be an integer in [1, 6].");
981
+ }
982
+ validateRange(threshold, 0, 4, "Outline threshold");
983
+ validateRange(opacity, 0, 1, "Outline opacity");
984
+ validateOutlineColor(color);
985
+
986
+ const edgeMask = new Uint8Array(width * height);
987
+ let maxGradient = 0;
988
+ for (let y = 0; y < height; y += 1) {
989
+ for (let x = 0; x < width; x += 1) {
990
+ const gradient = sobelLumaGradient(pixels, width, height, x, y);
991
+ maxGradient = Math.max(maxGradient, gradient);
992
+ if (gradient >= threshold) {
993
+ edgeMask[y * width + x] = 255;
994
+ }
995
+ }
996
+ }
997
+
998
+ const outlineMask = dilateMask(edgeMask, width, height, outlineWidth);
999
+ const output = new Uint8Array(pixels);
1000
+ let outlinedPixels = 0;
1001
+ let changedPixels = 0;
1002
+ const colorAlpha = (color[3] ?? 255) / 255;
1003
+ const alpha = opacity * colorAlpha;
1004
+ for (let index = 0; index < outlineMask.length; index += 1) {
1005
+ if (outlineMask[index] === 0) continue;
1006
+ outlinedPixels += 1;
1007
+ const pixelIndex = index * 4;
1008
+ const beforeRed = pixels[pixelIndex] ?? 0;
1009
+ const beforeGreen = pixels[pixelIndex + 1] ?? 0;
1010
+ const beforeBlue = pixels[pixelIndex + 2] ?? 0;
1011
+ output[pixelIndex] = clampByte(beforeRed * (1 - alpha) + color[0] * alpha);
1012
+ output[pixelIndex + 1] = clampByte(beforeGreen * (1 - alpha) + color[1] * alpha);
1013
+ output[pixelIndex + 2] = clampByte(beforeBlue * (1 - alpha) + color[2] * alpha);
1014
+ output[pixelIndex + 3] = pixels[pixelIndex + 3] ?? 255;
1015
+ if (Math.abs(output[pixelIndex]! - beforeRed) + Math.abs(output[pixelIndex + 1]! - beforeGreen) + Math.abs(output[pixelIndex + 2]! - beforeBlue) > 3) {
1016
+ changedPixels += 1;
1017
+ }
1018
+ }
1019
+
1020
+ return {
1021
+ width,
1022
+ height,
1023
+ pixels: output,
1024
+ outlineMask,
1025
+ outlinedPixels,
1026
+ changedPixels,
1027
+ maxGradient: Number(maxGradient.toFixed(6)),
1028
+ method: "sobel-luma"
1029
+ };
1030
+ }
1031
+
1032
+ export function filmGrainPixels(
1033
+ pixels: Uint8Array,
1034
+ width: number,
1035
+ height: number,
1036
+ options: FilmGrainOptions = {}
1037
+ ): FilmGrainResult {
1038
+ validatePixelBuffer(pixels, width, height, "Film grain");
1039
+ const intensity = options.intensity ?? 0.08;
1040
+ const seed = options.seed ?? 1;
1041
+ const monochrome = options.monochrome ?? true;
1042
+ validateRange(intensity, 0, 1, "Film grain intensity");
1043
+ if (!Number.isInteger(seed)) {
1044
+ throw new Error("Film grain seed must be an integer.");
1045
+ }
1046
+ const output = new Uint8Array(pixels);
1047
+ let changedPixels = 0;
1048
+ for (let y = 0; y < height; y += 1) {
1049
+ for (let x = 0; x < width; x += 1) {
1050
+ const index = (y * width + x) * 4;
1051
+ const luma = ((pixels[index] ?? 0) * 0.2126 + (pixels[index + 1] ?? 0) * 0.7152 + (pixels[index + 2] ?? 0) * 0.0722) / 255;
1052
+ const grain = (
1053
+ noise2d(x, y, seed) +
1054
+ noise2d(Math.floor(x / 2), Math.floor(y / 2), seed + 97) +
1055
+ noise2d(x + 19, y + 31, seed + 193)
1056
+ ) / 3 * 2 - 1;
1057
+ const amplitude = intensity * 84 * (0.35 + 0.65 * (1 - luma));
1058
+ const redGrain = grain;
1059
+ const greenGrain = monochrome ? grain : grain * 0.72 + (noise2d(x, y, seed + 17) * 2 - 1) * 0.28;
1060
+ const blueGrain = monochrome ? grain : grain * 0.72 + (noise2d(x, y, seed + 31) * 2 - 1) * 0.28;
1061
+ output[index] = clampByte((pixels[index] ?? 0) + redGrain * amplitude);
1062
+ output[index + 1] = clampByte((pixels[index + 1] ?? 0) + greenGrain * amplitude);
1063
+ output[index + 2] = clampByte((pixels[index + 2] ?? 0) + blueGrain * amplitude);
1064
+ output[index + 3] = pixels[index + 3] ?? 255;
1065
+ if (Math.abs(output[index]! - (pixels[index] ?? 0)) + Math.abs(output[index + 1]! - (pixels[index + 1] ?? 0)) + Math.abs(output[index + 2]! - (pixels[index + 2] ?? 0)) > 0) {
1066
+ changedPixels += 1;
1067
+ }
1068
+ }
1069
+ }
1070
+ return { width, height, pixels: output, changedPixels, seed, intensity, monochrome };
1071
+ }
1072
+
1073
+ export function depthOfFieldPixels(
1074
+ pixels: Uint8Array,
1075
+ width: number,
1076
+ height: number,
1077
+ options: DepthOfFieldOptions
1078
+ ): DepthOfFieldResult {
1079
+ validatePixelBuffer(pixels, width, height, "Depth of field");
1080
+ const focusDepth = options.focusDepth ?? 0.5;
1081
+ const focusRange = options.focusRange ?? 0.12;
1082
+ const maxRadius = options.maxRadius ?? 2;
1083
+ validateRange(focusDepth, 0, 1, "Depth of field focusDepth");
1084
+ validateRange(focusRange, 0.001, 1, "Depth of field focusRange");
1085
+ if (!Number.isInteger(maxRadius) || maxRadius < 0 || maxRadius > 8) {
1086
+ throw new Error("Depth of field maxRadius must be an integer in [0, 8].");
1087
+ }
1088
+ const depthTexture = requireDepthTextureBinding(options.depth, "Depth of field");
1089
+ if (depthTexture.width !== width || depthTexture.height !== height) {
1090
+ throw new Error("Depth of field depth texture dimensions must match source pixels.");
1091
+ }
1092
+ const output = new Uint8Array(pixels);
1093
+ let blurredPixels = 0;
1094
+ for (let y = 0; y < height; y += 1) {
1095
+ for (let x = 0; x < width; x += 1) {
1096
+ const depth = depthAt(depthTexture, x, y);
1097
+ const radius = Math.min(maxRadius, Math.round(Math.max(0, Math.abs(depth - focusDepth) - focusRange) / Math.max(focusRange, 0.001) * maxRadius));
1098
+ if (radius === 0) continue;
1099
+ blurredPixels += 1;
1100
+ const index = (y * width + x) * 4;
1101
+ let red = 0;
1102
+ let green = 0;
1103
+ let blue = 0;
1104
+ let samples = 0;
1105
+ for (let offsetY = -radius; offsetY <= radius; offsetY += 1) {
1106
+ for (let offsetX = -radius; offsetX <= radius; offsetX += 1) {
1107
+ if (Math.hypot(offsetX, offsetY) > radius + 0.01) continue;
1108
+ const sampleX = clampInt(x + offsetX, 0, width - 1);
1109
+ const sampleY = clampInt(y + offsetY, 0, height - 1);
1110
+ const sampleIndex = (sampleY * width + sampleX) * 4;
1111
+ red += pixels[sampleIndex] ?? 0;
1112
+ green += pixels[sampleIndex + 1] ?? 0;
1113
+ blue += pixels[sampleIndex + 2] ?? 0;
1114
+ samples += 1;
1115
+ }
1116
+ }
1117
+ output[index] = clampByte(red / samples);
1118
+ output[index + 1] = clampByte(green / samples);
1119
+ output[index + 2] = clampByte(blue / samples);
1120
+ output[index + 3] = pixels[index + 3] ?? 255;
1121
+ }
1122
+ }
1123
+ return { width, height, pixels: output, blurredPixels, maxBlurRadius: maxRadius, focusDepth, focusRange };
1124
+ }
1125
+
1126
+ export function motionBlurPixels(
1127
+ pixels: Uint8Array,
1128
+ width: number,
1129
+ height: number,
1130
+ options: MotionBlurOptions
1131
+ ): MotionBlurResult {
1132
+ validatePixelBuffer(pixels, width, height, "Motion blur");
1133
+ const samples = options.samples ?? 5;
1134
+ const scale = options.scale ?? 1;
1135
+ if (!Number.isInteger(samples) || samples < 2 || samples > 16) {
1136
+ throw new Error("Motion blur samples must be an integer in [2, 16].");
1137
+ }
1138
+ if (!Number.isFinite(scale) || scale < 0 || scale > 8) {
1139
+ throw new Error("Motion blur scale must be finite in [0, 8].");
1140
+ }
1141
+ if (options.velocity.length !== width * height * 2) {
1142
+ throw new Error("Motion blur velocity must contain width * height * 2 float samples.");
1143
+ }
1144
+ const output = new Uint8Array(pixels);
1145
+ let blurredPixels = 0;
1146
+ let maxVelocityPixels = 0;
1147
+ for (let y = 0; y < height; y += 1) {
1148
+ for (let x = 0; x < width; x += 1) {
1149
+ const velocityIndex = (y * width + x) * 2;
1150
+ const vx = (options.velocity[velocityIndex] ?? 0) * scale;
1151
+ const vy = (options.velocity[velocityIndex + 1] ?? 0) * scale;
1152
+ const velocityPixels = Math.hypot(vx, vy);
1153
+ maxVelocityPixels = Math.max(maxVelocityPixels, velocityPixels);
1154
+ if (velocityPixels < 0.01) continue;
1155
+ blurredPixels += 1;
1156
+ const index = (y * width + x) * 4;
1157
+ let red = 0;
1158
+ let green = 0;
1159
+ let blue = 0;
1160
+ for (let sample = 0; sample < samples; sample += 1) {
1161
+ const t = samples === 1 ? 0 : sample / (samples - 1) - 0.5;
1162
+ const sampleX = clampInt(Math.round(x - vx * t), 0, width - 1);
1163
+ const sampleY = clampInt(Math.round(y - vy * t), 0, height - 1);
1164
+ const sampleIndex = (sampleY * width + sampleX) * 4;
1165
+ red += pixels[sampleIndex] ?? 0;
1166
+ green += pixels[sampleIndex + 1] ?? 0;
1167
+ blue += pixels[sampleIndex + 2] ?? 0;
1168
+ }
1169
+ output[index] = clampByte(red / samples);
1170
+ output[index + 1] = clampByte(green / samples);
1171
+ output[index + 2] = clampByte(blue / samples);
1172
+ output[index + 3] = pixels[index + 3] ?? 255;
1173
+ }
1174
+ }
1175
+ return { width, height, pixels: output, blurredPixels, samples, maxVelocityPixels };
1176
+ }
1177
+
1178
+ export function ssaoPixels(
1179
+ pixels: Uint8Array,
1180
+ width: number,
1181
+ height: number,
1182
+ options: SSAOOptions
1183
+ ): SSAOResult {
1184
+ validatePixelBuffer(pixels, width, height, "SSAO");
1185
+ const depthTexture = requireDepthTextureBinding(options.depth, "SSAO");
1186
+ if (depthTexture.width !== width || depthTexture.height !== height) {
1187
+ throw new Error("SSAO depth texture dimensions must match source pixels.");
1188
+ }
1189
+ const radius = options.radius ?? 2;
1190
+ const intensity = options.intensity ?? 0.38;
1191
+ const bias = options.bias ?? 0.015;
1192
+ if (!Number.isInteger(radius) || radius < 1 || radius > 8) {
1193
+ throw new Error("SSAO radius must be an integer in [1, 8].");
1194
+ }
1195
+ validateRange(intensity, 0, 2, "SSAO intensity");
1196
+ validateRange(bias, 0, 0.25, "SSAO bias");
1197
+ const output = new Uint8Array(pixels);
1198
+ let occludedPixels = 0;
1199
+ let occlusionTotal = 0;
1200
+ for (let y = 0; y < height; y += 1) {
1201
+ for (let x = 0; x < width; x += 1) {
1202
+ const centerDepth = depthAt(depthTexture, x, y);
1203
+ let occlusion = 0;
1204
+ let samples = 0;
1205
+ for (let offsetY = -radius; offsetY <= radius; offsetY += radius) {
1206
+ for (let offsetX = -radius; offsetX <= radius; offsetX += radius) {
1207
+ if (offsetX === 0 && offsetY === 0) continue;
1208
+ const sampleDepth = depthAt(depthTexture, clampInt(x + offsetX, 0, width - 1), clampInt(y + offsetY, 0, height - 1));
1209
+ occlusion += Math.max(0, Math.min(1, (centerDepth - sampleDepth - bias) / (0.14 + radius * 0.04)));
1210
+ samples += 1;
1211
+ }
1212
+ }
1213
+ const factor = Math.max(0.18, 1 - (occlusion / Math.max(1, samples)) * intensity * 0.72);
1214
+ if (factor < 0.995) occludedPixels += 1;
1215
+ occlusionTotal += 1 - factor;
1216
+ const index = (y * width + x) * 4;
1217
+ output[index] = clampByte((pixels[index] ?? 0) * factor);
1218
+ output[index + 1] = clampByte((pixels[index + 1] ?? 0) * factor);
1219
+ output[index + 2] = clampByte((pixels[index + 2] ?? 0) * factor);
1220
+ output[index + 3] = pixels[index + 3] ?? 255;
1221
+ }
1222
+ }
1223
+ return { width, height, pixels: output, occludedPixels, averageOcclusion: Number((occlusionTotal / (width * height)).toFixed(6)), radius, intensity };
1224
+ }
1225
+
1226
+ export function contactShadowPixels(
1227
+ pixels: Uint8Array,
1228
+ width: number,
1229
+ height: number,
1230
+ options: ContactShadowPostProcessOptions
1231
+ ): ContactShadowPostProcessResult {
1232
+ validatePixelBuffer(pixels, width, height, "Contact shadow");
1233
+ const depthTexture = requireDepthTextureBinding(options.depth, "Contact shadow");
1234
+ if (depthTexture.width !== width || depthTexture.height !== height) {
1235
+ throw new Error("Contact shadow depth texture dimensions must match source pixels.");
1236
+ }
1237
+ const radius = options.radius ?? 4;
1238
+ const intensity = options.intensity ?? 0.72;
1239
+ const bias = options.bias ?? 0.008;
1240
+ const thickness = options.thickness ?? 0.12;
1241
+ if (!Number.isInteger(radius) || radius < 1 || radius > 16) {
1242
+ throw new Error("Contact shadow radius must be an integer in [1, 16].");
1243
+ }
1244
+ validateRange(intensity, 0, 2, "Contact shadow intensity");
1245
+ validateRange(bias, 0, 0.25, "Contact shadow bias");
1246
+ validateRange(thickness, 0.005, 1, "Contact shadow thickness");
1247
+ const direction = normalizeContactShadowDirection(options.direction ?? [0.35, 0.8]);
1248
+ const output = new Uint8Array(pixels);
1249
+ let contactPixels = 0;
1250
+ let darkeningTotal = 0;
1251
+
1252
+ for (let y = 0; y < height; y += 1) {
1253
+ for (let x = 0; x < width; x += 1) {
1254
+ const receiverDepth = depthAt(depthTexture, x, y);
1255
+ let contact = 0;
1256
+ for (let step = 1; step <= radius; step += 1) {
1257
+ const longitudinal = step / radius;
1258
+ const lateralRadius = Math.max(1, Math.round(radius * 0.28 * (1 - longitudinal * 0.35)));
1259
+ for (let side = -lateralRadius; side <= lateralRadius; side += 1) {
1260
+ const offsetX = direction[0] * step + -direction[1] * side;
1261
+ const offsetY = direction[1] * step + direction[0] * side;
1262
+ const sampleX = clampInt(Math.round(x - offsetX), 0, width - 1);
1263
+ const sampleY = clampInt(Math.round(y - offsetY), 0, height - 1);
1264
+ const casterDepth = depthAt(depthTexture, sampleX, sampleY);
1265
+ const depthGap = receiverDepth - casterDepth - bias;
1266
+ if (depthGap <= 0 || depthGap > thickness) continue;
1267
+ const spatialFalloff = Math.max(0, 1 - longitudinal);
1268
+ const lateralFalloff = Math.max(0, 1 - Math.abs(side) / (lateralRadius + 1));
1269
+ const depthFalloff = 1 - depthGap / thickness;
1270
+ contact = Math.max(contact, spatialFalloff * lateralFalloff * depthFalloff);
1271
+ }
1272
+ }
1273
+ if (contact <= 0) continue;
1274
+ const shadow = Math.min(0.82, contact * intensity * 0.72);
1275
+ const factor = 1 - shadow;
1276
+ const index = (y * width + x) * 4;
1277
+ output[index] = clampByte((pixels[index] ?? 0) * factor);
1278
+ output[index + 1] = clampByte((pixels[index + 1] ?? 0) * factor);
1279
+ output[index + 2] = clampByte((pixels[index + 2] ?? 0) * factor);
1280
+ output[index + 3] = pixels[index + 3] ?? 255;
1281
+ contactPixels += 1;
1282
+ darkeningTotal += shadow;
1283
+ }
1284
+ }
1285
+
1286
+ return {
1287
+ width,
1288
+ height,
1289
+ pixels: output,
1290
+ contactPixels,
1291
+ averageContactDarkening: Number((darkeningTotal / Math.max(1, contactPixels)).toFixed(6)),
1292
+ radius,
1293
+ intensity,
1294
+ mode: "screen-space-depth-contact"
1295
+ };
1296
+ }
1297
+
1298
+ export function ssrPixels(
1299
+ pixels: Uint8Array,
1300
+ width: number,
1301
+ height: number,
1302
+ options: SSROptions
1303
+ ): SSRResult {
1304
+ validatePixelBuffer(pixels, width, height, "SSR");
1305
+ const depthTexture = requireDepthTextureBinding(options.depth, "SSR");
1306
+ if (depthTexture.width !== width || depthTexture.height !== height) {
1307
+ throw new Error("SSR depth texture dimensions must match source pixels.");
1308
+ }
1309
+ const intensity = options.intensity ?? 0.32;
1310
+ const maxDistance = options.maxDistance ?? 16;
1311
+ validateRange(intensity, 0, 2, "SSR intensity");
1312
+ if (!Number.isInteger(maxDistance) || maxDistance < 1 || maxDistance > 64) {
1313
+ throw new Error("SSR maxDistance must be an integer in [1, 64].");
1314
+ }
1315
+ const output = new Uint8Array(pixels);
1316
+ let reflectedPixels = 0;
1317
+ let maxReflectionBoost = 0;
1318
+ for (let y = 0; y < height; y += 1) {
1319
+ for (let x = 0; x < width; x += 1) {
1320
+ const depth = depthAt(depthTexture, x, y);
1321
+ const rayDistance = Math.max(1, Math.round((1 - depth) * maxDistance));
1322
+ const sampleX = clampInt(x + (x < width / 2 ? rayDistance : -rayDistance), 0, width - 1);
1323
+ const sampleY = clampInt(height - 1 - y, 0, height - 1);
1324
+ const sourceIndex = (sampleY * width + sampleX) * 4;
1325
+ const targetIndex = (y * width + x) * 4;
1326
+ const sourceLuma = ((pixels[sourceIndex] ?? 0) + (pixels[sourceIndex + 1] ?? 0) + (pixels[sourceIndex + 2] ?? 0)) / (3 * 255);
1327
+ if (sourceLuma < 0.18 || depth > 0.92) continue;
1328
+ const boost = sourceLuma * intensity * (1 - depth);
1329
+ maxReflectionBoost = Math.max(maxReflectionBoost, boost);
1330
+ reflectedPixels += 1;
1331
+ output[targetIndex] = clampByte((pixels[targetIndex] ?? 0) + (pixels[sourceIndex] ?? 0) * boost);
1332
+ output[targetIndex + 1] = clampByte((pixels[targetIndex + 1] ?? 0) + (pixels[sourceIndex + 1] ?? 0) * boost);
1333
+ output[targetIndex + 2] = clampByte((pixels[targetIndex + 2] ?? 0) + (pixels[sourceIndex + 2] ?? 0) * boost);
1334
+ output[targetIndex + 3] = pixels[targetIndex + 3] ?? 255;
1335
+ }
1336
+ }
1337
+ return { width, height, pixels: output, reflectedPixels, maxReflectionBoost: Number(maxReflectionBoost.toFixed(6)), intensity, maxDistance };
1338
+ }
1339
+
1340
+ export function taaPixels(
1341
+ pixels: Uint8Array,
1342
+ width: number,
1343
+ height: number,
1344
+ options: TAAOptions
1345
+ ): TAAResult {
1346
+ validatePixelBuffer(pixels, width, height, "TAA");
1347
+ if (options.history.byteLength !== pixels.byteLength) {
1348
+ throw new Error("TAA history must contain width * height * 4 RGBA bytes.");
1349
+ }
1350
+ const blend = options.blend ?? 0.18;
1351
+ validateRange(blend, 0, 0.95, "TAA blend");
1352
+ const output = new Uint8Array(pixels.byteLength);
1353
+ let blendedPixels = 0;
1354
+ for (let index = 0; index < pixels.length; index += 4) {
1355
+ output[index] = clampByte((pixels[index] ?? 0) * (1 - blend) + (options.history[index] ?? 0) * blend);
1356
+ output[index + 1] = clampByte((pixels[index + 1] ?? 0) * (1 - blend) + (options.history[index + 1] ?? 0) * blend);
1357
+ output[index + 2] = clampByte((pixels[index + 2] ?? 0) * (1 - blend) + (options.history[index + 2] ?? 0) * blend);
1358
+ output[index + 3] = pixels[index + 3] ?? 255;
1359
+ if (Math.abs(output[index]! - (pixels[index] ?? 0)) + Math.abs(output[index + 1]! - (pixels[index + 1] ?? 0)) + Math.abs(output[index + 2]! - (pixels[index + 2] ?? 0)) > 0) {
1360
+ blendedPixels += 1;
1361
+ }
1362
+ }
1363
+ return { width, height, pixels: output, blendedPixels, blend };
1364
+ }
1365
+
1366
+ export function bloomPixels(
1367
+ pixels: Uint8Array,
1368
+ width: number,
1369
+ height: number,
1370
+ options: BloomOptions = {}
1371
+ ): BloomResult {
1372
+ validatePixelBuffer(pixels, width, height, "Bloom");
1373
+ const threshold = options.threshold ?? 0.75;
1374
+ const intensity = options.intensity ?? 0.35;
1375
+ const radius = options.radius ?? 1;
1376
+ validateBloomOptions(threshold, intensity, radius);
1377
+
1378
+ const { pixels: brightPixels, brightPixelCount, brightEnergy } = extractBloomBrightPixels(pixels, width, height, threshold);
1379
+ const horizontalBlurPixels = blurBloomPixelsHorizontal(brightPixels, width, height, radius);
1380
+ const verticalBlurPixels = blurBloomPixelsVertical(horizontalBlurPixels, width, height, radius);
1381
+ const composite = compositeBloomPixels(pixels, verticalBlurPixels, width, height, intensity, brightPixels);
1382
+ return {
1383
+ width,
1384
+ height,
1385
+ pixels: composite.pixels,
1386
+ brightPixels,
1387
+ horizontalBlurPixels,
1388
+ verticalBlurPixels,
1389
+ brightPixelCount,
1390
+ brightEnergy,
1391
+ maxNeighborBoost: composite.maxNeighborBoost,
1392
+ changedPixels: composite.changedPixels,
1393
+ maxChannelDelta: composite.maxChannelDelta,
1394
+ pipeline: ["bright-extract", "horizontal-blur", "vertical-blur", "composite"]
1395
+ };
1396
+ }
1397
+
1398
+ export function extractBloomBrightPixels(
1399
+ pixels: Uint8Array,
1400
+ width: number,
1401
+ height: number,
1402
+ threshold: number
1403
+ ): { readonly pixels: Uint8Array; readonly brightPixelCount: number; readonly brightEnergy: number } {
1404
+ validatePixelBuffer(pixels, width, height, "Bloom bright extraction");
1405
+ if (!Number.isFinite(threshold) || threshold < 0 || threshold > 1) {
1406
+ throw new Error("Bloom threshold must be finite and in [0, 1].");
1407
+ }
1408
+ const brightPixels = new Uint8Array(pixels.byteLength);
1409
+ let brightPixelCount = 0;
1410
+ let brightEnergy = 0;
1411
+ for (let index = 0; index < pixels.length; index += 4) {
1412
+ const luma = (0.2126 * pixels[index]! + 0.7152 * pixels[index + 1]! + 0.0722 * pixels[index + 2]!) / 255;
1413
+ if (luma >= threshold) {
1414
+ brightPixelCount += 1;
1415
+ brightEnergy += luma;
1416
+ brightPixels[index] = pixels[index]!;
1417
+ brightPixels[index + 1] = pixels[index + 1]!;
1418
+ brightPixels[index + 2] = pixels[index + 2]!;
1419
+ brightPixels[index + 3] = pixels[index + 3]!;
1420
+ }
1421
+ }
1422
+ return { pixels: brightPixels, brightPixelCount, brightEnergy };
1423
+ }
1424
+
1425
+ export function blurBloomPixelsHorizontal(pixels: Uint8Array, width: number, height: number, radius: number): Uint8Array {
1426
+ validatePixelBuffer(pixels, width, height, "Bloom horizontal blur");
1427
+ validateBloomBlurRadius(radius);
1428
+ const kernelSize = radius * 2 + 1;
1429
+ const output = new Uint8Array(pixels.byteLength);
1430
+ for (let y = 0; y < height; y += 1) {
1431
+ for (let x = 0; x < width; x += 1) {
1432
+ const targetIndex = (y * width + x) * 4;
1433
+ let red = 0;
1434
+ let green = 0;
1435
+ let blue = 0;
1436
+ let alpha = 0;
1437
+ for (let offsetX = -radius; offsetX <= radius; offsetX += 1) {
1438
+ const sampleX = clampInt(x + offsetX, 0, width - 1);
1439
+ const sampleIndex = (y * width + sampleX) * 4;
1440
+ red += pixels[sampleIndex]!;
1441
+ green += pixels[sampleIndex + 1]!;
1442
+ blue += pixels[sampleIndex + 2]!;
1443
+ alpha += pixels[sampleIndex + 3]!;
1444
+ }
1445
+ output[targetIndex] = clampByte(red / kernelSize);
1446
+ output[targetIndex + 1] = clampByte(green / kernelSize);
1447
+ output[targetIndex + 2] = clampByte(blue / kernelSize);
1448
+ output[targetIndex + 3] = clampByte(alpha / kernelSize);
1449
+ }
1450
+ }
1451
+ return output;
1452
+ }
1453
+
1454
+ export function blurBloomPixelsVertical(pixels: Uint8Array, width: number, height: number, radius: number): Uint8Array {
1455
+ validatePixelBuffer(pixels, width, height, "Bloom vertical blur");
1456
+ validateBloomBlurRadius(radius);
1457
+ const kernelSize = radius * 2 + 1;
1458
+ const output = new Uint8Array(pixels.byteLength);
1459
+ for (let y = 0; y < height; y += 1) {
1460
+ for (let x = 0; x < width; x += 1) {
1461
+ const targetIndex = (y * width + x) * 4;
1462
+ let red = 0;
1463
+ let green = 0;
1464
+ let blue = 0;
1465
+ let alpha = 0;
1466
+ for (let offsetY = -radius; offsetY <= radius; offsetY += 1) {
1467
+ const sampleY = clampInt(y + offsetY, 0, height - 1);
1468
+ const sampleIndex = (sampleY * width + x) * 4;
1469
+ red += pixels[sampleIndex]!;
1470
+ green += pixels[sampleIndex + 1]!;
1471
+ blue += pixels[sampleIndex + 2]!;
1472
+ alpha += pixels[sampleIndex + 3]!;
1473
+ }
1474
+ output[targetIndex] = clampByte(red / kernelSize);
1475
+ output[targetIndex + 1] = clampByte(green / kernelSize);
1476
+ output[targetIndex + 2] = clampByte(blue / kernelSize);
1477
+ output[targetIndex + 3] = clampByte(alpha / kernelSize);
1478
+ }
1479
+ }
1480
+ return output;
1481
+ }
1482
+
1483
+ export function compositeBloomPixels(
1484
+ sourcePixels: Uint8Array,
1485
+ blurredPixels: Uint8Array,
1486
+ width: number,
1487
+ height: number,
1488
+ intensity: number,
1489
+ brightPixels?: Uint8Array
1490
+ ): { readonly pixels: Uint8Array; readonly maxNeighborBoost: number; readonly changedPixels: number; readonly maxChannelDelta: number } {
1491
+ validatePixelBuffer(sourcePixels, width, height, "Bloom composite source");
1492
+ validatePixelBuffer(blurredPixels, width, height, "Bloom composite blur");
1493
+ if (brightPixels) validatePixelBuffer(brightPixels, width, height, "Bloom composite bright source");
1494
+ if (!Number.isFinite(intensity) || intensity < 0) {
1495
+ throw new Error("Bloom intensity must be finite and non-negative.");
1496
+ }
1497
+ const output = new Uint8Array(sourcePixels);
1498
+ let maxNeighborBoost = 0;
1499
+ let changedPixels = 0;
1500
+ let maxChannelDelta = 0;
1501
+ for (let index = 0; index < sourcePixels.length; index += 4) {
1502
+ const previousRed = output[index]!;
1503
+ const previousGreen = output[index + 1]!;
1504
+ const previousBlue = output[index + 2]!;
1505
+ const redBoost = blurredPixels[index]! * intensity;
1506
+ const greenBoost = blurredPixels[index + 1]! * intensity;
1507
+ const blueBoost = blurredPixels[index + 2]! * intensity;
1508
+ output[index] = clampByte(output[index]! + redBoost);
1509
+ output[index + 1] = clampByte(output[index + 1]! + greenBoost);
1510
+ output[index + 2] = clampByte(output[index + 2]! + blueBoost);
1511
+ output[index + 3] = sourcePixels[index + 3]!;
1512
+ const redDelta = Math.abs(output[index]! - previousRed);
1513
+ const greenDelta = Math.abs(output[index + 1]! - previousGreen);
1514
+ const blueDelta = Math.abs(output[index + 2]! - previousBlue);
1515
+ const pixelDelta = Math.max(redDelta, greenDelta, blueDelta);
1516
+ if (pixelDelta > 0) {
1517
+ changedPixels += 1;
1518
+ maxChannelDelta = Math.max(maxChannelDelta, pixelDelta);
1519
+ }
1520
+ if (!brightPixels || (brightPixels[index] === 0 && brightPixels[index + 1] === 0 && brightPixels[index + 2] === 0)) {
1521
+ maxNeighborBoost = Math.max(maxNeighborBoost, redBoost, greenBoost, blueBoost);
1522
+ }
1523
+ }
1524
+ return { pixels: output, maxNeighborBoost, changedPixels, maxChannelDelta };
1525
+ }
1526
+
1527
+ export function bloomFloatPixels(
1528
+ pixels: Float32Array,
1529
+ width: number,
1530
+ height: number,
1531
+ options: BloomOptions = {}
1532
+ ): HdrBloomResult {
1533
+ if (!Number.isInteger(width) || width <= 0 || !Number.isInteger(height) || height <= 0) {
1534
+ throw new Error("HDR bloom dimensions must be positive integers.");
1535
+ }
1536
+ if (pixels.length !== width * height * 4) {
1537
+ throw new Error("HDR bloom input must contain width * height * 4 RGBA float values.");
1538
+ }
1539
+ const threshold = options.threshold ?? 0.75;
1540
+ const intensity = options.intensity ?? 0.35;
1541
+ const radius = options.radius ?? 1;
1542
+ validateBloomOptions(threshold, intensity, radius);
1543
+
1544
+ const brightPixels = new Float32Array(pixels.length);
1545
+ let brightPixelCount = 0;
1546
+ let brightEnergy = 0;
1547
+ let maxInputValue = 0;
1548
+ for (let index = 0; index < pixels.length; index += 4) {
1549
+ const red = finiteHdrChannel(pixels[index]!, index);
1550
+ const green = finiteHdrChannel(pixels[index + 1]!, index + 1);
1551
+ const blue = finiteHdrChannel(pixels[index + 2]!, index + 2);
1552
+ const alpha = finiteHdrChannel(pixels[index + 3]!, index + 3);
1553
+ maxInputValue = Math.max(maxInputValue, red, green, blue);
1554
+ const luma = 0.2126 * red + 0.7152 * green + 0.0722 * blue;
1555
+ if (luma >= threshold) {
1556
+ brightPixelCount += 1;
1557
+ brightEnergy += luma;
1558
+ brightPixels[index] = red;
1559
+ brightPixels[index + 1] = green;
1560
+ brightPixels[index + 2] = blue;
1561
+ brightPixels[index + 3] = alpha;
1562
+ }
1563
+ }
1564
+
1565
+ const horizontalBlurPixels = blurBloomFloatPixelsHorizontal(brightPixels, width, height, radius);
1566
+ const verticalBlurPixels = blurBloomFloatPixelsVertical(horizontalBlurPixels, width, height, radius);
1567
+ const composite = compositeBloomFloatPixels(pixels, verticalBlurPixels, width, height, intensity, brightPixels);
1568
+
1569
+ return {
1570
+ width,
1571
+ height,
1572
+ pixels: composite.pixels,
1573
+ brightPixels,
1574
+ horizontalBlurPixels,
1575
+ verticalBlurPixels,
1576
+ brightPixelCount,
1577
+ brightEnergy: Number(brightEnergy.toFixed(6)),
1578
+ maxNeighborBoost: Number(composite.maxNeighborBoost.toFixed(6)),
1579
+ changedPixels: composite.changedPixels,
1580
+ maxChannelDelta: Number(composite.maxChannelDelta.toFixed(6)),
1581
+ maxInputValue: Number(maxInputValue.toFixed(6)),
1582
+ pipeline: ["bright-extract", "horizontal-blur", "vertical-blur", "composite"]
1583
+ };
1584
+ }
1585
+
1586
+ function blurBloomFloatPixelsHorizontal(pixels: Float32Array, width: number, height: number, radius: number): Float32Array {
1587
+ validateFloatPixelBuffer(pixels, width, height, "HDR bloom horizontal blur");
1588
+ validateBloomBlurRadius(radius);
1589
+ const kernelSize = radius * 2 + 1;
1590
+ const output = new Float32Array(pixels.length);
1591
+ for (let y = 0; y < height; y += 1) {
1592
+ for (let x = 0; x < width; x += 1) {
1593
+ const targetIndex = (y * width + x) * 4;
1594
+ let red = 0;
1595
+ let green = 0;
1596
+ let blue = 0;
1597
+ let alpha = 0;
1598
+ for (let offsetX = -radius; offsetX <= radius; offsetX += 1) {
1599
+ const sampleX = clampInt(x + offsetX, 0, width - 1);
1600
+ const sampleIndex = (y * width + sampleX) * 4;
1601
+ red += finiteHdrChannel(pixels[sampleIndex]!, sampleIndex);
1602
+ green += finiteHdrChannel(pixels[sampleIndex + 1]!, sampleIndex + 1);
1603
+ blue += finiteHdrChannel(pixels[sampleIndex + 2]!, sampleIndex + 2);
1604
+ alpha += finiteHdrChannel(pixels[sampleIndex + 3]!, sampleIndex + 3);
1605
+ }
1606
+ output[targetIndex] = red / kernelSize;
1607
+ output[targetIndex + 1] = green / kernelSize;
1608
+ output[targetIndex + 2] = blue / kernelSize;
1609
+ output[targetIndex + 3] = alpha / kernelSize;
1610
+ }
1611
+ }
1612
+ return output;
1613
+ }
1614
+
1615
+ function blurBloomFloatPixelsVertical(pixels: Float32Array, width: number, height: number, radius: number): Float32Array {
1616
+ validateFloatPixelBuffer(pixels, width, height, "HDR bloom vertical blur");
1617
+ validateBloomBlurRadius(radius);
1618
+ const kernelSize = radius * 2 + 1;
1619
+ const output = new Float32Array(pixels.length);
1620
+ for (let y = 0; y < height; y += 1) {
1621
+ for (let x = 0; x < width; x += 1) {
1622
+ const targetIndex = (y * width + x) * 4;
1623
+ let red = 0;
1624
+ let green = 0;
1625
+ let blue = 0;
1626
+ let alpha = 0;
1627
+ for (let offsetY = -radius; offsetY <= radius; offsetY += 1) {
1628
+ const sampleY = clampInt(y + offsetY, 0, height - 1);
1629
+ const sampleIndex = (sampleY * width + x) * 4;
1630
+ red += finiteHdrChannel(pixels[sampleIndex]!, sampleIndex);
1631
+ green += finiteHdrChannel(pixels[sampleIndex + 1]!, sampleIndex + 1);
1632
+ blue += finiteHdrChannel(pixels[sampleIndex + 2]!, sampleIndex + 2);
1633
+ alpha += finiteHdrChannel(pixels[sampleIndex + 3]!, sampleIndex + 3);
1634
+ }
1635
+ output[targetIndex] = red / kernelSize;
1636
+ output[targetIndex + 1] = green / kernelSize;
1637
+ output[targetIndex + 2] = blue / kernelSize;
1638
+ output[targetIndex + 3] = alpha / kernelSize;
1639
+ }
1640
+ }
1641
+ return output;
1642
+ }
1643
+
1644
+ function compositeBloomFloatPixels(
1645
+ sourcePixels: Float32Array,
1646
+ blurredPixels: Float32Array,
1647
+ width: number,
1648
+ height: number,
1649
+ intensity: number,
1650
+ brightPixels?: Float32Array
1651
+ ): { readonly pixels: Float32Array; readonly maxNeighborBoost: number; readonly changedPixels: number; readonly maxChannelDelta: number } {
1652
+ validateFloatPixelBuffer(sourcePixels, width, height, "HDR bloom composite source");
1653
+ validateFloatPixelBuffer(blurredPixels, width, height, "HDR bloom composite blur");
1654
+ if (brightPixels) validateFloatPixelBuffer(brightPixels, width, height, "HDR bloom composite bright source");
1655
+ if (!Number.isFinite(intensity) || intensity < 0) {
1656
+ throw new Error("Bloom intensity must be finite and non-negative.");
1657
+ }
1658
+ const output = new Float32Array(sourcePixels);
1659
+ let maxNeighborBoost = 0;
1660
+ let changedPixels = 0;
1661
+ let maxChannelDelta = 0;
1662
+ for (let index = 0; index < sourcePixels.length; index += 4) {
1663
+ const previousRed = finiteHdrChannel(output[index]!, index);
1664
+ const previousGreen = finiteHdrChannel(output[index + 1]!, index + 1);
1665
+ const previousBlue = finiteHdrChannel(output[index + 2]!, index + 2);
1666
+ const redBoost = finiteHdrChannel(blurredPixels[index]!, index) * intensity;
1667
+ const greenBoost = finiteHdrChannel(blurredPixels[index + 1]!, index + 1) * intensity;
1668
+ const blueBoost = finiteHdrChannel(blurredPixels[index + 2]!, index + 2) * intensity;
1669
+ output[index] = previousRed + redBoost;
1670
+ output[index + 1] = previousGreen + greenBoost;
1671
+ output[index + 2] = previousBlue + blueBoost;
1672
+ output[index + 3] = finiteHdrChannel(output[index + 3]!, index + 3);
1673
+ const pixelDelta = Math.max(
1674
+ Math.abs(output[index]! - previousRed),
1675
+ Math.abs(output[index + 1]! - previousGreen),
1676
+ Math.abs(output[index + 2]! - previousBlue)
1677
+ );
1678
+ if (pixelDelta > 0) {
1679
+ changedPixels += 1;
1680
+ maxChannelDelta = Math.max(maxChannelDelta, pixelDelta);
1681
+ }
1682
+ if (!brightPixels || (brightPixels[index] === 0 && brightPixels[index + 1] === 0 && brightPixels[index + 2] === 0)) {
1683
+ maxNeighborBoost = Math.max(maxNeighborBoost, redBoost, greenBoost, blueBoost);
1684
+ }
1685
+ }
1686
+ return { pixels: output, maxNeighborBoost, changedPixels, maxChannelDelta };
1687
+ }
1688
+
1689
+ export function createDepthTextureBinding(options: {
1690
+ readonly label: string;
1691
+ readonly width: number;
1692
+ readonly height: number;
1693
+ readonly data?: Float32Array;
1694
+ }): DepthTextureBinding {
1695
+ const { label, width, height } = options;
1696
+ if (!label) throw new Error("Depth texture label is required.");
1697
+ if (!Number.isInteger(width) || width <= 0 || !Number.isInteger(height) || height <= 0) {
1698
+ throw new Error("Depth texture dimensions must be positive integers.");
1699
+ }
1700
+ const data = options.data ? new Float32Array(options.data) : new Float32Array(width * height);
1701
+ if (data.length !== width * height) {
1702
+ throw new Error("Depth texture data must contain width * height float samples.");
1703
+ }
1704
+ for (const value of data) {
1705
+ if (!Number.isFinite(value) || value < 0 || value > 1) {
1706
+ throw new Error("Depth texture samples must be finite normalized values in [0, 1].");
1707
+ }
1708
+ }
1709
+ return { label, width, height, format: "depth24", data };
1710
+ }
1711
+
1712
+ export function createToneMappingCalibration(options: Required<ToneMappingOptions>): ToneMappingCalibration {
1713
+ const samples = [0, 0.18, 0.5, 1].map((inputLinear) => {
1714
+ const mappedLinear = applyToneMapping(inputLinear, options.exposure, options.whitePoint, options.operator);
1715
+ return {
1716
+ inputLinear,
1717
+ mappedLinear,
1718
+ encodedByte: encodeColorByte(mappedLinear, options.gamma, options.outputColorSpace)
1719
+ };
1720
+ });
1721
+ return {
1722
+ operator: options.operator,
1723
+ exposure: options.exposure,
1724
+ whitePoint: options.whitePoint,
1725
+ gamma: options.gamma,
1726
+ inputColorSpace: options.inputColorSpace,
1727
+ outputColorSpace: options.outputColorSpace,
1728
+ samples,
1729
+ monotonic: samples.every((sample, index) => index === 0 || sample.encodedByte >= samples[index - 1]!.encodedByte)
1730
+ };
1731
+ }
1732
+
1733
+ export function visualizeDepthTexture(
1734
+ texture: DepthTextureBinding,
1735
+ options: { readonly edgeThreshold?: number } = {}
1736
+ ): DepthVisualizationResult {
1737
+ const edgeThreshold = options.edgeThreshold ?? 0.08;
1738
+ if (!Number.isFinite(edgeThreshold) || edgeThreshold < 0 || edgeThreshold > 1) {
1739
+ throw new Error("Depth visualization edgeThreshold must be finite and in [0, 1].");
1740
+ }
1741
+ const stats = depthTextureStats(texture, edgeThreshold);
1742
+ const pixels = new Uint8Array(texture.width * texture.height * 4);
1743
+ for (let y = 0; y < texture.height; y += 1) {
1744
+ for (let x = 0; x < texture.width; x += 1) {
1745
+ const pixelIndex = (y * texture.width + x) * 4;
1746
+ const depth = depthAt(texture, x, y);
1747
+ const edge = isDepthEdge(texture, x, y, edgeThreshold);
1748
+ const shade = clampByte((1 - depth) * 255);
1749
+ pixels[pixelIndex] = edge ? 255 : shade;
1750
+ pixels[pixelIndex + 1] = edge ? 98 : shade;
1751
+ pixels[pixelIndex + 2] = edge ? 36 : shade;
1752
+ pixels[pixelIndex + 3] = 255;
1753
+ }
1754
+ }
1755
+ return { width: texture.width, height: texture.height, pixels, stats };
1756
+ }
1757
+
1758
+ export function depthTextureStats(texture: DepthTextureBinding, edgeThreshold = 0.08): DepthTextureStats {
1759
+ if (texture.data.length !== texture.width * texture.height) {
1760
+ throw new Error("Depth texture data length does not match dimensions.");
1761
+ }
1762
+ let minDepth = Number.POSITIVE_INFINITY;
1763
+ let maxDepth = Number.NEGATIVE_INFINITY;
1764
+ let edgePixelCount = 0;
1765
+ for (let y = 0; y < texture.height; y += 1) {
1766
+ for (let x = 0; x < texture.width; x += 1) {
1767
+ const depth = depthAt(texture, x, y);
1768
+ minDepth = Math.min(minDepth, depth);
1769
+ maxDepth = Math.max(maxDepth, depth);
1770
+ if (isDepthEdge(texture, x, y, edgeThreshold)) edgePixelCount += 1;
1771
+ }
1772
+ }
1773
+ return {
1774
+ label: texture.label,
1775
+ width: texture.width,
1776
+ height: texture.height,
1777
+ format: texture.format,
1778
+ byteLength: texture.data.byteLength,
1779
+ minDepth,
1780
+ maxDepth,
1781
+ centerDepth: depthAt(texture, Math.floor(texture.width / 2), Math.floor(texture.height / 2)),
1782
+ nearSample: depthAt(texture, Math.floor(texture.width * 0.48), Math.floor(texture.height * 0.44)),
1783
+ farSample: depthAt(texture, 1, 1),
1784
+ edgePixelCount
1785
+ };
1786
+ }
1787
+
1788
+ export function fxaaPixels(
1789
+ pixels: Uint8Array,
1790
+ width: number,
1791
+ height: number,
1792
+ options: FXAAOptions = {}
1793
+ ): FXAAResult {
1794
+ validatePixelBuffer(pixels, width, height, "FXAA");
1795
+ const edgeThreshold = options.edgeThreshold ?? 0.125;
1796
+ const subpixelBlend = options.subpixelBlend ?? 0.75;
1797
+ validateFXAAOptions(edgeThreshold, subpixelBlend);
1798
+
1799
+ const output = new Uint8Array(pixels);
1800
+ const edgeMask = new Uint8Array(width * height);
1801
+ for (let y = 0; y < height; y += 1) {
1802
+ for (let x = 0; x < width; x += 1) {
1803
+ const index = (y * width + x) * 4;
1804
+ const centerLuma = lumaAt(pixels, width, height, x, y);
1805
+ const northLuma = lumaAt(pixels, width, height, x, y - 1);
1806
+ const southLuma = lumaAt(pixels, width, height, x, y + 1);
1807
+ const westLuma = lumaAt(pixels, width, height, x - 1, y);
1808
+ const eastLuma = lumaAt(pixels, width, height, x + 1, y);
1809
+ const minLuma = Math.min(centerLuma, northLuma, southLuma, westLuma, eastLuma);
1810
+ const maxLuma = Math.max(centerLuma, northLuma, southLuma, westLuma, eastLuma);
1811
+ if (maxLuma - minLuma < edgeThreshold) {
1812
+ continue;
1813
+ }
1814
+
1815
+ edgeMask[y * width + x] = 255;
1816
+ for (let channel = 0; channel < 3; channel += 1) {
1817
+ const average = (
1818
+ channelAt(pixels, width, height, x, y - 1, channel)
1819
+ + channelAt(pixels, width, height, x, y + 1, channel)
1820
+ + channelAt(pixels, width, height, x - 1, y, channel)
1821
+ + channelAt(pixels, width, height, x + 1, y, channel)
1822
+ ) / 4;
1823
+ output[index + channel] = clampByte(pixels[index + channel]! * (1 - subpixelBlend) + average * subpixelBlend);
1824
+ }
1825
+ output[index + 3] = pixels[index + 3]!;
1826
+ }
1827
+ }
1828
+
1829
+ return { width, height, pixels: output, edgeMask };
1830
+ }
1831
+
1832
+ export function fusedLdrPostprocessPixels(
1833
+ pixels: Uint8Array,
1834
+ width: number,
1835
+ height: number,
1836
+ passes: readonly FusedLdrPostProcessPass[],
1837
+ options: FusedLdrPostProcessOptions = {}
1838
+ ): Uint8Array {
1839
+ validatePixelBuffer(pixels, width, height, "Fused LDR postprocess");
1840
+ const toneMapping = passes.find((pass) => pass.name === "tone-mapping");
1841
+ const colorGrade = passes.find((pass) => pass.name === "color-grade");
1842
+ const fxaa = passes.find((pass) => pass.name === "fxaa");
1843
+ const toneMappingLookup = toneMapping
1844
+ ? getToneMappingLookup(
1845
+ {
1846
+ ...(options.toneMappingDefaults ?? {}),
1847
+ ...(toneMapping.options as ToneMappingOptions)
1848
+ },
1849
+ options.scratch
1850
+ )
1851
+ : undefined;
1852
+ const colorGradeSettings = colorGrade ? normalizeColorGradeOptions(colorGrade.options as ColorGradeOptions) : undefined;
1853
+ const byteLength = pixels.byteLength;
1854
+ let current = pixels;
1855
+
1856
+ if (toneMappingLookup || colorGradeSettings) {
1857
+ const target = options.mutateInput
1858
+ ? pixels
1859
+ : acquireFusedLdrBuffer(options.scratch, byteLength, 0);
1860
+ const vignetteFactors = colorGradeSettings && colorGradeSettings.vignette > 0
1861
+ ? getVignetteFactors(width, height, colorGradeSettings.vignette, options.scratch)
1862
+ : undefined;
1863
+ applyToneMappingAndColorGrade(pixels, target, width, height, toneMappingLookup, colorGradeSettings, vignetteFactors);
1864
+ current = target;
1865
+ }
1866
+
1867
+ if (colorGradeSettings && colorGradeSettings.sharpening > 0) {
1868
+ const target = acquireFusedLdrBuffer(options.scratch, byteLength, current === options.scratch?.bufferA ? 1 : 0);
1869
+ sharpenPixelsInto(current, target, width, height, colorGradeSettings.sharpening);
1870
+ current = target;
1871
+ }
1872
+
1873
+ if (fxaa) {
1874
+ const settings = normalizeFXAAOptions(fxaa.options as FXAAOptions);
1875
+ const target = acquireFusedLdrBuffer(options.scratch, byteLength, current === options.scratch?.bufferA ? 1 : 0);
1876
+ fxaaPixelsInto(current, target, width, height, settings.edgeThreshold, settings.subpixelBlend);
1877
+ current = target;
1878
+ }
1879
+
1880
+ return current;
1881
+ }
1882
+
1883
+ function validatePixelBuffer(pixels: Uint8Array, width: number, height: number, label: string): void {
1884
+ if (!Number.isInteger(width) || width <= 0 || !Number.isInteger(height) || height <= 0) {
1885
+ throw new Error(`${label} dimensions must be positive integers.`);
1886
+ }
1887
+ if (pixels.byteLength !== width * height * 4) {
1888
+ throw new Error(`${label} input must contain width * height * 4 RGBA bytes.`);
1889
+ }
1890
+ }
1891
+
1892
+ function validateFloatPixelBuffer(pixels: Float32Array, width: number, height: number, label: string): void {
1893
+ if (!Number.isInteger(width) || width <= 0 || !Number.isInteger(height) || height <= 0) {
1894
+ throw new Error(`${label} dimensions must be positive integers.`);
1895
+ }
1896
+ if (pixels.length !== width * height * 4) {
1897
+ throw new Error(`${label} input must contain width * height * 4 RGBA float values.`);
1898
+ }
1899
+ }
1900
+
1901
+ function requireDepthTextureBinding(depth: DepthTextureBinding | undefined, label: string): DepthTextureBinding {
1902
+ if (!depth) {
1903
+ throw new Error(`${label} requires a depth texture binding. Renderer-owned postprocess passes inject this automatically when the backend exposes depth readback.`);
1904
+ }
1905
+ return depth;
1906
+ }
1907
+
1908
+ function validateFXAAOptions(edgeThreshold: number, subpixelBlend: number): void {
1909
+ if (!Number.isFinite(edgeThreshold) || edgeThreshold < 0 || edgeThreshold > 1) {
1910
+ throw new Error("FXAA edgeThreshold must be finite and in [0, 1].");
1911
+ }
1912
+ if (!Number.isFinite(subpixelBlend) || subpixelBlend < 0 || subpixelBlend > 1) {
1913
+ throw new Error("FXAA subpixelBlend must be finite and in [0, 1].");
1914
+ }
1915
+ }
1916
+
1917
+ function normalizeColorGradeOptions(options: ColorGradeOptions): Required<ColorGradeOptions> {
1918
+ const settings = {
1919
+ contrast: options.contrast ?? 1,
1920
+ temperature: options.temperature ?? 0,
1921
+ tint: options.tint ?? 0,
1922
+ saturation: options.saturation ?? 1,
1923
+ vibrance: options.vibrance ?? 0,
1924
+ vignette: options.vignette ?? 0,
1925
+ sharpening: options.sharpening ?? 0
1926
+ };
1927
+ validateRange(settings.contrast, 0, 3, "Color grading contrast");
1928
+ validateRange(settings.temperature, -1, 1, "Color grading temperature");
1929
+ validateRange(settings.tint, -1, 1, "Color grading tint");
1930
+ validateRange(settings.saturation, 0, 3, "Color grading saturation");
1931
+ validateRange(settings.vibrance, -1, 1, "Color grading vibrance");
1932
+ validateRange(settings.vignette, 0, 1, "Color grading vignette");
1933
+ validateRange(settings.sharpening, 0, 2, "Color grading sharpening");
1934
+ return settings;
1935
+ }
1936
+
1937
+ function normalizeFXAAOptions(options: FXAAOptions): Required<FXAAOptions> {
1938
+ const settings = {
1939
+ edgeThreshold: options.edgeThreshold ?? 0.125,
1940
+ subpixelBlend: options.subpixelBlend ?? 0.75
1941
+ };
1942
+ validateFXAAOptions(settings.edgeThreshold, settings.subpixelBlend);
1943
+ return settings;
1944
+ }
1945
+
1946
+ function acquireFusedLdrBuffer(scratch: FusedLdrPostProcessScratch | undefined, byteLength: number, slot: 0 | 1): Uint8Array {
1947
+ if (!scratch) return new Uint8Array(byteLength);
1948
+ if (slot === 0) {
1949
+ if (!scratch.bufferA || scratch.bufferA.byteLength !== byteLength) {
1950
+ scratch.bufferA = new Uint8Array(byteLength);
1951
+ }
1952
+ return scratch.bufferA;
1953
+ }
1954
+ if (!scratch.bufferB || scratch.bufferB.byteLength !== byteLength) {
1955
+ scratch.bufferB = new Uint8Array(byteLength);
1956
+ }
1957
+ return scratch.bufferB;
1958
+ }
1959
+
1960
+ function getToneMappingLookup(options: ToneMappingOptions, scratch: FusedLdrPostProcessScratch | undefined): Uint8Array {
1961
+ const exposure = options.exposure ?? 1;
1962
+ const whitePoint = options.whitePoint ?? 1;
1963
+ const gamma = options.gamma ?? 2.2;
1964
+ const operator = options.operator ?? "reinhard";
1965
+ const inputColorSpace = options.inputColorSpace ?? "linear";
1966
+ const outputColorSpace = options.outputColorSpace ?? "linear";
1967
+ if (!Number.isFinite(exposure) || exposure < 0) {
1968
+ throw new Error("Tone mapping exposure must be finite and non-negative.");
1969
+ }
1970
+ if (!Number.isFinite(whitePoint) || whitePoint <= 0) {
1971
+ throw new Error("Tone mapping whitePoint must be finite and positive.");
1972
+ }
1973
+ if (!Number.isFinite(gamma) || gamma <= 0) {
1974
+ throw new Error("Tone mapping gamma must be finite and positive.");
1975
+ }
1976
+ const key = `${exposure}|${whitePoint}|${gamma}|${operator}|${inputColorSpace}|${outputColorSpace}`;
1977
+ if (scratch?.toneMappingLookup && scratch.toneMappingLookupKey === key) {
1978
+ return scratch.toneMappingLookup;
1979
+ }
1980
+ const lookup = scratch?.toneMappingLookup ?? new Uint8Array(256);
1981
+ for (let value = 0; value < 256; value += 1) {
1982
+ lookup[value] = encodeToneMappedChannel(decodeColorByte(value, inputColorSpace), exposure, whitePoint, gamma, operator, outputColorSpace);
1983
+ }
1984
+ if (scratch) {
1985
+ scratch.toneMappingLookup = lookup;
1986
+ scratch.toneMappingLookupKey = key;
1987
+ }
1988
+ return lookup;
1989
+ }
1990
+
1991
+ function getVignetteFactors(
1992
+ width: number,
1993
+ height: number,
1994
+ vignette: number,
1995
+ scratch: FusedLdrPostProcessScratch | undefined
1996
+ ): Float32Array {
1997
+ const key = `${width}x${height}|${vignette}`;
1998
+ if (scratch?.vignetteFactors && scratch.vignetteFactorsKey === key) {
1999
+ return scratch.vignetteFactors;
2000
+ }
2001
+ const factors = scratch?.vignetteFactors && scratch.vignetteFactors.length === width * height
2002
+ ? scratch.vignetteFactors
2003
+ : new Float32Array(width * height);
2004
+ for (let y = 0; y < height; y += 1) {
2005
+ const centerY = height <= 1 ? 0 : (y / (height - 1)) * 2 - 1;
2006
+ for (let x = 0; x < width; x += 1) {
2007
+ const centerX = width <= 1 ? 0 : (x / (width - 1)) * 2 - 1;
2008
+ factors[y * width + x] = 1 - vignette * Math.min(1, Math.max(0, Math.sqrt(centerX * centerX + centerY * centerY) - 0.28) / 1.12);
2009
+ }
2010
+ }
2011
+ if (scratch) {
2012
+ scratch.vignetteFactors = factors;
2013
+ scratch.vignetteFactorsKey = key;
2014
+ }
2015
+ return factors;
2016
+ }
2017
+
2018
+ function applyToneMappingAndColorGrade(
2019
+ input: Uint8Array,
2020
+ output: Uint8Array,
2021
+ width: number,
2022
+ height: number,
2023
+ toneMappingLookup: Uint8Array | undefined,
2024
+ colorGradeSettings: Required<ColorGradeOptions> | undefined,
2025
+ vignetteFactors: Float32Array | undefined
2026
+ ): void {
2027
+ const contrast = colorGradeSettings?.contrast ?? 1;
2028
+ const contrastOffset = 0.5 - 0.5 * contrast;
2029
+ const temperature = colorGradeSettings?.temperature ?? 0;
2030
+ const tint = colorGradeSettings?.tint ?? 0;
2031
+ const redShift = temperature * 0.08 - tint * 0.02;
2032
+ const greenShift = tint * 0.06;
2033
+ const blueShift = -temperature * 0.08 - tint * 0.02;
2034
+ const saturationBase = colorGradeSettings?.saturation ?? 1;
2035
+ const vibrance = colorGradeSettings?.vibrance ?? 0;
2036
+ const applyColorGrade = colorGradeSettings !== undefined;
2037
+
2038
+ for (let pixel = 0, index = 0; pixel < width * height; pixel += 1, index += 4) {
2039
+ const toneRed = toneMappingLookup ? toneMappingLookup[input[index]!]! : input[index]!;
2040
+ const toneGreen = toneMappingLookup ? toneMappingLookup[input[index + 1]!]! : input[index + 1]!;
2041
+ const toneBlue = toneMappingLookup ? toneMappingLookup[input[index + 2]!]! : input[index + 2]!;
2042
+ if (!applyColorGrade) {
2043
+ output[index] = toneRed;
2044
+ output[index + 1] = toneGreen;
2045
+ output[index + 2] = toneBlue;
2046
+ output[index + 3] = input[index + 3] ?? 255;
2047
+ continue;
2048
+ }
2049
+
2050
+ let red = toneRed / 255;
2051
+ let green = toneGreen / 255;
2052
+ let blue = toneBlue / 255;
2053
+ const luma = 0.2126 * red + 0.7152 * green + 0.0722 * blue;
2054
+ red = red * contrast + contrastOffset + redShift;
2055
+ green = green * contrast + contrastOffset + greenShift;
2056
+ blue = blue * contrast + contrastOffset + blueShift;
2057
+ const vibranceBoost = vibrance === 0
2058
+ ? 0
2059
+ : vibrance * (1 - Math.min(1, Math.abs(red - luma) + Math.abs(green - luma) + Math.abs(blue - luma)));
2060
+ const saturation = saturationBase + vibranceBoost;
2061
+ red = luma + (red - luma) * saturation;
2062
+ green = luma + (green - luma) * saturation;
2063
+ blue = luma + (blue - luma) * saturation;
2064
+ const vignette = vignetteFactors ? vignetteFactors[pixel]! : 1;
2065
+ output[index] = clampByteFast(red * vignette * 255);
2066
+ output[index + 1] = clampByteFast(green * vignette * 255);
2067
+ output[index + 2] = clampByteFast(blue * vignette * 255);
2068
+ output[index + 3] = input[index + 3] ?? 255;
2069
+ }
2070
+ }
2071
+
2072
+ function sharpenPixelsInto(input: Uint8Array, output: Uint8Array, width: number, height: number, amount: number): void {
2073
+ output.set(input);
2074
+ const rowStride = width * 4;
2075
+ for (let y = 1; y < height - 1; y += 1) {
2076
+ const rowOffset = y * rowStride;
2077
+ for (let x = 1; x < width - 1; x += 1) {
2078
+ const index = rowOffset + x * 4;
2079
+ for (let channel = 0; channel < 3; channel += 1) {
2080
+ const center = input[index + channel] ?? 0;
2081
+ const blur = (
2082
+ (input[index - 4 + channel] ?? 0) +
2083
+ (input[index + 4 + channel] ?? 0) +
2084
+ (input[index - rowStride + channel] ?? 0) +
2085
+ (input[index + rowStride + channel] ?? 0)
2086
+ ) / 4;
2087
+ output[index + channel] = clampByteFast(center + (center - blur) * amount);
2088
+ }
2089
+ }
2090
+ }
2091
+ }
2092
+
2093
+ function fxaaPixelsInto(
2094
+ input: Uint8Array,
2095
+ output: Uint8Array,
2096
+ width: number,
2097
+ height: number,
2098
+ edgeThreshold: number,
2099
+ subpixelBlend: number
2100
+ ): void {
2101
+ output.set(input);
2102
+ const rowStride = width * 4;
2103
+ for (let y = 0; y < height; y += 1) {
2104
+ const rowOffset = y * rowStride;
2105
+ const northOffset = y > 0 ? rowOffset - rowStride : rowOffset;
2106
+ const southOffset = y < height - 1 ? rowOffset + rowStride : rowOffset;
2107
+ for (let x = 0; x < width; x += 1) {
2108
+ const index = rowOffset + x * 4;
2109
+ const westIndex = x > 0 ? index - 4 : index;
2110
+ const eastIndex = x < width - 1 ? index + 4 : index;
2111
+ const northIndex = northOffset + x * 4;
2112
+ const southIndex = southOffset + x * 4;
2113
+ const centerLuma = lumaAtIndex(input, index);
2114
+ const northLuma = lumaAtIndex(input, northIndex);
2115
+ const southLuma = lumaAtIndex(input, southIndex);
2116
+ const westLuma = lumaAtIndex(input, westIndex);
2117
+ const eastLuma = lumaAtIndex(input, eastIndex);
2118
+ const minLuma = Math.min(centerLuma, northLuma, southLuma, westLuma, eastLuma);
2119
+ const maxLuma = Math.max(centerLuma, northLuma, southLuma, westLuma, eastLuma);
2120
+ if (maxLuma - minLuma < edgeThreshold) continue;
2121
+
2122
+ for (let channel = 0; channel < 3; channel += 1) {
2123
+ const average = (
2124
+ (input[northIndex + channel] ?? 0) +
2125
+ (input[southIndex + channel] ?? 0) +
2126
+ (input[westIndex + channel] ?? 0) +
2127
+ (input[eastIndex + channel] ?? 0)
2128
+ ) / 4;
2129
+ output[index + channel] = clampByteFast(input[index + channel]! * (1 - subpixelBlend) + average * subpixelBlend);
2130
+ }
2131
+ output[index + 3] = input[index + 3]!;
2132
+ }
2133
+ }
2134
+ }
2135
+
2136
+ function lumaAtIndex(pixels: Uint8Array, index: number): number {
2137
+ return (0.2126 * pixels[index]! + 0.7152 * pixels[index + 1]! + 0.0722 * pixels[index + 2]!) / 255;
2138
+ }
2139
+
2140
+ function clampByteFast(value: number): number {
2141
+ if (value <= 0) return 0;
2142
+ if (value >= 255) return 255;
2143
+ return Math.round(value);
2144
+ }
2145
+
2146
+ function validateBloomOptions(threshold: number, intensity: number, radius: number): void {
2147
+ if (!Number.isFinite(threshold) || threshold < 0 || threshold > 1) {
2148
+ throw new Error("Bloom threshold must be finite and in [0, 1].");
2149
+ }
2150
+ if (!Number.isFinite(intensity) || intensity < 0) {
2151
+ throw new Error("Bloom intensity must be finite and non-negative.");
2152
+ }
2153
+ validateBloomBlurRadius(radius);
2154
+ }
2155
+
2156
+ function validateBloomBlurRadius(radius: number): void {
2157
+ if (!Number.isInteger(radius) || radius < 0 || radius > 16) {
2158
+ throw new Error("Bloom radius must be an integer in [0, 16].");
2159
+ }
2160
+ }
2161
+
2162
+ function validateOutlineColor(color: readonly [number, number, number, number?]): void {
2163
+ for (let index = 0; index < color.length; index += 1) {
2164
+ const channel = color[index] ?? 0;
2165
+ if (!Number.isFinite(channel) || channel < 0 || channel > 255) {
2166
+ throw new Error(`Outline color channel ${index} must be finite and within [0, 255].`);
2167
+ }
2168
+ }
2169
+ }
2170
+
2171
+ function sobelLumaGradient(pixels: Uint8Array, width: number, height: number, x: number, y: number): number {
2172
+ const nw = lumaAt(pixels, width, height, x - 1, y - 1);
2173
+ const n = lumaAt(pixels, width, height, x, y - 1);
2174
+ const ne = lumaAt(pixels, width, height, x + 1, y - 1);
2175
+ const w = lumaAt(pixels, width, height, x - 1, y);
2176
+ const e = lumaAt(pixels, width, height, x + 1, y);
2177
+ const sw = lumaAt(pixels, width, height, x - 1, y + 1);
2178
+ const s = lumaAt(pixels, width, height, x, y + 1);
2179
+ const se = lumaAt(pixels, width, height, x + 1, y + 1);
2180
+ const gx = -nw - 2 * w - sw + ne + 2 * e + se;
2181
+ const gy = -nw - 2 * n - ne + sw + 2 * s + se;
2182
+ return Math.hypot(gx, gy);
2183
+ }
2184
+
2185
+ function dilateMask(mask: Uint8Array, width: number, height: number, radius: number): Uint8Array {
2186
+ const output = new Uint8Array(mask.length);
2187
+ for (let y = 0; y < height; y += 1) {
2188
+ for (let x = 0; x < width; x += 1) {
2189
+ let outlined = false;
2190
+ for (let offsetY = -radius; offsetY <= radius && !outlined; offsetY += 1) {
2191
+ for (let offsetX = -radius; offsetX <= radius; offsetX += 1) {
2192
+ if (Math.hypot(offsetX, offsetY) > radius + 0.01) continue;
2193
+ const sampleX = clampInt(x + offsetX, 0, width - 1);
2194
+ const sampleY = clampInt(y + offsetY, 0, height - 1);
2195
+ if (mask[sampleY * width + sampleX] !== 0) {
2196
+ outlined = true;
2197
+ break;
2198
+ }
2199
+ }
2200
+ }
2201
+ if (outlined) output[y * width + x] = 255;
2202
+ }
2203
+ }
2204
+ return output;
2205
+ }
2206
+
2207
+ export function writePostProcessPixels(device: RenderDevice, source: RenderTarget, target: RenderTarget | undefined, pixels: Uint8Array): void {
2208
+ if (!target) {
2209
+ if (!device.presentRenderTarget) {
2210
+ throw new RenderDeviceError("Post-process presentation requires a render device with presentRenderTarget support", "POSTPROCESS_PRESENT_UNSUPPORTED", {
2211
+ source: source.label
2212
+ });
2213
+ }
2214
+ const presentationTarget = device.createRenderTarget({
2215
+ width: source.width,
2216
+ height: source.height,
2217
+ label: `${source.label}-postprocess-present`,
2218
+ format: "rgba8",
2219
+ depth: false
2220
+ });
2221
+ try {
2222
+ if (!device.writeRenderTargetPixels) {
2223
+ throw new RenderDeviceError("Post-process presentation requires a render device with writeRenderTargetPixels support", "POSTPROCESS_WRITE_UNSUPPORTED", {
2224
+ source: source.label
2225
+ });
2226
+ }
2227
+ device.writeRenderTargetPixels(presentationTarget, pixels);
2228
+ device.presentRenderTarget(presentationTarget);
2229
+ } finally {
2230
+ presentationTarget.dispose();
2231
+ }
2232
+ return;
2233
+ }
2234
+ if (target.width !== source.width || target.height !== source.height) {
2235
+ throw new Error("Post-process source and target dimensions must match.");
2236
+ }
2237
+ if (device.writeRenderTargetPixels) {
2238
+ device.writeRenderTargetPixels(target, pixels);
2239
+ } else {
2240
+ const writable = target as RenderTarget & { readonly colorPixels?: Uint8Array };
2241
+ if (writable.colorPixels) {
2242
+ writable.colorPixels.set(pixels);
2243
+ } else {
2244
+ throw new RenderDeviceError("Post-process target does not support byte pixel writes", "POSTPROCESS_WRITE_UNSUPPORTED", {
2245
+ target: target.label
2246
+ });
2247
+ }
2248
+ }
2249
+ device.setRenderTarget(target);
2250
+ }
2251
+
2252
+ function writeDepthTarget(target: RenderTarget | undefined, width: number, height: number, pixels: Uint8Array): void {
2253
+ if (!target) return;
2254
+ if (target.width !== width || target.height !== height) {
2255
+ throw new Error("Depth visualization target dimensions must match source depth texture.");
2256
+ }
2257
+ const writable = target as RenderTarget & { readonly colorPixels?: Uint8Array };
2258
+ if (writable.colorPixels) {
2259
+ writable.colorPixels.set(pixels);
2260
+ }
2261
+ }
2262
+
2263
+ function writeRenderTarget(device: RenderDevice, source: RenderTarget, target: RenderTarget | undefined, pixels: Uint8Array): void {
2264
+ writePostProcessPixels(device, source, target, pixels);
2265
+ }
2266
+
2267
+ function encodeToneMappedChannel(
2268
+ value: number,
2269
+ exposure: number,
2270
+ whitePoint: number,
2271
+ gamma: number,
2272
+ operator: ToneMappingOperator,
2273
+ outputColorSpace: PostProcessColorSpace
2274
+ ): number {
2275
+ return encodeColorByte(applyToneMapping(value, exposure, whitePoint, operator), gamma, outputColorSpace);
2276
+ }
2277
+
2278
+ function finiteHdrChannel(value: number, index: number): number {
2279
+ if (!Number.isFinite(value)) {
2280
+ throw new Error(`HDR tone mapping input contains non-finite float value at channel ${index}.`);
2281
+ }
2282
+ return Math.max(0, value);
2283
+ }
2284
+
2285
+ function applyToneMapping(value: number, exposure: number, whitePoint: number, operator: ToneMappingOperator): number {
2286
+ const exposed = Math.max(0, value * exposure) / whitePoint;
2287
+ return operator === "linear"
2288
+ ? Math.min(1, exposed)
2289
+ : operator === "reinhard"
2290
+ ? exposed / (1 + exposed)
2291
+ : operator === "aces"
2292
+ ? aces(exposed)
2293
+ : operator === "filmic"
2294
+ ? filmic(exposed)
2295
+ : operator === "uncharted2"
2296
+ ? uncharted2(exposed)
2297
+ : operator === "agx"
2298
+ ? agx(exposed)
2299
+ : neutral(exposed);
2300
+ }
2301
+
2302
+ function decodeColorByte(value: number, colorSpace: PostProcessColorSpace): number {
2303
+ const normalized = Math.max(0, Math.min(1, value / 255));
2304
+ if (colorSpace === "linear") return normalized;
2305
+ if (normalized <= 0.04045) return normalized / 12.92;
2306
+ return Math.pow((normalized + 0.055) / 1.055, 2.4);
2307
+ }
2308
+
2309
+ function encodeColorByte(value: number, gamma: number, colorSpace: PostProcessColorSpace): number {
2310
+ const linear = Math.max(0, Math.min(1, value));
2311
+ if (colorSpace === "linear") {
2312
+ return clampByte(linear * 255);
2313
+ }
2314
+ const encoded = linear <= 0.0031308
2315
+ ? linear * 12.92
2316
+ : 1.055 * Math.pow(linear, 1 / 2.4) - 0.055;
2317
+ return clampByte(encoded * 255);
2318
+ }
2319
+
2320
+ function aces(value: number): number {
2321
+ return (value * (2.51 * value + 0.03)) / (value * (2.43 * value + 0.59) + 0.14);
2322
+ }
2323
+
2324
+ function filmic(value: number): number {
2325
+ const x = Math.max(0, value);
2326
+ const toe = Math.max(0, x - 0.004);
2327
+ const curve = (toe * (6.2 * toe + 0.5)) / (toe * (6.2 * toe + 1.7) + 0.06);
2328
+ return Math.min(curve, x * 1.08);
2329
+ }
2330
+
2331
+ function uncharted2(value: number): number {
2332
+ const a = 0.15;
2333
+ const b = 0.5;
2334
+ const c = 0.1;
2335
+ const d = 0.2;
2336
+ const e = 0.02;
2337
+ const f = 0.3;
2338
+ const w = 11.2;
2339
+ const curve = (x: number) => ((x * (a * x + c * b) + d * e) / (x * (a * x + b) + d * f)) - e / f;
2340
+ return Math.max(0, Math.min(1, curve(value * 2) / curve(w)));
2341
+ }
2342
+
2343
+ function agx(value: number): number {
2344
+ const x = Math.max(0, value);
2345
+ const logEncoded = Math.log2(1 + x) / Math.log2(1 + 16);
2346
+ const shaped = logEncoded * logEncoded * (3 - 2 * logEncoded);
2347
+ return Math.max(0, Math.min(1, shaped));
2348
+ }
2349
+
2350
+ function neutral(value: number): number {
2351
+ const x = Math.max(0, value);
2352
+ return Math.min(1, (x * (1 + x / 7.5)) / (1 + x));
2353
+ }
2354
+
2355
+ function createToneMappingPreset(
2356
+ name: ToneMappingPresetName,
2357
+ label: string,
2358
+ options: Partial<ToneMappingOptions & ColorGradeOptions> & {
2359
+ readonly autoExposure: boolean;
2360
+ readonly adaptationSpeed?: number;
2361
+ readonly minExposure?: number;
2362
+ readonly maxExposure?: number;
2363
+ }
2364
+ ): ToneMappingPreset {
2365
+ return {
2366
+ name,
2367
+ label,
2368
+ toneMapping: {
2369
+ exposure: options.exposure ?? 1,
2370
+ whitePoint: options.whitePoint ?? 1,
2371
+ gamma: options.gamma ?? 2.2,
2372
+ operator: options.operator ?? "reinhard",
2373
+ inputColorSpace: options.inputColorSpace ?? "linear",
2374
+ outputColorSpace: options.outputColorSpace ?? "linear"
2375
+ },
2376
+ colorGrade: {
2377
+ contrast: options.contrast ?? 1,
2378
+ temperature: options.temperature ?? 0,
2379
+ tint: options.tint ?? 0,
2380
+ saturation: options.saturation ?? 1,
2381
+ vibrance: options.vibrance ?? 0,
2382
+ vignette: options.vignette ?? 0,
2383
+ sharpening: options.sharpening ?? 0
2384
+ },
2385
+ autoExposure: options.autoExposure,
2386
+ adaptationSpeed: options.adaptationSpeed ?? 0.5,
2387
+ minExposure: options.minExposure ?? 0.1,
2388
+ maxExposure: options.maxExposure ?? 10
2389
+ };
2390
+ }
2391
+
2392
+ function validateHistogramOptions(binCount: number, minLuminance: number, maxLuminance: number): void {
2393
+ if (!Number.isInteger(binCount) || binCount < 4 || binCount > 1024) {
2394
+ throw new Error("Exposure histogram binCount must be an integer in [4, 1024].");
2395
+ }
2396
+ validateRange(minLuminance, 0.000001, 128, "Exposure histogram minLuminance");
2397
+ validateRange(maxLuminance, minLuminance, 1024, "Exposure histogram maxLuminance");
2398
+ }
2399
+
2400
+ function histogramAverageFromBins(histogram: ExposureHistogram): number {
2401
+ const logMin = Math.log2(histogram.minLuminance);
2402
+ const logMax = Math.log2(histogram.maxLuminance);
2403
+ let weighted = 0;
2404
+ let count = 0;
2405
+ for (let index = 0; index < histogram.binCount; index += 1) {
2406
+ const binValue = histogram.bins[index] ?? 0;
2407
+ const t = histogram.binCount <= 1 ? 0 : index / (histogram.binCount - 1);
2408
+ const luminance = Math.pow(2, logMin + (logMax - logMin) * t);
2409
+ weighted += luminance * binValue;
2410
+ count += binValue;
2411
+ }
2412
+ return count > 0 ? weighted / count : 0.18;
2413
+ }
2414
+
2415
+ function noise2d(x: number, y: number, seed: number): number {
2416
+ let value = (x + 1) * 374761393 + (y + 1) * 668265263 + seed * 2147483647;
2417
+ value = (value ^ (value >>> 13)) * 1274126177;
2418
+ return ((value ^ (value >>> 16)) >>> 0) / 0xffffffff;
2419
+ }
2420
+
2421
+ function sharpenPixels(pixels: Uint8Array, width: number, height: number, amount: number): { readonly pixels: Uint8Array; readonly sharpenedPixels: number } {
2422
+ const output = new Uint8Array(pixels);
2423
+ let sharpenedPixels = 0;
2424
+ for (let y = 1; y < height - 1; y += 1) {
2425
+ for (let x = 1; x < width - 1; x += 1) {
2426
+ const index = (y * width + x) * 4;
2427
+ for (let channel = 0; channel < 3; channel += 1) {
2428
+ const center = pixels[index + channel] ?? 0;
2429
+ const blur = (
2430
+ (pixels[index - 4 + channel] ?? 0) +
2431
+ (pixels[index + 4 + channel] ?? 0) +
2432
+ (pixels[index - width * 4 + channel] ?? 0) +
2433
+ (pixels[index + width * 4 + channel] ?? 0)
2434
+ ) / 4;
2435
+ output[index + channel] = clampByte(center + (center - blur) * amount);
2436
+ }
2437
+ if (Math.abs(output[index]! - (pixels[index] ?? 0)) + Math.abs(output[index + 1]! - (pixels[index + 1] ?? 0)) + Math.abs(output[index + 2]! - (pixels[index + 2] ?? 0)) > 3) {
2438
+ sharpenedPixels += 1;
2439
+ }
2440
+ }
2441
+ }
2442
+ return { pixels: output, sharpenedPixels };
2443
+ }
2444
+
2445
+ function countChangedRgb(before: Uint8Array, after: Uint8Array): number {
2446
+ let count = 0;
2447
+ for (let index = 0; index < before.length; index += 4) {
2448
+ if (Math.abs((before[index] ?? 0) - (after[index] ?? 0)) + Math.abs((before[index + 1] ?? 0) - (after[index + 1] ?? 0)) + Math.abs((before[index + 2] ?? 0) - (after[index + 2] ?? 0)) > 3) count += 1;
2449
+ }
2450
+ return count;
2451
+ }
2452
+
2453
+ function validateRange(value: number, min: number, max: number, label: string): void {
2454
+ if (!Number.isFinite(value) || value < min || value > max) {
2455
+ throw new Error(`${label} must be finite and within [${min}, ${max}].`);
2456
+ }
2457
+ }
2458
+
2459
+ function clampByte(value: number): number {
2460
+ return Math.round(Math.max(0, Math.min(255, value)));
2461
+ }
2462
+
2463
+ function clampInt(value: number, min: number, max: number): number {
2464
+ return Math.min(max, Math.max(min, value));
2465
+ }
2466
+
2467
+ function lumaAt(pixels: Uint8Array, width: number, height: number, x: number, y: number): number {
2468
+ const sampleX = clampInt(x, 0, width - 1);
2469
+ const sampleY = clampInt(y, 0, height - 1);
2470
+ const index = (sampleY * width + sampleX) * 4;
2471
+ return (0.2126 * pixels[index]! + 0.7152 * pixels[index + 1]! + 0.0722 * pixels[index + 2]!) / 255;
2472
+ }
2473
+
2474
+ function channelAt(pixels: Uint8Array, width: number, height: number, x: number, y: number, channel: number): number {
2475
+ const sampleX = clampInt(x, 0, width - 1);
2476
+ const sampleY = clampInt(y, 0, height - 1);
2477
+ return pixels[(sampleY * width + sampleX) * 4 + channel]!;
2478
+ }
2479
+
2480
+ function normalizeContactShadowDirection(direction: readonly [number, number]): readonly [number, number] {
2481
+ const [x, y] = direction;
2482
+ if (!Number.isFinite(x) || !Number.isFinite(y)) {
2483
+ throw new Error("Contact shadow direction must contain finite x/y values.");
2484
+ }
2485
+ const length = Math.hypot(x, y);
2486
+ if (length < 0.0001) {
2487
+ throw new Error("Contact shadow direction must not be zero length.");
2488
+ }
2489
+ return [x / length, y / length];
2490
+ }
2491
+
2492
+ function depthAt(texture: DepthTextureBinding, x: number, y: number): number {
2493
+ const sampleX = clampInt(x, 0, texture.width - 1);
2494
+ const sampleY = clampInt(y, 0, texture.height - 1);
2495
+ return texture.data[sampleY * texture.width + sampleX]!;
2496
+ }
2497
+
2498
+ function isDepthEdge(texture: DepthTextureBinding, x: number, y: number, edgeThreshold: number): boolean {
2499
+ const center = depthAt(texture, x, y);
2500
+ const delta = Math.max(
2501
+ Math.abs(center - depthAt(texture, x + 1, y)),
2502
+ Math.abs(center - depthAt(texture, x - 1, y)),
2503
+ Math.abs(center - depthAt(texture, x, y + 1)),
2504
+ Math.abs(center - depthAt(texture, x, y - 1))
2505
+ );
2506
+ return delta >= edgeThreshold;
2507
+ }