@woosh/meep-engine 3.59.0 → 3.60.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 (326) hide show
  1. package/package.json +1 -1
  2. package/src/shade/playground/probe_clipmap/index.html +12 -0
  3. package/src/shade/playground/probe_clipmap/main.d.ts.map +1 -1
  4. package/src/shade/playground/probe_clipmap/main.js +5 -0
  5. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  6. package/src/shade/renderer/Renderer.js +4 -6
  7. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts +63 -1
  8. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.d.ts.map +1 -1
  9. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.js +228 -16
  10. package/src/shade/renderer/geometry/sdf/cards/GPUMeshCardSets.d.ts +27 -4
  11. package/src/shade/renderer/geometry/sdf/cards/GPUMeshCardSets.d.ts.map +1 -1
  12. package/src/shade/renderer/geometry/sdf/cards/GPUMeshCardSets.js +526 -23
  13. package/src/shade/renderer/geometry/sdf/cards/MeshCardCaptureMode.d.ts +11 -0
  14. package/src/shade/renderer/geometry/sdf/cards/MeshCardCaptureMode.d.ts.map +1 -0
  15. package/src/shade/renderer/geometry/sdf/cards/MeshCardCaptureMode.js +21 -0
  16. package/src/shade/renderer/geometry/sdf/cards/mesh_cards_raster_pass_descriptor.d.ts +65 -0
  17. package/src/shade/renderer/geometry/sdf/cards/mesh_cards_raster_pass_descriptor.d.ts.map +1 -0
  18. package/src/shade/renderer/geometry/sdf/cards/mesh_cards_raster_pass_descriptor.js +376 -0
  19. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_capture.d.ts +7 -3
  20. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_capture.d.ts.map +1 -1
  21. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_capture.js +70 -6
  22. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_args.d.ts +20 -0
  23. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_args.d.ts.map +1 -0
  24. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_args.js +80 -0
  25. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_scatter.d.ts +18 -0
  26. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_scatter.d.ts.map +1 -0
  27. package/src/shade/renderer/geometry/sdf/cards/shader_mesh_cards_raster_scatter.js +113 -0
  28. package/src/shade/renderer/geometry/virtual/sdf/VGEO_SDF.d.ts +47 -0
  29. package/src/shade/renderer/geometry/virtual/sdf/VGEO_SDF.d.ts.map +1 -0
  30. package/src/shade/renderer/geometry/virtual/sdf/VGEO_SDF.js +80 -0
  31. package/src/shade/renderer/geometry/virtual/sdf/VGeoSDFProxies.d.ts +91 -0
  32. package/src/shade/renderer/geometry/virtual/sdf/VGeoSDFProxies.d.ts.map +1 -0
  33. package/src/shade/renderer/geometry/virtual/sdf/VGeoSDFProxies.js +902 -0
  34. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_collect.d.ts +16 -0
  35. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_collect.d.ts.map +1 -0
  36. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_collect.js +67 -0
  37. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_decode.d.ts +17 -0
  38. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_decode.d.ts.map +1 -0
  39. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_decode.js +145 -0
  40. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_traverse.d.ts +12 -0
  41. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_traverse.d.ts.map +1 -0
  42. package/src/shade/renderer/geometry/virtual/sdf/shader_vgeo_sdf_traverse.js +105 -0
  43. package/src/shade/renderer/global_illumination/probe/octahedral/shader_lpv_build_gbuffer.d.ts.map +1 -1
  44. package/src/shade/renderer/global_illumination/probe/octahedral/shader_lpv_build_gbuffer.js +2 -1
  45. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +3 -9
  46. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts.map +1 -1
  47. package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.js +13 -31
  48. package/src/shade/renderer/global_illumination/probe_clipmap/PROBE_CLIPMAP_PROPOSAL_2026_10_27.md +764 -48
  49. package/src/shade/renderer/global_illumination/probe_clipmap/PROBE_RAYS_VARIABLE_AND_SORTED_SCOPE_2026_10_30.md +410 -0
  50. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.d.ts +3 -2
  51. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.d.ts.map +1 -1
  52. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.js +4 -3
  53. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts +41 -17
  54. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts.map +1 -1
  55. package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.js +57 -33
  56. package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_CLIPMAP.d.ts +11 -3
  57. package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_CLIPMAP.d.ts.map +1 -1
  58. package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_CLIPMAP.js +13 -4
  59. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts +9 -18
  60. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.d.ts.map +1 -1
  61. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUBrickClipmap.js +8 -10
  62. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.d.ts +12 -0
  63. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.d.ts.map +1 -1
  64. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap.js +28 -0
  65. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +1 -29
  66. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
  67. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +1 -74
  68. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK.d.ts +161 -0
  69. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK.d.ts.map +1 -0
  70. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK.js +219 -0
  71. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK_INSTANCE_STRUCT.d.ts +1 -8
  72. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK_INSTANCE_STRUCT.d.ts.map +1 -1
  73. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MESH_BRICK_INSTANCE_STRUCT.js +1 -9
  74. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MeshSDFBrickProvider.d.ts +40 -12
  75. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MeshSDFBrickProvider.d.ts.map +1 -1
  76. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/MeshSDFBrickProvider.js +373 -31
  77. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_instance.d.ts +2 -1
  78. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_instance.d.ts.map +1 -1
  79. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_instance.js +2 -1
  80. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_texel.d.ts +15 -8
  81. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_texel.d.ts.map +1 -1
  82. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_texel.js +28 -14
  83. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.d.ts +23 -0
  84. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.d.ts.map +1 -0
  85. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_walk.js +66 -0
  86. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_batch.d.ts +29 -0
  87. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_batch.d.ts.map +1 -0
  88. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_batch.js +210 -0
  89. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_command.d.ts +29 -0
  90. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_command.d.ts.map +1 -0
  91. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_command.js +86 -0
  92. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.d.ts +41 -0
  93. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.d.ts.map +1 -0
  94. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_gather.js +439 -0
  95. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_resolve.d.ts +23 -0
  96. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_resolve.d.ts.map +1 -0
  97. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_resolve.js +135 -0
  98. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_free.d.ts +3 -1
  99. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_free.d.ts.map +1 -1
  100. package/src/shade/renderer/global_illumination/probe_clipmap/brick/shader_brick_clipmap_free.js +12 -3
  101. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts +21 -18
  102. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.d.ts.map +1 -1
  103. package/src/shade/renderer/global_illumination/probe_clipmap/probe/GPUProbeClipmap.js +254 -73
  104. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts +149 -8
  105. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.d.ts.map +1 -1
  106. package/src/shade/renderer/global_illumination/probe_clipmap/probe/PROBE_CLIPMAP.js +181 -13
  107. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts +179 -7
  108. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.d.ts.map +1 -1
  109. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap.js +412 -31
  110. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_pick.js +4 -4
  111. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.d.ts.map +1 -1
  112. package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_sample_radiance.js +4 -3
  113. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts +36 -10
  114. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.d.ts.map +1 -1
  115. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_accumulate.js +218 -29
  116. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.d.ts +5 -1
  117. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.d.ts.map +1 -1
  118. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_admit.js +24 -14
  119. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts +15 -6
  120. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.d.ts.map +1 -1
  121. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_due.js +21 -22
  122. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_guide.d.ts +36 -0
  123. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_guide.d.ts.map +1 -0
  124. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_guide.js +257 -0
  125. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts +18 -7
  126. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts.map +1 -1
  127. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.js +157 -51
  128. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_order.d.ts +23 -0
  129. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_order.d.ts.map +1 -0
  130. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_order.js +110 -0
  131. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts +24 -2
  132. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.d.ts.map +1 -1
  133. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_project.js +90 -10
  134. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.d.ts +45 -0
  135. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.d.ts.map +1 -0
  136. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_ray_layout.js +205 -0
  137. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_relocate.js +1 -1
  138. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_retire.d.ts +16 -3
  139. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_retire.d.ts.map +1 -1
  140. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_retire.js +55 -10
  141. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.d.ts +19 -4
  142. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.d.ts.map +1 -1
  143. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_schedule.js +60 -6
  144. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.d.ts +4 -8
  145. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.d.ts.map +1 -1
  146. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_shade.js +21 -36
  147. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts +21 -14
  148. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts.map +1 -1
  149. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.js +100 -30
  150. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.d.ts +6 -2
  151. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.d.ts.map +1 -1
  152. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace_command.js +26 -10
  153. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.d.ts +3 -2
  154. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.d.ts.map +1 -1
  155. package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_want_hits.js +12 -12
  156. package/src/shade/renderer/gpu_primitive/sort/SORT_DIGIT_SETTINGS_STRUCT.d.ts +10 -0
  157. package/src/shade/renderer/gpu_primitive/sort/SORT_DIGIT_SETTINGS_STRUCT.d.ts.map +1 -0
  158. package/src/shade/renderer/gpu_primitive/sort/SORT_DIGIT_SETTINGS_STRUCT.js +21 -0
  159. package/src/shade/renderer/gpu_primitive/sort/SORT_PASS_SETTINGS_STRUCT.d.ts +5 -2
  160. package/src/shade/renderer/gpu_primitive/sort/SORT_PASS_SETTINGS_STRUCT.d.ts.map +1 -1
  161. package/src/shade/renderer/gpu_primitive/sort/SORT_PASS_SETTINGS_STRUCT.js +31 -23
  162. package/src/shade/renderer/gpu_primitive/sort/SORT_SIZE_STRUCT.d.ts +10 -0
  163. package/src/shade/renderer/gpu_primitive/sort/SORT_SIZE_STRUCT.d.ts.map +1 -0
  164. package/src/shade/renderer/gpu_primitive/sort/SORT_SIZE_STRUCT.js +22 -0
  165. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_constants.d.ts +9 -0
  166. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_constants.d.ts.map +1 -0
  167. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_constants.js +18 -0
  168. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_digit.d.ts +8 -3
  169. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_digit.d.ts.map +1 -1
  170. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_digit.js +41 -32
  171. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_histogram_tile.d.ts +31 -0
  172. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_histogram_tile.d.ts.map +1 -0
  173. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_histogram_tile.js +71 -0
  174. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_scatter_tile.d.ts +47 -0
  175. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_scatter_tile.d.ts.map +1 -0
  176. package/src/shade/renderer/gpu_primitive/sort/chunk_sort_scatter_tile.js +210 -0
  177. package/src/shade/renderer/gpu_primitive/sort/defs.d.ts +5 -4
  178. package/src/shade/renderer/gpu_primitive/sort/defs.d.ts.map +1 -1
  179. package/src/shade/renderer/gpu_primitive/sort/defs.js +5 -4
  180. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.d.ts +56 -15
  181. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.d.ts.map +1 -1
  182. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.js +410 -61
  183. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram.d.ts +4 -1
  184. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram.d.ts.map +1 -1
  185. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram.js +16 -42
  186. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram_indirect.d.ts +15 -0
  187. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram_indirect.d.ts.map +1 -0
  188. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_histogram_indirect.js +60 -0
  189. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_prepare.d.ts +25 -0
  190. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_prepare.d.ts.map +1 -0
  191. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_prepare.js +89 -0
  192. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter.d.ts +3 -8
  193. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter.d.ts.map +1 -1
  194. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter.js +28 -160
  195. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter_indirect.d.ts +12 -0
  196. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter_indirect.d.ts.map +1 -0
  197. package/src/shade/renderer/gpu_primitive/sort/shader_radix_sort_scatter_indirect.js +74 -0
  198. package/src/shade/renderer/gpu_primitive/sort/verify_radix_sort.d.ts +3 -1
  199. package/src/shade/renderer/gpu_primitive/sort/verify_radix_sort.d.ts.map +1 -1
  200. package/src/shade/renderer/gpu_primitive/sort/verify_radix_sort.js +387 -188
  201. package/src/shade/renderer/lightmap/bake/shader_lightmap_viz_to_irradiance_flat.js +1 -1
  202. package/src/shade/renderer/lightmap/bake/shader_lightmap_viz_to_sh.js +1 -1
  203. package/src/shade/renderer/material/resident/GPUResidentMaterialContext.d.ts.map +1 -1
  204. package/src/shade/renderer/material/resident/GPUResidentMaterialContext.js +90 -72
  205. package/src/shade/renderer/material/resident/RESIDENT_MATERIAL_TEXTURE_LAYOUT.d.ts +5 -0
  206. package/src/shade/renderer/material/resident/RESIDENT_MATERIAL_TEXTURE_LAYOUT.d.ts.map +1 -1
  207. package/src/shade/renderer/material/resident/RESIDENT_MATERIAL_TEXTURE_LAYOUT.js +9 -0
  208. package/src/shade/renderer/path_tracer/shader/INDIRECT_TEXTURE_FILTER.d.ts +13 -0
  209. package/src/shade/renderer/path_tracer/shader/INDIRECT_TEXTURE_FILTER.d.ts.map +1 -0
  210. package/src/shade/renderer/path_tracer/shader/INDIRECT_TEXTURE_FILTER.js +14 -0
  211. package/src/shade/renderer/path_tracer/shader/IndirectTextureFilter.d.ts +10 -0
  212. package/src/shade/renderer/path_tracer/shader/IndirectTextureFilter.d.ts.map +1 -0
  213. package/src/shade/renderer/path_tracer/shader/IndirectTextureFilter.js +15 -0
  214. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_tangent_normal.d.ts +4 -3
  215. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_tangent_normal.d.ts.map +1 -1
  216. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_tangent_normal.js +6 -5
  217. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture.d.ts +17 -2
  218. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture.d.ts.map +1 -1
  219. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture.js +25 -57
  220. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_exact.d.ts +13 -0
  221. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_exact.d.ts.map +1 -0
  222. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_exact.js +70 -0
  223. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_stochastic.d.ts +10 -0
  224. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_stochastic.d.ts.map +1 -0
  225. package/src/shade/renderer/path_tracer/shader/chunk_indirect_sample_texture_stochastic.js +59 -0
  226. package/src/shade/renderer/path_tracer/shader/chunk_indirect_texture_load.d.ts +12 -0
  227. package/src/shade/renderer/path_tracer/shader/chunk_indirect_texture_load.d.ts.map +1 -0
  228. package/src/shade/renderer/path_tracer/shader/chunk_indirect_texture_load.js +49 -0
  229. package/src/shade/renderer/path_tracer/shader/chunk_ray_hit_to_opacity.d.ts.map +1 -1
  230. package/src/shade/renderer/path_tracer/shader/chunk_ray_hit_to_opacity.js +1 -0
  231. package/src/shade/renderer/path_tracer/shader/chunk_render_trace_path.d.ts.map +1 -1
  232. package/src/shade/renderer/path_tracer/shader/chunk_render_trace_path.js +1 -0
  233. package/src/shade/renderer/path_tracer/shader/chunk_sample_material.d.ts.map +1 -1
  234. package/src/shade/renderer/path_tracer/shader/chunk_sample_material.js +2 -1
  235. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.d.ts +7 -0
  236. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.d.ts.map +1 -1
  237. package/src/shade/renderer/path_tracer/shader/chunk_sample_material_data.js +15 -6
  238. package/src/shade/renderer/scene/GPUSceneContext.d.ts +7 -1
  239. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  240. package/src/shade/renderer/scene/GPUSceneContext.js +26 -1
  241. package/src/shade/renderer/shader/chunk/bvh/chunk_bvh_query_aabb_cooperative.d.ts +7 -7
  242. package/src/shade/renderer/shader/chunk/bvh/chunk_bvh_query_aabb_cooperative.d.ts.map +1 -1
  243. package/src/shade/renderer/shader/chunk/bvh/chunk_bvh_query_aabb_cooperative.js +262 -294
  244. package/src/shade/renderer/shader/chunk/filter/MULTISCALE_MEAN_STRUCT.d.ts +9 -0
  245. package/src/shade/renderer/shader/chunk/filter/MULTISCALE_MEAN_STRUCT.d.ts.map +1 -0
  246. package/src/shade/renderer/shader/chunk/filter/MULTISCALE_MEAN_STRUCT.js +21 -0
  247. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts +43 -0
  248. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts.map +1 -0
  249. package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.js +87 -0
  250. package/src/shade/renderer/shader/chunk/noise/r/chunk_r2_canonical.d.ts +7 -1
  251. package/src/shade/renderer/shader/chunk/noise/r/chunk_r2_canonical.d.ts.map +1 -1
  252. package/src/shade/renderer/shader/chunk/noise/r/chunk_r2_canonical.js +1 -1
  253. package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_reserve_workgroup.d.ts +21 -0
  254. package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_reserve_workgroup.d.ts.map +1 -0
  255. package/src/shade/renderer/shader/chunk/subgroup/chunk_subgroup_reserve_workgroup.js +42 -0
  256. package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
  257. package/src/shade/wgsl/emulator/CPUBitmapData.d.ts +19 -0
  258. package/src/shade/wgsl/emulator/CPUBitmapData.d.ts.map +1 -1
  259. package/src/shade/wgsl/emulator/CPUBitmapData.js +27 -0
  260. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  261. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +39 -18
  262. package/src/view/elements/progress/segmented/GhostTrail.d.ts +56 -0
  263. package/src/view/elements/progress/segmented/GhostTrail.d.ts.map +1 -0
  264. package/src/view/elements/progress/segmented/GhostTrail.js +98 -0
  265. package/src/view/elements/progress/segmented/RESOURCE_BAR_SEGMENTS.d.ts +3 -1
  266. package/src/view/elements/progress/segmented/RESOURCE_BAR_SEGMENTS.d.ts.map +1 -1
  267. package/src/view/elements/progress/segmented/RESOURCE_BAR_SEGMENTS.js +3 -1
  268. package/src/view/elements/progress/segmented/SEGMENT_TIERS_DEFAULT.d.ts +11 -0
  269. package/src/view/elements/progress/segmented/SEGMENT_TIERS_DEFAULT.d.ts.map +1 -0
  270. package/src/view/elements/progress/segmented/SEGMENT_TIERS_DEFAULT.js +15 -0
  271. package/src/view/elements/progress/segmented/SegmentDefinition.d.ts +3 -0
  272. package/src/view/elements/progress/segmented/SegmentDefinition.d.ts.map +1 -1
  273. package/src/view/elements/progress/segmented/SegmentDefinition.js +3 -0
  274. package/src/view/elements/progress/segmented/SegmentTier.d.ts +38 -0
  275. package/src/view/elements/progress/segmented/SegmentTier.d.ts.map +1 -0
  276. package/src/view/elements/progress/segmented/SegmentTier.js +50 -0
  277. package/src/view/elements/progress/segmented/SegmentedResourceBarView.d.ts +155 -10
  278. package/src/view/elements/progress/segmented/SegmentedResourceBarView.d.ts.map +1 -1
  279. package/src/view/elements/progress/segmented/SegmentedResourceBarView.js +427 -101
  280. package/src/view/elements/progress/segmented/playground/index.html +78 -0
  281. package/src/view/elements/progress/segmented/playground/main.d.ts +2 -0
  282. package/src/view/elements/progress/segmented/playground/main.d.ts.map +1 -0
  283. package/src/view/elements/progress/segmented/playground/main.js +173 -0
  284. package/src/view/elements/progress/segmented/segment_cell_layout.d.ts +48 -0
  285. package/src/view/elements/progress/segmented/segment_cell_layout.d.ts.map +1 -0
  286. package/src/view/elements/progress/segmented/segment_cell_layout.js +75 -0
  287. package/src/view/elements/progress/segmented/segment_notch_place.d.ts +18 -0
  288. package/src/view/elements/progress/segmented/segment_notch_place.d.ts.map +1 -0
  289. package/src/view/elements/progress/segmented/segment_notch_place.js +28 -0
  290. package/src/view/elements/progress/segmented/segment_tick_positions.d.ts +32 -0
  291. package/src/view/elements/progress/segmented/segment_tick_positions.d.ts.map +1 -0
  292. package/src/view/elements/progress/segmented/segment_tick_positions.js +103 -0
  293. package/src/view/elements/progress/segmented/segmented-resource-bar.css +142 -0
  294. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_provider.d.ts +0 -35
  295. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_provider.d.ts.map +0 -1
  296. package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/shader_mesh_brick_provider.js +0 -238
  297. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/VGEO_BRICK.d.ts +0 -99
  298. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/VGEO_BRICK.d.ts.map +0 -1
  299. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/VGEO_BRICK.js +0 -139
  300. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/VGeoBrickProvider.d.ts +0 -65
  301. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/VGeoBrickProvider.d.ts.map +0 -1
  302. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/VGeoBrickProvider.js +0 -393
  303. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_box.d.ts +0 -17
  304. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_box.d.ts.map +0 -1
  305. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_box.js +0 -36
  306. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_pair.d.ts +0 -29
  307. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_pair.d.ts.map +0 -1
  308. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_pair.js +0 -108
  309. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_texel.d.ts +0 -31
  310. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_texel.d.ts.map +0 -1
  311. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_texel.js +0 -113
  312. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_triangle.d.ts +0 -36
  313. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_triangle.d.ts.map +0 -1
  314. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/chunk_vgeo_brick_triangle.js +0 -85
  315. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_distance.d.ts +0 -23
  316. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_distance.d.ts.map +0 -1
  317. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_distance.js +0 -273
  318. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_gather.d.ts +0 -13
  319. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_gather.d.ts.map +0 -1
  320. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_gather.js +0 -151
  321. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_traverse.d.ts +0 -13
  322. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_traverse.d.ts.map +0 -1
  323. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_traverse.js +0 -133
  324. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_wait.d.ts +0 -22
  325. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_wait.d.ts.map +0 -1
  326. package/src/shade/renderer/global_illumination/probe_clipmap/brick/vgeo/shader_vgeo_brick_wait.js +0 -135
@@ -4,18 +4,34 @@ import Signal from "../../../../../core/events/signal/Signal.js";
4
4
  import IdPool from "../../../../../core/IdPool.js";
5
5
  import { warn_limited } from "../../../../util/warn_limited.js";
6
6
  import { BufferDescriptor } from "../../../../descriptor/buffer/BufferDescriptor.js";
7
+ import { BindGroupDescriptor } from "../../../binding/BindGroupDescriptor.js";
8
+ import { STRUCT_UNINDEXED_DRAW_COMMAND } from "../../../gpu_primitive/indirect/STRUCT_UNINDEXED_DRAW_COMMAND.js";
7
9
  import { WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION } from "../../../gpu_primitive/indirect/WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION.js";
8
10
  import { graph_import_texture } from "../../../shader/graph/graph_import_texture.js";
9
11
  import { GPUTileAtlas2D } from "../../../texture/atlas/GPUTileAtlas2D.js";
10
12
  import { MESH_SDF_BAKE_WORKGROUP_SIZE } from "../bake/MESH_SDF_BAKE.js";
11
13
  import { MESH_CARD_PAGE_TEXELS } from "./MESH_CARDS.js";
12
14
  import { MESH_CARD_SET_STRUCT } from "./MESH_CARD_SET_STRUCT.js";
15
+ import { MeshCardCaptureMode } from "./MeshCardCaptureMode.js";
16
+ import {
17
+ MESH_CARD_RASTER_CELLS_X,
18
+ MESH_CARD_RASTER_CELLS_Y,
19
+ MESH_CARD_RASTER_DEPTH_FORMAT,
20
+ MESH_CARD_RASTER_TARGET_FORMATS,
21
+ MESH_CARDS_RASTER_IMMEDIATE_SIZE,
22
+ MESH_CARDS_RASTER_LAYOUT,
23
+ mesh_cards_raster_pass_descriptor
24
+ } from "./mesh_cards_raster_pass_descriptor.js";
13
25
  import { shader_mesh_cards_capture } from "./shader_mesh_cards_capture.js";
26
+ import { MESH_CARDS_RASTER_ARGS_WORKGROUP_SIZE, shader_mesh_cards_raster_args } from "./shader_mesh_cards_raster_args.js";
27
+ import { shader_mesh_cards_raster_scatter } from "./shader_mesh_cards_raster_scatter.js";
14
28
 
15
29
  /**
16
30
  * @typedef {import("../../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph} FrameGraph
17
31
  * @typedef {import("../../../material/ShadeMaterial.js").ShadeMaterial} ShadeMaterial
18
32
  * @typedef {import("../../../material/resident/GPUResidentMaterialContext.js").GPUResidentMaterialContext} GPUResidentMaterialContext
33
+ * @typedef {import("../../../material/GPUMaterialManager.js").GPUMaterialManager} GPUMaterialManager
34
+ * @typedef {import("../../../material/GPUMaterialContext.js").GPUMaterialContext} GPUMaterialContext
19
35
  * @typedef {import("../../../../../core/binary/allocator/OffsetAllocator.js").Allocation} Allocation
20
36
  */
21
37
 
@@ -40,6 +56,21 @@ const PAGE_THREADS = MESH_CARD_PAGE_TEXELS * MESH_CARD_PAGE_TEXELS;
40
56
  */
41
57
  export const MESH_CARD_CAPTURE_BUDGET_MAX = WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION;
42
58
 
59
+ /**
60
+ * Texels across the raster scratch, and down it at most: a frame's raster runs are packed into it in
61
+ * shelves, and one that does not fit waits for the next frame. A frame's first run always fits, at
62
+ * whatever size its region is.
63
+ * @type {number}
64
+ */
65
+ const RASTER_SCRATCH_SIDE = 2048;
66
+
67
+ /**
68
+ * The raster scratch grows in steps of this many texels a side, so a frame a little larger than the
69
+ * last does not make it again.
70
+ * @type {number}
71
+ */
72
+ const RASTER_SCRATCH_STEP = 256;
73
+
43
74
  /**
44
75
  * s_e: the largest component of a material's emissive factor, which the capture stores emissive
45
76
  * over. 0 for a material that emits nothing, or that has no emissive factor.
@@ -103,6 +134,10 @@ function grow_typed(array, length) {
103
134
  * the order they were asked for, then recaptures in the order queued. A card set's pages may span
104
135
  * frames. {@link recapture} queues a resident card set again, which reads its last capture until the
105
136
  * new one is done; a card set whose capture is under way starts it again.
137
+ *
138
+ * **Modes** ({@link capture_mode}). A traced card set is a run of pages, a thread a texel. A
139
+ * rastered one is taken whole: its cards are drawn into a region of a scratch, a cell a card, and its
140
+ * pages scattered from there into the atlas; the frame's last one may take the budget past its end.
106
141
  */
107
142
  export class GPUMeshCardSets {
108
143
 
@@ -156,12 +191,23 @@ export class GPUMeshCardSets {
156
191
  */
157
192
  #layout_pages = new Map();
158
193
 
194
+ /**
195
+ * Texels a side of each placed layout's largest card, by geometry id: the side of a raster cell.
196
+ * @type {Map<number, number>}
197
+ */
198
+ #layout_side = new Map();
199
+
159
200
  /**
160
201
  * The card sets of each geometry, by geometry id.
161
202
  * @type {Map<number, number[]>}
162
203
  */
163
204
  #sets_of_geometry = new Map();
164
205
 
206
+ /**
207
+ * @type {MeshCardCaptureMode}
208
+ */
209
+ #capture_mode = MeshCardCaptureMode.Raster;
210
+
165
211
  // ---- the queues: (id, ticket) pairs, from a head ----
166
212
 
167
213
  #queue_new = [];
@@ -195,6 +241,74 @@ export class GPUMeshCardSets {
195
241
  #bindings = {};
196
242
  #pass_data = { albedo: -1, emissive: -1 };
197
243
 
244
+ // ---- raster capture: a run a whole card set, (first scatter thread, id, region corner, cell side) ----
245
+
246
+ /** @type {GPUBuffer|null} */
247
+ #raster_runs = null;
248
+ /** @type {GPUBuffer|null} */
249
+ #raster_draws = null;
250
+ #raster_run_capacity = 0;
251
+ #raster_run_scratch = new Uint32Array(4 * 64);
252
+
253
+ /**
254
+ * The material context each of the frame's raster runs draws with.
255
+ * @type {GPUMaterialContext[]}
256
+ */
257
+ #frame_raster_materials = [];
258
+
259
+ #frame_raster_runs = 0;
260
+ #frame_raster_threads = 0;
261
+
262
+ /**
263
+ * What a frame's capture draws with, for the raster: set by {@link graph_capture}.
264
+ * @type {GPUMaterialManager|null}
265
+ */
266
+ #frame_material_contexts = null;
267
+
268
+ // the frame's shelves in the scratch
269
+ #shelf_x = 0;
270
+ #shelf_y = 0;
271
+ #shelf_height = 0;
272
+ #frame_scratch_width = 0;
273
+ #frame_scratch_height = 0;
274
+
275
+ /**
276
+ * √(diffuse albedo) and depth, emissive / s_e, then depth through the slab.
277
+ * @type {GPUTexture[]}
278
+ */
279
+ #raster_targets = [];
280
+ /** @type {GPUTextureView[]} */
281
+ #raster_views = [];
282
+ #raster_width = 0;
283
+ #raster_height = 0;
284
+
285
+ #raster_pass_descriptor = {
286
+ label: "Mesh Card Capture / Raster",
287
+ colorAttachments: MESH_CARD_RASTER_TARGET_FORMATS.map(() => ({
288
+ view: null,
289
+ loadOp: "clear",
290
+ storeOp: "store",
291
+ clearValue: [0, 0, 0, 0],
292
+ })),
293
+ depthStencilAttachment: {
294
+ view: null,
295
+ depthLoadOp: "clear",
296
+ depthStoreOp: "discard",
297
+ depthClearValue: 1,
298
+ },
299
+ };
300
+
301
+ #raster_immediate = new Uint32Array(MESH_CARDS_RASTER_IMMEDIATE_SIZE / 4);
302
+ #raster_immediate_f32 = new Float32Array(this.#raster_immediate.buffer);
303
+
304
+ #raster_args_settings = { run_count: 0 };
305
+ #raster_args_bindings = {};
306
+ #raster_scatter_settings = { run_count: 0, thread_count: 0, groups_x: 0 };
307
+ #raster_scatter_bindings = {};
308
+ #raster_pass_data = { arena: -1, albedo: -1, emissive: -1 };
309
+ /** The buffers group 1 of the draws binds beside the arena, as the frame's capture was recorded. */
310
+ #raster_group_buffers = { mesh_sdf_headers: null, geometries: null, meshlet_metadata: null, meshlet_data: null };
311
+
198
312
  /** Card sets turned resident by the frame's capture, sent once it is recorded. */
199
313
  #completed = [];
200
314
 
@@ -283,6 +397,37 @@ export class GPUMeshCardSets {
283
397
  return pages;
284
398
  }
285
399
 
400
+ /**
401
+ * @returns {MeshCardCaptureMode}
402
+ */
403
+ get capture_mode() {
404
+ return this.#capture_mode;
405
+ }
406
+
407
+ /**
408
+ * A change captures every card set again in the new mode: resident ones read their last capture
409
+ * until it is done, and captures under way start again.
410
+ *
411
+ * @param {MeshCardCaptureMode} mode
412
+ */
413
+ set capture_mode(mode) {
414
+ assert.enum(mode, MeshCardCaptureMode, 'mode');
415
+
416
+ if (mode === this.#capture_mode) {
417
+ return;
418
+ }
419
+
420
+ this.#capture_mode = mode;
421
+
422
+ for (let id = 0; id < this.#state.length; id++) {
423
+ const state = this.#state[id];
424
+
425
+ if (state === SET_CAPTURING || state === SET_RESIDENT) {
426
+ this.recapture(id);
427
+ }
428
+ }
429
+ }
430
+
286
431
  /**
287
432
  * Whether readers may use the card set: captured at least once, and its layout still there.
288
433
  *
@@ -423,11 +568,15 @@ export class GPUMeshCardSets {
423
568
  *
424
569
  * @param {number} geometry
425
570
  * @param {number} pages
571
+ * @param {number} side texels a side of the layout's largest card: its grid's longest axis in
572
+ * voxels, plus one, the lattice having a point at either end
426
573
  */
427
- set_layout(geometry, pages) {
574
+ set_layout(geometry, pages, side) {
428
575
  assert.isNonNegativeInteger(pages, 'pages');
576
+ assert.isPositiveInteger(side, 'side');
429
577
 
430
578
  this.#layout_pages.set(geometry, pages);
579
+ this.#layout_side.set(geometry, side);
431
580
 
432
581
  const sets = this.#sets_of_geometry.get(geometry);
433
582
 
@@ -452,6 +601,8 @@ export class GPUMeshCardSets {
452
601
  return;
453
602
  }
454
603
 
604
+ this.#layout_side.delete(geometry);
605
+
455
606
  const sets = this.#sets_of_geometry.get(geometry);
456
607
 
457
608
  if (sets === undefined) {
@@ -586,6 +737,14 @@ export class GPUMeshCardSets {
586
737
  this.#frame_threads = 0;
587
738
  this.#frame_left = budget;
588
739
 
740
+ this.#frame_raster_runs = 0;
741
+ this.#frame_raster_threads = 0;
742
+ this.#shelf_x = 0;
743
+ this.#shelf_y = 0;
744
+ this.#shelf_height = 0;
745
+ this.#frame_scratch_width = 0;
746
+ this.#frame_scratch_height = 0;
747
+
589
748
  this.#head_new = this.#compact(this.#queue_new, this.#take_from(this.#queue_new, this.#head_new));
590
749
  this.#head_re = this.#compact(this.#queue_re, this.#take_from(this.#queue_re, this.#head_re));
591
750
 
@@ -610,6 +769,24 @@ export class GPUMeshCardSets {
610
769
  }
611
770
 
612
771
  const pages = this.#layout_pages.get(this.#geometry[id]);
772
+
773
+ if (this.#capture_mode === MeshCardCaptureMode.Raster) {
774
+ // a context is made with its bind group
775
+ const material = this.#frame_material_contexts.obtain(this.#material[id]);
776
+
777
+ if (material.template.surface !== null) {
778
+ if (!this.#take_raster(id, pages, material)) {
779
+ // the frame's scratch is full: next frame
780
+ return head;
781
+ }
782
+
783
+ head += 2;
784
+ continue;
785
+ }
786
+
787
+ // a template that cannot be drawn this way is traced
788
+ }
789
+
613
790
  const first = this.#next_page[id];
614
791
  const count = Math.min(pages - first, this.#frame_left);
615
792
 
@@ -648,6 +825,79 @@ export class GPUMeshCardSets {
648
825
  return head;
649
826
  }
650
827
 
828
+ /**
829
+ * Take a whole card set into the frame's raster runs, if its region fits the frame's scratch.
830
+ *
831
+ * @param {number} id
832
+ * @param {number} pages its layout's
833
+ * @param {GPUMaterialContext} material what its draw binds
834
+ * @returns {boolean} whether it was taken
835
+ */
836
+ #take_raster(id, pages, material) {
837
+ const side = this.#layout_side.get(this.#geometry[id]);
838
+ const corner = this.#place_region(MESH_CARD_RASTER_CELLS_X * side, MESH_CARD_RASTER_CELLS_Y * side);
839
+
840
+ if (corner === -1) {
841
+ return false;
842
+ }
843
+
844
+ this.#write_record(id);
845
+
846
+ const runs = this.#frame_raster_runs;
847
+
848
+ this.#raster_run_scratch = grow_typed(this.#raster_run_scratch, 4 * (runs + 1));
849
+ this.#raster_run_scratch[4 * runs] = this.#frame_raster_threads;
850
+ this.#raster_run_scratch[4 * runs + 1] = id;
851
+ this.#raster_run_scratch[4 * runs + 2] = corner;
852
+ this.#raster_run_scratch[4 * runs + 3] = side;
853
+
854
+ this.#frame_raster_materials[runs] = material;
855
+
856
+ this.#frame_raster_runs = runs + 1;
857
+ this.#frame_raster_threads += pages * PAGE_THREADS;
858
+ this.#frame_left -= pages;
859
+
860
+ this.#next_page[id] = 0;
861
+ this.#queued[id] = 0;
862
+
863
+ if (this.#state[id] === SET_CAPTURING) {
864
+ this.#turn_resident(id);
865
+ }
866
+
867
+ return true;
868
+ }
869
+
870
+ /**
871
+ * A corner for a region in the frame's scratch, shelf by shelf.
872
+ *
873
+ * @param {number} width
874
+ * @param {number} height
875
+ * @returns {number} the corner as x | y << 16, or -1 when the region must wait for the next frame
876
+ */
877
+ #place_region(width, height) {
878
+ if (this.#shelf_x > 0 && this.#shelf_x + width > RASTER_SCRATCH_SIDE) {
879
+ this.#shelf_y += this.#shelf_height;
880
+ this.#shelf_x = 0;
881
+ this.#shelf_height = 0;
882
+ }
883
+
884
+ const fits = this.#shelf_x + width <= RASTER_SCRATCH_SIDE && this.#shelf_y + height <= RASTER_SCRATCH_SIDE;
885
+
886
+ if (!fits && this.#frame_raster_runs > 0) {
887
+ return -1;
888
+ }
889
+
890
+ const corner = this.#shelf_x | (this.#shelf_y << 16);
891
+
892
+ this.#shelf_x += width;
893
+ this.#shelf_height = Math.max(this.#shelf_height, height);
894
+
895
+ this.#frame_scratch_width = Math.max(this.#frame_scratch_width, this.#shelf_x);
896
+ this.#frame_scratch_height = Math.max(this.#frame_scratch_height, this.#shelf_y + height);
897
+
898
+ return corner;
899
+ }
900
+
651
901
  /**
652
902
  * Drop a queue's taken entries once they are most of it.
653
903
  *
@@ -680,45 +930,99 @@ export class GPUMeshCardSets {
680
930
  * @param {number} options.budget pages captured at most, `card_capture_budget`
681
931
  * @param {number} options.arena graph handle of the arena, as the frame's bake left it
682
932
  * @param {GPUBuffer} options.headers
683
- * @param {GPUResidentMaterialContext} options.materials
684
- * @param {Object} options.blas the geometry bindings `ray_query_blas_nearest` reads
933
+ * @param {GPUResidentMaterialContext} options.materials what the trace shades with
934
+ * @param {GPUMaterialManager} options.material_contexts what the raster draws with: each
935
+ * material's template and bind group
936
+ * @param {Object} options.blas the geometry bindings `ray_query_blas_nearest` reads, whose
937
+ * geometry and meshlet buffers the raster pulls vertices from
685
938
  */
686
- graph_capture({ graph, budget, arena, headers, materials, blas }) {
939
+ graph_capture({ graph, budget, arena, headers, materials, material_contexts, blas }) {
687
940
  assert.defined(graph, 'graph');
688
941
  assert.isPositiveInteger(budget, 'budget');
689
942
  assert.lessThanOrEqual(budget, MESH_CARD_CAPTURE_BUDGET_MAX, 'budget');
690
943
 
944
+ if (this.#capture_mode === MeshCardCaptureMode.Raster) {
945
+ assert.notNull(material_contexts, 'material_contexts');
946
+ assert.defined(material_contexts, 'material_contexts');
947
+ }
948
+
949
+ this.#frame_material_contexts = material_contexts;
950
+
691
951
  this.#take(budget);
692
952
 
953
+ this.#frame_material_contexts = null;
954
+
693
955
  const completed = this.#completed;
694
956
 
695
- if (this.#frame_runs > 0) {
957
+ if (this.#frame_runs > 0 || this.#frame_raster_runs > 0) {
696
958
  this.#ensure_device();
697
- this.#ensure_runs(this.#frame_runs);
698
959
 
699
- this.#device.queue.writeBuffer(this.#runs, 0, this.#run_scratch, 0, 4 * this.#frame_runs);
960
+ let albedo = graph_import_texture(graph, this.#atlas.texture_at(0), "mesh_card_albedo");
961
+ let emissive = graph_import_texture(graph, this.#atlas.texture_at(1), "mesh_card_emissive");
962
+
963
+ if (this.#frame_runs > 0) {
964
+ this.#ensure_runs(this.#frame_runs);
965
+
966
+ this.#device.queue.writeBuffer(this.#runs, 0, this.#run_scratch, 0, 4 * this.#frame_runs);
967
+
968
+ const data = this.#pass_data;
969
+ const pass = graph.add("Mesh Card Capture", data, this.#execute);
970
+
971
+ pass.read(arena);
972
+
973
+ data.arena = arena;
974
+ albedo = data.albedo = pass.write(albedo);
975
+ emissive = data.emissive = pass.write(emissive);
976
+
977
+ pass.make_side_effect();
978
+
979
+ const b = this.#bindings;
980
+
981
+ b.mesh_sdf_headers = headers;
982
+ b.materials = materials.buffer_materials;
983
+ b.textures = materials.textureView;
984
+ b.blas_lookup = blas.blas_lookup;
985
+ b.blas_data = blas.blas_data;
986
+ b.geometries = blas.geometries;
987
+ b.meshlet_metadata = blas.meshlet_metadata;
988
+ b.meshlet_data = blas.meshlet_data;
989
+ }
990
+
991
+ if (this.#frame_raster_runs > 0) {
992
+ const runs = this.#frame_raster_runs;
993
+
994
+ this.#ensure_raster_runs(runs);
995
+ this.#ensure_raster_scratch(this.#frame_scratch_width, this.#frame_scratch_height);
700
996
 
701
- const data = this.#pass_data;
702
- const pass = graph.add("Mesh Card Capture", data, this.#execute);
997
+ this.#device.queue.writeBuffer(this.#raster_runs, 0, this.#raster_run_scratch, 0, 4 * runs);
703
998
 
704
- pass.read(arena);
999
+ const data = this.#raster_pass_data;
1000
+ const pass = graph.add("Mesh Card Capture / Raster", data, this.#execute_raster);
705
1001
 
706
- data.arena = arena;
707
- data.albedo = pass.write(graph_import_texture(graph, this.#atlas.texture_at(0), "mesh_card_albedo"));
708
- data.emissive = pass.write(graph_import_texture(graph, this.#atlas.texture_at(1), "mesh_card_emissive"));
1002
+ pass.read(arena);
709
1003
 
710
- pass.make_side_effect();
1004
+ data.arena = arena;
1005
+ data.albedo = pass.write(albedo);
1006
+ data.emissive = pass.write(emissive);
711
1007
 
712
- const b = this.#bindings;
1008
+ pass.make_side_effect();
713
1009
 
714
- b.mesh_sdf_headers = headers;
715
- b.materials = materials.buffer_materials;
716
- b.textures = materials.textureView;
717
- b.blas_lookup = blas.blas_lookup;
718
- b.blas_data = blas.blas_data;
719
- b.geometries = blas.geometries;
720
- b.meshlet_metadata = blas.meshlet_metadata;
721
- b.meshlet_data = blas.meshlet_data;
1010
+ const args = this.#raster_args_bindings;
1011
+
1012
+ args.mesh_sdf_headers = headers;
1013
+ args.geometries = blas.geometries;
1014
+
1015
+ const scatter = this.#raster_scatter_bindings;
1016
+
1017
+ scatter.mesh_sdf_headers = headers;
1018
+ scatter.mesh_card_raster_albedo = this.#raster_views[0];
1019
+ scatter.mesh_card_raster_emissive = this.#raster_views[1];
1020
+
1021
+ this.#raster_group_buffers.mesh_sdf_headers = headers;
1022
+ this.#raster_group_buffers.geometries = blas.geometries;
1023
+ this.#raster_group_buffers.meshlet_metadata = blas.meshlet_metadata;
1024
+ this.#raster_group_buffers.meshlet_data = blas.meshlet_data;
1025
+ }
722
1026
  }
723
1027
 
724
1028
  for (let i = 0; i < completed.length; i++) {
@@ -759,6 +1063,116 @@ export class GPUMeshCardSets {
759
1063
  });
760
1064
  }
761
1065
 
1066
+ /**
1067
+ * {@link #execute_raster_capture}, bound once.
1068
+ * @type {function(Object, Object, Object): void}
1069
+ */
1070
+ #execute_raster = (data, resources, context) => this.#execute_raster_capture(data, resources, context);
1071
+
1072
+ /**
1073
+ * A draw a run, every run's cards into the scratch, then every run's pages into the atlas.
1074
+ */
1075
+ #execute_raster_capture(data, resources, context) {
1076
+ const encoder = context.encoder;
1077
+ const graphics = context.graphics;
1078
+ const runs = this.#frame_raster_runs;
1079
+ const arena = resources.get(data.arena);
1080
+
1081
+ const args_settings = this.#raster_args_settings;
1082
+ const args = this.#raster_args_bindings;
1083
+
1084
+ args_settings.run_count = runs;
1085
+
1086
+ args.settings = args_settings;
1087
+ args.mesh_sdf_indirection = arena;
1088
+ args.mesh_card_sets = this.#records;
1089
+ args.mesh_card_raster_runs = this.#raster_runs;
1090
+ args.mesh_card_raster_draws = this.#raster_draws;
1091
+
1092
+ shader_mesh_cards_raster_args.dispatch({
1093
+ encoder,
1094
+ group_count_x: Math.ceil(runs / MESH_CARDS_RASTER_ARGS_WORKGROUP_SIZE),
1095
+ bindings: args,
1096
+ });
1097
+
1098
+ const buffers = this.#raster_group_buffers;
1099
+
1100
+ const group = graphics.bind_groups.obtain(BindGroupDescriptor.from(
1101
+ MESH_CARDS_RASTER_LAYOUT,
1102
+ [
1103
+ { buffer: buffers.mesh_sdf_headers },
1104
+ { buffer: arena },
1105
+ { buffer: this.#records },
1106
+ { buffer: this.#raster_runs },
1107
+ { buffer: buffers.geometries },
1108
+ { buffer: buffers.meshlet_metadata },
1109
+ { buffer: buffers.meshlet_data },
1110
+ ]
1111
+ ));
1112
+
1113
+ const immediate = this.#raster_immediate;
1114
+
1115
+ this.#raster_immediate_f32[1] = this.#raster_width;
1116
+ this.#raster_immediate_f32[2] = this.#raster_height;
1117
+
1118
+ const pass = encoder.beginRenderPass(this.#raster_pass_descriptor);
1119
+
1120
+ pass.setBindGroup(1, group);
1121
+
1122
+ let bound_template = null;
1123
+
1124
+ for (let run = 0; run < runs; run++) {
1125
+ const material = this.#frame_raster_materials[run];
1126
+
1127
+ if (!material.is_built) {
1128
+ // let go since it was taken: its texels stay empty, every lookup missing
1129
+ continue;
1130
+ }
1131
+
1132
+ const template = material.template;
1133
+
1134
+ if (template !== bound_template) {
1135
+ pass.setPipeline(mesh_cards_raster_pass_descriptor.obtain_pipeline(graphics.render_pipelines, template, "none"));
1136
+
1137
+ bound_template = template;
1138
+ }
1139
+
1140
+ // the same group 0 the G-buffer pass binds
1141
+ pass.setBindGroup(0, material.material_binding);
1142
+
1143
+ immediate[0] = run;
1144
+
1145
+ pass.setImmediates(0, immediate, 0, immediate.length);
1146
+ pass.drawIndirect(this.#raster_draws, run * STRUCT_UNINDEXED_DRAW_COMMAND.size);
1147
+ }
1148
+
1149
+ pass.end();
1150
+
1151
+ const groups = Math.ceil(this.#frame_raster_threads / MESH_SDF_BAKE_WORKGROUP_SIZE);
1152
+ const groups_x = Math.min(groups, WEBGPU_GUARANTEED_MAX_COMPUTE_WORKGROUPS_PER_DIMENSION);
1153
+
1154
+ const scatter_settings = this.#raster_scatter_settings;
1155
+ const scatter = this.#raster_scatter_bindings;
1156
+
1157
+ scatter_settings.run_count = runs;
1158
+ scatter_settings.thread_count = this.#frame_raster_threads;
1159
+ scatter_settings.groups_x = groups_x;
1160
+
1161
+ scatter.settings = scatter_settings;
1162
+ scatter.mesh_sdf_indirection = arena;
1163
+ scatter.mesh_card_sets = this.#records;
1164
+ scatter.mesh_card_raster_runs = this.#raster_runs;
1165
+ scatter.mesh_card_albedo = resources.get(data.albedo).obtainView();
1166
+ scatter.mesh_card_emissive = resources.get(data.emissive).obtainView();
1167
+
1168
+ shader_mesh_cards_raster_scatter.dispatch({
1169
+ encoder,
1170
+ group_count_x: groups_x,
1171
+ group_count_y: Math.ceil(groups / groups_x),
1172
+ bindings: scatter,
1173
+ });
1174
+ }
1175
+
762
1176
  #ensure_id(id) {
763
1177
  const length = id + 1;
764
1178
 
@@ -837,6 +1251,76 @@ export class GPUMeshCardSets {
837
1251
  this.#run_capacity = capacity;
838
1252
  }
839
1253
 
1254
+ /**
1255
+ * @param {number} runs
1256
+ */
1257
+ #ensure_raster_runs(runs) {
1258
+ if (runs <= this.#raster_run_capacity) {
1259
+ return;
1260
+ }
1261
+
1262
+ let capacity = Math.max(64, this.#raster_run_capacity);
1263
+
1264
+ while (capacity < runs) {
1265
+ capacity *= 2;
1266
+ }
1267
+
1268
+ this.#raster_runs?.destroy();
1269
+ this.#raster_draws?.destroy();
1270
+
1271
+ this.#raster_runs = this.#create_buffer("raster runs", 16 * capacity, GPUBufferUsage.COPY_DST);
1272
+ this.#raster_draws = this.#create_buffer("raster draws", STRUCT_UNINDEXED_DRAW_COMMAND.size * capacity, GPUBufferUsage.INDIRECT);
1273
+ this.#raster_run_capacity = capacity;
1274
+ }
1275
+
1276
+ /**
1277
+ * The scratch the cards are drawn into, at least `width` × `height`. It only grows.
1278
+ *
1279
+ * @param {number} width
1280
+ * @param {number} height
1281
+ */
1282
+ #ensure_raster_scratch(width, height) {
1283
+ if (width <= this.#raster_width && height <= this.#raster_height) {
1284
+ return;
1285
+ }
1286
+
1287
+ const step = RASTER_SCRATCH_STEP;
1288
+
1289
+ width = Math.max(this.#raster_width, Math.ceil(width / step) * step);
1290
+ height = Math.max(this.#raster_height, Math.ceil(height / step) * step);
1291
+
1292
+ const formats = [...MESH_CARD_RASTER_TARGET_FORMATS, MESH_CARD_RASTER_DEPTH_FORMAT];
1293
+
1294
+ for (let i = 0; i < formats.length; i++) {
1295
+ // a frame already submitted may still be reading it; destroy waits for that
1296
+ this.#raster_targets[i]?.destroy();
1297
+
1298
+ const color = i < MESH_CARD_RASTER_TARGET_FORMATS.length;
1299
+
1300
+ this.#raster_targets[i] = this.#device.createTexture({
1301
+ label: `GPUMeshCardSets/raster scratch ${i}`,
1302
+ size: [width, height],
1303
+ format: formats[i],
1304
+ usage: color
1305
+ ? GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
1306
+ : GPUTextureUsage.RENDER_ATTACHMENT,
1307
+ });
1308
+
1309
+ this.#raster_views[i] = this.#raster_targets[i].createView();
1310
+ }
1311
+
1312
+ const descriptor = this.#raster_pass_descriptor;
1313
+
1314
+ for (let i = 0; i < descriptor.colorAttachments.length; i++) {
1315
+ descriptor.colorAttachments[i].view = this.#raster_views[i];
1316
+ }
1317
+
1318
+ descriptor.depthStencilAttachment.view = this.#raster_views[formats.length - 1];
1319
+
1320
+ this.#raster_width = width;
1321
+ this.#raster_height = height;
1322
+ }
1323
+
840
1324
  /**
841
1325
  * @param {string} name
842
1326
  * @param {number} size
@@ -869,6 +1353,13 @@ export class GPUMeshCardSets {
869
1353
  bytes += this.#atlas.gpu_memory_usage;
870
1354
  }
871
1355
 
1356
+ if (this.#raster_runs !== null) {
1357
+ bytes += this.#raster_runs.size + this.#raster_draws.size;
1358
+ }
1359
+
1360
+ // two rgba8 targets and a depth32float, 4 bytes a texel each
1361
+ bytes += this.#raster_width * this.#raster_height * 4 * (MESH_CARD_RASTER_TARGET_FORMATS.length + 1);
1362
+
872
1363
  return bytes;
873
1364
  }
874
1365
 
@@ -876,9 +1367,21 @@ export class GPUMeshCardSets {
876
1367
  this.#records?.destroy();
877
1368
  this.#runs?.destroy();
878
1369
  this.#atlas?.destroy();
1370
+ this.#raster_runs?.destroy();
1371
+ this.#raster_draws?.destroy();
1372
+
1373
+ for (let i = 0; i < this.#raster_targets.length; i++) {
1374
+ this.#raster_targets[i].destroy();
1375
+ }
879
1376
 
880
1377
  this.#records = null;
881
1378
  this.#runs = null;
882
1379
  this.#atlas = null;
1380
+ this.#raster_runs = null;
1381
+ this.#raster_draws = null;
1382
+ this.#raster_targets.length = 0;
1383
+ this.#raster_views.length = 0;
1384
+ this.#raster_width = 0;
1385
+ this.#raster_height = 0;
883
1386
  }
884
1387
  }