@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,217 @@
1
+ import { f32, u32, vec2i } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
2
+ import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
3
+
4
+ /**
5
+ * The press field: where obstacles have pressed grass down, kept on the device.
6
+ *
7
+ * The ground is cut into square **cells** over the world's x and z, `spacing` metres a side. An obstacle
8
+ * over a cell leaves a **press** in it: the heights the obstacle spans on the vertical line through the
9
+ * cell's middle, its velocity over the ground there, and when. A blade leans as far as a press leaves it no
10
+ * room to stand, and from the press's time on stands back up (`chunk_grass_press`). Nothing sweeps the
11
+ * field: a cell is written only while an obstacle is over it.
12
+ *
13
+ * **A cell remembers two presses**, which together are its **state**: the *latest*, and the *deepest* of
14
+ * the contact the latest is part of, a contact being the stamps of the field, one after another, in which
15
+ * something is over the cell. Both are needed. Whatever rolls or steps over a cell leaves it rim last, so the latest
16
+ * press of a contact is too high to hold anything down; and whatever comes down on a cell and then lingers
17
+ * above it holds the grass as low as it lingers long after how low it first came has been stood back up
18
+ * from. A blade is held by whichever of the two holds it further.
19
+ *
20
+ * It is exact for something that comes down on a cell and goes. Where it lingers higher than it has been
21
+ * and then goes, what is remembered is how low it first came and how it left, not how it lingered.
22
+ *
23
+ * **A cell keeps the state it had before its last stamp** beside the one it has, so that a blade can be
24
+ * drawn as it was a frame ago: for a cell stamped this frame that is the other state, and for any other
25
+ * cell the one it has.
26
+ *
27
+ * The field holds the cells of a **window**, `GRASS_PRESS_WINDOW_CELLS` a side, about a view. A cell has
28
+ * one place in the field wherever the window is, its coordinates wrapped by the window's side, and a
29
+ * place says which cell it holds, so a place the window has moved away from and come back to with
30
+ * another cell is never read as that cell's. The window's side, a tile's and the tiles' count are powers
31
+ * of two, so that wrapping is a mask.
32
+ *
33
+ * Each frame the obstacles over the window are listed by the **tiles** they stand over
34
+ * (`shader_grass_press_mark`), `GRASS_PRESS_TILE_CELLS` cells a side, and every cell of every tile that
35
+ * has an obstacle is written by a thread of its own (`shader_grass_press_stamp`).
36
+ *
37
+ * **A tile remembers when an obstacle was last near it**, one word, at the front of the field. Most grass
38
+ * is nowhere near a press, and a blade whose tile was last near an obstacle too long ago for any press to
39
+ * still show reads that word and none of its cells.
40
+ *
41
+ * Times are 32-bit ticks of the press's clock: a press is read rightly for 2³¹ ticks after it was made,
42
+ * 24 days.
43
+ *
44
+ * What is ground of a grass surface presses nothing: the grass on it stands on it, and other obstacles
45
+ * stand on it too. An obstacle that stands in for ground and is not to flatten the grass about it is made
46
+ * a member of the surface.
47
+ */
48
+
49
+ /**
50
+ * Cells along a tile's side, as a power of two.
51
+ *
52
+ * @type {number}
53
+ */
54
+ export const GRASS_PRESS_TILE_CELLS_LOG2 = 4;
55
+
56
+ /**
57
+ * Cells along a tile's side.
58
+ *
59
+ * @type {number}
60
+ */
61
+ export const GRASS_PRESS_TILE_CELLS = 1 << GRASS_PRESS_TILE_CELLS_LOG2;
62
+
63
+ /**
64
+ * Tiles along the window's side, as a power of two.
65
+ *
66
+ * @type {number}
67
+ */
68
+ export const GRASS_PRESS_WINDOW_TILES_LOG2 = 4;
69
+
70
+ /**
71
+ * Tiles along the window's side.
72
+ *
73
+ * @type {number}
74
+ */
75
+ export const GRASS_PRESS_WINDOW_TILES = 1 << GRASS_PRESS_WINDOW_TILES_LOG2;
76
+
77
+ /**
78
+ * Cells along the window's side, as a power of two.
79
+ *
80
+ * @type {number}
81
+ */
82
+ export const GRASS_PRESS_WINDOW_CELLS_LOG2 = GRASS_PRESS_TILE_CELLS_LOG2 + GRASS_PRESS_WINDOW_TILES_LOG2;
83
+
84
+ /**
85
+ * Cells along the window's side.
86
+ *
87
+ * @type {number}
88
+ */
89
+ export const GRASS_PRESS_WINDOW_CELLS = 1 << GRASS_PRESS_WINDOW_CELLS_LOG2;
90
+
91
+ /**
92
+ * Obstacles a tile lists at most: what a cell's thread walks. A tile more obstacles stand over is
93
+ * pressed by the first that many to list themselves.
94
+ *
95
+ * @type {number}
96
+ */
97
+ export const GRASS_PRESS_TILE_CANDIDATES = 16;
98
+
99
+ /**
100
+ * Steps of the press's clock in a second.
101
+ *
102
+ * @type {number}
103
+ */
104
+ export const GRASS_PRESS_TICKS_PER_SECOND = 1024;
105
+
106
+ /**
107
+ * Words a press takes.
108
+ *
109
+ * @type {number}
110
+ */
111
+ export const GRASS_PRESS_WORDS = 4;
112
+
113
+ /** Press word: when, in ticks of the press's clock. */
114
+ export const GRASS_PRESS_TIME = 0;
115
+
116
+ /** Press word: the lowest height of the obstacle on the cell's line, the bits of a `f32`. */
117
+ export const GRASS_PRESS_BOTTOM = 1;
118
+
119
+ /** Press word: the highest, the bits of a `f32`. */
120
+ export const GRASS_PRESS_TOP = 2;
121
+
122
+ /** Press word: the obstacle's velocity along x and along z at the foot of its span, two half floats. */
123
+ export const GRASS_PRESS_VELOCITY = 3;
124
+
125
+ /**
126
+ * Words a state takes: whose press the latest is, the latest, and the deepest of its contact.
127
+ *
128
+ * @type {number}
129
+ */
130
+ export const GRASS_PRESS_STATE_WORDS = 1 + 2 * GRASS_PRESS_WORDS;
131
+
132
+ /** State word: the `transforms` row of the latest press's obstacle, plus one; 0 for a state that holds nothing. */
133
+ export const GRASS_PRESS_STATE_NODE = 0;
134
+
135
+ /** State word: the first of the latest press's. */
136
+ export const GRASS_PRESS_STATE_LATEST = 1;
137
+
138
+ /** State word: the first of the deepest press's. */
139
+ export const GRASS_PRESS_STATE_DEEPEST = GRASS_PRESS_STATE_LATEST + GRASS_PRESS_WORDS;
140
+
141
+ /**
142
+ * Words a cell takes in the field: its tag, and its two states.
143
+ *
144
+ * @type {number}
145
+ */
146
+ export const GRASS_PRESS_CELL_WORDS = 1 + 2 * GRASS_PRESS_STATE_WORDS;
147
+
148
+ /**
149
+ * Cell word: the cell's tag. Its low {@link GRASS_PRESS_TAG_CURRENT_SHIFT} bits say which cell this is,
150
+ * `grass_press_page`; the bits above which state is the cell's, 1 or 2, the other being the one it had
151
+ * before its last stamp, or 0 for a cell nothing has pressed.
152
+ */
153
+ export const GRASS_PRESS_CELL_TAG = 0;
154
+
155
+ /**
156
+ * Where in a cell's tag the number of its state is: above the page.
157
+ *
158
+ * @type {number}
159
+ */
160
+ export const GRASS_PRESS_TAG_CURRENT_SHIFT = 30;
161
+
162
+ /** Cell word: the first of state 1's; state 2's follow. */
163
+ export const GRASS_PRESS_CELL_STATES = 1;
164
+
165
+ /**
166
+ * Field word: the first of the window's tiles' words, one a tile, by the tile's place among the window's.
167
+ * The clock's time when an obstacle last stood within a cell of the tile; 0 for never, a time of 0 being
168
+ * written as 1.
169
+ */
170
+ export const GRASS_PRESS_FIELD_TILES = 0;
171
+
172
+ /** Field word: the first of the cells'. */
173
+ export const GRASS_PRESS_FIELD_CELLS = GRASS_PRESS_FIELD_TILES + GRASS_PRESS_WINDOW_TILES ** 2;
174
+
175
+ /**
176
+ * Words in the field.
177
+ *
178
+ * @type {number}
179
+ */
180
+ export const GRASS_PRESS_FIELD_WORDS = GRASS_PRESS_FIELD_CELLS + GRASS_PRESS_WINDOW_CELLS ** 2 * GRASS_PRESS_CELL_WORDS;
181
+
182
+ /**
183
+ * Words of the frame's tile jobs (`shader_grass_press_mark` writes them, `shader_grass_press_stamp` reads
184
+ * them): the stamp's indirect dispatch, three words and one unused; then for each of the window's tiles how
185
+ * many obstacles listed themselves; then the tiles that have any, in the order they were first listed;
186
+ * then each tile's list, `GRASS_PRESS_TILE_CANDIDATES` rows of the fluid's obstacle table.
187
+ */
188
+ export const GRASS_PRESS_JOBS_COMMAND = 0;
189
+
190
+ export const GRASS_PRESS_JOBS_COUNTS = 4;
191
+
192
+ export const GRASS_PRESS_JOBS_TILES = GRASS_PRESS_JOBS_COUNTS + GRASS_PRESS_WINDOW_TILES ** 2;
193
+
194
+ export const GRASS_PRESS_JOBS_LISTS = GRASS_PRESS_JOBS_TILES + GRASS_PRESS_WINDOW_TILES ** 2;
195
+
196
+ export const GRASS_PRESS_JOBS_WORDS = GRASS_PRESS_JOBS_LISTS + GRASS_PRESS_WINDOW_TILES ** 2 * GRASS_PRESS_TILE_CANDIDATES;
197
+
198
+ /**
199
+ * The press field's window and clock, as every pass that touches the field reads them.
200
+ *
201
+ * - `corner`: the window's first cell along x and along z, a multiple of `GRASS_PRESS_TILE_CELLS`.
202
+ * - `spacing`: a cell's side in metres. Zero while there is no field: nothing is pressed.
203
+ * - `now`, `previous`: the press's clock at this frame and at the frame before, in ticks.
204
+ * - `stamped`: the clock when the field was stamped the time before this one. It is `previous` where
205
+ * every frame of the clock stamps, and earlier where frames went by unstamped.
206
+ * - `row_count`: obstacle rows the frame lists, for the pass that marks tiles.
207
+ *
208
+ * @type {WebGPUStruct}
209
+ */
210
+ export const GRASS_PRESS_WINDOW_STRUCT = WebGPUStruct.from({
211
+ corner: vec2i,
212
+ spacing: f32,
213
+ now: u32,
214
+ previous: u32,
215
+ stamped: u32,
216
+ row_count: u32,
217
+ }, "GrassPressWindow");
@@ -0,0 +1,65 @@
1
+ /**
2
+ * The press field (`GRASS_PRESS.js`) as a shader reads it: a cell's place, a press, and what the presses
3
+ * about a blade push it by.
4
+ *
5
+ * ```wgsl
6
+ * struct GrassPress {
7
+ * time: u32, // when, in ticks
8
+ * bottom: f32, // the heights the obstacle spans on the cell's line, in the world
9
+ * top: f32,
10
+ * velocity: vec2<f32>, // the obstacle's, along the world's x and z, m/s
11
+ * }
12
+ *
13
+ * struct GrassPressPush {
14
+ * now: vec3<f32>,
15
+ * before: vec3<f32>,
16
+ * }
17
+ *
18
+ * fn grass_press_cell(position_xz: vec2<f32>, spacing: f32) -> vec2<i32>
19
+ * fn grass_press_slot(cell: vec2<i32>) -> u32
20
+ * fn grass_press_page(cell: vec2<i32>) -> u32
21
+ * fn grass_press_tile(cell: vec2<i32>) -> u32
22
+ * fn grass_press_state(slot: u32, which: u32) -> u32
23
+ * fn grass_press_pack(press: GrassPress) -> array<u32, 4>
24
+ * fn grass_press_read(at: u32) -> GrassPress
25
+ * fn grass_press_held(press: GrassPress, ticks: u32, root_height: f32, blade_length: f32, recovery: f32) -> f32
26
+ * fn grass_press_pushed(position: vec3<f32>, blade_length: f32, recovery: f32, frame: mat4x4<f32>, least: f32) -> GrassPressPush
27
+ * ```
28
+ *
29
+ * Reads `grass_press`, the field as `array<u32>`, and `grass_press_window`
30
+ * (`GRASS_PRESS_WINDOW_STRUCT`), which the enclosing shader binds.
31
+ *
32
+ * **A cell's place.** `grass_press_cell` is the cell a point of ground is in; `grass_press_slot` the
33
+ * first word of the cell's place in the field, its coordinates wrapped by the window's side;
34
+ * `grass_press_page` which of the cells that share the place it is, the low bits of the tag a place
35
+ * holds; `grass_press_state` the first word of a place's state 1 or 2; `grass_press_tile` the place
36
+ * of the cell's tile among the window's, which is where in the field the tile's word is.
37
+ *
38
+ * **How far a press holds a blade over** (`grass_press_held`), as an angle from upright: not at all,
39
+ * unless the obstacle's span and the blade's share height: its top above the blade's root and its bottom
40
+ * under the blade's tip as it stands, `blade_length` over `root_height`. Otherwise until the blade's
41
+ * top is under the obstacle, `acos(clear / length)`, `clear` the room between root and obstacle; and
42
+ * from the press's time on the blade stands back up, what is left of the angle falling by `e` every
43
+ * `recovery` seconds. A press later than `ticks` has not happened yet and holds nothing.
44
+ *
45
+ * **What a blade is pushed by** (`grass_press_pushed`), now and a frame ago. A cell holds the blade by
46
+ * whichever of its state's two presses holds it further, and the blade is held by the four cells about its
47
+ * place, each weighed by how near its middle is, so that a press's edge is a ramp a cell wide. `z` of an
48
+ * answer is the angle the blade is held over by, the cells' angles so weighed; `xy` the velocity over the
49
+ * ground of what holds it, the cells' presses' weighed by how far each holds the blade, in the frame of
50
+ * `frame`, the blade's surface's. Which way the blade goes over is the blade's to say
51
+ * (`grass_blade_bend`). `position` is the blade's root in the world.
52
+ *
53
+ * `now` is at the clock's time, by the state each cell has. `before` is at the clock's previous time: by
54
+ * the state a cell had before its last stamp, for a cell stamped since that time, and by the state it has
55
+ * otherwise.
56
+ *
57
+ * `least` is the smallest angle the caller can tell from none. Where the blade's tile was last near an
58
+ * obstacle so long before the clock's previous time that a press that laid the blade flat then would by
59
+ * now hold it less than `least`, or was never near one, the answer is no push and no cell is read.
60
+ *
61
+ * @type {CodeChunk}
62
+ */
63
+ export const chunk_grass_press: CodeChunk;
64
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
65
+ //# sourceMappingURL=chunk_grass_press.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_grass_press.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/press/chunk_grass_press.js"],"names":[],"mappings":"AA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,gCAFU,SAAS,CAgNjB;0BAvSwB,oCAAoC"}
@@ -0,0 +1,296 @@
1
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
+ import { chunk_grass_surface_frame } from "../surface/chunk_grass_surface_frame.js";
3
+ import {
4
+ GRASS_PRESS_BOTTOM,
5
+ GRASS_PRESS_CELL_STATES,
6
+ GRASS_PRESS_CELL_TAG,
7
+ GRASS_PRESS_CELL_WORDS,
8
+ GRASS_PRESS_FIELD_CELLS,
9
+ GRASS_PRESS_FIELD_TILES,
10
+ GRASS_PRESS_STATE_DEEPEST,
11
+ GRASS_PRESS_STATE_LATEST,
12
+ GRASS_PRESS_STATE_NODE,
13
+ GRASS_PRESS_STATE_WORDS,
14
+ GRASS_PRESS_TAG_CURRENT_SHIFT,
15
+ GRASS_PRESS_TICKS_PER_SECOND,
16
+ GRASS_PRESS_TILE_CELLS_LOG2,
17
+ GRASS_PRESS_TIME,
18
+ GRASS_PRESS_TOP,
19
+ GRASS_PRESS_VELOCITY,
20
+ GRASS_PRESS_WINDOW_CELLS,
21
+ GRASS_PRESS_WINDOW_CELLS_LOG2,
22
+ GRASS_PRESS_WINDOW_STRUCT,
23
+ GRASS_PRESS_WINDOW_TILES,
24
+ GRASS_PRESS_WINDOW_TILES_LOG2,
25
+ GRASS_PRESS_WORDS
26
+ } from "./GRASS_PRESS.js";
27
+
28
+ /**
29
+ * The press field (`GRASS_PRESS.js`) as a shader reads it: a cell's place, a press, and what the presses
30
+ * about a blade push it by.
31
+ *
32
+ * ```wgsl
33
+ * struct GrassPress {
34
+ * time: u32, // when, in ticks
35
+ * bottom: f32, // the heights the obstacle spans on the cell's line, in the world
36
+ * top: f32,
37
+ * velocity: vec2<f32>, // the obstacle's, along the world's x and z, m/s
38
+ * }
39
+ *
40
+ * struct GrassPressPush {
41
+ * now: vec3<f32>,
42
+ * before: vec3<f32>,
43
+ * }
44
+ *
45
+ * fn grass_press_cell(position_xz: vec2<f32>, spacing: f32) -> vec2<i32>
46
+ * fn grass_press_slot(cell: vec2<i32>) -> u32
47
+ * fn grass_press_page(cell: vec2<i32>) -> u32
48
+ * fn grass_press_tile(cell: vec2<i32>) -> u32
49
+ * fn grass_press_state(slot: u32, which: u32) -> u32
50
+ * fn grass_press_pack(press: GrassPress) -> array<u32, 4>
51
+ * fn grass_press_read(at: u32) -> GrassPress
52
+ * fn grass_press_held(press: GrassPress, ticks: u32, root_height: f32, blade_length: f32, recovery: f32) -> f32
53
+ * fn grass_press_pushed(position: vec3<f32>, blade_length: f32, recovery: f32, frame: mat4x4<f32>, least: f32) -> GrassPressPush
54
+ * ```
55
+ *
56
+ * Reads `grass_press`, the field as `array<u32>`, and `grass_press_window`
57
+ * (`GRASS_PRESS_WINDOW_STRUCT`), which the enclosing shader binds.
58
+ *
59
+ * **A cell's place.** `grass_press_cell` is the cell a point of ground is in; `grass_press_slot` the
60
+ * first word of the cell's place in the field, its coordinates wrapped by the window's side;
61
+ * `grass_press_page` which of the cells that share the place it is, the low bits of the tag a place
62
+ * holds; `grass_press_state` the first word of a place's state 1 or 2; `grass_press_tile` the place
63
+ * of the cell's tile among the window's, which is where in the field the tile's word is.
64
+ *
65
+ * **How far a press holds a blade over** (`grass_press_held`), as an angle from upright: not at all,
66
+ * unless the obstacle's span and the blade's share height: its top above the blade's root and its bottom
67
+ * under the blade's tip as it stands, `blade_length` over `root_height`. Otherwise until the blade's
68
+ * top is under the obstacle, `acos(clear / length)`, `clear` the room between root and obstacle; and
69
+ * from the press's time on the blade stands back up, what is left of the angle falling by `e` every
70
+ * `recovery` seconds. A press later than `ticks` has not happened yet and holds nothing.
71
+ *
72
+ * **What a blade is pushed by** (`grass_press_pushed`), now and a frame ago. A cell holds the blade by
73
+ * whichever of its state's two presses holds it further, and the blade is held by the four cells about its
74
+ * place, each weighed by how near its middle is, so that a press's edge is a ramp a cell wide. `z` of an
75
+ * answer is the angle the blade is held over by, the cells' angles so weighed; `xy` the velocity over the
76
+ * ground of what holds it, the cells' presses' weighed by how far each holds the blade, in the frame of
77
+ * `frame`, the blade's surface's. Which way the blade goes over is the blade's to say
78
+ * (`grass_blade_bend`). `position` is the blade's root in the world.
79
+ *
80
+ * `now` is at the clock's time, by the state each cell has. `before` is at the clock's previous time: by
81
+ * the state a cell had before its last stamp, for a cell stamped since that time, and by the state it has
82
+ * otherwise.
83
+ *
84
+ * `least` is the smallest angle the caller can tell from none. Where the blade's tile was last near an
85
+ * obstacle so long before the clock's previous time that a press that laid the blade flat then would by
86
+ * now hold it less than `least`, or was never near one, the answer is no push and no cell is read.
87
+ *
88
+ * @type {CodeChunk}
89
+ */
90
+ export const chunk_grass_press = CodeChunk.from(
91
+ //language=WGSL
92
+ `
93
+ struct GrassPress {
94
+ time: u32,
95
+ bottom: f32,
96
+ top: f32,
97
+ velocity: vec2<f32>,
98
+ }
99
+
100
+ struct GrassPressPush {
101
+ now: vec3<f32>,
102
+ before: vec3<f32>,
103
+ }
104
+
105
+ // the most a press holds a blade over: flat
106
+ const GRASS_PRESS_FLAT = 1.5707963267948966;
107
+
108
+ fn grass_press_cell(position_xz: vec2<f32>, spacing: f32) -> vec2<i32> {
109
+ return vec2<i32>(floor(position_xz / spacing));
110
+ }
111
+
112
+ // a cell's coordinates within the window's side, never negative
113
+ fn grass_press_wrapped(cell: vec2<i32>) -> vec2<i32> {
114
+ return cell & vec2<i32>(${GRASS_PRESS_WINDOW_CELLS - 1});
115
+ }
116
+
117
+ fn grass_press_slot(cell: vec2<i32>) -> u32 {
118
+ let wrapped = grass_press_wrapped(cell);
119
+
120
+ return ${GRASS_PRESS_FIELD_CELLS}u + u32(wrapped.y * ${GRASS_PRESS_WINDOW_CELLS} + wrapped.x) * ${GRASS_PRESS_CELL_WORDS}u;
121
+ }
122
+
123
+ fn grass_press_tile(cell: vec2<i32>) -> u32 {
124
+ let wrapped = (cell >> vec2<u32>(${GRASS_PRESS_TILE_CELLS_LOG2}u)) & vec2<i32>(${GRASS_PRESS_WINDOW_TILES - 1});
125
+
126
+ return u32((wrapped.y << ${GRASS_PRESS_WINDOW_TILES_LOG2}u) | wrapped.x);
127
+ }
128
+
129
+ fn grass_press_page(cell: vec2<i32>) -> u32 {
130
+ // how many window sides along each axis, half the page's bits each
131
+ let page = vec2<u32>(cell >> vec2<u32>(${GRASS_PRESS_WINDOW_CELLS_LOG2}u)) & vec2<u32>(${(1 << (GRASS_PRESS_TAG_CURRENT_SHIFT / 2)) - 1}u);
132
+
133
+ return page.x | (page.y << ${GRASS_PRESS_TAG_CURRENT_SHIFT / 2}u);
134
+ }
135
+
136
+ fn grass_press_state(slot: u32, which: u32) -> u32 {
137
+ return slot + ${GRASS_PRESS_CELL_STATES}u + (which - 1u) * ${GRASS_PRESS_STATE_WORDS}u;
138
+ }
139
+
140
+ fn grass_press_pack(press: GrassPress) -> array<u32, ${GRASS_PRESS_WORDS}> {
141
+ var words: array<u32, ${GRASS_PRESS_WORDS}>;
142
+
143
+ words[${GRASS_PRESS_TIME}] = press.time;
144
+ words[${GRASS_PRESS_BOTTOM}] = bitcast<u32>(press.bottom);
145
+ words[${GRASS_PRESS_TOP}] = bitcast<u32>(press.top);
146
+ words[${GRASS_PRESS_VELOCITY}] = pack2x16float(press.velocity);
147
+
148
+ return words;
149
+ }
150
+
151
+ fn grass_press_read(at: u32) -> GrassPress {
152
+ var press: GrassPress;
153
+
154
+ press.time = grass_press[at + ${GRASS_PRESS_TIME}u];
155
+ press.bottom = bitcast<f32>(grass_press[at + ${GRASS_PRESS_BOTTOM}u]);
156
+ press.top = bitcast<f32>(grass_press[at + ${GRASS_PRESS_TOP}u]);
157
+ press.velocity = unpack2x16float(grass_press[at + ${GRASS_PRESS_VELOCITY}u]);
158
+
159
+ return press;
160
+ }
161
+
162
+ fn grass_press_held(
163
+ press: GrassPress,
164
+ ticks: u32,
165
+ root_height: f32,
166
+ blade_length: f32,
167
+ recovery: f32,
168
+ ) -> f32 {
169
+ // wholly under the root. One wholly over the tip leaves the blade all its length, and holds it by no angle
170
+ if (press.top <= root_height) {
171
+ return 0.0;
172
+ }
173
+
174
+ // the clock wraps, and so does a time after it
175
+ let age = ticks - press.time;
176
+
177
+ if (age >= 0x80000000u) {
178
+ return 0.0;
179
+ }
180
+
181
+ // the room between root and obstacle, none where the obstacle reaches under the root
182
+ let clear = press.bottom - root_height;
183
+ let held = acos(clamp(clear / blade_length, 0.0, 1.0));
184
+
185
+ return held * exp(-f32(age) / (${GRASS_PRESS_TICKS_PER_SECOND}.0 * max(recovery, 1e-6)));
186
+ }
187
+
188
+ // what a state holds a blade by at a time: its obstacle's velocity over the ground times the angle, and the angle
189
+ fn grass_press_state_push(state: u32, ticks: u32, root_height: f32, blade_length: f32, recovery: f32) -> vec3<f32> {
190
+ let latest = grass_press_read(state + ${GRASS_PRESS_STATE_LATEST}u);
191
+ let deepest = grass_press_read(state + ${GRASS_PRESS_STATE_DEEPEST}u);
192
+
193
+ let by_latest = grass_press_held(latest, ticks, root_height, blade_length, recovery);
194
+ let by_deepest = grass_press_held(deepest, ticks, root_height, blade_length, recovery);
195
+
196
+ if (by_deepest > by_latest) {
197
+ return vec3<f32>(deepest.velocity * by_deepest, by_deepest);
198
+ }
199
+
200
+ return vec3<f32>(latest.velocity * by_latest, by_latest);
201
+ }
202
+
203
+ // the obstacles' way over the ground in a frame, from a sum of velocities times angles and of angles
204
+ fn grass_press_carried(frame: mat4x4<f32>, sum: vec3<f32>) -> vec3<f32> {
205
+ if (sum.z <= 0.0) {
206
+ return vec3<f32>(0.0);
207
+ }
208
+
209
+ let velocity = grass_world_direction_to_frame(frame, vec3<f32>(sum.x, 0.0, sum.y) * (1.0 / sum.z));
210
+
211
+ return vec3<f32>(velocity.xz, sum.z);
212
+ }
213
+
214
+ fn grass_press_pushed(
215
+ position: vec3<f32>,
216
+ blade_length: f32,
217
+ recovery: f32,
218
+ frame: mat4x4<f32>,
219
+ least: f32,
220
+ ) -> GrassPressPush {
221
+ var pushed: GrassPressPush;
222
+
223
+ let spacing = grass_press_window.spacing;
224
+
225
+ if (spacing <= 0.0) {
226
+ return pushed;
227
+ }
228
+
229
+ let now = grass_press_window.now;
230
+ let previous = grass_press_window.previous;
231
+
232
+ // when an obstacle was last within a cell of the blade's tile, which is as late as any press the blade reads
233
+ let touched = grass_press[${GRASS_PRESS_FIELD_TILES}u + grass_press_tile(grass_press_cell(position.xz, spacing))];
234
+
235
+ if (touched == 0u) {
236
+ return pushed;
237
+ }
238
+
239
+ // a tile touched after the clock's previous time was touched a time less than none before it, and is read
240
+ let since = i32(previous - touched);
241
+
242
+ if (f32(since) > ${GRASS_PRESS_TICKS_PER_SECOND}.0 * recovery * log(GRASS_PRESS_FLAT / least)) {
243
+ return pushed;
244
+ }
245
+
246
+ // the four cells whose middles are about the place
247
+ let place = position.xz / spacing - vec2<f32>(0.5);
248
+ let first = vec2<i32>(floor(place));
249
+ let share = place - floor(place);
250
+
251
+ var sum_now = vec3<f32>(0.0);
252
+ var sum_before = vec3<f32>(0.0);
253
+
254
+ for (var i = 0u; i < 4u; i++) {
255
+ let corner = vec2<i32>(i32(i & 1u), i32(i >> 1u));
256
+ let cell = first + corner;
257
+ let slot = grass_press_slot(cell);
258
+
259
+ // nothing has pressed most cells: one word says so
260
+ let tag = grass_press[slot + ${GRASS_PRESS_CELL_TAG}u];
261
+ let current = tag >> ${GRASS_PRESS_TAG_CURRENT_SHIFT}u;
262
+
263
+ if (current == 0u || (tag & ${(2 ** GRASS_PRESS_TAG_CURRENT_SHIFT) - 1}u) != grass_press_page(cell)) {
264
+ continue;
265
+ }
266
+
267
+ let weight = mix(1.0 - share.x, share.x, f32(corner.x)) * mix(1.0 - share.y, share.y, f32(corner.y));
268
+
269
+ let state = grass_press_state(slot, current);
270
+
271
+ sum_now += grass_press_state_push(state, now, position.y, blade_length, recovery) * weight;
272
+
273
+ // stamped since the frame before: the state it had then is the other one, if that holds anything
274
+ let stamped = grass_press[state + ${GRASS_PRESS_STATE_LATEST + GRASS_PRESS_TIME}u];
275
+
276
+ if ((previous - stamped) < 0x80000000u) {
277
+ sum_before += grass_press_state_push(state, previous, position.y, blade_length, recovery) * weight;
278
+ } else {
279
+ let other = grass_press_state(slot, 3u - current);
280
+
281
+ if (grass_press[other + ${GRASS_PRESS_STATE_NODE}u] != 0u) {
282
+ sum_before += grass_press_state_push(other, previous, position.y, blade_length, recovery) * weight;
283
+ }
284
+ }
285
+ }
286
+
287
+ pushed.now = grass_press_carried(frame, sum_now);
288
+ pushed.before = grass_press_carried(frame, sum_before);
289
+
290
+ return pushed;
291
+ }
292
+ `, [
293
+ GRASS_PRESS_WINDOW_STRUCT.declaration_chunk,
294
+ chunk_grass_surface_frame,
295
+ ]
296
+ );
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Threads in a workgroup of {@link shader_grass_press_mark}.
3
+ *
4
+ * @type {number}
5
+ */
6
+ export const GRASS_PRESS_MARK_WORKGROUP_SIZE: number;
7
+ /**
8
+ * Lists the frame's obstacles by the tiles of the press field's window they stand over
9
+ * (`GRASS_PRESS.js`), a thread an obstacle: element `i` of `press_rows` is a row of the fluid's obstacle
10
+ * table, for `i` under `grass_press_window.row_count`.
11
+ *
12
+ * An obstacle stands over the tiles its world box crosses (`fluid_forcing_obstacle_box`), as far as they
13
+ * are the window's. For each it takes the next place in the tile's list, if the list has one left, and
14
+ * the first obstacle to list itself in a tile adds the tile to the frame's tiles and one to the count
15
+ * of workgroups the stamp is dispatched with.
16
+ *
17
+ * It also writes the clock's time into the word of every tile of the window that its box comes within a
18
+ * cell of, at the front of the field, `grass_press`: the tiles whose blades read a cell it may press.
19
+ *
20
+ * Two kinds of obstacle list themselves nowhere, and so press nothing. One with no box, a half-space:
21
+ * there is no end to what it would press. And one whose row is ground of a grass surface (a member, by the
22
+ * scene's `mesh_ground_covers`): ground does not press what grows on it, and under everything that
23
+ * stands on it, it would be the lowest obstacle of every cell.
24
+ *
25
+ * `press_jobs` is the frame's jobs, its command and its tiles' counts zero on entry.
26
+ *
27
+ * @type {ComputeShader}
28
+ */
29
+ export const shader_grass_press_mark: ComputeShader;
30
+ import { ComputeShader } from "../../shader/ComputeShader.js";
31
+ //# sourceMappingURL=shader_grass_press_mark.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shader_grass_press_mark.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/press/shader_grass_press_mark.js"],"names":[],"mappings":"AA0BA;;;;GAIG;AACH,8CAFU,MAAM,CAEkC;AAYlD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,sCAFU,aAAa,CAyGpB;8BAlK2B,+BAA+B"}