@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,85 @@
1
+ import { chunk_decode_vertex_normal } from "../../shader/chunk/geometry/normal/chunk_decode_vertex_normal.js";
2
+ import { chunk_encode_vertex_normal } from "../../shader/chunk/geometry/normal/chunk_encode_vertex_normal.js";
3
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
4
+ import { chunk_grass_column_cross } from "./chunk_grass_column_cross.js";
5
+
6
+ /**
7
+ * Texture format of a surfel: four words, one texel.
8
+ * @type {GPUTextureFormat}
9
+ */
10
+ export const GRASS_SURFEL_FORMAT = "rgba32uint";
11
+
12
+ /**
13
+ * A surfel of a grass surface: one point of ground a blade can stand on, and what a blade needs of it.
14
+ *
15
+ * A surfel sits on a column of its surface's lattice, so where it is across the surface is its place in
16
+ * its tile; the record holds only where it is along the surface frame's up axis.
17
+ *
18
+ * ```wgsl
19
+ * struct GrassSurfel {
20
+ * height: f32, // along the surface frame's up axis, in the frame's units
21
+ * normal: vec3<f32>, // unit, in the surface's frame
22
+ * member: u32, // the meshes row of the member it lies on
23
+ * clear_height: f32, // open air over it; GRASS_CLEAR_HEIGHT_OPEN and above mean open sky
24
+ * density: f32, // painted density, 0 to 1
25
+ * }
26
+ *
27
+ * fn grass_surfel_pack(surfel: GrassSurfel) -> vec4<u32>
28
+ * fn grass_surfel_unpack(texel: vec4<u32>) -> GrassSurfel
29
+ * fn grass_surfel_exists(texel: vec4<u32>) -> bool
30
+ * ```
31
+ *
32
+ * A texel is `(height bits, normal, member, clear height | density << 16)`: the normal in the vertex-normal
33
+ * format, the clear height a half float, the density a 16-bit unorm. `height` and `member` round-trip
34
+ * exactly. A clear height must be in `[0, GRASS_CLEAR_HEIGHT_OPEN]`.
35
+ *
36
+ * Row 0 of the scene's tables is its root and never a mesh, so a member of 0 is no surfel: a cleared
37
+ * texel holds none, which is what `grass_surfel_exists` asks.
38
+ *
39
+ * @type {CodeChunk}
40
+ */
41
+ export const chunk_grass_surfel = CodeChunk.from(
42
+ //language=WGSL
43
+ `
44
+ struct GrassSurfel {
45
+ height: f32,
46
+ normal: vec3<f32>,
47
+ member: u32,
48
+ clear_height: f32,
49
+ density: f32,
50
+ }
51
+
52
+ fn grass_surfel_pack(surfel: GrassSurfel) -> vec4<u32> {
53
+ let clear_height = pack2x16float(vec2<f32>(surfel.clear_height, 0.0)) & 0xFFFFu;
54
+ let density = u32(saturate(surfel.density) * 65535.0 + 0.5);
55
+
56
+ return vec4<u32>(
57
+ bitcast<u32>(surfel.height),
58
+ encode_vertex_normal(surfel.normal),
59
+ surfel.member,
60
+ clear_height | (density << 16u),
61
+ );
62
+ }
63
+
64
+ fn grass_surfel_unpack(texel: vec4<u32>) -> GrassSurfel {
65
+ var surfel: GrassSurfel;
66
+
67
+ surfel.height = bitcast<f32>(texel.x);
68
+ surfel.normal = decode_vertex_normal(texel.y);
69
+ surfel.member = texel.z;
70
+ surfel.clear_height = unpack2x16float(texel.w & 0xFFFFu).x;
71
+ surfel.density = f32(texel.w >> 16u) / 65535.0;
72
+
73
+ return surfel;
74
+ }
75
+
76
+ fn grass_surfel_exists(texel: vec4<u32>) -> bool {
77
+ return texel.z != 0u;
78
+ }
79
+ `, [
80
+ chunk_encode_vertex_normal,
81
+ chunk_decode_vertex_normal,
82
+ // GRASS_CLEAR_HEIGHT_OPEN
83
+ chunk_grass_column_cross,
84
+ ]
85
+ );
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Where the columns of a grass surface's tiles are: in the surface's frame, and in the surfel atlas.
3
+ * `GRASS_SURFACE.js` says what a level, a tile and a slot are.
4
+ *
5
+ * ```wgsl
6
+ * fn grass_level_spacing(finest_spacing: f32, level: u32) -> f32
7
+ * fn grass_tile_column_position(tile: vec2<i32>, column: vec2<u32>, spacing: f32) -> vec2<f32>
8
+ * fn grass_tile_of_position(position: vec2<f32>, spacing: f32) -> vec2<i32>
9
+ * fn grass_slot_texel(slot: u32, column: vec2<u32>, atlas_width: u32) -> vec2<u32>
10
+ * ```
11
+ *
12
+ * - `grass_level_spacing`: the distance between neighbouring columns of a level, `finest_spacing * 2^level`,
13
+ * exactly.
14
+ * - `grass_tile_column_position`: the frame's `(x, z)` of a column's centre. `tile` is in tiles of the
15
+ * level, `column` in `[0, GRASS_TILE_COLUMNS)` on each axis, `spacing` the level's.
16
+ * - `grass_tile_of_position`: the tile of a level whose square holds the frame's `(x, z)`; a point on an
17
+ * edge belongs to the tile on its far side.
18
+ * - `grass_slot_texel`: the atlas texel of a column of a slot. The atlas is a `GPUTileAtlas2D`, whose
19
+ * tiles run in rows as wide as the texture: `atlas_width` is `textureDimensions(atlas).x`.
20
+ *
21
+ * @type {CodeChunk}
22
+ */
23
+ export const chunk_grass_tile: CodeChunk;
24
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
25
+ //# sourceMappingURL=chunk_grass_tile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_grass_tile.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/surface/chunk_grass_tile.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,+BAFU,SAAS,CA2BjB;0BAnDwB,oCAAoC"}
@@ -0,0 +1,52 @@
1
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
+ import { chunk_index_to_grid2d } from "../../shader/chunk/grid/chunk_index_to_grid2d.js";
3
+ import { GRASS_TILE_COLUMNS } from "./GRASS_SURFACE.js";
4
+
5
+ /**
6
+ * Where the columns of a grass surface's tiles are: in the surface's frame, and in the surfel atlas.
7
+ * `GRASS_SURFACE.js` says what a level, a tile and a slot are.
8
+ *
9
+ * ```wgsl
10
+ * fn grass_level_spacing(finest_spacing: f32, level: u32) -> f32
11
+ * fn grass_tile_column_position(tile: vec2<i32>, column: vec2<u32>, spacing: f32) -> vec2<f32>
12
+ * fn grass_tile_of_position(position: vec2<f32>, spacing: f32) -> vec2<i32>
13
+ * fn grass_slot_texel(slot: u32, column: vec2<u32>, atlas_width: u32) -> vec2<u32>
14
+ * ```
15
+ *
16
+ * - `grass_level_spacing`: the distance between neighbouring columns of a level, `finest_spacing * 2^level`,
17
+ * exactly.
18
+ * - `grass_tile_column_position`: the frame's `(x, z)` of a column's centre. `tile` is in tiles of the
19
+ * level, `column` in `[0, GRASS_TILE_COLUMNS)` on each axis, `spacing` the level's.
20
+ * - `grass_tile_of_position`: the tile of a level whose square holds the frame's `(x, z)`; a point on an
21
+ * edge belongs to the tile on its far side.
22
+ * - `grass_slot_texel`: the atlas texel of a column of a slot. The atlas is a `GPUTileAtlas2D`, whose
23
+ * tiles run in rows as wide as the texture: `atlas_width` is `textureDimensions(atlas).x`.
24
+ *
25
+ * @type {CodeChunk}
26
+ */
27
+ export const chunk_grass_tile = CodeChunk.from(
28
+ //language=WGSL
29
+ `
30
+ const GRASS_TILE_COLUMNS: u32 = ${GRASS_TILE_COLUMNS}u;
31
+
32
+ fn grass_level_spacing(finest_spacing: f32, level: u32) -> f32 {
33
+ return ldexp(finest_spacing, i32(level));
34
+ }
35
+
36
+ fn grass_tile_column_position(tile: vec2<i32>, column: vec2<u32>, spacing: f32) -> vec2<f32> {
37
+ let lattice = tile * i32(GRASS_TILE_COLUMNS) + vec2<i32>(column);
38
+
39
+ return (vec2<f32>(lattice) + 0.5) * spacing;
40
+ }
41
+
42
+ fn grass_tile_of_position(position: vec2<f32>, spacing: f32) -> vec2<i32> {
43
+ return vec2<i32>(floor(position / (spacing * f32(GRASS_TILE_COLUMNS))));
44
+ }
45
+
46
+ fn grass_slot_texel(slot: u32, column: vec2<u32>, atlas_width: u32) -> vec2<u32> {
47
+ return index_to_grid2d(slot, atlas_width / GRASS_TILE_COLUMNS) * GRASS_TILE_COLUMNS + column;
48
+ }
49
+ `, [
50
+ chunk_index_to_grid2d,
51
+ ]
52
+ );
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Threads in a workgroup of {@link shader_grass_directory_fill}.
3
+ *
4
+ * @type {number}
5
+ */
6
+ export const GRASS_DIRECTORY_FILL_WORKGROUP_SIZE: number;
7
+ /**
8
+ * Lists every slot the pool has taken in an empty directory, a thread a slot: the directory made again,
9
+ * for a table that has grown, or one whose removed records are to be cleared out.
10
+ *
11
+ * `grass_directory` holds no record on entry: its count zero, its table's size set, its records empty. A
12
+ * slot that is pending, baked or stale is listed under its layer's key. One the table has no room for
13
+ * within the key's probes becomes an orphan, as one the asks could not list does, and the next retire
14
+ * frees it.
15
+ *
16
+ * No find or removal shares the dispatch. Dispatch
17
+ * `ceil(slot_capacity / GRASS_DIRECTORY_FILL_WORKGROUP_SIZE)` groups.
18
+ *
19
+ * @type {ComputeShader}
20
+ */
21
+ export const shader_grass_directory_fill: ComputeShader;
22
+ import { ComputeShader } from "../../shader/ComputeShader.js";
23
+ //# sourceMappingURL=shader_grass_directory_fill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shader_grass_directory_fill.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/surface/shader_grass_directory_fill.js"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,kDAFU,MAAM,CAEsC;AAWtD;;;;;;;;;;;;;GAaG;AACH,0CAFU,aAAa,CA0CpB;8BArF2B,+BAA+B"}
@@ -0,0 +1,87 @@
1
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
+ import { ComputeShader } from "../../shader/ComputeShader.js";
3
+ import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
4
+ import { u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
5
+ import { chunk_grass_directory } from "./chunk_grass_directory.js";
6
+ import {
7
+ GRASS_SLOT_LEVEL_LAYER,
8
+ GRASS_SLOT_STATE,
9
+ GRASS_SLOT_STATE_FREE,
10
+ GRASS_SLOT_STATE_ORPHAN,
11
+ GRASS_SLOT_SURFACE,
12
+ GRASS_SLOT_TILE_X,
13
+ GRASS_SLOT_TILE_Z
14
+ } from "./GRASS_SURFACE.js";
15
+ import { GRASS_DIRECTORY_RESOURCE, GRASS_POOL_RESOURCE } from "./GRASS_SURFACE_VIEW.js";
16
+
17
+ /**
18
+ * Threads in a workgroup of {@link shader_grass_directory_fill}.
19
+ *
20
+ * @type {number}
21
+ */
22
+ export const GRASS_DIRECTORY_FILL_WORKGROUP_SIZE = 64;
23
+
24
+ const resources = new ShaderResourceSetDescriptor();
25
+
26
+ // slots in the pool
27
+ resources.setImmediate("slot_capacity", u32);
28
+
29
+ resources.createGroup()
30
+ .add(GRASS_POOL_RESOURCE)
31
+ .add(GRASS_DIRECTORY_RESOURCE);
32
+
33
+ /**
34
+ * Lists every slot the pool has taken in an empty directory, a thread a slot: the directory made again,
35
+ * for a table that has grown, or one whose removed records are to be cleared out.
36
+ *
37
+ * `grass_directory` holds no record on entry: its count zero, its table's size set, its records empty. A
38
+ * slot that is pending, baked or stale is listed under its layer's key. One the table has no room for
39
+ * within the key's probes becomes an orphan, as one the asks could not list does, and the next retire
40
+ * frees it.
41
+ *
42
+ * No find or removal shares the dispatch. Dispatch
43
+ * `ceil(slot_capacity / GRASS_DIRECTORY_FILL_WORKGROUP_SIZE)` groups.
44
+ *
45
+ * @type {ComputeShader}
46
+ */
47
+ export const shader_grass_directory_fill = ComputeShader.from({
48
+ label: "Grass Directory Fill",
49
+ resources,
50
+ body: CodeChunk.from(
51
+ //language=WGSL
52
+ `
53
+ @compute @workgroup_size(${GRASS_DIRECTORY_FILL_WORKGROUP_SIZE})
54
+ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
55
+ let slot = id.x;
56
+
57
+ if (slot >= slot_capacity) {
58
+ return;
59
+ }
60
+
61
+ let record = grass_slot_record(slot);
62
+ let state = atomicLoad(&grass_pool[record + ${GRASS_SLOT_STATE}u]);
63
+
64
+ if (state == ${GRASS_SLOT_STATE_FREE}u || state == ${GRASS_SLOT_STATE_ORPHAN}u) {
65
+ return;
66
+ }
67
+
68
+ let tile = vec2<i32>(
69
+ bitcast<i32>(atomicLoad(&grass_pool[record + ${GRASS_SLOT_TILE_X}u])),
70
+ bitcast<i32>(atomicLoad(&grass_pool[record + ${GRASS_SLOT_TILE_Z}u])),
71
+ );
72
+
73
+ let listed = grass_directory_insert(
74
+ atomicLoad(&grass_pool[record + ${GRASS_SLOT_SURFACE}u]),
75
+ atomicLoad(&grass_pool[record + ${GRASS_SLOT_LEVEL_LAYER}u]),
76
+ tile,
77
+ slot,
78
+ );
79
+
80
+ if (!listed) {
81
+ atomicStore(&grass_pool[record + ${GRASS_SLOT_STATE}u], ${GRASS_SLOT_STATE_ORPHAN}u);
82
+ }
83
+ }
84
+ `, [
85
+ chunk_grass_directory,
86
+ ]),
87
+ });
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The scene database's `mesh_ground_covers` table.
3
+ */
4
+ export const MESH_GROUND_COVERS_TABLE: import("../../buffer/table/GPUTypedTableDescriptor.js").GPUTypedTableDescriptor;
5
+ /**
6
+ * The bake's immediate.
7
+ *
8
+ * - `finest_spacing`: the distance between neighbouring columns of level 0, in world units.
9
+ *
10
+ * @type {WebGPUStruct}
11
+ */
12
+ export const GRASS_SURFACE_BAKE_SETTINGS: WebGPUStruct;
13
+ /**
14
+ * Bakes one layer of one tile of a grass surface a workgroup: a thread a column, which walks down the
15
+ * column through the surface's members and writes the surfel of the layer's ground, or none.
16
+ *
17
+ * `grass_jobs` lists the slots to bake. Workgroup `j` of the folded dispatch (`folded_workgroup_index`)
18
+ * bakes slot `grass_jobs.elements[j]`; a workgroup past `grass_jobs.count`, or whose place holds
19
+ * `GRASS_SLOT_NONE`, does nothing. The slot's record, in the pool's arena `grass_pool`, names its surface,
20
+ * level, layer and tile (`GRASS_SURFACE.js`).
21
+ *
22
+ * **The column.** A ray from above the scene to below it, along the up axis of the surface's frame
23
+ * (`grass_surface_frame`), through the column's centre. It crosses at most `GRASS_COLUMN_CROSSINGS` faces, nearest first, each found by
24
+ * `ray_query_nearest_among`: only instances whose `mesh_ground_covers` record names the surface are
25
+ * entered, each as the geometry its record names. `grass_column_cross` decides which crossings are ground.
26
+ *
27
+ * **What a thread writes.** Its column's texel of the slot: the surfel of the `layer`-th ground from the top,
28
+ * or zeros when the column has no such ground. And into the slot's record, shared with every thread of the
29
+ * workgroup: the most ground any column met (`GRASS_SLOT_LAYER_COUNT`, a maximum) and how many columns wrote a
30
+ * surfel (`GRASS_SLOT_SURFEL_COUNT`, a sum). Both words must be zero when the workgroup starts. One thread
31
+ * marks the record baked and counts the bake in the pool's `GRASS_POOL_BAKED`; a pass that reads the slot's
32
+ * surfels comes after the bake's.
33
+ *
34
+ * **A surfel.** Height along the frame's up axis and the face's normal, both in the frame; the member's
35
+ * `meshes` row; the open air over it; and its painted density, the red of the member's vertex colour at the
36
+ * hit.
37
+ *
38
+ * @type {ComputeShader}
39
+ */
40
+ export const shader_grass_surface_bake: ComputeShader;
41
+ import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
42
+ import { ComputeShader } from "../../shader/ComputeShader.js";
43
+ //# sourceMappingURL=shader_grass_surface_bake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shader_grass_surface_bake.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/surface/shader_grass_surface_bake.js"],"names":[],"mappings":"AAyCA;;GAEG;AACH,uHAAsF;AAEtF;;;;;;GAMG;AACH,0CAFU,YAAY,CAIS;AAa/B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wCAFU,aAAa,CA2KpB;6BAxP0B,mCAAmC;8BAHlC,+BAA+B"}
@@ -0,0 +1,265 @@
1
+ import { sr_create_group_RTX } from "../../geometry/sr_create_group_RTX.js";
2
+ import { COLLECTION_U32_STRUCT_READ } from "../../gpu_primitive/COLLECTION_U32_STRUCT_READ.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 { BVH_NULL_NODE_DEFINITION } from "../../shader/chunk/bvh/BVH_NULL_NODE_DEFINITION.js";
7
+ import { chunk_geometry_read_triangle_vertices } from "../../shader/chunk/geometry/format/chunk_geometry_read_triangle_vertices.js";
8
+ import { chunk_compute_normal_matrix_from_m4 } from "../../shader/chunk/geometry/mat4/chunk_compute_normal_matrix_from_m4.js";
9
+ import { chunk_offset_ray } from "../../shader/chunk/geometry/ray/chunk_offset_ray.js";
10
+ import { chunk_ray_query_nearest_among } from "../../shader/chunk/geometry/ray/chunk_ray_query_nearest_among.js";
11
+ import { RAY_STRUCT } from "../../shader/chunk/geometry/ray/RAY_STRUCT.js";
12
+ import { chunk_folded_workgroup_index } from "../../shader/chunk/grid/chunk_folded_workgroup_index.js";
13
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
14
+ import { ComputeShader } from "../../shader/ComputeShader.js";
15
+ import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
16
+ import { f32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
17
+ import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
18
+ import { chunk_grass_column_cross } from "./chunk_grass_column_cross.js";
19
+ import { chunk_grass_slot } from "./chunk_grass_slot.js";
20
+ import { chunk_grass_surface_frame } from "./chunk_grass_surface_frame.js";
21
+ import { chunk_grass_surfel, GRASS_SURFEL_FORMAT } from "./chunk_grass_surfel.js";
22
+ import { chunk_grass_tile } from "./chunk_grass_tile.js";
23
+ import {
24
+ GRASS_COLUMN_CROSSINGS,
25
+ GRASS_POOL_BAKED,
26
+ GRASS_SLOT_HEIGHT_MAX,
27
+ GRASS_SLOT_HEIGHT_MIN,
28
+ GRASS_SLOT_LAYER_COUNT,
29
+ GRASS_SLOT_LEVEL_LAYER,
30
+ GRASS_SLOT_NORMAL_SPREAD,
31
+ GRASS_SLOT_STATE,
32
+ GRASS_SLOT_STATE_BAKED,
33
+ GRASS_SLOT_SURFACE,
34
+ GRASS_SLOT_SURFEL_COUNT,
35
+ GRASS_SLOT_TILE_X,
36
+ GRASS_SLOT_TILE_Z,
37
+ GRASS_TILE_COLUMNS,
38
+ GRASS_TILE_SURFELS
39
+ } from "./GRASS_SURFACE.js";
40
+ import { GRASS_POOL_RESOURCE } from "./GRASS_SURFACE_VIEW.js";
41
+
42
+ /**
43
+ * The scene database's `mesh_ground_covers` table.
44
+ */
45
+ export const MESH_GROUND_COVERS_TABLE = SCENE_DATABASE_SPEC.get('mesh_ground_covers');
46
+
47
+ /**
48
+ * The bake's immediate.
49
+ *
50
+ * - `finest_spacing`: the distance between neighbouring columns of level 0, in world units.
51
+ *
52
+ * @type {WebGPUStruct}
53
+ */
54
+ export const GRASS_SURFACE_BAKE_SETTINGS = WebGPUStruct.from({
55
+ finest_spacing: f32,
56
+ }, "GrassSurfaceBakeSettings");
57
+
58
+ const resources = new ShaderResourceSetDescriptor();
59
+
60
+ resources.setImmediate("settings", GRASS_SURFACE_BAKE_SETTINGS);
61
+
62
+ sr_create_group_RTX(resources);
63
+
64
+ resources.createGroup()
65
+ .addStorageBuffer("grass_jobs", COLLECTION_U32_STRUCT_READ)
66
+ .add(GRASS_POOL_RESOURCE)
67
+ .addStorageTexture("grass_surfels", GRASS_SURFEL_FORMAT, "2d", "write-only");
68
+
69
+ /**
70
+ * Bakes one layer of one tile of a grass surface a workgroup: a thread a column, which walks down the
71
+ * column through the surface's members and writes the surfel of the layer's ground, or none.
72
+ *
73
+ * `grass_jobs` lists the slots to bake. Workgroup `j` of the folded dispatch (`folded_workgroup_index`)
74
+ * bakes slot `grass_jobs.elements[j]`; a workgroup past `grass_jobs.count`, or whose place holds
75
+ * `GRASS_SLOT_NONE`, does nothing. The slot's record, in the pool's arena `grass_pool`, names its surface,
76
+ * level, layer and tile (`GRASS_SURFACE.js`).
77
+ *
78
+ * **The column.** A ray from above the scene to below it, along the up axis of the surface's frame
79
+ * (`grass_surface_frame`), through the column's centre. It crosses at most `GRASS_COLUMN_CROSSINGS` faces, nearest first, each found by
80
+ * `ray_query_nearest_among`: only instances whose `mesh_ground_covers` record names the surface are
81
+ * entered, each as the geometry its record names. `grass_column_cross` decides which crossings are ground.
82
+ *
83
+ * **What a thread writes.** Its column's texel of the slot: the surfel of the `layer`-th ground from the top,
84
+ * or zeros when the column has no such ground. And into the slot's record, shared with every thread of the
85
+ * workgroup: the most ground any column met (`GRASS_SLOT_LAYER_COUNT`, a maximum) and how many columns wrote a
86
+ * surfel (`GRASS_SLOT_SURFEL_COUNT`, a sum). Both words must be zero when the workgroup starts. One thread
87
+ * marks the record baked and counts the bake in the pool's `GRASS_POOL_BAKED`; a pass that reads the slot's
88
+ * surfels comes after the bake's.
89
+ *
90
+ * **A surfel.** Height along the frame's up axis and the face's normal, both in the frame; the member's
91
+ * `meshes` row; the open air over it; and its painted density, the red of the member's vertex colour at the
92
+ * hit.
93
+ *
94
+ * @type {ComputeShader}
95
+ */
96
+ export const shader_grass_surface_bake = ComputeShader.from({
97
+ label: "Grass Surface Bake",
98
+ resources,
99
+ body: CodeChunk.from(
100
+ //language=WGSL
101
+ `
102
+ // the surface the invocation's column belongs to, for the query's hook
103
+ var<private> grass_bake_surface: u32;
104
+
105
+ fn ray_query_among_geometry(mesh: u32) -> u32 {
106
+ let cover = ${MESH_GROUND_COVERS_TABLE.marshalling_method_read}(&scene_database, mesh);
107
+
108
+ if ((cover.flags & ${MESH_GROUND_COVER_FLAG_MEMBER}u) == 0u || cover.surface != grass_bake_surface) {
109
+ return RAY_QUERY_AMONG_PASS;
110
+ }
111
+
112
+ return cover.geometry;
113
+ }
114
+
115
+ @compute @workgroup_size(${GRASS_TILE_SURFELS})
116
+ fn main(
117
+ @builtin(workgroup_id) workgroup_id: vec3<u32>,
118
+ @builtin(local_invocation_index) lane: u32,
119
+ ) {
120
+ let job = folded_workgroup_index(workgroup_id);
121
+
122
+ if (job >= grass_jobs.count) {
123
+ return;
124
+ }
125
+
126
+ let slot = grass_jobs.elements[job];
127
+
128
+ if (slot == GRASS_SLOT_NONE) {
129
+ return;
130
+ }
131
+
132
+ let record = grass_slot_record(slot);
133
+
134
+ let surface = atomicLoad(&grass_pool[record + ${GRASS_SLOT_SURFACE}u]);
135
+ let level_layer = atomicLoad(&grass_pool[record + ${GRASS_SLOT_LEVEL_LAYER}u]);
136
+ let level = level_layer & 0xFFu;
137
+ let layer = (level_layer >> 8u) & 0xFFu;
138
+ let tile = vec2<i32>(
139
+ bitcast<i32>(atomicLoad(&grass_pool[record + ${GRASS_SLOT_TILE_X}u])),
140
+ bitcast<i32>(atomicLoad(&grass_pool[record + ${GRASS_SLOT_TILE_Z}u])),
141
+ );
142
+
143
+ let column = vec2<u32>(lane % ${GRASS_TILE_COLUMNS}u, lane / ${GRASS_TILE_COLUMNS}u);
144
+ let spacing = grass_level_spacing(settings.finest_spacing, level);
145
+ let place = grass_tile_column_position(tile, column, spacing);
146
+
147
+ var texel = vec4<u32>(0u);
148
+ var kept = 0u;
149
+
150
+ // the surfel's height, and how far its normal is from the frame's up axis
151
+ var found = vec2<f32>(0.0);
152
+
153
+ if (tlas.root != BVH_NULL_NODE) {
154
+ grass_bake_surface = surface;
155
+
156
+ let frame = grass_surface_frame(${TRANSFORMS_TABLE.marshalling_method_read_field('global')}(&scene_database, surface));
157
+ let up = frame[1].xyz;
158
+
159
+ // the scene's reach along the frame's up axis: its box's centre, and the box's half extent along it
160
+ let bounds = tlas.nodes[tlas.root].bounds;
161
+ let low = vec3<f32>(bounds[0], bounds[1], bounds[2]);
162
+ let high = vec3<f32>(bounds[3], bounds[4], bounds[5]);
163
+ let half_reach = dot(0.5 * (high - low), abs(up));
164
+ let top = dot(0.5 * (high + low), up) + half_reach;
165
+
166
+ // the walk starts clear of the scene's top, so its highest face is a crossing like any other
167
+ let margin = max(half_reach, 1.0) / 1024.0;
168
+
169
+ let foot = (frame * vec4<f32>(place.x, 0.0, place.y, 1.0)).xyz;
170
+
171
+ var ray: ${RAY_STRUCT.wgsl_ref};
172
+ ray.direction = -up;
173
+ ray.origin = foot + up * (top - dot(foot, up) + margin);
174
+ ray.tmax = 2.0 * (half_reach + margin);
175
+
176
+ var walk = grass_column_begin();
177
+
178
+ for (var i = 0u; i < ${GRASS_COLUMN_CROSSINGS}u; i++) {
179
+ let hit = ray_query_nearest_among(ray);
180
+
181
+ if (hit.t < 0.0) {
182
+ break;
183
+ }
184
+
185
+ let position = ray.origin + ray.direction * hit.t;
186
+
187
+ let member = ${TRANSFORMS_TABLE.marshalling_method_read_field('global')}(&scene_database, hit.instance);
188
+ let triangle = geometry_read_triangle_vertices(geometries[hit.geometry], hit.triangle);
189
+
190
+ let face = cross(triangle.b.position - triangle.a.position, triangle.c.position - triangle.a.position);
191
+ let normal = normalize(compute_normal_matrix_from_m4(member) * face);
192
+
193
+ let height = grass_world_to_frame(frame, position).y;
194
+
195
+ let crossing = grass_column_cross(walk, height, dot(normal, up) > 0.0);
196
+
197
+ walk = crossing.walk;
198
+
199
+ if (crossing.keep) {
200
+ if (kept == layer) {
201
+ let lambda = vec3<f32>(1.0 - hit.barycentrics.x - hit.barycentrics.y, hit.barycentrics.x, hit.barycentrics.y);
202
+
203
+ var surfel: GrassSurfel;
204
+ surfel.height = height;
205
+ surfel.normal = grass_world_direction_to_frame(frame, normal);
206
+ surfel.member = hit.instance;
207
+ surfel.clear_height = crossing.clear_height;
208
+ surfel.density = dot(lambda, vec3<f32>(triangle.a.color.r, triangle.b.color.r, triangle.c.color.r));
209
+
210
+ texel = grass_surfel_pack(surfel);
211
+
212
+ found = vec2<f32>(height, length(surfel.normal - vec3<f32>(0.0, 1.0, 0.0)));
213
+ }
214
+
215
+ kept++;
216
+ }
217
+
218
+ // on past the face
219
+ ray.origin = offset_ray(position, ray.direction);
220
+ ray.tmax -= hit.t;
221
+
222
+ if (ray.tmax <= 0.0) {
223
+ break;
224
+ }
225
+ }
226
+ }
227
+
228
+ textureStore(grass_surfels, grass_slot_texel(slot, column, textureDimensions(grass_surfels).x), texel);
229
+
230
+ atomicMax(&grass_pool[record + ${GRASS_SLOT_LAYER_COUNT}u], kept);
231
+
232
+ if (grass_surfel_exists(texel)) {
233
+ atomicAdd(&grass_pool[record + ${GRASS_SLOT_SURFEL_COUNT}u], 1u);
234
+
235
+ let key = grass_height_key(found.x);
236
+
237
+ atomicMin(&grass_pool[record + ${GRASS_SLOT_HEIGHT_MIN}u], key);
238
+ atomicMax(&grass_pool[record + ${GRASS_SLOT_HEIGHT_MAX}u], key);
239
+
240
+ // the bits of a float at or above zero order as it does
241
+ atomicMax(&grass_pool[record + ${GRASS_SLOT_NORMAL_SPREAD}u], bitcast<u32>(found.y));
242
+ }
243
+
244
+ if (lane == 0u) {
245
+ atomicStore(&grass_pool[record + ${GRASS_SLOT_STATE}u], ${GRASS_SLOT_STATE_BAKED}u);
246
+ atomicAdd(&grass_pool[${GRASS_POOL_BAKED}u], 1u);
247
+ }
248
+ }
249
+ `, [
250
+ BVH_NULL_NODE_DEFINITION,
251
+ RAY_STRUCT.declaration_chunk,
252
+ chunk_folded_workgroup_index,
253
+ chunk_compute_normal_matrix_from_m4,
254
+ chunk_geometry_read_triangle_vertices,
255
+ chunk_offset_ray,
256
+ chunk_ray_query_nearest_among,
257
+ chunk_grass_column_cross,
258
+ chunk_grass_slot,
259
+ chunk_grass_surface_frame,
260
+ chunk_grass_surfel,
261
+ chunk_grass_tile,
262
+ MESH_GROUND_COVERS_TABLE.chunk_read,
263
+ TRANSFORMS_TABLE.chunk_read_field('global'),
264
+ ]),
265
+ });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * One thread, between the asks for a frame's tiles ({@link shader_grass_surface_want}) and their bake
3
+ * ({@link shader_grass_surface_bake}), which runs a workgroup a place of the bake list.
4
+ *
5
+ * The asks leave the list's count at how many places were asked for, which can pass the places there are.
6
+ * This writes the count the bake reads, the places taken, and the bake's folded dispatch
7
+ * (`folded_dispatch`) of that many workgroups. A pass never writes the command it is dispatched through.
8
+ *
9
+ * @type {ComputeShader}
10
+ */
11
+ export const shader_grass_surface_bake_command: ComputeShader;
12
+ import { ComputeShader } from "../../shader/ComputeShader.js";
13
+ //# sourceMappingURL=shader_grass_surface_bake_command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shader_grass_surface_bake_command.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/surface/shader_grass_surface_bake_command.js"],"names":[],"mappings":"AAiBA;;;;;;;;;GASG;AACH,gDAFU,aAAa,CAuBpB;8BA5C2B,+BAA+B"}
@@ -0,0 +1,49 @@
1
+ import { COLLECTION_U32_STRUCT_WRITE } from "../../gpu_primitive/COLLECTION_U32_STRUCT_WRITE.js";
2
+ import { chunk_folded_dispatch } from "../../gpu_primitive/indirect/chunk_folded_dispatch.js";
3
+ import { STRUCT_DISPATCH_COMPUTE_COMMAND } from "../../gpu_primitive/indirect/STRUCT_DISPATCH_COMPUTE_COMMAND.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
+
9
+ const resources = new ShaderResourceSetDescriptor();
10
+
11
+ // how many places the frame's bake list has
12
+ resources.setImmediate("job_capacity", u32);
13
+
14
+ resources.createGroup()
15
+ .addStorageBuffer("grass_jobs", COLLECTION_U32_STRUCT_WRITE, true)
16
+ .addStorageBuffer("command", STRUCT_DISPATCH_COMPUTE_COMMAND, true);
17
+
18
+ /**
19
+ * One thread, between the asks for a frame's tiles ({@link shader_grass_surface_want}) and their bake
20
+ * ({@link shader_grass_surface_bake}), which runs a workgroup a place of the bake list.
21
+ *
22
+ * The asks leave the list's count at how many places were asked for, which can pass the places there are.
23
+ * This writes the count the bake reads, the places taken, and the bake's folded dispatch
24
+ * (`folded_dispatch`) of that many workgroups. A pass never writes the command it is dispatched through.
25
+ *
26
+ * @type {ComputeShader}
27
+ */
28
+ export const shader_grass_surface_bake_command = ComputeShader.from({
29
+ label: "Grass Surface Bake Command",
30
+ resources,
31
+ body: CodeChunk.from(
32
+ //language=WGSL
33
+ `
34
+ @compute @workgroup_size(1)
35
+ fn main() {
36
+ let taken = min(atomicLoad(&grass_jobs.count), job_capacity);
37
+
38
+ atomicStore(&grass_jobs.count, taken);
39
+
40
+ let folded = folded_dispatch(taken);
41
+
42
+ command.workgroupCountX = folded.x;
43
+ command.workgroupCountY = folded.y;
44
+ command.workgroupCountZ = folded.z;
45
+ }
46
+ `, [
47
+ chunk_folded_dispatch,
48
+ ]),
49
+ });