@aura3d/engine 1.4.4 → 1.5.0

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 (487) hide show
  1. package/README.md +65 -30
  2. package/dist/animation/Retargeting.d.ts +12 -0
  3. package/dist/animation/Retargeting.d.ts.map +1 -0
  4. package/dist/animation/Retargeting.js +19 -0
  5. package/dist/animation/Retargeting.js.map +1 -0
  6. package/dist/assets/GLTFLoader.d.ts +4 -0
  7. package/dist/assets/GLTFLoader.d.ts.map +1 -1
  8. package/dist/assets/GLTFLoader.js +39 -4
  9. package/dist/assets/GLTFLoader.js.map +1 -1
  10. package/dist/assets/GLTFRenderResources.d.ts +16 -0
  11. package/dist/assets/GLTFRenderResources.d.ts.map +1 -1
  12. package/dist/assets/GLTFRenderResources.js +42 -2
  13. package/dist/assets/GLTFRenderResources.js.map +1 -1
  14. package/dist/assets/asset-corpus/ProductionGLTFRenderPipeline.d.ts +6 -0
  15. package/dist/assets/asset-corpus/ProductionGLTFRenderPipeline.d.ts.map +1 -1
  16. package/dist/assets/asset-corpus/ProductionGLTFRenderPipeline.js +2 -1
  17. package/dist/assets/asset-corpus/ProductionGLTFRenderPipeline.js.map +1 -1
  18. package/dist/assets/index.d.ts +0 -1
  19. package/dist/assets/index.d.ts.map +1 -1
  20. package/dist/assets/index.js +0 -1
  21. package/dist/assets/index.js.map +1 -1
  22. package/dist/assets/loaders/index.d.ts +0 -1
  23. package/dist/assets/loaders/index.d.ts.map +1 -1
  24. package/dist/assets/loaders/index.js +0 -1
  25. package/dist/assets/loaders/index.js.map +1 -1
  26. package/dist/aura3d-cli/asset-intent.d.ts +148 -0
  27. package/dist/aura3d-cli/asset-intent.d.ts.map +1 -0
  28. package/dist/aura3d-cli/asset-intent.js +145 -0
  29. package/dist/aura3d-cli/asset-intent.js.map +1 -0
  30. package/dist/aura3d-cli/asset-role-admission.d.ts +174 -0
  31. package/dist/aura3d-cli/asset-role-admission.d.ts.map +1 -0
  32. package/dist/aura3d-cli/asset-role-admission.js +381 -0
  33. package/dist/aura3d-cli/asset-role-admission.js.map +1 -0
  34. package/dist/aura3d-cli/asset-screening-effects.d.ts +95 -0
  35. package/dist/aura3d-cli/asset-screening-effects.d.ts.map +1 -0
  36. package/dist/aura3d-cli/asset-screening-effects.js +321 -0
  37. package/dist/aura3d-cli/asset-screening-effects.js.map +1 -0
  38. package/dist/aura3d-cli/asset-screening-pipeline.d.ts +132 -0
  39. package/dist/aura3d-cli/asset-screening-pipeline.d.ts.map +1 -0
  40. package/dist/aura3d-cli/asset-screening-pipeline.js +277 -0
  41. package/dist/aura3d-cli/asset-screening-pipeline.js.map +1 -0
  42. package/dist/aura3d-cli/cartoon-asset-profiles.d.ts +15 -0
  43. package/dist/aura3d-cli/cartoon-asset-profiles.d.ts.map +1 -0
  44. package/dist/aura3d-cli/cartoon-asset-profiles.js +46 -0
  45. package/dist/aura3d-cli/cartoon-asset-profiles.js.map +1 -0
  46. package/dist/aura3d-cli/cli-help.js +1 -1
  47. package/dist/aura3d-cli/cli.js +16 -2
  48. package/dist/aura3d-cli/cli.js.map +1 -1
  49. package/dist/aura3d-cli/index.d.ts +8 -0
  50. package/dist/aura3d-cli/index.d.ts.map +1 -1
  51. package/dist/aura3d-cli/index.js +390 -17
  52. package/dist/aura3d-cli/index.js.map +1 -1
  53. package/dist/aura3d-cli/pull-bridge/search.d.ts +4 -0
  54. package/dist/aura3d-cli/pull-bridge/search.d.ts.map +1 -1
  55. package/dist/aura3d-cli/pull-bridge/search.js +22 -0
  56. package/dist/aura3d-cli/pull-bridge/search.js.map +1 -1
  57. package/dist/aura3d-cli/pull-bridge.d.ts +20 -5
  58. package/dist/aura3d-cli/pull-bridge.d.ts.map +1 -1
  59. package/dist/aura3d-cli/pull-bridge.js +38 -1
  60. package/dist/aura3d-cli/pull-bridge.js.map +1 -1
  61. package/dist/controls/ControlState.d.ts +1 -1
  62. package/dist/controls/ControlState.d.ts.map +1 -1
  63. package/dist/controls/DragControls.d.ts +21 -1
  64. package/dist/controls/DragControls.d.ts.map +1 -1
  65. package/dist/controls/DragControls.js +24 -2
  66. package/dist/controls/DragControls.js.map +1 -1
  67. package/dist/controls/FirstPersonControls.d.ts +10 -1
  68. package/dist/controls/FirstPersonControls.d.ts.map +1 -1
  69. package/dist/controls/FirstPersonControls.js +18 -2
  70. package/dist/controls/FirstPersonControls.js.map +1 -1
  71. package/dist/controls/FlyControls.d.ts +42 -0
  72. package/dist/controls/FlyControls.d.ts.map +1 -1
  73. package/dist/controls/FlyControls.js +106 -3
  74. package/dist/controls/FlyControls.js.map +1 -1
  75. package/dist/controls/MapControls.d.ts +13 -0
  76. package/dist/controls/MapControls.d.ts.map +1 -1
  77. package/dist/controls/MapControls.js +40 -2
  78. package/dist/controls/MapControls.js.map +1 -1
  79. package/dist/controls/OrbitControls.d.ts +54 -0
  80. package/dist/controls/OrbitControls.d.ts.map +1 -1
  81. package/dist/controls/OrbitControls.js +133 -0
  82. package/dist/controls/OrbitControls.js.map +1 -1
  83. package/dist/controls/PointerLockControls.d.ts +12 -5
  84. package/dist/controls/PointerLockControls.d.ts.map +1 -1
  85. package/dist/controls/PointerLockControls.js +30 -11
  86. package/dist/controls/PointerLockControls.js.map +1 -1
  87. package/dist/controls/SelectionManager.d.ts +22 -1
  88. package/dist/controls/SelectionManager.d.ts.map +1 -1
  89. package/dist/controls/SelectionManager.js +64 -6
  90. package/dist/controls/SelectionManager.js.map +1 -1
  91. package/dist/controls/TransformControls.d.ts +135 -1
  92. package/dist/controls/TransformControls.d.ts.map +1 -1
  93. package/dist/controls/TransformControls.js +534 -10
  94. package/dist/controls/TransformControls.js.map +1 -1
  95. package/dist/controls/index.d.ts +7 -2
  96. package/dist/controls/index.d.ts.map +1 -1
  97. package/dist/controls/index.js +1 -1
  98. package/dist/controls/index.js.map +1 -1
  99. package/dist/create-aura3d/index.js +1 -1
  100. package/dist/create-aura3d/showcase-spec-game-geometry-extractor.d.ts +2 -0
  101. package/dist/create-aura3d/showcase-spec-game-geometry-extractor.d.ts.map +1 -1
  102. package/dist/create-aura3d/showcase-spec-game-geometry-extractor.js +781 -46
  103. package/dist/create-aura3d/showcase-spec-game-geometry-extractor.js.map +1 -1
  104. package/dist/create-aura3d/showcase-spec-game-template-evidence.d.ts.map +1 -1
  105. package/dist/create-aura3d/showcase-spec-game-template-evidence.js +24 -4
  106. package/dist/create-aura3d/showcase-spec-game-template-evidence.js.map +1 -1
  107. package/dist/create-aura3d/showcase-spec-platformer-artifacts.d.ts.map +1 -1
  108. package/dist/create-aura3d/showcase-spec-platformer-artifacts.js +28 -17
  109. package/dist/create-aura3d/showcase-spec-platformer-artifacts.js.map +1 -1
  110. package/dist/create-aura3d/showcase-spec-racing-artifacts.d.ts.map +1 -1
  111. package/dist/create-aura3d/showcase-spec-racing-artifacts.js +10 -5
  112. package/dist/create-aura3d/showcase-spec-racing-artifacts.js.map +1 -1
  113. package/dist/create-aura3d/showcase-spec-replacement-candidates.js +26 -0
  114. package/dist/create-aura3d/showcase-spec-replacement-candidates.js.map +1 -1
  115. package/dist/ecs/components/MeshComponent.d.ts +5 -2
  116. package/dist/ecs/components/MeshComponent.d.ts.map +1 -1
  117. package/dist/ecs/components/MeshComponent.js.map +1 -1
  118. package/dist/editor-runtime/CartoonSceneEditor.d.ts +111 -0
  119. package/dist/editor-runtime/CartoonSceneEditor.d.ts.map +1 -0
  120. package/dist/editor-runtime/CartoonSceneEditor.js +285 -0
  121. package/dist/editor-runtime/CartoonSceneEditor.js.map +1 -0
  122. package/dist/editor-runtime/InteractiveTransformGizmo.d.ts +142 -0
  123. package/dist/editor-runtime/InteractiveTransformGizmo.d.ts.map +1 -0
  124. package/dist/editor-runtime/InteractiveTransformGizmo.js +468 -0
  125. package/dist/editor-runtime/InteractiveTransformGizmo.js.map +1 -0
  126. package/dist/editor-runtime/index.d.ts +2 -0
  127. package/dist/editor-runtime/index.d.ts.map +1 -1
  128. package/dist/editor-runtime/index.js +1 -0
  129. package/dist/editor-runtime/index.js.map +1 -1
  130. package/dist/engine/agent-api/CartoonAssetManifest.d.ts +50 -0
  131. package/dist/engine/agent-api/CartoonAssetManifest.d.ts.map +1 -0
  132. package/dist/engine/agent-api/CartoonAssetManifest.js +65 -0
  133. package/dist/engine/agent-api/CartoonAssetManifest.js.map +1 -0
  134. package/dist/engine/agent-api/CartoonDirector.d.ts +120 -0
  135. package/dist/engine/agent-api/CartoonDirector.d.ts.map +1 -0
  136. package/dist/engine/agent-api/CartoonDirector.js +432 -0
  137. package/dist/engine/agent-api/CartoonDirector.js.map +1 -0
  138. package/dist/engine/agent-api/CartoonEpisodePackage.d.ts +51 -0
  139. package/dist/engine/agent-api/CartoonEpisodePackage.d.ts.map +1 -0
  140. package/dist/engine/agent-api/CartoonEpisodePackage.js +79 -0
  141. package/dist/engine/agent-api/CartoonEpisodePackage.js.map +1 -0
  142. package/dist/engine/agent-api/CartoonMotionQuality.d.ts +83 -0
  143. package/dist/engine/agent-api/CartoonMotionQuality.d.ts.map +1 -0
  144. package/dist/engine/agent-api/CartoonMotionQuality.js +128 -0
  145. package/dist/engine/agent-api/CartoonMotionQuality.js.map +1 -0
  146. package/dist/engine/agent-api/CartoonPerformance.d.ts +150 -0
  147. package/dist/engine/agent-api/CartoonPerformance.d.ts.map +1 -0
  148. package/dist/engine/agent-api/CartoonPerformance.js +345 -0
  149. package/dist/engine/agent-api/CartoonPerformance.js.map +1 -0
  150. package/dist/engine/agent-api/CartoonRenderQueue.d.ts +143 -0
  151. package/dist/engine/agent-api/CartoonRenderQueue.d.ts.map +1 -0
  152. package/dist/engine/agent-api/CartoonRenderQueue.js +410 -0
  153. package/dist/engine/agent-api/CartoonRenderQueue.js.map +1 -0
  154. package/dist/engine/agent-api/CartoonRouteProof.d.ts +112 -0
  155. package/dist/engine/agent-api/CartoonRouteProof.d.ts.map +1 -0
  156. package/dist/engine/agent-api/CartoonRouteProof.js +127 -0
  157. package/dist/engine/agent-api/CartoonRouteProof.js.map +1 -0
  158. package/dist/engine/agent-api/GameEvidence.d.ts +1 -0
  159. package/dist/engine/agent-api/GameEvidence.d.ts.map +1 -1
  160. package/dist/engine/agent-api/GameEvidence.js +1 -0
  161. package/dist/engine/agent-api/GameEvidence.js.map +1 -1
  162. package/dist/engine/agent-api/GameGenreKits.d.ts +13 -0
  163. package/dist/engine/agent-api/GameGenreKits.d.ts.map +1 -1
  164. package/dist/engine/agent-api/GameGenreKits.js +57 -11
  165. package/dist/engine/agent-api/GameGenreKits.js.map +1 -1
  166. package/dist/engine/agent-api/GameRuntime.d.ts +1 -0
  167. package/dist/engine/agent-api/GameRuntime.d.ts.map +1 -1
  168. package/dist/engine/agent-api/GameRuntime.js +1 -0
  169. package/dist/engine/agent-api/GameRuntime.js.map +1 -1
  170. package/dist/engine/agent-api/GameSceneGeometryBindings.d.ts +12 -0
  171. package/dist/engine/agent-api/GameSceneGeometryBindings.d.ts.map +1 -1
  172. package/dist/engine/agent-api/GameSceneGeometryBindings.js +2 -0
  173. package/dist/engine/agent-api/GameSceneGeometryBindings.js.map +1 -1
  174. package/dist/engine/agent-api/LayeredSceneComposition.d.ts +295 -0
  175. package/dist/engine/agent-api/LayeredSceneComposition.d.ts.map +1 -0
  176. package/dist/engine/agent-api/LayeredSceneComposition.js +387 -0
  177. package/dist/engine/agent-api/LayeredSceneComposition.js.map +1 -0
  178. package/dist/engine/agent-api/SceneGroundingUtils.d.ts +62 -0
  179. package/dist/engine/agent-api/SceneGroundingUtils.d.ts.map +1 -1
  180. package/dist/engine/agent-api/SceneGroundingUtils.js +37 -0
  181. package/dist/engine/agent-api/SceneGroundingUtils.js.map +1 -1
  182. package/dist/engine/agent-api/SubjectFramingUtils.d.ts +127 -0
  183. package/dist/engine/agent-api/SubjectFramingUtils.d.ts.map +1 -0
  184. package/dist/engine/agent-api/SubjectFramingUtils.js +126 -0
  185. package/dist/engine/agent-api/SubjectFramingUtils.js.map +1 -0
  186. package/dist/engine/agent-api/TouchControlBinding.d.ts +81 -0
  187. package/dist/engine/agent-api/TouchControlBinding.d.ts.map +1 -0
  188. package/dist/engine/agent-api/TouchControlBinding.js +116 -0
  189. package/dist/engine/agent-api/TouchControlBinding.js.map +1 -0
  190. package/dist/engine/agent-api/index.d.ts +39 -0
  191. package/dist/engine/agent-api/index.d.ts.map +1 -1
  192. package/dist/engine/agent-api/index.js +546 -74
  193. package/dist/engine/agent-api/index.js.map +1 -1
  194. package/dist/engine/agent-api/product-viewer-runtime.d.ts.map +1 -1
  195. package/dist/engine/production-runtime/GameRenderPreset.d.ts +32 -0
  196. package/dist/engine/production-runtime/GameRenderPreset.d.ts.map +1 -1
  197. package/dist/engine/production-runtime/GameRenderPreset.js +37 -2
  198. package/dist/engine/production-runtime/GameRenderPreset.js.map +1 -1
  199. package/dist/engine/production-runtime/TypedGLBActor.d.ts +8 -0
  200. package/dist/engine/production-runtime/TypedGLBActor.d.ts.map +1 -1
  201. package/dist/engine/production-runtime/TypedGLBActor.js +2 -1
  202. package/dist/engine/production-runtime/TypedGLBActor.js.map +1 -1
  203. package/dist/input/controls/PointerLockControls.d.ts +1 -1
  204. package/dist/input/controls/PointerLockControls.d.ts.map +1 -1
  205. package/dist/input/controls/PointerLockControls.js +12 -0
  206. package/dist/input/controls/PointerLockControls.js.map +1 -1
  207. package/dist/physics/Collider.d.ts +1 -1
  208. package/dist/physics/Collider.d.ts.map +1 -1
  209. package/dist/physics/Collider.js +2 -2
  210. package/dist/physics/Collider.js.map +1 -1
  211. package/dist/physics/CollisionEvents.d.ts +1 -0
  212. package/dist/physics/CollisionEvents.d.ts.map +1 -1
  213. package/dist/physics/CollisionEvents.js.map +1 -1
  214. package/dist/physics/NarrowPhase.d.ts +11 -0
  215. package/dist/physics/NarrowPhase.d.ts.map +1 -0
  216. package/dist/physics/NarrowPhase.js +565 -0
  217. package/dist/physics/NarrowPhase.js.map +1 -0
  218. package/dist/physics/PhysicsDebugDraw.js +19 -1
  219. package/dist/physics/PhysicsDebugDraw.js.map +1 -1
  220. package/dist/physics/PhysicsWorld.d.ts +43 -0
  221. package/dist/physics/PhysicsWorld.d.ts.map +1 -1
  222. package/dist/physics/PhysicsWorld.js +305 -30
  223. package/dist/physics/PhysicsWorld.js.map +1 -1
  224. package/dist/physics/RigidBody.d.ts +8 -1
  225. package/dist/physics/RigidBody.d.ts.map +1 -1
  226. package/dist/physics/RigidBody.js +32 -5
  227. package/dist/physics/RigidBody.js.map +1 -1
  228. package/dist/physics/Shape.d.ts +16 -2
  229. package/dist/physics/Shape.d.ts.map +1 -1
  230. package/dist/physics/Shape.js +93 -31
  231. package/dist/physics/Shape.js.map +1 -1
  232. package/dist/physics/TimeOfImpact.d.ts +15 -0
  233. package/dist/physics/TimeOfImpact.d.ts.map +1 -0
  234. package/dist/physics/TimeOfImpact.js +81 -0
  235. package/dist/physics/TimeOfImpact.js.map +1 -0
  236. package/dist/physics/index.d.ts +2 -0
  237. package/dist/physics/index.d.ts.map +1 -1
  238. package/dist/physics/index.js +2 -0
  239. package/dist/physics/index.js.map +1 -1
  240. package/dist/rendering/CascadedShadowMaps.d.ts +9 -1
  241. package/dist/rendering/CascadedShadowMaps.d.ts.map +1 -1
  242. package/dist/rendering/CascadedShadowMaps.js +68 -0
  243. package/dist/rendering/CascadedShadowMaps.js.map +1 -1
  244. package/dist/rendering/ClusteredForwardLighting.d.ts +28 -0
  245. package/dist/rendering/ClusteredForwardLighting.d.ts.map +1 -0
  246. package/dist/rendering/ClusteredForwardLighting.js +156 -0
  247. package/dist/rendering/ClusteredForwardLighting.js.map +1 -0
  248. package/dist/rendering/DepthPass.d.ts +14 -1
  249. package/dist/rendering/DepthPass.d.ts.map +1 -1
  250. package/dist/rendering/DepthPass.js +19 -4
  251. package/dist/rendering/DepthPass.js.map +1 -1
  252. package/dist/rendering/EnvironmentMapResources.d.ts +59 -1
  253. package/dist/rendering/EnvironmentMapResources.d.ts.map +1 -1
  254. package/dist/rendering/EnvironmentMapResources.js +140 -100
  255. package/dist/rendering/EnvironmentMapResources.js.map +1 -1
  256. package/dist/rendering/EnvironmentPlatform.d.ts +3 -2
  257. package/dist/rendering/EnvironmentPlatform.d.ts.map +1 -1
  258. package/dist/rendering/EnvironmentPlatform.js +99 -44
  259. package/dist/rendering/EnvironmentPlatform.js.map +1 -1
  260. package/dist/rendering/ForwardPass.d.ts +37 -0
  261. package/dist/rendering/ForwardPass.d.ts.map +1 -1
  262. package/dist/rendering/ForwardPass.js +234 -7
  263. package/dist/rendering/ForwardPass.js.map +1 -1
  264. package/dist/rendering/Geometry.d.ts +19 -0
  265. package/dist/rendering/Geometry.d.ts.map +1 -1
  266. package/dist/rendering/Geometry.js +64 -0
  267. package/dist/rendering/Geometry.js.map +1 -1
  268. package/dist/rendering/IBL.d.ts.map +1 -1
  269. package/dist/rendering/IBL.js +0 -1
  270. package/dist/rendering/IBL.js.map +1 -1
  271. package/dist/rendering/LightCollector.d.ts +5 -1
  272. package/dist/rendering/LightCollector.d.ts.map +1 -1
  273. package/dist/rendering/LightCollector.js +16 -3
  274. package/dist/rendering/LightCollector.js.map +1 -1
  275. package/dist/rendering/LightUniforms.d.ts +26 -1
  276. package/dist/rendering/LightUniforms.d.ts.map +1 -1
  277. package/dist/rendering/LightUniforms.js +140 -8
  278. package/dist/rendering/LightUniforms.js.map +1 -1
  279. package/dist/rendering/LightingRig.d.ts +77 -0
  280. package/dist/rendering/LightingRig.d.ts.map +1 -1
  281. package/dist/rendering/LightingRig.js +100 -11
  282. package/dist/rendering/LightingRig.js.map +1 -1
  283. package/dist/rendering/MeshConsolidation.d.ts +63 -0
  284. package/dist/rendering/MeshConsolidation.d.ts.map +1 -0
  285. package/dist/rendering/MeshConsolidation.js +251 -0
  286. package/dist/rendering/MeshConsolidation.js.map +1 -0
  287. package/dist/rendering/PMREM.d.ts +13 -1
  288. package/dist/rendering/PMREM.d.ts.map +1 -1
  289. package/dist/rendering/PMREM.js +18 -4
  290. package/dist/rendering/PMREM.js.map +1 -1
  291. package/dist/rendering/PostProcessPass.d.ts +24 -2
  292. package/dist/rendering/PostProcessPass.d.ts.map +1 -1
  293. package/dist/rendering/PostProcessPass.js +136 -18
  294. package/dist/rendering/PostProcessPass.js.map +1 -1
  295. package/dist/rendering/PrimitiveSubmissionAudit.d.ts +195 -0
  296. package/dist/rendering/PrimitiveSubmissionAudit.d.ts.map +1 -0
  297. package/dist/rendering/PrimitiveSubmissionAudit.js +280 -0
  298. package/dist/rendering/PrimitiveSubmissionAudit.js.map +1 -0
  299. package/dist/rendering/ProductTurntableFixtures.d.ts.map +1 -1
  300. package/dist/rendering/ProductTurntableFixtures.js +93 -13
  301. package/dist/rendering/ProductTurntableFixtures.js.map +1 -1
  302. package/dist/rendering/ReflectionProbe.d.ts +59 -0
  303. package/dist/rendering/ReflectionProbe.d.ts.map +1 -1
  304. package/dist/rendering/ReflectionProbe.js +224 -0
  305. package/dist/rendering/ReflectionProbe.js.map +1 -1
  306. package/dist/rendering/ReflectionSurfaces.d.ts +4 -2
  307. package/dist/rendering/ReflectionSurfaces.d.ts.map +1 -1
  308. package/dist/rendering/ReflectionSurfaces.js +13 -8
  309. package/dist/rendering/ReflectionSurfaces.js.map +1 -1
  310. package/dist/rendering/RenderBackend.d.ts +1 -1
  311. package/dist/rendering/RenderBackend.d.ts.map +1 -1
  312. package/dist/rendering/RenderBackend.js +5 -1
  313. package/dist/rendering/RenderBackend.js.map +1 -1
  314. package/dist/rendering/RenderDevice.d.ts +13 -2
  315. package/dist/rendering/RenderDevice.d.ts.map +1 -1
  316. package/dist/rendering/RenderDevice.js +5 -2
  317. package/dist/rendering/RenderDevice.js.map +1 -1
  318. package/dist/rendering/Renderer.d.ts +41 -1
  319. package/dist/rendering/Renderer.d.ts.map +1 -1
  320. package/dist/rendering/Renderer.js +406 -61
  321. package/dist/rendering/Renderer.js.map +1 -1
  322. package/dist/rendering/RendererPostprocessPlan.d.ts +10 -3
  323. package/dist/rendering/RendererPostprocessPlan.d.ts.map +1 -1
  324. package/dist/rendering/RendererPostprocessPlan.js +25 -5
  325. package/dist/rendering/RendererPostprocessPlan.js.map +1 -1
  326. package/dist/rendering/RendererVisualPipelineReport.d.ts +3 -2
  327. package/dist/rendering/RendererVisualPipelineReport.d.ts.map +1 -1
  328. package/dist/rendering/RendererVisualPipelineReport.js +2 -0
  329. package/dist/rendering/RendererVisualPipelineReport.js.map +1 -1
  330. package/dist/rendering/ScreenSpaceLineMaterial.d.ts +34 -0
  331. package/dist/rendering/ScreenSpaceLineMaterial.d.ts.map +1 -0
  332. package/dist/rendering/ScreenSpaceLineMaterial.js +93 -0
  333. package/dist/rendering/ScreenSpaceLineMaterial.js.map +1 -0
  334. package/dist/rendering/ShaderChunks.d.ts +7 -0
  335. package/dist/rendering/ShaderChunks.d.ts.map +1 -1
  336. package/dist/rendering/ShaderChunks.js +137 -0
  337. package/dist/rendering/ShaderChunks.js.map +1 -1
  338. package/dist/rendering/ShaderLibrary.d.ts +17 -0
  339. package/dist/rendering/ShaderLibrary.d.ts.map +1 -1
  340. package/dist/rendering/ShaderLibrary.js +940 -98
  341. package/dist/rendering/ShaderLibrary.js.map +1 -1
  342. package/dist/rendering/ShadowPass.d.ts +10 -0
  343. package/dist/rendering/ShadowPass.d.ts.map +1 -1
  344. package/dist/rendering/ShadowPass.js +8 -1
  345. package/dist/rendering/ShadowPass.js.map +1 -1
  346. package/dist/rendering/SkinnedLitMaterial.d.ts +6 -0
  347. package/dist/rendering/SkinnedLitMaterial.d.ts.map +1 -1
  348. package/dist/rendering/SkinnedLitMaterial.js +22 -8
  349. package/dist/rendering/SkinnedLitMaterial.js.map +1 -1
  350. package/dist/rendering/SkinnedUnlitMaterial.d.ts +8 -0
  351. package/dist/rendering/SkinnedUnlitMaterial.d.ts.map +1 -1
  352. package/dist/rendering/SkinnedUnlitMaterial.js +26 -9
  353. package/dist/rendering/SkinnedUnlitMaterial.js.map +1 -1
  354. package/dist/rendering/SpecularPrefilter.d.ts +42 -0
  355. package/dist/rendering/SpecularPrefilter.d.ts.map +1 -0
  356. package/dist/rendering/SpecularPrefilter.js +480 -0
  357. package/dist/rendering/SpecularPrefilter.js.map +1 -0
  358. package/dist/rendering/TerrainFixtures.d.ts +24 -0
  359. package/dist/rendering/TerrainFixtures.d.ts.map +1 -1
  360. package/dist/rendering/TerrainFixtures.js +96 -0
  361. package/dist/rendering/TerrainFixtures.js.map +1 -1
  362. package/dist/rendering/Texture.d.ts +7 -0
  363. package/dist/rendering/Texture.d.ts.map +1 -1
  364. package/dist/rendering/Texture.js +9 -0
  365. package/dist/rendering/Texture.js.map +1 -1
  366. package/dist/rendering/VertexFormat.d.ts +34 -1
  367. package/dist/rendering/VertexFormat.d.ts.map +1 -1
  368. package/dist/rendering/VertexFormat.js +61 -0
  369. package/dist/rendering/VertexFormat.js.map +1 -1
  370. package/dist/rendering/WebGL2Device.d.ts +48 -0
  371. package/dist/rendering/WebGL2Device.d.ts.map +1 -1
  372. package/dist/rendering/WebGL2Device.js +1298 -44
  373. package/dist/rendering/WebGL2Device.js.map +1 -1
  374. package/dist/rendering/WebGPUDevice.d.ts +7 -2
  375. package/dist/rendering/WebGPUDevice.d.ts.map +1 -1
  376. package/dist/rendering/WebGPUDevice.js +111 -17
  377. package/dist/rendering/WebGPUDevice.js.map +1 -1
  378. package/dist/rendering/WebGPUSkinningLimits.d.ts +14 -0
  379. package/dist/rendering/WebGPUSkinningLimits.d.ts.map +1 -0
  380. package/dist/rendering/WebGPUSkinningLimits.js +14 -0
  381. package/dist/rendering/WebGPUSkinningLimits.js.map +1 -0
  382. package/dist/rendering/cartoon/CartoonMaterialStyle.d.ts +19 -0
  383. package/dist/rendering/cartoon/CartoonMaterialStyle.d.ts.map +1 -0
  384. package/dist/rendering/cartoon/CartoonMaterialStyle.js +13 -0
  385. package/dist/rendering/cartoon/CartoonMaterialStyle.js.map +1 -0
  386. package/dist/rendering/cartoon/CartoonRenderPreset.d.ts +36 -0
  387. package/dist/rendering/cartoon/CartoonRenderPreset.d.ts.map +1 -0
  388. package/dist/rendering/cartoon/CartoonRenderPreset.js +23 -0
  389. package/dist/rendering/cartoon/CartoonRenderPreset.js.map +1 -0
  390. package/dist/rendering/cartoon/CartoonToonMaterial.d.ts +130 -0
  391. package/dist/rendering/cartoon/CartoonToonMaterial.d.ts.map +1 -0
  392. package/dist/rendering/cartoon/CartoonToonMaterial.js +303 -0
  393. package/dist/rendering/cartoon/CartoonToonMaterial.js.map +1 -0
  394. package/dist/rendering/cartoon/CartoonVisualQuality.d.ts +28 -0
  395. package/dist/rendering/cartoon/CartoonVisualQuality.d.ts.map +1 -0
  396. package/dist/rendering/cartoon/CartoonVisualQuality.js +39 -0
  397. package/dist/rendering/cartoon/CartoonVisualQuality.js.map +1 -0
  398. package/dist/rendering/cartoon/applyCartoonRenderPreset.d.ts +79 -0
  399. package/dist/rendering/cartoon/applyCartoonRenderPreset.d.ts.map +1 -0
  400. package/dist/rendering/cartoon/applyCartoonRenderPreset.js +88 -0
  401. package/dist/rendering/cartoon/applyCartoonRenderPreset.js.map +1 -0
  402. package/dist/rendering/cartoon/index.d.ts +6 -0
  403. package/dist/rendering/cartoon/index.d.ts.map +1 -0
  404. package/dist/rendering/cartoon/index.js +6 -0
  405. package/dist/rendering/cartoon/index.js.map +1 -0
  406. package/dist/rendering/index.d.ts +26 -15
  407. package/dist/rendering/index.d.ts.map +1 -1
  408. package/dist/rendering/index.js +15 -9
  409. package/dist/rendering/index.js.map +1 -1
  410. package/dist/rendering/postprocess/NativeLdrEffectLuts.d.ts +93 -0
  411. package/dist/rendering/postprocess/NativeLdrEffectLuts.d.ts.map +1 -0
  412. package/dist/rendering/postprocess/NativeLdrEffectLuts.js +202 -0
  413. package/dist/rendering/postprocess/NativeLdrEffectLuts.js.map +1 -0
  414. package/dist/rendering/production-runtime/PBRHDRPipeline.d.ts.map +1 -1
  415. package/dist/rendering/production-runtime/PBRHDRPipeline.js +3 -0
  416. package/dist/rendering/production-runtime/PBRHDRPipeline.js.map +1 -1
  417. package/dist/rendering/production-runtime/ProductionRendererTypes.d.ts +1 -0
  418. package/dist/rendering/production-runtime/ProductionRendererTypes.d.ts.map +1 -1
  419. package/dist/rendering/production-runtime/ProductionRendererTypes.js.map +1 -1
  420. package/dist/rendering/production-runtime/ProductionWebGL2Renderer.d.ts.map +1 -1
  421. package/dist/rendering/production-runtime/ProductionWebGL2Renderer.js +5 -3
  422. package/dist/rendering/production-runtime/ProductionWebGL2Renderer.js.map +1 -1
  423. package/dist/rendering/production-runtime/ProductionWebGPURenderer.d.ts.map +1 -1
  424. package/dist/rendering/production-runtime/ProductionWebGPURenderer.js +9 -5
  425. package/dist/rendering/production-runtime/ProductionWebGPURenderer.js.map +1 -1
  426. package/dist/rendering/production-runtime/TransmissionBackdropCapture.d.ts +5 -0
  427. package/dist/rendering/production-runtime/TransmissionBackdropCapture.d.ts.map +1 -1
  428. package/dist/rendering/production-runtime/TransmissionBackdropCapture.js +40 -0
  429. package/dist/rendering/production-runtime/TransmissionBackdropCapture.js.map +1 -1
  430. package/dist/rendering/production-runtime/environment/HDRLoader.d.ts +6 -0
  431. package/dist/rendering/production-runtime/environment/HDRLoader.d.ts.map +1 -1
  432. package/dist/rendering/production-runtime/environment/HDRLoader.js +19 -0
  433. package/dist/rendering/production-runtime/environment/HDRLoader.js.map +1 -1
  434. package/dist/rendering/production-runtime/index.d.ts +3 -1
  435. package/dist/rendering/production-runtime/index.d.ts.map +1 -1
  436. package/dist/rendering/production-runtime/index.js +1 -0
  437. package/dist/rendering/production-runtime/index.js.map +1 -1
  438. package/dist/scene/Light.d.ts +1 -1
  439. package/dist/scene/Light.d.ts.map +1 -1
  440. package/dist/scene/RectAreaLight.d.ts +22 -0
  441. package/dist/scene/RectAreaLight.d.ts.map +1 -0
  442. package/dist/scene/RectAreaLight.js +46 -0
  443. package/dist/scene/RectAreaLight.js.map +1 -0
  444. package/dist/scene/Scene.d.ts +6 -1
  445. package/dist/scene/Scene.d.ts.map +1 -1
  446. package/dist/scene/Scene.js +8 -1
  447. package/dist/scene/Scene.js.map +1 -1
  448. package/dist/scene/SceneSerializer.d.ts +3 -1
  449. package/dist/scene/SceneSerializer.d.ts.map +1 -1
  450. package/dist/scene/SceneSerializer.js +14 -7
  451. package/dist/scene/SceneSerializer.js.map +1 -1
  452. package/dist/scene/index.d.ts +1 -0
  453. package/dist/scene/index.d.ts.map +1 -1
  454. package/dist/scene/index.js +1 -0
  455. package/dist/scene/index.js.map +1 -1
  456. package/dist/scripting/CartoonNodeCategories.d.ts +3 -0
  457. package/dist/scripting/CartoonNodeCategories.d.ts.map +1 -0
  458. package/dist/scripting/CartoonNodeCategories.js +9 -0
  459. package/dist/scripting/CartoonNodeCategories.js.map +1 -0
  460. package/dist/scripting/CartoonVisualNodes.d.ts +3 -0
  461. package/dist/scripting/CartoonVisualNodes.d.ts.map +1 -0
  462. package/dist/scripting/CartoonVisualNodes.js +41 -0
  463. package/dist/scripting/CartoonVisualNodes.js.map +1 -0
  464. package/package.json +124 -113
  465. package/templates/cinematic-scene/package.json +1 -1
  466. package/templates/mini-game/package.json +1 -1
  467. package/templates/product-viewer/package.json +1 -1
  468. package/templates/production-asset-inspector/README.md +5 -0
  469. package/templates/production-asset-inspector/asset-manifest.json +9 -0
  470. package/templates/production-asset-inspector/index.html +2 -0
  471. package/templates/production-asset-inspector/package.json +17 -0
  472. package/templates/production-asset-inspector/src/main.ts +16 -0
  473. package/templates/production-material-studio/README.md +5 -0
  474. package/templates/production-material-studio/asset-manifest.json +9 -0
  475. package/templates/production-material-studio/index.html +2 -0
  476. package/templates/production-material-studio/package.json +17 -0
  477. package/templates/production-material-studio/src/main.ts +16 -0
  478. package/templates/production-product-configurator/README.md +5 -0
  479. package/templates/production-product-configurator/asset-manifest.json +9 -0
  480. package/templates/production-product-configurator/index.html +2 -0
  481. package/templates/production-product-configurator/package.json +17 -0
  482. package/templates/production-product-configurator/src/main.ts +16 -0
  483. package/templates/production-product-viewer/README.md +7 -0
  484. package/templates/production-product-viewer/asset-manifest.json +8 -0
  485. package/templates/production-product-viewer/index.html +26 -0
  486. package/templates/production-product-viewer/package.json +17 -0
  487. package/templates/production-product-viewer/src/main.ts +70 -0
@@ -12,9 +12,22 @@ export declare class DepthMaterial extends Material {
12
12
  }
13
13
  export declare class DepthPass extends BaseRenderPass {
14
14
  private readonly options;
15
+ /**
16
+ * Depth shader modules, shared across `DepthPass` instances and keyed by shader library.
17
+ *
18
+ * `ShadowPass` constructs a **new `DepthPass` every time it renders**, so an instance-field cache
19
+ * was discarded each frame and the depth shader was recompiled and relinked on every shadow pass.
20
+ * WebGL shader compilation is a synchronous GPU stall: measured on the Aura Clash playable route,
21
+ * that single per-frame recompile held the whole route at **2 FPS** with 97.8% of profiled time
22
+ * outside JS, which in turn made every timing-based browser test miss its window.
23
+ *
24
+ * A `WeakMap` keyed by the library keeps the entry alive exactly as long as the library is, so a
25
+ * long-lived renderer compiles the depth shader once while a disposed library is still collectable.
26
+ * This mirrors the per-device/per-library cache `ForwardPass` already uses.
27
+ */
28
+ private static readonly shaderModules;
15
29
  private readonly shaderLibrary;
16
30
  private readonly material;
17
- private shaderModule;
18
31
  constructor(options: DepthPassOptions);
19
32
  execute(context: RenderPassContext): void;
20
33
  private drawCaster;
@@ -1 +1 @@
1
- {"version":3,"file":"DepthPass.d.ts","sourceRoot":"","sources":["../../../../packages/rendering/src/DepthPass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAA6B,KAAK,aAAa,EAA8B,MAAM,iBAAiB,CAAC;AAC5G,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE,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,gBAAgB;IAKtD,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAMzC,OAAO,CAAC,UAAU;IA6BlB,OAAO,CAAC,SAAS;CAQlB"}
@@ -20,9 +20,22 @@ export class DepthMaterial extends Material {
20
20
  }
21
21
  export class DepthPass extends BaseRenderPass {
22
22
  options;
23
+ /**
24
+ * Depth shader modules, shared across `DepthPass` instances and keyed by shader library.
25
+ *
26
+ * `ShadowPass` constructs a **new `DepthPass` every time it renders**, so an instance-field cache
27
+ * was discarded each frame and the depth shader was recompiled and relinked on every shadow pass.
28
+ * WebGL shader compilation is a synchronous GPU stall: measured on the Aura Clash playable route,
29
+ * that single per-frame recompile held the whole route at **2 FPS** with 97.8% of profiled time
30
+ * outside JS, which in turn made every timing-based browser test miss its window.
31
+ *
32
+ * A `WeakMap` keyed by the library keeps the entry alive exactly as long as the library is, so a
33
+ * long-lived renderer compiles the depth shader once while a disposed library is still collectable.
34
+ * This mirrors the per-device/per-library cache `ForwardPass` already uses.
35
+ */
36
+ static shaderModules = new WeakMap();
23
37
  shaderLibrary;
24
38
  material = new DepthMaterial();
25
- shaderModule = null;
26
39
  constructor(options) {
27
40
  super("depth", [], ["depth"]);
28
41
  this.options = options;
@@ -62,10 +75,12 @@ export class DepthPass extends BaseRenderPass {
62
75
  device.draw(command);
63
76
  }
64
77
  getShader(device) {
65
- if (!this.shaderModule) {
66
- this.shaderModule = ShaderModule.fromLibrary(this.shaderLibrary, this.material.shaderKey);
78
+ let module = DepthPass.shaderModules.get(this.shaderLibrary);
79
+ if (!module) {
80
+ module = ShaderModule.fromLibrary(this.shaderLibrary, this.material.shaderKey);
81
+ DepthPass.shaderModules.set(this.shaderLibrary, module);
67
82
  }
68
- return this.shaderModule.compile(device);
83
+ return module.compile(device);
69
84
  }
70
85
  }
71
86
  function resolveDepthDrawRange(geometry, range) {
@@ -1 +1 @@
1
- {"version":3,"file":"DepthPass.js","sourceRoot":"","sources":["../../../../packages/rendering/src/DepthPass.ts"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K,GAAG,SAAS,EAAE,CAAC;QACrJ,MAAM,IAAI,iBAAiB,CAAC,4DAA4D,EAAE,0BAA0B,EAAE;YACpH,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS;SACV,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc;IACrB,OAAO,IAAI,YAAY,CAAC;QACtB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACV,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACV,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACV,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;KACX,CAAC,CAAC;AACL,CAAC;AAED,SAAS,MAAM,CAAC,KAAuC,EAAE,KAAc;IACrE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,MAAM,CAAC,MAAM,KAAK,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAC5E,MAAM,IAAI,KAAK,CAAC,aAAa,KAAK,IAAI,QAAQ,yCAAyC,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO,MAAyB,CAAC;AACnC,CAAC"}
@@ -51,6 +51,7 @@ export interface EnvironmentResourceSetOptions {
51
51
  readonly toneMapping?: EnvironmentToneMappingOperator;
52
52
  readonly specularLevels?: number;
53
53
  readonly specularBlurRadius?: number;
54
+ readonly specularSampleCount?: number;
54
55
  readonly irradianceWidth?: number;
55
56
  readonly irradianceHeight?: number;
56
57
  readonly irradianceBlurRadius?: number;
@@ -69,6 +70,10 @@ export interface EnvironmentMapResourceSet {
69
70
  readonly hdrSource: boolean;
70
71
  readonly maxLinearValue: number;
71
72
  readonly specularMipCount: number;
73
+ /** Roughness each specular level was GGX-filtered for, ordered by level. */
74
+ readonly specularLevelRoughness: readonly number[];
75
+ readonly specularFilterModel: "ggx-importance-sampled-equirect-prefilter";
76
+ readonly diffuseIrradianceModel: "sh9-cosine-convolved";
72
77
  readonly diffuseIrradianceSize: readonly [number, number];
73
78
  readonly brdfLutSize: readonly [number, number];
74
79
  };
@@ -86,13 +91,66 @@ export declare function encodeLinearHdrEnvironmentToRgba8(source: LinearHdrEnvir
86
91
  export declare function encodeLinearHdrEnvironmentToRgbe(source: LinearHdrEnvironmentMapSource): RgbeEnvironmentMapSource;
87
92
  export declare function encodeLinearHdrEnvironmentToRgba16f(source: LinearHdrEnvironmentMapSource): TextureMipLevelDescriptor;
88
93
  export declare function generateRgba8EnvironmentMipLevels(source: Rgba8EnvironmentMapSource, options?: EnvironmentMipGenerationOptions): readonly TextureMipLevelDescriptor[];
89
- export declare function generateSpecularPrefilterMipLevels(source: Rgba8EnvironmentMapSource, options?: EnvironmentMipGenerationOptions): readonly TextureMipLevelDescriptor[];
94
+ /**
95
+ * Real GGX importance-sampled specular prefilter over an RGBA8 environment.
96
+ *
97
+ * Each level `i` of `levelCount` is filtered for roughness `i / (levelCount - 1)`
98
+ * by convolving the linearised source with the GGX lobe for that exact
99
+ * roughness, so the roughness a shader assigns to a LOD is the roughness the
100
+ * texels were actually filtered for. The previous implementation delegated to
101
+ * `generateRgba8EnvironmentMipLevels` with a box-blur radius, which produced a
102
+ * mip chain whose blur width was unrelated to its nominal roughness.
103
+ *
104
+ * `blurRadius` is retained only for call-site compatibility and no longer
105
+ * affects the filter; `sampleCount` controls GGX sample density instead.
106
+ */
107
+ export declare function generateSpecularPrefilterMipLevels(source: Rgba8EnvironmentMapSource, options?: EnvironmentSpecularPrefilterGenerationOptions): readonly TextureMipLevelDescriptor[];
108
+ /**
109
+ * Roughness each specular prefilter level was genuinely filtered for. Callers
110
+ * must use this rather than deriving roughness from a mip index they did not
111
+ * generate.
112
+ */
113
+ export { specularPrefilterLevelRoughness } from "./SpecularPrefilter";
90
114
  export declare function generateRgbeEnvironmentMipLevels(source: LinearHdrEnvironmentMapSource, options?: EnvironmentMipGenerationOptions): readonly TextureMipLevelDescriptor[];
115
+ /**
116
+ * Real GGX specular prefilter for HDR environments, encoded as RGBE per level.
117
+ * `generateRgbeEnvironmentMipLevels` remains available for plain mip pyramids,
118
+ * but it is a progressive box downsample and must not be labelled as
119
+ * roughness-prefiltered.
120
+ */
121
+ export declare function generateRgbeSpecularPrefilterMipLevels(source: LinearHdrEnvironmentMapSource, options?: EnvironmentSpecularPrefilterGenerationOptions): readonly TextureMipLevelDescriptor[];
91
122
  export declare function generateRgba16fEnvironmentMipLevels(source: LinearHdrEnvironmentMapSource, options?: EnvironmentMipGenerationOptions): readonly TextureMipLevelDescriptor[];
92
123
  export declare function generateRgba16fSpecularPrefilterMipLevels(source: LinearHdrEnvironmentMapSource, options?: EnvironmentSpecularPrefilterGenerationOptions): readonly TextureMipLevelDescriptor[];
93
124
  export declare function generateRgba16fDiffuseIrradianceMipLevel(source: LinearHdrEnvironmentMapSource, options?: DiffuseIrradianceGenerationOptions): TextureMipLevelDescriptor;
125
+ /**
126
+ * Cosine-convolved diffuse irradiance for RGBA8 environments.
127
+ *
128
+ * This previously averaged a square box of source texels, which is not a cosine
129
+ * convolution: it ignores the hemisphere orientation entirely, so two opposite
130
+ * normals sampled from nearby texels received nearly identical "irradiance".
131
+ * The environment is now decoded to linear, projected onto nine irradiance SH
132
+ * bands with per-texel solid angle weights, and evaluated per output direction.
133
+ *
134
+ * `blurRadius` is retained for call-site compatibility and no longer affects
135
+ * the result.
136
+ */
94
137
  export declare function generateDiffuseIrradianceRgba8(source: Rgba8EnvironmentMapSource, options?: DiffuseIrradianceGenerationOptions): Rgba8EnvironmentMapSource;
138
+ /**
139
+ * Cosine-convolved diffuse irradiance for HDR environments, encoded as RGBE.
140
+ * Replaces the previous box average for the same reason as the RGBA8 path.
141
+ */
95
142
  export declare function generateDiffuseIrradianceRgbe(source: LinearHdrEnvironmentMapSource, options?: DiffuseIrradianceGenerationOptions): RgbeEnvironmentMapSource;
96
143
  export declare function createEnvironmentMapResourceSet(input: EnvironmentMapResourceInput, options?: EnvironmentResourceSetOptions): EnvironmentMapResourceSet;
144
+ /**
145
+ * Generates the deterministic GGX split-sum DFG lookup texture used by the
146
+ * environment-lighting shaders. The historical `Approximate` export name is
147
+ * retained for API compatibility; each texel is numerically integrated rather
148
+ * than evaluated from an analytic fit.
149
+ *
150
+ * The red channel stores the coefficient multiplied by F0 and the green
151
+ * channel stores the grazing-angle Fresnel bias:
152
+ *
153
+ * `environmentSpecular * (F0 * red + green)`
154
+ */
97
155
  export declare function generateApproximateBrdfLutPixels(descriptor?: BrdfLutDescriptor): Rgba8EnvironmentMapSource;
98
156
  //# sourceMappingURL=EnvironmentMapResources.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnvironmentMapResources.d.ts","sourceRoot":"","sources":["../../../../packages/rendering/src/EnvironmentMapResources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAE3D,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,MAAM,CAAC;AACtD,MAAM,MAAM,wBAAwB,GAAG,cAAc,GAAG,YAAY,GAAG,MAAM,CAAC;AAC9E,MAAM,MAAM,0BAA0B,GAAG,cAAc,GAAG,YAAY,GAAG,MAAM,CAAC;AAChF,MAAM,MAAM,8BAA8B,GAAG,QAAQ,GAAG,UAAU,CAAC;AAInE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,iBAAiB,CAAC;CAC/C;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CA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,7 @@
1
1
  import {} from "./Texture.js";
2
+ import { convolveEnvironmentIrradiance, prefilterGgxEnvironmentLevels, specularPrefilterLevelRoughness } from "./SpecularPrefilter.js";
2
3
  const A3D_EPSILON_NUMBER = 0.00001;
4
+ const A3D_MIN_PBR_ROUGHNESS = 0.045;
3
5
  export function srgbChannelToLinear(value) {
4
6
  const channel = validateNormalizedChannel(value, "sRGB channel");
5
7
  return channel <= 0.04045 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);
@@ -103,12 +105,57 @@ export function generateRgba8EnvironmentMipLevels(source, options = {}) {
103
105
  }
104
106
  return levels;
105
107
  }
108
+ /**
109
+ * Real GGX importance-sampled specular prefilter over an RGBA8 environment.
110
+ *
111
+ * Each level `i` of `levelCount` is filtered for roughness `i / (levelCount - 1)`
112
+ * by convolving the linearised source with the GGX lobe for that exact
113
+ * roughness, so the roughness a shader assigns to a LOD is the roughness the
114
+ * texels were actually filtered for. The previous implementation delegated to
115
+ * `generateRgba8EnvironmentMipLevels` with a box-blur radius, which produced a
116
+ * mip chain whose blur width was unrelated to its nominal roughness.
117
+ *
118
+ * `blurRadius` is retained only for call-site compatibility and no longer
119
+ * affects the filter; `sampleCount` controls GGX sample density instead.
120
+ */
106
121
  export function generateSpecularPrefilterMipLevels(source, options = {}) {
107
- return generateRgba8EnvironmentMipLevels(source, {
108
- levels: options.levels,
109
- blurRadius: options.blurRadius ?? 2
122
+ validateSource(source);
123
+ const maxLevels = maxMipLevels(source.width, source.height);
124
+ const requestedLevels = options.levels ?? maxLevels;
125
+ if (!Number.isInteger(requestedLevels) || requestedLevels < 1) {
126
+ throw new RangeError("Environment specular prefilter levels must be a positive integer");
127
+ }
128
+ const sampleCount = options.sampleCount ?? 64;
129
+ if (!Number.isInteger(sampleCount) || sampleCount <= 0) {
130
+ throw new RangeError("Environment specular prefilter sampleCount must be a positive integer");
131
+ }
132
+ const levelCount = Math.min(requestedLevels, maxLevels);
133
+ const linear = decodeRgba8EnvironmentToLinear(source, "srgb");
134
+ const prefiltered = prefilterGgxEnvironmentLevels(linear, { levels: levelCount, sampleCount });
135
+ return prefiltered.map((level, index) => {
136
+ if (index === 0) {
137
+ // Roughness 0 is a mirror reflection, so level 0 is the unfiltered
138
+ // source. Copy the bytes instead of round-tripping through sRGB to keep
139
+ // it bit-exact.
140
+ return { width: source.width, height: source.height, data: new Uint8Array(source.data) };
141
+ }
142
+ const data = new Uint8Array(level.width * level.height * 4);
143
+ for (let index2 = 0; index2 < level.width * level.height; index2 += 1) {
144
+ const offset = index2 * 4;
145
+ data[offset] = encodeColorByte(clamp(level.data[offset] ?? 0, 0, 1), "srgb");
146
+ data[offset + 1] = encodeColorByte(clamp(level.data[offset + 1] ?? 0, 0, 1), "srgb");
147
+ data[offset + 2] = encodeColorByte(clamp(level.data[offset + 2] ?? 0, 0, 1), "srgb");
148
+ data[offset + 3] = 255;
149
+ }
150
+ return { width: level.width, height: level.height, data };
110
151
  });
111
152
  }
153
+ /**
154
+ * Roughness each specular prefilter level was genuinely filtered for. Callers
155
+ * must use this rather than deriving roughness from a mip index they did not
156
+ * generate.
157
+ */
158
+ export { specularPrefilterLevelRoughness } from "./SpecularPrefilter.js";
112
159
  export function generateRgbeEnvironmentMipLevels(source, options = {}) {
113
160
  validateHdrSource(source);
114
161
  const maxLevels = maxMipLevels(source.width, source.height);
@@ -133,6 +180,32 @@ export function generateRgbeEnvironmentMipLevels(source, options = {}) {
133
180
  }
134
181
  return levels;
135
182
  }
183
+ /**
184
+ * Real GGX specular prefilter for HDR environments, encoded as RGBE per level.
185
+ * `generateRgbeEnvironmentMipLevels` remains available for plain mip pyramids,
186
+ * but it is a progressive box downsample and must not be labelled as
187
+ * roughness-prefiltered.
188
+ */
189
+ export function generateRgbeSpecularPrefilterMipLevels(source, options = {}) {
190
+ validateHdrSource(source);
191
+ const maxLevels = maxMipLevels(source.width, source.height);
192
+ const requestedLevels = options.levels ?? maxLevels;
193
+ if (!Number.isInteger(requestedLevels) || requestedLevels < 1) {
194
+ throw new RangeError("Environment RGBe specular prefilter levels must be a positive integer");
195
+ }
196
+ const sampleCount = options.sampleCount ?? 32;
197
+ if (!Number.isInteger(sampleCount) || sampleCount <= 0) {
198
+ throw new RangeError("Environment RGBe specular prefilter sampleCount must be a positive integer");
199
+ }
200
+ return prefilterGgxEnvironmentLevels(source, {
201
+ levels: Math.min(requestedLevels, maxLevels),
202
+ sampleCount
203
+ }).map((level) => encodeLinearHdrEnvironmentToRgbe({
204
+ width: level.width,
205
+ height: level.height,
206
+ data: level.data
207
+ }));
208
+ }
136
209
  export function generateRgba16fEnvironmentMipLevels(source, options = {}) {
137
210
  validateHdrSource(source);
138
211
  const maxLevels = maxMipLevels(source.width, source.height);
@@ -169,19 +242,12 @@ export function generateRgba16fSpecularPrefilterMipLevels(source, options = {})
169
242
  throw new RangeError("Environment RGBA16F specular prefilter sampleCount must be a positive integer");
170
243
  }
171
244
  const mipCount = Math.min(requestedLevels, maxLevels);
172
- const levels = [
173
- encodeLinearHdrEnvironmentToRgba16f({
174
- width: source.width,
175
- height: source.height,
176
- data: new Float32Array(source.data)
177
- })
178
- ];
179
- for (let mipIndex = 1; mipIndex < mipCount; mipIndex += 1) {
180
- const roughness = clamp(mipIndex / Math.max(1, mipCount - 1), 0, 1);
181
- const effectiveSamples = Math.max(8, Math.round(sampleCount * lerp(0.5, 1, roughness)));
182
- const level = prefilterLinearHdrEnvironmentLevel(source, mipIndex, roughness, effectiveSamples);
183
- levels.push(encodeLinearHdrEnvironmentToRgba16f(level));
184
- }
245
+ const prefiltered = prefilterGgxEnvironmentLevels(source, { levels: mipCount, sampleCount });
246
+ const levels = prefiltered.map((level) => encodeLinearHdrEnvironmentToRgba16f({
247
+ width: level.width,
248
+ height: level.height,
249
+ data: level.data
250
+ }));
185
251
  if (levels.length > 1) {
186
252
  const diffuseLevel = levels[levels.length - 1];
187
253
  levels[levels.length - 1] = generateRgba16fDiffuseIrradianceMipLevel(source, {
@@ -217,6 +283,18 @@ export function generateRgba16fDiffuseIrradianceMipLevel(source, options = {}) {
217
283
  }
218
284
  return encodeLinearHdrEnvironmentToRgba16f({ width, height, data });
219
285
  }
286
+ /**
287
+ * Cosine-convolved diffuse irradiance for RGBA8 environments.
288
+ *
289
+ * This previously averaged a square box of source texels, which is not a cosine
290
+ * convolution: it ignores the hemisphere orientation entirely, so two opposite
291
+ * normals sampled from nearby texels received nearly identical "irradiance".
292
+ * The environment is now decoded to linear, projected onto nine irradiance SH
293
+ * bands with per-texel solid angle weights, and evaluated per output direction.
294
+ *
295
+ * `blurRadius` is retained for call-site compatibility and no longer affects
296
+ * the result.
297
+ */
220
298
  export function generateDiffuseIrradianceRgba8(source, options = {}) {
221
299
  validateSource(source);
222
300
  const width = options.width ?? Math.min(16, source.width);
@@ -228,21 +306,21 @@ export function generateDiffuseIrradianceRgba8(source, options = {}) {
228
306
  if (!Number.isInteger(blurRadius) || blurRadius < 0) {
229
307
  throw new RangeError("Environment diffuse irradiance blurRadius must be a non-negative integer");
230
308
  }
309
+ const irradiance = convolveEnvironmentIrradiance(decodeRgba8EnvironmentToLinear(source, "srgb"), width, height);
231
310
  const data = new Uint8Array(width * height * 4);
232
- for (let y = 0; y < height; y += 1) {
233
- for (let x = 0; x < width; x += 1) {
234
- const sourceX = Math.round((x / Math.max(1, width - 1)) * (source.width - 1));
235
- const sourceY = Math.round((y / Math.max(1, height - 1)) * (source.height - 1));
236
- const color = sampleBox(source, sourceX, sourceY, blurRadius);
237
- const index = (y * width + x) * 4;
238
- data[index] = color[0];
239
- data[index + 1] = color[1];
240
- data[index + 2] = color[2];
241
- data[index + 3] = color[3];
242
- }
311
+ for (let index = 0; index < width * height; index += 1) {
312
+ const offset = index * 4;
313
+ data[offset] = encodeColorByte(clamp(irradiance.data[offset] ?? 0, 0, 1), "srgb");
314
+ data[offset + 1] = encodeColorByte(clamp(irradiance.data[offset + 1] ?? 0, 0, 1), "srgb");
315
+ data[offset + 2] = encodeColorByte(clamp(irradiance.data[offset + 2] ?? 0, 0, 1), "srgb");
316
+ data[offset + 3] = 255;
243
317
  }
244
318
  return { width, height, data };
245
319
  }
320
+ /**
321
+ * Cosine-convolved diffuse irradiance for HDR environments, encoded as RGBE.
322
+ * Replaces the previous box average for the same reason as the RGBA8 path.
323
+ */
246
324
  export function generateDiffuseIrradianceRgbe(source, options = {}) {
247
325
  validateHdrSource(source);
248
326
  const width = options.width ?? Math.min(16, source.width);
@@ -254,14 +332,11 @@ export function generateDiffuseIrradianceRgbe(source, options = {}) {
254
332
  if (!Number.isInteger(blurRadius) || blurRadius < 0) {
255
333
  throw new RangeError("Environment diffuse irradiance blurRadius must be a non-negative integer");
256
334
  }
335
+ const irradiance = convolveEnvironmentIrradiance(source, width, height);
257
336
  const data = new Uint8Array(width * height * 4);
258
- for (let y = 0; y < height; y += 1) {
259
- for (let x = 0; x < width; x += 1) {
260
- const sourceX = Math.round((x / Math.max(1, width - 1)) * (source.width - 1));
261
- const sourceY = Math.round((y / Math.max(1, height - 1)) * (source.height - 1));
262
- const color = sampleLinearHdrBox(source, sourceX, sourceY, blurRadius);
263
- encodeLinearRgbePixel(color[0], color[1], color[2], color[3], data, (y * width + x) * 4);
264
- }
337
+ for (let index = 0; index < width * height; index += 1) {
338
+ const offset = index * 4;
339
+ encodeLinearRgbePixel(irradiance.data[offset] ?? 0, irradiance.data[offset + 1] ?? 0, irradiance.data[offset + 2] ?? 0, 1, data, offset);
265
340
  }
266
341
  return { width, height, data };
267
342
  }
@@ -281,13 +356,13 @@ export function createEnvironmentMapResourceSet(input, options = {}) {
281
356
  outputColorSpace: textureEncoding === "rgba8-linear" ? "linear" : "srgb"
282
357
  });
283
358
  const specularMipLevels = textureEncoding === "rgbe"
284
- ? generateRgbeEnvironmentMipLevels(linearForTexture, {
359
+ ? generateRgbeSpecularPrefilterMipLevels(linearForTexture, {
285
360
  levels: options.specularLevels,
286
- blurRadius: options.specularBlurRadius ?? 2
361
+ ...(options.specularSampleCount === undefined ? {} : { sampleCount: options.specularSampleCount })
287
362
  })
288
363
  : generateSpecularPrefilterMipLevels(base, {
289
364
  levels: options.specularLevels,
290
- blurRadius: options.specularBlurRadius ?? 2
365
+ ...(options.specularSampleCount === undefined ? {} : { sampleCount: options.specularSampleCount })
291
366
  });
292
367
  const diffuseIrradiance = textureEncoding === "rgbe"
293
368
  ? generateDiffuseIrradianceRgbe(linearForTexture, {
@@ -317,11 +392,25 @@ export function createEnvironmentMapResourceSet(input, options = {}) {
317
392
  hdrSource: inputEncoding === "rgbe" || inputEncoding === "linear-hdr",
318
393
  maxLinearValue: Number(maxLinearValue(linear).toFixed(6)),
319
394
  specularMipCount: specularMipLevels.length,
395
+ specularLevelRoughness: specularPrefilterLevelRoughness(specularMipLevels.length),
396
+ specularFilterModel: "ggx-importance-sampled-equirect-prefilter",
397
+ diffuseIrradianceModel: "sh9-cosine-convolved",
320
398
  diffuseIrradianceSize: [diffuseIrradiance.width, diffuseIrradiance.height],
321
399
  brdfLutSize: [brdfLut.width, brdfLut.height]
322
400
  }
323
401
  };
324
402
  }
403
+ /**
404
+ * Generates the deterministic GGX split-sum DFG lookup texture used by the
405
+ * environment-lighting shaders. The historical `Approximate` export name is
406
+ * retained for API compatibility; each texel is numerically integrated rather
407
+ * than evaluated from an analytic fit.
408
+ *
409
+ * The red channel stores the coefficient multiplied by F0 and the green
410
+ * channel stores the grazing-angle Fresnel bias:
411
+ *
412
+ * `environmentSpecular * (F0 * red + green)`
413
+ */
325
414
  export function generateApproximateBrdfLutPixels(descriptor = {}) {
326
415
  const width = descriptor.width ?? 32;
327
416
  const height = descriptor.height ?? 32;
@@ -337,7 +426,7 @@ export function generateApproximateBrdfLutPixels(descriptor = {}) {
337
426
  const roughness = clamp(y / Math.max(1, height - 1), 0, 1);
338
427
  for (let x = 0; x < width; x += 1) {
339
428
  const nDotV = clamp(x / Math.max(1, width - 1), 0.001, 1);
340
- const brdf = integrateGgxEnvironmentBrdf(nDotV, roughness, sampleCount);
429
+ const brdf = integrateSplitSumGgxEnvironmentBrdf(nDotV, roughness, sampleCount);
341
430
  const index = (y * width + x) * 4;
342
431
  data[index] = encodeColorByte(brdf[0], "linear");
343
432
  data[index + 1] = encodeColorByte(brdf[1], "linear");
@@ -347,7 +436,7 @@ export function generateApproximateBrdfLutPixels(descriptor = {}) {
347
436
  }
348
437
  return { width, height, data };
349
438
  }
350
- function integrateGgxEnvironmentBrdf(nDotV, roughness, sampleCount) {
439
+ function integrateSplitSumGgxEnvironmentBrdf(nDotV, roughness, sampleCount) {
351
440
  const view = [
352
441
  Math.sqrt(Math.max(0, 1 - nDotV * nDotV)),
353
442
  0,
@@ -369,7 +458,12 @@ function integrateGgxEnvironmentBrdf(nDotV, roughness, sampleCount) {
369
458
  if (nDotL <= 0 || nDotH <= 0 || vDotH <= 0) {
370
459
  continue;
371
460
  }
372
- const visibility = ggxGeometrySmithCorrelated(nDotV, nDotL, roughness) * vDotH / Math.max(nDotH * nDotV, A3D_EPSILON_NUMBER);
461
+ // Split-sum weight for GGX-importance-sampled half vectors. The GGX pdf is
462
+ // D * nDotH / (4 * vDotH), so the estimator for the specular integral
463
+ // D * V * nDotL reduces to 4 * V * nDotL * vDotH / nDotH. Dropping the
464
+ // 4 * nDotL factor (or dividing by nDotV instead) produces values far above
465
+ // 1 that clamp to white and destroy split-sum energy conservation.
466
+ const visibility = 4 * ggxGeometrySmithCorrelated(nDotV, nDotL, roughness) * nDotL * vDotH / Math.max(nDotH, A3D_EPSILON_NUMBER);
373
467
  const fresnel = Math.pow(1 - vDotH, 5);
374
468
  scale += (1 - fresnel) * visibility;
375
469
  bias += fresnel * visibility;
@@ -392,7 +486,11 @@ function radicalInverseVdc(bits) {
392
486
  return value * 2.3283064365386963e-10;
393
487
  }
394
488
  function importanceSampleGgx(xi, roughness) {
395
- const alpha = Math.max(roughness, 0.001) * Math.max(roughness, 0.001);
489
+ // Match the minimum perceptual roughness used by the PBR shader's GGX
490
+ // distribution. Using a narrower proposal than the evaluated lobe biases the
491
+ // first LUT row even though the runtime shader clamps that row to this value.
492
+ const clampedRoughness = Math.max(roughness, A3D_MIN_PBR_ROUGHNESS);
493
+ const alpha = clampedRoughness * clampedRoughness;
396
494
  const alpha2 = alpha * alpha;
397
495
  const phi = 2 * Math.PI * xi[0];
398
496
  const cosTheta = Math.sqrt((1 - xi[1]) / Math.max(1 + (alpha2 - 1) * xi[1], A3D_EPSILON_NUMBER));
@@ -404,7 +502,7 @@ function importanceSampleGgx(xi, roughness) {
404
502
  ];
405
503
  }
406
504
  function ggxGeometrySmithCorrelated(nDotV, nDotL, roughness) {
407
- const alpha = Math.max(roughness, 0.045);
505
+ const alpha = Math.max(roughness, A3D_MIN_PBR_ROUGHNESS);
408
506
  const alpha2 = alpha * alpha * alpha * alpha;
409
507
  const lambdaV = nDotL * Math.sqrt(Math.max((nDotV - alpha2 * nDotV) * nDotV + alpha2, A3D_EPSILON_NUMBER));
410
508
  const lambdaL = nDotV * Math.sqrt(Math.max((nDotL - alpha2 * nDotL) * nDotL + alpha2, A3D_EPSILON_NUMBER));
@@ -451,64 +549,6 @@ function downsampleLinearHdrEnvironmentLevel(source, blurRadius) {
451
549
  }
452
550
  return { width, height, data };
453
551
  }
454
- function prefilterLinearHdrEnvironmentLevel(source, mipIndex, roughness, sampleCount) {
455
- const width = Math.max(1, Math.floor(source.width / 2 ** mipIndex));
456
- const height = Math.max(1, Math.floor(source.height / 2 ** mipIndex));
457
- const data = new Float32Array(width * height * 4);
458
- for (let y = 0; y < height; y += 1) {
459
- for (let x = 0; x < width; x += 1) {
460
- const direction = equirectPixelDirection(x, y, width, height);
461
- const color = prefilterLinearHdrEnvironmentDirection(source, direction, roughness, sampleCount);
462
- const index = (y * width + x) * 4;
463
- data[index] = color[0];
464
- data[index + 1] = color[1];
465
- data[index + 2] = color[2];
466
- data[index + 3] = color[3];
467
- }
468
- }
469
- return { width, height, data };
470
- }
471
- function prefilterLinearHdrEnvironmentDirection(source, reflectionDirection, roughness, sampleCount) {
472
- if (roughness <= A3D_EPSILON_NUMBER) {
473
- return sampleLinearHdrEquirect(source, reflectionDirection);
474
- }
475
- const normal = reflectionDirection;
476
- const view = reflectionDirection;
477
- let red = 0;
478
- let green = 0;
479
- let blue = 0;
480
- let alpha = 0;
481
- let totalWeight = 0;
482
- for (let sampleIndex = 0; sampleIndex < sampleCount; sampleIndex += 1) {
483
- const xi = hammersley2d(sampleIndex, sampleCount);
484
- const halfVector = tangentToWorld(importanceSampleGgx(xi, roughness), normal);
485
- const vDotH = Math.max(dot3(view, halfVector), 0);
486
- const light = normalize3([
487
- 2 * vDotH * halfVector[0] - view[0],
488
- 2 * vDotH * halfVector[1] - view[1],
489
- 2 * vDotH * halfVector[2] - view[2]
490
- ]);
491
- const nDotL = Math.max(dot3(normal, light), 0);
492
- if (nDotL <= A3D_EPSILON_NUMBER) {
493
- continue;
494
- }
495
- const sample = sampleLinearHdrEquirect(source, light);
496
- red += sample[0] * nDotL;
497
- green += sample[1] * nDotL;
498
- blue += sample[2] * nDotL;
499
- alpha += sample[3] * nDotL;
500
- totalWeight += nDotL;
501
- }
502
- if (totalWeight <= A3D_EPSILON_NUMBER) {
503
- return sampleLinearHdrEquirect(source, reflectionDirection);
504
- }
505
- return [
506
- red / totalWeight,
507
- green / totalWeight,
508
- blue / totalWeight,
509
- alpha / totalWeight
510
- ];
511
- }
512
552
  function integrateDiffuseIrradianceOverHemisphere(source, normal, sampleCount) {
513
553
  let red = 0;
514
554
  let green = 0;