@woosh/meep-engine 3.43.0 → 3.44.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 (287) hide show
  1. package/editor/prototypeEditorShell.d.ts.map +1 -1
  2. package/editor/prototypeEditorShell.js +4 -2
  3. package/package.json +1 -1
  4. package/src/engine/Clock.d.ts +15 -0
  5. package/src/engine/Clock.d.ts.map +1 -1
  6. package/src/engine/Clock.js +29 -5
  7. package/src/engine/Engine.d.ts.map +1 -1
  8. package/src/engine/Engine.js +11 -19
  9. package/src/engine/graphics/ecs/mesh-v2/MeshSkin.d.ts +57 -0
  10. package/src/engine/graphics/ecs/mesh-v2/MeshSkin.d.ts.map +1 -0
  11. package/src/engine/graphics/ecs/mesh-v2/MeshSkin.js +84 -0
  12. package/src/engine/graphics3/AnimationGraphSystem.d.ts +23 -13
  13. package/src/engine/graphics3/AnimationGraphSystem.d.ts.map +1 -1
  14. package/src/engine/graphics3/AnimationGraphSystem.js +61 -64
  15. package/src/engine/graphics3/AnimationSystem.d.ts +24 -15
  16. package/src/engine/graphics3/AnimationSystem.d.ts.map +1 -1
  17. package/src/engine/graphics3/AnimationSystem.js +67 -61
  18. package/src/engine/graphics3/MeshSkinSystem.d.ts +56 -0
  19. package/src/engine/graphics3/MeshSkinSystem.d.ts.map +1 -0
  20. package/src/engine/graphics3/MeshSkinSystem.js +317 -0
  21. package/src/engine/graphics3/MeshSystem.d.ts +15 -35
  22. package/src/engine/graphics3/MeshSystem.d.ts.map +1 -1
  23. package/src/engine/graphics3/MeshSystem.js +21 -298
  24. package/src/engine/graphics3/RowChains.d.ts +76 -0
  25. package/src/engine/graphics3/RowChains.d.ts.map +1 -0
  26. package/src/engine/graphics3/RowChains.js +347 -0
  27. package/src/engine/graphics3/ShadedGeometrySystem.d.ts +6 -0
  28. package/src/engine/graphics3/ShadedGeometrySystem.d.ts.map +1 -1
  29. package/src/engine/graphics3/ShadedGeometrySystem.js +329 -309
  30. package/src/engine/graphics3/animation/AnimationClips.d.ts +56 -0
  31. package/src/engine/graphics3/animation/AnimationClips.d.ts.map +1 -0
  32. package/src/engine/graphics3/animation/AnimationClips.js +79 -0
  33. package/src/engine/graphics3/animation/ClipListPlayer.d.ts +13 -14
  34. package/src/engine/graphics3/animation/ClipListPlayer.d.ts.map +1 -1
  35. package/src/engine/graphics3/animation/ClipListPlayer.js +262 -263
  36. package/src/engine/graphics3/animation/write_clip_playback.d.ts +3 -3
  37. package/src/engine/graphics3/animation/write_clip_playback.js +4 -4
  38. package/src/engine/graphics3/pose/query_entity_node_world_pose.d.ts +5 -0
  39. package/src/engine/graphics3/pose/query_entity_node_world_pose.d.ts.map +1 -1
  40. package/src/engine/graphics3/pose/query_entity_node_world_pose.js +80 -75
  41. package/src/engine/graphics3/prefab/PrefabInstance.d.ts +4 -24
  42. package/src/engine/graphics3/prefab/PrefabInstance.d.ts.map +1 -1
  43. package/src/engine/graphics3/prefab/PrefabInstance.js +60 -80
  44. package/src/engine/graphics3/prefab/prefab_instantiate.d.ts +16 -3
  45. package/src/engine/graphics3/prefab/prefab_instantiate.d.ts.map +1 -1
  46. package/src/engine/graphics3/prefab/prefab_instantiate.js +49 -12
  47. package/src/engine/graphics3/prefab/prefab_place.d.ts +31 -17
  48. package/src/engine/graphics3/prefab/prefab_place.d.ts.map +1 -1
  49. package/src/engine/graphics3/prefab/prefab_place.js +175 -130
  50. package/src/engine/graphics3/register_clips.d.ts +64 -0
  51. package/src/engine/graphics3/register_clips.d.ts.map +1 -0
  52. package/src/engine/graphics3/register_clips.js +114 -0
  53. package/src/engine/physics/cloth/MEASUREMENTS.md +795 -0
  54. package/src/engine/physics/cloth/PLAN.md +339 -9
  55. package/src/engine/physics/cloth/build/ClothProxy.d.ts +113 -61
  56. package/src/engine/physics/cloth/build/ClothProxy.d.ts.map +1 -1
  57. package/src/engine/physics/cloth/build/ClothProxy.js +142 -77
  58. package/src/engine/physics/cloth/build/cloth_bind_in_frame.d.ts +22 -0
  59. package/src/engine/physics/cloth/build/cloth_bind_in_frame.d.ts.map +1 -0
  60. package/src/engine/physics/cloth/build/cloth_bind_in_frame.js +75 -0
  61. package/src/engine/physics/cloth/build/cloth_proxy_from_joints.d.ts +43 -30
  62. package/src/engine/physics/cloth/build/cloth_proxy_from_joints.d.ts.map +1 -1
  63. package/src/engine/physics/cloth/build/cloth_proxy_from_joints.js +357 -284
  64. package/src/engine/physics/cloth/build/cloth_proxy_from_mesh.d.ts +62 -0
  65. package/src/engine/physics/cloth/build/cloth_proxy_from_mesh.d.ts.map +1 -0
  66. package/src/engine/physics/cloth/build/cloth_proxy_from_mesh.js +280 -0
  67. package/src/engine/physics/cloth/collider/cloth_collider_sdf.d.ts +1 -1
  68. package/src/engine/physics/cloth/collider/cloth_collider_sdf.js +1 -1
  69. package/src/engine/physics/cloth/ecs/Cloth.d.ts +17 -9
  70. package/src/engine/physics/cloth/ecs/Cloth.d.ts.map +1 -1
  71. package/src/engine/physics/cloth/ecs/Cloth.js +220 -212
  72. package/src/engine/physics/cloth/ecs/ClothDynamicsFlags.js +6 -0
  73. package/src/engine/physics/cloth/ecs/ClothHold.d.ts +91 -0
  74. package/src/engine/physics/cloth/ecs/ClothHold.d.ts.map +1 -0
  75. package/src/engine/physics/cloth/ecs/ClothHold.js +103 -0
  76. package/src/engine/physics/cloth/ecs/ClothInstance.d.ts +254 -48
  77. package/src/engine/physics/cloth/ecs/ClothInstance.d.ts.map +1 -1
  78. package/src/engine/physics/cloth/ecs/ClothInstance.js +277 -47
  79. package/src/engine/physics/cloth/ecs/ClothPin.d.ts +73 -0
  80. package/src/engine/physics/cloth/ecs/ClothPin.d.ts.map +1 -0
  81. package/src/engine/physics/cloth/ecs/ClothPin.js +92 -0
  82. package/src/engine/physics/cloth/ecs/ClothPinSerializationAdapter.d.ts +36 -0
  83. package/src/engine/physics/cloth/ecs/ClothPinSerializationAdapter.d.ts.map +1 -0
  84. package/src/engine/physics/cloth/ecs/ClothPinSerializationAdapter.js +61 -0
  85. package/src/engine/physics/cloth/ecs/ClothRig.d.ts +23 -17
  86. package/src/engine/physics/cloth/ecs/ClothRig.d.ts.map +1 -1
  87. package/src/engine/physics/cloth/ecs/ClothRig.js +29 -27
  88. package/src/engine/physics/cloth/ecs/ClothSystem.d.ts +12 -14
  89. package/src/engine/physics/cloth/ecs/ClothSystem.d.ts.map +1 -1
  90. package/src/engine/physics/cloth/ecs/ClothSystem.js +20 -15
  91. package/src/engine/physics/cloth/ecs/ClothWorld.d.ts +57 -36
  92. package/src/engine/physics/cloth/ecs/ClothWorld.d.ts.map +1 -1
  93. package/src/engine/physics/cloth/ecs/ClothWorld.js +816 -179
  94. package/src/engine/physics/cloth/ecs/WorkerClothSystem.d.ts +12 -13
  95. package/src/engine/physics/cloth/ecs/WorkerClothSystem.d.ts.map +1 -1
  96. package/src/engine/physics/cloth/ecs/WorkerClothSystem.js +20 -14
  97. package/src/engine/physics/cloth/ecs/cloth_build_rows.d.ts +63 -11
  98. package/src/engine/physics/cloth/ecs/cloth_build_rows.d.ts.map +1 -1
  99. package/src/engine/physics/cloth/ecs/cloth_build_rows.js +321 -84
  100. package/src/engine/physics/cloth/ecs/cloth_dynamics_map.d.ts +9 -7
  101. package/src/engine/physics/cloth/ecs/cloth_dynamics_map.d.ts.map +1 -1
  102. package/src/engine/physics/cloth/ecs/cloth_dynamics_map.js +9 -7
  103. package/src/engine/physics/cloth/ecs/cloth_gather_colliders.d.ts +3 -3
  104. package/src/engine/physics/cloth/ecs/cloth_gather_colliders.js +30 -30
  105. package/src/engine/physics/cloth/ecs/cloth_geodesic.d.ts +37 -0
  106. package/src/engine/physics/cloth/ecs/cloth_geodesic.d.ts.map +1 -0
  107. package/src/engine/physics/cloth/ecs/cloth_geodesic.js +142 -0
  108. package/src/engine/physics/cloth/ecs/cloth_holds.d.ts +97 -0
  109. package/src/engine/physics/cloth/ecs/cloth_holds.d.ts.map +1 -0
  110. package/src/engine/physics/cloth/ecs/cloth_holds.js +608 -0
  111. package/src/engine/physics/cloth/ecs/cloth_reconstruct_pose.d.ts +2 -2
  112. package/src/engine/physics/cloth/ecs/cloth_reconstruct_pose.d.ts.map +1 -1
  113. package/src/engine/physics/cloth/ecs/cloth_reconstruct_pose.js +160 -9
  114. package/src/engine/physics/cloth/ecs/cloth_seed_rig.d.ts +17 -22
  115. package/src/engine/physics/cloth/ecs/cloth_seed_rig.d.ts.map +1 -1
  116. package/src/engine/physics/cloth/ecs/cloth_seed_rig.js +55 -117
  117. package/src/engine/physics/cloth/ecs/cloth_seed_subtree.d.ts +21 -6
  118. package/src/engine/physics/cloth/ecs/cloth_seed_subtree.d.ts.map +1 -1
  119. package/src/engine/physics/cloth/ecs/cloth_seed_subtree.js +44 -15
  120. package/src/engine/physics/cloth/ecs/cloth_write_back.d.ts +5 -0
  121. package/src/engine/physics/cloth/ecs/cloth_write_back.d.ts.map +1 -1
  122. package/src/engine/physics/cloth/ecs/cloth_write_back.js +60 -16
  123. package/src/engine/physics/cloth/ecs/cloth_write_back_rig.d.ts.map +1 -1
  124. package/src/engine/physics/cloth/ecs/cloth_write_back_rig.js +65 -58
  125. package/src/engine/physics/cloth/playground/collide_main.js +1 -1
  126. package/src/engine/physics/cloth/playground/garment_build.d.ts.map +1 -1
  127. package/src/engine/physics/cloth/playground/garment_build.js +17 -5
  128. package/src/engine/physics/cloth/playground/garment_main.js +1 -1
  129. package/src/engine/physics/cloth/playground/rig_build.d.ts.map +1 -1
  130. package/src/engine/physics/cloth/playground/rig_build.js +302 -296
  131. package/src/engine/physics/cloth/solver/ClothState.d.ts +45 -7
  132. package/src/engine/physics/cloth/solver/ClothState.d.ts.map +1 -1
  133. package/src/engine/physics/cloth/solver/ClothState.js +63 -7
  134. package/src/engine/physics/cloth/solver/cloth_contact_find.d.ts +6 -1
  135. package/src/engine/physics/cloth/solver/cloth_contact_find.d.ts.map +1 -1
  136. package/src/engine/physics/cloth/solver/cloth_contact_find.js +7 -2
  137. package/src/engine/physics/cloth/solver/cloth_hold_line.d.ts +114 -0
  138. package/src/engine/physics/cloth/solver/cloth_hold_line.d.ts.map +1 -0
  139. package/src/engine/physics/cloth/solver/cloth_hold_line.js +362 -0
  140. package/src/engine/physics/cloth/solver/cloth_self_find.d.ts +6 -2
  141. package/src/engine/physics/cloth/solver/cloth_self_find.d.ts.map +1 -1
  142. package/src/engine/physics/cloth/solver/cloth_self_find.js +13 -13
  143. package/src/engine/physics/cloth/solver/cloth_solver_constants.d.ts +24 -12
  144. package/src/engine/physics/cloth/solver/cloth_solver_constants.d.ts.map +1 -1
  145. package/src/engine/physics/cloth/solver/cloth_solver_constants.js +24 -12
  146. package/src/engine/physics/cloth/solver/cloth_step.d.ts +16 -0
  147. package/src/engine/physics/cloth/solver/cloth_step.d.ts.map +1 -1
  148. package/src/engine/physics/cloth/solver/cloth_step.js +183 -20
  149. package/src/engine/physics/cloth/solver/cloth_step_instance.d.ts +1 -0
  150. package/src/engine/physics/cloth/solver/cloth_step_instance.d.ts.map +1 -1
  151. package/src/engine/physics/cloth/solver/cloth_step_instance.js +10 -3
  152. package/src/engine/physics/cloth/solver/constraint/cloth_leash_row.d.ts +1 -1
  153. package/src/engine/physics/cloth/solver/constraint/cloth_leash_row.d.ts.map +1 -1
  154. package/src/engine/physics/cloth/solver/constraint/cloth_leash_row.js +353 -346
  155. package/src/engine/physics/cloth/solver/constraint/cloth_self_row.d.ts +7 -5
  156. package/src/engine/physics/cloth/solver/constraint/cloth_self_row.d.ts.map +1 -1
  157. package/src/engine/physics/cloth/solver/constraint/cloth_self_row.js +7 -5
  158. package/src/engine/physics/cloth/wind/cloth_sample_air.d.ts +9 -9
  159. package/src/engine/physics/cloth/wind/cloth_sample_air.d.ts.map +1 -1
  160. package/src/engine/physics/cloth/wind/cloth_sample_air.js +26 -26
  161. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  162. package/src/engine/simulation/Ticker.d.ts +13 -0
  163. package/src/engine/simulation/Ticker.d.ts.map +1 -1
  164. package/src/engine/simulation/Ticker.js +43 -8
  165. package/src/shade/RENDERER_CONTRACT.md +8 -2
  166. package/src/shade/playground/mesh_row_ceiling/main.js +2 -1
  167. package/src/shade/playground/skinned_blas_refit/main.d.ts.map +1 -1
  168. package/src/shade/playground/skinned_blas_refit/main.js +11 -19
  169. package/src/shade/playground/skinned_blas_refit/place_character.d.ts +6 -3
  170. package/src/shade/playground/skinned_blas_refit/place_character.d.ts.map +1 -1
  171. package/src/shade/playground/skinned_blas_refit/place_character.js +90 -90
  172. package/src/shade/playground/skinned_mesh_soup/main.d.ts.map +1 -1
  173. package/src/shade/playground/skinned_mesh_soup/main.js +502 -509
  174. package/src/shade/playground/texture_encode/README.md +129 -109
  175. package/src/shade/playground/texture_encode/main.js +1430 -1430
  176. package/src/shade/renderer/animation/GPUAnimationManager.d.ts +45 -14
  177. package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
  178. package/src/shade/renderer/animation/GPUAnimationManager.js +316 -64
  179. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts +5 -0
  180. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts.map +1 -1
  181. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.js +11 -1
  182. package/src/shade/renderer/geometry/BoxGeometry.d.ts +1 -11
  183. package/src/shade/renderer/geometry/BoxGeometry.d.ts.map +1 -1
  184. package/src/shade/renderer/geometry/BoxGeometry.js +6 -13
  185. package/src/shade/renderer/geometry/CapsuleGeometry.d.ts +19 -0
  186. package/src/shade/renderer/geometry/CapsuleGeometry.d.ts.map +1 -0
  187. package/src/shade/renderer/geometry/CapsuleGeometry.js +24 -0
  188. package/src/shade/renderer/geometry/ConeGeometry.d.ts +20 -0
  189. package/src/shade/renderer/geometry/ConeGeometry.d.ts.map +1 -0
  190. package/src/shade/renderer/geometry/ConeGeometry.js +33 -0
  191. package/src/shade/renderer/geometry/CylinderGeometry.d.ts +21 -0
  192. package/src/shade/renderer/geometry/CylinderGeometry.d.ts.map +1 -0
  193. package/src/shade/renderer/geometry/CylinderGeometry.js +35 -0
  194. package/src/shade/renderer/geometry/PlaneGeometry.d.ts +17 -0
  195. package/src/shade/renderer/geometry/PlaneGeometry.d.ts.map +1 -0
  196. package/src/shade/renderer/geometry/PlaneGeometry.js +22 -0
  197. package/src/shade/renderer/geometry/TorusGeometry.d.ts +18 -0
  198. package/src/shade/renderer/geometry/TorusGeometry.d.ts.map +1 -0
  199. package/src/shade/renderer/geometry/TorusGeometry.js +23 -0
  200. package/src/shade/renderer/geometry/UVSphereGeometry.d.ts +21 -0
  201. package/src/shade/renderer/geometry/UVSphereGeometry.d.ts.map +1 -0
  202. package/src/shade/renderer/geometry/UVSphereGeometry.js +34 -0
  203. package/src/shade/renderer/geometry/primitives/make_capsule_geometry.d.ts +19 -0
  204. package/src/shade/renderer/geometry/primitives/make_capsule_geometry.d.ts.map +1 -0
  205. package/src/shade/renderer/geometry/primitives/make_capsule_geometry.js +205 -0
  206. package/src/shade/renderer/geometry/primitives/make_cone_geometry.d.ts +21 -0
  207. package/src/shade/renderer/geometry/primitives/make_cone_geometry.d.ts.map +1 -0
  208. package/src/shade/renderer/geometry/primitives/make_cone_geometry.js +36 -0
  209. package/src/shade/renderer/geometry/primitives/make_cylinder_geometry.d.ts +1 -1
  210. package/src/shade/renderer/geometry/primitives/make_cylinder_geometry.d.ts.map +1 -1
  211. package/src/shade/renderer/geometry/primitives/make_cylinder_geometry.js +44 -9
  212. package/src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.d.ts +20 -0
  213. package/src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.d.ts.map +1 -0
  214. package/src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.js +190 -0
  215. package/src/shade/renderer/geometry/virtual/runtime/graph_vgeo_expand_instances_to_meshlets.d.ts.map +1 -1
  216. package/src/shade/renderer/geometry/virtual/runtime/graph_vgeo_expand_instances_to_meshlets.js +7 -2
  217. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.d.ts +26 -8
  218. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.d.ts.map +1 -1
  219. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.js +56 -39
  220. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.d.ts +7 -0
  221. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.d.ts.map +1 -1
  222. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.js +46 -4
  223. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/test_prefix_sum.d.ts.map +1 -1
  224. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/test_prefix_sum.js +4 -2
  225. package/src/shade/renderer/gpu_primitive/sort/defs.d.ts +2 -2
  226. package/src/shade/renderer/gpu_primitive/sort/defs.js +79 -79
  227. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.d.ts +1 -1
  228. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.d.ts.map +1 -1
  229. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.js +7 -3
  230. package/src/shade/renderer/particles/GPUParticleSystem.js +1 -1
  231. package/src/shade/renderer/particles/coherence/graph_particle_bucket.d.ts +4 -3
  232. package/src/shade/renderer/particles/coherence/graph_particle_bucket.d.ts.map +1 -1
  233. package/src/shade/renderer/particles/coherence/graph_particle_bucket.js +200 -194
  234. package/src/shade/renderer/particles/graph_particles.d.ts.map +1 -1
  235. package/src/shade/renderer/particles/graph_particles.js +6 -2
  236. package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts.map +1 -1
  237. package/src/shade/renderer/particles/warmup/graph_particle_warmup.js +334 -329
  238. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.d.ts.map +1 -1
  239. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.js +7 -2
  240. package/src/shade/renderer/rasterize/expand/mesh/graph_expand_meshes_to_meshlets.d.ts.map +1 -1
  241. package/src/shade/renderer/rasterize/expand/mesh/graph_expand_meshes_to_meshlets.js +16 -4
  242. package/src/shade/renderer/texture/COMPRESSED_TEXTURE_PLAN_2026_09_01.md +2444 -2345
  243. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts.map +1 -1
  244. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.js +312 -310
  245. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts +3 -3
  246. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts.map +1 -1
  247. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.js +383 -375
  248. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.d.ts.map +1 -1
  249. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.js +349 -346
  250. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts +58 -0
  251. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts.map +1 -0
  252. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.js +536 -0
  253. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts +21 -7
  254. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts.map +1 -1
  255. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.js +291 -327
  256. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode1.d.ts +25 -0
  257. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode1.d.ts.map +1 -0
  258. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode1.js +99 -0
  259. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode6.d.ts +5 -3
  260. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode6.d.ts.map +1 -1
  261. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode6.js +47 -71
  262. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.d.ts +10 -0
  263. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.d.ts.map +1 -0
  264. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.js +50 -0
  265. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.d.ts +4 -5
  266. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.d.ts.map +1 -1
  267. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.js +7 -8
  268. package/src/shade/renderer/water/chunk_water_transport.d.ts.map +1 -1
  269. package/src/shade/renderer/water/chunk_water_transport.js +7 -5
  270. package/src/shade/renderer/water/medium/GPUWaterBodies.d.ts.map +1 -1
  271. package/src/shade/renderer/water/medium/GPUWaterBodies.js +8 -2
  272. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.d.ts +3 -2
  273. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.d.ts.map +1 -1
  274. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.js +3 -2
  275. package/src/shade/renderer/water/shader_water.d.ts.map +1 -1
  276. package/src/shade/renderer/water/shader_water.js +3 -1
  277. package/src/shade/renderer/water/surface/GPUWaterSurface.d.ts.map +1 -1
  278. package/src/shade/renderer/water/surface/GPUWaterSurface.js +3 -1
  279. package/src/shade/renderer/water/surface/graph_water_tessellation.d.ts.map +1 -1
  280. package/src/shade/renderer/water/surface/graph_water_tessellation.js +11 -4
  281. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.d.ts.map +1 -1
  282. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.js +37 -20
  283. package/src/shade/wgsl/validate_wgsl_source.d.ts.map +1 -1
  284. package/src/shade/wgsl/validate_wgsl_source.js +74 -3
  285. package/src/engine/graphics3/register_instance_animation.d.ts +0 -114
  286. package/src/engine/graphics3/register_instance_animation.d.ts.map +0 -1
  287. package/src/engine/graphics3/register_instance_animation.js +0 -201
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @typedef {import("../Geometry.js").Geometry} Geometry
3
+ */
4
+ /**
5
+ * The axis runs along Y with the apex at the top, and the body is centred on the origin.
6
+ *
7
+ * A cone is a cylinder whose top radius is zero, exactly as three's `ConeGeometry` is, so this is
8
+ * {@link make_cylinder_geometry} under its own name; the apex handling lives there.
9
+ *
10
+ * @param {number} [radius] radius of the base
11
+ * @param {number} [height]
12
+ * @param {number} [radialSegments] segments around the axis
13
+ * @param {number} [heightSegments] segments along the axis
14
+ * @param {boolean} [openEnded] leave the base off, which makes the surface a hollow shell rather than a solid
15
+ * @param {number} [thetaStart]
16
+ * @param {number} [thetaLength] how much of the turn to build, in radians
17
+ * @returns {Geometry}
18
+ */
19
+ export function make_cone_geometry(radius?: number, height?: number, radialSegments?: number, heightSegments?: number, openEnded?: boolean, thetaStart?: number, thetaLength?: number): Geometry;
20
+ export type Geometry = import("../Geometry.js").Geometry;
21
+ //# sourceMappingURL=make_cone_geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make_cone_geometry.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/primitives/make_cone_geometry.js"],"names":[],"mappings":"AAEA;;GAEG;AAEH;;;;;;;;;;;;;;GAcG;AACH,4CATW,MAAM,WACN,MAAM,mBACN,MAAM,mBACN,MAAM,cACN,OAAO,eACP,MAAM,gBACN,MAAM,GACJ,QAAQ,CAgBpB;uBAhCY,OAAO,gBAAgB,EAAE,QAAQ"}
@@ -0,0 +1,36 @@
1
+ import { make_cylinder_geometry } from "./make_cylinder_geometry.js";
2
+
3
+ /**
4
+ * @typedef {import("../Geometry.js").Geometry} Geometry
5
+ */
6
+
7
+ /**
8
+ * The axis runs along Y with the apex at the top, and the body is centred on the origin.
9
+ *
10
+ * A cone is a cylinder whose top radius is zero, exactly as three's `ConeGeometry` is, so this is
11
+ * {@link make_cylinder_geometry} under its own name; the apex handling lives there.
12
+ *
13
+ * @param {number} [radius] radius of the base
14
+ * @param {number} [height]
15
+ * @param {number} [radialSegments] segments around the axis
16
+ * @param {number} [heightSegments] segments along the axis
17
+ * @param {boolean} [openEnded] leave the base off, which makes the surface a hollow shell rather than a solid
18
+ * @param {number} [thetaStart]
19
+ * @param {number} [thetaLength] how much of the turn to build, in radians
20
+ * @returns {Geometry}
21
+ */
22
+ export function make_cone_geometry(
23
+ radius = 1,
24
+ height = 1,
25
+ radialSegments = 8,
26
+ heightSegments = 1,
27
+ openEnded = false,
28
+ thetaStart = 0,
29
+ thetaLength = Math.PI * 2
30
+ ) {
31
+ const geo = make_cylinder_geometry(0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength);
32
+
33
+ geo.name = "Cone";
34
+
35
+ return geo;
36
+ }
@@ -4,7 +4,7 @@
4
4
  * `Geometry` carries no multi-material groups, so the torso and the two caps are one index run
5
5
  * rather than three; three's cylinder splits them only to address a material array.
6
6
  *
7
- * @param {number} [radiusTop]
7
+ * @param {number} [radiusTop] zero makes a cone, which is what `make_cone_geometry` does
8
8
  * @param {number} [radiusBottom]
9
9
  * @param {number} [height]
10
10
  * @param {number} [radialSegments] segments around the axis
@@ -1 +1 @@
1
- {"version":3,"file":"make_cylinder_geometry.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/primitives/make_cylinder_geometry.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,mDAVW,MAAM,iBACN,MAAM,WACN,MAAM,mBACN,MAAM,mBACN,MAAM,cACN,OAAO,eACP,MAAM,gBACN,MAAM,GACJ,QAAQ,CA6NpB;yBA9OwB,gBAAgB"}
1
+ {"version":3,"file":"make_cylinder_geometry.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/primitives/make_cylinder_geometry.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,mDAVW,MAAM,iBACN,MAAM,WACN,MAAM,mBACN,MAAM,mBACN,MAAM,cACN,OAAO,eACP,MAAM,gBACN,MAAM,GACJ,QAAQ,CAgQpB;yBAjRwB,gBAAgB"}
@@ -8,7 +8,7 @@ import { StandardAttributes } from "../StandardAttributes.js";
8
8
  * `Geometry` carries no multi-material groups, so the torso and the two caps are one index run
9
9
  * rather than three; three's cylinder splits them only to address a material array.
10
10
  *
11
- * @param {number} [radiusTop]
11
+ * @param {number} [radiusTop] zero makes a cone, which is what `make_cone_geometry` does
12
12
  * @param {number} [radiusBottom]
13
13
  * @param {number} [height]
14
14
  * @param {number} [radialSegments] segments around the axis
@@ -31,7 +31,8 @@ export function make_cylinder_geometry(
31
31
 
32
32
  /*
33
33
  A port of three's `CylinderGeometry` onto `Geometry`: the same parameterisation and the same
34
- winding, writing meep attributes instead of three ones.
34
+ winding, writing meep attributes instead of three ones. It departs at a cone's apex, see
35
+ `generateTorso`.
35
36
 
36
37
  Derived from three.js (https://github.com/mrdoob/three.js), Copyright (c) 2010-2024 three.js authors, MIT licence.
37
38
  */
@@ -56,6 +57,7 @@ export function make_cylinder_geometry(
56
57
 
57
58
  let index = 0;
58
59
  const indexArray = [];
60
+ const apexRows = [];
59
61
  const halfHeight = height / 2;
60
62
 
61
63
  // generate geometry
@@ -98,9 +100,21 @@ export function make_cylinder_geometry(
98
100
 
99
101
  const radius = v * (radiusBottom - radiusTop) + radiusTop;
100
102
 
101
- for (let x = 0; x <= radialSegments; x++) {
103
+ // A row of zero radius is a cone's apex, where three's grid would put two corners of
104
+ // every segment's upper triangle on the same point and lean the other one's apex normal
105
+ // toward one edge. Instead the apex holds one vertex per segment, turned to the middle of
106
+ // that segment, and each segment draws just the one triangle that has area. The `u` is
107
+ // offset the same way, as three's own sphere does at its poles.
108
+ const apex = radius === 0;
102
109
 
103
- const u = x / radialSegments;
110
+ apexRows.push(apex);
111
+
112
+ const rowVertexCount = apex ? radialSegments : radialSegments + 1;
113
+ const uOffset = apex ? 0.5 : 0;
114
+
115
+ for (let x = 0; x < rowVertexCount; x++) {
116
+
117
+ const u = (x + uOffset) / radialSegments;
104
118
 
105
119
  const theta = u * thetaLength + thetaStart;
106
120
 
@@ -143,13 +157,34 @@ export function make_cylinder_geometry(
143
157
 
144
158
  const a = indexArray[y][x];
145
159
  const b = indexArray[y + 1][x];
146
- const c = indexArray[y + 1][x + 1];
147
- const d = indexArray[y][x + 1];
148
160
 
149
- // faces
161
+ if (apexRows[y] && apexRows[y + 1]) {
162
+
163
+ // both rows on the axis, so the band has no area
164
+
165
+ } else if (apexRows[y]) {
166
+
167
+ // `a` is the segment's apex vertex and stands in for `d` as well
168
+
169
+ indices.push(b, indexArray[y + 1][x + 1], a);
170
+
171
+ } else if (apexRows[y + 1]) {
172
+
173
+ // `b` is the segment's apex vertex and stands in for `c` as well
174
+
175
+ indices.push(a, b, indexArray[y][x + 1]);
176
+
177
+ } else {
178
+
179
+ const c = indexArray[y + 1][x + 1];
180
+ const d = indexArray[y][x + 1];
181
+
182
+ // faces
183
+
184
+ indices.push(a, b, d);
185
+ indices.push(b, c, d);
150
186
 
151
- indices.push(a, b, d);
152
- indices.push(b, c, d);
187
+ }
153
188
 
154
189
  }
155
190
 
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A sphere of rings of latitude and meridians of longitude, centred on the origin with its poles on
3
+ * the Y axis. The texture coordinates are equirectangular: `u` runs once around the axis and `v`
4
+ * from the south pole (0) to the north pole (1).
5
+ *
6
+ * The two angular intervals cut a partial sphere: `phi` turns about the Y axis and `theta` runs
7
+ * down from the north pole, so a `thetaLength` of `Math.PI / 2` is a dome.
8
+ *
9
+ * @param {number} [radius]
10
+ * @param {number} [widthSegments] segments around the axis, at least 3
11
+ * @param {number} [heightSegments] segments from pole to pole, at least 2
12
+ * @param {number} [phiStart]
13
+ * @param {number} [phiLength] how much of the turn about the axis to build, in radians
14
+ * @param {number} [thetaStart] where to start, in radians down from the north pole
15
+ * @param {number} [thetaLength] how far toward the south pole to build, in radians; stops at the pole
16
+ * @returns {Geometry}
17
+ */
18
+ export function make_uv_sphere_geometry(radius?: number, widthSegments?: number, heightSegments?: number, phiStart?: number, phiLength?: number, thetaStart?: number, thetaLength?: number): Geometry;
19
+ import { Geometry } from "../Geometry.js";
20
+ //# sourceMappingURL=make_uv_sphere_geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make_uv_sphere_geometry.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;GAgBG;AACH,iDATW,MAAM,kBACN,MAAM,mBACN,MAAM,aACN,MAAM,cACN,MAAM,eACN,MAAM,gBACN,MAAM,GACJ,QAAQ,CAkKpB;yBA5LwB,gBAAgB"}
@@ -0,0 +1,190 @@
1
+ import { Attribute } from "../Attribute.js";
2
+ import { Geometry } from "../Geometry.js";
3
+ import { StandardAttributes } from "../StandardAttributes.js";
4
+
5
+ /**
6
+ * How far short of `Math.PI`, in radians, a theta interval may end and still close at the south
7
+ * pole: four ulps of pi, room for the rounding of a sum of two or three rounded angles.
8
+ *
9
+ * @type {number}
10
+ */
11
+ const SOUTH_POLE_TOLERANCE = 8 * Number.EPSILON;
12
+
13
+ /**
14
+ * A sphere of rings of latitude and meridians of longitude, centred on the origin with its poles on
15
+ * the Y axis. The texture coordinates are equirectangular: `u` runs once around the axis and `v`
16
+ * from the south pole (0) to the north pole (1).
17
+ *
18
+ * The two angular intervals cut a partial sphere: `phi` turns about the Y axis and `theta` runs
19
+ * down from the north pole, so a `thetaLength` of `Math.PI / 2` is a dome.
20
+ *
21
+ * @param {number} [radius]
22
+ * @param {number} [widthSegments] segments around the axis, at least 3
23
+ * @param {number} [heightSegments] segments from pole to pole, at least 2
24
+ * @param {number} [phiStart]
25
+ * @param {number} [phiLength] how much of the turn about the axis to build, in radians
26
+ * @param {number} [thetaStart] where to start, in radians down from the north pole
27
+ * @param {number} [thetaLength] how far toward the south pole to build, in radians; stops at the pole
28
+ * @returns {Geometry}
29
+ */
30
+ export function make_uv_sphere_geometry(
31
+ radius = 1,
32
+ widthSegments = 32,
33
+ heightSegments = 16,
34
+ phiStart = 0,
35
+ phiLength = Math.PI * 2,
36
+ thetaStart = 0,
37
+ thetaLength = Math.PI
38
+ ) {
39
+
40
+ /*
41
+ A port of three's `SphereGeometry` onto `Geometry`: the same parameterisation and the same
42
+ winding, writing meep attributes instead of three ones. It departs at the poles, see below.
43
+
44
+ Derived from three.js (https://github.com/mrdoob/three.js), Copyright (c) 2010-2024 three.js authors, MIT licence.
45
+ */
46
+
47
+ const geo = new Geometry();
48
+
49
+ geo.name = "UVSphere";
50
+
51
+ // segments
52
+
53
+ widthSegments = Math.max(3, Math.floor(widthSegments));
54
+ heightSegments = Math.max(2, Math.floor(heightSegments));
55
+
56
+ // three clamps only its triangle selection to the south pole; clamping the rows too keeps a
57
+ // long `thetaLength` from folding the last band back over the sphere
58
+ let thetaEnd = Math.min(thetaStart + thetaLength, Math.PI);
59
+
60
+ // an interval meant to end at the pole is the sum of two rounded angles, and lands short of
61
+ // `Math.PI` often enough (`Math.PI / 6 + Math.PI / 6 * 5` is an ulp short) that within a few
62
+ // ulps it is taken to mean the pole
63
+ if (Math.PI - thetaEnd <= SOUTH_POLE_TOLERANCE) {
64
+ thetaEnd = Math.PI;
65
+ }
66
+
67
+ // A ring at a pole is a single point. Three's grid still gives it a vertex per meridian, which
68
+ // puts two corners of every polar triangle on the same point. Here a pole holds one vertex per
69
+ // segment, turned to the middle of that segment, and each segment draws just the one triangle
70
+ // that has area. A pole's normal is the axis whichever way it is turned, so only its `u` moves.
71
+ const northPole = thetaStart === 0;
72
+ const southPole = thetaEnd === Math.PI;
73
+
74
+ // buffers
75
+
76
+ const indices = [];
77
+ const vertices = [];
78
+ const normals = [];
79
+ const uvs = [];
80
+
81
+ // helper variables
82
+
83
+ let index = 0;
84
+ const grid = [];
85
+
86
+ // generate vertices, normals and uvs
87
+
88
+ for (let iy = 0; iy <= heightSegments; iy++) {
89
+
90
+ const verticesRow = [];
91
+
92
+ const v = iy / heightSegments;
93
+
94
+ const atNorthPole = iy === 0 && northPole;
95
+ const atSouthPole = iy === heightSegments && southPole;
96
+ const pole = atNorthPole || atSouthPole;
97
+
98
+ // `Math.sin(Math.PI)` is not zero, so a pole is put on the axis rather than computed onto it
99
+
100
+ const theta = thetaStart + v * (thetaEnd - thetaStart);
101
+
102
+ const sinTheta = pole ? 0 : Math.sin(theta);
103
+ const cosTheta = atNorthPole ? 1 : (atSouthPole ? -1 : Math.cos(theta));
104
+
105
+ const rowVertexCount = pole ? widthSegments : widthSegments + 1;
106
+ const uOffset = pole ? 0.5 : 0;
107
+
108
+ for (let ix = 0; ix < rowVertexCount; ix++) {
109
+
110
+ const u = (ix + uOffset) / widthSegments;
111
+
112
+ const phi = phiStart + u * phiLength;
113
+
114
+ // normal, the direction from the centre, which is what the vertex is scaled from; taking
115
+ // it from the angles rather than normalising the vertex keeps it defined at radius zero
116
+
117
+ const normal_x = -Math.cos(phi) * sinTheta;
118
+ const normal_y = cosTheta;
119
+ const normal_z = Math.sin(phi) * sinTheta;
120
+
121
+ normals.push(normal_x, normal_y, normal_z);
122
+
123
+ // vertex
124
+
125
+ vertices.push(radius * normal_x, radius * normal_y, radius * normal_z);
126
+
127
+ // uv
128
+
129
+ uvs.push(u, 1 - v);
130
+
131
+ verticesRow.push(index++);
132
+
133
+ }
134
+
135
+ grid.push(verticesRow);
136
+
137
+ }
138
+
139
+ // indices
140
+
141
+ for (let iy = 0; iy < heightSegments; iy++) {
142
+
143
+ const upper = grid[iy];
144
+ const lower = grid[iy + 1];
145
+
146
+ // at least two segments from pole to pole, so a band never has a pole on both sides
147
+ const upperIsPole = iy === 0 && northPole;
148
+ const lowerIsPole = iy + 1 === heightSegments && southPole;
149
+
150
+ for (let ix = 0; ix < widthSegments; ix++) {
151
+
152
+ if (upperIsPole) {
153
+
154
+ // the segment's pole vertex stands in for both upper corners
155
+
156
+ indices.push(upper[ix], lower[ix], lower[ix + 1]);
157
+
158
+ } else if (lowerIsPole) {
159
+
160
+ // the segment's pole vertex stands in for both lower corners
161
+
162
+ indices.push(upper[ix + 1], upper[ix], lower[ix]);
163
+
164
+ } else {
165
+
166
+ const a = upper[ix + 1];
167
+ const b = upper[ix];
168
+ const c = lower[ix];
169
+ const d = lower[ix + 1];
170
+
171
+ // faces
172
+
173
+ indices.push(a, b, d);
174
+ indices.push(b, c, d);
175
+
176
+ }
177
+
178
+ }
179
+
180
+ }
181
+
182
+ // build geometry
183
+
184
+ geo.index = Attribute.from(new Uint32Array(indices), 1, 'index');
185
+ geo.addAttribute(Attribute.from(new Float32Array(vertices), 3, StandardAttributes.Position));
186
+ geo.addAttribute(Attribute.from(new Float32Array(normals), 3, StandardAttributes.Normal));
187
+ geo.addAttribute(Attribute.from(new Float32Array(uvs), 2, StandardAttributes.TextureCoordinates0));
188
+
189
+ return geo;
190
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"graph_vgeo_expand_instances_to_meshlets.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/geometry/virtual/runtime/graph_vgeo_expand_instances_to_meshlets.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH;IAX+B,KAAK;IACT,YAAY,EAA5B,MAAM;IACU,eAAe,EAA/B,MAAM;IACkB,IAAI;IACO,OAAO;IACb,MAAM;IACjC,MAAM,CA4TlB"}
1
+ {"version":3,"file":"graph_vgeo_expand_instances_to_meshlets.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/geometry/virtual/runtime/graph_vgeo_expand_instances_to_meshlets.js"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH;IAX+B,KAAK;IACT,YAAY,EAA5B,MAAM;IACU,eAAe,EAA/B,MAAM;IACkB,IAAI;IACO,OAAO;IACb,MAAM;IACjC,MAAM,CA6TlB"}
@@ -5,8 +5,12 @@ import {
5
5
  graph_build_indirect_dispatch_command,
6
6
  INDIRECT_COMPUTE_COMMAND_DESCRIPTOR
7
7
  } from "../../../gpu_primitive/indirect/IndirectComputeCommandBuildPass.js";
8
- import { graph_prefix_scan_csdldf } from "../../../gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.js";
8
+ import {
9
+ graph_prefix_scan_csdldf,
10
+ prefix_scan_csdldf_output_descriptor
11
+ } from "../../../gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.js";
9
12
  import { RasterizationCollectionType } from "../../../rasterize/expand/RasterizationCollectionType.js";
13
+ import { graph_create_buffer } from "../../../shader/graph/graph_create_buffer.js";
10
14
  import { shader_vgeo_cut_collect } from "./cut/shader_vgeo_cut_collect.js";
11
15
  import { shader_vgeo_cut_queue_prepare } from "./cut/shader_vgeo_cut_queue_prepare.js";
12
16
  import { shader_vgeo_cut_queue_remainder } from "./cut/shader_vgeo_cut_queue_remainder.js";
@@ -186,7 +190,8 @@ export function graph_vgeo_expand_instances_to_meshlets({
186
190
  */
187
191
  const prefix_sums = graph_prefix_scan_csdldf({
188
192
  graph,
189
- data: collect_data.claim_widths,
193
+ input: collect_data.claim_widths,
194
+ output: graph_create_buffer(graph, "vg claim offsets", prefix_scan_csdldf_output_descriptor(instance_capacity)),
190
195
  element_max_count: instance_capacity,
191
196
  });
192
197
 
@@ -1,25 +1,43 @@
1
+ /**
2
+ * A transient {@link graph_prefix_scan_csdldf} output for up to `element_max_count` elements: the count, padded to 16
3
+ * bytes, then the sums in whole vec4 blocks. The scan writes the count itself, so nothing needs clearing.
4
+ *
5
+ * @param {number} element_max_count
6
+ * @returns {BufferResourceDescriptor}
7
+ */
8
+ export function prefix_scan_csdldf_output_descriptor(element_max_count: number): BufferResourceDescriptor;
1
9
  /**
2
10
  * Indirect pass.
3
- * Input data is expected to be counts in form:
11
+ * Inclusive prefix sums of `input` into `output`.
12
+ * Both are expected in the form:
4
13
  * ```wgsl
5
14
  * struct InputData{
6
15
  * count:u32,
7
16
  * elements: array<u32> // counts: [count0, count1, count2, ... countN-1]
8
17
  * }
9
18
  * ```
10
- * Data is modified in-place, elements are replaced with prefix sums.
11
- * Make sure to set `element_max_count` to be at least equal to the number of elements in the input, otherwise an incomplete scan will be performed.
12
- * The penalty for `element_max_count` being too big is fairly small, requiring more memory for the pass and a larger `bufferClear` region.
19
+ * `output` receives the input's count and, for each of its elements, the sum of the elements up to and including it.
20
+ * `input` is never written: the scan's fallback re-reads a tile's inputs while other tiles are writing their sums, so
21
+ * the two cannot be one buffer.
22
+ *
23
+ * The work follows the input's count, read on the device; `element_max_count` sizes only the memory — the spine, and
24
+ * what `output` must hold — so make it at least the most elements the input can carry, otherwise an incomplete scan will
25
+ * be performed. Where a count records demand and runs past a soft limit — a culled collection does — that is what the
26
+ * buffer holds, not the limit. The penalty for `element_max_count` being too big is fairly small: a larger spine to clear.
13
27
  *
14
28
  * @param {Object} options
15
29
  * @param {FrameGraph} options.graph
16
- * @param {number} options.data buffer resource ID, array<u32> first position must be "count". The buffer must be 16-byte aligned.
30
+ * @param {number} options.input buffer resource ID, array<u32> first position must be "count". The buffer must be 16-byte aligned.
31
+ * @param {number} options.output buffer resource ID of the same layout, at least `16 + ⌈element_max_count / 4⌉ · 16` bytes;
32
+ * see {@link prefix_scan_csdldf_output_descriptor}
17
33
  * @param {number} [options.element_max_count=1,048,576] how many elements might be in the input, this is a limit
18
- * @returns {number} buffer resource ID with prefix sums, this is rewritten input. The first position (count) is untouched.
34
+ * @returns {number} buffer resource ID of the written output
19
35
  */
20
- export function graph_prefix_scan_csdldf({ graph, data, element_max_count, }: {
36
+ export function graph_prefix_scan_csdldf({ graph, input, output, element_max_count, }: {
21
37
  graph: FrameGraph;
22
- data: number;
38
+ input: number;
39
+ output: number;
23
40
  element_max_count?: number;
24
41
  }): number;
42
+ import { BufferResourceDescriptor } from "../../../../device/graph/BufferResourceDescriptor.js";
25
43
  //# sourceMappingURL=graph_prefix_scan_csdldf.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"graph_prefix_scan_csdldf.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;GAkBG;AACH;IAL+B,KAAK;IACT,IAAI,EAApB,MAAM;IACW,iBAAiB,GAAlC,MAAM;IACJ,MAAM,CAgFlB"}
1
+ {"version":3,"file":"graph_prefix_scan_csdldf.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.js"],"names":[],"mappings":"AAeA;;;;;;GAMG;AACH,wEAHW,MAAM,GACJ,wBAAwB,CAMpC;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH;IAP+B,KAAK;IACT,KAAK,EAArB,MAAM;IACU,MAAM,EAAtB,MAAM;IAEW,iBAAiB,GAAlC,MAAM;IACJ,MAAM,CAwElB;yCA3HwC,sDAAsD"}
@@ -3,51 +3,74 @@ import { round_up } from "../../../../../core/math/round_up.js";
3
3
  import { warn_limited } from "../../../../util/warn_limited.js";
4
4
  import { BufferResourceDescriptor } from "../../../../device/graph/BufferResourceDescriptor.js";
5
5
  import { u32 } from "../../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
6
+ import { INDIRECT_COMPUTE_COMMAND_DESCRIPTOR } from "../../indirect/IndirectComputeCommandBuildPass.js";
6
7
  import {
7
- build_indirect_compute_dispatch_command,
8
- INDIRECT_COMPUTE_COMMAND_DESCRIPTOR
9
- } from "../../indirect/IndirectComputeCommandBuildPass.js";
10
- import { PREFIX_SCAN_CSDLDF_PARTITION_SIZE, shader_prefix_scan_csdldf } from "./shader_prefix_scan_csdldf.js";
8
+ WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION
9
+ } from "../../indirect/WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION.js";
10
+ import {
11
+ PREFIX_SCAN_CSDLDF_PARTITION_SIZE,
12
+ shader_prefix_scan_csdldf,
13
+ shader_prefix_scan_csdldf_prepare
14
+ } from "./shader_prefix_scan_csdldf.js";
15
+
16
+ /**
17
+ * A transient {@link graph_prefix_scan_csdldf} output for up to `element_max_count` elements: the count, padded to 16
18
+ * bytes, then the sums in whole vec4 blocks. The scan writes the count itself, so nothing needs clearing.
19
+ *
20
+ * @param {number} element_max_count
21
+ * @returns {BufferResourceDescriptor}
22
+ */
23
+ export function prefix_scan_csdldf_output_descriptor(element_max_count) {
24
+ assert.isNonNegativeInteger(element_max_count, 'element_max_count');
25
+
26
+ return BufferResourceDescriptor.from(16 + Math.max(1, Math.ceil(element_max_count / 4)) * 16, GPUBufferUsage.STORAGE);
27
+ }
11
28
 
12
29
 
13
30
  /**
14
31
  * Indirect pass.
15
- * Input data is expected to be counts in form:
32
+ * Inclusive prefix sums of `input` into `output`.
33
+ * Both are expected in the form:
16
34
  * ```wgsl
17
35
  * struct InputData{
18
36
  * count:u32,
19
37
  * elements: array<u32> // counts: [count0, count1, count2, ... countN-1]
20
38
  * }
21
39
  * ```
22
- * Data is modified in-place, elements are replaced with prefix sums.
23
- * Make sure to set `element_max_count` to be at least equal to the number of elements in the input, otherwise an incomplete scan will be performed.
24
- * The penalty for `element_max_count` being too big is fairly small, requiring more memory for the pass and a larger `bufferClear` region.
40
+ * `output` receives the input's count and, for each of its elements, the sum of the elements up to and including it.
41
+ * `input` is never written: the scan's fallback re-reads a tile's inputs while other tiles are writing their sums, so
42
+ * the two cannot be one buffer.
43
+ *
44
+ * The work follows the input's count, read on the device; `element_max_count` sizes only the memory — the spine, and
45
+ * what `output` must hold — so make it at least the most elements the input can carry, otherwise an incomplete scan will
46
+ * be performed. Where a count records demand and runs past a soft limit — a culled collection does — that is what the
47
+ * buffer holds, not the limit. The penalty for `element_max_count` being too big is fairly small: a larger spine to clear.
25
48
  *
26
49
  * @param {Object} options
27
50
  * @param {FrameGraph} options.graph
28
- * @param {number} options.data buffer resource ID, array<u32> first position must be "count". The buffer must be 16-byte aligned.
51
+ * @param {number} options.input buffer resource ID, array<u32> first position must be "count". The buffer must be 16-byte aligned.
52
+ * @param {number} options.output buffer resource ID of the same layout, at least `16 + ⌈element_max_count / 4⌉ · 16` bytes;
53
+ * see {@link prefix_scan_csdldf_output_descriptor}
29
54
  * @param {number} [options.element_max_count=1,048,576] how many elements might be in the input, this is a limit
30
- * @returns {number} buffer resource ID with prefix sums, this is rewritten input. The first position (count) is untouched.
55
+ * @returns {number} buffer resource ID of the written output
31
56
  */
32
57
  export function graph_prefix_scan_csdldf({
33
58
  graph,
34
- data,
59
+ input,
60
+ output,
35
61
  element_max_count = 1048576,
36
62
  }) {
37
63
 
38
64
  assert.isNonNegativeInteger(element_max_count, 'element_max_count');
39
65
 
40
- if (element_max_count <= 0) {
41
- console.warn("element_max_count <= 0, returning input");
42
-
43
- return data;
44
- }
45
-
46
66
  // TODO run a special prefix scan if element_max_count fits into a single group
47
67
 
48
-
49
68
  const group_count = Math.ceil(element_max_count / PREFIX_SCAN_CSDLDF_PARTITION_SIZE);
50
69
 
70
+ if (group_count > WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION) {
71
+ warn_limited(`group_count(=${group_count} > MAX_DISPATCH_SIZE(=${WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION}). Prefix scan likely incomplete`);
72
+ }
73
+
51
74
  const pass_data = {};
52
75
 
53
76
  /**
@@ -58,41 +81,35 @@ export function graph_prefix_scan_csdldf({
58
81
  */
59
82
  function execute(pass_data, resources, context) {
60
83
 
61
- const data = resources.get(pass_data.data);
62
- const partition_descriptor_buffer = resources.get(pass_data.partition_descriptor_buffer);
63
- const command = resources.get(pass_data.command);
64
-
65
84
  const encoder = context.encoder;
66
85
 
67
- const MAX_DISPATCH_SIZE = encoder.device.limits.maxComputeWorkgroupsPerDimension;
86
+ const scan_in = resources.get(pass_data.input);
87
+ const scan_out = resources.get(pass_data.output);
88
+ const command = resources.get(pass_data.command);
68
89
 
69
- if (group_count > MAX_DISPATCH_SIZE) {
70
- warn_limited(`group_count(=${group_count} > MAX_DISPATCH_SIZE(=${MAX_DISPATCH_SIZE}). Prefix scan likely incomplete`);
71
- }
90
+ assert.notEqual(scan_in, scan_out, 'input and output must be different buffers');
91
+ assert.greaterThanOrEqual(scan_out.size, 16 + Math.ceil(element_max_count / 4) * 16, 'output is too small for element_max_count');
72
92
 
73
- build_indirect_compute_dispatch_command(
74
- PREFIX_SCAN_CSDLDF_PARTITION_SIZE,
93
+ shader_prefix_scan_csdldf_prepare.dispatch({
75
94
  encoder,
76
- data,
77
- 0,
78
- command,
79
- 0,
80
- );
95
+ bindings: { scan_in, scan_out, command },
96
+ });
81
97
 
82
98
  shader_prefix_scan_csdldf.dispatchIndirect({
83
99
  encoder,
84
100
  command,
85
101
  bindings: {
86
- scan_in: data,
87
- spine: partition_descriptor_buffer,
102
+ scan_in,
103
+ scan_out,
104
+ spine: resources.get(pass_data.partition_descriptor_buffer),
88
105
  }
89
106
  });
90
107
  }
91
108
 
92
109
  const pass = graph.add("prefix sum", pass_data, execute);
93
110
 
94
- pass.read(data);
95
- pass_data.data = pass.write(data);
111
+ pass_data.input = pass.read(input);
112
+ pass_data.output = pass.write(pass.read(output));
96
113
 
97
114
  pass_data.command = pass.create("command", INDIRECT_COMPUTE_COMMAND_DESCRIPTOR);
98
115
 
@@ -106,5 +123,5 @@ export function graph_prefix_scan_csdldf({
106
123
  )
107
124
  );
108
125
 
109
- return pass_data.data;
110
- }
126
+ return pass_data.output;
127
+ }
@@ -23,5 +23,12 @@ export const PREFIX_SCAN_CSDLDF_HEADER_WORDS: number;
23
23
  * @type {ComputeShader}
24
24
  */
25
25
  export const shader_prefix_scan_csdldf: ComputeShader;
26
+ /**
27
+ * One thread ahead of {@link shader_prefix_scan_csdldf}: the scan's dispatch, a workgroup per partition of the input's
28
+ * count, and the output's count. The output gets its count here rather than from the scan's first tile because an input
29
+ * of no elements dispatches no tile at all.
30
+ * @type {ComputeShader}
31
+ */
32
+ export const shader_prefix_scan_csdldf_prepare: ComputeShader;
26
33
  import { ComputeShader } from "../../../shader/ComputeShader.js";
27
34
  //# sourceMappingURL=shader_prefix_scan_csdldf.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shader_prefix_scan_csdldf.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.js"],"names":[],"mappings":"AASA;;;;GAIG;AACH,gDAFU,MAAM,CAEsC;AAOtD;;;;;;;;;;GAUG;AACH,8CAFU,MAAM,CAE6E;AA0S7F;;;;;GAKG;AACH,wCAFU,aAAa,CAMpB;8BA9U2B,kCAAkC"}
1
+ {"version":3,"file":"shader_prefix_scan_csdldf.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.js"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,gDAFU,MAAM,CAEsC;AAOtD;;;;;;;;;;GAUG;AACH,8CAFU,MAAM,CAE6E;AAmT7F;;;;;GAKG;AACH,wCAFU,aAAa,CAMpB;AAQH;;;;;GAKG;AACH,gDAFU,aAAa,CAkBpB;8BArX2B,kCAAkC"}