@woosh/meep-engine 3.64.1 → 3.67.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 (372) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/build/bundle-worker-image-decoder.js +1 -1
  3. package/build/bundle-worker-terrain.js +1 -1
  4. package/package.json +1 -1
  5. package/src/core/binary/BinaryBuffer.d.ts +5 -0
  6. package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
  7. package/src/core/binary/BinaryBuffer.js +39 -5
  8. package/src/core/geom/3d/topology/struct/binary/io/bt_boundary_loop.d.ts +65 -6
  9. package/src/core/geom/3d/topology/struct/binary/io/bt_boundary_loop.d.ts.map +1 -1
  10. package/src/core/geom/3d/topology/struct/binary/io/bt_boundary_loop.js +451 -101
  11. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts +4 -2
  12. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts.map +1 -1
  13. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.js +4 -2
  14. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_fill_small_holes.d.ts +8 -1
  15. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_fill_small_holes.d.ts.map +1 -1
  16. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_fill_small_holes.js +45 -10
  17. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_face_find_path_polyanya.d.ts.map +1 -1
  18. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_face_find_path_polyanya.js +237 -119
  19. package/src/engine/graphics/ecs/grass/GrassSpecies.d.ts +143 -0
  20. package/src/engine/graphics/ecs/grass/GrassSpecies.d.ts.map +1 -0
  21. package/src/engine/graphics/ecs/grass/GrassSpecies.js +189 -0
  22. package/src/engine/graphics/ecs/grass/GrassSurface.d.ts +25 -0
  23. package/src/engine/graphics/ecs/grass/GrassSurface.d.ts.map +1 -0
  24. package/src/engine/graphics/ecs/grass/GrassSurface.js +32 -0
  25. package/src/engine/graphics/ecs/grass/GroundCover.d.ts +68 -0
  26. package/src/engine/graphics/ecs/grass/GroundCover.d.ts.map +1 -0
  27. package/src/engine/graphics/ecs/grass/GroundCover.js +85 -0
  28. package/src/engine/graphics3/GrassSurfaceSystem.d.ts +153 -0
  29. package/src/engine/graphics3/GrassSurfaceSystem.d.ts.map +1 -0
  30. package/src/engine/graphics3/GrassSurfaceSystem.js +1076 -0
  31. package/src/engine/graphics3/GroundCoverSystem.d.ts +33 -0
  32. package/src/engine/graphics3/GroundCoverSystem.d.ts.map +1 -0
  33. package/src/engine/graphics3/GroundCoverSystem.js +58 -0
  34. package/src/engine/network/NetworkSession.d.ts.map +1 -1
  35. package/src/engine/network/NetworkSession.js +372 -110
  36. package/src/engine/network/orchestrator/NetworkPeer.d.ts.map +1 -1
  37. package/src/engine/network/orchestrator/NetworkPeer.js +6 -1
  38. package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts.map +1 -1
  39. package/src/engine/network/orchestrator/ServerAuthoritativeClient.js +9 -2
  40. package/src/engine/network/orchestrator/ServerAuthoritativeServer.d.ts.map +1 -1
  41. package/src/engine/network/orchestrator/ServerAuthoritativeServer.js +325 -140
  42. package/src/engine/network/sim/SimActionExecutor.d.ts +4 -1
  43. package/src/engine/network/sim/SimActionExecutor.d.ts.map +1 -1
  44. package/src/engine/network/sim/SimActionExecutor.js +65 -9
  45. package/src/engine/network/state/PredictionHistory.d.ts.map +1 -1
  46. package/src/engine/network/state/PredictionHistory.js +6 -1
  47. package/src/engine/network/time/AdaptiveRenderDelay.d.ts +25 -14
  48. package/src/engine/network/time/AdaptiveRenderDelay.d.ts.map +1 -1
  49. package/src/engine/network/time/AdaptiveRenderDelay.js +38 -20
  50. package/src/engine/network/time/RenderPlayout.d.ts +23 -3
  51. package/src/engine/network/time/RenderPlayout.d.ts.map +1 -1
  52. package/src/engine/network/time/RenderPlayout.js +40 -4
  53. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  54. package/src/engine/physics/fluid/obstacle/chunk_fluid_obstacle_record.d.ts +5 -1
  55. package/src/engine/physics/fluid/obstacle/chunk_fluid_obstacle_record.d.ts.map +1 -1
  56. package/src/engine/physics/fluid/obstacle/chunk_fluid_obstacle_record.js +27 -1
  57. package/src/format/lut/cube/CubeLut.d.ts +38 -0
  58. package/src/format/lut/cube/CubeLut.d.ts.map +1 -0
  59. package/src/format/lut/cube/CubeLut.js +23 -0
  60. package/src/format/lut/cube/cube_read.d.ts +23 -0
  61. package/src/format/lut/cube/cube_read.d.ts.map +1 -0
  62. package/src/format/lut/cube/cube_read.js +199 -0
  63. package/src/format/lut/cube/cube_write.d.ts +15 -0
  64. package/src/format/lut/cube/cube_write.d.ts.map +1 -0
  65. package/src/format/lut/cube/cube_write.js +90 -0
  66. package/src/shade/device/shader/ShaderModuleCompiler.d.ts +2 -0
  67. package/src/shade/device/shader/ShaderModuleCompiler.d.ts.map +1 -1
  68. package/src/shade/device/shader/ShaderModuleCompiler.js +25 -2
  69. package/src/shade/playground/grass_surfaces/index.html +75 -0
  70. package/src/shade/playground/grass_surfaces/main.d.ts +2 -0
  71. package/src/shade/playground/grass_surfaces/main.d.ts.map +1 -0
  72. package/src/shade/playground/grass_surfaces/main.js +593 -0
  73. package/src/shade/playground/grass_surfaces/read_grass_surfaces.d.ts +62 -0
  74. package/src/shade/playground/grass_surfaces/read_grass_surfaces.d.ts.map +1 -0
  75. package/src/shade/playground/grass_surfaces/read_grass_surfaces.js +188 -0
  76. package/src/shade/playground/probe_clipmap/README.md +1 -0
  77. package/src/shade/playground/probe_clipmap/index.html +5 -0
  78. package/src/shade/playground/probe_clipmap/main.d.ts.map +1 -1
  79. package/src/shade/playground/probe_clipmap/main.js +7 -0
  80. package/src/shade/playground/probe_clipmap_box/README.md +5 -1
  81. package/src/shade/playground/probe_clipmap_box/index.html +12 -0
  82. package/src/shade/playground/probe_clipmap_box/main.d.ts.map +1 -1
  83. package/src/shade/playground/probe_clipmap_box/main.js +15 -0
  84. package/src/shade/playground/probe_clipmap_box/scene.d.ts +8 -1
  85. package/src/shade/playground/probe_clipmap_box/scene.d.ts.map +1 -1
  86. package/src/shade/playground/probe_clipmap_box/scene.js +74 -6
  87. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  88. package/src/shade/renderer/Renderer.js +59 -55
  89. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts +73 -4
  90. package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts.map +1 -1
  91. package/src/shade/renderer/deferred/tonemap/ColorGrade.js +113 -7
  92. package/src/shade/renderer/deferred/tonemap/TONEMAP_PURKINJE_SHIFT.d.ts +12 -0
  93. package/src/shade/renderer/deferred/tonemap/TONEMAP_PURKINJE_SHIFT.d.ts.map +1 -0
  94. package/src/shade/renderer/deferred/tonemap/TONEMAP_PURKINJE_SHIFT.js +12 -0
  95. package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts +15 -1
  96. package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts.map +1 -1
  97. package/src/shade/renderer/deferred/tonemap/ToneMapper.js +31 -3
  98. package/src/shade/renderer/deferred/tonemap/chunk_tonemap_purkinje.d.ts +25 -0
  99. package/src/shade/renderer/deferred/tonemap/chunk_tonemap_purkinje.d.ts.map +1 -0
  100. package/src/shade/renderer/deferred/tonemap/chunk_tonemap_purkinje.js +51 -0
  101. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts +2 -2
  102. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts.map +1 -1
  103. package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.js +6 -3
  104. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts +3 -2
  105. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts.map +1 -1
  106. package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.js +7 -3
  107. package/src/shade/renderer/extension/ViewTextures.d.ts +12 -5
  108. package/src/shade/renderer/extension/ViewTextures.d.ts.map +1 -1
  109. package/src/shade/renderer/extension/ViewTextures.js +19 -5
  110. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +3 -1
  111. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts.map +1 -1
  112. package/src/shade/renderer/fluid/GPUFluidCascadeStack.js +6 -1
  113. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -0
  114. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts.map +1 -1
  115. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.js +10 -0
  116. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts +7 -1
  117. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts.map +1 -1
  118. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.js +46 -15
  119. package/src/shade/renderer/geometry/sdf/bundle/ModelCacheBundle.d.ts +3 -2
  120. package/src/shade/renderer/geometry/sdf/bundle/ModelCacheBundle.d.ts.map +1 -1
  121. package/src/shade/renderer/geometry/sdf/bundle/ModelCacheBundle.js +3 -2
  122. package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_sort_morton.d.ts +22 -0
  123. package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_sort_morton.d.ts.map +1 -0
  124. package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_sort_morton.js +247 -0
  125. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +50 -0
  126. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts.map +1 -1
  127. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.js +101 -0
  128. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts +2 -1
  129. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts.map +1 -1
  130. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.js +2 -1
  131. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts +8 -0
  132. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts.map +1 -1
  133. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.js +12 -0
  134. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +12 -6
  135. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
  136. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +35 -29
  137. package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_clipmap.d.ts.map +1 -1
  138. package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_clipmap.js +4 -2
  139. package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_material.d.ts.map +1 -1
  140. package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_material.js +6 -4
  141. package/src/shade/renderer/global_illumination/probe_clipmap/material/GPUBrickMaterial.d.ts.map +1 -1
  142. package/src/shade/renderer/global_illumination/probe_clipmap/material/GPUBrickMaterial.js +2 -1
  143. package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material.d.ts +6 -5
  144. package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material.d.ts.map +1 -1
  145. package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material.js +15 -14
  146. package/src/shade/renderer/global_illumination/probe_clipmap/material/shader_brick_material_gather.d.ts.map +1 -1
  147. package/src/shade/renderer/global_illumination/probe_clipmap/material/shader_brick_material_gather.js +4 -2
  148. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts +19 -2
  149. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts.map +1 -1
  150. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.js +128 -10
  151. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts +19 -1
  152. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts.map +1 -1
  153. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.js +27 -2
  154. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.d.ts +19 -11
  155. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.d.ts.map +1 -1
  156. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.js +35 -11
  157. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts.map +1 -1
  158. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.js +3 -1
  159. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_box_cages.d.ts +40 -0
  160. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_box_cages.d.ts.map +1 -0
  161. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_box_cages.js +174 -0
  162. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_material.d.ts +4 -4
  163. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_material.js +10 -10
  164. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_parallax.d.ts +31 -0
  165. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_parallax.d.ts.map +1 -0
  166. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_parallax.js +54 -0
  167. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.d.ts +8 -4
  168. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.d.ts.map +1 -1
  169. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.js +10 -21
  170. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.d.ts +7 -2
  171. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.d.ts.map +1 -1
  172. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.js +33 -29
  173. package/src/shade/renderer/global_illumination/probe_clipmap/probe/graph_probe_clipmap_want_meshlets.d.ts +28 -0
  174. package/src/shade/renderer/global_illumination/probe_clipmap/probe/graph_probe_clipmap_want_meshlets.d.ts.map +1 -0
  175. package/src/shade/renderer/global_illumination/probe_clipmap/probe/graph_probe_clipmap_want_meshlets.js +138 -0
  176. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts +13 -9
  177. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts.map +1 -1
  178. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.js +18 -11
  179. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.js +1 -1
  180. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.d.ts.map +1 -1
  181. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.js +4 -2
  182. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_retire.d.ts.map +1 -1
  183. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_retire.js +2 -3
  184. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.d.ts +5 -3
  185. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.d.ts.map +1 -1
  186. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.js +15 -30
  187. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.js +1 -1
  188. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts.map +1 -1
  189. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.js +4 -2
  190. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.d.ts +11 -0
  191. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.d.ts.map +1 -1
  192. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.js +29 -2
  193. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_late.d.ts +40 -0
  194. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_late.d.ts.map +1 -0
  195. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_late.js +126 -0
  196. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_meshlets.d.ts +36 -0
  197. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_meshlets.d.ts.map +1 -0
  198. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_meshlets.js +221 -0
  199. package/src/shade/renderer/gpu_primitive/age_eviction/chunk_age_eviction.d.ts +40 -0
  200. package/src/shade/renderer/gpu_primitive/age_eviction/chunk_age_eviction.d.ts.map +1 -0
  201. package/src/shade/renderer/gpu_primitive/age_eviction/chunk_age_eviction.js +86 -0
  202. package/src/shade/renderer/grass/blade/GPUGrassBlades.d.ts +135 -0
  203. package/src/shade/renderer/grass/blade/GPUGrassBlades.d.ts.map +1 -0
  204. package/src/shade/renderer/grass/blade/GPUGrassBlades.js +676 -0
  205. package/src/shade/renderer/grass/blade/GRASS_BLADE.d.ts +145 -0
  206. package/src/shade/renderer/grass/blade/GRASS_BLADE.d.ts.map +1 -0
  207. package/src/shade/renderer/grass/blade/GRASS_BLADE.js +179 -0
  208. package/src/shade/renderer/grass/blade/chunk_grass_blade.d.ts +63 -0
  209. package/src/shade/renderer/grass/blade/chunk_grass_blade.d.ts.map +1 -0
  210. package/src/shade/renderer/grass/blade/chunk_grass_blade.js +244 -0
  211. package/src/shade/renderer/grass/blade/chunk_grass_blade_wind.d.ts +58 -0
  212. package/src/shade/renderer/grass/blade/chunk_grass_blade_wind.d.ts.map +1 -0
  213. package/src/shade/renderer/grass/blade/chunk_grass_blade_wind.js +174 -0
  214. package/src/shade/renderer/grass/blade/grass_blade_id_draw.d.ts +25 -0
  215. package/src/shade/renderer/grass/blade/grass_blade_id_draw.d.ts.map +1 -0
  216. package/src/shade/renderer/grass/blade/grass_blade_id_draw.js +133 -0
  217. package/src/shade/renderer/grass/blade/grass_blade_mechanics.d.ts +80 -0
  218. package/src/shade/renderer/grass/blade/grass_blade_mechanics.d.ts.map +1 -0
  219. package/src/shade/renderer/grass/blade/grass_blade_mechanics.js +92 -0
  220. package/src/shade/renderer/grass/blade/grass_blade_resolve.d.ts +29 -0
  221. package/src/shade/renderer/grass/blade/grass_blade_resolve.d.ts.map +1 -0
  222. package/src/shade/renderer/grass/blade/grass_blade_resolve.js +175 -0
  223. package/src/shade/renderer/grass/blade/shader_grass_blade_draw_args.d.ts +14 -0
  224. package/src/shade/renderer/grass/blade/shader_grass_blade_draw_args.d.ts.map +1 -0
  225. package/src/shade/renderer/grass/blade/shader_grass_blade_draw_args.js +45 -0
  226. package/src/shade/renderer/grass/blade/shader_grass_blade_expand.d.ts +61 -0
  227. package/src/shade/renderer/grass/blade/shader_grass_blade_expand.d.ts.map +1 -0
  228. package/src/shade/renderer/grass/blade/shader_grass_blade_expand.js +340 -0
  229. package/src/shade/renderer/grass/blade/shader_grass_cell_count.d.ts +46 -0
  230. package/src/shade/renderer/grass/blade/shader_grass_cell_count.d.ts.map +1 -0
  231. package/src/shade/renderer/grass/blade/shader_grass_cell_count.js +280 -0
  232. package/src/shade/renderer/grass/population/chunk_grass_population.d.ts +60 -0
  233. package/src/shade/renderer/grass/population/chunk_grass_population.d.ts.map +1 -0
  234. package/src/shade/renderer/grass/population/chunk_grass_population.js +171 -0
  235. package/src/shade/renderer/grass/press/GPUGrassPress.d.ts +99 -0
  236. package/src/shade/renderer/grass/press/GPUGrassPress.d.ts.map +1 -0
  237. package/src/shade/renderer/grass/press/GPUGrassPress.js +436 -0
  238. package/src/shade/renderer/grass/press/GRASS_PRESS.d.ts +179 -0
  239. package/src/shade/renderer/grass/press/GRASS_PRESS.d.ts.map +1 -0
  240. package/src/shade/renderer/grass/press/GRASS_PRESS.js +217 -0
  241. package/src/shade/renderer/grass/press/chunk_grass_press.d.ts +65 -0
  242. package/src/shade/renderer/grass/press/chunk_grass_press.d.ts.map +1 -0
  243. package/src/shade/renderer/grass/press/chunk_grass_press.js +296 -0
  244. package/src/shade/renderer/grass/press/shader_grass_press_mark.d.ts +31 -0
  245. package/src/shade/renderer/grass/press/shader_grass_press_mark.d.ts.map +1 -0
  246. package/src/shade/renderer/grass/press/shader_grass_press_mark.js +169 -0
  247. package/src/shade/renderer/grass/press/shader_grass_press_stamp.d.ts +27 -0
  248. package/src/shade/renderer/grass/press/shader_grass_press_stamp.d.ts.map +1 -0
  249. package/src/shade/renderer/grass/press/shader_grass_press_stamp.js +183 -0
  250. package/src/shade/renderer/grass/surface/GPUGrassSurfaces.d.ts +193 -0
  251. package/src/shade/renderer/grass/surface/GPUGrassSurfaces.d.ts.map +1 -0
  252. package/src/shade/renderer/grass/surface/GPUGrassSurfaces.js +1253 -0
  253. package/src/shade/renderer/grass/surface/GRASS_SURFACE.d.ts +211 -0
  254. package/src/shade/renderer/grass/surface/GRASS_SURFACE.d.ts.map +1 -0
  255. package/src/shade/renderer/grass/surface/GRASS_SURFACE.js +241 -0
  256. package/src/shade/renderer/grass/surface/GRASS_SURFACE_VIEW.d.ts +82 -0
  257. package/src/shade/renderer/grass/surface/GRASS_SURFACE_VIEW.d.ts.map +1 -0
  258. package/src/shade/renderer/grass/surface/GRASS_SURFACE_VIEW.js +111 -0
  259. package/src/shade/renderer/grass/surface/chunk_grass_column_cross.d.ts +39 -0
  260. package/src/shade/renderer/grass/surface/chunk_grass_column_cross.d.ts.map +1 -0
  261. package/src/shade/renderer/grass/surface/chunk_grass_column_cross.js +85 -0
  262. package/src/shade/renderer/grass/surface/chunk_grass_directory.d.ts +29 -0
  263. package/src/shade/renderer/grass/surface/chunk_grass_directory.d.ts.map +1 -0
  264. package/src/shade/renderer/grass/surface/chunk_grass_directory.js +112 -0
  265. package/src/shade/renderer/grass/surface/chunk_grass_slot.d.ts +27 -0
  266. package/src/shade/renderer/grass/surface/chunk_grass_slot.d.ts.map +1 -0
  267. package/src/shade/renderer/grass/surface/chunk_grass_slot.js +50 -0
  268. package/src/shade/renderer/grass/surface/chunk_grass_surface_frame.d.ts +21 -0
  269. package/src/shade/renderer/grass/surface/chunk_grass_surface_frame.d.ts.map +1 -0
  270. package/src/shade/renderer/grass/surface/chunk_grass_surface_frame.js +41 -0
  271. package/src/shade/renderer/grass/surface/chunk_grass_surface_window.d.ts +32 -0
  272. package/src/shade/renderer/grass/surface/chunk_grass_surface_window.d.ts.map +1 -0
  273. package/src/shade/renderer/grass/surface/chunk_grass_surface_window.js +136 -0
  274. package/src/shade/renderer/grass/surface/chunk_grass_surfel.d.ts +37 -0
  275. package/src/shade/renderer/grass/surface/chunk_grass_surfel.d.ts.map +1 -0
  276. package/src/shade/renderer/grass/surface/chunk_grass_surfel.js +85 -0
  277. package/src/shade/renderer/grass/surface/chunk_grass_tile.d.ts +25 -0
  278. package/src/shade/renderer/grass/surface/chunk_grass_tile.d.ts.map +1 -0
  279. package/src/shade/renderer/grass/surface/chunk_grass_tile.js +52 -0
  280. package/src/shade/renderer/grass/surface/shader_grass_directory_fill.d.ts +23 -0
  281. package/src/shade/renderer/grass/surface/shader_grass_directory_fill.d.ts.map +1 -0
  282. package/src/shade/renderer/grass/surface/shader_grass_directory_fill.js +87 -0
  283. package/src/shade/renderer/grass/surface/shader_grass_surface_bake.d.ts +43 -0
  284. package/src/shade/renderer/grass/surface/shader_grass_surface_bake.d.ts.map +1 -0
  285. package/src/shade/renderer/grass/surface/shader_grass_surface_bake.js +265 -0
  286. package/src/shade/renderer/grass/surface/shader_grass_surface_bake_command.d.ts +13 -0
  287. package/src/shade/renderer/grass/surface/shader_grass_surface_bake_command.d.ts.map +1 -0
  288. package/src/shade/renderer/grass/surface/shader_grass_surface_bake_command.js +49 -0
  289. package/src/shade/renderer/grass/surface/shader_grass_surface_invalidate.d.ts +62 -0
  290. package/src/shade/renderer/grass/surface/shader_grass_surface_invalidate.d.ts.map +1 -0
  291. package/src/shade/renderer/grass/surface/shader_grass_surface_invalidate.js +162 -0
  292. package/src/shade/renderer/grass/surface/shader_grass_surface_retire.d.ts +40 -0
  293. package/src/shade/renderer/grass/surface/shader_grass_surface_retire.d.ts.map +1 -0
  294. package/src/shade/renderer/grass/surface/shader_grass_surface_retire.js +155 -0
  295. package/src/shade/renderer/grass/surface/shader_grass_surface_schedule.d.ts +19 -0
  296. package/src/shade/renderer/grass/surface/shader_grass_surface_schedule.d.ts.map +1 -0
  297. package/src/shade/renderer/grass/surface/shader_grass_surface_schedule.js +58 -0
  298. package/src/shade/renderer/grass/surface/shader_grass_surface_want.d.ts +30 -0
  299. package/src/shade/renderer/grass/surface/shader_grass_surface_want.d.ts.map +1 -0
  300. package/src/shade/renderer/grass/surface/shader_grass_surface_want.js +251 -0
  301. package/src/shade/renderer/grass/surface/shader_grass_surface_window_count.d.ts +21 -0
  302. package/src/shade/renderer/grass/surface/shader_grass_surface_window_count.d.ts.map +1 -0
  303. package/src/shade/renderer/grass/surface/shader_grass_surface_window_count.js +75 -0
  304. package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.d.ts +35 -9
  305. package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.d.ts.map +1 -1
  306. package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.js +81 -11
  307. package/src/shade/renderer/postprocess/eye/shader_autoexposure_adapt.d.ts.map +1 -1
  308. package/src/shade/renderer/postprocess/eye/shader_autoexposure_adapt.js +4 -1
  309. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts.map +1 -1
  310. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.js +4 -23
  311. package/src/shade/renderer/postprocess/velocity/view_velocity_matrices.d.ts +12 -0
  312. package/src/shade/renderer/postprocess/velocity/view_velocity_matrices.d.ts.map +1 -0
  313. package/src/shade/renderer/postprocess/velocity/view_velocity_matrices.js +29 -0
  314. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.d.ts.map +1 -1
  315. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.js +22 -0
  316. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  317. package/src/shade/renderer/scene/GPUSceneContext.js +3 -0
  318. package/src/shade/renderer/scene/GRASS_SURFACE_PARAMS_STRUCT.d.ts +27 -0
  319. package/src/shade/renderer/scene/GRASS_SURFACE_PARAMS_STRUCT.d.ts.map +1 -0
  320. package/src/shade/renderer/scene/GRASS_SURFACE_PARAMS_STRUCT.js +38 -0
  321. package/src/shade/renderer/scene/MESH_GROUND_COVER_STRUCT.d.ts +28 -0
  322. package/src/shade/renderer/scene/MESH_GROUND_COVER_STRUCT.d.ts.map +1 -0
  323. package/src/shade/renderer/scene/MESH_GROUND_COVER_STRUCT.js +58 -0
  324. package/src/shade/renderer/scene/SCENE_DATABASE_SPEC.d.ts.map +1 -1
  325. package/src/shade/renderer/scene/SCENE_DATABASE_SPEC.js +8 -0
  326. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts +6 -0
  327. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts.map +1 -1
  328. package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.js +7 -0
  329. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts +4 -4
  330. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts.map +1 -1
  331. package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.js +86 -5
  332. package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.d.ts +65 -0
  333. package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.d.ts.map +1 -0
  334. package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.js +136 -0
  335. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.d.ts +37 -0
  336. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.d.ts.map +1 -0
  337. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.js +148 -0
  338. package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_line_span.d.ts +20 -0
  339. package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_line_span.d.ts.map +1 -0
  340. package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_line_span.js +169 -0
  341. package/src/shade/renderer/texture/atlas/chunk_tile_atlas_slot_origin.d.ts +18 -0
  342. package/src/shade/renderer/texture/atlas/chunk_tile_atlas_slot_origin.d.ts.map +1 -1
  343. package/src/shade/renderer/texture/atlas/chunk_tile_atlas_slot_origin.js +28 -0
  344. package/src/shade/renderer/texture/atlas/tile_atlas_slot_shift.d.ts +13 -0
  345. package/src/shade/renderer/texture/atlas/tile_atlas_slot_shift.d.ts.map +1 -0
  346. package/src/shade/renderer/texture/atlas/tile_atlas_slot_shift.js +22 -0
  347. package/src/shade/renderer/water/GPUWaterRenderer.d.ts.map +1 -1
  348. package/src/shade/renderer/water/GPUWaterRenderer.js +4 -0
  349. package/src/shade/renderer/wind/GPUSceneWind.d.ts +52 -5
  350. package/src/shade/renderer/wind/GPUSceneWind.d.ts.map +1 -1
  351. package/src/shade/renderer/wind/GPUSceneWind.js +164 -8
  352. package/src/shade/renderer/wind/WIND_FIELD_UNIFORM.d.ts +3 -1
  353. package/src/shade/renderer/wind/WIND_FIELD_UNIFORM.d.ts.map +1 -1
  354. package/src/shade/renderer/wind/WIND_FIELD_UNIFORM.js +3 -1
  355. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts +2 -1
  356. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts.map +1 -1
  357. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.js +18 -13
  358. package/src/shade/renderer/wind/chunk_wind_field_sample_previous.d.ts +13 -0
  359. package/src/shade/renderer/wind/chunk_wind_field_sample_previous.d.ts.map +1 -0
  360. package/src/shade/renderer/wind/chunk_wind_field_sample_previous.js +23 -0
  361. package/src/shade/renderer/wind/chunk_wind_field_sample_uniform.d.ts +1 -0
  362. package/src/shade/renderer/wind/chunk_wind_field_sample_uniform.d.ts.map +1 -1
  363. package/src/shade/renderer/wind/chunk_wind_field_sample_uniform.js +6 -1
  364. package/src/shade/renderer/wind/wind_field_add_resources.d.ts +11 -0
  365. package/src/shade/renderer/wind/wind_field_add_resources.d.ts.map +1 -1
  366. package/src/shade/renderer/wind/wind_field_add_resources.js +15 -0
  367. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +1 -1
  368. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  369. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +2 -0
  370. package/src/shade/renderer/shader/chunk/color/tonemap/purkinjie/chunk_apply_purkinjie_shift.d.ts +0 -11
  371. package/src/shade/renderer/shader/chunk/color/tonemap/purkinjie/chunk_apply_purkinjie_shift.d.ts.map +0 -1
  372. package/src/shade/renderer/shader/chunk/color/tonemap/purkinjie/chunk_apply_purkinjie_shift.js +0 -56
@@ -0,0 +1,169 @@
1
+ import { FLUID_OBSTACLE_DESCRIPTOR } from "../../fluid/forcing/FLUID_DATABASE_SPEC.js";
2
+ import { chunk_fluid_forcing_leaf } from "../../fluid/forcing/chunk_fluid_forcing_leaf.js";
3
+ import { TRANSFORMS_TABLE } from "../../scene/chunk_scene_database_access.js";
4
+ import { MESH_GROUND_COVER_FLAG_MEMBER } from "../../scene/MESH_GROUND_COVER_STRUCT.js";
5
+ import { SCENE_DATABASE_SPEC } from "../../scene/SCENE_DATABASE_SPEC.js";
6
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
7
+ import { ComputeShader } from "../../shader/ComputeShader.js";
8
+ import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
9
+ import { atomic_u32, u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
10
+ import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
11
+ import {
12
+ GRASS_PRESS_FIELD_TILES,
13
+ GRASS_PRESS_JOBS_COMMAND,
14
+ GRASS_PRESS_JOBS_COUNTS,
15
+ GRASS_PRESS_JOBS_LISTS,
16
+ GRASS_PRESS_JOBS_TILES,
17
+ GRASS_PRESS_TILE_CANDIDATES,
18
+ GRASS_PRESS_TILE_CELLS,
19
+ GRASS_PRESS_TILE_CELLS_LOG2,
20
+ GRASS_PRESS_WINDOW_STRUCT,
21
+ GRASS_PRESS_WINDOW_TILES,
22
+ GRASS_PRESS_WINDOW_TILES_LOG2
23
+ } from "./GRASS_PRESS.js";
24
+
25
+ const MESH_GROUND_COVERS_TABLE = SCENE_DATABASE_SPEC.get('mesh_ground_covers');
26
+
27
+ /**
28
+ * Threads in a workgroup of {@link shader_grass_press_mark}.
29
+ *
30
+ * @type {number}
31
+ */
32
+ export const GRASS_PRESS_MARK_WORKGROUP_SIZE = 64;
33
+
34
+ const resources = new ShaderResourceSetDescriptor();
35
+
36
+ resources.createGroup()
37
+ .addUniform("grass_press_window", GRASS_PRESS_WINDOW_STRUCT)
38
+ .addStorageBuffer("press_rows", WebGPUArray.from(u32))
39
+ .addStorageBuffer("fluid_database", WebGPUArray.from(u32))
40
+ .addStorageBuffer("scene_database", WebGPUArray.from(u32))
41
+ .addStorageBuffer("press_jobs", WebGPUArray.from(atomic_u32), true)
42
+ .addStorageBuffer("grass_press", WebGPUArray.from(atomic_u32), true);
43
+
44
+ /**
45
+ * Lists the frame's obstacles by the tiles of the press field's window they stand over
46
+ * (`GRASS_PRESS.js`), a thread an obstacle: element `i` of `press_rows` is a row of the fluid's obstacle
47
+ * table, for `i` under `grass_press_window.row_count`.
48
+ *
49
+ * An obstacle stands over the tiles its world box crosses (`fluid_forcing_obstacle_box`), as far as they
50
+ * are the window's. For each it takes the next place in the tile's list, if the list has one left, and
51
+ * the first obstacle to list itself in a tile adds the tile to the frame's tiles and one to the count
52
+ * of workgroups the stamp is dispatched with.
53
+ *
54
+ * It also writes the clock's time into the word of every tile of the window that its box comes within a
55
+ * cell of, at the front of the field, `grass_press`: the tiles whose blades read a cell it may press.
56
+ *
57
+ * Two kinds of obstacle list themselves nowhere, and so press nothing. One with no box, a half-space:
58
+ * there is no end to what it would press. And one whose row is ground of a grass surface (a member, by the
59
+ * scene's `mesh_ground_covers`): ground does not press what grows on it, and under everything that
60
+ * stands on it, it would be the lowest obstacle of every cell.
61
+ *
62
+ * `press_jobs` is the frame's jobs, its command and its tiles' counts zero on entry.
63
+ *
64
+ * @type {ComputeShader}
65
+ */
66
+ export const shader_grass_press_mark = ComputeShader.from({
67
+ label: "Grass Press Mark",
68
+ resources,
69
+ body: CodeChunk.from(
70
+ //language=WGSL
71
+ `
72
+ @compute @workgroup_size(${GRASS_PRESS_MARK_WORKGROUP_SIZE})
73
+ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
74
+ let i = id.x;
75
+
76
+ if (i == 0u) {
77
+ // the stamp is dispatched along x alone
78
+ atomicStore(&press_jobs[${GRASS_PRESS_JOBS_COMMAND + 1}], 1u);
79
+ atomicStore(&press_jobs[${GRASS_PRESS_JOBS_COMMAND + 2}], 1u);
80
+ }
81
+
82
+ if (i >= grass_press_window.row_count) {
83
+ return;
84
+ }
85
+
86
+ let row = press_rows[i];
87
+ let record = ${FLUID_OBSTACLE_DESCRIPTOR.marshalling_method_read}(&fluid_database, row);
88
+
89
+ if (!shape_record_local_bounded(record.shape_kind)) {
90
+ return;
91
+ }
92
+
93
+ // ground of a grass surface
94
+ let cover_flags = ${MESH_GROUND_COVERS_TABLE.marshalling_method_read_field('flags')}(&scene_database, record.node);
95
+
96
+ if ((cover_flags & ${MESH_GROUND_COVER_FLAG_MEMBER}u) != 0u) {
97
+ return;
98
+ }
99
+
100
+ let global = ${TRANSFORMS_TABLE.marshalling_method_read_field('global')}(&scene_database, record.node);
101
+ let box = fluid_forcing_obstacle_box(record, global, 0.0);
102
+
103
+ // the tiles the box crosses, and the window's, which are all that is marked
104
+ let tile_side = grass_press_window.spacing * ${GRASS_PRESS_TILE_CELLS}.0;
105
+
106
+ let window_low = grass_press_window.corner >> vec2<u32>(${GRASS_PRESS_TILE_CELLS_LOG2}u);
107
+ let window_high = window_low + vec2<i32>(${GRASS_PRESS_WINDOW_TILES - 1});
108
+
109
+ let low = vec2<i32>(floor(box.low.xz / tile_side));
110
+ let high = vec2<i32>(floor(box.high.xz / tile_side));
111
+
112
+ // the tiles it is within a cell of: a blade reads the cells about it
113
+ let reach = grass_press_window.spacing;
114
+
115
+ let near_low = max(vec2<i32>(floor((box.low.xz - reach) / tile_side)), window_low);
116
+ let near_high = min(vec2<i32>(floor((box.high.xz + reach) / tile_side)), window_high);
117
+
118
+ if (near_low.x > near_high.x || near_low.y > near_high.y) {
119
+ return;
120
+ }
121
+
122
+ // a time of zero would read as never
123
+ let time = max(grass_press_window.now, 1u);
124
+
125
+ for (var dz = 0; dz < ${GRASS_PRESS_WINDOW_TILES}; dz++) {
126
+ if (near_low.y + dz > near_high.y) {
127
+ break;
128
+ }
129
+
130
+ for (var dx = 0; dx < ${GRASS_PRESS_WINDOW_TILES}; dx++) {
131
+ if (near_low.x + dx > near_high.x) {
132
+ break;
133
+ }
134
+
135
+ let at = near_low + vec2<i32>(dx, dz);
136
+
137
+ // a tile's place among the window's is its coordinates wrapped by the window's side
138
+ let wrapped = at & vec2<i32>(${GRASS_PRESS_WINDOW_TILES - 1});
139
+ let tile = u32((wrapped.y << ${GRASS_PRESS_WINDOW_TILES_LOG2}u) | wrapped.x);
140
+
141
+ atomicStore(&grass_press[${GRASS_PRESS_FIELD_TILES}u + tile], time);
142
+
143
+ if (at.x < low.x || at.x > high.x || at.y < low.y || at.y > high.y) {
144
+ // near it, not under it
145
+ continue;
146
+ }
147
+
148
+ let listed = atomicAdd(&press_jobs[${GRASS_PRESS_JOBS_COUNTS}u + tile], 1u);
149
+
150
+ if (listed == 0u) {
151
+ let job = atomicAdd(&press_jobs[${GRASS_PRESS_JOBS_COMMAND}], 1u);
152
+
153
+ atomicStore(&press_jobs[${GRASS_PRESS_JOBS_TILES}u + job], tile);
154
+ }
155
+
156
+ if (listed < ${GRASS_PRESS_TILE_CANDIDATES}u) {
157
+ atomicStore(&press_jobs[${GRASS_PRESS_JOBS_LISTS}u + tile * ${GRASS_PRESS_TILE_CANDIDATES}u + listed], row);
158
+ }
159
+ }
160
+ }
161
+ }
162
+ `, [
163
+ GRASS_PRESS_WINDOW_STRUCT.declaration_chunk,
164
+ chunk_fluid_forcing_leaf,
165
+ FLUID_OBSTACLE_DESCRIPTOR.chunk_read,
166
+ TRANSFORMS_TABLE.chunk_read_field('global'),
167
+ MESH_GROUND_COVERS_TABLE.chunk_read_field('flags'),
168
+ ]),
169
+ });
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Writes the press field under the frame's obstacles (`GRASS_PRESS.js`): a workgroup a tile that has an
3
+ * obstacle listed, a thread a cell of it. Dispatched with the command at the front of `press_jobs`, which
4
+ * {@link shader_grass_press_mark} wrote.
5
+ *
6
+ * A cell's thread walks its tile's list and asks each obstacle what it spans on the vertical line through
7
+ * the cell's middle (`fluid_obstacle_record_line_span`). Of those that cross the line it keeps the one
8
+ * that reaches lowest, and that is the cell's press for the frame: the heights of the span, the
9
+ * obstacle's velocity over the ground at its foot, and the clock's time. A cell no obstacle crosses is left
10
+ * as it is.
11
+ *
12
+ * The press is written as the latest of a new state for the cell, into the place of the state the cell had
13
+ * before the one it has, which the one it has now becomes. The new state's deepest press is the one the
14
+ * cell's state had, where that state was written by the stamp before this one
15
+ * (`grass_press_window.stamped`) and its deepest reaches lower than this press: the cell is still in the
16
+ * same contact, and has been pressed further in it. Otherwise it is this
17
+ * press. A cell stamped a second time at one time of the clock has its state written again in place, so
18
+ * the state before it stays the one before that time. A cell whose place held another cell starts with
19
+ * nothing.
20
+ *
21
+ * One press a cell and frame: where two obstacles stand over a cell at two heights, only the lower presses.
22
+ *
23
+ * @type {ComputeShader}
24
+ */
25
+ export const shader_grass_press_stamp: ComputeShader;
26
+ import { ComputeShader } from "../../shader/ComputeShader.js";
27
+ //# sourceMappingURL=shader_grass_press_stamp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shader_grass_press_stamp.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/press/shader_grass_press_stamp.js"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,uCAFU,aAAa,CA2HpB;8BAlL2B,+BAA+B"}
@@ -0,0 +1,183 @@
1
+ import { chunk_fluid_obstacle_record } from "../../../../engine/physics/fluid/obstacle/chunk_fluid_obstacle_record.js";
2
+ import { FLUID_OBSTACLE_DESCRIPTOR, FLUID_OBSTACLE_PLANE_DESCRIPTOR } from "../../fluid/forcing/FLUID_DATABASE_SPEC.js";
3
+ import { TRANSFORMS_TABLE } from "../../scene/chunk_scene_database_access.js";
4
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
5
+ import { ComputeShader } from "../../shader/ComputeShader.js";
6
+ import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
7
+ import { u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
8
+ import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
9
+ import { chunk_grass_press } from "./chunk_grass_press.js";
10
+ import {
11
+ GRASS_PRESS_CELL_TAG,
12
+ GRASS_PRESS_JOBS_COUNTS,
13
+ GRASS_PRESS_JOBS_LISTS,
14
+ GRASS_PRESS_JOBS_TILES,
15
+ GRASS_PRESS_STATE_DEEPEST,
16
+ GRASS_PRESS_STATE_LATEST,
17
+ GRASS_PRESS_STATE_NODE,
18
+ GRASS_PRESS_TAG_CURRENT_SHIFT,
19
+ GRASS_PRESS_TILE_CANDIDATES,
20
+ GRASS_PRESS_TILE_CELLS,
21
+ GRASS_PRESS_TILE_CELLS_LOG2,
22
+ GRASS_PRESS_TIME,
23
+ GRASS_PRESS_WINDOW_STRUCT,
24
+ GRASS_PRESS_WINDOW_TILES,
25
+ GRASS_PRESS_WINDOW_TILES_LOG2,
26
+ GRASS_PRESS_WORDS
27
+ } from "./GRASS_PRESS.js";
28
+
29
+ const resources = new ShaderResourceSetDescriptor();
30
+
31
+ resources.createGroup()
32
+ .addUniform("grass_press_window", GRASS_PRESS_WINDOW_STRUCT)
33
+ .addStorageBuffer("press_jobs", WebGPUArray.from(u32))
34
+ .addStorageBuffer("fluid_database", WebGPUArray.from(u32))
35
+ .addStorageBuffer("scene_database", WebGPUArray.from(u32))
36
+ .addStorageBuffer("grass_press", WebGPUArray.from(u32), true);
37
+
38
+ /**
39
+ * Writes the press field under the frame's obstacles (`GRASS_PRESS.js`): a workgroup a tile that has an
40
+ * obstacle listed, a thread a cell of it. Dispatched with the command at the front of `press_jobs`, which
41
+ * {@link shader_grass_press_mark} wrote.
42
+ *
43
+ * A cell's thread walks its tile's list and asks each obstacle what it spans on the vertical line through
44
+ * the cell's middle (`fluid_obstacle_record_line_span`). Of those that cross the line it keeps the one
45
+ * that reaches lowest, and that is the cell's press for the frame: the heights of the span, the
46
+ * obstacle's velocity over the ground at its foot, and the clock's time. A cell no obstacle crosses is left
47
+ * as it is.
48
+ *
49
+ * The press is written as the latest of a new state for the cell, into the place of the state the cell had
50
+ * before the one it has, which the one it has now becomes. The new state's deepest press is the one the
51
+ * cell's state had, where that state was written by the stamp before this one
52
+ * (`grass_press_window.stamped`) and its deepest reaches lower than this press: the cell is still in the
53
+ * same contact, and has been pressed further in it. Otherwise it is this
54
+ * press. A cell stamped a second time at one time of the clock has its state written again in place, so
55
+ * the state before it stays the one before that time. A cell whose place held another cell starts with
56
+ * nothing.
57
+ *
58
+ * One press a cell and frame: where two obstacles stand over a cell at two heights, only the lower presses.
59
+ *
60
+ * @type {ComputeShader}
61
+ */
62
+ export const shader_grass_press_stamp = ComputeShader.from({
63
+ label: "Grass Press Stamp",
64
+ resources,
65
+ body: CodeChunk.from(
66
+ //language=WGSL
67
+ `
68
+ fn shape_record_plane(index: u32) -> vec4<f32> {
69
+ return ${FLUID_OBSTACLE_PLANE_DESCRIPTOR.marshalling_method_read_field('plane')}(&fluid_database, index);
70
+ }
71
+
72
+ @compute @workgroup_size(${GRASS_PRESS_TILE_CELLS}, ${GRASS_PRESS_TILE_CELLS}, 1)
73
+ fn main(
74
+ @builtin(workgroup_id) workgroup: vec3<u32>,
75
+ @builtin(local_invocation_id) local: vec3<u32>,
76
+ ) {
77
+ let tile = press_jobs[${GRASS_PRESS_JOBS_TILES}u + workgroup.x];
78
+
79
+ // the tile's place among the window's back to the tile it is of, the one of that place inside the window
80
+ let window_low = grass_press_window.corner >> vec2<u32>(${GRASS_PRESS_TILE_CELLS_LOG2}u);
81
+ let place = vec2<i32>(i32(tile & ${GRASS_PRESS_WINDOW_TILES - 1}u), i32(tile >> ${GRASS_PRESS_WINDOW_TILES_LOG2}u));
82
+
83
+ let world_tile = window_low + ((place - window_low) & vec2<i32>(${GRASS_PRESS_WINDOW_TILES - 1}));
84
+ let cell = (world_tile << vec2<u32>(${GRASS_PRESS_TILE_CELLS_LOG2}u)) + vec2<i32>(local.xy);
85
+
86
+ let middle = (vec2<f32>(cell) + vec2<f32>(0.5)) * grass_press_window.spacing;
87
+
88
+ let listed = min(press_jobs[${GRASS_PRESS_JOBS_COUNTS}u + tile], ${GRASS_PRESS_TILE_CANDIDATES}u);
89
+
90
+ var found = false;
91
+ var press: GrassPress;
92
+ var node = 0u;
93
+
94
+ for (var i = 0u; i < ${GRASS_PRESS_TILE_CANDIDATES}u; i++) {
95
+ if (i >= listed) {
96
+ break;
97
+ }
98
+
99
+ let row = press_jobs[${GRASS_PRESS_JOBS_LISTS}u + tile * ${GRASS_PRESS_TILE_CANDIDATES}u + i];
100
+ let record = ${FLUID_OBSTACLE_DESCRIPTOR.marshalling_method_read}(&fluid_database, row);
101
+ let global = ${TRANSFORMS_TABLE.marshalling_method_read_field('global')}(&scene_database, record.node);
102
+
103
+ // up the line from height zero, so a place along it is a height
104
+ let span = fluid_obstacle_record_line_span(record, global, vec3<f32>(middle.x, 0.0, middle.y), vec3<f32>(0.0, 1.0, 0.0));
105
+
106
+ if (span.x > span.y) {
107
+ continue;
108
+ }
109
+
110
+ if (found && span.x >= press.bottom) {
111
+ continue;
112
+ }
113
+
114
+ found = true;
115
+ node = record.node + 1u;
116
+
117
+ press.time = grass_press_window.now;
118
+ press.bottom = span.x;
119
+ press.top = span.y;
120
+ press.velocity = fluid_obstacle_record_wall_velocity(record, global, vec3<f32>(middle.x, span.x, middle.y)).xz;
121
+ }
122
+
123
+ if (!found) {
124
+ return;
125
+ }
126
+
127
+ let slot = grass_press_slot(cell);
128
+ let page = grass_press_page(cell);
129
+
130
+ let tag = grass_press[slot + ${GRASS_PRESS_CELL_TAG}u];
131
+
132
+ var current = tag >> ${GRASS_PRESS_TAG_CURRENT_SHIFT}u;
133
+
134
+ if ((tag & ${(2 ** GRASS_PRESS_TAG_CURRENT_SHIFT) - 1}u) != page) {
135
+ // the place was another cell's: this cell has held nothing. Its first state is written below
136
+ grass_press[grass_press_state(slot, 2u) + ${GRASS_PRESS_STATE_NODE}u] = 0u;
137
+
138
+ current = 0u;
139
+ }
140
+
141
+ // the state this frame's is written over, and what the cell's contact has been pressed to
142
+ var written = 1u;
143
+ var deepest = press;
144
+
145
+ if (current != 0u) {
146
+ let had = grass_press_state(slot, current);
147
+ let stamped = grass_press[had + ${GRASS_PRESS_STATE_LATEST + GRASS_PRESS_TIME}u];
148
+
149
+ // stamped at this time already: that state again. Else the one before it
150
+ written = select(3u - current, current, stamped == press.time);
151
+
152
+ if (stamped == press.time || stamped == grass_press_window.stamped) {
153
+ let kept = grass_press_read(had + ${GRASS_PRESS_STATE_DEEPEST}u);
154
+
155
+ if (kept.bottom < press.bottom) {
156
+ deepest = kept;
157
+ }
158
+ }
159
+ }
160
+
161
+ let state = grass_press_state(slot, written);
162
+
163
+ let latest_words = grass_press_pack(press);
164
+ let deepest_words = grass_press_pack(deepest);
165
+
166
+ grass_press[state + ${GRASS_PRESS_STATE_NODE}u] = node;
167
+
168
+ for (var w = 0u; w < ${GRASS_PRESS_WORDS}u; w++) {
169
+ grass_press[state + ${GRASS_PRESS_STATE_LATEST}u + w] = latest_words[w];
170
+ grass_press[state + ${GRASS_PRESS_STATE_DEEPEST}u + w] = deepest_words[w];
171
+ }
172
+
173
+ grass_press[slot + ${GRASS_PRESS_CELL_TAG}u] = page | (written << ${GRASS_PRESS_TAG_CURRENT_SHIFT}u);
174
+ }
175
+ `, [
176
+ GRASS_PRESS_WINDOW_STRUCT.declaration_chunk,
177
+ chunk_grass_press,
178
+ chunk_fluid_obstacle_record,
179
+ FLUID_OBSTACLE_DESCRIPTOR.chunk_read,
180
+ FLUID_OBSTACLE_PLANE_DESCRIPTOR.chunk_read_field('plane'),
181
+ TRANSFORMS_TABLE.chunk_read_field('global'),
182
+ ]),
183
+ });
@@ -0,0 +1,193 @@
1
+ /**
2
+ * Records in the directory of a pool of `slot_capacity` slots: a power of two at least twice the slots,
3
+ * so the table is never more than half full, and no fewer than its probe limit.
4
+ *
5
+ * @param {number} slot_capacity
6
+ * @returns {number}
7
+ */
8
+ export function grass_directory_table_size(slot_capacity: number): number;
9
+ /**
10
+ * How finely a scene's grass surfaces are sampled, and how fast.
11
+ */
12
+ export class GrassSurfaceSettings {
13
+ /**
14
+ * The distance between neighbouring columns of a surface's finest level, in world units: how exactly a
15
+ * blade's root follows the ground, against the rays that find it and the memory that keeps it.
16
+ *
17
+ * @type {number}
18
+ */
19
+ finest_spacing: number;
20
+ /**
21
+ * The least width a blade is drawn at, in pixels of the view's render resolution. A surface's level
22
+ * serves the distances at which its spacing spans no more than this.
23
+ *
24
+ * @type {number}
25
+ */
26
+ narrowest_blade: number;
27
+ /**
28
+ * The least length a blade is drawn at, in pixels of the view's render resolution. No tile is asked for
29
+ * past the distance where its surface's tallest blade spans less.
30
+ *
31
+ * @type {number}
32
+ */
33
+ shortest_blade: number;
34
+ /**
35
+ * The most layers of tiles baked a view a frame, each a workgroup of {@link GRASS_TILE_SURFELS} columns:
36
+ * how fast ground a view turns towards gets its grass. A frame bakes what it was asked and no more, so
37
+ * this is the cost of the frame that asks most.
38
+ *
39
+ * @type {number}
40
+ */
41
+ bake_capacity: number;
42
+ /**
43
+ * How many blades a view ray may cross before the grass behind them is left out: the grass's density
44
+ * where it is seen at a low angle. Lower lets more ground show through.
45
+ * @type {number}
46
+ */
47
+ canopy_opacity: number;
48
+ }
49
+ /**
50
+ * The grass surfaces of one scene on the device: which surfaces there are, the pool their tiles' surfels
51
+ * are kept in, and the passes that ask for and bake the tiles a view wants (`GRASS_SURFACE.js`).
52
+ *
53
+ * A surface is named by its `transforms` row. Its members are the mesh rows whose `mesh_ground_covers`
54
+ * record names that row; this class is told only the surface's box and tallest blade.
55
+ *
56
+ * Each frame: {@link update} once, then {@link graph_update} for every view that draws grass.
57
+ */
58
+ export class GPUGrassSurfaces {
59
+ /**
60
+ * Offer the pipelines the surfaces' passes run — see {@link PipelineEnquiry}.
61
+ *
62
+ * @param {PipelineEnquiry} enquiry
63
+ */
64
+ static enquirePipelines(enquiry: PipelineEnquiry): void;
65
+ /**
66
+ * @param {GraphicsContext} graphics
67
+ */
68
+ constructor(graphics: GraphicsContext);
69
+ /**
70
+ * @type {GrassSurfaceSettings}
71
+ */
72
+ settings: GrassSurfaceSettings;
73
+ /**
74
+ * @returns {number} how many surfaces there are
75
+ */
76
+ get surface_count(): number;
77
+ /**
78
+ * @returns {number} how many slots the pool has; 0 before the first surface
79
+ */
80
+ get slot_capacity(): number;
81
+ /**
82
+ * The pool's arena: its counters, then a record a slot (`GRASS_SURFACE.js`). Null before the first
83
+ * surface, and replaced when the pool grows: read it when a pass runs.
84
+ *
85
+ * @returns {GPUBuffer|null}
86
+ */
87
+ get pool_buffer(): any;
88
+ /**
89
+ * The pool's directory, a `chunk_hash_table_atomic` table. Null before the first surface, and replaced
90
+ * when the pool grows.
91
+ *
92
+ * @returns {GPUBuffer|null}
93
+ */
94
+ get directory_buffer(): any;
95
+ /**
96
+ * The surfel atlas, a texel a column of a slot (`chunk_grass_surfel`, `grass_slot_texel`). Null before
97
+ * the first surface, and replaced when the pool grows.
98
+ *
99
+ * @returns {GPUTexture|null}
100
+ */
101
+ get atlas(): any;
102
+ /**
103
+ * A view of the surfel atlas for a pass to bind. Null before the first surface; ask again each frame.
104
+ *
105
+ * @returns {GPUTextureView|null}
106
+ */
107
+ get atlas_view(): any;
108
+ /**
109
+ * The most slots the pool can grow to on this device: what the surfel atlas can hold. 0 before the
110
+ * first surface.
111
+ *
112
+ * @returns {number}
113
+ */
114
+ get slot_capacity_limit(): number;
115
+ /**
116
+ * The list of surface records (`GRASS_SURFACE_RECORD_STRUCT`), {@link surface_count} of them. Null
117
+ * before the first surface, and replaced when the list grows.
118
+ *
119
+ * @returns {GPUBuffer|null}
120
+ */
121
+ get surfaces_buffer(): any;
122
+ /**
123
+ * Whether `node` is a surface here.
124
+ *
125
+ * @param {number} node a `transforms` row
126
+ * @returns {boolean}
127
+ */
128
+ has(node: number): boolean;
129
+ /**
130
+ * Make a surface of a `transforms` row, or change the one it is.
131
+ *
132
+ * @param {number} node the surface's `transforms` row; not the scene's root
133
+ * @param {ArrayLike<number>} low the least corner of a box, in the surface's frame, that holds every member
134
+ * @param {ArrayLike<number>} high the box's greatest corner
135
+ * @param {number} blade_length the tallest blade that grows on any member, world units; 0 when none grows
136
+ */
137
+ set(node: number, low: ArrayLike<number>, high: ArrayLike<number>, blade_length: number): void;
138
+ /**
139
+ * A row stops being a surface. The slots that hold its tiles stay taken until the pool has need of them.
140
+ *
141
+ * @param {number} node a `transforms` row; one that is no surface is left alone
142
+ */
143
+ remove(node: number): void;
144
+ /**
145
+ * The ground of a surface has changed inside a rectangle: a member has come, gone or moved there. Every
146
+ * layer of every tile the rectangle touches, of every level, is baked again, where it is, when a view
147
+ * next asks for it. What it costs does not depend on the rectangle's size.
148
+ *
149
+ * @param {number} node the surface's `transforms` row
150
+ * @param {number} low_x the rectangle, in the surface's frame
151
+ * @param {number} low_z
152
+ * @param {number} high_x
153
+ * @param {number} high_z
154
+ */
155
+ invalidate(node: number, low_x: number, low_z: number, high_x: number, high_z: number): void;
156
+ /**
157
+ * Begin a frame: bring the device's list of surfaces up to date, and make the pool if there is a
158
+ * surface and no pool yet. Call once a frame, before any view's {@link graph_update}.
159
+ */
160
+ update(): void;
161
+ /**
162
+ * What a view asks of the surfaces this frame, as the passes' immediate (`GRASS_SURFACE_VIEW_SETTINGS`):
163
+ * the settings, the view's focal length in pixels, the frame and the counts. `blade_capacity` is left
164
+ * at zero for whoever keeps a blade list.
165
+ *
166
+ * @param {GPUViewContext} view
167
+ * @returns {object|null} null while there is no pool, no surface, or nothing grows on any
168
+ */
169
+ view_settings(view: GPUViewContext): object | null;
170
+ /**
171
+ * Record a view's asks for tiles, and the bake of those taken: the passes of `GRASS_SURFACE.js`'s
172
+ * lifetime, in the frame graph. Records nothing while there is no surface.
173
+ *
174
+ * @param {object} options
175
+ * @param {FrameGraph} options.graph
176
+ * @param {GPUViewContext} options.view the view; its scene is the surfaces' scene
177
+ */
178
+ graph_update({ graph, view }: {
179
+ graph: FrameGraph;
180
+ view: GPUViewContext;
181
+ }): void;
182
+ /**
183
+ * Let go of everything on the device. The surfaces stay listed: the next {@link update} makes a fresh
184
+ * pool for them.
185
+ */
186
+ destroy(): void;
187
+ #private;
188
+ }
189
+ export type FrameGraph = import("../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph;
190
+ export type PipelineEnquiry = import("../../../device/pipeline/PipelineEnquiry.js").PipelineEnquiry;
191
+ export type GraphicsContext = import("../../GraphicsContext.js").GraphicsContext;
192
+ export type GPUViewContext = import("../../view/GPUViewContext.js").GPUViewContext;
193
+ //# sourceMappingURL=GPUGrassSurfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GPUGrassSurfaces.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/surface/GPUGrassSurfaces.js"],"names":[],"mappings":"AAyGA;;;;;;GAMG;AACH,0DAHW,MAAM,GACJ,MAAM,CAUlB;AAED;;GAEG;AACH;IACI;;;;;OAKG;IACH,gBAFU,MAAM,CAEO;IAEvB;;;;;OAKG;IACH,iBAFU,MAAM,CAEM;IAEtB;;;;;OAKG;IACH,gBAFU,MAAM,CAEG;IAEnB;;;;;;OAMG;IACH,eAFU,MAAM,CAEG;IAEnB;;;;OAIG;IACH,gBAFU,MAAM,CAEG;CACtB;AAED;;;;;;;;GAQG;AACH;IAEI;;;;OAIG;IACH,iCAFW,eAAe,QAczB;IA4KD;;OAEG;IACH,sBAFW,eAAe,EAOzB;IAlLD;;OAEG;IACH,UAFU,oBAAoB,CAEQ;IAiLtC;;OAEG;IACH,4BAEC;IAED;;OAEG;IACH,4BAEC;IAED;;;;;OAKG;IACH,uBAEC;IAED;;;;;OAKG;IACH,4BAEC;IAED;;;;;OAKG;IACH,iBAEC;IAED;;;;OAIG;IACH,sBAEC;IAED;;;;;OAKG;IACH,kCAEC;IAED;;;;;OAKG;IACH,2BAEC;IAED;;;;;OAKG;IACH,UAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;;;;OAOG;IACH,UALW,MAAM,OACN,UAAU,MAAM,CAAC,QACjB,UAAU,MAAM,CAAC,gBACjB,MAAM,QAgDhB;IAED;;;;OAIG;IACH,aAFW,MAAM,QA8BhB;IAED;;;;;;;;;;OAUG;IACH,iBANW,MAAM,SACN,MAAM,SACN,MAAM,UACN,MAAM,UACN,MAAM,QAYhB;IAyGD;;;OAGG;IACH,eAwEC;IAoPD;;;;;;;OAOG;IACH,oBAHW,cAAc,GACZ,MAAM,GAAC,IAAI,CAyBvB;IAED;;;;;;;OAOG;IACH;QAH+B,KAAK,EAAzB,UAAU;QACc,IAAI,EAA5B,cAAc;aA+KxB;IAED;;;OAGG;IACH,gBAQC;;CA2BJ;yBAzqCY,OAAO,8DAA8D,EAAE,UAAU;8BACjF,OAAO,6CAA6C,EAAE,eAAe;8BACrE,OAAO,0BAA0B,EAAE,eAAe;6BAClD,OAAO,8BAA8B,EAAE,cAAc"}