@woosh/meep-engine 3.42.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 (345) hide show
  1. package/editor/prototypeEditorShell.d.ts.map +1 -1
  2. package/editor/prototypeEditorShell.js +4 -2
  3. package/package.json +91 -96
  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/playground/vgeo_runtime/README.md +5 -4
  177. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  178. package/src/shade/renderer/Renderer.js +6 -5
  179. package/src/shade/renderer/animation/GPUAnimationManager.d.ts +45 -14
  180. package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
  181. package/src/shade/renderer/animation/GPUAnimationManager.js +316 -64
  182. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts +5 -0
  183. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts.map +1 -1
  184. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.js +11 -1
  185. package/src/shade/renderer/atmosphere/GPUSky.d.ts +12 -0
  186. package/src/shade/renderer/atmosphere/GPUSky.d.ts.map +1 -1
  187. package/src/shade/renderer/atmosphere/GPUSky.js +162 -147
  188. package/src/shade/renderer/geometry/BoxGeometry.d.ts +1 -11
  189. package/src/shade/renderer/geometry/BoxGeometry.d.ts.map +1 -1
  190. package/src/shade/renderer/geometry/BoxGeometry.js +6 -13
  191. package/src/shade/renderer/geometry/CapsuleGeometry.d.ts +19 -0
  192. package/src/shade/renderer/geometry/CapsuleGeometry.d.ts.map +1 -0
  193. package/src/shade/renderer/geometry/CapsuleGeometry.js +24 -0
  194. package/src/shade/renderer/geometry/ConeGeometry.d.ts +20 -0
  195. package/src/shade/renderer/geometry/ConeGeometry.d.ts.map +1 -0
  196. package/src/shade/renderer/geometry/ConeGeometry.js +33 -0
  197. package/src/shade/renderer/geometry/CylinderGeometry.d.ts +21 -0
  198. package/src/shade/renderer/geometry/CylinderGeometry.d.ts.map +1 -0
  199. package/src/shade/renderer/geometry/CylinderGeometry.js +35 -0
  200. package/src/shade/renderer/geometry/PlaneGeometry.d.ts +17 -0
  201. package/src/shade/renderer/geometry/PlaneGeometry.d.ts.map +1 -0
  202. package/src/shade/renderer/geometry/PlaneGeometry.js +22 -0
  203. package/src/shade/renderer/geometry/TorusGeometry.d.ts +18 -0
  204. package/src/shade/renderer/geometry/TorusGeometry.d.ts.map +1 -0
  205. package/src/shade/renderer/geometry/TorusGeometry.js +23 -0
  206. package/src/shade/renderer/geometry/UVSphereGeometry.d.ts +21 -0
  207. package/src/shade/renderer/geometry/UVSphereGeometry.d.ts.map +1 -0
  208. package/src/shade/renderer/geometry/UVSphereGeometry.js +34 -0
  209. package/src/shade/renderer/geometry/primitives/make_capsule_geometry.d.ts +19 -0
  210. package/src/shade/renderer/geometry/primitives/make_capsule_geometry.d.ts.map +1 -0
  211. package/src/shade/renderer/geometry/primitives/make_capsule_geometry.js +205 -0
  212. package/src/shade/renderer/geometry/primitives/make_cone_geometry.d.ts +21 -0
  213. package/src/shade/renderer/geometry/primitives/make_cone_geometry.d.ts.map +1 -0
  214. package/src/shade/renderer/geometry/primitives/make_cone_geometry.js +36 -0
  215. package/src/shade/renderer/geometry/primitives/make_cylinder_geometry.d.ts +1 -1
  216. package/src/shade/renderer/geometry/primitives/make_cylinder_geometry.d.ts.map +1 -1
  217. package/src/shade/renderer/geometry/primitives/make_cylinder_geometry.js +44 -9
  218. package/src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.d.ts +20 -0
  219. package/src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.d.ts.map +1 -0
  220. package/src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.js +190 -0
  221. package/src/shade/renderer/geometry/virtual/runtime/graph_vgeo_expand_instances_to_meshlets.d.ts.map +1 -1
  222. package/src/shade/renderer/geometry/virtual/runtime/graph_vgeo_expand_instances_to_meshlets.js +7 -2
  223. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.d.ts +26 -8
  224. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.d.ts.map +1 -1
  225. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.js +56 -39
  226. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.d.ts +7 -0
  227. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.d.ts.map +1 -1
  228. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.js +46 -4
  229. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/test_prefix_sum.d.ts.map +1 -1
  230. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/test_prefix_sum.js +4 -2
  231. package/src/shade/renderer/gpu_primitive/sort/defs.d.ts +2 -2
  232. package/src/shade/renderer/gpu_primitive/sort/defs.js +79 -79
  233. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.d.ts +1 -1
  234. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.d.ts.map +1 -1
  235. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.js +7 -3
  236. package/src/shade/renderer/lightmap/bake/shader_lightmap_denoise_sh.d.ts.map +1 -1
  237. package/src/shade/renderer/lightmap/bake/shader_lightmap_denoise_sh.js +10 -3
  238. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  239. package/src/shade/renderer/particles/DESIGN.md +13 -9
  240. package/src/shade/renderer/particles/GPUParticleSystem.js +1 -1
  241. package/src/shade/renderer/particles/coherence/graph_particle_bucket.d.ts +4 -3
  242. package/src/shade/renderer/particles/coherence/graph_particle_bucket.d.ts.map +1 -1
  243. package/src/shade/renderer/particles/coherence/graph_particle_bucket.js +200 -194
  244. package/src/shade/renderer/particles/graph_particles.d.ts.map +1 -1
  245. package/src/shade/renderer/particles/graph_particles.js +6 -2
  246. package/src/shade/renderer/particles/shaders/chunk_particle_lighting.d.ts +1 -1
  247. package/src/shade/renderer/particles/shaders/chunk_particle_lighting.js +1 -1
  248. package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts.map +1 -1
  249. package/src/shade/renderer/particles/warmup/graph_particle_warmup.js +334 -329
  250. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  251. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.d.ts.map +1 -1
  252. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.js +7 -2
  253. package/src/shade/renderer/rasterize/expand/mesh/graph_expand_meshes_to_meshlets.d.ts.map +1 -1
  254. package/src/shade/renderer/rasterize/expand/mesh/graph_expand_meshes_to_meshlets.js +16 -4
  255. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.d.ts +3 -2
  256. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.d.ts.map +1 -1
  257. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.js +3 -2
  258. package/src/shade/renderer/scene/GPUSceneContext.d.ts +9 -1
  259. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  260. package/src/shade/renderer/scene/GPUSceneContext.js +23 -1
  261. package/src/shade/renderer/texture/COMPRESSED_TEXTURE_PLAN_2026_09_01.md +2444 -2345
  262. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts.map +1 -1
  263. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.js +312 -310
  264. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts +3 -3
  265. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts.map +1 -1
  266. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.js +383 -375
  267. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.d.ts.map +1 -1
  268. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.js +349 -346
  269. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts +58 -0
  270. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts.map +1 -0
  271. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.js +536 -0
  272. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts +21 -7
  273. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts.map +1 -1
  274. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.js +291 -327
  275. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode1.d.ts +25 -0
  276. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode1.d.ts.map +1 -0
  277. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode1.js +99 -0
  278. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode6.d.ts +5 -3
  279. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode6.d.ts.map +1 -1
  280. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode6.js +47 -71
  281. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.d.ts +10 -0
  282. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.d.ts.map +1 -0
  283. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.js +50 -0
  284. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.d.ts +4 -5
  285. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.d.ts.map +1 -1
  286. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.js +7 -8
  287. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts +4 -1
  288. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts.map +1 -1
  289. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +74 -3
  290. package/src/shade/renderer/volumetrics/NOTES.md +1023 -957
  291. package/src/shade/renderer/volumetrics/chunk_volumetrics_irradiance_sh.d.ts +5 -4
  292. package/src/shade/renderer/volumetrics/chunk_volumetrics_irradiance_sh.d.ts.map +1 -1
  293. package/src/shade/renderer/volumetrics/chunk_volumetrics_irradiance_sh.js +5 -4
  294. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.d.ts +1 -1
  295. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.js +1 -1
  296. package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.d.ts +1 -1
  297. package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.js +1 -1
  298. package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.d.ts +41 -0
  299. package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.d.ts.map +1 -0
  300. package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.js +112 -0
  301. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts +9 -23
  302. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts.map +1 -1
  303. package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +18 -126
  304. package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.d.ts +22 -0
  305. package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.d.ts.map +1 -0
  306. package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.js +228 -0
  307. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.d.ts.map +1 -1
  308. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js +0 -53
  309. package/src/shade/renderer/water/chunk_water_transport.d.ts.map +1 -1
  310. package/src/shade/renderer/water/chunk_water_transport.js +7 -5
  311. package/src/shade/renderer/water/medium/GPUWaterBodies.d.ts.map +1 -1
  312. package/src/shade/renderer/water/medium/GPUWaterBodies.js +8 -2
  313. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.d.ts +3 -2
  314. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.d.ts.map +1 -1
  315. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.js +3 -2
  316. package/src/shade/renderer/water/shader_water.d.ts.map +1 -1
  317. package/src/shade/renderer/water/shader_water.js +3 -1
  318. package/src/shade/renderer/water/surface/GPUWaterSurface.d.ts.map +1 -1
  319. package/src/shade/renderer/water/surface/GPUWaterSurface.js +3 -1
  320. package/src/shade/renderer/water/surface/chunk_water_surface_sample.d.ts +4 -3
  321. package/src/shade/renderer/water/surface/chunk_water_surface_sample.d.ts.map +1 -1
  322. package/src/shade/renderer/water/surface/chunk_water_surface_sample.js +17 -7
  323. package/src/shade/renderer/water/surface/graph_water_tessellation.d.ts.map +1 -1
  324. package/src/shade/renderer/water/surface/graph_water_tessellation.js +11 -4
  325. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.d.ts.map +1 -1
  326. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.js +93 -30
  327. package/src/shade/renderer/water/surface/particles/WATER_PARTICLE_STRUCT.d.ts.map +1 -1
  328. package/src/shade/renderer/water/surface/particles/WATER_PARTICLE_STRUCT.js +13 -5
  329. package/src/shade/renderer/water/surface/particles/chunk_water_particle.d.ts +29 -8
  330. package/src/shade/renderer/water/surface/particles/chunk_water_particle.d.ts.map +1 -1
  331. package/src/shade/renderer/water/surface/particles/chunk_water_particle.js +155 -30
  332. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.d.ts +6 -1
  333. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.d.ts.map +1 -1
  334. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.js +157 -39
  335. package/src/shade/renderer/water/surface/particles/shader_water_particles.d.ts +91 -21
  336. package/src/shade/renderer/water/surface/particles/shader_water_particles.d.ts.map +1 -1
  337. package/src/shade/renderer/water/surface/particles/shader_water_particles.js +442 -70
  338. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +11 -3
  339. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  340. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +3 -0
  341. package/src/shade/wgsl/validate_wgsl_source.d.ts.map +1 -1
  342. package/src/shade/wgsl/validate_wgsl_source.js +74 -3
  343. package/src/engine/graphics3/register_instance_animation.d.ts +0 -114
  344. package/src/engine/graphics3/register_instance_animation.d.ts.map +0 -1
  345. package/src/engine/graphics3/register_instance_animation.js +0 -201
@@ -0,0 +1,228 @@
1
+ import { CAMERA_UNIFORM_STRUCT } from "../camera/CAMERA_UNIFORM_STRUCT.js";
2
+ import { chunk_light_cluster_counts } from "../light/cluster/chunk_light_cluster_counts.js";
3
+ import { chunk_light_cluster_metadata_by_position } from "../light/cluster/chunk_light_cluster_metadata_by_position.js";
4
+ import { LIGHT_CLUSTER_LOOKUP_STRUCT } from "../light/cluster/shader_cluster_assign_lights.js";
5
+ import { chunk_cluster_depth_from_z_slice } from "../light/cluster/chunk_cluster_depth_from_z_slice.js";
6
+ import { chunk_camera_ray_from_uv } from "../shader/chunk/geometry/ray/chunk_camera_ray_from_uv.js";
7
+ import { RAY_STRUCT } from "../shader/chunk/geometry/ray/RAY_STRUCT.js";
8
+ import { chunk_stbn_sample_vec3 } from "../shader/chunk/noise/chunk_stbn_sample_vec3.js";
9
+ import {
10
+ chunk_directional_lights_iteration_mask
11
+ } from "../shader/chunk/light/io/chunk_directional_lights_iteration_mask.js";
12
+ import {
13
+ chunk_get_directional_light_info_by_index
14
+ } from "../shader/chunk/light/io/chunk_get_directional_light_info_by_index.js";
15
+ import {
16
+ chunk_get_point_light_info_by_index
17
+ } from "../shader/chunk/light/io/chunk_get_point_light_info_by_index.js";
18
+ import { chunk_get_spot_light_info_by_index } from "../shader/chunk/light/io/chunk_get_spot_light_info_by_index.js";
19
+ import {
20
+ METRO_L1_IRRADIANCE_STRUCT
21
+ } from "../shader/chunk/spherical_harmonics/l1i/chunk_convert_to_irradiance_sh.js";
22
+ import { chunk_texel_coordinate_to_uv } from "../shader/chunk/texture/chunk_texel_coordinate_to_uv.js";
23
+ import { chunk_uv_to_texel_coordinate } from "../shader/chunk/texture/chunk_uv_to_texel_coordinate.js";
24
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
25
+ import { ComputeShader } from "../shader/ComputeShader.js";
26
+ import { ShaderResourceSetDescriptor } from "../shader/resource/ShaderResourceSetDescriptor.js";
27
+ import { vec3f } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
28
+ import { WebGPUArray } from "../shader/type/WebGPUArray.js";
29
+ import { chunk_shadowmap_get_light_visibility } from "../shadow/map/shader/chunk_shadowmap_get_light_visibility.js";
30
+ import { SHADOWMAP_COMPARE_SAMPLER_DESCRIPTOR } from "../shadow/map/SHADOWMAP_COMPARE_SAMPLER_DESCRIPTOR.js";
31
+ import { VIEW_UNIFORM_STRUCT } from "../view/VIEW_UNIFORM_STRUCT.js";
32
+ import { chunk_volumetrics_irradiance_sh } from "./chunk_volumetrics_irradiance_sh.js";
33
+ import { chunk_volumetrics_local_light_shadow } from "./chunk_volumetrics_local_light_shadow.js";
34
+ import { chunk_camera_ray_planar_depth_scale } from "./chunk_camera_ray_planar_depth_scale.js";
35
+ import { chunk_volumetrics_column_jitter } from "./chunk_volumetrics_column_jitter.js";
36
+ import { VOLUMETRICS_METADATA_STRUCT } from "./VOLUMETRICS_METADATA_STRUCT.js";
37
+
38
+ /**
39
+ * Workgroup shape of this pass, `[x, y, z]` in froxels, stated to the `@workgroup_size` below and
40
+ * read back out of it by the dispatch. Flat in z and 64 invocations, for the reasons the fog's
41
+ * lighting pass gives (`VOLUMETRICS_LIGHTING_WORKGROUP_RESOLUTION`): it walks the same light
42
+ * clusters, and those are farthest apart along depth.
43
+ *
44
+ * @type {number[]}
45
+ */
46
+ export const VOLUMETRICS_IRRADIANCE_WORKGROUP_RESOLUTION = [8, 8, 1];
47
+
48
+ const resources = new ShaderResourceSetDescriptor();
49
+
50
+ // The froxel irradiance volume (chunk_volumetrics_irradiance_sh): luma SH2 in one, chroma in the .rg
51
+ // of the other. rgba16float for both, because rg16float is not a storage format without
52
+ // texture-formats-tier1. It starts from what the froxel GI stage (gi/) wrote to tGIY / tGICoCg.
53
+ resources.createGroup()
54
+ .addUniform("volumetrics_metadata", VOLUMETRICS_METADATA_STRUCT)
55
+ .addUniform("camera", CAMERA_UNIFORM_STRUCT)
56
+ .addUniform("view", VIEW_UNIFORM_STRUCT)
57
+ .addTexture("tSTBN_vec3", "unfilterable-float", "3d")
58
+ .addTexture("tGIY", "float", "3d")
59
+ .addTexture("tGICoCg", "float", "3d")
60
+ .addStorageTexture("tIrradianceY", "rgba16float", "3d", "write-only")
61
+ .addStorageTexture("tIrradianceCoCg", "rgba16float", "3d", "write-only");
62
+
63
+ // Lighting information
64
+ resources.createGroup()
65
+ .addStorageBuffer("light_data", WebGPUArray.u32)
66
+ // clusters
67
+ .addUniform("cluster_parameters", vec3f)
68
+ .addStorageBuffer("cluster_lookup", LIGHT_CLUSTER_LOOKUP_STRUCT)
69
+ .addStorageBuffer("cluster_data", WebGPUArray.u32)
70
+ // shadows
71
+ .addTexture("shadowmapAtlas", "depth")
72
+ .addSampler("sCompareLinear", "comparison", SHADOWMAP_COMPARE_SAMPLER_DESCRIPTOR);
73
+
74
+ const body = CodeChunk.from(
75
+ //language=WGSL
76
+ `
77
+ @compute @workgroup_size(${VOLUMETRICS_IRRADIANCE_WORKGROUP_RESOLUTION.join(",")})
78
+ fn main(
79
+ @builtin(global_invocation_id) voxel : vec3<u32>
80
+ ){
81
+ let resolution = textureDimensions(tIrradianceY);
82
+
83
+ if (any(voxel >= resolution)) {
84
+ return;
85
+ }
86
+
87
+ // The fog lighting pass's sample, taken the same way (shader_volumetrics_build_lighting, where
88
+ // the irradiance was written until it had a pass of its own): one point per froxel per frame,
89
+ // jittered across the slab in depth by the column jitter and the blue noise, and in xy by the
90
+ // blue noise. Never a fixed point. A particle spans many froxels and reads them trilinearly, and
91
+ // a lattice of samples that never moves shows on it as seams wherever neighbouring texels
92
+ // disagree — beside a light, along a shadow edge. Moved every frame, the lattice is resolved by
93
+ // the main TAA, which the particles are drawn ahead of.
94
+ let near_far = camera.clip_near_far;
95
+ let curve = volumetrics_metadata.froxel_cluster_parameters;
96
+
97
+ let z_jitter = volumetrics_column_jitter(voxel.xy, view.frame_index);
98
+
99
+ let z0 = max(near_far.x, cluster_depth_from_z_slice(f32(voxel.z) + z_jitter, curve, f32(resolution.z)));
100
+ let z1 = min(near_far.y, cluster_depth_from_z_slice(f32(voxel.z + 1u) + z_jitter, curve, f32(resolution.z)));
101
+
102
+ // the lighting pass's offset and temporal axis, so the two passes ask about the same point
103
+ const STBN_DECORRELATION_OFFSET = vec2<u32>(37u, 71u);
104
+
105
+ let noise = stbn_sample_vec3(vec3(voxel.xy + STBN_DECORRELATION_OFFSET, view.frame_index + voxel.z));
106
+
107
+ // interpolate the cubes, then take the cube root: uniform in world-space volume across the slab
108
+ let view_depth = pow(mix(z0 * z0 * z0, z1 * z1 * z1, noise.z), 0.333333);
109
+
110
+ let tile_uv = saturate(texel_coordinate_to_uv(vec2<f32>(voxel.xy) + (noise.xy - 0.5), resolution.xy));
111
+ let view_ray = camera_ray_from_uv(tile_uv, camera);
112
+
113
+ // view_depth is planar, so step the ray by the planar-to-distance scale
114
+ let position_ws = view_ray.origin
115
+ + view_ray.direction * (view_depth * camera_ray_planar_depth_scale(view_ray.direction, camera));
116
+
117
+ let view_pixel_coord = uv_to_texel_coordinate(tile_uv, vec2(view.width, view.height));
118
+
119
+ var irradiance: ${METRO_L1_IRRADIANCE_STRUCT.wgsl_ref};
120
+
121
+ // Each light as the surfaces around the froxel receive it: its colour and its shadow, and no
122
+ // medium on the way in. The deferred and forward paths light meshes by exactly this, and a lit
123
+ // particle beside a lit log has to agree with it — the fog is composited over both afterwards.
124
+
125
+ var directional_bits = directional_lights_iteration_mask(&light_data);
126
+ while (directional_bits != 0u) {
127
+ let directional_index = countTrailingZeros(directional_bits);
128
+ directional_bits &= ~(1u << directional_index);
129
+
130
+ let sun = get_directional_light_info_by_index(&light_data, directional_index);
131
+
132
+ let shadow_term = shadowmap_get_directional_light_visibility(
133
+ &light_data,
134
+ directional_index,
135
+ position_ws,
136
+ // toward-camera, the deferred cascade-blend convention; view_ray runs camera->scene
137
+ -view_ray.direction,
138
+ sun.direction
139
+ );
140
+
141
+ irradiance = volumetrics_irradiance_sh_add(irradiance, shadow_term * sun.color, sun.direction);
142
+ }
143
+
144
+ let cluster_metadata = light_cluster_metadata_by_position(
145
+ view_pixel_coord,
146
+ view_depth,
147
+ vec2(view.width, view.height)
148
+ );
149
+
150
+ let cluster_offset = cluster_metadata.offset;
151
+ let point_count = light_cluster_count_point(cluster_metadata.counts);
152
+ let spot_count = light_cluster_count_spot(cluster_metadata.counts);
153
+
154
+ for (var j = 0u; j < point_count; j++) {
155
+ let light_index = cluster_data[cluster_offset + j];
156
+ let direct_light = get_point_light_info_by_index(&light_data, light_index, position_ws);
157
+
158
+ if (all(direct_light.color == vec3(0.0))) {
159
+ continue;
160
+ }
161
+
162
+ let shadow_term = volumetrics_point_light_shadow(&light_data, light_index, position_ws);
163
+
164
+ irradiance = volumetrics_irradiance_sh_add(irradiance, shadow_term * direct_light.color, direct_light.direction);
165
+ }
166
+
167
+ for (var k = 0u; k < spot_count; k++) {
168
+ let light_index = cluster_data[cluster_offset + point_count + k];
169
+ let direct_light = get_spot_light_info_by_index(&light_data, light_index, position_ws);
170
+
171
+ if (all(direct_light.color == vec3(0.0))) {
172
+ continue;
173
+ }
174
+
175
+ let shadow_term = volumetrics_spot_light_shadow(&light_data, light_index, position_ws);
176
+
177
+ irradiance = volumetrics_irradiance_sh_add(irradiance, shadow_term * direct_light.color, direct_light.direction);
178
+ }
179
+
180
+ // What the renderer's indirect lighting gives this froxel, in the same encoding; the lights add
181
+ // to it. Written by the froxel GI module the mode selects, which is all this pass knows of GI.
182
+ irradiance.Y += textureLoad(tGIY, voxel, 0);
183
+ irradiance.CoCg += textureLoad(tGICoCg, voxel, 0).xy;
184
+
185
+ // nothing filters this volume, so nothing downstream would stop an Inf or a NaN here
186
+ let stored = volumetrics_irradiance_sh_storable(irradiance);
187
+
188
+ textureStore(tIrradianceY, voxel, stored.Y);
189
+ textureStore(tIrradianceCoCg, voxel, vec4<f32>(stored.CoCg, 0.0, 0.0));
190
+ }
191
+ `, [
192
+ METRO_L1_IRRADIANCE_STRUCT.declaration_chunk,
193
+ RAY_STRUCT.declaration_chunk,
194
+ chunk_volumetrics_column_jitter,
195
+ chunk_cluster_depth_from_z_slice,
196
+ chunk_stbn_sample_vec3,
197
+ chunk_texel_coordinate_to_uv,
198
+ chunk_uv_to_texel_coordinate,
199
+ chunk_camera_ray_from_uv,
200
+ chunk_camera_ray_planar_depth_scale,
201
+
202
+ chunk_light_cluster_metadata_by_position,
203
+ chunk_light_cluster_counts,
204
+ chunk_directional_lights_iteration_mask,
205
+ chunk_get_directional_light_info_by_index,
206
+ chunk_get_point_light_info_by_index,
207
+ chunk_get_spot_light_info_by_index,
208
+ chunk_shadowmap_get_light_visibility,
209
+ chunk_volumetrics_local_light_shadow,
210
+ chunk_volumetrics_irradiance_sh,
211
+ ]
212
+ );
213
+
214
+ /**
215
+ * The froxel irradiance volume (`chunk_volumetrics_irradiance_sh`): what a lit particle standing in a
216
+ * froxel is lit by. Starts from the froxel GI stage's volume and adds every directional, point and
217
+ * spot light with its shadow, at a point jittered through the froxel every frame.
218
+ *
219
+ * Its own pass, not a by-product of the fog's lighting pass: particle lighting needs no medium, so it
220
+ * runs whether or not the scene has any fog, and the frame graph culls it when nothing reads it.
221
+ *
222
+ * @type {ComputeShader}
223
+ */
224
+ export const shader_volumetrics_build_irradiance = ComputeShader.from({
225
+ label: "Volumetrics / build irradiance",
226
+ resources,
227
+ body,
228
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"shader_volumetrics_build_lighting.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js"],"names":[],"mappings":"AAiDA;;;;;;;;;;;;;;;GAeG;AACH,wDAFU,MAAM,EAAE,CAEiD;AAkanE,8DAIE;8BAnd4B,4BAA4B"}
1
+ {"version":3,"file":"shader_volumetrics_build_lighting.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js"],"names":[],"mappings":"AA6CA;;;;;;;;;;;;;;;GAeG;AACH,wDAFU,MAAM,EAAE,CAEiD;AAiXnE,8DAIE;8BA9Z4B,4BAA4B"}
@@ -41,10 +41,6 @@ import {
41
41
  import { VOLUMETRICS_SUN_SHADOW_CASCADE_COUNT } from "./VOLUMETRICS_SUN_SHADOW_RESOLUTION.js";
42
42
  import { chunk_volumetrics_column_jitter } from "./chunk_volumetrics_column_jitter.js";
43
43
  import { chunk_volumetrics_local_light_shadow } from "./chunk_volumetrics_local_light_shadow.js";
44
- import { chunk_volumetrics_irradiance_sh } from "./chunk_volumetrics_irradiance_sh.js";
45
- import {
46
- METRO_L1_IRRADIANCE_STRUCT
47
- } from "../shader/chunk/spherical_harmonics/l1i/chunk_convert_to_irradiance_sh.js";
48
44
  import { VOLUMETRICS_METADATA_STRUCT } from "./VOLUMETRICS_METADATA_STRUCT.js";
49
45
 
50
46
  /**
@@ -87,14 +83,6 @@ for (let cascade = 0; cascade < VOLUMETRICS_SUN_SHADOW_CASCADE_COUNT; cascade++)
87
83
 
88
84
  primary_group.addStorageTexture("tLighting", "rgba16float", "3d", "write-only")
89
85
 
90
- // The froxel irradiance volume (chunk_volumetrics_irradiance_sh): luma SH2 in one, chroma in the
91
- // .rg of the other. rgba16float for both, because rg16float is not a storage format without
92
- // texture-formats-tier1. It is what the froxel GI stage (gi/) wrote to tGIY / tGICoCg, plus the lights.
93
- primary_group.addTexture("tGIY", "float", "3d")
94
- primary_group.addTexture("tGICoCg", "float", "3d")
95
- primary_group.addStorageTexture("tIrradianceY", "rgba16float", "3d", "write-only")
96
- primary_group.addStorageTexture("tIrradianceCoCg", "rgba16float", "3d", "write-only")
97
-
98
86
  // Lighting information
99
87
  resources.createGroup()
100
88
 
@@ -144,11 +132,6 @@ fn main(
144
132
  var inScatteringSum = vec3<f32>(0.0);
145
133
  var extinctionSum = 0.0;
146
134
 
147
- // What a transparent surface at the sample receives from the same lights: their shadowed
148
- // colour, attenuated by the medium toward each light, before any scattering by it.
149
- var irradianceSum: ${METRO_L1_IRRADIANCE_STRUCT.wgsl_ref};
150
-
151
-
152
135
  // One sample per froxel. The 0.95-blend TAA downstream is a ~39-effective-sample temporal
153
136
  // integrator; supersampling here as well spends N times this pass removing variance that filter
154
137
  // removes anyway — and spends it at the Monte Carlo rate, because the samples were independent
@@ -313,15 +296,6 @@ fn main(
313
296
  );
314
297
 
315
298
  inScatteringSum += shadow_term * ms * transmittance_atmospheric * sun.color;
316
-
317
- // No atmospheric transmittance: that is the air's, and a surface in the volume is lit
318
- // the way the surfaces around it are — the deferred and forward paths light meshes by
319
- // sun.color as it stands, and a lit particle beside a lit log has to agree with it.
320
- irradianceSum = volumetrics_irradiance_sh_add(
321
- irradianceSum,
322
- shadow_term * exp(-optical_depth) * sun.color,
323
- sun.direction
324
- );
325
299
  }
326
300
 
327
301
  // Local lights
@@ -374,12 +348,6 @@ fn main(
374
348
  let shadow_term = volumetrics_point_light_shadow(&light_data, light_index, position_ws);
375
349
 
376
350
  inScatteringSum += shadow_term * ms * direct_light.color;
377
-
378
- irradianceSum = volumetrics_irradiance_sh_add(
379
- irradianceSum,
380
- shadow_term * exp(-optical_depth) * direct_light.color,
381
- direct_light.direction
382
- );
383
351
  }
384
352
 
385
353
  for (var k = 0u; k < spot_count; k++) {
@@ -415,12 +383,6 @@ fn main(
415
383
  let shadow_term = volumetrics_spot_light_shadow(&light_data, light_index, position_ws);
416
384
 
417
385
  inScatteringSum += shadow_term * ms * direct_light.color;
418
-
419
- irradianceSum = volumetrics_irradiance_sh_add(
420
- irradianceSum,
421
- shadow_term * exp(-optical_depth) * direct_light.color,
422
- direct_light.direction
423
- );
424
386
  }
425
387
  }
426
388
 
@@ -435,20 +397,6 @@ fn main(
435
397
  let extinction = extinctionSum / f32(SAMPLE_COUNT);
436
398
 
437
399
  textureStore(tLighting, voxel_coord, vec4<f32>(inScattering, extinction));
438
-
439
- irradianceSum.Y /= f32(SAMPLE_COUNT);
440
- irradianceSum.CoCg /= f32(SAMPLE_COUNT);
441
-
442
- // What the renderer's indirect lighting gives this froxel, in the same encoding; the lights add
443
- // to it. Written by the froxel GI module the mode selects, which is all this pass knows of GI.
444
- irradianceSum.Y += textureLoad(tGIY, voxel_coord, 0);
445
- irradianceSum.CoCg += textureLoad(tGICoCg, voxel_coord, 0).xy;
446
-
447
- // nothing TAA-filters this volume, so nothing downstream would stop an Inf or a NaN here
448
- let irradiance = volumetrics_irradiance_sh_storable(irradianceSum);
449
-
450
- textureStore(tIrradianceY, voxel_coord, irradiance.Y);
451
- textureStore(tIrradianceCoCg, voxel_coord, vec4<f32>(irradiance.CoCg, 0.0, 0.0));
452
400
  }
453
401
  `, [
454
402
  chunk_cluster_depth_from_z_slice,
@@ -469,7 +417,6 @@ fn main(
469
417
  chunk_get_spot_light_info_by_index,
470
418
  chunk_shadowmap_get_light_visibility,
471
419
  chunk_volumetrics_local_light_shadow,
472
- chunk_volumetrics_irradiance_sh,
473
420
  chunk_sky_lut_compute_uv,
474
421
 
475
422
  RAY_STRUCT.declaration_chunk,
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_water_transport.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/water/chunk_water_transport.js"],"names":[],"mappings":"AAUA,0DAEG;AAEH,0DAeG;AAEH,8CAsBG;AAGH,mDAS6F;AAI7F,sDAmCoE;0BAxG1C,iCAAiC"}
1
+ {"version":3,"file":"chunk_water_transport.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/water/chunk_water_transport.js"],"names":[],"mappings":"AAUA,0DAEG;AAEH,0DAeG;AAEH,8CAsBG;AAIH,mDAU6F;AAI7F,sDAmCoE;0BA1G1C,iCAAiC"}
@@ -53,15 +53,17 @@ fn water_transport(event: WaterEvent, original: vec3f, receiver: vec3f,
53
53
  }
54
54
  `);
55
55
 
56
- // One G-buffer texel in world space: its stored depth, texel-center position and face normal.
56
+ // One G-buffer texel in world space: its stored depth, texel-center position, its triangle's face normal, which
57
+ // is where the surface is, and the normal it was shaded with, which is what lit it.
57
58
  export const chunk_water_receiver_texel = CodeChunk.from(/* language=WGSL */ `
58
- struct WaterReceiverTexel { depth: f32, position: vec3f, normal: vec3f }
59
+ struct WaterReceiverTexel { depth: f32, position: vec3f, face_normal: vec3f, shading_normal: vec3f }
59
60
  fn water_receiver_texel(depth: texture_2d<f32>, normals: texture_2d<u32>, coord: vec2i,
60
61
  inverse_projection: mat4x4f, inverse_view: mat4x4f) -> WaterReceiverTexel {
61
62
  let d = textureLoad(depth, coord, 0).r;
62
63
  let center = texel_coordinate_to_uv(vec2f(coord), textureDimensions(depth, 0));
63
64
  let position = inverse_view * vec4f(inv_project_position(vec3f(center, d), inverse_projection), 1.0);
64
- return WaterReceiverTexel(d, position.xyz, decode_g_buffer_normal(textureLoad(normals, coord, 0).zw));
65
+ let encoded = textureLoad(normals, coord, 0);
66
+ return WaterReceiverTexel(d, position.xyz, decode_g_buffer_normal(encoded.zw), decode_g_buffer_normal(encoded.xy));
65
67
  }
66
68
  `, [chunk_decode_g_buffer_normal, chunk_inv_project_position, chunk_texel_coordinate_to_uv]);
67
69
 
@@ -92,8 +94,8 @@ fn water_receiver_radiance(scene: texture_2d<f32>, depth: texture_2d<f32>, norma
92
94
  let coord = clamp(base + vec2i(x,y), vec2i(0), size-1);
93
95
  let tap = water_receiver_texel(depth, normals, coord, inverse_projection, inverse_view);
94
96
  if (is_background(tap.depth) || (below_interface && dot(tap.position - surface, surface_normal) > WATER_LEVEL_TOLERANCE)
95
- || dot(center.normal, tap.normal) < 0.95
96
- || abs(dot(tap.position - center.position, center.normal)) > 0.02) { continue; }
97
+ || dot(center.face_normal, tap.face_normal) < 0.95
98
+ || abs(dot(tap.position - center.position, center.face_normal)) > 0.02) { continue; }
97
99
  let w = select(1.0-f.x, f.x, x == 1) * select(1.0-f.y, f.y, y == 1);
98
100
  color += w * textureLoad(scene, coord, 0).rgb;
99
101
  weight += w;
@@ -1 +1 @@
1
- {"version":3,"file":"GPUWaterBodies.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/water/medium/GPUWaterBodies.js"],"names":[],"mappings":"AAcA,4FAA4F;AAC5F;IACI;;;;;;OAMG;IACH;;;;;;;;QAFa;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC,CA8ClD;CACJ"}
1
+ {"version":3,"file":"GPUWaterBodies.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/water/medium/GPUWaterBodies.js"],"names":[],"mappings":"AAkBA,4FAA4F;AAC5F;IACI;;;;;;OAMG;IACH;;;;;;;;QAFa;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAC,CAgDlD;CACJ"}
@@ -1,6 +1,10 @@
1
1
  import { BufferResourceDescriptor } from "../../../device/graph/BufferResourceDescriptor.js";
2
2
  import { round_up } from "../../../../core/math/round_up.js";
3
- import { graph_prefix_scan_csdldf } from "../../gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.js";
3
+ import {
4
+ graph_prefix_scan_csdldf,
5
+ prefix_scan_csdldf_output_descriptor
6
+ } from "../../gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.js";
7
+ import { graph_create_buffer } from "../../shader/graph/graph_create_buffer.js";
4
8
  import {
5
9
  build_indirect_compute_dispatch_command,
6
10
  INDIRECT_COMPUTE_COMMAND_DESCRIPTOR
@@ -42,7 +46,9 @@ export class GPUWaterBodies {
42
46
  data.command = pass.create('Water lod bodies command', INDIRECT_COMPUTE_COMMAND_DESCRIPTOR);
43
47
  data.lod_bodies = pass.create('Water lod bodies', BufferResourceDescriptor.from(capacity * WATER_LOD_BODY_STRUCT.size,
44
48
  GPUBufferUsage.STORAGE));
45
- const sums = graph_prefix_scan_csdldf({ graph, data: data.counts, element_max_count: capacity });
49
+ const sums = graph_prefix_scan_csdldf({ graph, input: data.counts,
50
+ output: graph_create_buffer(graph, 'Water lod body meshlet sums', prefix_scan_csdldf_output_descriptor(capacity)),
51
+ element_max_count: capacity });
46
52
  const command_data = {};
47
53
  const command_pass = graph.add('Water / expand command', command_data, (d, resources, { encoder }) => {
48
54
  shader_prefix_sum_to_command.dispatch({ encoder, bindings: {
@@ -5,8 +5,9 @@
5
5
  * light that receiver was shaded with survives the water above it.
6
6
  *
7
7
  * The ratio is of the receiver's irradiance under the water to its irradiance dry, from what the
8
- * water pass can rebuild at the receiver — its position, G-buffer normal and depth below the
9
- * surface, the shadow map and the GI mode:
8
+ * water pass can rebuild at the receiver — its position, the normal it was shaded with (the G-buffer's
9
+ * shading normal, as deferred lighting takes n·l, the shadow lookup and GI on it; never its triangle's,
10
+ * which turns at every edge) and depth below the surface, the shadow map and the GI mode:
10
11
  *
11
12
  * - dry: each directional light × its shadow × n·l, plus the GI mode's irradiance on n;
12
13
  * - wet: each light refracted at the surface, so steeper, with the Fresnel transmittance, the beam's
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_water_receiver_downwelling.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/water/optics/chunk_water_receiver_downwelling.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,+CAFU,SAAS,CAyCmE;0BApE5D,oCAAoC"}
1
+ {"version":3,"file":"chunk_water_receiver_downwelling.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/water/optics/chunk_water_receiver_downwelling.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,+CAFU,SAAS,CAyCmE;0BArE5D,oCAAoC"}
@@ -16,8 +16,9 @@ import { chunk_water_optics } from "./chunk_water_optics.js";
16
16
  * light that receiver was shaded with survives the water above it.
17
17
  *
18
18
  * The ratio is of the receiver's irradiance under the water to its irradiance dry, from what the
19
- * water pass can rebuild at the receiver — its position, G-buffer normal and depth below the
20
- * surface, the shadow map and the GI mode:
19
+ * water pass can rebuild at the receiver — its position, the normal it was shaded with (the G-buffer's
20
+ * shading normal, as deferred lighting takes n·l, the shadow lookup and GI on it; never its triangle's,
21
+ * which turns at every edge) and depth below the surface, the shadow map and the GI mode:
21
22
  *
22
23
  * - dry: each directional light × its shadow × n·l, plus the GI mode's irradiance on n;
23
24
  * - wet: each light refracted at the surface, so steeper, with the Fresnel transmittance, the beam's
@@ -1 +1 @@
1
- {"version":3,"file":"shader_water.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/water/shader_water.js"],"names":[],"mappings":"AAwmBA,kEAAuH;AACvH,+EAA+J;AAC/J,kFAAqK;AA/jBrK,8CAKwB;AAiCxB,oGAAoG;AACpG,uEAAkE;AAGlE,gGAAgG;AAChG,0EAAqE;AAqOrE,+CA+EmB;AA6LnB,4CAAmG;AACnG,kFAAkF;AAClF,yDAC8G;AAC9G,oCAAoC;AACpC,4DACoH;AACpH,0DAAyC;yCA5kBA,8DAA8D;6BAmB1E,gCAAgC;4CAJjB,mDAAmD;0BADrE,iCAAiC;iCAE1B,+BAA+B"}
1
+ {"version":3,"file":"shader_water.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/water/shader_water.js"],"names":[],"mappings":"AA0mBA,kEAAuH;AACvH,+EAA+J;AAC/J,kFAAqK;AAjkBrK,8CAKwB;AAiCxB,oGAAoG;AACpG,uEAAkE;AAGlE,gGAAgG;AAChG,0EAAqE;AAqOrE,+CA+EmB;AA+LnB,4CAAmG;AACnG,kFAAkF;AAClF,yDAC8G;AAC9G,oCAAoC;AACpC,4DACoH;AACpH,0DAAyC;yCA9kBA,8DAA8D;6BAmB1E,gCAAgC;4CAJjB,mDAAmD;0BADrE,iCAAiC;iCAE1B,+BAA+B"}
@@ -550,12 +550,14 @@ fn fs_main(in: WaterVertexOut, @builtin(front_facing) above: bool) -> WaterOptic
550
550
  } else { confidence = 0.0; }
551
551
  // The opaque scene was shaded dry: what reaches the receiver is what survives the water above it
552
552
  // (WATER_OPTICS_PLAN_2026_10_02.md §4.3). Seen from under the surface, the receiver is above it.
553
+ // Its light is rebuilt on the normal it was shaded with: its triangle's turns at every edge of a
554
+ // tessellated floor, and every edge would show through the water.
553
555
  let receiver_texel = water_receiver_texel(tDepth, tNormal, receiver_coord, camera.projection_matrix_inverse,
554
556
  camera.view_matrix_inverse);
555
557
  if (above && !is_background(receiver_texel.depth)) {
556
558
  let camera_ws = camera.view_matrix_inverse[3].xyz;
557
559
  let up = normalize(in.rest_normal);
558
- color *= water_receiver_downwelling(body, receiver_texel.position, receiver_texel.normal, up,
560
+ color *= water_receiver_downwelling(body, receiver_texel.position, receiver_texel.shading_normal, up,
559
561
  max(dot(in.world - receiver_texel.position, up), 0.0), normalize(camera_ws - receiver_texel.position));
560
562
  }
561
563
  // Light in the water body (WATER_OPTICS_PLAN_2026_10_02.md §4.4): the receiver attenuated along
@@ -1 +1 @@
1
- {"version":3,"file":"GPUWaterSurface.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/water/surface/GPUWaterSurface.js"],"names":[],"mappings":"AAmBA,uHAAuH;AACvH,2CAA4C;AAE5C,4EAA4E;AAC5E,6DAKI;AAEJ;;;;;;GAMG;AACH;IACI,4FAA4F;IAC5F,yBAAgC;IAChC,oEAAoE;IACpE,0BAA0B;IAC1B,6EAA6E;IAC7E,eAAc;IACd;;;OAGG;IACH,kBAAiB;IAejB,mCAA0D;IAC1D,kCAAwD;IACxD,kCAA0D;IAC1D,kCAA0D;IAC1D,kHAAkH;IAClH,uBAAmC;IACnC,qGAAqG;IACrG,0BAAyC;IACzC,gHAAgH;IAChH,8BAA2D;IAC3D,mCAA2C;IAE3C;;;OAGG;IACH,YAFW,MAAM,QAKhB;IAED,gBAWC;IAsBD;;;;;;;;;;;OAWG;IACH;QAVsG,KAAK,EAAhG,OAAO,8DAA8D,EAAE,UAAU;QAC9D,MAAM;QACT,KAAK,EAArB,MAAM;QACU,IAAI,EAApB,MAAM;QACU,IAAI;YACI,MAAM;YACE,UAAU,EAA1C,UAAU,MAAM,CAAC;YACI,MAAM,EAA3B,MAAM;;QACU,MAAM,EAAtB,MAAM;aAsEhB;;CACJ;kCApMiC,kDAAkD;mBAFjE,0CAA0C;kCAI3B,kCAAkC"}
1
+ {"version":3,"file":"GPUWaterSurface.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/water/surface/GPUWaterSurface.js"],"names":[],"mappings":"AAoBA,uHAAuH;AACvH,2CAA4C;AAE5C,4EAA4E;AAC5E,6DAKI;AAEJ;;;;;;GAMG;AACH;IACI,4FAA4F;IAC5F,yBAAgC;IAChC,oEAAoE;IACpE,0BAA0B;IAC1B,6EAA6E;IAC7E,eAAc;IACd;;;OAGG;IACH,kBAAiB;IAejB,mCAA0D;IAC1D,kCAAwD;IACxD,kCAA0D;IAC1D,kCAA0D;IAC1D,kHAAkH;IAClH,uBAAmC;IACnC,qGAAqG;IACrG,0BAAyC;IACzC,gHAAgH;IAChH,8BAA2D;IAC3D,mCAA2C;IAE3C;;;OAGG;IACH,YAFW,MAAM,QAKhB;IAED,gBAWC;IAuBD;;;;;;;;;;;OAWG;IACH;QAVsG,KAAK,EAAhG,OAAO,8DAA8D,EAAE,UAAU;QAC9D,MAAM;QACT,KAAK,EAArB,MAAM;QACU,IAAI,EAApB,MAAM;QACU,IAAI;YACI,MAAM;YACE,UAAU,EAA1C,UAAU,MAAM,CAAC;YACI,MAAM,EAA3B,MAAM;;QACU,MAAM,EAAtB,MAAM;aAsEhB;;CACJ;kCArMiC,kDAAkD;mBAHjE,0CAA0C;kCAK3B,kCAAkC"}
@@ -1,5 +1,6 @@
1
1
  import Signal from "../../../../core/events/signal/Signal.js";
2
2
  import { assert } from "../../../../core/assert.js";
3
+ import { round_up } from "../../../../core/math/round_up.js";
3
4
  import { SamplerDescriptor } from "../../../descriptor/texture/SamplerDescriptor.js";
4
5
  import { GPUWaterSpectrum } from "./spectrum/GPUWaterSpectrum.js";
5
6
  import { GPUWaterParticles } from "./particles/GPUWaterParticles.js";
@@ -104,7 +105,8 @@ export class GPUWaterSurface {
104
105
  usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC | usage });
105
106
  this.#steep = buffer('steep bodies', rows * 4);
106
107
  this.#activity = buffer('activity', rows * 4);
107
- const list = label => buffer(label, WATER_LIST_HEADER_BYTES + rows * 4);
108
+ // rows are aligned to 16, so WGSL rounds a list up to whole blocks of 4: one row binds 32 bytes, not 20
109
+ const list = label => buffer(label, WATER_LIST_HEADER_BYTES + round_up(rows, 4) * 4);
108
110
  this.#lists = { visible: list('visible rows'), active: list('active rows'), emit: list('emit rows') };
109
111
  this.#commands ??= buffer('surface commands', WATER_SURFACE_COMMAND_COUNT * WATER_SURFACE_COMMAND_STRIDE, GPUBufferUsage.INDIRECT);
110
112
  this.#rows = rows;
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Most particle entries one point reads, over every level. The bin pass thins a crowded cell to about
3
- * WATER_PARTICLE_CELL_SHARE packets, the same ones in every cell they reach, so a point reads all of its cells
4
- * unless several levels are crowded there at once.
2
+ * Most particle entries one point reads, over every level. Where a point would read more than
3
+ * WATER_PARTICLE_CELL_SHARE, the bin pass thins its cells to about that many between them, the same packets in every
4
+ * cell they reach, and where whole fronts would still crowd it past this, its cells keep no more than their part of
5
+ * it. So a point reads all of its cells, short of a cell only one front reaches (~40 entries at most).
5
6
  */
6
7
  export const WATER_PARTICLE_GATHER_BUDGET: 64;
7
8
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_water_surface_sample.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/water/surface/chunk_water_surface_sample.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,8CAA+C;AAE/C;;;;;;;;;;;;GAYG;AACH,yCAFU,SAAS,CAgMyC;0BAxNlC,oCAAoC"}
1
+ {"version":3,"file":"chunk_water_surface_sample.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/water/surface/chunk_water_surface_sample.js"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,8CAA+C;AAE/C;;;;;;;;;;;;GAYG;AACH,yCAFU,SAAS,CAyMyC;0BAlOlC,oCAAoC"}
@@ -5,9 +5,10 @@ import { chunk_water_spectrum } from "./spectrum/chunk_water_spectrum.js";
5
5
  import { chunk_water_particle } from "./particles/chunk_water_particle.js";
6
6
 
7
7
  /**
8
- * Most particle entries one point reads, over every level. The bin pass thins a crowded cell to about
9
- * WATER_PARTICLE_CELL_SHARE packets, the same ones in every cell they reach, so a point reads all of its cells
10
- * unless several levels are crowded there at once.
8
+ * Most particle entries one point reads, over every level. Where a point would read more than
9
+ * WATER_PARTICLE_CELL_SHARE, the bin pass thins its cells to about that many between them, the same packets in every
10
+ * cell they reach, and where whole fronts would still crowd it past this, its cells keep no more than their part of
11
+ * it. So a point reads all of its cells, short of a cell only one front reaches (~40 entries at most).
11
12
  */
12
13
  export const WATER_PARTICLE_GATHER_BUDGET = 64;
13
14
 
@@ -113,14 +114,17 @@ fn water_surface_sum(wave: u32, p: vec2<f32>, footprint: f32) -> WaterSurfaceSum
113
114
  }
114
115
  let table = water_particle_offsets.count;
115
116
  var visited = 0u;
116
- var particle_variance = 0.0;
117
+ // the slope of what the footprint cannot draw of the packets and the same a quarter carrier cycle on, summed as the
118
+ // surface sums them, so a front's packets roughen it alike however many they are
119
+ var unresolved = vec2<f32>(0.0);
120
+ var quadrature = vec2<f32>(0.0);
117
121
  // coarsest first: the budget goes to packets the footprint can draw before those it can only roughen
118
122
  for (var from_top = 0u; from_top < WATER_PARTICLE_LEVELS && table != 0u; from_top++) {
119
123
  let level = WATER_PARTICLE_LEVELS - 1u - from_top;
120
124
  if ((levels & (1u << level)) == 0u) { continue; }
121
125
  let size = water_particle_cell_size(level);
122
126
  let cell = vec2<i32>(floor(p / size));
123
- let key = (wave << 4u) | level;
127
+ let key = water_particle_key(wave, level);
124
128
  let bucket = water_particle_bucket(wave, level, cell, table);
125
129
  var start = 0u;
126
130
  if (bucket > 0u) { start = water_particle_offsets.elements[bucket - 1u]; }
@@ -129,16 +133,22 @@ fn water_surface_sum(wave: u32, p: vec2<f32>, footprint: f32) -> WaterSurfaceSum
129
133
  visited++;
130
134
  let entry = water_particle_entries[i];
131
135
  if (entry.key != key || any(entry.cell != cell)) { continue; }
132
- let field = water_particle_field(p - entry.position, entry.angle, entry.amplitude, entry.radius, entry.width, entry.phase);
136
+ let field = water_particle_field(p - entry.position, entry.angle, entry.amplitude, entry.radius, entry.half_length,
137
+ entry.dispersion, entry.distance, entry.phase);
133
138
  // a packet is geometry while its wavelength spans eight samples, fading out by four
134
139
  let f = clamp(log2(entry.radius / (2.0 * footprint)), 0.0, 1.0);
135
- particle_variance += (1.0 - f * f) * dot(field.slope, field.slope);
140
+ let rough = sqrt(1.0 - f * f);
141
+ unresolved += rough * field.slope;
142
+ quadrature += rough * field.displacement_gradient;
136
143
  sum.height += f * field.height;
137
144
  sum.slope += f * field.slope;
138
145
  sum.displacement += f * field.displacement;
139
146
  sum.jacobian += f * field.jacobian;
140
147
  }
141
148
  }
149
+ // the slope's mean square over a carrier cycle, as the bands' variance is (Bruneton, Neyret & Holzschuch 2010): at a
150
+ // point the slope alone swings from nothing to twice it with the carrier
151
+ let particle_variance = 0.5 * (dot(unresolved, unresolved) + dot(quadrature, quadrature));
142
152
  sum.variance = variance + particle_variance;
143
153
  sum.particle_variance = particle_variance;
144
154
  return sum;
@@ -1 +1 @@
1
- {"version":3,"file":"graph_water_tessellation.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/water/surface/graph_water_tessellation.js"],"names":[],"mappings":"AAiCA;;;;;;;GAOG;AACH,8CAHW;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,GACtE;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAQrH;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH;IAXsG,KAAK,EAAhG,OAAO,8DAA8D,EAAE,UAAU;IACjE,KAAK,EAArB,MAAM;IACU,MAAM,EAAtB,MAAM;IACU,QAAQ,EAAxB,MAAM;IACU,UAAU,EAA1B,MAAM;IACU,gBAAgB,EAAhC,MAAM;IAC2E,GAAG,EAApF;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC;IAC+B,MAAM,EAA5G;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC;IACzE,KAAK;IACtB;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC,CAsGrF"}
1
+ {"version":3,"file":"graph_water_tessellation.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/water/surface/graph_water_tessellation.js"],"names":[],"mappings":"AAqCA;;;;;;;GAOG;AACH,8CAHW;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,GACtE;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAQrH;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH;IAXsG,KAAK,EAAhG,OAAO,8DAA8D,EAAE,UAAU;IACjE,KAAK,EAArB,MAAM;IACU,MAAM,EAAtB,MAAM;IACU,QAAQ,EAAxB,MAAM;IACU,UAAU,EAA1B,MAAM;IACU,gBAAgB,EAAhC,MAAM;IAC2E,GAAG,EAApF;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC;IAC+B,MAAM,EAA5G;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC;IACzE,KAAK;IACtB;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC,CAyGrF"}
@@ -1,11 +1,15 @@
1
1
  import { assert } from "../../../../core/assert.js";
2
2
  import { BufferResourceDescriptor } from "../../../device/graph/BufferResourceDescriptor.js";
3
3
  import { GEOMETRY_MESHLET_TRIANGLE_LIMIT } from "../../geometry/meshlet/GEOMETRY_MESHLET_TRIANGLE_LIMIT.js";
4
- import { graph_prefix_scan_csdldf } from "../../gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.js";
4
+ import {
5
+ graph_prefix_scan_csdldf,
6
+ prefix_scan_csdldf_output_descriptor
7
+ } from "../../gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.js";
5
8
  import {
6
9
  build_indirect_compute_dispatch_command,
7
10
  INDIRECT_COMPUTE_COMMAND_DESCRIPTOR
8
11
  } from "../../gpu_primitive/indirect/IndirectComputeCommandBuildPass.js";
12
+ import { graph_create_buffer } from "../../shader/graph/graph_create_buffer.js";
9
13
  import { WATER_LOD_VIEW_STRUCT } from "./lod/WATER_LOD.js";
10
14
  import {
11
15
  shader_water_lod_candidate_command,
@@ -73,6 +77,9 @@ export function graph_water_tessellation({ graph, scene, camera, meshlets, lod_b
73
77
  const geometry_bindings = { scene_database: scene.scene_database_buffer,
74
78
  meshlet_metadata: scene.geometries.meshlets.buffer_metadata, meshlet_data: scene.geometries.meshlets.buffer_data };
75
79
  const limits_value = { ...limits };
80
+ // a counts collection's inclusive sums, into a collection of their own
81
+ const sums_of = (counts, label, elements) => graph_prefix_scan_csdldf({ graph, input: counts,
82
+ output: graph_create_buffer(graph, label, prefix_scan_csdldf_output_descriptor(elements)), element_max_count: elements });
76
83
 
77
84
  // per triangle slot of the drawn meshlets: drawn as itself, or its candidates
78
85
  const triangles_data = {};
@@ -88,8 +95,8 @@ export function graph_water_tessellation({ graph, scene, camera, meshlets, lod_b
88
95
  triangles_data.command = triangles.create('Water lod triangles command', INDIRECT_COMPUTE_COMMAND_DESCRIPTOR);
89
96
  triangles_data.counts = triangles.create('Water lod triangle counts', counts_descriptor(slots));
90
97
  triangles_data.flats = triangles.create('Water lod flat counts', counts_descriptor(slots));
91
- const triangle_sums = graph_prefix_scan_csdldf({ graph, data: triangles_data.counts, element_max_count: slots });
92
- const flat_sums = graph_prefix_scan_csdldf({ graph, data: triangles_data.flats, element_max_count: slots });
98
+ const triangle_sums = sums_of(triangles_data.counts, 'Water lod triangle sums', slots);
99
+ const flat_sums = sums_of(triangles_data.flats, 'Water lod flat sums', slots);
93
100
 
94
101
  // the candidates' dispatch; the flat triangles' records and draw
95
102
  const command_data = {};
@@ -133,7 +140,7 @@ export function graph_water_tessellation({ graph, scene, camera, meshlets, lod_b
133
140
  budget * WATER_LOD_CANDIDATE_ROW_WORDS * 4, GPUBufferUsage.STORAGE));
134
141
  // the interior, boundary and patch counts of every candidate, one region after another, scanned once
135
142
  candidates_data.counts = candidates.create('Water lod cell counts', counts_descriptor(3 * budget));
136
- const list_sums = graph_prefix_scan_csdldf({ graph, data: candidates_data.counts, element_max_count: 3 * budget });
143
+ const list_sums = sums_of(candidates_data.counts, 'Water lod cell sums', 3 * budget);
137
144
 
138
145
  // each list's records; the boundary cells' polygons
139
146
  const lists = [
@@ -1 +1 @@
1
- {"version":3,"file":"GPUWaterParticles.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/water/surface/particles/GPUWaterParticles.js"],"names":[],"mappings":"AAuBA,kHAAkH;AAClH,+CAAgD;AAUhD;;;;GAIG;AACH;IAkBI,uFAAuF;IACvF,yBAAuC;IACvC,kGAAkG;IAClG,yBAAuC;IACvC,uGAAuG;IACvG,6BAA+C;IAC/C,mEAAmE;IACnE,2BAAyD;IACzD,uBAAyC;IAEzC;;;;;;;;;;;OAWG;IACH,qCALW,MAAM,QACN,MAAM,UACK,OAAO,8CAA8C,EAAE,sBAAsB,KAAE,IAAI,GAAC,IAAI,CA4C7G;IAED,gBAWC;IAED;;;;;;;;;;;;;;;OAeG;IACH;QATyG,KAAK,EAAnG,OAAO,iEAAiE,EAAE,UAAU;QACpE,KAAK,EAArB,MAAM;QACa,KAAK;QACL,QAAQ;QACR,SAAS;QACT,QAAQ;QACX,YAAY,EAA5B,MAAM;QACU,EAAE,EAAlB,MAAM;aA6EhB;;CACJ"}
1
+ {"version":3,"file":"GPUWaterParticles.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/water/surface/particles/GPUWaterParticles.js"],"names":[],"mappings":"AAkCA,kHAAkH;AAClH,+CAAgD;AAUhD;;;;GAIG;AACH;IA0BI,uFAAuF;IACvF,yBAAuC;IACvC,kGAAkG;IAClG,yBAAuC;IACvC,uGAAuG;IACvG,6BAA+C;IAC/C,mEAAmE;IACnE,2BAAyD;IACzD,uBAAyC;IAEzC;;;;;;;;;;;OAWG;IACH,qCALW,MAAM,QACN,MAAM,UACK,OAAO,8CAA8C,EAAE,sBAAsB,KAAE,IAAI,GAAC,IAAI,CA6D7G;IAED,gBAgBC;IAED;;;;;;;;;;;;;;;OAeG;IACH;QATyG,KAAK,EAAnG,OAAO,iEAAiE,EAAE,UAAU;QACpE,KAAK,EAArB,MAAM;QACa,KAAK;QACL,QAAQ;QACR,SAAS;QACT,QAAQ;QACX,YAAY,EAA5B,MAAM;QACU,EAAE,EAAlB,MAAM;aAmGhB;;CACJ"}