@woosh/meep-engine 3.60.6 → 3.60.8

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 (328) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/package.json +1 -1
  3. package/src/core/binary/BitSet.d.ts.map +1 -1
  4. package/src/core/binary/BitSet.js +2 -1
  5. package/src/{format/image/avif/av1/util → core/binary/operations}/ceil_log2.d.ts +2 -2
  6. package/src/core/binary/operations/ceil_log2.d.ts.map +1 -0
  7. package/src/{format/image/avif/av1/util → core/binary/operations}/ceil_log2.js +18 -18
  8. package/src/core/binary/zstd/ZstdReverseBitReader.d.ts.map +1 -1
  9. package/src/core/binary/zstd/ZstdReverseBitReader.js +225 -223
  10. package/src/core/binary/zstd/zstd_fse.d.ts.map +1 -1
  11. package/src/core/binary/zstd/zstd_fse.js +267 -265
  12. package/src/core/binary/zstd/zstd_huffman.d.ts.map +1 -1
  13. package/src/core/binary/zstd/zstd_huffman.js +246 -244
  14. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts.map +1 -1
  15. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +8 -2
  16. package/src/core/bvh2/bvh3/ebvh_optimize_treelet.d.ts.map +1 -1
  17. package/src/core/bvh2/bvh3/ebvh_optimize_treelet.js +8 -7
  18. package/src/core/collection/PairUint32Map.d.ts.map +1 -1
  19. package/src/core/collection/PairUint32Map.js +2 -2
  20. package/src/core/collection/Uint32Map.d.ts.map +1 -1
  21. package/src/core/collection/Uint32Map.js +2 -4
  22. package/src/core/collection/heap/FibonacciHeap.d.ts.map +1 -1
  23. package/src/core/collection/heap/FibonacciHeap.js +2 -1
  24. package/src/core/geom/2d/r-tree/StaticR2Tree.d.ts.map +1 -1
  25. package/src/core/geom/2d/r-tree/StaticR2Tree.js +8 -2
  26. package/src/core/geom/3d/shape/util/mesh_compute_triangle_edge_flags.d.ts.map +1 -1
  27. package/src/core/geom/3d/shape/util/mesh_compute_triangle_edge_flags.js +2 -3
  28. package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts.map +1 -1
  29. package/src/engine/graphics/texture/atlas/TextureAtlas.js +13 -14
  30. package/src/engine/graphics/texture/atlas/sprite_atlas_border.d.ts.map +1 -1
  31. package/src/engine/graphics/texture/atlas/sprite_atlas_border.js +70 -69
  32. package/src/engine/graphics/texture/reflection/convolve_equirectangular_reflection.d.ts.map +1 -1
  33. package/src/engine/graphics/texture/reflection/convolve_equirectangular_reflection.js +2 -1
  34. package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts.map +1 -1
  35. package/src/engine/graphics3/GPUParticleEmitterSystem.js +2 -1
  36. package/src/engine/graphics3/decal/GPUDecalRenderer.d.ts.map +1 -1
  37. package/src/engine/graphics3/decal/GPUDecalRenderer.js +2 -1
  38. package/src/engine/graphics3/decal/chunk_decal_record.d.ts +14 -0
  39. package/src/engine/graphics3/decal/chunk_decal_record.d.ts.map +1 -0
  40. package/src/engine/graphics3/decal/chunk_decal_record.js +44 -0
  41. package/src/engine/graphics3/decal/shader_cluster_assign_decals.d.ts.map +1 -1
  42. package/src/engine/graphics3/decal/shader_cluster_assign_decals.js +2 -15
  43. package/src/engine/graphics3/decal/shader_cull_decals_frustum.d.ts.map +1 -1
  44. package/src/engine/graphics3/decal/shader_cull_decals_frustum.js +3 -16
  45. package/src/engine/graphics3/decal/shader_decal_composite.d.ts.map +1 -1
  46. package/src/engine/graphics3/decal/shader_decal_composite.js +3 -23
  47. package/src/engine/graphics3/terrain/TERRAIN_MATERIAL_TEMPLATE.d.ts.map +1 -1
  48. package/src/engine/graphics3/terrain/TERRAIN_MATERIAL_TEMPLATE.js +2 -1
  49. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  50. package/src/engine/physics/queries/shape_cast.js +2 -2
  51. package/src/format/image/avif/av1/decode/decode_palette.js +442 -442
  52. package/src/format/image/avif/av1/entropy/SymbolWriter.d.ts.map +1 -1
  53. package/src/format/image/avif/av1/entropy/SymbolWriter.js +2 -1
  54. package/src/generation/foliage/material/foliage_tile.d.ts.map +1 -1
  55. package/src/generation/foliage/material/foliage_tile.js +2 -1
  56. package/src/generation/markers/GridActionRuleSet.d.ts.map +1 -1
  57. package/src/generation/markers/GridActionRuleSet.js +12 -3
  58. package/src/shade/device/mock/SoftwareGPUDevice.d.ts.map +1 -1
  59. package/src/shade/device/mock/SoftwareGPUDevice.js +6 -13
  60. package/src/shade/playground/caldera/main.js +3 -2
  61. package/src/shade/playground/probe_clipmap/README.md +2 -1
  62. package/src/shade/playground/probe_clipmap/index.html +7 -2
  63. package/src/shade/playground/probe_clipmap/main.d.ts.map +1 -1
  64. package/src/shade/playground/probe_clipmap/main.js +17 -7
  65. package/src/shade/playground/sh_exponential/sh_exp_playground_shaders.d.ts.map +1 -1
  66. package/src/shade/playground/sh_exponential/sh_exp_playground_shaders.js +7 -13
  67. package/src/shade/playground/vgeo_scene/main.js +2 -1
  68. package/src/shade/playground/vsm/VSMDebugOverlay.d.ts.map +1 -1
  69. package/src/shade/playground/vsm/VSMDebugOverlay.js +3 -1
  70. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  71. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  72. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
  73. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  74. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_coarsest.d.ts.map +1 -1
  75. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_coarsest.js +5 -4
  76. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_residual_restrict.d.ts.map +1 -1
  77. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_residual_restrict.js +168 -166
  78. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_smooth.d.ts.map +1 -1
  79. package/src/shade/renderer/fluid/pressure/shader_fluid_mg_smooth.js +221 -219
  80. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  81. package/src/shade/renderer/fow/shader_fog_of_war.d.ts.map +1 -1
  82. package/src/shade/renderer/fow/shader_fog_of_war.js +8 -19
  83. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts.map +1 -1
  84. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.js +6 -6
  85. package/src/shade/renderer/geometry/sdf/MeshSDFLayout.d.ts.map +1 -1
  86. package/src/shade/renderer/geometry/sdf/MeshSDFLayout.js +2 -1
  87. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts.map +1 -1
  88. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.js +2 -1
  89. package/src/shade/renderer/geometry/virtual/runtime/VGeoResidency.d.ts.map +1 -1
  90. package/src/shade/renderer/geometry/virtual/runtime/VGeoResidency.js +2 -1
  91. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_decode_from_storage.d.ts.map +1 -1
  92. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_decode_from_storage.js +10 -31
  93. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_encode_to_storage.d.ts.map +1 -1
  94. package/src/shade/renderer/global_illumination/brick4/gpu/encoding/v1/chunk_brick4_sh3_color_encode_to_storage.js +9 -15
  95. package/src/shade/renderer/global_illumination/clipmap/shader_debug_clipmap.d.ts +2 -1
  96. package/src/shade/renderer/global_illumination/clipmap/shader_debug_clipmap.d.ts.map +1 -1
  97. package/src/shade/renderer/global_illumination/clipmap/shader_debug_clipmap.js +6 -5
  98. package/src/shade/renderer/global_illumination/probe/octahedral/convolve/graph_reduce_atlas_to_sh.d.ts.map +1 -1
  99. package/src/shade/renderer/global_illumination/probe/octahedral/convolve/graph_reduce_atlas_to_sh.js +2 -1
  100. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +15 -3
  101. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts.map +1 -1
  102. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.js +168 -18
  103. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts +98 -57
  104. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts.map +1 -1
  105. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.js +168 -77
  106. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts +4 -2
  107. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts.map +1 -1
  108. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.js +27 -12
  109. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.d.ts.map +1 -1
  110. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.js +12 -7
  111. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
  112. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +8 -2
  113. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.d.ts.map +1 -1
  114. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.js +5 -2
  115. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_batch.js +1 -1
  116. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.d.ts.map +1 -1
  117. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.js +5 -3
  118. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_resolve.js +1 -1
  119. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_free.d.ts.map +1 -1
  120. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_free.js +1 -1
  121. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_movers_command.d.ts.map +1 -1
  122. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_movers_command.js +4 -2
  123. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_scroll.d.ts.map +1 -1
  124. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_scroll.js +1 -1
  125. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_store.d.ts.map +1 -1
  126. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_store.js +1 -1
  127. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_take.d.ts.map +1 -1
  128. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_take.js +3 -1
  129. package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_mesh_cards.js +2 -2
  130. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts +114 -41
  131. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts.map +1 -1
  132. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.js +424 -207
  133. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts +34 -25
  134. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts.map +1 -1
  135. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.js +41 -31
  136. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP_RESAMPLING.d.ts +7 -5
  137. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP_RESAMPLING.d.ts.map +1 -1
  138. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP_RESAMPLING.js +7 -5
  139. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapHitWants.d.ts +47 -0
  140. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapHitWants.d.ts.map +1 -0
  141. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapHitWants.js +84 -0
  142. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.d.ts +48 -0
  143. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.d.ts.map +1 -0
  144. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.js +101 -0
  145. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts +58 -4
  146. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts.map +1 -1
  147. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.js +127 -30
  148. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_cage.d.ts +18 -7
  149. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_cage.d.ts.map +1 -1
  150. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_cage.js +39 -13
  151. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.d.ts +29 -8
  152. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.d.ts.map +1 -1
  153. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.js +112 -56
  154. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_resample.d.ts +19 -0
  155. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_resample.d.ts.map +1 -0
  156. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_resample.js +35 -0
  157. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.d.ts.map +1 -1
  158. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.js +9 -3
  159. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.d.ts +3 -3
  160. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.js +5 -5
  161. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts +8 -12
  162. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts.map +1 -1
  163. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.js +23 -56
  164. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.d.ts +0 -3
  165. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.d.ts.map +1 -1
  166. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.js +11 -15
  167. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_bounce.d.ts +26 -0
  168. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_bounce.d.ts.map +1 -0
  169. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_bounce.js +173 -0
  170. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_candidate.d.ts +32 -0
  171. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_candidate.d.ts.map +1 -0
  172. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_candidate.js +166 -0
  173. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts +3 -4
  174. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts.map +1 -1
  175. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.js +3 -4
  176. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_guide.d.ts.map +1 -1
  177. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_guide.js +3 -1
  178. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts +6 -12
  179. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts.map +1 -1
  180. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.js +15 -65
  181. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_order.d.ts.map +1 -1
  182. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_order.js +7 -2
  183. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts +4 -4
  184. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts.map +1 -1
  185. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.js +24 -17
  186. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_publish.d.ts +7 -5
  187. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_publish.d.ts.map +1 -1
  188. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_publish.js +18 -10
  189. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.d.ts +2 -2
  190. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.d.ts.map +1 -1
  191. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.js +9 -5
  192. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.d.ts +3 -0
  193. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.d.ts.map +1 -1
  194. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.js +9 -6
  195. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample.d.ts +1 -1
  196. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample.d.ts.map +1 -1
  197. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample.js +16 -16
  198. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample_rays.d.ts +36 -0
  199. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample_rays.d.ts.map +1 -0
  200. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_resample_rays.js +233 -0
  201. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.d.ts.map +1 -1
  202. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.js +7 -5
  203. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.d.ts.map +1 -1
  204. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.js +5 -3
  205. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts.map +1 -1
  206. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.js +10 -4
  207. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.d.ts +2 -1
  208. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.d.ts.map +1 -1
  209. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.js +12 -6
  210. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.d.ts +1 -2
  211. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.d.ts.map +1 -1
  212. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.js +5 -6
  213. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.d.ts +14 -18
  214. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.d.ts.map +1 -1
  215. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.js +25 -35
  216. package/src/shade/renderer/gpu_primitive/WEBGPU_GUARANTEED_MAX_UNIFORM_BUFFER_BINDING_SIZE.d.ts +13 -0
  217. package/src/shade/renderer/gpu_primitive/WEBGPU_GUARANTEED_MAX_UNIFORM_BUFFER_BINDING_SIZE.d.ts.map +1 -0
  218. package/src/shade/renderer/gpu_primitive/WEBGPU_GUARANTEED_MAX_UNIFORM_BUFFER_BINDING_SIZE.js +12 -0
  219. package/src/shade/renderer/gpu_primitive/hash_table/cpu_build_hash_table.d.ts +27 -2
  220. package/src/shade/renderer/gpu_primitive/hash_table/cpu_build_hash_table.d.ts.map +1 -1
  221. package/src/shade/renderer/gpu_primitive/hash_table/cpu_build_hash_table.js +62 -6
  222. package/src/shade/renderer/gpu_primitive/indirect/IndirectComputeCommandBuildPass.d.ts.map +1 -1
  223. package/src/shade/renderer/gpu_primitive/indirect/IndirectComputeCommandBuildPass.js +10 -19
  224. package/src/shade/renderer/gpu_primitive/indirect/chunk_folded_dispatch.d.ts.map +1 -1
  225. package/src/shade/renderer/gpu_primitive/indirect/chunk_folded_dispatch.js +6 -3
  226. package/src/shade/renderer/hiz/hzb_pick_alignment.d.ts.map +1 -1
  227. package/src/shade/renderer/hiz/hzb_pick_alignment.js +149 -148
  228. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_environment_cells.d.ts.map +1 -1
  229. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_environment_cells.js +4 -2
  230. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_log_floor.d.ts.map +1 -1
  231. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_log_floor.js +6 -5
  232. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_project.d.ts.map +1 -1
  233. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_project.js +3 -1
  234. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_reference_reflectance.d.ts.map +1 -1
  235. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_reference_reflectance.js +3 -1
  236. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_solve.d.ts.map +1 -1
  237. package/src/shade/renderer/light/environment/sh_exponential/shader_sh_exp_solve.js +3 -1
  238. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.d.ts +0 -5
  239. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.d.ts.map +1 -1
  240. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.js +0 -7
  241. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.d.ts +15 -2
  242. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.d.ts.map +1 -1
  243. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.js +51 -16
  244. package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.d.ts.map +1 -1
  245. package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.js +3 -2
  246. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  247. package/src/shade/renderer/postprocess/dof/raymarch/chunk_dof_lds_coc_cache.d.ts +17 -0
  248. package/src/shade/renderer/postprocess/dof/raymarch/chunk_dof_lds_coc_cache.d.ts.map +1 -0
  249. package/src/shade/renderer/postprocess/dof/raymarch/chunk_dof_lds_coc_cache.js +81 -0
  250. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_raymarch_compute.d.ts.map +1 -1
  251. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_raymarch_compute.js +5 -48
  252. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_slice_compute.d.ts.map +1 -1
  253. package/src/shade/renderer/postprocess/dof/raymarch/shader_dof_slice_compute.js +4 -44
  254. package/src/shade/renderer/postprocess/gtao/chunk_integrate_lighting_sample.d.ts.map +1 -1
  255. package/src/shade/renderer/postprocess/gtao/chunk_integrate_lighting_sample.js +4 -1
  256. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.d.ts.map +1 -1
  257. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.js +8 -7
  258. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  259. package/src/shade/renderer/postprocess/nss/chunk_nss_luma_derivative.d.ts.map +1 -1
  260. package/src/shade/renderer/postprocess/nss/chunk_nss_luma_derivative.js +5 -7
  261. package/src/shade/renderer/postprocess/nss/chunk_nss_tonemap.d.ts +17 -0
  262. package/src/shade/renderer/postprocess/nss/chunk_nss_tonemap.d.ts.map +1 -0
  263. package/src/shade/renderer/postprocess/nss/chunk_nss_tonemap.js +56 -0
  264. package/src/shade/renderer/postprocess/nss/shader_nss_postprocess.d.ts.map +1 -1
  265. package/src/shade/renderer/postprocess/nss/shader_nss_postprocess.js +2 -22
  266. package/src/shade/renderer/postprocess/nss/shader_nss_preprocess.d.ts.map +1 -1
  267. package/src/shade/renderer/postprocess/nss/shader_nss_preprocess.js +2 -13
  268. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.d.ts.map +1 -1
  269. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.js +10 -13
  270. package/src/shade/renderer/rasterize/expand/bucket/RASTERIZATION_BUCKET_LIMIT.d.ts.map +1 -1
  271. package/src/shade/renderer/rasterize/expand/bucket/RASTERIZATION_BUCKET_LIMIT.js +39 -38
  272. package/src/shade/renderer/rasterize/expand/mesh/shader_prefix_sum_to_command.d.ts.map +1 -1
  273. package/src/shade/renderer/rasterize/expand/mesh/shader_prefix_sum_to_command.js +7 -12
  274. package/src/shade/renderer/shader/chunk/clipmap/CLIPMAP_LEVEL_STRUCT.d.ts +8 -6
  275. package/src/shade/renderer/shader/chunk/clipmap/CLIPMAP_LEVEL_STRUCT.d.ts.map +1 -1
  276. package/src/shade/renderer/shader/chunk/clipmap/CLIPMAP_LEVEL_STRUCT.js +10 -7
  277. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_key.d.ts +16 -0
  278. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_key.d.ts.map +1 -0
  279. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_key.js +35 -0
  280. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_select_finest.d.ts +5 -2
  281. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_select_finest.d.ts.map +1 -1
  282. package/src/shade/renderer/shader/chunk/clipmap/chunk_clipmap_select_finest.js +27 -18
  283. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh2_color_get_irradiance_at.d.ts.map +1 -1
  284. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh2_color_get_irradiance_at.js +5 -15
  285. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh3_convolve_with_cosine_kernel.d.ts.map +1 -1
  286. package/src/shade/renderer/shader/chunk/spherical_harmonics/chunk_sh3_convolve_with_cosine_kernel.js +5 -19
  287. package/src/shade/renderer/shader/chunk/spherical_harmonics/dering/chunk_sh3_windowing.d.ts.map +1 -1
  288. package/src/shade/renderer/shader/chunk/spherical_harmonics/dering/chunk_sh3_windowing.js +3 -22
  289. package/src/shade/renderer/shadow/map/ShadowmapDrawSelector.d.ts.map +1 -1
  290. package/src/shade/renderer/shadow/map/ShadowmapDrawSelector.js +2 -1
  291. package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_shadow_group_list.d.ts.map +1 -1
  292. package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_shadow_group_list.js +154 -152
  293. package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.d.ts.map +1 -1
  294. package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.js +2 -1
  295. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.d.ts +3 -1
  296. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.d.ts.map +1 -1
  297. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.js +4 -3
  298. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.d.ts +7 -1
  299. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.d.ts.map +1 -1
  300. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.js +54 -47
  301. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.d.ts.map +1 -1
  302. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.js +371 -370
  303. package/src/shade/renderer/water/GPUWaterRenderer.d.ts.map +1 -1
  304. package/src/shade/renderer/water/GPUWaterRenderer.js +2 -1
  305. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
  306. package/src/shade/renderer/water/surface/lod/shader_water_lod.d.ts.map +1 -1
  307. package/src/shade/renderer/water/surface/lod/shader_water_lod.js +12 -14
  308. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.d.ts.map +1 -1
  309. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.js +2 -9
  310. package/src/shade/renderer/water/surface/particles/chunk_water_particle.d.ts.map +1 -1
  311. package/src/shade/renderer/water/surface/particles/chunk_water_particle.js +2 -1
  312. package/src/shade/renderer/wind/WIND_FIELD.d.ts +3 -1
  313. package/src/shade/renderer/wind/WIND_FIELD.d.ts.map +1 -1
  314. package/src/shade/renderer/wind/WIND_FIELD.js +4 -3
  315. package/src/shade/renderer/wind/WIND_FIELD_STRUCT.d.ts +8 -2
  316. package/src/shade/renderer/wind/WIND_FIELD_STRUCT.d.ts.map +1 -1
  317. package/src/shade/renderer/wind/WIND_FIELD_STRUCT.js +11 -4
  318. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts +2 -2
  319. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts.map +1 -1
  320. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.js +13 -4
  321. package/src/shade/util/texture_mip_extent.d.ts.map +1 -1
  322. package/src/shade/util/texture_mip_extent.js +88 -87
  323. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  324. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +9 -7
  325. package/src/format/image/avif/av1/util/ceil_log2.d.ts.map +0 -1
  326. package/src/shade/renderer/shader/chunk/color/chunk_hash_squirrel3.d.ts +0 -1
  327. package/src/shade/renderer/shader/chunk/color/chunk_hash_squirrel3.d.ts.map +0 -1
  328. package/src/shade/renderer/shader/chunk/color/chunk_hash_squirrel3.js +0 -0
@@ -1,166 +1,168 @@
1
- import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
- import { ComputeShader } from "../../shader/ComputeShader.js";
3
- import { chunk_grid_tile_halo_f32 } from "../../shader/chunk/grid/chunk_grid_tile_halo_f32.js";
4
- import { GRID_TILE_WINDOW_STRUCT } from "../../shader/chunk/grid/GRID_TILE_WINDOW_STRUCT.js";
5
- import { chunk_index_to_grid3d } from "../../shader/chunk/grid/chunk_index_to_grid3d.js";
6
- import { chunk_is_finite } from "../../shader/chunk/math/chunk_is_finite.js";
7
- import { chunk_subgroup_atomic_add } from "../../shader/chunk/subgroup/chunk_subgroup_atomic_add.js";
8
- import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
9
- import { atomic_u32, f32, u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
10
- import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
11
- import { chunk_fluid_mg_coarse_word } from "./chunk_fluid_mg_coarse_word.js";
12
- import { chunk_fluid_mg_relax } from "./chunk_fluid_mg_relax.js";
13
- import { chunk_fluid_mg_restrict } from "./chunk_fluid_mg_restrict.js";
14
- import { chunk_fluid_pressure_ghost } from "./chunk_fluid_pressure_ghost.js";
15
- import { FLUID_MG_PASS_STRUCT } from "./FLUID_MG_PASS_STRUCT.js";
16
-
17
- const resources = new ShaderResourceSetDescriptor();
18
-
19
- resources.createGroup()
20
- .addUniform('params', FLUID_MG_PASS_STRUCT)
21
- .addStorageBuffer('input', WebGPUArray.from(f32), false)
22
- .addStorageBuffer('rhs', WebGPUArray.from(f32), false)
23
- .addStorageBuffer('words', WebGPUArray.from(u32), false)
24
- .addStorageBuffer('coarse_rhs', WebGPUArray.from(f32), true)
25
- .addStorageBuffer('coarse_error', WebGPUArray.from(f32), true)
26
- .addStorageBuffer('coarse_words', WebGPUArray.from(u32), true)
27
- .addStorageBuffer('nonfinite', WebGPUArray.from(atomic_u32), true)
28
- .addStorageBuffer('ghost_pressure', WebGPUArray.from(f32), false);
29
-
30
- /**
31
- * The pressure V-cycle's residual, restriction, and coarse weight reduction
32
- * (GPU_FLUID_CASCADES_PROPOSAL_2026_10_16.md §8): one workgroup an 8×8×4 tile of a level, one invocation
33
- * a cell.
34
- *
35
- * The workgroup loads its tile and halo from `input` as the smoother does, without a prolongation (the
36
- * finest level's ghosts its parent's pressure, from the step's `ghost_pressure`);
37
- * each invocation takes its cell's residual (`chunk_fluid_mg_relax`), 0 outside the level or with no
38
- * degree of freedom, and its cell's weight word into workgroup memory. After a barrier, the first 32
39
- * invocations each write one of the tile's 4×4×2 coarse cells inside the coarser level: `coarse_rhs`,
40
- * the 8-child mean (`chunk_fluid_mg_restrict`), `coarse_error`, 0, which the coarser level's down leg
41
- * starts from, and `coarse_words`, the 8-child face-open reduction (`chunk_fluid_mg_coarse_word`).
42
- *
43
- * Non-finite input and RHS are read as 0 and counted into `nonfinite[0]`, as the smoother does.
44
- *
45
- * Dispatched as `ceil(size / (8, 8, 4))` workgroups. Workgroup memory: 4,448 bytes.
46
- */
47
- export const shader_fluid_mg_residual_restrict = ComputeShader.from({
48
- label: 'Fluid / pressure / residual + restrict',
49
- resources,
50
- body: CodeChunk.from(
51
- //language=WGSL
52
- `
53
- const FLUID_MG_SOURCE_PRESSURE = 0u;
54
- const FLUID_MG_SOURCE_ERROR = 1u;
55
-
56
- var<workgroup> tile_p: array<f32, GRID_TILE_HALO_CELLS>;
57
- var<workgroup> tile_r: array<f32, GRID_TILE_THREADS>;
58
- var<workgroup> tile_w: array<u32, GRID_TILE_THREADS>;
59
-
60
- fn fluid_mg_input_index(storage_cell: vec3<u32>) -> u32 {
61
- return storage_cell.x + params.input_period.x * (storage_cell.y + params.input_period.y * storage_cell.z);
62
- }
63
-
64
- fn grid_tile_f32_fetch_inside(source: u32, storage_cell: vec3<u32>) -> f32 {
65
- let value = input[fluid_mg_input_index(storage_cell)];
66
-
67
- return select(0.0, value, is_finite(value));
68
- }
69
-
70
- fn grid_tile_f32_fetch_outside(source: u32, world_cell: vec3<i32>) -> f32 {
71
- if (source == FLUID_MG_SOURCE_PRESSURE) {
72
- return fluid_pressure_ghost(world_cell);
73
- }
74
-
75
- return 0.0;
76
- }
77
-
78
-
79
- // where the finest level's window is, for its pressure ghosts
80
- fn fluid_pressure_ghost_corner() -> vec3<i32> {
81
- return params.corner;
82
- }
83
-
84
- fn fluid_pressure_ghost_size() -> vec3<u32> {
85
- return params.size;
86
- }
87
- fn tile_read_p(local: vec3<i32>) -> f32 {
88
- return grid_tile_f32_read(&tile_p, local);
89
- }
90
-
91
- // a tile-local interior cell's residual
92
- fn tile_read_r(local: vec3<i32>) -> f32 {
93
- let c = vec3<u32>(local);
94
-
95
- return tile_r[c.x + 8u * (c.y + 8u * c.z)];
96
- }
97
-
98
- // a tile-local interior cell's weight word
99
- fn fluid_mg_read_child_word(local: vec3<i32>) -> u32 {
100
- let c = vec3<u32>(local);
101
-
102
- return tile_w[c.x + 8u * (c.y + 8u * c.z)];
103
- }
104
-
105
- @compute @workgroup_size(8, 8, 4)
106
- fn main(
107
- @builtin(workgroup_id) group: vec3<u32>,
108
- @builtin(local_invocation_id) local_id: vec3<u32>,
109
- @builtin(local_invocation_index) lane: u32,
110
- ) {
111
- let window = ${GRID_TILE_WINDOW_STRUCT.wgsl_ref}(params.corner, params.input_corner_storage, params.size, params.input_period);
112
- let source = select(FLUID_MG_SOURCE_ERROR, FLUID_MG_SOURCE_PRESSURE, params.level == 0u);
113
- let tile_origin = vec3<i32>(group) * GRID_TILE_SIZE;
114
-
115
- grid_tile_f32_load(&tile_p, window, source, tile_origin, lane);
116
-
117
- let local = vec3<i32>(local_id);
118
- let cell = vec3<u32>(tile_origin + local);
119
-
120
- var residual = 0.0;
121
- var word = 0u;
122
- var zeroed = 0u;
123
-
124
- if (all(cell < params.size)) {
125
- let linear = cell.x + params.size.x * (cell.y + params.size.y * cell.z);
126
- let rhs_value = rhs[linear];
127
- let held = input[fluid_mg_input_index(grid_tile_window_storage(vec3<i32>(cell), params.input_corner_storage, params.input_period))];
128
- let f = select(0.0, rhs_value, is_finite(rhs_value));
129
- word = words[linear];
130
- let stencil = fluid_mg_stencil(local, cell, params.size, word, params.edge_weight);
131
-
132
- residual = fluid_mg_residual(tile_read_p(local), stencil, f, params.h2);
133
- zeroed = select(0u, 1u, !is_finite(held)) + select(0u, 1u, !is_finite(rhs_value));
134
- }
135
-
136
- tile_r[lane] = residual;
137
- tile_w[lane] = word;
138
-
139
- subgroup_atomic_add_u32(&nonfinite[0], zeroed);
140
-
141
- workgroupBarrier();
142
-
143
- if (lane < 32u) {
144
- let coarse_local = vec3<i32>(index_to_grid3d(lane, vec2<u32>(4u, 4u)));
145
- let coarse_cell = vec3<u32>(tile_origin / 2 + coarse_local);
146
-
147
- if (all(coarse_cell < params.coarse_size)) {
148
- let coarse_linear = coarse_cell.x + params.coarse_size.x * (coarse_cell.y + params.coarse_size.y * coarse_cell.z);
149
-
150
- coarse_rhs[coarse_linear] = fluid_mg_restrict(coarse_local);
151
- coarse_error[coarse_linear] = 0.0;
152
- coarse_words[coarse_linear] = fluid_mg_coarse_word(coarse_local);
153
- }
154
- }
155
- }
156
- `, [
157
- chunk_grid_tile_halo_f32,
158
- chunk_fluid_mg_relax,
159
- chunk_fluid_mg_restrict,
160
- chunk_fluid_mg_coarse_word,
161
- chunk_fluid_pressure_ghost,
162
- chunk_index_to_grid3d,
163
- chunk_is_finite,
164
- chunk_subgroup_atomic_add,
165
- ]),
166
- });
1
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
+ import { ComputeShader } from "../../shader/ComputeShader.js";
3
+ import { chunk_grid3d_to_index } from "../../shader/chunk/grid/chunk_grid3d_to_index.js";
4
+ import { chunk_grid_tile_halo_f32 } from "../../shader/chunk/grid/chunk_grid_tile_halo_f32.js";
5
+ import { GRID_TILE_WINDOW_STRUCT } from "../../shader/chunk/grid/GRID_TILE_WINDOW_STRUCT.js";
6
+ import { chunk_index_to_grid3d } from "../../shader/chunk/grid/chunk_index_to_grid3d.js";
7
+ import { chunk_is_finite } from "../../shader/chunk/math/chunk_is_finite.js";
8
+ import { chunk_subgroup_atomic_add } from "../../shader/chunk/subgroup/chunk_subgroup_atomic_add.js";
9
+ import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
10
+ import { atomic_u32, f32, u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
11
+ import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
12
+ import { chunk_fluid_mg_coarse_word } from "./chunk_fluid_mg_coarse_word.js";
13
+ import { chunk_fluid_mg_relax } from "./chunk_fluid_mg_relax.js";
14
+ import { chunk_fluid_mg_restrict } from "./chunk_fluid_mg_restrict.js";
15
+ import { chunk_fluid_pressure_ghost } from "./chunk_fluid_pressure_ghost.js";
16
+ import { FLUID_MG_PASS_STRUCT } from "./FLUID_MG_PASS_STRUCT.js";
17
+
18
+ const resources = new ShaderResourceSetDescriptor();
19
+
20
+ resources.createGroup()
21
+ .addUniform('params', FLUID_MG_PASS_STRUCT)
22
+ .addStorageBuffer('input', WebGPUArray.from(f32), false)
23
+ .addStorageBuffer('rhs', WebGPUArray.from(f32), false)
24
+ .addStorageBuffer('words', WebGPUArray.from(u32), false)
25
+ .addStorageBuffer('coarse_rhs', WebGPUArray.from(f32), true)
26
+ .addStorageBuffer('coarse_error', WebGPUArray.from(f32), true)
27
+ .addStorageBuffer('coarse_words', WebGPUArray.from(u32), true)
28
+ .addStorageBuffer('nonfinite', WebGPUArray.from(atomic_u32), true)
29
+ .addStorageBuffer('ghost_pressure', WebGPUArray.from(f32), false);
30
+
31
+ /**
32
+ * The pressure V-cycle's residual, restriction, and coarse weight reduction
33
+ * (GPU_FLUID_CASCADES_PROPOSAL_2026_10_16.md §8): one workgroup an 8×8×4 tile of a level, one invocation
34
+ * a cell.
35
+ *
36
+ * The workgroup loads its tile and halo from `input` as the smoother does, without a prolongation (the
37
+ * finest level's ghosts its parent's pressure, from the step's `ghost_pressure`);
38
+ * each invocation takes its cell's residual (`chunk_fluid_mg_relax`), 0 outside the level or with no
39
+ * degree of freedom, and its cell's weight word into workgroup memory. After a barrier, the first 32
40
+ * invocations each write one of the tile's 4×4×2 coarse cells inside the coarser level: `coarse_rhs`,
41
+ * the 8-child mean (`chunk_fluid_mg_restrict`), `coarse_error`, 0, which the coarser level's down leg
42
+ * starts from, and `coarse_words`, the 8-child face-open reduction (`chunk_fluid_mg_coarse_word`).
43
+ *
44
+ * Non-finite input and RHS are read as 0 and counted into `nonfinite[0]`, as the smoother does.
45
+ *
46
+ * Dispatched as `ceil(size / (8, 8, 4))` workgroups. Workgroup memory: 4,448 bytes.
47
+ */
48
+ export const shader_fluid_mg_residual_restrict = ComputeShader.from({
49
+ label: 'Fluid / pressure / residual + restrict',
50
+ resources,
51
+ body: CodeChunk.from(
52
+ //language=WGSL
53
+ `
54
+ const FLUID_MG_SOURCE_PRESSURE = 0u;
55
+ const FLUID_MG_SOURCE_ERROR = 1u;
56
+
57
+ var<workgroup> tile_p: array<f32, GRID_TILE_HALO_CELLS>;
58
+ var<workgroup> tile_r: array<f32, GRID_TILE_THREADS>;
59
+ var<workgroup> tile_w: array<u32, GRID_TILE_THREADS>;
60
+
61
+ fn fluid_mg_input_index(storage_cell: vec3<u32>) -> u32 {
62
+ return grid3d_to_index(storage_cell, params.input_period.xy);
63
+ }
64
+
65
+ fn grid_tile_f32_fetch_inside(source: u32, storage_cell: vec3<u32>) -> f32 {
66
+ let value = input[fluid_mg_input_index(storage_cell)];
67
+
68
+ return select(0.0, value, is_finite(value));
69
+ }
70
+
71
+ fn grid_tile_f32_fetch_outside(source: u32, world_cell: vec3<i32>) -> f32 {
72
+ if (source == FLUID_MG_SOURCE_PRESSURE) {
73
+ return fluid_pressure_ghost(world_cell);
74
+ }
75
+
76
+ return 0.0;
77
+ }
78
+
79
+
80
+ // where the finest level's window is, for its pressure ghosts
81
+ fn fluid_pressure_ghost_corner() -> vec3<i32> {
82
+ return params.corner;
83
+ }
84
+
85
+ fn fluid_pressure_ghost_size() -> vec3<u32> {
86
+ return params.size;
87
+ }
88
+ fn tile_read_p(local: vec3<i32>) -> f32 {
89
+ return grid_tile_f32_read(&tile_p, local);
90
+ }
91
+
92
+ // a tile-local interior cell's residual
93
+ fn tile_read_r(local: vec3<i32>) -> f32 {
94
+ let c = vec3<u32>(local);
95
+
96
+ return tile_r[grid3d_to_index(c, vec2<u32>(8u, 8u))];
97
+ }
98
+
99
+ // a tile-local interior cell's weight word
100
+ fn fluid_mg_read_child_word(local: vec3<i32>) -> u32 {
101
+ let c = vec3<u32>(local);
102
+
103
+ return tile_w[grid3d_to_index(c, vec2<u32>(8u, 8u))];
104
+ }
105
+
106
+ @compute @workgroup_size(8, 8, 4)
107
+ fn main(
108
+ @builtin(workgroup_id) group: vec3<u32>,
109
+ @builtin(local_invocation_id) local_id: vec3<u32>,
110
+ @builtin(local_invocation_index) lane: u32,
111
+ ) {
112
+ let window = ${GRID_TILE_WINDOW_STRUCT.wgsl_ref}(params.corner, params.input_corner_storage, params.size, params.input_period);
113
+ let source = select(FLUID_MG_SOURCE_ERROR, FLUID_MG_SOURCE_PRESSURE, params.level == 0u);
114
+ let tile_origin = vec3<i32>(group) * GRID_TILE_SIZE;
115
+
116
+ grid_tile_f32_load(&tile_p, window, source, tile_origin, lane);
117
+
118
+ let local = vec3<i32>(local_id);
119
+ let cell = vec3<u32>(tile_origin + local);
120
+
121
+ var residual = 0.0;
122
+ var word = 0u;
123
+ var zeroed = 0u;
124
+
125
+ if (all(cell < params.size)) {
126
+ let linear = grid3d_to_index(cell, params.size.xy);
127
+ let rhs_value = rhs[linear];
128
+ let held = input[fluid_mg_input_index(grid_tile_window_storage(vec3<i32>(cell), params.input_corner_storage, params.input_period))];
129
+ let f = select(0.0, rhs_value, is_finite(rhs_value));
130
+ word = words[linear];
131
+ let stencil = fluid_mg_stencil(local, cell, params.size, word, params.edge_weight);
132
+
133
+ residual = fluid_mg_residual(tile_read_p(local), stencil, f, params.h2);
134
+ zeroed = select(0u, 1u, !is_finite(held)) + select(0u, 1u, !is_finite(rhs_value));
135
+ }
136
+
137
+ tile_r[lane] = residual;
138
+ tile_w[lane] = word;
139
+
140
+ subgroup_atomic_add_u32(&nonfinite[0], zeroed);
141
+
142
+ workgroupBarrier();
143
+
144
+ if (lane < 32u) {
145
+ let coarse_local = vec3<i32>(index_to_grid3d(lane, vec2<u32>(4u, 4u)));
146
+ let coarse_cell = vec3<u32>(tile_origin / 2 + coarse_local);
147
+
148
+ if (all(coarse_cell < params.coarse_size)) {
149
+ let coarse_linear = grid3d_to_index(coarse_cell, params.coarse_size.xy);
150
+
151
+ coarse_rhs[coarse_linear] = fluid_mg_restrict(coarse_local);
152
+ coarse_error[coarse_linear] = 0.0;
153
+ coarse_words[coarse_linear] = fluid_mg_coarse_word(coarse_local);
154
+ }
155
+ }
156
+ }
157
+ `, [
158
+ chunk_grid3d_to_index,
159
+ chunk_grid_tile_halo_f32,
160
+ chunk_fluid_mg_relax,
161
+ chunk_fluid_mg_restrict,
162
+ chunk_fluid_mg_coarse_word,
163
+ chunk_fluid_pressure_ghost,
164
+ chunk_index_to_grid3d,
165
+ chunk_is_finite,
166
+ chunk_subgroup_atomic_add,
167
+ ]),
168
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"shader_fluid_mg_smooth.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/fluid/pressure/shader_fluid_mg_smooth.js"],"names":[],"mappings":"AA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,mDAkKG;8BAzN2B,+BAA+B"}
1
+ {"version":3,"file":"shader_fluid_mg_smooth.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/fluid/pressure/shader_fluid_mg_smooth.js"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,mDAmKG;8BA3N2B,+BAA+B"}