@woosh/meep-engine 3.64.1 → 3.65.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 (324) 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/shade/device/shader/ShaderModuleCompiler.d.ts +2 -0
  58. package/src/shade/device/shader/ShaderModuleCompiler.d.ts.map +1 -1
  59. package/src/shade/device/shader/ShaderModuleCompiler.js +25 -2
  60. package/src/shade/playground/grass_surfaces/index.html +75 -0
  61. package/src/shade/playground/grass_surfaces/main.d.ts +2 -0
  62. package/src/shade/playground/grass_surfaces/main.d.ts.map +1 -0
  63. package/src/shade/playground/grass_surfaces/main.js +593 -0
  64. package/src/shade/playground/grass_surfaces/read_grass_surfaces.d.ts +62 -0
  65. package/src/shade/playground/grass_surfaces/read_grass_surfaces.d.ts.map +1 -0
  66. package/src/shade/playground/grass_surfaces/read_grass_surfaces.js +188 -0
  67. package/src/shade/playground/probe_clipmap_box/README.md +5 -1
  68. package/src/shade/playground/probe_clipmap_box/index.html +12 -0
  69. package/src/shade/playground/probe_clipmap_box/main.d.ts.map +1 -1
  70. package/src/shade/playground/probe_clipmap_box/main.js +15 -0
  71. package/src/shade/playground/probe_clipmap_box/scene.d.ts +8 -1
  72. package/src/shade/playground/probe_clipmap_box/scene.d.ts.map +1 -1
  73. package/src/shade/playground/probe_clipmap_box/scene.js +74 -6
  74. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  75. package/src/shade/renderer/Renderer.js +47 -43
  76. package/src/shade/renderer/extension/ViewTextures.d.ts +12 -5
  77. package/src/shade/renderer/extension/ViewTextures.d.ts.map +1 -1
  78. package/src/shade/renderer/extension/ViewTextures.js +19 -5
  79. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +3 -1
  80. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts.map +1 -1
  81. package/src/shade/renderer/fluid/GPUFluidCascadeStack.js +6 -1
  82. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -0
  83. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts.map +1 -1
  84. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.js +10 -0
  85. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts +7 -1
  86. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts.map +1 -1
  87. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.js +46 -15
  88. package/src/shade/renderer/geometry/sdf/bundle/ModelCacheBundle.d.ts +3 -2
  89. package/src/shade/renderer/geometry/sdf/bundle/ModelCacheBundle.d.ts.map +1 -1
  90. package/src/shade/renderer/geometry/sdf/bundle/ModelCacheBundle.js +3 -2
  91. package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_sort_morton.d.ts +22 -0
  92. package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_sort_morton.d.ts.map +1 -0
  93. package/src/shade/renderer/geometry/sdf/bundle/model_cache_bundle_sort_morton.js +247 -0
  94. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +50 -0
  95. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts.map +1 -1
  96. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.js +101 -0
  97. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts +2 -1
  98. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts.map +1 -1
  99. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.js +2 -1
  100. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts +8 -0
  101. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts.map +1 -1
  102. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.js +12 -0
  103. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +12 -6
  104. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
  105. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +35 -29
  106. package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_clipmap.d.ts.map +1 -1
  107. package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_clipmap.js +4 -2
  108. package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_material.d.ts.map +1 -1
  109. package/src/shade/renderer/global_illumination/probe_clipmap/debug/graph_probe_clipmap_debug_brick_material.js +6 -4
  110. package/src/shade/renderer/global_illumination/probe_clipmap/material/GPUBrickMaterial.d.ts.map +1 -1
  111. package/src/shade/renderer/global_illumination/probe_clipmap/material/GPUBrickMaterial.js +2 -1
  112. package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material.d.ts +6 -5
  113. package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material.d.ts.map +1 -1
  114. package/src/shade/renderer/global_illumination/probe_clipmap/material/chunk_brick_material.js +15 -14
  115. package/src/shade/renderer/global_illumination/probe_clipmap/material/shader_brick_material_gather.d.ts.map +1 -1
  116. package/src/shade/renderer/global_illumination/probe_clipmap/material/shader_brick_material_gather.js +4 -2
  117. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts +19 -2
  118. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts.map +1 -1
  119. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.js +128 -10
  120. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts +19 -1
  121. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts.map +1 -1
  122. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.js +27 -2
  123. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.d.ts +19 -11
  124. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.d.ts.map +1 -1
  125. package/src/shade/renderer/global_illumination/probe_clipmap/probe/ProbeClipmapScreenWants.js +35 -11
  126. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts.map +1 -1
  127. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.js +3 -1
  128. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_box_cages.d.ts +40 -0
  129. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_box_cages.d.ts.map +1 -0
  130. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_box_cages.js +174 -0
  131. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_material.d.ts +4 -4
  132. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_material.js +10 -10
  133. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_parallax.d.ts +31 -0
  134. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_parallax.d.ts.map +1 -0
  135. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_parallax.js +54 -0
  136. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.d.ts +8 -4
  137. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.d.ts.map +1 -1
  138. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.js +10 -21
  139. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.d.ts +7 -2
  140. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.d.ts.map +1 -1
  141. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_want.js +33 -29
  142. package/src/shade/renderer/global_illumination/probe_clipmap/probe/graph_probe_clipmap_want_meshlets.d.ts +28 -0
  143. package/src/shade/renderer/global_illumination/probe_clipmap/probe/graph_probe_clipmap_want_meshlets.d.ts.map +1 -0
  144. package/src/shade/renderer/global_illumination/probe_clipmap/probe/graph_probe_clipmap_want_meshlets.js +138 -0
  145. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts +13 -9
  146. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts.map +1 -1
  147. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.js +18 -11
  148. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.js +1 -1
  149. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.d.ts.map +1 -1
  150. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.js +4 -2
  151. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_retire.d.ts.map +1 -1
  152. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_retire.js +2 -3
  153. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.d.ts +5 -3
  154. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.d.ts.map +1 -1
  155. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.js +15 -30
  156. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.js +1 -1
  157. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts.map +1 -1
  158. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.js +4 -2
  159. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.d.ts +11 -0
  160. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.d.ts.map +1 -1
  161. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want.js +29 -2
  162. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_late.d.ts +40 -0
  163. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_late.d.ts.map +1 -0
  164. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_late.js +126 -0
  165. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_meshlets.d.ts +36 -0
  166. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_meshlets.d.ts.map +1 -0
  167. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_meshlets.js +221 -0
  168. package/src/shade/renderer/gpu_primitive/age_eviction/chunk_age_eviction.d.ts +40 -0
  169. package/src/shade/renderer/gpu_primitive/age_eviction/chunk_age_eviction.d.ts.map +1 -0
  170. package/src/shade/renderer/gpu_primitive/age_eviction/chunk_age_eviction.js +86 -0
  171. package/src/shade/renderer/grass/blade/GPUGrassBlades.d.ts +135 -0
  172. package/src/shade/renderer/grass/blade/GPUGrassBlades.d.ts.map +1 -0
  173. package/src/shade/renderer/grass/blade/GPUGrassBlades.js +676 -0
  174. package/src/shade/renderer/grass/blade/GRASS_BLADE.d.ts +145 -0
  175. package/src/shade/renderer/grass/blade/GRASS_BLADE.d.ts.map +1 -0
  176. package/src/shade/renderer/grass/blade/GRASS_BLADE.js +179 -0
  177. package/src/shade/renderer/grass/blade/chunk_grass_blade.d.ts +63 -0
  178. package/src/shade/renderer/grass/blade/chunk_grass_blade.d.ts.map +1 -0
  179. package/src/shade/renderer/grass/blade/chunk_grass_blade.js +244 -0
  180. package/src/shade/renderer/grass/blade/chunk_grass_blade_wind.d.ts +58 -0
  181. package/src/shade/renderer/grass/blade/chunk_grass_blade_wind.d.ts.map +1 -0
  182. package/src/shade/renderer/grass/blade/chunk_grass_blade_wind.js +174 -0
  183. package/src/shade/renderer/grass/blade/grass_blade_id_draw.d.ts +25 -0
  184. package/src/shade/renderer/grass/blade/grass_blade_id_draw.d.ts.map +1 -0
  185. package/src/shade/renderer/grass/blade/grass_blade_id_draw.js +133 -0
  186. package/src/shade/renderer/grass/blade/grass_blade_mechanics.d.ts +80 -0
  187. package/src/shade/renderer/grass/blade/grass_blade_mechanics.d.ts.map +1 -0
  188. package/src/shade/renderer/grass/blade/grass_blade_mechanics.js +92 -0
  189. package/src/shade/renderer/grass/blade/grass_blade_resolve.d.ts +29 -0
  190. package/src/shade/renderer/grass/blade/grass_blade_resolve.d.ts.map +1 -0
  191. package/src/shade/renderer/grass/blade/grass_blade_resolve.js +175 -0
  192. package/src/shade/renderer/grass/blade/shader_grass_blade_draw_args.d.ts +14 -0
  193. package/src/shade/renderer/grass/blade/shader_grass_blade_draw_args.d.ts.map +1 -0
  194. package/src/shade/renderer/grass/blade/shader_grass_blade_draw_args.js +45 -0
  195. package/src/shade/renderer/grass/blade/shader_grass_blade_expand.d.ts +61 -0
  196. package/src/shade/renderer/grass/blade/shader_grass_blade_expand.d.ts.map +1 -0
  197. package/src/shade/renderer/grass/blade/shader_grass_blade_expand.js +340 -0
  198. package/src/shade/renderer/grass/blade/shader_grass_cell_count.d.ts +46 -0
  199. package/src/shade/renderer/grass/blade/shader_grass_cell_count.d.ts.map +1 -0
  200. package/src/shade/renderer/grass/blade/shader_grass_cell_count.js +280 -0
  201. package/src/shade/renderer/grass/population/chunk_grass_population.d.ts +60 -0
  202. package/src/shade/renderer/grass/population/chunk_grass_population.d.ts.map +1 -0
  203. package/src/shade/renderer/grass/population/chunk_grass_population.js +171 -0
  204. package/src/shade/renderer/grass/press/GPUGrassPress.d.ts +99 -0
  205. package/src/shade/renderer/grass/press/GPUGrassPress.d.ts.map +1 -0
  206. package/src/shade/renderer/grass/press/GPUGrassPress.js +436 -0
  207. package/src/shade/renderer/grass/press/GRASS_PRESS.d.ts +179 -0
  208. package/src/shade/renderer/grass/press/GRASS_PRESS.d.ts.map +1 -0
  209. package/src/shade/renderer/grass/press/GRASS_PRESS.js +217 -0
  210. package/src/shade/renderer/grass/press/chunk_grass_press.d.ts +65 -0
  211. package/src/shade/renderer/grass/press/chunk_grass_press.d.ts.map +1 -0
  212. package/src/shade/renderer/grass/press/chunk_grass_press.js +296 -0
  213. package/src/shade/renderer/grass/press/shader_grass_press_mark.d.ts +31 -0
  214. package/src/shade/renderer/grass/press/shader_grass_press_mark.d.ts.map +1 -0
  215. package/src/shade/renderer/grass/press/shader_grass_press_mark.js +169 -0
  216. package/src/shade/renderer/grass/press/shader_grass_press_stamp.d.ts +27 -0
  217. package/src/shade/renderer/grass/press/shader_grass_press_stamp.d.ts.map +1 -0
  218. package/src/shade/renderer/grass/press/shader_grass_press_stamp.js +183 -0
  219. package/src/shade/renderer/grass/surface/GPUGrassSurfaces.d.ts +193 -0
  220. package/src/shade/renderer/grass/surface/GPUGrassSurfaces.d.ts.map +1 -0
  221. package/src/shade/renderer/grass/surface/GPUGrassSurfaces.js +1253 -0
  222. package/src/shade/renderer/grass/surface/GRASS_SURFACE.d.ts +211 -0
  223. package/src/shade/renderer/grass/surface/GRASS_SURFACE.d.ts.map +1 -0
  224. package/src/shade/renderer/grass/surface/GRASS_SURFACE.js +241 -0
  225. package/src/shade/renderer/grass/surface/GRASS_SURFACE_VIEW.d.ts +82 -0
  226. package/src/shade/renderer/grass/surface/GRASS_SURFACE_VIEW.d.ts.map +1 -0
  227. package/src/shade/renderer/grass/surface/GRASS_SURFACE_VIEW.js +111 -0
  228. package/src/shade/renderer/grass/surface/chunk_grass_column_cross.d.ts +39 -0
  229. package/src/shade/renderer/grass/surface/chunk_grass_column_cross.d.ts.map +1 -0
  230. package/src/shade/renderer/grass/surface/chunk_grass_column_cross.js +85 -0
  231. package/src/shade/renderer/grass/surface/chunk_grass_directory.d.ts +29 -0
  232. package/src/shade/renderer/grass/surface/chunk_grass_directory.d.ts.map +1 -0
  233. package/src/shade/renderer/grass/surface/chunk_grass_directory.js +112 -0
  234. package/src/shade/renderer/grass/surface/chunk_grass_slot.d.ts +27 -0
  235. package/src/shade/renderer/grass/surface/chunk_grass_slot.d.ts.map +1 -0
  236. package/src/shade/renderer/grass/surface/chunk_grass_slot.js +50 -0
  237. package/src/shade/renderer/grass/surface/chunk_grass_surface_frame.d.ts +21 -0
  238. package/src/shade/renderer/grass/surface/chunk_grass_surface_frame.d.ts.map +1 -0
  239. package/src/shade/renderer/grass/surface/chunk_grass_surface_frame.js +41 -0
  240. package/src/shade/renderer/grass/surface/chunk_grass_surface_window.d.ts +32 -0
  241. package/src/shade/renderer/grass/surface/chunk_grass_surface_window.d.ts.map +1 -0
  242. package/src/shade/renderer/grass/surface/chunk_grass_surface_window.js +136 -0
  243. package/src/shade/renderer/grass/surface/chunk_grass_surfel.d.ts +37 -0
  244. package/src/shade/renderer/grass/surface/chunk_grass_surfel.d.ts.map +1 -0
  245. package/src/shade/renderer/grass/surface/chunk_grass_surfel.js +85 -0
  246. package/src/shade/renderer/grass/surface/chunk_grass_tile.d.ts +25 -0
  247. package/src/shade/renderer/grass/surface/chunk_grass_tile.d.ts.map +1 -0
  248. package/src/shade/renderer/grass/surface/chunk_grass_tile.js +52 -0
  249. package/src/shade/renderer/grass/surface/shader_grass_directory_fill.d.ts +23 -0
  250. package/src/shade/renderer/grass/surface/shader_grass_directory_fill.d.ts.map +1 -0
  251. package/src/shade/renderer/grass/surface/shader_grass_directory_fill.js +87 -0
  252. package/src/shade/renderer/grass/surface/shader_grass_surface_bake.d.ts +43 -0
  253. package/src/shade/renderer/grass/surface/shader_grass_surface_bake.d.ts.map +1 -0
  254. package/src/shade/renderer/grass/surface/shader_grass_surface_bake.js +265 -0
  255. package/src/shade/renderer/grass/surface/shader_grass_surface_bake_command.d.ts +13 -0
  256. package/src/shade/renderer/grass/surface/shader_grass_surface_bake_command.d.ts.map +1 -0
  257. package/src/shade/renderer/grass/surface/shader_grass_surface_bake_command.js +49 -0
  258. package/src/shade/renderer/grass/surface/shader_grass_surface_invalidate.d.ts +62 -0
  259. package/src/shade/renderer/grass/surface/shader_grass_surface_invalidate.d.ts.map +1 -0
  260. package/src/shade/renderer/grass/surface/shader_grass_surface_invalidate.js +162 -0
  261. package/src/shade/renderer/grass/surface/shader_grass_surface_retire.d.ts +40 -0
  262. package/src/shade/renderer/grass/surface/shader_grass_surface_retire.d.ts.map +1 -0
  263. package/src/shade/renderer/grass/surface/shader_grass_surface_retire.js +155 -0
  264. package/src/shade/renderer/grass/surface/shader_grass_surface_schedule.d.ts +19 -0
  265. package/src/shade/renderer/grass/surface/shader_grass_surface_schedule.d.ts.map +1 -0
  266. package/src/shade/renderer/grass/surface/shader_grass_surface_schedule.js +58 -0
  267. package/src/shade/renderer/grass/surface/shader_grass_surface_want.d.ts +30 -0
  268. package/src/shade/renderer/grass/surface/shader_grass_surface_want.d.ts.map +1 -0
  269. package/src/shade/renderer/grass/surface/shader_grass_surface_want.js +251 -0
  270. package/src/shade/renderer/grass/surface/shader_grass_surface_window_count.d.ts +21 -0
  271. package/src/shade/renderer/grass/surface/shader_grass_surface_window_count.d.ts.map +1 -0
  272. package/src/shade/renderer/grass/surface/shader_grass_surface_window_count.js +75 -0
  273. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts.map +1 -1
  274. package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.js +4 -23
  275. package/src/shade/renderer/postprocess/velocity/view_velocity_matrices.d.ts +12 -0
  276. package/src/shade/renderer/postprocess/velocity/view_velocity_matrices.d.ts.map +1 -0
  277. package/src/shade/renderer/postprocess/velocity/view_velocity_matrices.js +29 -0
  278. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.d.ts.map +1 -1
  279. package/src/shade/renderer/rasterize/native/avboit/graph_rasterize_meshes_transparent_avboit.js +22 -0
  280. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  281. package/src/shade/renderer/scene/GPUSceneContext.js +3 -0
  282. package/src/shade/renderer/scene/GRASS_SURFACE_PARAMS_STRUCT.d.ts +27 -0
  283. package/src/shade/renderer/scene/GRASS_SURFACE_PARAMS_STRUCT.d.ts.map +1 -0
  284. package/src/shade/renderer/scene/GRASS_SURFACE_PARAMS_STRUCT.js +38 -0
  285. package/src/shade/renderer/scene/MESH_GROUND_COVER_STRUCT.d.ts +28 -0
  286. package/src/shade/renderer/scene/MESH_GROUND_COVER_STRUCT.d.ts.map +1 -0
  287. package/src/shade/renderer/scene/MESH_GROUND_COVER_STRUCT.js +58 -0
  288. package/src/shade/renderer/scene/SCENE_DATABASE_SPEC.d.ts.map +1 -1
  289. package/src/shade/renderer/scene/SCENE_DATABASE_SPEC.js +8 -0
  290. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.d.ts +37 -0
  291. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.d.ts.map +1 -0
  292. package/src/shade/renderer/shader/chunk/geometry/ray/chunk_ray_query_nearest_among.js +148 -0
  293. package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_line_span.d.ts +20 -0
  294. package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_line_span.d.ts.map +1 -0
  295. package/src/shade/renderer/shader/chunk/sdf/chunk_shape_record_line_span.js +169 -0
  296. package/src/shade/renderer/texture/atlas/chunk_tile_atlas_slot_origin.d.ts +18 -0
  297. package/src/shade/renderer/texture/atlas/chunk_tile_atlas_slot_origin.d.ts.map +1 -1
  298. package/src/shade/renderer/texture/atlas/chunk_tile_atlas_slot_origin.js +28 -0
  299. package/src/shade/renderer/texture/atlas/tile_atlas_slot_shift.d.ts +13 -0
  300. package/src/shade/renderer/texture/atlas/tile_atlas_slot_shift.d.ts.map +1 -0
  301. package/src/shade/renderer/texture/atlas/tile_atlas_slot_shift.js +22 -0
  302. package/src/shade/renderer/water/GPUWaterRenderer.d.ts.map +1 -1
  303. package/src/shade/renderer/water/GPUWaterRenderer.js +4 -0
  304. package/src/shade/renderer/wind/GPUSceneWind.d.ts +52 -5
  305. package/src/shade/renderer/wind/GPUSceneWind.d.ts.map +1 -1
  306. package/src/shade/renderer/wind/GPUSceneWind.js +164 -8
  307. package/src/shade/renderer/wind/WIND_FIELD_UNIFORM.d.ts +3 -1
  308. package/src/shade/renderer/wind/WIND_FIELD_UNIFORM.d.ts.map +1 -1
  309. package/src/shade/renderer/wind/WIND_FIELD_UNIFORM.js +3 -1
  310. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts +2 -1
  311. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.d.ts.map +1 -1
  312. package/src/shade/renderer/wind/chunk_wind_field_sample_cascades.js +18 -13
  313. package/src/shade/renderer/wind/chunk_wind_field_sample_previous.d.ts +13 -0
  314. package/src/shade/renderer/wind/chunk_wind_field_sample_previous.d.ts.map +1 -0
  315. package/src/shade/renderer/wind/chunk_wind_field_sample_previous.js +23 -0
  316. package/src/shade/renderer/wind/chunk_wind_field_sample_uniform.d.ts +1 -0
  317. package/src/shade/renderer/wind/chunk_wind_field_sample_uniform.d.ts.map +1 -1
  318. package/src/shade/renderer/wind/chunk_wind_field_sample_uniform.js +6 -1
  319. package/src/shade/renderer/wind/wind_field_add_resources.d.ts +11 -0
  320. package/src/shade/renderer/wind/wind_field_add_resources.d.ts.map +1 -1
  321. package/src/shade/renderer/wind/wind_field_add_resources.js +15 -0
  322. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +1 -1
  323. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  324. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +2 -0
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Grass blades on the device: the constants and records every pass over them shares.
3
+ *
4
+ * No blade is kept. Each frame, for each view, every baked slot of the grass surfaces' pool
5
+ * (`GRASS_SURFACE.js`) is a **cell**: it counts the blades it can owe the view, the counts are summed, and
6
+ * a thread a counted blade makes the blade or drops it. The blades that are made are a **blade list**, in
7
+ * no order, which the blade draw and the blade resolve read by a blade's place in it.
8
+ */
9
+ /**
10
+ * Words in a blade's record (`chunk_grass_blade_record`).
11
+ *
12
+ * @type {number}
13
+ */
14
+ export const GRASS_BLADE_RECORD_WORDS: number;
15
+ /**
16
+ * Words at the front of a blade list, ahead of its records.
17
+ *
18
+ * @type {number}
19
+ */
20
+ export const GRASS_BLADE_LIST_HEADER_WORDS: number;
21
+ /**
22
+ * Blade list word: how many blades asked for a place. It can pass the places the list has, and the list
23
+ * then holds its first `blade_capacity` only.
24
+ *
25
+ * @type {number}
26
+ */
27
+ export const GRASS_BLADE_LIST_COUNT: number;
28
+ /**
29
+ * Blade list word: the view's focal length in pixels, the bits of a `f32`, for the draw.
30
+ *
31
+ * @type {number}
32
+ */
33
+ export const GRASS_BLADE_LIST_FOCAL: number;
34
+ /**
35
+ * Blade list word: the least width a blade is drawn at, in pixels, the bits of a `f32`, for the draw.
36
+ *
37
+ * @type {number}
38
+ */
39
+ export const GRASS_BLADE_LIST_NARROWEST: number;
40
+ /**
41
+ * Segments a blade is drawn with along its length.
42
+ *
43
+ * @type {number}
44
+ */
45
+ export const GRASS_BLADE_SEGMENTS: number;
46
+ /**
47
+ * Vertices of a blade's triangle strip: a pair an end of a segment but the last, which is the tip.
48
+ *
49
+ * @type {number}
50
+ */
51
+ export const GRASS_BLADE_VERTICES: number;
52
+ /**
53
+ * Format of the blade id target: for each pixel a blade covers, which blade and where on it.
54
+ *
55
+ * @type {GPUTextureFormat}
56
+ */
57
+ export const GRASS_BLADE_ID_FORMAT: GPUTextureFormat;
58
+ /**
59
+ * What the id target holds where no blade is.
60
+ *
61
+ * @type {number}
62
+ */
63
+ export const GRASS_BLADE_ID_NONE: number;
64
+ /**
65
+ * Bits of an id that say where across the blade's width the pixel is.
66
+ *
67
+ * @type {number}
68
+ */
69
+ export const GRASS_BLADE_ID_ACROSS_BITS: number;
70
+ /**
71
+ * Bits of an id that say where along the blade's length the pixel is.
72
+ *
73
+ * @type {number}
74
+ */
75
+ export const GRASS_BLADE_ID_ALONG_BITS: number;
76
+ /**
77
+ * The most blades a list can hold: an id's remaining bits name a blade's place plus one.
78
+ *
79
+ * @type {number}
80
+ */
81
+ export const GRASS_BLADE_CAPACITY_LIMIT: number;
82
+ /**
83
+ * Cell flag: no baked tile of the next level up covers the cell, so it also makes the blades past its
84
+ * level's ring.
85
+ *
86
+ * @type {number}
87
+ */
88
+ export const GRASS_CELL_PARENT_MISSING: number;
89
+ /**
90
+ * Cell flag, shifted left by a quarter's number (x's half, plus two for z's): no baked tile of the level
91
+ * below covers that quarter of the cell, so it also makes that quarter's blades nearer than its ring.
92
+ *
93
+ * @type {number}
94
+ */
95
+ export const GRASS_CELL_CHILD_MISSING: number;
96
+ /**
97
+ * Bit a cell's `flags` hold its surface's lattice bits from, eight of them.
98
+ *
99
+ * @type {number}
100
+ */
101
+ export const GRASS_CELL_LATTICE_SHIFT: number;
102
+ /**
103
+ * A cell: what a blade's thread needs of a slot of the grass surfaces' pool, written by the frame's cell
104
+ * count for a view. The cell of slot `s` is element `s`.
105
+ *
106
+ * - `rank`: the bits every rank in the cell's block ends with (`grass_population_block_rank`).
107
+ * - `flags`: `GRASS_CELL_*`.
108
+ * - `surface`: the surface's `transforms` row.
109
+ * - `level_layer`: the slot record's word of that name.
110
+ * - `tile`: the slot's tile.
111
+ * - `ring`: the distances from the view the cell's level serves, inner then outer.
112
+ *
113
+ * @type {WebGPUStruct}
114
+ */
115
+ export const GRASS_CELL_STRUCT: WebGPUStruct;
116
+ /**
117
+ * Words in a {@link GRASS_CELL_STRUCT}.
118
+ *
119
+ * @type {number}
120
+ */
121
+ export const GRASS_CELL_WORDS: number;
122
+ /**
123
+ * A species of grass on the device, element `i` of the species list the species `i`.
124
+ *
125
+ * - `shape`: blade length and blade width in metres, blades a square metre, roughness.
126
+ * - `root`: the blade's colour at its root, linear; and how much of its length a blade can lack, 0 to 1.
127
+ * - `tip`: the blade's colour at its tip, linear; and the most a blade leans from upright at its root, radians.
128
+ * - `more`: the most a blade's tip turns further than its root leans, radians; how far a blade's colour
129
+ * strays from its species'; how far a blade's normal turns towards its edges; one word unused.
130
+ * - `wind`: the species' wind compliance per blade length cubed (`grass_blade_compliance`); its sway
131
+ * frequency times blade length squared (`grass_blade_frequency`); how unsteady the wind a blade feels
132
+ * is, as a share of its speed; and the seconds in which a blade that was pressed down stands back up by
133
+ * a factor of `e`.
134
+ *
135
+ * @type {WebGPUStruct}
136
+ */
137
+ export const GRASS_SPECIES_STRUCT: WebGPUStruct;
138
+ /**
139
+ * Words in a {@link GRASS_SPECIES_STRUCT}.
140
+ *
141
+ * @type {number}
142
+ */
143
+ export const GRASS_SPECIES_WORDS: number;
144
+ import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
145
+ //# sourceMappingURL=GRASS_BLADE.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GRASS_BLADE.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/blade/GRASS_BLADE.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH;;;;GAIG;AACH,uCAFU,MAAM,CAE2B;AAE3C;;;;GAIG;AACH,4CAFU,MAAM,CAE+B;AAE/C;;;;;GAKG;AACH,qCAFU,MAAM,CAEwB;AAExC;;;;GAIG;AACH,qCAFU,MAAM,CAEwB;AAExC;;;;GAIG;AACH,yCAFU,MAAM,CAE4B;AAE5C;;;;GAIG;AACH,mCAFU,MAAM,CAEsB;AAEtC;;;;GAIG;AACH,mCAFU,MAAM,CAEiD;AAEjE;;;;GAIG;AACH,qDAA+C;AAE/C;;;;GAIG;AACH,kCAFU,MAAM,CAEqB;AAErC;;;;GAIG;AACH,yCAFU,MAAM,CAE4B;AAE5C;;;;GAIG;AACH,wCAFU,MAAM,CAE2B;AAE3C;;;;GAIG;AACH,yCAFU,MAAM,CAEiG;AAEjH;;;;;GAKG;AACH,wCAFU,MAAM,CAE2B;AAE3C;;;;;GAKG;AACH,uCAFU,MAAM,CAE0B;AAE1C;;;;GAIG;AACH,uCAFU,MAAM,CAE0B;AAE1C;;;;;;;;;;;;GAYG;AACH,gCAFU,YAAY,CAUN;AAEhB;;;;GAIG;AACH,+BAFU,MAAM,CAEkB;AAElC;;;;;;;;;;;;;;GAcG;AACH,mCAFU,YAAY,CAQG;AAEzB;;;;GAIG;AACH,kCAFU,MAAM,CAEsB;6BAjLT,mCAAmC"}
@@ -0,0 +1,179 @@
1
+ import { f32, u32, vec2i, vec4f } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
2
+ import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
3
+
4
+ /**
5
+ * Grass blades on the device: the constants and records every pass over them shares.
6
+ *
7
+ * No blade is kept. Each frame, for each view, every baked slot of the grass surfaces' pool
8
+ * (`GRASS_SURFACE.js`) is a **cell**: it counts the blades it can owe the view, the counts are summed, and
9
+ * a thread a counted blade makes the blade or drops it. The blades that are made are a **blade list**, in
10
+ * no order, which the blade draw and the blade resolve read by a blade's place in it.
11
+ */
12
+
13
+ /**
14
+ * Words in a blade's record (`chunk_grass_blade_record`).
15
+ *
16
+ * @type {number}
17
+ */
18
+ export const GRASS_BLADE_RECORD_WORDS = 10;
19
+
20
+ /**
21
+ * Words at the front of a blade list, ahead of its records.
22
+ *
23
+ * @type {number}
24
+ */
25
+ export const GRASS_BLADE_LIST_HEADER_WORDS = 4;
26
+
27
+ /**
28
+ * Blade list word: how many blades asked for a place. It can pass the places the list has, and the list
29
+ * then holds its first `blade_capacity` only.
30
+ *
31
+ * @type {number}
32
+ */
33
+ export const GRASS_BLADE_LIST_COUNT = 0;
34
+
35
+ /**
36
+ * Blade list word: the view's focal length in pixels, the bits of a `f32`, for the draw.
37
+ *
38
+ * @type {number}
39
+ */
40
+ export const GRASS_BLADE_LIST_FOCAL = 1;
41
+
42
+ /**
43
+ * Blade list word: the least width a blade is drawn at, in pixels, the bits of a `f32`, for the draw.
44
+ *
45
+ * @type {number}
46
+ */
47
+ export const GRASS_BLADE_LIST_NARROWEST = 2;
48
+
49
+ /**
50
+ * Segments a blade is drawn with along its length.
51
+ *
52
+ * @type {number}
53
+ */
54
+ export const GRASS_BLADE_SEGMENTS = 3;
55
+
56
+ /**
57
+ * Vertices of a blade's triangle strip: a pair an end of a segment but the last, which is the tip.
58
+ *
59
+ * @type {number}
60
+ */
61
+ export const GRASS_BLADE_VERTICES = 2 * GRASS_BLADE_SEGMENTS + 1;
62
+
63
+ /**
64
+ * Format of the blade id target: for each pixel a blade covers, which blade and where on it.
65
+ *
66
+ * @type {GPUTextureFormat}
67
+ */
68
+ export const GRASS_BLADE_ID_FORMAT = "r32uint";
69
+
70
+ /**
71
+ * What the id target holds where no blade is.
72
+ *
73
+ * @type {number}
74
+ */
75
+ export const GRASS_BLADE_ID_NONE = 0;
76
+
77
+ /**
78
+ * Bits of an id that say where across the blade's width the pixel is.
79
+ *
80
+ * @type {number}
81
+ */
82
+ export const GRASS_BLADE_ID_ACROSS_BITS = 4;
83
+
84
+ /**
85
+ * Bits of an id that say where along the blade's length the pixel is.
86
+ *
87
+ * @type {number}
88
+ */
89
+ export const GRASS_BLADE_ID_ALONG_BITS = 6;
90
+
91
+ /**
92
+ * The most blades a list can hold: an id's remaining bits name a blade's place plus one.
93
+ *
94
+ * @type {number}
95
+ */
96
+ export const GRASS_BLADE_CAPACITY_LIMIT = 2 ** (32 - GRASS_BLADE_ID_ACROSS_BITS - GRASS_BLADE_ID_ALONG_BITS) - 1;
97
+
98
+ /**
99
+ * Cell flag: no baked tile of the next level up covers the cell, so it also makes the blades past its
100
+ * level's ring.
101
+ *
102
+ * @type {number}
103
+ */
104
+ export const GRASS_CELL_PARENT_MISSING = 1;
105
+
106
+ /**
107
+ * Cell flag, shifted left by a quarter's number (x's half, plus two for z's): no baked tile of the level
108
+ * below covers that quarter of the cell, so it also makes that quarter's blades nearer than its ring.
109
+ *
110
+ * @type {number}
111
+ */
112
+ export const GRASS_CELL_CHILD_MISSING = 2;
113
+
114
+ /**
115
+ * Bit a cell's `flags` hold its surface's lattice bits from, eight of them.
116
+ *
117
+ * @type {number}
118
+ */
119
+ export const GRASS_CELL_LATTICE_SHIFT = 8;
120
+
121
+ /**
122
+ * A cell: what a blade's thread needs of a slot of the grass surfaces' pool, written by the frame's cell
123
+ * count for a view. The cell of slot `s` is element `s`.
124
+ *
125
+ * - `rank`: the bits every rank in the cell's block ends with (`grass_population_block_rank`).
126
+ * - `flags`: `GRASS_CELL_*`.
127
+ * - `surface`: the surface's `transforms` row.
128
+ * - `level_layer`: the slot record's word of that name.
129
+ * - `tile`: the slot's tile.
130
+ * - `ring`: the distances from the view the cell's level serves, inner then outer.
131
+ *
132
+ * @type {WebGPUStruct}
133
+ */
134
+ export const GRASS_CELL_STRUCT = WebGPUStruct.from({
135
+ rank: u32,
136
+ flags: u32,
137
+ surface: u32,
138
+ level_layer: u32,
139
+ tile: vec2i,
140
+ ring_inner: f32,
141
+ ring_outer: f32,
142
+ }, "GrassCell");
143
+
144
+ /**
145
+ * Words in a {@link GRASS_CELL_STRUCT}.
146
+ *
147
+ * @type {number}
148
+ */
149
+ export const GRASS_CELL_WORDS = 8;
150
+
151
+ /**
152
+ * A species of grass on the device, element `i` of the species list the species `i`.
153
+ *
154
+ * - `shape`: blade length and blade width in metres, blades a square metre, roughness.
155
+ * - `root`: the blade's colour at its root, linear; and how much of its length a blade can lack, 0 to 1.
156
+ * - `tip`: the blade's colour at its tip, linear; and the most a blade leans from upright at its root, radians.
157
+ * - `more`: the most a blade's tip turns further than its root leans, radians; how far a blade's colour
158
+ * strays from its species'; how far a blade's normal turns towards its edges; one word unused.
159
+ * - `wind`: the species' wind compliance per blade length cubed (`grass_blade_compliance`); its sway
160
+ * frequency times blade length squared (`grass_blade_frequency`); how unsteady the wind a blade feels
161
+ * is, as a share of its speed; and the seconds in which a blade that was pressed down stands back up by
162
+ * a factor of `e`.
163
+ *
164
+ * @type {WebGPUStruct}
165
+ */
166
+ export const GRASS_SPECIES_STRUCT = WebGPUStruct.from({
167
+ shape: vec4f,
168
+ root: vec4f,
169
+ tip: vec4f,
170
+ more: vec4f,
171
+ wind: vec4f,
172
+ }, "GrassSpeciesRecord");
173
+
174
+ /**
175
+ * Words in a {@link GRASS_SPECIES_STRUCT}.
176
+ *
177
+ * @type {number}
178
+ */
179
+ export const GRASS_SPECIES_WORDS = 20;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * A blade of grass: its record, its shape, and how many of them a view is shown.
3
+ *
4
+ * ```wgsl
5
+ * struct GrassBlade {
6
+ * root: vec3<f32>, // where it stands, in its surface's frame
7
+ * surface: u32, // the surface's transforms row, under 2^22
8
+ * species: u32, // its species' place in the species list, under 2^10
9
+ * length: f32, // from root to tip along the blade, as drawn
10
+ * width: f32, // at the root, as grown
11
+ * facing: f32, // the way it leans, an angle about the frame's up axis from +x towards +z, [0, 2π)
12
+ * lean: f32, // how far from upright it is at the root, towards its facing, [-π/2, π/2]
13
+ * curl: f32, // how much further its tip has turned, [-π, π]
14
+ * ground: vec3<f32>, // the ground's normal under it, unit, in the frame
15
+ * thinning: f32, // 1 where it stands for itself, towards 0 as it stands for more blades left out
16
+ * seed: u32, // eight bits that are the blade's own
17
+ * facing_previous: f32, // facing, lean and curl as they were a frame ago
18
+ * lean_previous: f32,
19
+ * curl_previous: f32,
20
+ * }
21
+ *
22
+ * fn grass_blade_pack(blade: GrassBlade) -> array<u32, 10>
23
+ * fn grass_blade_unpack(words: array<u32, 10>) -> GrassBlade
24
+ * fn grass_blade_previous(blade: GrassBlade) -> GrassBlade
25
+ * fn grass_blade_point(blade: GrassBlade, along: f32) -> vec3<f32>
26
+ * fn grass_blade_tangent(blade: GrassBlade, along: f32) -> vec3<f32>
27
+ * fn grass_blade_across(blade: GrassBlade) -> vec3<f32>
28
+ * fn grass_blade_taper(along: f32) -> f32
29
+ * fn grass_blade_drawn_width(view: GrassSurfaceViewSettings, width: f32, distance: f32) -> f32
30
+ * fn grass_blade_density(view: GrassSurfaceViewSettings, content: f32, width: f32, length: f32, distance: f32, sin_elevation: f32, ground_up: f32) -> f32
31
+ * fn grass_blade_fade(view: GrassSurfaceViewSettings, length: f32, distance: f32) -> f32
32
+ * ```
33
+ *
34
+ * **Shape.** A blade is an arc of its length, in the plane of the frame's up axis and its facing: upright
35
+ * but for `lean` at the root, and turned by `curl` more at the tip, evenly along it, so bending never
36
+ * stretches it. A record keeps the arc twice, as it is and as it was a frame ago; `grass_blade_previous`
37
+ * is the blade as it was, for where each of its points has come from. The two arcs are packed alike, so
38
+ * a blade that has not moved unpacks as the same arc twice. `grass_blade_point` is the point `along` of the way from root (0) to tip (1), in the frame;
39
+ * `grass_blade_tangent` the unit direction the blade runs there; `grass_blade_across` the unit direction
40
+ * of its width, level in the frame. `grass_blade_taper` is the blade's width at a point as a share of its
41
+ * root's.
42
+ *
43
+ * **How many.** `grass_blade_density` is the blades a square metre of ground a view is shown, of grass
44
+ * that grows `content` a square metre, each `width` wide and `length` long, `distance` from the view. It
45
+ * is the least of three:
46
+ *
47
+ * - what grows;
48
+ * - no blade is drawn narrower than `view.narrowest_blade` pixels (`grass_blade_drawn_width`), and where
49
+ * blades are drawn wider than they are there are as many fewer, so the ground they cover is the same;
50
+ * - a view ray crosses no more than `view.canopy_opacity` blades: it runs `length * ground_up /
51
+ * tan(elevation)` over the ground inside grass of that height, and meets the blades whose drawn width
52
+ * that run crosses. `sin_elevation` is the sine of the angle between the ray and the ground, and
53
+ * `ground_up` how upright the ground's normal is, its component along the frame's up axis.
54
+ *
55
+ * **How long.** `grass_blade_fade` is the share of its length a blade is drawn at: all of it while its
56
+ * length spans twice `view.shortest_blade` pixels or more, none once it spans that or less, and in between
57
+ * as much as the span is past it.
58
+ *
59
+ * @type {CodeChunk}
60
+ */
61
+ export const chunk_grass_blade: CodeChunk;
62
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
63
+ //# sourceMappingURL=chunk_grass_blade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_grass_blade.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/blade/chunk_grass_blade.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,gCAFU,SAAS,CAmLjB;0BAjPwB,oCAAoC"}
@@ -0,0 +1,244 @@
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 { GRASS_SURFACE_VIEW_SETTINGS } from "../surface/GRASS_SURFACE_VIEW.js";
5
+ import { GRASS_BLADE_RECORD_WORDS } from "./GRASS_BLADE.js";
6
+
7
+ /**
8
+ * A blade of grass: its record, its shape, and how many of them a view is shown.
9
+ *
10
+ * ```wgsl
11
+ * struct GrassBlade {
12
+ * root: vec3<f32>, // where it stands, in its surface's frame
13
+ * surface: u32, // the surface's transforms row, under 2^22
14
+ * species: u32, // its species' place in the species list, under 2^10
15
+ * length: f32, // from root to tip along the blade, as drawn
16
+ * width: f32, // at the root, as grown
17
+ * facing: f32, // the way it leans, an angle about the frame's up axis from +x towards +z, [0, 2π)
18
+ * lean: f32, // how far from upright it is at the root, towards its facing, [-π/2, π/2]
19
+ * curl: f32, // how much further its tip has turned, [-π, π]
20
+ * ground: vec3<f32>, // the ground's normal under it, unit, in the frame
21
+ * thinning: f32, // 1 where it stands for itself, towards 0 as it stands for more blades left out
22
+ * seed: u32, // eight bits that are the blade's own
23
+ * facing_previous: f32, // facing, lean and curl as they were a frame ago
24
+ * lean_previous: f32,
25
+ * curl_previous: f32,
26
+ * }
27
+ *
28
+ * fn grass_blade_pack(blade: GrassBlade) -> array<u32, 10>
29
+ * fn grass_blade_unpack(words: array<u32, 10>) -> GrassBlade
30
+ * fn grass_blade_previous(blade: GrassBlade) -> GrassBlade
31
+ * fn grass_blade_point(blade: GrassBlade, along: f32) -> vec3<f32>
32
+ * fn grass_blade_tangent(blade: GrassBlade, along: f32) -> vec3<f32>
33
+ * fn grass_blade_across(blade: GrassBlade) -> vec3<f32>
34
+ * fn grass_blade_taper(along: f32) -> f32
35
+ * fn grass_blade_drawn_width(view: GrassSurfaceViewSettings, width: f32, distance: f32) -> f32
36
+ * fn grass_blade_density(view: GrassSurfaceViewSettings, content: f32, width: f32, length: f32, distance: f32, sin_elevation: f32, ground_up: f32) -> f32
37
+ * fn grass_blade_fade(view: GrassSurfaceViewSettings, length: f32, distance: f32) -> f32
38
+ * ```
39
+ *
40
+ * **Shape.** A blade is an arc of its length, in the plane of the frame's up axis and its facing: upright
41
+ * but for `lean` at the root, and turned by `curl` more at the tip, evenly along it, so bending never
42
+ * stretches it. A record keeps the arc twice, as it is and as it was a frame ago; `grass_blade_previous`
43
+ * is the blade as it was, for where each of its points has come from. The two arcs are packed alike, so
44
+ * a blade that has not moved unpacks as the same arc twice. `grass_blade_point` is the point `along` of the way from root (0) to tip (1), in the frame;
45
+ * `grass_blade_tangent` the unit direction the blade runs there; `grass_blade_across` the unit direction
46
+ * of its width, level in the frame. `grass_blade_taper` is the blade's width at a point as a share of its
47
+ * root's.
48
+ *
49
+ * **How many.** `grass_blade_density` is the blades a square metre of ground a view is shown, of grass
50
+ * that grows `content` a square metre, each `width` wide and `length` long, `distance` from the view. It
51
+ * is the least of three:
52
+ *
53
+ * - what grows;
54
+ * - no blade is drawn narrower than `view.narrowest_blade` pixels (`grass_blade_drawn_width`), and where
55
+ * blades are drawn wider than they are there are as many fewer, so the ground they cover is the same;
56
+ * - a view ray crosses no more than `view.canopy_opacity` blades: it runs `length * ground_up /
57
+ * tan(elevation)` over the ground inside grass of that height, and meets the blades whose drawn width
58
+ * that run crosses. `sin_elevation` is the sine of the angle between the ray and the ground, and
59
+ * `ground_up` how upright the ground's normal is, its component along the frame's up axis.
60
+ *
61
+ * **How long.** `grass_blade_fade` is the share of its length a blade is drawn at: all of it while its
62
+ * length spans twice `view.shortest_blade` pixels or more, none once it spans that or less, and in between
63
+ * as much as the span is past it.
64
+ *
65
+ * @type {CodeChunk}
66
+ */
67
+ export const chunk_grass_blade = CodeChunk.from(
68
+ //language=WGSL
69
+ `
70
+ struct GrassBlade {
71
+ root: vec3<f32>,
72
+ surface: u32,
73
+ species: u32,
74
+ length: f32,
75
+ width: f32,
76
+ facing: f32,
77
+ lean: f32,
78
+ curl: f32,
79
+ ground: vec3<f32>,
80
+ thinning: f32,
81
+ seed: u32,
82
+ facing_previous: f32,
83
+ lean_previous: f32,
84
+ curl_previous: f32,
85
+ }
86
+
87
+ const GRASS_BLADE_TAU = 6.283185307179586;
88
+
89
+ // the least a record's lean can change by: half a turn over sixteen bits
90
+ const GRASS_BLADE_LEAN_STEP = 4.7937028972077485e-5;
91
+
92
+ // a facing in sixteen bits of a turn
93
+ fn grass_blade_pack_facing(facing: f32) -> u32 {
94
+ return u32(fract(facing / GRASS_BLADE_TAU) * 65535.0 + 0.5);
95
+ }
96
+
97
+ // a lean in [-π/2, π/2] and a curl in [-π, π], sixteen bits each
98
+ fn grass_blade_pack_bend(lean: f32, curl: f32) -> u32 {
99
+ let l = u32(saturate(lean * 2.0 / GRASS_BLADE_TAU + 0.5) * 65535.0 + 0.5);
100
+ let c = u32(saturate(curl / GRASS_BLADE_TAU + 0.5) * 65535.0 + 0.5);
101
+
102
+ return l | (c << 16u);
103
+ }
104
+
105
+ fn grass_blade_unpack_facing(word: u32) -> f32 {
106
+ return f32(word & 0xFFFFu) / 65535.0 * GRASS_BLADE_TAU;
107
+ }
108
+
109
+ fn grass_blade_unpack_bend(word: u32) -> vec2<f32> {
110
+ return vec2<f32>(
111
+ (f32(word & 0xFFFFu) / 65535.0 - 0.5) * GRASS_BLADE_TAU * 0.5,
112
+ (f32(word >> 16u) / 65535.0 - 0.5) * GRASS_BLADE_TAU,
113
+ );
114
+ }
115
+
116
+ fn grass_blade_pack(blade: GrassBlade) -> array<u32, ${GRASS_BLADE_RECORD_WORDS}> {
117
+ return array<u32, ${GRASS_BLADE_RECORD_WORDS}>(
118
+ bitcast<u32>(blade.root.x),
119
+ bitcast<u32>(blade.root.y),
120
+ bitcast<u32>(blade.root.z),
121
+ (blade.surface & 0x3FFFFFu) | (blade.species << 22u),
122
+ pack2x16float(vec2<f32>(blade.length, blade.width)),
123
+ grass_blade_pack_facing(blade.facing) | (u32(saturate(blade.thinning) * 255.0 + 0.5) << 16u) | ((blade.seed & 0xFFu) << 24u),
124
+ encode_vertex_normal(blade.ground),
125
+ grass_blade_pack_bend(blade.lean, blade.curl),
126
+ grass_blade_pack_facing(blade.facing_previous),
127
+ grass_blade_pack_bend(blade.lean_previous, blade.curl_previous),
128
+ );
129
+ }
130
+
131
+ fn grass_blade_unpack(words: array<u32, ${GRASS_BLADE_RECORD_WORDS}>) -> GrassBlade {
132
+ var blade: GrassBlade;
133
+
134
+ blade.root = vec3<f32>(bitcast<f32>(words[0]), bitcast<f32>(words[1]), bitcast<f32>(words[2]));
135
+ blade.surface = words[3] & 0x3FFFFFu;
136
+ blade.species = words[3] >> 22u;
137
+
138
+ let size = unpack2x16float(words[4]);
139
+
140
+ blade.length = size.x;
141
+ blade.width = size.y;
142
+ blade.facing = grass_blade_unpack_facing(words[5]);
143
+ blade.thinning = f32((words[5] >> 16u) & 0xFFu) / 255.0;
144
+ blade.seed = words[5] >> 24u;
145
+ blade.ground = decode_vertex_normal(words[6]);
146
+
147
+ let bend = grass_blade_unpack_bend(words[7]);
148
+
149
+ blade.lean = bend.x;
150
+ blade.curl = bend.y;
151
+ blade.facing_previous = grass_blade_unpack_facing(words[8]);
152
+
153
+ let bend_previous = grass_blade_unpack_bend(words[9]);
154
+
155
+ blade.lean_previous = bend_previous.x;
156
+ blade.curl_previous = bend_previous.y;
157
+
158
+ return blade;
159
+ }
160
+
161
+ fn grass_blade_previous(blade: GrassBlade) -> GrassBlade {
162
+ var before = blade;
163
+
164
+ before.facing = blade.facing_previous;
165
+ before.lean = blade.lean_previous;
166
+ before.curl = blade.curl_previous;
167
+
168
+ return before;
169
+ }
170
+
171
+ fn grass_blade_point(blade: GrassBlade, along: f32) -> vec3<f32> {
172
+ let facing = vec2<f32>(cos(blade.facing), sin(blade.facing));
173
+
174
+ // the blade's angle from upright runs from lean to lean + curl; its point is that direction summed along it
175
+ let turned = blade.curl * along;
176
+
177
+ var out: f32;
178
+ var up: f32;
179
+
180
+ if (abs(blade.curl) < 1e-3) {
181
+ // straight, to the precision of what follows
182
+ out = sin(blade.lean) * along;
183
+ up = cos(blade.lean) * along;
184
+ } else {
185
+ out = (cos(blade.lean) - cos(blade.lean + turned)) / blade.curl;
186
+ up = (sin(blade.lean + turned) - sin(blade.lean)) / blade.curl;
187
+ }
188
+
189
+ return blade.root + blade.length * vec3<f32>(facing.x * out, up, facing.y * out);
190
+ }
191
+
192
+ fn grass_blade_tangent(blade: GrassBlade, along: f32) -> vec3<f32> {
193
+ let angle = blade.lean + blade.curl * along;
194
+ let out = sin(angle);
195
+
196
+ return vec3<f32>(cos(blade.facing) * out, cos(angle), sin(blade.facing) * out);
197
+ }
198
+
199
+ fn grass_blade_across(blade: GrassBlade) -> vec3<f32> {
200
+ return vec3<f32>(-sin(blade.facing), 0.0, cos(blade.facing));
201
+ }
202
+
203
+ fn grass_blade_taper(along: f32) -> f32 {
204
+ return 1.0 - along * along;
205
+ }
206
+
207
+ fn grass_blade_drawn_width(view: ${GRASS_SURFACE_VIEW_SETTINGS.wgsl_ref}, width: f32, distance: f32) -> f32 {
208
+ return max(width, view.narrowest_blade * distance / view.focal);
209
+ }
210
+
211
+ fn grass_blade_density(
212
+ view: ${GRASS_SURFACE_VIEW_SETTINGS.wgsl_ref},
213
+ content: f32,
214
+ width: f32,
215
+ length: f32,
216
+ distance: f32,
217
+ sin_elevation: f32,
218
+ ground_up: f32,
219
+ ) -> f32 {
220
+ let drawn = grass_blade_drawn_width(view, width, distance);
221
+
222
+ // as many fewer as each is drawn wider
223
+ let covering = content * width / drawn;
224
+
225
+ let s = min(abs(sin_elevation), 1.0);
226
+ let tan_elevation = s / sqrt(max(1.0 - s * s, 1e-12));
227
+
228
+ // the blades a ray crosses are those within the drawn width of its run over the ground inside the grass
229
+ let opaque = view.canopy_opacity * tan_elevation / max(drawn * length * max(ground_up, 1e-3), 1e-12);
230
+
231
+ return min(covering, opaque);
232
+ }
233
+
234
+ fn grass_blade_fade(view: ${GRASS_SURFACE_VIEW_SETTINGS.wgsl_ref}, length: f32, distance: f32) -> f32 {
235
+ let pixels = length * view.focal / max(distance, 1e-6);
236
+
237
+ return saturate(pixels / view.shortest_blade - 1.0);
238
+ }
239
+ `, [
240
+ GRASS_SURFACE_VIEW_SETTINGS.declaration_chunk,
241
+ chunk_encode_vertex_normal,
242
+ chunk_decode_vertex_normal,
243
+ ]
244
+ );