@woosh/meep-engine 3.69.0 → 3.70.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 (398) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/build/bundle-worker-terrain.js +1 -1
  3. package/package.json +1 -1
  4. package/src/core/bvh8/build/BVH8Converter.d.ts +16 -0
  5. package/src/core/bvh8/build/BVH8Converter.d.ts.map +1 -1
  6. package/src/core/bvh8/build/BVH8Converter.js +64 -37
  7. package/src/core/bvh8/build/bvh8_assign_slots_greedy.d.ts +25 -0
  8. package/src/core/bvh8/build/bvh8_assign_slots_greedy.d.ts.map +1 -0
  9. package/src/core/bvh8/build/bvh8_assign_slots_greedy.js +68 -0
  10. package/src/core/bvh8/build/bvh8_from_proxy.d.ts.map +1 -1
  11. package/src/core/bvh8/build/bvh8_from_proxy.js +2 -33
  12. package/src/core/bvh8/build/bvh8_node_fit_slots.d.ts +22 -0
  13. package/src/core/bvh8/build/bvh8_node_fit_slots.d.ts.map +1 -0
  14. package/src/core/bvh8/build/bvh8_node_fit_slots.js +115 -0
  15. package/src/core/bvh8/bvh8_depth.d.ts +8 -0
  16. package/src/core/bvh8/bvh8_depth.d.ts.map +1 -0
  17. package/src/core/bvh8/bvh8_depth.js +39 -0
  18. package/src/core/math/complex/complex_fft_radix2.d.ts +19 -0
  19. package/src/core/math/complex/complex_fft_radix2.d.ts.map +1 -0
  20. package/src/core/math/complex/complex_fft_radix2.js +71 -0
  21. package/src/engine/graphics3/GPUFluidSystem.d.ts +17 -4
  22. package/src/engine/graphics3/GPUFluidSystem.d.ts.map +1 -1
  23. package/src/engine/graphics3/GPUFluidSystem.js +113 -16
  24. package/src/engine/physics/cloth/playground/wind_main.js +7 -6
  25. package/src/engine/physics/cloth/wind/AbstractClothWind.d.ts +2 -2
  26. package/src/engine/physics/cloth/wind/AbstractClothWind.js +2 -2
  27. package/src/engine/physics/cloth/wind/ClothFluidWind.d.ts +3 -3
  28. package/src/engine/physics/cloth/wind/ClothFluidWind.d.ts.map +1 -1
  29. package/src/engine/physics/cloth/wind/ClothFluidWind.js +7 -9
  30. package/src/engine/physics/cloth/wind/ClothGPUFluidWind.d.ts +10 -10
  31. package/src/engine/physics/cloth/wind/ClothGPUFluidWind.d.ts.map +1 -1
  32. package/src/engine/physics/cloth/wind/ClothGPUFluidWind.js +14 -22
  33. package/src/engine/physics/fluid/FluidAtmosphere.d.ts +16 -2
  34. package/src/engine/physics/fluid/FluidAtmosphere.d.ts.map +1 -1
  35. package/src/engine/physics/fluid/FluidAtmosphere.js +17 -3
  36. package/src/engine/physics/fluid/ecs/FluidEffectorsComponentSerializationAdapter.d.ts +1 -2
  37. package/src/engine/physics/fluid/ecs/FluidEffectorsComponentSerializationAdapter.d.ts.map +1 -1
  38. package/src/engine/physics/fluid/ecs/FluidEffectorsComponentSerializationAdapter.js +1 -2
  39. package/src/engine/physics/fluid/ecs/FluidEffectorsSystem.d.ts +8 -5
  40. package/src/engine/physics/fluid/ecs/FluidEffectorsSystem.d.ts.map +1 -1
  41. package/src/engine/physics/fluid/ecs/FluidEffectorsSystem.js +60 -17
  42. package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts +1 -1
  43. package/src/engine/physics/fluid/effector/AbstractFluidEffector.js +1 -1
  44. package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts +33 -47
  45. package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts.map +1 -1
  46. package/src/engine/physics/fluid/effector/GlobalFluidEffector.js +38 -176
  47. package/src/engine/physics/fluid/effector/GlobalFluidEffectorSerializationAdapter.d.ts +8 -11
  48. package/src/engine/physics/fluid/effector/GlobalFluidEffectorSerializationAdapter.d.ts.map +1 -1
  49. package/src/engine/physics/fluid/effector/GlobalFluidEffectorSerializationAdapter.js +13 -24
  50. package/src/engine/physics/fluid/effector/GlobalFluidEffectorSerializationUpgrader_0_1.d.ts +16 -0
  51. package/src/engine/physics/fluid/effector/GlobalFluidEffectorSerializationUpgrader_0_1.d.ts.map +1 -0
  52. package/src/engine/physics/fluid/effector/GlobalFluidEffectorSerializationUpgrader_0_1.js +35 -0
  53. package/src/engine/physics/fluid/fluid_apply_atmosphere.d.ts +1 -1
  54. package/src/engine/physics/fluid/fluid_apply_atmosphere.js +1 -1
  55. package/src/engine/physics/fluid/turbulence/FLUID_TURBULENCE_TILE.d.ts +28 -0
  56. package/src/engine/physics/fluid/turbulence/FLUID_TURBULENCE_TILE.d.ts.map +1 -0
  57. package/src/engine/physics/fluid/turbulence/FLUID_TURBULENCE_TILE.js +29 -0
  58. package/src/engine/physics/fluid/turbulence/fluid_atmosphere_velocity_at.d.ts +16 -0
  59. package/src/engine/physics/fluid/turbulence/fluid_atmosphere_velocity_at.d.ts.map +1 -0
  60. package/src/engine/physics/fluid/turbulence/fluid_atmosphere_velocity_at.js +49 -0
  61. package/src/engine/physics/fluid/turbulence/fluid_turbulence_inverse_tile_size.d.ts +11 -0
  62. package/src/engine/physics/fluid/turbulence/fluid_turbulence_inverse_tile_size.d.ts.map +1 -0
  63. package/src/engine/physics/fluid/turbulence/fluid_turbulence_inverse_tile_size.js +18 -0
  64. package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_data.d.ts +25 -0
  65. package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_data.d.ts.map +1 -0
  66. package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_data.js +65 -0
  67. package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_generate.d.ts +56 -0
  68. package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_generate.d.ts.map +1 -0
  69. package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_generate.js +313 -0
  70. package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_sample.d.ts +16 -0
  71. package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_sample.d.ts.map +1 -0
  72. package/src/engine/physics/fluid/turbulence/fluid_turbulence_tile_sample.js +69 -0
  73. package/src/generation/foliage/mesh/branch_ring_triangulate.d.ts +1 -1
  74. package/src/generation/foliage/mesh/branch_ring_triangulate.js +1 -1
  75. package/src/shade/playground/bvh_repro/README.md +8 -6
  76. package/src/shade/playground/bvh_repro/index.html +125 -124
  77. package/src/shade/playground/bvh_repro/main.js +259 -254
  78. package/src/shade/playground/foliage_wind/foliage_world.d.ts.map +1 -1
  79. package/src/shade/playground/foliage_wind/foliage_world.js +7 -4
  80. package/src/shade/playground/grass_surfaces/main.js +3 -2
  81. package/src/shade/playground/particle_ecs/bonfire_wind.d.ts +23 -13
  82. package/src/shade/playground/particle_ecs/bonfire_wind.d.ts.map +1 -1
  83. package/src/shade/playground/particle_ecs/bonfire_wind.js +30 -33
  84. package/src/shade/playground/skinned_blas_refit/README.md +26 -14
  85. package/src/shade/playground/skinned_blas_refit/shader_blas_audit_leaf_triangles.d.ts +14 -9
  86. package/src/shade/playground/skinned_blas_refit/shader_blas_audit_leaf_triangles.d.ts.map +1 -1
  87. package/src/shade/playground/skinned_blas_refit/shader_blas_audit_leaf_triangles.js +126 -127
  88. package/src/shade/playground/skinned_blas_refit/shader_blas_audit_points.js +95 -95
  89. package/src/shade/playground/skinned_blas_refit/shader_blas_audit_visibility.d.ts +9 -1
  90. package/src/shade/playground/skinned_blas_refit/shader_blas_audit_visibility.d.ts.map +1 -1
  91. package/src/shade/playground/skinned_blas_refit/shader_blas_audit_visibility.js +146 -135
  92. package/src/shade/playground/skinned_blas_refit/verify_clone_leaves.d.ts +6 -6
  93. package/src/shade/playground/skinned_blas_refit/verify_clone_leaves.d.ts.map +1 -1
  94. package/src/shade/playground/skinned_blas_refit/verify_clone_leaves.js +148 -134
  95. package/src/shade/playground/skinned_blas_refit/verify_leaf_triangles.d.ts +11 -8
  96. package/src/shade/playground/skinned_blas_refit/verify_leaf_triangles.d.ts.map +1 -1
  97. package/src/shade/playground/skinned_blas_refit/verify_leaf_triangles.js +342 -202
  98. package/src/shade/playground/skinned_blas_refit/verify_skinned_blas_refit.d.ts +12 -13
  99. package/src/shade/playground/skinned_blas_refit/verify_skinned_blas_refit.d.ts.map +1 -1
  100. package/src/shade/playground/skinned_blas_refit/verify_skinned_blas_refit.js +136 -116
  101. package/src/shade/playground/skinned_blas_refit/verify_traversal_reachability.d.ts +4 -4
  102. package/src/shade/playground/skinned_blas_refit/verify_traversal_reachability.d.ts.map +1 -1
  103. package/src/shade/playground/skinned_blas_refit/verify_traversal_reachability.js +255 -249
  104. package/src/shade/playground/water_surface/main.js +6 -3
  105. package/src/shade/renderer/animation/GPUAnimationManager.js +2 -2
  106. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts.map +1 -1
  107. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.js +7 -8
  108. package/src/shade/renderer/fluid/FLUID_FAR_FIELD_STRUCT.d.ts +111 -0
  109. package/src/shade/renderer/fluid/FLUID_FAR_FIELD_STRUCT.d.ts.map +1 -0
  110. package/src/shade/renderer/fluid/FLUID_FAR_FIELD_STRUCT.js +162 -0
  111. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +37 -8
  112. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts.map +1 -1
  113. package/src/shade/renderer/fluid/GPUFluidCascade.js +149 -47
  114. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +10 -3
  115. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts.map +1 -1
  116. package/src/shade/renderer/fluid/GPUFluidCascadeStack.js +69 -10
  117. package/src/shade/renderer/fluid/chunk_fluid_far_field.d.ts +19 -0
  118. package/src/shade/renderer/fluid/chunk_fluid_far_field.d.ts.map +1 -0
  119. package/src/shade/renderer/fluid/chunk_fluid_far_field.js +43 -0
  120. package/src/shade/renderer/fluid/coupling/FLUID_CASCADE_PARENT_STRUCT.d.ts +10 -9
  121. package/src/shade/renderer/fluid/coupling/FLUID_CASCADE_PARENT_STRUCT.d.ts.map +1 -1
  122. package/src/shade/renderer/fluid/coupling/FLUID_CASCADE_PARENT_STRUCT.js +14 -12
  123. package/src/shade/renderer/fluid/coupling/FLUID_CASCADE_RESTRICT_STRUCT.d.ts +3 -2
  124. package/src/shade/renderer/fluid/coupling/FLUID_CASCADE_RESTRICT_STRUCT.d.ts.map +1 -1
  125. package/src/shade/renderer/fluid/coupling/FLUID_CASCADE_RESTRICT_STRUCT.js +7 -5
  126. package/src/shade/renderer/fluid/coupling/chunk_fluid_cascade_epilogue.d.ts +17 -9
  127. package/src/shade/renderer/fluid/coupling/chunk_fluid_cascade_epilogue.d.ts.map +1 -1
  128. package/src/shade/renderer/fluid/coupling/chunk_fluid_cascade_epilogue.js +58 -18
  129. package/src/shade/renderer/fluid/coupling/chunk_fluid_cascade_parent.d.ts +23 -11
  130. package/src/shade/renderer/fluid/coupling/chunk_fluid_cascade_parent.d.ts.map +1 -1
  131. package/src/shade/renderer/fluid/coupling/chunk_fluid_cascade_parent.js +371 -335
  132. package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_fill.d.ts.map +1 -1
  133. package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_fill.js +2 -1
  134. package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_ghosts.d.ts.map +1 -1
  135. package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_ghosts.js +109 -108
  136. package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_restrict.d.ts +5 -3
  137. package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_restrict.d.ts.map +1 -1
  138. package/src/shade/renderer/fluid/coupling/shader_fluid_cascade_restrict.js +24 -12
  139. package/src/shade/renderer/fluid/mac/FLUID_MAC_STEP_STRUCT.d.ts +6 -2
  140. package/src/shade/renderer/fluid/mac/FLUID_MAC_STEP_STRUCT.d.ts.map +1 -1
  141. package/src/shade/renderer/fluid/mac/FLUID_MAC_STEP_STRUCT.js +10 -5
  142. package/src/shade/renderer/fluid/mac/FluidMacPasses.d.ts +20 -21
  143. package/src/shade/renderer/fluid/mac/FluidMacPasses.d.ts.map +1 -1
  144. package/src/shade/renderer/fluid/mac/FluidMacPasses.js +453 -427
  145. package/src/shade/renderer/fluid/mac/shader_fluid_mac_advect_correct.d.ts.map +1 -1
  146. package/src/shade/renderer/fluid/mac/shader_fluid_mac_advect_correct.js +2 -1
  147. package/src/shade/renderer/fluid/publish/FluidWindPublish.d.ts +13 -5
  148. package/src/shade/renderer/fluid/publish/FluidWindPublish.d.ts.map +1 -1
  149. package/src/shade/renderer/fluid/publish/FluidWindPublish.js +20 -10
  150. package/src/shade/renderer/fluid/publish/chunk_fluid_wind_publish_cell.d.ts +2 -2
  151. package/src/shade/renderer/fluid/publish/chunk_fluid_wind_publish_cell.js +2 -2
  152. package/src/shade/renderer/fluid/publish/shader_fluid_wind_publish.d.ts +5 -3
  153. package/src/shade/renderer/fluid/publish/shader_fluid_wind_publish.d.ts.map +1 -1
  154. package/src/shade/renderer/fluid/publish/shader_fluid_wind_publish.js +147 -142
  155. package/src/shade/renderer/fluid/query/GPUFluidQueries.js +2 -2
  156. package/src/shade/renderer/geometry/GPUGeometryManager.d.ts.map +1 -1
  157. package/src/shade/renderer/geometry/GPUGeometryManager.js +5 -7
  158. package/src/shade/renderer/geometry/MeshletGeometry.d.ts +4 -1
  159. package/src/shade/renderer/geometry/MeshletGeometry.d.ts.map +1 -1
  160. package/src/shade/renderer/geometry/MeshletGeometry.js +4 -1
  161. package/src/shade/renderer/geometry/MeshletGeometrySerializationAdapter.d.ts +20 -0
  162. package/src/shade/renderer/geometry/MeshletGeometrySerializationAdapter.d.ts.map +1 -1
  163. package/src/shade/renderer/geometry/MeshletGeometrySerializationAdapter.js +35 -3
  164. package/src/shade/renderer/geometry/blas_from_meshlets.d.ts +9 -3
  165. package/src/shade/renderer/geometry/blas_from_meshlets.d.ts.map +1 -1
  166. package/src/shade/renderer/geometry/blas_from_meshlets.js +16 -30
  167. package/src/shade/renderer/geometry/bvh/BLAS8_REFIT_TARGET_STRUCT.d.ts +14 -0
  168. package/src/shade/renderer/geometry/bvh/BLAS8_REFIT_TARGET_STRUCT.d.ts.map +1 -0
  169. package/src/shade/renderer/geometry/bvh/BLAS8_REFIT_TARGET_STRUCT.js +33 -0
  170. package/src/shade/renderer/geometry/bvh/GPUBLASRefitBatch.d.ts +18 -21
  171. package/src/shade/renderer/geometry/bvh/GPUBLASRefitBatch.d.ts.map +1 -1
  172. package/src/shade/renderer/geometry/bvh/GPUBLASRefitBatch.js +78 -158
  173. package/src/shade/renderer/geometry/bvh/GPUGeometryBVHManager.d.ts +18 -39
  174. package/src/shade/renderer/geometry/bvh/GPUGeometryBVHManager.d.ts.map +1 -1
  175. package/src/shade/renderer/geometry/bvh/GPUGeometryBVHManager.js +39 -398
  176. package/src/shade/renderer/geometry/bvh/GPUGeometryMeshletsBVH.d.ts +6 -7
  177. package/src/shade/renderer/geometry/bvh/GPUGeometryMeshletsBVH.d.ts.map +1 -1
  178. package/src/shade/renderer/geometry/bvh/GPUGeometryMeshletsBVH.js +5 -7
  179. package/src/shade/renderer/geometry/bvh/bvh8_build_for_meshlets.d.ts +36 -0
  180. package/src/shade/renderer/geometry/bvh/bvh8_build_for_meshlets.d.ts.map +1 -0
  181. package/src/shade/renderer/geometry/bvh/bvh8_build_for_meshlets.js +179 -0
  182. package/src/shade/renderer/geometry/bvh/meshlet_batch_to_clustered_bvh.d.ts +30 -0
  183. package/src/shade/renderer/geometry/bvh/meshlet_batch_to_clustered_bvh.d.ts.map +1 -0
  184. package/src/shade/renderer/geometry/bvh/meshlet_batch_to_clustered_bvh.js +207 -0
  185. package/src/shade/renderer/geometry/bvh/shader_blas8_refit_batch.d.ts +52 -0
  186. package/src/shade/renderer/geometry/bvh/shader_blas8_refit_batch.d.ts.map +1 -0
  187. package/src/shade/renderer/geometry/bvh/shader_blas8_refit_batch.js +464 -0
  188. package/src/shade/renderer/geometry/meshlet/MeshletBatch.d.ts +12 -0
  189. package/src/shade/renderer/geometry/meshlet/MeshletBatch.d.ts.map +1 -1
  190. package/src/shade/renderer/geometry/meshlet/MeshletBatch.js +37 -0
  191. package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_classify.d.ts.map +1 -1
  192. package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_classify.js +4 -4
  193. package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_evaluate.d.ts.map +1 -1
  194. package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_evaluate.js +2 -2
  195. package/src/shade/renderer/geometry/sdf/chunk_blas_query_band_sdf.d.ts.map +1 -1
  196. package/src/shade/renderer/geometry/sdf/chunk_blas_query_band_sdf.js +2 -2
  197. package/src/shade/renderer/geometry/sdf/shader_sdf_visualize.d.ts.map +1 -1
  198. package/src/shade/renderer/geometry/sdf/shader_sdf_visualize.js +4 -4
  199. package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_trace.d.ts.map +1 -1
  200. package/src/shade/renderer/geometry/sdf/surface/shader_mesh_surface_trace.js +2 -2
  201. package/src/shade/renderer/geometry/sr_create_group_RTX.d.ts.map +1 -1
  202. package/src/shade/renderer/geometry/sr_create_group_RTX.js +4 -4
  203. package/src/shade/renderer/global_illumination/brick4/gpu/bake/brick4_bake_basic.d.ts.map +1 -1
  204. package/src/shade/renderer/global_illumination/brick4/gpu/bake/brick4_bake_basic.js +1 -0
  205. package/src/shade/renderer/global_illumination/lpv/bake/GPULightProbeVolumeRenderer.d.ts.map +1 -1
  206. package/src/shade/renderer/global_illumination/lpv/bake/GPULightProbeVolumeRenderer.js +1 -0
  207. package/src/shade/renderer/global_illumination/lpv/placement/graph_generate_probe_locations.d.ts.map +1 -1
  208. package/src/shade/renderer/global_illumination/lpv/placement/graph_generate_probe_locations.js +372 -376
  209. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK.d.ts +9 -10
  210. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK.d.ts.map +1 -1
  211. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK.js +10 -11
  212. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.d.ts +2 -2
  213. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.js +2 -2
  214. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.d.ts +12 -8
  215. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.d.ts.map +1 -1
  216. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.js +109 -60
  217. package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_mesh_sdf.js +2 -2
  218. package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_mesh_surfaces.js +2 -2
  219. package/src/shade/renderer/gpu_primitive/bvh/BVH_BUFFER_LAYOUT.d.ts +2 -2
  220. package/src/shade/renderer/gpu_primitive/bvh/BVH_BUFFER_LAYOUT.js +70 -70
  221. package/src/shade/renderer/gpu_primitive/bvh/BVH_BUILD_SETTINGS_STRUCT.d.ts +6 -7
  222. package/src/shade/renderer/gpu_primitive/bvh/BVH_BUILD_SETTINGS_STRUCT.d.ts.map +1 -1
  223. package/src/shade/renderer/gpu_primitive/bvh/BVH_BUILD_SETTINGS_STRUCT.js +6 -7
  224. package/src/shade/renderer/gpu_primitive/bvh/graph_bvh_build_lbvh.d.ts +3 -3
  225. package/src/shade/renderer/gpu_primitive/bvh/graph_bvh_build_lbvh.js +3 -3
  226. package/src/shade/renderer/gpu_primitive/bvh/shader_bvh_build_single_workgroup.js +1 -1
  227. package/src/shade/renderer/gpu_primitive/bvh/shader_bvh_emit_hierarchy.d.ts +2 -2
  228. package/src/shade/renderer/gpu_primitive/bvh/shader_bvh_emit_hierarchy.js +3 -3
  229. package/src/shade/renderer/gpu_primitive/bvh8/BVH8_TREE_BUFFER_LAYOUT.d.ts +69 -0
  230. package/src/shade/renderer/gpu_primitive/bvh8/BVH8_TREE_BUFFER_LAYOUT.d.ts.map +1 -0
  231. package/src/shade/renderer/gpu_primitive/bvh8/BVH8_TREE_BUFFER_LAYOUT.js +89 -0
  232. package/src/shade/renderer/gpu_primitive/bvh8/bvh8_encode_from_bvh2.d.ts +41 -0
  233. package/src/shade/renderer/gpu_primitive/bvh8/bvh8_encode_from_bvh2.d.ts.map +1 -0
  234. package/src/shade/renderer/gpu_primitive/bvh8/bvh8_encode_from_bvh2.js +348 -0
  235. package/src/shade/renderer/gpu_primitive/bvh8/check_bvh8_tree.d.ts +34 -0
  236. package/src/shade/renderer/gpu_primitive/bvh8/check_bvh8_tree.d.ts.map +1 -0
  237. package/src/shade/renderer/gpu_primitive/bvh8/check_bvh8_tree.js +291 -0
  238. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_assign.d.ts +31 -0
  239. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_assign.d.ts.map +1 -0
  240. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_assign.js +175 -0
  241. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_depth.d.ts +27 -0
  242. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_depth.d.ts.map +1 -0
  243. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_depth.js +48 -0
  244. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_gather.d.ts +26 -0
  245. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_gather.d.ts.map +1 -0
  246. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_gather.js +118 -0
  247. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_node.d.ts +22 -0
  248. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_node.d.ts.map +1 -0
  249. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_node.js +143 -0
  250. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_sums.d.ts +36 -0
  251. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_sums.d.ts.map +1 -0
  252. package/src/shade/renderer/gpu_primitive/bvh8/chunk_bvh8_encode_sums.js +97 -0
  253. package/src/shade/renderer/gpu_primitive/bvh8/graph_bvh8_encode_from_bvh2.d.ts +49 -0
  254. package/src/shade/renderer/gpu_primitive/bvh8/graph_bvh8_encode_from_bvh2.d.ts.map +1 -0
  255. package/src/shade/renderer/gpu_primitive/bvh8/graph_bvh8_encode_from_bvh2.js +265 -0
  256. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_assign.d.ts +37 -0
  257. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_assign.d.ts.map +1 -0
  258. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_assign.js +109 -0
  259. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_count.d.ts +15 -0
  260. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_count.d.ts.map +1 -0
  261. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_count.js +85 -0
  262. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_count_single_workgroup.d.ts +26 -0
  263. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_count_single_workgroup.d.ts.map +1 -0
  264. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_count_single_workgroup.js +200 -0
  265. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_parents.d.ts +19 -0
  266. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_parents.d.ts.map +1 -0
  267. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_parents.js +81 -0
  268. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_write.d.ts +14 -0
  269. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_write.d.ts.map +1 -0
  270. package/src/shade/renderer/gpu_primitive/bvh8/shader_bvh8_encode_write.js +101 -0
  271. package/src/shade/renderer/gpu_primitive/bvh8/verify_gpu_bvh8_encode.d.ts +19 -0
  272. package/src/shade/renderer/gpu_primitive/bvh8/verify_gpu_bvh8_encode.d.ts.map +1 -0
  273. package/src/shade/renderer/gpu_primitive/bvh8/verify_gpu_bvh8_encode.js +361 -0
  274. package/src/shade/renderer/grass/surface/shader_grass_surface_bake.d.ts.map +1 -1
  275. package/src/shade/renderer/grass/surface/shader_grass_surface_bake.js +5 -6
  276. package/src/shade/renderer/lightmap/GPULightMap.d.ts.map +1 -1
  277. package/src/shade/renderer/lightmap/GPULightMap.js +1 -0
  278. package/src/shade/renderer/path_tracer/accumulating/AccumulatingPathTracer.d.ts.map +1 -1
  279. package/src/shade/renderer/path_tracer/accumulating/AccumulatingPathTracer.js +1 -0
  280. package/src/shade/renderer/path_tracer/graph_path_trace_scene.d.ts.map +1 -1
  281. package/src/shade/renderer/path_tracer/graph_path_trace_scene.js +1 -0
  282. package/src/shade/renderer/scene/GPUInstancesAccelerationStructure.d.ts +8 -4
  283. package/src/shade/renderer/scene/GPUInstancesAccelerationStructure.d.ts.map +1 -1
  284. package/src/shade/renderer/scene/GPUInstancesAccelerationStructure.js +60 -33
  285. package/src/shade/renderer/scene/verify_gpu_tlas_build.d.ts +6 -6
  286. package/src/shade/renderer/scene/verify_gpu_tlas_build.d.ts.map +1 -1
  287. package/src/shade/renderer/scene/verify_gpu_tlas_build.js +23 -53
  288. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/BVH8_INODE_STRUCT.d.ts +3 -1
  289. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/BVH8_INODE_STRUCT.d.ts.map +1 -1
  290. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/BVH8_INODE_STRUCT.js +5 -3
  291. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/BVH8_MAX_DEPTH.d.ts +28 -0
  292. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/BVH8_MAX_DEPTH.d.ts.map +1 -0
  293. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/BVH8_MAX_DEPTH.js +29 -0
  294. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_grid.d.ts +25 -0
  295. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_grid.d.ts.map +1 -0
  296. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_grid.js +97 -0
  297. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_intersect.d.ts +8 -0
  298. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_intersect.d.ts.map +1 -1
  299. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_intersect.js +23 -14
  300. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_slot_distances.d.ts +36 -0
  301. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_slot_distances.d.ts.map +1 -0
  302. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_node_slot_distances.js +222 -0
  303. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_ray_direction_rcp.d.ts +20 -0
  304. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_ray_direction_rcp.d.ts.map +1 -0
  305. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_ray_direction_rcp.js +30 -0
  306. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_tree_read.d.ts +30 -0
  307. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_tree_read.d.ts.map +1 -0
  308. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_tree_read.js +91 -0
  309. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_waiting_slots.d.ts +23 -0
  310. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_waiting_slots.d.ts.map +1 -0
  311. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_waiting_slots.js +40 -0
  312. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_blas_nearest.d.ts +22 -0
  313. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_blas_nearest.d.ts.map +1 -1
  314. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_blas_nearest.js +121 -70
  315. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_blas_occluded.d.ts +13 -1
  316. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_blas_occluded.d.ts.map +1 -1
  317. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_blas_occluded.js +117 -61
  318. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest.d.ts +21 -0
  319. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest.d.ts.map +1 -1
  320. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest.js +111 -72
  321. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.d.ts +1 -2
  322. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.d.ts.map +1 -1
  323. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.js +83 -54
  324. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_occluded.d.ts +14 -0
  325. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_occluded.d.ts.map +1 -1
  326. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_occluded.js +92 -60
  327. package/src/shade/renderer/shader/chunk/sdf/chunk_point_query_blas_nearest.d.ts +22 -0
  328. package/src/shade/renderer/shader/chunk/sdf/chunk_point_query_blas_nearest.d.ts.map +1 -1
  329. package/src/shade/renderer/shader/chunk/sdf/chunk_point_query_blas_nearest.js +153 -106
  330. package/src/shade/renderer/shader/chunk/sdf/chunk_scene_point_query_nearest.d.ts +21 -0
  331. package/src/shade/renderer/shader/chunk/sdf/chunk_scene_point_query_nearest.d.ts.map +1 -1
  332. package/src/shade/renderer/shader/chunk/sdf/chunk_scene_point_query_nearest.js +115 -74
  333. package/src/shade/renderer/shader/chunk/sdf/chunk_scene_sdf_raymarch.d.ts +5 -2
  334. package/src/shade/renderer/shader/chunk/sdf/chunk_scene_sdf_raymarch.d.ts.map +1 -1
  335. package/src/shade/renderer/shader/chunk/sdf/chunk_scene_sdf_raymarch.js +89 -63
  336. package/src/shade/renderer/shader/chunk/sdf/chunk_sdf_query_distance.d.ts +15 -0
  337. package/src/shade/renderer/shader/chunk/sdf/chunk_sdf_query_distance.d.ts.map +1 -1
  338. package/src/shade/renderer/shader/chunk/sdf/chunk_sdf_query_distance.js +108 -63
  339. package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_raycast.d.ts +14 -0
  340. package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_raycast.d.ts.map +1 -1
  341. package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_raycast.js +94 -60
  342. package/src/shade/renderer/shadow/sdf/graph_draw_sdf_shadows.d.ts.map +1 -1
  343. package/src/shade/renderer/shadow/sdf/graph_draw_sdf_shadows.js +4 -4
  344. package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +2 -2
  345. package/src/shade/renderer/water/query/shader_water_surface_query.d.ts.map +1 -1
  346. package/src/shade/renderer/water/query/shader_water_surface_query.js +227 -227
  347. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.d.ts.map +1 -1
  348. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.js +7 -4
  349. package/src/shade/renderer/water/surface/particles/shader_water_particles.js +2 -2
  350. package/src/shade/renderer/wind/GPUSceneWind.d.ts +36 -4
  351. package/src/shade/renderer/wind/GPUSceneWind.d.ts.map +1 -1
  352. package/src/shade/renderer/wind/GPUSceneWind.js +150 -4
  353. package/src/shade/renderer/wind/WIND_FIELD_STRUCT.d.ts +9 -3
  354. package/src/shade/renderer/wind/WIND_FIELD_STRUCT.d.ts.map +1 -1
  355. package/src/shade/renderer/wind/WIND_FIELD_STRUCT.js +13 -3
  356. package/src/shade/renderer/wind/WIND_FIELD_UNIFORM.d.ts +6 -6
  357. package/src/shade/renderer/wind/WIND_FIELD_UNIFORM.js +6 -6
  358. package/src/shade/renderer/wind/chunk_fluid_turbulence.d.ts +39 -0
  359. package/src/shade/renderer/wind/chunk_fluid_turbulence.d.ts.map +1 -0
  360. package/src/shade/renderer/wind/chunk_fluid_turbulence.js +63 -0
  361. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts +10 -7
  362. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts.map +1 -1
  363. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.js +34 -11
  364. package/src/shade/renderer/wind/chunk_wind_field_sample_uniform.d.ts +2 -2
  365. package/src/shade/renderer/wind/chunk_wind_field_sample_uniform.js +2 -2
  366. package/src/shade/renderer/wind/wind_field_add_resources.d.ts +6 -4
  367. package/src/shade/renderer/wind/wind_field_add_resources.d.ts.map +1 -1
  368. package/src/shade/renderer/wind/wind_field_add_resources.js +9 -6
  369. package/src/shade/renderer/geometry/bvh/BLAS_REFIT_TARGET_STRUCT.d.ts +0 -18
  370. package/src/shade/renderer/geometry/bvh/BLAS_REFIT_TARGET_STRUCT.d.ts.map +0 -1
  371. package/src/shade/renderer/geometry/bvh/BLAS_REFIT_TARGET_STRUCT.js +0 -50
  372. package/src/shade/renderer/geometry/bvh/bvh2_derive_topology.d.ts +0 -23
  373. package/src/shade/renderer/geometry/bvh/bvh2_derive_topology.d.ts.map +0 -1
  374. package/src/shade/renderer/geometry/bvh/bvh2_derive_topology.js +0 -87
  375. package/src/shade/renderer/geometry/bvh/shader_blas_refit_batch.d.ts +0 -42
  376. package/src/shade/renderer/geometry/bvh/shader_blas_refit_batch.d.ts.map +0 -1
  377. package/src/shade/renderer/geometry/bvh/shader_blas_refit_batch.js +0 -141
  378. package/src/shade/renderer/geometry/bvh/shader_blas_refit_batch_seed.d.ts +0 -21
  379. package/src/shade/renderer/geometry/bvh/shader_blas_refit_batch_seed.d.ts.map +0 -1
  380. package/src/shade/renderer/geometry/bvh/shader_blas_refit_batch_seed.js +0 -75
  381. package/src/shade/renderer/geometry/meshlet_batch_to_bvh.d.ts +0 -17
  382. package/src/shade/renderer/geometry/meshlet_batch_to_bvh.d.ts.map +0 -1
  383. package/src/shade/renderer/geometry/meshlet_batch_to_bvh.js +0 -247
  384. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_ray_query_blas_occlusion.d.ts +0 -7
  385. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_ray_query_blas_occlusion.d.ts.map +0 -1
  386. package/src/shade/renderer/shader/chunk/bvh/bvh8/webgpu/chunk_bvh8_ray_query_blas_occlusion.js +0 -226
  387. package/src/shade/renderer/shader/chunk/light/lpv/chunk_lpv_mask_visibility_via_rays.d.ts +0 -8
  388. package/src/shade/renderer/shader/chunk/light/lpv/chunk_lpv_mask_visibility_via_rays.d.ts.map +0 -1
  389. package/src/shade/renderer/shader/chunk/light/lpv/chunk_lpv_mask_visibility_via_rays.js +0 -45
  390. package/src/shade/renderer/shader/chunk/light/sample/chunk_ray_sample_light.d.ts +0 -3
  391. package/src/shade/renderer/shader/chunk/light/sample/chunk_ray_sample_light.d.ts.map +0 -1
  392. package/src/shade/renderer/shader/chunk/light/sample/chunk_ray_sample_light.js +0 -105
  393. package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_distance.d.ts +0 -6
  394. package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_distance.d.ts.map +0 -1
  395. package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_distance.js +0 -86
  396. package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_raycast_traversal_count.d.ts +0 -2
  397. package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_raycast_traversal_count.d.ts.map +0 -1
  398. package/src/shade/renderer/shadow/sdf/chunk_ray_query_sdf_raycast_traversal_count.js +0 -136
@@ -1,6 +1,7 @@
1
1
  import { chunk_clipmap_select_finest } from "../shader/chunk/clipmap/chunk_clipmap_select_finest.js";
2
2
  import { CodeChunk } from "../shader/compiler/CodeChunk.js";
3
3
  import { WIND_FIELD_BAND_WIDTH, WIND_FIELD_CASCADE_LIMIT } from "./WIND_FIELD.js";
4
+ import { chunk_fluid_turbulence } from "./chunk_fluid_turbulence.js";
4
5
  import { WIND_FIELD_STRUCT } from "./WIND_FIELD_STRUCT.js";
5
6
 
6
7
  /**
@@ -8,21 +9,24 @@ import { WIND_FIELD_STRUCT } from "./WIND_FIELD_STRUCT.js";
8
9
  * `chunk_wind_field_sample` links for a field as it is ({@link WIND_FIELD_UNIFORM} `false`), any
9
10
  * number of cascades, none included.
10
11
  *
11
- * Reads `wind_field` ({@link WIND_FIELD_STRUCT}), `wind_field_atlas` and `wind_field_sampler`, as
12
- * {@link wind_field_add_resources} declares them. `wind_field_sample_in(field, position_ws)` is the
12
+ * Reads `wind_field` ({@link WIND_FIELD_STRUCT}), `wind_field_atlas`, `wind_field_sampler` and the
13
+ * turbulence tile, as {@link wind_field_add_resources} declares them. `wind_field_sample_in(field, position_ws)` is the
13
14
  * same read through any table over that atlas, the previous frame's for one.
14
15
  *
15
16
  * **The read:**
16
17
  * - the cascades' windows are walked finest first, each by `clipmap_level_select`, and the first holding
17
18
  * the point answers, with how far into its edge band of {@link WIND_FIELD_BAND_WIDTH} cells the point is;
18
- * - a cascade's read is the atmosphere identity, `v_far(t) + tap · k_c`: one trilinear tap of its tile,
19
- * which holds `v − v_far(t_s,c)` at cell centres, times its decay;
19
+ * - the far field at the point, `v_far(t, p)`: its mean, plus its turbulence's one tap when it has any
20
+ * (`wind_field_far`), band-limited inside a cascade to the cascade's cell, as the cascade's own far
21
+ * field is, and whole beyond every cascade;
22
+ * - a cascade's read is the atmosphere identity, `v_far(t, p) + tap · k_c`: one trilinear tap of its
23
+ * tile, which holds `v − v_far(t_s,c)` at cell centres, times its decay;
20
24
  * - in the band, a second read blends in linearly, all of it on the window's face: the parent's
21
- * identity read, or `v_far(t)` for the coarsest; deeper than the band, one read;
22
- * - outside every cascade, `v_far(t)`.
25
+ * identity read, or `v_far(t, p)` for the coarsest; deeper than the band, one read;
26
+ * - outside every cascade, `v_far(t, p)`.
23
27
  *
24
28
  * The blend and the decay are taken now, at the sample, so a cascade that last stepped ticks ago reads
25
- * the far field's current gust and drag. Air at the far field publishes a deviation of 0 and reads
29
+ * the far field's current mean, turbulence and drag. Air at the far field publishes a deviation of 0 and reads
26
30
  * back `v_far(t)` exactly, on every cascade, in every band, at every instant: the blend is written as
27
31
  * `inner + (outer − inner)·w`, which leaves equal reads as they are.
28
32
  *
@@ -46,10 +50,26 @@ export const chunk_wind_field_sample_cascades = CodeChunk.from(
46
50
  `
47
51
  const WIND_FIELD_BAND_WIDTH: f32 = ${WIND_FIELD_BAND_WIDTH}.0;
48
52
 
49
- // cascade c's identity read at a world point its window holds
53
+ // the far field at a world point, band-limited to what a lattice of that cell holds: its mean, and its
54
+ // turbulence there when it has any; a cell of 0 reads the tile whole
55
+ fn wind_field_far(field: ptr<uniform, ${WIND_FIELD_STRUCT.wgsl_ref}>, position_ws: vec3<f32>, cell: f32) -> vec3<f32> {
56
+ let sigma = (*field).turbulence_sigma;
57
+
58
+ if (sigma == 0.0) {
59
+ return (*field).far_velocity;
60
+ }
61
+
62
+ let lod = fluid_turbulence_lod(cell, (*field).turbulence_inverse_texel);
63
+
64
+ return (*field).far_velocity + sigma * fluid_turbulence_at(position_ws * (*field).turbulence_scale + (*field).turbulence_origin, lod);
65
+ }
66
+
67
+ // cascade c's identity read at a world point its window holds: its far field at its own level, which is
68
+ // what its tile is a deviation from
50
69
  fn wind_field_cascade_read(field: ptr<uniform, ${WIND_FIELD_STRUCT.wgsl_ref}>, c: u32, position_ws: vec3<f32>) -> vec3<f32> {
51
70
  let level = (*field).levels[c];
52
71
  let cascade = (*field).cascades[c];
72
+ let far = wind_field_far(field, position_ws, level.cell_size);
53
73
 
54
74
  // window-local position in the cascade's cells, which is a texel offset from the tile's content
55
75
  let local = position_ws / level.cell_size - vec3<f32>(level.corner);
@@ -57,7 +77,7 @@ fn wind_field_cascade_read(field: ptr<uniform, ${WIND_FIELD_STRUCT.wgsl_ref}>, c
57
77
 
58
78
  let deviation = textureSampleLevel(wind_field_atlas, wind_field_sampler, uvw, 0.0).xyz;
59
79
 
60
- return (*field).far_velocity + deviation * cascade.decay;
80
+ return far + deviation * cascade.decay;
61
81
  }
62
82
 
63
83
  fn wind_field_sample_in(field: ptr<uniform, ${WIND_FIELD_STRUCT.wgsl_ref}>, position_ws: vec3<f32>) -> vec3<f32> {
@@ -75,7 +95,7 @@ fn wind_field_sample_in(field: ptr<uniform, ${WIND_FIELD_STRUCT.wgsl_ref}>, posi
75
95
  }
76
96
 
77
97
  if (selection.level == CLIPMAP_LEVEL_NONE) {
78
- return (*field).far_velocity;
98
+ return wind_field_far(field, position_ws, 0.0);
79
99
  }
80
100
 
81
101
  let inner = wind_field_cascade_read(field, selection.level, position_ws);
@@ -86,10 +106,12 @@ fn wind_field_sample_in(field: ptr<uniform, ${WIND_FIELD_STRUCT.wgsl_ref}>, posi
86
106
 
87
107
  let parent = selection.level + 1u;
88
108
 
89
- var outer = (*field).far_velocity;
109
+ var outer: vec3<f32>;
90
110
 
91
111
  if (parent < count) {
92
112
  outer = wind_field_cascade_read(field, parent, position_ws);
113
+ } else {
114
+ outer = wind_field_far(field, position_ws, 0.0);
93
115
  }
94
116
 
95
117
  // mix's form, written so that equal reads blend to themselves exactly
@@ -102,5 +124,6 @@ fn wind_field_sample(position_ws: vec3<f32>) -> vec3<f32> {
102
124
  `, [
103
125
  WIND_FIELD_STRUCT.declaration_chunk,
104
126
  chunk_clipmap_select_finest,
127
+ chunk_fluid_turbulence,
105
128
  ]
106
129
  );
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * `wind_field_sample(position_ws)` in a uniform field ({@link WIND_FIELD_UNIFORM} `true`): one with no
3
- * cascades, where the wind is `v_far(t)` at every point, which is what the cascaded read returns there,
4
- * exactly, having found no window that holds the point.
3
+ * cascades and no turbulence, where the wind is `v_far(t)` at every point, which is what the cascaded
4
+ * read returns there, exactly, having found no window that holds the point.
5
5
  *
6
6
  * Reads `wind_field.far_velocity` and nothing else; the atlas and its sampler stay bound and unread.
7
7
  * `wind_field_sample_in(field, position_ws)` is the same read of any table with no cascades.
@@ -3,8 +3,8 @@ import { WIND_FIELD_STRUCT } from "./WIND_FIELD_STRUCT.js";
3
3
 
4
4
  /**
5
5
  * `wind_field_sample(position_ws)` in a uniform field ({@link WIND_FIELD_UNIFORM} `true`): one with no
6
- * cascades, where the wind is `v_far(t)` at every point, which is what the cascaded read returns there,
7
- * exactly, having found no window that holds the point.
6
+ * cascades and no turbulence, where the wind is `v_far(t)` at every point, which is what the cascaded
7
+ * read returns there, exactly, having found no window that holds the point.
8
8
  *
9
9
  * Reads `wind_field.far_velocity` and nothing else; the atlas and its sampler stay bound and unread.
10
10
  * `wind_field_sample_in(field, position_ws)` is the same read of any table with no cascades.
@@ -3,10 +3,12 @@
3
3
  * `chunk_wind_field_sample` reads:
4
4
  * - `wind_field`: the uniform {@link WIND_FIELD_STRUCT};
5
5
  * - `wind_field_atlas`: the tiles, `texture_3d<f32>`, filterable;
6
- * - `wind_field_sampler`: linear and clamped, by default the field's own, so a host binds only the
7
- * other two (`GPUSceneWind.bind`).
6
+ * - `wind_field_sampler`: linear and clamped, by default the field's own;
7
+ * - `fluid_turbulence`, `fluid_turbulence_sampler`: the far field's turbulence tile and its repeating
8
+ * sampler (`fluid_turbulence_add_resources`), the sampler by default.
8
9
  *
9
- * One uniform, one texture, one sampler, and no storage buffer.
10
+ * A host binds the uniform and the two textures (`GPUSceneWind.bind`). One uniform, two textures, two
11
+ * samplers, and no storage buffer.
10
12
  *
11
13
  * @param {import("../shader/resource/ShaderResourceGroupDescriptor.js").ShaderResourceGroupDescriptor} group
12
14
  * @returns {import("../shader/resource/ShaderResourceGroupDescriptor.js").ShaderResourceGroupDescriptor} group
@@ -17,7 +19,7 @@ export function wind_field_add_resources(group: import("../shader/resource/Shade
17
19
  * samples both (`chunk_wind_field_sample_previous`): `wind_field_previous`, a second uniform
18
20
  * {@link WIND_FIELD_STRUCT} over the same atlas. `GPUSceneWind.bind_history` fills them.
19
21
  *
20
- * Two uniforms, one texture, one sampler, and no storage buffer.
22
+ * Two uniforms, two textures, two samplers, and no storage buffer.
21
23
  *
22
24
  * @param {import("../shader/resource/ShaderResourceGroupDescriptor.js").ShaderResourceGroupDescriptor} group
23
25
  * @returns {import("../shader/resource/ShaderResourceGroupDescriptor.js").ShaderResourceGroupDescriptor} group
@@ -1 +1 @@
1
- {"version":3,"file":"wind_field_add_resources.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/wind/wind_field_add_resources.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,gDAHW,OAAO,qDAAqD,EAAE,6BAA6B,GACzF,OAAO,qDAAqD,EAAE,6BAA6B,CAOvG;AAED;;;;;;;;;GASG;AACH,wDAHW,OAAO,qDAAqD,EAAE,6BAA6B,GACzF,OAAO,qDAAqD,EAAE,6BAA6B,CAKvG"}
1
+ {"version":3,"file":"wind_field_add_resources.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/wind/wind_field_add_resources.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,gDAHW,OAAO,qDAAqD,EAAE,6BAA6B,GACzF,OAAO,qDAAqD,EAAE,6BAA6B,CAOvG;AAED;;;;;;;;;GASG;AACH,wDAHW,OAAO,qDAAqD,EAAE,6BAA6B,GACzF,OAAO,qDAAqD,EAAE,6BAA6B,CAKvG"}
@@ -1,3 +1,4 @@
1
+ import { fluid_turbulence_add_resources } from "./chunk_fluid_turbulence.js";
1
2
  import { WIND_FIELD_SAMPLER_DESCRIPTOR } from "./WIND_FIELD.js";
2
3
  import { WIND_FIELD_STRUCT } from "./WIND_FIELD_STRUCT.js";
3
4
 
@@ -6,19 +7,21 @@ import { WIND_FIELD_STRUCT } from "./WIND_FIELD_STRUCT.js";
6
7
  * `chunk_wind_field_sample` reads:
7
8
  * - `wind_field`: the uniform {@link WIND_FIELD_STRUCT};
8
9
  * - `wind_field_atlas`: the tiles, `texture_3d<f32>`, filterable;
9
- * - `wind_field_sampler`: linear and clamped, by default the field's own, so a host binds only the
10
- * other two (`GPUSceneWind.bind`).
10
+ * - `wind_field_sampler`: linear and clamped, by default the field's own;
11
+ * - `fluid_turbulence`, `fluid_turbulence_sampler`: the far field's turbulence tile and its repeating
12
+ * sampler (`fluid_turbulence_add_resources`), the sampler by default.
11
13
  *
12
- * One uniform, one texture, one sampler, and no storage buffer.
14
+ * A host binds the uniform and the two textures (`GPUSceneWind.bind`). One uniform, two textures, two
15
+ * samplers, and no storage buffer.
13
16
  *
14
17
  * @param {import("../shader/resource/ShaderResourceGroupDescriptor.js").ShaderResourceGroupDescriptor} group
15
18
  * @returns {import("../shader/resource/ShaderResourceGroupDescriptor.js").ShaderResourceGroupDescriptor} group
16
19
  */
17
20
  export function wind_field_add_resources(group) {
18
- return group
21
+ return fluid_turbulence_add_resources(group
19
22
  .addUniform("wind_field", WIND_FIELD_STRUCT)
20
23
  .addTexture("wind_field_atlas", "float", "3d")
21
- .addSampler("wind_field_sampler", "filtering", WIND_FIELD_SAMPLER_DESCRIPTOR);
24
+ .addSampler("wind_field_sampler", "filtering", WIND_FIELD_SAMPLER_DESCRIPTOR));
22
25
  }
23
26
 
24
27
  /**
@@ -26,7 +29,7 @@ export function wind_field_add_resources(group) {
26
29
  * samples both (`chunk_wind_field_sample_previous`): `wind_field_previous`, a second uniform
27
30
  * {@link WIND_FIELD_STRUCT} over the same atlas. `GPUSceneWind.bind_history` fills them.
28
31
  *
29
- * Two uniforms, one texture, one sampler, and no storage buffer.
32
+ * Two uniforms, two textures, two samplers, and no storage buffer.
30
33
  *
31
34
  * @param {import("../shader/resource/ShaderResourceGroupDescriptor.js").ShaderResourceGroupDescriptor} group
32
35
  * @returns {import("../shader/resource/ShaderResourceGroupDescriptor.js").ShaderResourceGroupDescriptor} group
@@ -1,18 +0,0 @@
1
- /**
2
- * One tree in a batched refit: where it lives, and where its arrival counters live.
3
- *
4
- * The first five fields are what {@link GPUGeometryBVHManager#get_refit_target} answers, copied
5
- * out at the frame the batch's tables are built. The other two are the batch's own: a tree's
6
- * counters sit at `counters_offset` in one buffer that holds the counters of every tree in the
7
- * batch — a prefix sum of node counts — and `geometry_index` is the row whose meshlets the leaf
8
- * payloads index, which for a skinned clone is the clone's own row, the one skinning deformed.
9
- *
10
- * Read by {@link shader_blas_refit_batch} and {@link shader_blas_refit_batch_seed} once per
11
- * workgroup, through their workgroup lookups;
12
- * written by {@link GPUBLASRefitBatch} when the set of trees or their residency changes.
13
- *
14
- * @type {WebGPUStruct}
15
- */
16
- export const BLAS_REFIT_TARGET_STRUCT: WebGPUStruct;
17
- import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
18
- //# sourceMappingURL=BLAS_REFIT_TARGET_STRUCT.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BLAS_REFIT_TARGET_STRUCT.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/bvh/BLAS_REFIT_TARGET_STRUCT.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,uCAFU,YAAY,CAiCA;6BAhDO,mCAAmC"}
@@ -1,50 +0,0 @@
1
- import { u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
2
- import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
3
-
4
- /**
5
- * One tree in a batched refit: where it lives, and where its arrival counters live.
6
- *
7
- * The first five fields are what {@link GPUGeometryBVHManager#get_refit_target} answers, copied
8
- * out at the frame the batch's tables are built. The other two are the batch's own: a tree's
9
- * counters sit at `counters_offset` in one buffer that holds the counters of every tree in the
10
- * batch — a prefix sum of node counts — and `geometry_index` is the row whose meshlets the leaf
11
- * payloads index, which for a skinned clone is the clone's own row, the one skinning deformed.
12
- *
13
- * Read by {@link shader_blas_refit_batch} and {@link shader_blas_refit_batch_seed} once per
14
- * workgroup, through their workgroup lookups;
15
- * written by {@link GPUBLASRefitBatch} when the set of trees or their residency changes.
16
- *
17
- * @type {WebGPUStruct}
18
- */
19
- export const BLAS_REFIT_TARGET_STRUCT = WebGPUStruct.from({
20
- /**
21
- * u32 word this tree's node 0 starts at in the node arena.
22
- */
23
- node_word_offset: u32,
24
- /**
25
- * Where this tree's parents start in the parents arena.
26
- */
27
- parents_offset: u32,
28
- /**
29
- * Where this tree's leaf list starts in the leaf-node arena.
30
- */
31
- leaf_nodes_offset: u32,
32
- /**
33
- * Leaves in this tree — one triangle each, so also its triangle count.
34
- */
35
- leaf_count: u32,
36
- /**
37
- * Node slots the tree spans from `node_word_offset`, holes included — what the seeding pass
38
- * covers before every refit.
39
- */
40
- node_count: u32,
41
- /**
42
- * Where this tree's arrival counters start in the batch's counters buffer, one word per node
43
- * slot of the tree.
44
- */
45
- counters_offset: u32,
46
- /**
47
- * Row in the geometry table whose meshlets the leaf payloads index into.
48
- */
49
- geometry_index: u32,
50
- }, "BlasRefitTarget");
@@ -1,23 +0,0 @@
1
- /**
2
- * The two things a refit needs to know about a tree it did not build: who each node's parent is, and
3
- * which nodes are the leaves.
4
- *
5
- * Read straight off the compressed node bytes — the same bytes that go to the GPU — rather than off
6
- * the `BVH` object they came from. That is deliberate: the arena holds `node_capacity` slots and a
7
- * `BVH` allocates from a free list, so the buffer contains holes that were never part of any tree
8
- * and whose child words are whatever the last occupant left. Walking from the root visits exactly
9
- * the tree, so a hole is never mistaken for a leaf and never gets a parent.
10
- *
11
- * Topology, not geometry. Every per-instance copy of a geometry has the same answer, so this is
12
- * derived once per source and shared — only bounds are per-instance.
13
- *
14
- * @param {ArrayBuffer} nodes compressed BVH2 nodes, 32 bytes each, root at node 0
15
- * @returns {{parents: Uint32Array, leaf_nodes: Uint32Array}} `parents` is indexed by node and holds
16
- * `BVH_NULL_NODE` for the root and for every slot the tree does not reach; `leaf_nodes` lists the
17
- * leaves in pre-order, which is the ordinal the refit dispatches one thread per.
18
- */
19
- export function bvh2_derive_topology(nodes: ArrayBuffer): {
20
- parents: Uint32Array;
21
- leaf_nodes: Uint32Array;
22
- };
23
- //# sourceMappingURL=bvh2_derive_topology.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bvh2_derive_topology.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/bvh/bvh2_derive_topology.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;GAiBG;AACH,4CALW,WAAW,GACT;IAAC,OAAO,EAAE,WAAW,CAAC;IAAC,UAAU,EAAE,WAAW,CAAA;CAAC,CA4D3D"}
@@ -1,87 +0,0 @@
1
- import { assert } from "../../../../core/assert.js";
2
- import {
3
- BVH_NODE_CHILD_1_WORD,
4
- BVH_NODE_CHILD_2_WORD,
5
- BVH_NODE_STRIDE_WORDS
6
- } from "../../gpu_primitive/bvh/BVH_BUFFER_LAYOUT.js";
7
-
8
- /**
9
- * @type {number}
10
- */
11
- const BVH_NULL_NODE = 0xffffffff;
12
-
13
- /**
14
- * The two things a refit needs to know about a tree it did not build: who each node's parent is, and
15
- * which nodes are the leaves.
16
- *
17
- * Read straight off the compressed node bytes — the same bytes that go to the GPU — rather than off
18
- * the `BVH` object they came from. That is deliberate: the arena holds `node_capacity` slots and a
19
- * `BVH` allocates from a free list, so the buffer contains holes that were never part of any tree
20
- * and whose child words are whatever the last occupant left. Walking from the root visits exactly
21
- * the tree, so a hole is never mistaken for a leaf and never gets a parent.
22
- *
23
- * Topology, not geometry. Every per-instance copy of a geometry has the same answer, so this is
24
- * derived once per source and shared — only bounds are per-instance.
25
- *
26
- * @param {ArrayBuffer} nodes compressed BVH2 nodes, 32 bytes each, root at node 0
27
- * @returns {{parents: Uint32Array, leaf_nodes: Uint32Array}} `parents` is indexed by node and holds
28
- * `BVH_NULL_NODE` for the root and for every slot the tree does not reach; `leaf_nodes` lists the
29
- * leaves in pre-order, which is the ordinal the refit dispatches one thread per.
30
- */
31
- export function bvh2_derive_topology(nodes) {
32
- assert.defined(nodes, 'nodes');
33
-
34
- const words = new Uint32Array(nodes);
35
-
36
- const node_count = Math.floor(words.length / BVH_NODE_STRIDE_WORDS);
37
-
38
- assert.greaterThan(node_count, 0, 'node_count');
39
-
40
- const parents = new Uint32Array(node_count).fill(BVH_NULL_NODE);
41
-
42
- const leaf_nodes = [];
43
-
44
- const stack = [0];
45
-
46
- let visited = 0;
47
-
48
- while (stack.length > 0) {
49
- const node = stack.pop();
50
-
51
- visited += 1;
52
-
53
- assert.lessThanOrEqual(visited, node_count, 'walk visited more nodes than the buffer holds — the tree is not a tree');
54
-
55
- const base = node * BVH_NODE_STRIDE_WORDS;
56
-
57
- const child_1 = words[base + BVH_NODE_CHILD_1_WORD];
58
-
59
- if (child_1 === BVH_NULL_NODE) {
60
- leaf_nodes.push(node);
61
-
62
- continue;
63
- }
64
-
65
- const child_2 = words[base + BVH_NODE_CHILD_2_WORD];
66
-
67
- assert.greaterThan(child_1, 0, 'child_1 must be a non-root node');
68
- assert.greaterThan(child_2, 0, 'child_2 must be a non-root node');
69
- assert.lessThan(child_1, node_count, 'child_1 out of range');
70
- assert.lessThan(child_2, node_count, 'child_2 out of range');
71
- assert.notEqual(child_1, child_2, 'internal node children must be distinct');
72
- assert.equal(parents[child_1], BVH_NULL_NODE, 'child_1 already has a parent');
73
- assert.equal(parents[child_2], BVH_NULL_NODE, 'child_2 already has a parent');
74
-
75
- parents[child_1] = node;
76
- parents[child_2] = node;
77
-
78
- // child_1 first out, so the leaf order is a pre-order walk rather than an artefact of
79
- // which way the stack happens to run
80
- stack.push(child_2, child_1);
81
- }
82
-
83
- return {
84
- parents,
85
- leaf_nodes: Uint32Array.from(leaf_nodes),
86
- };
87
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * Leaves per workgroup. A workgroup serves one tree and one aligned run of this many of its leaves,
3
- * which is what the lookup's `leaf_base` counts in.
4
- *
5
- * @type {number}
6
- */
7
- export const BLAS_REFIT_BATCH_WORKGROUP_SIZE: number;
8
- /**
9
- * Refit every tree in a batch, from one dispatch.
10
- *
11
- * One lane per leaf, across every tree the batch lists: the lane finds its tree and its leaf through
12
- * the workgroup lookup, rewrites that leaf's box from the triangle it names as the vertex buffer
13
- * holds it *now*, and climbs — {@link chunk_bvh_refit_climb}, the same arrival-counter climb the
14
- * LBVH build ends with, at this tree's positions in the shared arenas. Topology is untouched:
15
- * nothing is sorted, nothing is emitted, no node's children change.
16
- *
17
- * Batched rather than per tree because a refit's cost is not the refit. A tree's climb is a chain
18
- * of dependent atomics as long as the tree is deep, with half the live lanes exiting at every
19
- * level; on its own it is a long tail of a nearly idle GPU, and a dispatch per tree serialises
20
- * `N` such tails behind `2N` pass boundaries. In one dispatch a small tree's climb overlaps the
21
- * next tree's, and the command count is the same for one skinned mesh as for three hundred.
22
- *
23
- * Fused rather than two passes: the leaf box is stored through the same atomic words the climb
24
- * reads, before the lane's first arrival, so the second arrival at its parent reads it exactly as
25
- * it reads an internal node's — including when it has not arrived yet. Arriving second does not
26
- * order the sibling's stores (R1 in GPU_BVH_BUILD_PLAN.md), so every bound word is seeded with
27
- * {@link BVH_UNFITTED} a dispatch earlier ({@link shader_blas_refit_batch_seed}), the climb defers
28
- * the nodes it cannot see whole to the list in `refit_deferred`, and
29
- * {@link shader_bvh_refit_repair} grows them a dispatch later — the build's own repair, over every
30
- * tree in the batch at once.
31
- *
32
- * For a skinned mesh this runs against the per-instance clone, after the skinning pass has deformed
33
- * its vertex region; `geometry_index` on the row is the clone's, and reading the source instead
34
- * would produce the rest pose.
35
- *
36
- * Recorded by {@link GPUBLASRefitBatch}, which builds the tables and paginates the dispatch.
37
- *
38
- * @type {ComputeShader}
39
- */
40
- export const shader_blas_refit_batch: ComputeShader;
41
- import { ComputeShader } from "../../shader/ComputeShader.js";
42
- //# sourceMappingURL=shader_blas_refit_batch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shader_blas_refit_batch.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/bvh/shader_blas_refit_batch.js"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,8CAFU,MAAM,CAEkC;AAmFlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,sCAFU,aAAa,CAMpB;8BAzI2B,+BAA+B"}
@@ -1,141 +0,0 @@
1
- import { atomic_u32, u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
2
- import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
3
- import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
4
- import { ComputeShader } from "../../shader/ComputeShader.js";
5
- import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
6
- import { BVH_NODE_LAYOUT_DEFINITION } from "../../gpu_primitive/bvh/BVH_NODE_LAYOUT_DEFINITION.js";
7
- import { chunk_bvh_refit_climb } from "../../gpu_primitive/bvh/chunk_bvh_refit_climb.js";
8
- import {
9
- chunk_geometry_read_triangle_bounds
10
- } from "../../shader/chunk/geometry/format/chunk_geometry_read_triangle_bounds.js";
11
- import { GEOMETRY_ATTRIBUTE_DATA_TYPE } from "../GEOMETRY_ATTRIBUTE_DATA_TYPE.js";
12
- import { GEOMETRY_METADATA_STRUCT } from "../GEOMETRY_METADATA_STRUCT.js";
13
- import { MESHLET_METADATA_STRUCT } from "../meshlet/encoding/MESHLET_METADATA_STRUCT.js";
14
- import { BLAS_REFIT_TARGET_STRUCT } from "./BLAS_REFIT_TARGET_STRUCT.js";
15
-
16
- /**
17
- * Leaves per workgroup. A workgroup serves one tree and one aligned run of this many of its leaves,
18
- * which is what the lookup's `leaf_base` counts in.
19
- *
20
- * @type {number}
21
- */
22
- export const BLAS_REFIT_BATCH_WORKGROUP_SIZE = 64;
23
-
24
- const resources = new ShaderResourceSetDescriptor();
25
-
26
- // Workgroups already covered by earlier sub-dispatches of the same batch, for a batch larger than
27
- // the device's per-dimension cap. Four bytes, per dispatch: immediate data.
28
- resources.setImmediate("dispatch_offset", u32);
29
-
30
- resources.createGroup()
31
- // one row per tree in the batch — where it lives, and where its counters live
32
- .addStorageBuffer("targets", WebGPUArray.from(BLAS_REFIT_TARGET_STRUCT), false)
33
- // `(target_index, leaf_base)` per workgroup, flat
34
- .addStorageBuffer("lookup", WebGPUArray.from(u32), false)
35
- // node index of each leaf ordinal, per tree, at the tree's `leaf_nodes_offset`
36
- .addStorageBuffer("leaf_nodes", WebGPUArray.from(u32), false)
37
- // parent of every node, per tree, at the tree's `parents_offset`
38
- .addStorageBuffer("parents", WebGPUArray.from(u32), false)
39
- // one arrival counter per node slot of every tree, at each tree's `counters_offset`; zero at
40
- // the start of every batch
41
- .addStorageBuffer("counters", WebGPUArray.from(atomic_u32), true)
42
- // The node arena, flat and atomic. Every word this kernel writes is communicated between
43
- // invocations — a leaf box to the second arrival at its parent, a node box to the next — so
44
- // every access to it is an atomic one. Its bound words arrive seeded by
45
- // shader_blas_refit_batch_seed.
46
- .addStorageBuffer("nodes", WebGPUArray.from(atomic_u32), true)
47
- // the nodes whose children had not all reached their second arrival, every tree's, for the
48
- // repair; header zero at the start of every batch
49
- .addStorageBuffer("refit_deferred", WebGPUArray.from(atomic_u32), true)
50
- .addStorageBuffer("geometries", WebGPUArray.from(GEOMETRY_METADATA_STRUCT), false)
51
- .addStorageBuffer("meshlet_metadata", WebGPUArray.from(MESHLET_METADATA_STRUCT), false)
52
- .addStorageBuffer("meshlet_data", GEOMETRY_ATTRIBUTE_DATA_TYPE, false);
53
-
54
- const body = CodeChunk.from(
55
- //language=WGSL
56
- `
57
- @compute @workgroup_size(${BLAS_REFIT_BATCH_WORKGROUP_SIZE}, 1, 1)
58
- fn main(
59
- @builtin(workgroup_id) wg: vec3<u32>,
60
- @builtin(local_invocation_id) lid: vec3<u32>,
61
- ) {
62
- // Which tree, and which run of its leaves: one lookup pair per workgroup, so the row read below
63
- // is uniform across the workgroup and the leaf list read is one contiguous run.
64
- let pair = (wg.x + dispatch_offset) * 2u;
65
-
66
- // ("target" is a reserved word in WGSL)
67
- let tree = targets[lookup[pair]];
68
-
69
- let leaf = lookup[pair + 1u] + lid.x;
70
-
71
- if (leaf >= tree.leaf_count) {
72
- // the tail of a tree's last run; the next workgroup is another tree's
73
- return;
74
- }
75
-
76
- let leaf_node = leaf_nodes[tree.leaf_nodes_offset + leaf];
77
-
78
- let leaf_word = tree.node_word_offset + leaf_node * BVH_NODE_STRIDE;
79
-
80
- // The leaf already says which triangle it holds — its payload is what the ray query hands to
81
- // the triangle test. Reading it back means no side table has to agree with the tree about
82
- // which leaf is which.
83
- let payload = atomicLoad(&nodes[leaf_word + BVH_NODE_CHILD_2]);
84
-
85
- let box = geometry_read_triangle_bounds(geometries[tree.geometry_index], payload);
86
-
87
- // This leaf's box, then the climb from it. The box is written before this lane's first arrival
88
- // at the parent, through the same atomic words the climb reads every other box through, so the
89
- // second arrival at the parent finds it exactly as it finds an internal node's.
90
- bvh_node_store_bounds(leaf_word, box.min, box.max);
91
-
92
- bvh_refit_climb(
93
- tree.node_word_offset,
94
- tree.parents_offset,
95
- tree.counters_offset,
96
- leaf_node
97
- );
98
- }
99
- `, [
100
- BVH_NODE_LAYOUT_DEFINITION,
101
- chunk_bvh_refit_climb,
102
- chunk_geometry_read_triangle_bounds,
103
- ]);
104
-
105
- /**
106
- * Refit every tree in a batch, from one dispatch.
107
- *
108
- * One lane per leaf, across every tree the batch lists: the lane finds its tree and its leaf through
109
- * the workgroup lookup, rewrites that leaf's box from the triangle it names as the vertex buffer
110
- * holds it *now*, and climbs — {@link chunk_bvh_refit_climb}, the same arrival-counter climb the
111
- * LBVH build ends with, at this tree's positions in the shared arenas. Topology is untouched:
112
- * nothing is sorted, nothing is emitted, no node's children change.
113
- *
114
- * Batched rather than per tree because a refit's cost is not the refit. A tree's climb is a chain
115
- * of dependent atomics as long as the tree is deep, with half the live lanes exiting at every
116
- * level; on its own it is a long tail of a nearly idle GPU, and a dispatch per tree serialises
117
- * `N` such tails behind `2N` pass boundaries. In one dispatch a small tree's climb overlaps the
118
- * next tree's, and the command count is the same for one skinned mesh as for three hundred.
119
- *
120
- * Fused rather than two passes: the leaf box is stored through the same atomic words the climb
121
- * reads, before the lane's first arrival, so the second arrival at its parent reads it exactly as
122
- * it reads an internal node's — including when it has not arrived yet. Arriving second does not
123
- * order the sibling's stores (R1 in GPU_BVH_BUILD_PLAN.md), so every bound word is seeded with
124
- * {@link BVH_UNFITTED} a dispatch earlier ({@link shader_blas_refit_batch_seed}), the climb defers
125
- * the nodes it cannot see whole to the list in `refit_deferred`, and
126
- * {@link shader_bvh_refit_repair} grows them a dispatch later — the build's own repair, over every
127
- * tree in the batch at once.
128
- *
129
- * For a skinned mesh this runs against the per-instance clone, after the skinning pass has deformed
130
- * its vertex region; `geometry_index` on the row is the clone's, and reading the source instead
131
- * would produce the rest pose.
132
- *
133
- * Recorded by {@link GPUBLASRefitBatch}, which builds the tables and paginates the dispatch.
134
- *
135
- * @type {ComputeShader}
136
- */
137
- export const shader_blas_refit_batch = ComputeShader.from({
138
- label: "BLAS/RefitBatch",
139
- resources,
140
- body,
141
- });
@@ -1,21 +0,0 @@
1
- /**
2
- * Seed every bound word of every tree in a batch with {@link BVH_UNFITTED}, a dispatch ahead of
3
- * {@link shader_blas_refit_batch}.
4
- *
5
- * The batch refit hands boxes between invocations through relaxed atomics — leaf boxes included,
6
- * since it writes them in the same dispatch — and a store need not reach the reader before the
7
- * dispatch ends. What this leaves behind is what such a read returns, so the climb can see a box
8
- * that has not arrived instead of taking last frame's for it. For a skinned mesh last frame's box
9
- * is close to this frame's, so taking it would go unnoticed.
10
- *
11
- * One lane per node slot, holes included: the arena's trees keep the slots their builder allocated,
12
- * and seeding a hole costs six stores where telling it apart would cost a walk. The bounds words are
13
- * all it touches; children and payloads are the tree's topology and stay as they are.
14
- *
15
- * Recorded by {@link GPUBLASRefitBatch}, paginated as the refit is.
16
- *
17
- * @type {ComputeShader}
18
- */
19
- export const shader_blas_refit_batch_seed: ComputeShader;
20
- import { ComputeShader } from "../../shader/ComputeShader.js";
21
- //# sourceMappingURL=shader_blas_refit_batch_seed.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shader_blas_refit_batch_seed.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/bvh/shader_blas_refit_batch_seed.js"],"names":[],"mappings":"AAoDA;;;;;;;;;;;;;;;;;GAiBG;AACH,2CAFU,aAAa,CAMpB;8BAvE2B,+BAA+B"}