@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 @@
1
+ {"version":3,"file":"chunk_grass_column_cross.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/surface/chunk_grass_column_cross.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,sCAFU,MAAM,CAE6B;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,uCAFU,SAAS,CA+CjB;0BApFwB,oCAAoC"}
@@ -0,0 +1,85 @@
1
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
+
3
+ /**
4
+ * Clear height of ground under open sky: the largest finite half float, which is how a surfel stores it.
5
+ * Any stored clear height at or above this means nothing stands over the surfel.
6
+ * @type {number}
7
+ */
8
+ export const GRASS_CLEAR_HEIGHT_OPEN = 65504;
9
+
10
+ /**
11
+ * One step of a walk down a column of a grass surface, from above the surface's members to below them.
12
+ *
13
+ * A column crosses the faces of its surface's members in order of falling height. Each crossing is either
14
+ * an upward face (ground a blade could stand on) or a downward one (an underside: a ceiling, the bottom of
15
+ * something resting there). What the column crossed just before a crossing decides what it is:
16
+ *
17
+ * - nothing: the crossing is under open sky;
18
+ * - a downward face: the crossing is in open air under it, and the gap between them is its clear height;
19
+ * - an upward face: the crossing is inside the member that face tops, where nothing grows.
20
+ *
21
+ * ```wgsl
22
+ * fn grass_column_begin() -> GrassColumnWalk
23
+ * fn grass_column_cross(walk: GrassColumnWalk, height: f32, faces_up: bool) -> GrassColumnCrossing
24
+ * ```
25
+ *
26
+ * `grass_column_cross` takes the walk as it stood before the crossing and answers with:
27
+ *
28
+ * - `keep`: the crossing is ground to keep, an upward face that is not inside a member;
29
+ * - `clear_height`: for a kept crossing, the height of open air over it, `GRASS_CLEAR_HEIGHT_OPEN` under
30
+ * open sky; never negative;
31
+ * - `walk`: the walk after the crossing, to hand to the next one.
32
+ *
33
+ * Heights are along the surface frame's up axis and must not rise from one crossing to the next.
34
+ *
35
+ * Which way a face points is read from its winding, so ground under a one-sided sheet reads as inside it:
36
+ * a cave needs its ceiling modelled.
37
+ *
38
+ * @type {CodeChunk}
39
+ */
40
+ export const chunk_grass_column_cross = CodeChunk.from(
41
+ //language=WGSL
42
+ `
43
+ const GRASS_CLEAR_HEIGHT_OPEN: f32 = ${GRASS_CLEAR_HEIGHT_OPEN}.0;
44
+
45
+ // nothing crossed yet
46
+ const GRASS_COLUMN_ABOVE_SKY: u32 = 0u;
47
+ // the last face crossed points down: open air under it
48
+ const GRASS_COLUMN_ABOVE_UNDERSIDE: u32 = 1u;
49
+ // the last face crossed points up: the inside of the member it tops
50
+ const GRASS_COLUMN_ABOVE_TOPSIDE: u32 = 2u;
51
+
52
+ struct GrassColumnWalk {
53
+ above: u32,
54
+ above_height: f32,
55
+ }
56
+
57
+ struct GrassColumnCrossing {
58
+ keep: bool,
59
+ clear_height: f32,
60
+ walk: GrassColumnWalk,
61
+ }
62
+
63
+ fn grass_column_begin() -> GrassColumnWalk {
64
+ return GrassColumnWalk(GRASS_COLUMN_ABOVE_SKY, 0.0);
65
+ }
66
+
67
+ fn grass_column_cross(walk: GrassColumnWalk, height: f32, faces_up: bool) -> GrassColumnCrossing {
68
+ var crossing: GrassColumnCrossing;
69
+
70
+ crossing.keep = faces_up && walk.above != GRASS_COLUMN_ABOVE_TOPSIDE;
71
+
72
+ crossing.clear_height = GRASS_CLEAR_HEIGHT_OPEN;
73
+ if (walk.above == GRASS_COLUMN_ABOVE_UNDERSIDE) {
74
+ crossing.clear_height = min(max(walk.above_height - height, 0.0), GRASS_CLEAR_HEIGHT_OPEN);
75
+ }
76
+
77
+ crossing.walk = GrassColumnWalk(
78
+ select(GRASS_COLUMN_ABOVE_UNDERSIDE, GRASS_COLUMN_ABOVE_TOPSIDE, faces_up),
79
+ height,
80
+ );
81
+
82
+ return crossing;
83
+ }
84
+ `
85
+ );
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The directory of the grass surfaces' pool: which slot holds a given layer of a given tile.
3
+ *
4
+ * ```wgsl
5
+ * fn grass_tile_key(surface: u32, level_layer: u32, tile: vec2<i32>) -> u32
6
+ * fn grass_directory_find(surface: u32, level_layer: u32, tile: vec2<i32>) -> u32
7
+ * fn grass_directory_insert(surface: u32, level_layer: u32, tile: vec2<i32>, slot: u32) -> bool
8
+ * fn grass_directory_remove(surface: u32, level_layer: u32, tile: vec2<i32>, slot: u32) -> bool
9
+ * ```
10
+ *
11
+ * - `grass_tile_key`: the directory's key for a layer of a tile. A hash: different layers may share one.
12
+ * - `grass_directory_find`: the slot whose record names that surface, level, layer and tile, or
13
+ * `GRASS_SLOT_NONE`. The key only finds candidates; the record decides.
14
+ * - `grass_directory_insert`: list a slot under its key. The slot's record must name the layer already.
15
+ * False when the key's probe sequence has no record free, and the slot is then listed nowhere.
16
+ * - `grass_directory_remove`: take a slot's record out from under its layer's key. False when the
17
+ * directory does not list the slot there. A removal shares a dispatch with no find or insert.
18
+ *
19
+ * `surface` is the surface's `transforms` row and `level_layer` a record's word of that name
20
+ * (`GRASS_SURFACE.js`).
21
+ *
22
+ * Reads `grass_pool` ({@link GRASS_POOL_RESOURCE}) and `grass_directory` ({@link GRASS_DIRECTORY_RESOURCE}). A
23
+ * find and an insert of the same layer must not share a dispatch.
24
+ *
25
+ * @type {CodeChunk}
26
+ */
27
+ export const chunk_grass_directory: CodeChunk;
28
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
29
+ //# sourceMappingURL=chunk_grass_directory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_grass_directory.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/surface/chunk_grass_directory.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,oCAFU,SAAS,CAwEjB;0BA1GwB,oCAAoC"}
@@ -0,0 +1,112 @@
1
+ import { chunk_hash_table_atomic } from "../../gpu_primitive/hash_table/chunk_hash_table_atomic.js";
2
+ import { chunk_hash_lowbias32 } from "../../shader/chunk/random/chunk_hash_lowbias32.js";
3
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
4
+ import { chunk_grass_slot } from "./chunk_grass_slot.js";
5
+ import {
6
+ GRASS_SLOT_LEVEL_LAYER,
7
+ GRASS_SLOT_SURFACE,
8
+ GRASS_SLOT_TILE_X,
9
+ GRASS_SLOT_TILE_Z
10
+ } from "./GRASS_SURFACE.js";
11
+ import { GRASS_DIRECTORY_RESOURCE, GRASS_POOL_RESOURCE } from "./GRASS_SURFACE_VIEW.js";
12
+
13
+ /**
14
+ * The directory of the grass surfaces' pool: which slot holds a given layer of a given tile.
15
+ *
16
+ * ```wgsl
17
+ * fn grass_tile_key(surface: u32, level_layer: u32, tile: vec2<i32>) -> u32
18
+ * fn grass_directory_find(surface: u32, level_layer: u32, tile: vec2<i32>) -> u32
19
+ * fn grass_directory_insert(surface: u32, level_layer: u32, tile: vec2<i32>, slot: u32) -> bool
20
+ * fn grass_directory_remove(surface: u32, level_layer: u32, tile: vec2<i32>, slot: u32) -> bool
21
+ * ```
22
+ *
23
+ * - `grass_tile_key`: the directory's key for a layer of a tile. A hash: different layers may share one.
24
+ * - `grass_directory_find`: the slot whose record names that surface, level, layer and tile, or
25
+ * `GRASS_SLOT_NONE`. The key only finds candidates; the record decides.
26
+ * - `grass_directory_insert`: list a slot under its key. The slot's record must name the layer already.
27
+ * False when the key's probe sequence has no record free, and the slot is then listed nowhere.
28
+ * - `grass_directory_remove`: take a slot's record out from under its layer's key. False when the
29
+ * directory does not list the slot there. A removal shares a dispatch with no find or insert.
30
+ *
31
+ * `surface` is the surface's `transforms` row and `level_layer` a record's word of that name
32
+ * (`GRASS_SURFACE.js`).
33
+ *
34
+ * Reads `grass_pool` ({@link GRASS_POOL_RESOURCE}) and `grass_directory` ({@link GRASS_DIRECTORY_RESOURCE}). A
35
+ * find and an insert of the same layer must not share a dispatch.
36
+ *
37
+ * @type {CodeChunk}
38
+ */
39
+ export const chunk_grass_directory = CodeChunk.from(
40
+ //language=WGSL
41
+ `
42
+ fn grass_tile_key(surface: u32, level_layer: u32, tile: vec2<i32>) -> u32 {
43
+ var key = hash_lowbias32(surface ^ (level_layer * 0x9E3779B9u));
44
+ key = hash_lowbias32(key ^ bitcast<u32>(tile.x));
45
+ key = hash_lowbias32(key ^ bitcast<u32>(tile.y));
46
+
47
+ // the table's keys stay below its two reserved words
48
+ return key >> 1u;
49
+ }
50
+
51
+ fn grass_directory_find(surface: u32, level_layer: u32, tile: vec2<i32>) -> u32 {
52
+ let key = grass_tile_key(surface, level_layer, tile);
53
+
54
+ var cursor = hash_table_atomic_start(&grass_directory, 0u, key);
55
+
56
+ for (var i = 0u; i < HASH_TABLE_PROBE_LIMIT; i++) {
57
+ let entry = hash_table_atomic_find(&grass_directory, 0u, key, &cursor);
58
+
59
+ if (entry == HASH_TABLE_MISS) {
60
+ break;
61
+ }
62
+
63
+ // a value a racing insert of another layer has not stored yet reads as slot 0, whose record decides like any other
64
+ let slot = hash_table_atomic_value(&grass_directory, entry);
65
+
66
+ let record = grass_slot_record(slot);
67
+
68
+ if (atomicLoad(&grass_pool[record + ${GRASS_SLOT_SURFACE}u]) == surface
69
+ && atomicLoad(&grass_pool[record + ${GRASS_SLOT_LEVEL_LAYER}u]) == level_layer
70
+ && atomicLoad(&grass_pool[record + ${GRASS_SLOT_TILE_X}u]) == bitcast<u32>(tile.x)
71
+ && atomicLoad(&grass_pool[record + ${GRASS_SLOT_TILE_Z}u]) == bitcast<u32>(tile.y)) {
72
+ return slot;
73
+ }
74
+ }
75
+
76
+ return GRASS_SLOT_NONE;
77
+ }
78
+
79
+ fn grass_directory_insert(surface: u32, level_layer: u32, tile: vec2<i32>, slot: u32) -> bool {
80
+ return hash_table_atomic_insert(&grass_directory, 0u, grass_tile_key(surface, level_layer, tile), slot);
81
+ }
82
+
83
+ fn grass_directory_remove(surface: u32, level_layer: u32, tile: vec2<i32>, slot: u32) -> bool {
84
+ let key = grass_tile_key(surface, level_layer, tile);
85
+
86
+ var cursor = hash_table_atomic_start(&grass_directory, 0u, key);
87
+
88
+ for (var i = 0u; i < HASH_TABLE_PROBE_LIMIT; i++) {
89
+ let entry = hash_table_atomic_find(&grass_directory, 0u, key, &cursor);
90
+
91
+ if (entry == HASH_TABLE_MISS) {
92
+ break;
93
+ }
94
+
95
+ if (hash_table_atomic_value(&grass_directory, entry) == slot) {
96
+ hash_table_atomic_remove(&grass_directory, 0u, entry);
97
+
98
+ return true;
99
+ }
100
+ }
101
+
102
+ return false;
103
+ }
104
+ `, [
105
+ chunk_hash_lowbias32,
106
+ chunk_hash_table_atomic,
107
+ chunk_grass_slot,
108
+ ]
109
+ );
110
+
111
+ chunk_grass_directory.requireResource(GRASS_POOL_RESOURCE);
112
+ chunk_grass_directory.requireResource(GRASS_DIRECTORY_RESOURCE);
@@ -0,0 +1,27 @@
1
+ /**
2
+ * No slot: what a look-up of a tile's layer the pool does not hold answers, and what a place of the bake
3
+ * list holds when no slot could be taken for it.
4
+ *
5
+ * @type {number}
6
+ */
7
+ export const GRASS_SLOT_NONE: number;
8
+ /**
9
+ * A slot of the grass surfaces' pool, by number.
10
+ *
11
+ * ```wgsl
12
+ * const GRASS_SLOT_NONE: u32
13
+ * fn grass_slot_record(slot: u32) -> u32
14
+ * fn grass_height_key(height: f32) -> u32
15
+ * fn grass_height_of_key(key: u32) -> f32
16
+ * ```
17
+ *
18
+ * - `grass_slot_record`: the word of the pool's arena a slot's record starts at (`GRASS_SURFACE.js`).
19
+ * - `grass_height_key`: a height as a word that orders as the height does, so that an atomic minimum or
20
+ * maximum of keys is one of heights. Every finite height has a key above zero and under the highest word.
21
+ * - `grass_height_of_key`: the height a key was made of.
22
+ *
23
+ * @type {CodeChunk}
24
+ */
25
+ export const chunk_grass_slot: CodeChunk;
26
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
27
+ //# sourceMappingURL=chunk_grass_slot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_grass_slot.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/surface/chunk_grass_slot.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,8BAFU,MAAM,CAE+B;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,+BAFU,SAAS,CAsBjB;0BAhDwB,oCAAoC"}
@@ -0,0 +1,50 @@
1
+ import { SLOT_STACK_NONE } from "../../gpu_primitive/slot_stack/chunk_slot_stack.js";
2
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
3
+ import { GRASS_POOL_HEADER_WORDS, GRASS_SLOT_WORDS } from "./GRASS_SURFACE.js";
4
+
5
+ /**
6
+ * No slot: what a look-up of a tile's layer the pool does not hold answers, and what a place of the bake
7
+ * list holds when no slot could be taken for it.
8
+ *
9
+ * @type {number}
10
+ */
11
+ export const GRASS_SLOT_NONE = SLOT_STACK_NONE;
12
+
13
+ /**
14
+ * A slot of the grass surfaces' pool, by number.
15
+ *
16
+ * ```wgsl
17
+ * const GRASS_SLOT_NONE: u32
18
+ * fn grass_slot_record(slot: u32) -> u32
19
+ * fn grass_height_key(height: f32) -> u32
20
+ * fn grass_height_of_key(key: u32) -> f32
21
+ * ```
22
+ *
23
+ * - `grass_slot_record`: the word of the pool's arena a slot's record starts at (`GRASS_SURFACE.js`).
24
+ * - `grass_height_key`: a height as a word that orders as the height does, so that an atomic minimum or
25
+ * maximum of keys is one of heights. Every finite height has a key above zero and under the highest word.
26
+ * - `grass_height_of_key`: the height a key was made of.
27
+ *
28
+ * @type {CodeChunk}
29
+ */
30
+ export const chunk_grass_slot = CodeChunk.from(
31
+ //language=WGSL
32
+ `
33
+ const GRASS_SLOT_NONE: u32 = ${GRASS_SLOT_NONE}u;
34
+
35
+ fn grass_slot_record(slot: u32) -> u32 {
36
+ return ${GRASS_POOL_HEADER_WORDS}u + slot * ${GRASS_SLOT_WORDS}u;
37
+ }
38
+
39
+ fn grass_height_key(height: f32) -> u32 {
40
+ let bits = bitcast<u32>(height);
41
+
42
+ // a float's bits order as its magnitude: the sign bit is flipped for those at or above zero, every bit for those below
43
+ return bits ^ select(0x80000000u, 0xFFFFFFFFu, (bits & 0x80000000u) != 0u);
44
+ }
45
+
46
+ fn grass_height_of_key(key: u32) -> f32 {
47
+ return bitcast<f32>(key ^ select(0xFFFFFFFFu, 0x80000000u, (key & 0x80000000u) != 0u));
48
+ }
49
+ `
50
+ );
@@ -0,0 +1,21 @@
1
+ /**
2
+ * A grass surface's frame: where its `transforms` row is and how it is turned. The row's scale is not part
3
+ * of the frame, so a frame's units are the world's and a surface's lattice keeps its spacing whatever its
4
+ * entity's scale.
5
+ *
6
+ * ```wgsl
7
+ * fn grass_surface_frame(global: mat4x4<f32>) -> mat4x4<f32>
8
+ * fn grass_world_to_frame(frame: mat4x4<f32>, position: vec3<f32>) -> vec3<f32>
9
+ * fn grass_world_direction_to_frame(frame: mat4x4<f32>, direction: vec3<f32>) -> vec3<f32>
10
+ * ```
11
+ *
12
+ * - `grass_surface_frame`: the frame of a row whose world matrix is `global`, frame to world. Its second
13
+ * column is the frame's up axis, unit length. The matrix must not shear.
14
+ * - `grass_world_to_frame`: a world point in the frame.
15
+ * - `grass_world_direction_to_frame`: a world direction in the frame, its length kept.
16
+ *
17
+ * @type {CodeChunk}
18
+ */
19
+ export const chunk_grass_surface_frame: CodeChunk;
20
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
21
+ //# sourceMappingURL=chunk_grass_surface_frame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_grass_surface_frame.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/surface/chunk_grass_surface_frame.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,wCAFU,SAAS,CAsBjB;0BAxCwB,oCAAoC"}
@@ -0,0 +1,41 @@
1
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
+
3
+ /**
4
+ * A grass surface's frame: where its `transforms` row is and how it is turned. The row's scale is not part
5
+ * of the frame, so a frame's units are the world's and a surface's lattice keeps its spacing whatever its
6
+ * entity's scale.
7
+ *
8
+ * ```wgsl
9
+ * fn grass_surface_frame(global: mat4x4<f32>) -> mat4x4<f32>
10
+ * fn grass_world_to_frame(frame: mat4x4<f32>, position: vec3<f32>) -> vec3<f32>
11
+ * fn grass_world_direction_to_frame(frame: mat4x4<f32>, direction: vec3<f32>) -> vec3<f32>
12
+ * ```
13
+ *
14
+ * - `grass_surface_frame`: the frame of a row whose world matrix is `global`, frame to world. Its second
15
+ * column is the frame's up axis, unit length. The matrix must not shear.
16
+ * - `grass_world_to_frame`: a world point in the frame.
17
+ * - `grass_world_direction_to_frame`: a world direction in the frame, its length kept.
18
+ *
19
+ * @type {CodeChunk}
20
+ */
21
+ export const chunk_grass_surface_frame = CodeChunk.from(
22
+ //language=WGSL
23
+ `
24
+ fn grass_surface_frame(global: mat4x4<f32>) -> mat4x4<f32> {
25
+ return mat4x4<f32>(
26
+ vec4<f32>(normalize(global[0].xyz), 0.0),
27
+ vec4<f32>(normalize(global[1].xyz), 0.0),
28
+ vec4<f32>(normalize(global[2].xyz), 0.0),
29
+ vec4<f32>(global[3].xyz, 1.0),
30
+ );
31
+ }
32
+
33
+ fn grass_world_direction_to_frame(frame: mat4x4<f32>, direction: vec3<f32>) -> vec3<f32> {
34
+ return vec3<f32>(dot(frame[0].xyz, direction), dot(frame[1].xyz, direction), dot(frame[2].xyz, direction));
35
+ }
36
+
37
+ fn grass_world_to_frame(frame: mat4x4<f32>, position: vec3<f32>) -> vec3<f32> {
38
+ return grass_world_direction_to_frame(frame, position - frame[3].xyz);
39
+ }
40
+ `
41
+ );
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Which tiles of a level of a grass surface a view may want.
3
+ *
4
+ * ```wgsl
5
+ * fn grass_level_ring(view: GrassSurfaceViewSettings, level: u32, blade_length: f32) -> vec2<f32>
6
+ * fn grass_surface_window(view: GrassSurfaceViewSettings, surface: GrassSurfaceRecord, level: u32, eye: vec3<f32>) -> GrassWindow
7
+ * fn grass_tile_box(view: GrassSurfaceViewSettings, surface: GrassSurfaceRecord, level: u32, tile: vec2<i32>) -> GrassTileBox
8
+ * fn grass_tile_wanted(view: GrassSurfaceViewSettings, surface: GrassSurfaceRecord, level: u32, box: GrassTileBox, eye: vec3<f32>) -> bool
9
+ * ```
10
+ *
11
+ * **A level's ring.** Level `l` serves the distances from a view at which its spacing spans no more than
12
+ * the narrowest blade's width in pixels and the level below's spans more: from
13
+ * `finest_spacing * focal / narrowest_blade * 2^(l-1)` (0 for level 0) out to twice that. No level serves
14
+ * past the distance where a blade of `blade_length` spans `shortest_blade` pixels.
15
+ * `grass_level_ring` answers `(inner, outer)`; a level with no ring answers `inner >= outer`.
16
+ *
17
+ * **A level's window.** `grass_surface_window` is the block of the level's tiles that can hold a wanted
18
+ * one: `size` tiles from `corner` on the frame's x and z, a size of zero for none. `eye` is the view's
19
+ * position in the surface's frame. It is the level's reach about the eye, clipped to the surface's box, so
20
+ * a window is never more than `2 * focal / (narrowest_blade * GRASS_TILE_COLUMNS) + 2` tiles a side.
21
+ *
22
+ * **A tile's box.** `grass_tile_box` is where a tile's grass can be, in the frame: the tile's square cut to
23
+ * the surface's box, through the surface's height and a blade over it.
24
+ *
25
+ * **A wanted tile.** `grass_tile_wanted` is whether a tile of the window is in the level's ring: some of
26
+ * its box is nearer than the ring's outside, and some is not nearer than its inside.
27
+ *
28
+ * @type {CodeChunk}
29
+ */
30
+ export const chunk_grass_surface_window: CodeChunk;
31
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
32
+ //# sourceMappingURL=chunk_grass_surface_window.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_grass_surface_window.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/surface/chunk_grass_surface_window.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,yCAFU,SAAS,CAwGjB;0BAvIwB,oCAAoC"}
@@ -0,0 +1,136 @@
1
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
2
+ import { chunk_grass_tile } from "./chunk_grass_tile.js";
3
+ import { GRASS_SURFACE_RECORD_STRUCT, GRASS_SURFACE_VIEW_SETTINGS } from "./GRASS_SURFACE_VIEW.js";
4
+
5
+ /**
6
+ * Which tiles of a level of a grass surface a view may want.
7
+ *
8
+ * ```wgsl
9
+ * fn grass_level_ring(view: GrassSurfaceViewSettings, level: u32, blade_length: f32) -> vec2<f32>
10
+ * fn grass_surface_window(view: GrassSurfaceViewSettings, surface: GrassSurfaceRecord, level: u32, eye: vec3<f32>) -> GrassWindow
11
+ * fn grass_tile_box(view: GrassSurfaceViewSettings, surface: GrassSurfaceRecord, level: u32, tile: vec2<i32>) -> GrassTileBox
12
+ * fn grass_tile_wanted(view: GrassSurfaceViewSettings, surface: GrassSurfaceRecord, level: u32, box: GrassTileBox, eye: vec3<f32>) -> bool
13
+ * ```
14
+ *
15
+ * **A level's ring.** Level `l` serves the distances from a view at which its spacing spans no more than
16
+ * the narrowest blade's width in pixels and the level below's spans more: from
17
+ * `finest_spacing * focal / narrowest_blade * 2^(l-1)` (0 for level 0) out to twice that. No level serves
18
+ * past the distance where a blade of `blade_length` spans `shortest_blade` pixels.
19
+ * `grass_level_ring` answers `(inner, outer)`; a level with no ring answers `inner >= outer`.
20
+ *
21
+ * **A level's window.** `grass_surface_window` is the block of the level's tiles that can hold a wanted
22
+ * one: `size` tiles from `corner` on the frame's x and z, a size of zero for none. `eye` is the view's
23
+ * position in the surface's frame. It is the level's reach about the eye, clipped to the surface's box, so
24
+ * a window is never more than `2 * focal / (narrowest_blade * GRASS_TILE_COLUMNS) + 2` tiles a side.
25
+ *
26
+ * **A tile's box.** `grass_tile_box` is where a tile's grass can be, in the frame: the tile's square cut to
27
+ * the surface's box, through the surface's height and a blade over it.
28
+ *
29
+ * **A wanted tile.** `grass_tile_wanted` is whether a tile of the window is in the level's ring: some of
30
+ * its box is nearer than the ring's outside, and some is not nearer than its inside.
31
+ *
32
+ * @type {CodeChunk}
33
+ */
34
+ export const chunk_grass_surface_window = CodeChunk.from(
35
+ //language=WGSL
36
+ `
37
+ struct GrassWindow {
38
+ // the window's lowest tile on the frame's x and z, in tiles of the level
39
+ corner: vec2<i32>,
40
+ // tiles along each
41
+ size: vec2<u32>,
42
+ }
43
+
44
+ fn grass_level_ring(view: ${GRASS_SURFACE_VIEW_SETTINGS.wgsl_ref}, level: u32, blade_length: f32) -> vec2<f32> {
45
+ let finest_reach = view.finest_spacing * view.focal / view.narrowest_blade;
46
+ let blade_reach = blade_length * view.focal / view.shortest_blade;
47
+
48
+ let outer = min(ldexp(finest_reach, i32(level)), blade_reach);
49
+ let inner = select(min(ldexp(finest_reach, i32(level) - 1), blade_reach), 0.0, level == 0u);
50
+
51
+ return vec2<f32>(inner, outer);
52
+ }
53
+
54
+ fn grass_surface_window(
55
+ view: ${GRASS_SURFACE_VIEW_SETTINGS.wgsl_ref},
56
+ surface: ${GRASS_SURFACE_RECORD_STRUCT.wgsl_ref},
57
+ level: u32,
58
+ eye: vec3<f32>,
59
+ ) -> GrassWindow {
60
+ var window: GrassWindow;
61
+
62
+ let ring = grass_level_ring(view, level, surface.blade_length);
63
+
64
+ if (ring.x >= ring.y) {
65
+ return window;
66
+ }
67
+
68
+ // how far over or under the surface's slab the eye is
69
+ let clear = max(max(surface.low.y - eye.y, eye.y - (surface.high.y + surface.blade_length)), 0.0);
70
+
71
+ if (clear >= ring.y) {
72
+ return window;
73
+ }
74
+
75
+ let low = max(surface.low.xz, eye.xz - ring.y);
76
+ let high = min(surface.high.xz, eye.xz + ring.y);
77
+
78
+ if (low.x > high.x || low.y > high.y) {
79
+ return window;
80
+ }
81
+
82
+ let spacing = grass_level_spacing(view.finest_spacing, level);
83
+
84
+ let first = grass_tile_of_position(low, spacing);
85
+ let last = grass_tile_of_position(high, spacing);
86
+
87
+ window.corner = first;
88
+ window.size = vec2<u32>(last - first) + 1u;
89
+
90
+ return window;
91
+ }
92
+
93
+ struct GrassTileBox {
94
+ low: vec3<f32>,
95
+ high: vec3<f32>,
96
+ }
97
+
98
+ fn grass_tile_box(
99
+ view: ${GRASS_SURFACE_VIEW_SETTINGS.wgsl_ref},
100
+ surface: ${GRASS_SURFACE_RECORD_STRUCT.wgsl_ref},
101
+ level: u32,
102
+ tile: vec2<i32>,
103
+ ) -> GrassTileBox {
104
+ let edge = grass_level_spacing(view.finest_spacing, level) * f32(GRASS_TILE_COLUMNS);
105
+
106
+ let corner = vec2<f32>(tile) * edge;
107
+
108
+ let low = max(corner, surface.low.xz);
109
+ let high = min(corner + edge, surface.high.xz);
110
+
111
+ return GrassTileBox(
112
+ vec3<f32>(low.x, surface.low.y, low.y),
113
+ vec3<f32>(high.x, surface.high.y + surface.blade_length, high.y),
114
+ );
115
+ }
116
+
117
+ fn grass_tile_wanted(
118
+ view: ${GRASS_SURFACE_VIEW_SETTINGS.wgsl_ref},
119
+ surface: ${GRASS_SURFACE_RECORD_STRUCT.wgsl_ref},
120
+ level: u32,
121
+ box: GrassTileBox,
122
+ eye: vec3<f32>,
123
+ ) -> bool {
124
+ let ring = grass_level_ring(view, level, surface.blade_length);
125
+
126
+ let nearest = length(max(max(box.low - eye, eye - box.high), vec3<f32>(0.0)));
127
+ let farthest = length(max(abs(box.low - eye), abs(box.high - eye)));
128
+
129
+ return nearest < ring.y && farthest >= ring.x;
130
+ }
131
+ `, [
132
+ GRASS_SURFACE_VIEW_SETTINGS.declaration_chunk,
133
+ GRASS_SURFACE_RECORD_STRUCT.declaration_chunk,
134
+ chunk_grass_tile,
135
+ ]
136
+ );
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Texture format of a surfel: four words, one texel.
3
+ * @type {GPUTextureFormat}
4
+ */
5
+ export const GRASS_SURFEL_FORMAT: GPUTextureFormat;
6
+ /**
7
+ * A surfel of a grass surface: one point of ground a blade can stand on, and what a blade needs of it.
8
+ *
9
+ * A surfel sits on a column of its surface's lattice, so where it is across the surface is its place in
10
+ * its tile; the record holds only where it is along the surface frame's up axis.
11
+ *
12
+ * ```wgsl
13
+ * struct GrassSurfel {
14
+ * height: f32, // along the surface frame's up axis, in the frame's units
15
+ * normal: vec3<f32>, // unit, in the surface's frame
16
+ * member: u32, // the meshes row of the member it lies on
17
+ * clear_height: f32, // open air over it; GRASS_CLEAR_HEIGHT_OPEN and above mean open sky
18
+ * density: f32, // painted density, 0 to 1
19
+ * }
20
+ *
21
+ * fn grass_surfel_pack(surfel: GrassSurfel) -> vec4<u32>
22
+ * fn grass_surfel_unpack(texel: vec4<u32>) -> GrassSurfel
23
+ * fn grass_surfel_exists(texel: vec4<u32>) -> bool
24
+ * ```
25
+ *
26
+ * A texel is `(height bits, normal, member, clear height | density << 16)`: the normal in the vertex-normal
27
+ * format, the clear height a half float, the density a 16-bit unorm. `height` and `member` round-trip
28
+ * exactly. A clear height must be in `[0, GRASS_CLEAR_HEIGHT_OPEN]`.
29
+ *
30
+ * Row 0 of the scene's tables is its root and never a mesh, so a member of 0 is no surfel: a cleared
31
+ * texel holds none, which is what `grass_surfel_exists` asks.
32
+ *
33
+ * @type {CodeChunk}
34
+ */
35
+ export const chunk_grass_surfel: CodeChunk;
36
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
37
+ //# sourceMappingURL=chunk_grass_surfel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_grass_surfel.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/grass/surface/chunk_grass_surfel.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH,mDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,iCAFU,SAAS,CA8CjB;0BAlFwB,oCAAoC"}