@woosh/meep-engine 3.53.0 → 3.55.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 (249) hide show
  1. package/package.json +1 -1
  2. package/src/core/math/noise/worley_noise_2d.d.ts +14 -0
  3. package/src/core/math/noise/worley_noise_2d.d.ts.map +1 -0
  4. package/src/core/math/noise/worley_noise_2d.js +74 -0
  5. package/src/engine/graphics/texture/atlas/CachingTextureAtlas.d.ts +6 -1
  6. package/src/engine/graphics/texture/atlas/CachingTextureAtlas.d.ts.map +1 -1
  7. package/src/engine/graphics/texture/atlas/CachingTextureAtlas.js +363 -325
  8. package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.d.ts +93 -14
  9. package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.d.ts.map +1 -1
  10. package/src/engine/graphics/texture/atlas/ManagedTextureAtlas.js +322 -183
  11. package/src/engine/graphics/texture/atlas/ReferencedTextureAtlas.d.ts +9 -0
  12. package/src/engine/graphics/texture/atlas/ReferencedTextureAtlas.d.ts.map +1 -1
  13. package/src/engine/graphics/texture/atlas/ReferencedTextureAtlas.js +110 -83
  14. package/src/engine/graphics/texture/atlas/SpriteAtlas.d.ts +42 -0
  15. package/src/engine/graphics/texture/atlas/SpriteAtlas.d.ts.map +1 -0
  16. package/src/engine/{graphics3/decal/DecalAtlas.js → graphics/texture/atlas/SpriteAtlas.js} +202 -194
  17. package/src/engine/{graphics3/decal/DecalAtlasFill.d.ts → graphics/texture/atlas/SpriteAtlasFill.d.ts} +4 -4
  18. package/src/engine/graphics/texture/atlas/SpriteAtlasFill.d.ts.map +1 -0
  19. package/src/engine/graphics/texture/atlas/SpriteAtlasFill.js +30 -0
  20. package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts +7 -0
  21. package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts.map +1 -1
  22. package/src/engine/graphics/texture/atlas/TextureAtlas.js +11 -1
  23. package/src/engine/{graphics3/decal/decal_atlas_border.d.ts → graphics/texture/atlas/sprite_atlas_border.d.ts} +12 -12
  24. package/src/engine/graphics/texture/atlas/sprite_atlas_border.d.ts.map +1 -0
  25. package/src/engine/{graphics3/decal/decal_atlas_border.js → graphics/texture/atlas/sprite_atlas_border.js} +69 -69
  26. package/src/engine/graphics3/DecalSystem.d.ts.map +1 -1
  27. package/src/engine/graphics3/DecalSystem.js +447 -450
  28. package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts +9 -22
  29. package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts.map +1 -1
  30. package/src/engine/graphics3/GPUParticleEmitterSystem.js +892 -951
  31. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  32. package/src/generation/foliage/FOLIAGE_DESIGN.md +2 -1
  33. package/src/generation/foliage/config/BarkMaterialConfig.d.ts +4 -3
  34. package/src/generation/foliage/config/BarkMaterialConfig.d.ts.map +1 -1
  35. package/src/generation/foliage/config/BarkMaterialConfig.js +6 -6
  36. package/src/generation/foliage/config/FoliageBarkType.d.ts +11 -0
  37. package/src/generation/foliage/config/FoliageBarkType.d.ts.map +1 -0
  38. package/src/generation/foliage/config/FoliageBarkType.js +16 -0
  39. package/src/generation/foliage/config/FoliageMaterialConfig.d.ts +58 -5
  40. package/src/generation/foliage/config/FoliageMaterialConfig.d.ts.map +1 -1
  41. package/src/generation/foliage/config/FoliageMaterialConfig.js +279 -181
  42. package/src/generation/foliage/index.d.ts +2 -1
  43. package/src/generation/foliage/index.js +44 -43
  44. package/src/generation/foliage/material/make_bark_material.d.ts.map +1 -1
  45. package/src/generation/foliage/material/make_bark_material.js +23 -95
  46. package/src/generation/foliage/material/make_foliage_material.d.ts +29 -3
  47. package/src/generation/foliage/material/make_foliage_material.d.ts.map +1 -1
  48. package/src/generation/foliage/material/make_foliage_material.js +605 -359
  49. package/src/generation/foliage/mesh/branch_collar_project.d.ts.map +1 -1
  50. package/src/generation/foliage/mesh/branch_collar_project.js +205 -203
  51. package/src/generation/foliage/mesh/foliage_collect_attachments.d.ts +15 -0
  52. package/src/generation/foliage/mesh/foliage_collect_attachments.d.ts.map +1 -1
  53. package/src/generation/foliage/mesh/foliage_collect_attachments.js +569 -502
  54. package/src/generation/foliage/mesh/tree_mesh_build_bark.d.ts.map +1 -1
  55. package/src/generation/foliage/mesh/tree_mesh_build_bark.js +1049 -1047
  56. package/src/generation/foliage/mesh/tree_mesh_build_foliage.d.ts +2 -1
  57. package/src/generation/foliage/mesh/tree_mesh_build_foliage.d.ts.map +1 -1
  58. package/src/generation/foliage/mesh/tree_mesh_build_foliage.js +454 -415
  59. package/src/generation/foliage/presets/make_tree_species_preset.d.ts.map +1 -1
  60. package/src/generation/foliage/presets/make_tree_species_preset.js +870 -837
  61. package/src/generation/foliage/skeleton/crown_envelope_evaluate.js +121 -121
  62. package/src/generation/foliage/skeleton/tree_skeleton_compute_pipe_radii.d.ts +10 -7
  63. package/src/generation/foliage/skeleton/tree_skeleton_compute_pipe_radii.d.ts.map +1 -1
  64. package/src/generation/foliage/skeleton/tree_skeleton_compute_pipe_radii.js +206 -179
  65. package/src/generation/foliage/skeleton/tree_skeleton_grow.d.ts.map +1 -1
  66. package/src/generation/foliage/skeleton/tree_skeleton_grow.js +1871 -1104
  67. package/src/shade/RENDERER_CONTRACT.md +5 -2
  68. package/src/shade/device/SHADE_DEVICE_FLOOR.d.ts.map +1 -1
  69. package/src/shade/device/SHADE_DEVICE_FLOOR.js +2 -0
  70. package/src/shade/playground/foliage_wind/foliage_world.d.ts +6 -0
  71. package/src/shade/playground/foliage_wind/foliage_world.d.ts.map +1 -1
  72. package/src/shade/playground/foliage_wind/foliage_world.js +602 -593
  73. package/src/shade/playground/foliage_wind/index.html +260 -254
  74. package/src/shade/playground/foliage_wind/main.js +275 -263
  75. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  76. package/src/shade/renderer/Renderer.js +1 -1
  77. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  78. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  79. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
  80. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  81. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  82. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.js +1 -1
  83. package/src/shade/renderer/hiz/HierarchicalZBuffer.d.ts +3 -3
  84. package/src/shade/renderer/hiz/HierarchicalZBuffer.d.ts.map +1 -1
  85. package/src/shade/renderer/hiz/HierarchicalZBuffer.js +350 -294
  86. package/src/shade/renderer/hiz/generate_downsampler_code.d.ts +0 -2
  87. package/src/shade/renderer/hiz/generate_downsampler_code.d.ts.map +1 -1
  88. package/src/shade/renderer/hiz/generate_downsampler_code.js +99 -100
  89. package/src/shade/renderer/hiz/hzb_pick_alignment.d.ts +15 -0
  90. package/src/shade/renderer/hiz/hzb_pick_alignment.d.ts.map +1 -0
  91. package/src/shade/renderer/hiz/hzb_pick_alignment.js +148 -0
  92. package/src/shade/renderer/hiz/hzb_plan_reduction_steps.d.ts +28 -0
  93. package/src/shade/renderer/hiz/hzb_plan_reduction_steps.d.ts.map +1 -0
  94. package/src/shade/renderer/hiz/hzb_plan_reduction_steps.js +58 -0
  95. package/src/shade/renderer/hiz/shader_hzb_reduce_any.d.ts +5 -5
  96. package/src/shade/renderer/hiz/shader_hzb_reduce_any.d.ts.map +1 -1
  97. package/src/shade/renderer/hiz/shader_hzb_reduce_any.js +57 -67
  98. package/src/shade/renderer/hiz/shader_hzb_reduce_mip0_clip.d.ts +3 -3
  99. package/src/shade/renderer/hiz/shader_hzb_reduce_mip0_clip.d.ts.map +1 -1
  100. package/src/shade/renderer/hiz/shader_hzb_reduce_mip0_clip.js +111 -112
  101. package/src/shade/renderer/hiz/shader_hzb_spd.d.ts +5 -0
  102. package/src/shade/renderer/hiz/shader_hzb_spd.d.ts.map +1 -0
  103. package/src/shade/renderer/hiz/shader_hzb_spd.js +160 -0
  104. package/src/shade/renderer/light/GPULightCollection.d.ts +8 -0
  105. package/src/shade/renderer/light/GPULightCollection.d.ts.map +1 -1
  106. package/src/shade/renderer/light/GPULightCollection.js +67 -0
  107. package/src/shade/renderer/light/environment/FAR_FIELD_IRRADIANCE_SH_RESOURCE.d.ts +7 -0
  108. package/src/shade/renderer/light/environment/FAR_FIELD_IRRADIANCE_SH_RESOURCE.d.ts.map +1 -0
  109. package/src/shade/renderer/light/environment/FAR_FIELD_IRRADIANCE_SH_RESOURCE.js +13 -0
  110. package/src/shade/renderer/light/environment/shader_project_far_field_irradiance_sh.d.ts +10 -0
  111. package/src/shade/renderer/light/environment/shader_project_far_field_irradiance_sh.d.ts.map +1 -0
  112. package/src/shade/renderer/light/environment/shader_project_far_field_irradiance_sh.js +72 -0
  113. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.d.ts +39 -0
  114. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.d.ts.map +1 -0
  115. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.js +90 -0
  116. package/src/shade/renderer/light/world_cluster/chunk_world_light_cluster_lookup.d.ts +12 -0
  117. package/src/shade/renderer/light/world_cluster/chunk_world_light_cluster_lookup.d.ts.map +1 -0
  118. package/src/shade/renderer/light/world_cluster/chunk_world_light_cluster_lookup.js +56 -0
  119. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.d.ts +31 -0
  120. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.d.ts.map +1 -0
  121. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.js +196 -0
  122. package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.d.ts +10 -0
  123. package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.d.ts.map +1 -0
  124. package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.js +163 -0
  125. package/src/shade/renderer/light/world_cluster/shader_world_cluster_cull_lights.d.ts +4 -0
  126. package/src/shade/renderer/light/world_cluster/shader_world_cluster_cull_lights.d.ts.map +1 -0
  127. package/src/shade/renderer/light/world_cluster/shader_world_cluster_cull_lights.js +137 -0
  128. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  129. package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
  130. package/src/shade/renderer/particles/GPUParticleSystem.js +4 -3
  131. package/src/shade/renderer/particles/graph_particles_avboit.d.ts +4 -3
  132. package/src/shade/renderer/particles/graph_particles_avboit.d.ts.map +1 -1
  133. package/src/shade/renderer/particles/graph_particles_avboit.js +28 -11
  134. package/src/shade/renderer/particles/shaders/chunk_particle_lighting.d.ts +9 -13
  135. package/src/shade/renderer/particles/shaders/chunk_particle_lighting.d.ts.map +1 -1
  136. package/src/shade/renderer/particles/shaders/chunk_particle_lighting.js +25 -20
  137. package/src/shade/renderer/particles/shaders/shader_particle_avboit_draw.d.ts.map +1 -1
  138. package/src/shade/renderer/particles/shaders/shader_particle_avboit_draw.js +21 -38
  139. package/src/shade/renderer/postprocess/denoise/fragment_shader_denoise_ao.d.ts.map +1 -1
  140. package/src/shade/renderer/postprocess/denoise/fragment_shader_denoise_ao.js +154 -147
  141. package/src/shade/renderer/postprocess/gtao/GTAO.d.ts +2 -1
  142. package/src/shade/renderer/postprocess/gtao/GTAO.d.ts.map +1 -1
  143. package/src/shade/renderer/postprocess/gtao/GTAO.js +5 -1
  144. package/src/shade/renderer/postprocess/gtao/GTAO_CONSTANTS.d.ts +8 -0
  145. package/src/shade/renderer/postprocess/gtao/GTAO_CONSTANTS.d.ts.map +1 -1
  146. package/src/shade/renderer/postprocess/gtao/GTAO_CONSTANTS.js +10 -1
  147. package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.d.ts.map +1 -1
  148. package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.js +5 -0
  149. package/src/shade/renderer/postprocess/gtao/chunk_gtao_compute_mip_level.d.ts +22 -0
  150. package/src/shade/renderer/postprocess/gtao/chunk_gtao_compute_mip_level.d.ts.map +1 -0
  151. package/src/shade/renderer/postprocess/gtao/chunk_gtao_compute_mip_level.js +33 -0
  152. package/src/shade/renderer/postprocess/gtao/chunk_gtao_resolve_hzb_depth.d.ts +22 -0
  153. package/src/shade/renderer/postprocess/gtao/chunk_gtao_resolve_hzb_depth.d.ts.map +1 -0
  154. package/src/shade/renderer/postprocess/gtao/chunk_gtao_resolve_hzb_depth.js +56 -0
  155. package/src/shade/renderer/postprocess/gtao/chunk_gtao_sample_depth.d.ts +13 -0
  156. package/src/shade/renderer/postprocess/gtao/chunk_gtao_sample_depth.d.ts.map +1 -0
  157. package/src/shade/renderer/postprocess/gtao/chunk_gtao_sample_depth.js +42 -0
  158. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao.d.ts +2 -1
  159. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao.d.ts.map +1 -1
  160. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao.js +382 -357
  161. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.d.ts.map +1 -1
  162. package/src/shade/renderer/postprocess/gtao/fragment_shader_gtao_with_irradiance.js +414 -410
  163. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  164. package/src/shade/renderer/postprocess/ssr/prefilter/NOTES.md +0 -7
  165. package/src/shade/renderer/shader/chunk/depth/chunk_query_depth_from_screen_space_bb.d.ts.map +1 -1
  166. package/src/shade/renderer/shader/chunk/depth/chunk_query_depth_from_screen_space_bb.js +62 -62
  167. package/src/shade/renderer/shader/chunk/random/lowbias/chunk_hash_lowbias32_vec2u.d.ts +6 -0
  168. package/src/shade/renderer/shader/chunk/random/lowbias/chunk_hash_lowbias32_vec2u.d.ts.map +1 -0
  169. package/src/shade/renderer/shader/chunk/random/lowbias/chunk_hash_lowbias32_vec2u.js +19 -0
  170. package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_get_mip_resolution.d.ts.map +1 -1
  171. package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_get_mip_resolution.js +16 -10
  172. package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_hierarchical_raymarch.d.ts.map +1 -1
  173. package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_hierarchical_raymarch.js +118 -117
  174. package/src/shade/renderer/texture/atlas/GPUTileAtlas3D.d.ts +41 -7
  175. package/src/shade/renderer/texture/atlas/GPUTileAtlas3D.d.ts.map +1 -1
  176. package/src/shade/renderer/texture/atlas/GPUTileAtlas3D.js +162 -58
  177. package/src/shade/renderer/volumetrics/GPUSceneVolumetrics.js +1 -1
  178. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts +10 -12
  179. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts.map +1 -1
  180. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +583 -606
  181. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts +1 -1
  182. package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +640 -640
  183. package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.d.ts +113 -0
  184. package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.d.ts.map +1 -0
  185. package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.js +484 -0
  186. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.d.ts +50 -0
  187. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.d.ts.map +1 -0
  188. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.js +60 -0
  189. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.d.ts +25 -0
  190. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.d.ts.map +1 -0
  191. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.js +47 -0
  192. package/src/shade/renderer/volumetrics/irradiance_clipmap/IrradianceCascadePlacement.d.ts +74 -0
  193. package/src/shade/renderer/volumetrics/irradiance_clipmap/IrradianceCascadePlacement.d.ts.map +1 -0
  194. package/src/shade/renderer/volumetrics/irradiance_clipmap/IrradianceCascadePlacement.js +173 -0
  195. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.d.ts +26 -0
  196. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.d.ts.map +1 -0
  197. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.js +83 -0
  198. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_local_light.d.ts +36 -0
  199. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_local_light.d.ts.map +1 -0
  200. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_local_light.js +129 -0
  201. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.d.ts +121 -0
  202. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.d.ts.map +1 -0
  203. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.js +370 -0
  204. package/src/shade/renderer/volumetrics/irradiance_clipmap/shader_irradiance_clipmap_build.d.ts +16 -0
  205. package/src/shade/renderer/volumetrics/irradiance_clipmap/shader_irradiance_clipmap_build.d.ts.map +1 -0
  206. package/src/shade/renderer/volumetrics/irradiance_clipmap/shader_irradiance_clipmap_build.js +191 -0
  207. package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
  208. package/src/shade/renderer/wind/GPUSceneWind.js +1 -1
  209. package/src/engine/graphics3/decal/DecalAtlas.d.ts +0 -43
  210. package/src/engine/graphics3/decal/DecalAtlas.d.ts.map +0 -1
  211. package/src/engine/graphics3/decal/DecalAtlasFill.d.ts.map +0 -1
  212. package/src/engine/graphics3/decal/DecalAtlasFill.js +0 -32
  213. package/src/engine/graphics3/decal/decal_atlas_border.d.ts.map +0 -1
  214. package/src/shade/renderer/postprocess/gtao/graph_build_depth_mipmap.d.ts +0 -26
  215. package/src/shade/renderer/postprocess/gtao/graph_build_depth_mipmap.d.ts.map +0 -1
  216. package/src/shade/renderer/postprocess/gtao/graph_build_depth_mipmap.js +0 -268
  217. package/src/shade/renderer/postprocess/ssr/copy_shader_f32.d.ts +0 -3
  218. package/src/shade/renderer/postprocess/ssr/copy_shader_f32.d.ts.map +0 -1
  219. package/src/shade/renderer/postprocess/ssr/copy_shader_f32.js +0 -32
  220. package/src/shade/renderer/postprocess/ssr/depth_max_shader.d.ts +0 -17
  221. package/src/shade/renderer/postprocess/ssr/depth_max_shader.d.ts.map +0 -1
  222. package/src/shade/renderer/postprocess/ssr/depth_max_shader.js +0 -98
  223. package/src/shade/renderer/postprocess/ssr/graph_build_depth_max_pyramid.d.ts +0 -23
  224. package/src/shade/renderer/postprocess/ssr/graph_build_depth_max_pyramid.d.ts.map +0 -1
  225. package/src/shade/renderer/postprocess/ssr/graph_build_depth_max_pyramid.js +0 -118
  226. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_froxel_centre_ws.d.ts +0 -15
  227. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_froxel_centre_ws.d.ts.map +0 -1
  228. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_froxel_centre_ws.js +0 -49
  229. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.d.ts +0 -17
  230. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.d.ts.map +0 -1
  231. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.js +0 -50
  232. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi_sample.d.ts +0 -35
  233. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi_sample.d.ts.map +0 -1
  234. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi_sample.js +0 -105
  235. package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.d.ts +0 -35
  236. package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.d.ts.map +0 -1
  237. package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.js +0 -80
  238. package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi.d.ts +0 -10
  239. package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi.d.ts.map +0 -1
  240. package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi.js +0 -51
  241. package/src/shade/renderer/volumetrics/gi/volumetrics_gi_resources.d.ts +0 -28
  242. package/src/shade/renderer/volumetrics/gi/volumetrics_gi_resources.d.ts.map +0 -1
  243. package/src/shade/renderer/volumetrics/gi/volumetrics_gi_resources.js +0 -39
  244. package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.d.ts +0 -48
  245. package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.d.ts.map +0 -1
  246. package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.js +0 -121
  247. package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.d.ts +0 -28
  248. package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.d.ts.map +0 -1
  249. package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.js +0 -237
@@ -0,0 +1,72 @@
1
+ import { INDIRECT_LIGHT_INTENSITY } from "../../deferred/INDIRECT_LIGHT_INTENSITY.js";
2
+ import {
3
+ chunk_directional_lights_iteration_mask
4
+ } from "../../shader/chunk/light/io/chunk_directional_lights_iteration_mask.js";
5
+ import {
6
+ chunk_get_directional_light_info_by_index
7
+ } from "../../shader/chunk/light/io/chunk_get_directional_light_info_by_index.js";
8
+ import {
9
+ METRO_L1_IRRADIANCE_STRUCT
10
+ } from "../../shader/chunk/spherical_harmonics/l1i/chunk_convert_to_irradiance_sh.js";
11
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
12
+ import { ComputeShader } from "../../shader/ComputeShader.js";
13
+ import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
14
+ import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
15
+ import { chunk_volumetrics_irradiance_sh } from "../../volumetrics/chunk_volumetrics_irradiance_sh.js";
16
+ import { ENVIRONMENT_SH_TYPE } from "./shader_project_environment_sh.js";
17
+
18
+ const resources = new ShaderResourceSetDescriptor();
19
+
20
+ resources.createGroup()
21
+ .addUniform("environment_sh", ENVIRONMENT_SH_TYPE)
22
+ .addStorageBuffer("light_data", WebGPUArray.u32, false)
23
+ .addStorageBuffer("far_field_sh", METRO_L1_IRRADIANCE_STRUCT, true);
24
+
25
+ const body = CodeChunk.from(
26
+ //language=WGSL
27
+ `
28
+ @compute @workgroup_size(1)
29
+ fn main() {
30
+ const INDIRECT_INTENSITY : f32 = ${INDIRECT_LIGHT_INTENSITY};
31
+
32
+ let scaled_radiance = array<vec3<f32>, 4>(
33
+ environment_sh[0].xyz * INDIRECT_INTENSITY,
34
+ environment_sh[1].xyz * INDIRECT_INTENSITY,
35
+ environment_sh[2].xyz * INDIRECT_INTENSITY,
36
+ environment_sh[3].xyz * INDIRECT_INTENSITY,
37
+ );
38
+
39
+ var sh: ${METRO_L1_IRRADIANCE_STRUCT.wgsl_ref};
40
+ sh = volumetrics_irradiance_sh_add_radiance(sh, scaled_radiance);
41
+
42
+ var directional_bits = directional_lights_iteration_mask(&light_data);
43
+ while (directional_bits != 0u) {
44
+ let directional_index = countTrailingZeros(directional_bits);
45
+ directional_bits &= ~(1u << directional_index);
46
+
47
+ let sun = get_directional_light_info_by_index(&light_data, directional_index);
48
+ sh = volumetrics_irradiance_sh_add(sh, sun.color, sun.direction);
49
+ }
50
+
51
+ far_field_sh = volumetrics_irradiance_sh_storable(sh);
52
+ }
53
+ `, [
54
+ METRO_L1_IRRADIANCE_STRUCT.declaration_chunk,
55
+ chunk_volumetrics_irradiance_sh,
56
+ chunk_directional_lights_iteration_mask,
57
+ chunk_get_directional_light_info_by_index,
58
+ ]
59
+ );
60
+
61
+ /**
62
+ * Projects the scene's far-field irradiance (the environment SH scaled by `INDIRECT_LIGHT_INTENSITY`
63
+ * plus unshadowed directional lights) into a single cached {@link METRO_L1_IRRADIANCE_STRUCT} buffer on
64
+ * `GPULightCollection`. Updated only when the environment or directional lights change.
65
+ *
66
+ * @type {ComputeShader}
67
+ */
68
+ export const shader_project_far_field_irradiance_sh = ComputeShader.from({
69
+ label: "Environment / project far-field irradiance SH",
70
+ resources,
71
+ body,
72
+ });
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Number of cluster cells along each axis of a single world-space clipmap cascade (`8 × 8 × 8 = 512`).
3
+ * @type {number}
4
+ */
5
+ export const WORLD_LIGHT_CLUSTER_GRID_SIZE: number;
6
+ /**
7
+ * Total cluster cells in one cascade (`8³ = 512`).
8
+ * @type {number}
9
+ */
10
+ export const WORLD_LIGHT_CLUSTER_CELLS_PER_CASCADE: number;
11
+ /**
12
+ * Maximum number of cascades supported by the world-space light cluster clipmap.
13
+ * @type {number}
14
+ */
15
+ export const WORLD_LIGHT_CLUSTER_MAX_CASCADES: number;
16
+ /**
17
+ * Maximum number of lights (point + spot) assigned to a single world-space cluster cell.
18
+ * @type {number}
19
+ */
20
+ export const WORLD_LIGHT_CLUSTER_MAX_LIGHTS_PER_CELL: number;
21
+ /**
22
+ * Maximum number of point/spot lights culled into the world-space clipmap candidate list.
23
+ * @type {number}
24
+ */
25
+ export const WORLD_LIGHT_CLUSTER_LIGHT_CAPACITY: number;
26
+ /**
27
+ * Settings passed to the world-space light culling pass: the world-space AABB of the coarsest
28
+ * cascade (including its skirt).
29
+ * @type {WebGPUStruct}
30
+ */
31
+ export const WORLD_LIGHT_CLUSTER_CULL_SETTINGS: WebGPUStruct;
32
+ /**
33
+ * Exact sphere-vs-AABB and conservative spot-cone-vs-AABB intersection tests in world space.
34
+ * @type {CodeChunk}
35
+ */
36
+ export const chunk_world_cluster_aabb: CodeChunk;
37
+ import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
38
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
39
+ //# sourceMappingURL=WORLD_LIGHT_CLUSTER.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WORLD_LIGHT_CLUSTER.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH,4CAFU,MAAM,CAE+B;AAE/C;;;GAGG;AACH,oDAFU,MAAM,CAEwE;AAExF;;;GAGG;AACH,+CAFU,MAAM,CAEiE;AAEjF;;;GAGG;AACH,sDAFU,MAAM,CAE2C;AAE3D;;;GAGG;AACH,iDAFU,MAAM,CAEuC;AAEvD;;;;GAIG;AACH,gDAFU,YAAY,CAOc;AAEpC;;;GAGG;AACH,uCAFU,SAAS,CAsCjB;6BAtF2B,mCAAmC;0BAFtC,oCAAoC"}
@@ -0,0 +1,90 @@
1
+ import { chunk_cone_intersects_sphere } from "../../shader/chunk/geometry/cone/chunk_cone_intersects_sphere.js";
2
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
3
+ import { u32, vec3f } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
4
+ import { WebGPUStruct } from "../../shader/type/WebGPUStruct.js";
5
+ import { IRRADIANCE_CLIPMAP_CASCADE_LIMIT } from "../../volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.js";
6
+ import { CLUSTER_LIGHT_PROXY } from "../cluster/CLUSTER_LIGHT_PROXY.js";
7
+
8
+ /**
9
+ * Number of cluster cells along each axis of a single world-space clipmap cascade (`8 × 8 × 8 = 512`).
10
+ * @type {number}
11
+ */
12
+ export const WORLD_LIGHT_CLUSTER_GRID_SIZE = 8;
13
+
14
+ /**
15
+ * Total cluster cells in one cascade (`8³ = 512`).
16
+ * @type {number}
17
+ */
18
+ export const WORLD_LIGHT_CLUSTER_CELLS_PER_CASCADE = WORLD_LIGHT_CLUSTER_GRID_SIZE ** 3;
19
+
20
+ /**
21
+ * Maximum number of cascades supported by the world-space light cluster clipmap.
22
+ * @type {number}
23
+ */
24
+ export const WORLD_LIGHT_CLUSTER_MAX_CASCADES = IRRADIANCE_CLIPMAP_CASCADE_LIMIT;
25
+
26
+ /**
27
+ * Maximum number of lights (point + spot) assigned to a single world-space cluster cell.
28
+ * @type {number}
29
+ */
30
+ export const WORLD_LIGHT_CLUSTER_MAX_LIGHTS_PER_CELL = 128;
31
+
32
+ /**
33
+ * Maximum number of point/spot lights culled into the world-space clipmap candidate list.
34
+ * @type {number}
35
+ */
36
+ export const WORLD_LIGHT_CLUSTER_LIGHT_CAPACITY = 4096;
37
+
38
+ /**
39
+ * Settings passed to the world-space light culling pass: the world-space AABB of the coarsest
40
+ * cascade (including its skirt).
41
+ * @type {WebGPUStruct}
42
+ */
43
+ export const WORLD_LIGHT_CLUSTER_CULL_SETTINGS = WebGPUStruct.from({
44
+ coarsest_min: vec3f,
45
+ cascade_count: u32,
46
+ coarsest_max: vec3f,
47
+ pad0: u32,
48
+ }, "WorldLightClusterCullSettings");
49
+
50
+ /**
51
+ * Exact sphere-vs-AABB and conservative spot-cone-vs-AABB intersection tests in world space.
52
+ * @type {CodeChunk}
53
+ */
54
+ export const chunk_world_cluster_aabb = CodeChunk.from(
55
+ //language=WGSL
56
+ `
57
+ fn world_cluster_sphere_intersects_aabb(
58
+ center: vec3<f32>,
59
+ radius: f32,
60
+ box_min: vec3<f32>,
61
+ box_max: vec3<f32>,
62
+ ) -> bool {
63
+ let closest = clamp(center, box_min, box_max);
64
+ let d = center - closest;
65
+ return dot(d, d) <= radius * radius;
66
+ }
67
+
68
+ fn world_cluster_cone_intersects_aabb(
69
+ proxy: ${CLUSTER_LIGHT_PROXY.wgsl_ref},
70
+ box_min: vec3<f32>,
71
+ box_max: vec3<f32>,
72
+ ) -> bool {
73
+ if (!world_cluster_sphere_intersects_aabb(proxy.bound.xyz, proxy.bound.w, box_min, box_max)) {
74
+ return false;
75
+ }
76
+ let box_center = 0.5 * (box_min + box_max);
77
+ let box_radius = length(0.5 * (box_max - box_min));
78
+ return cone_intersects_sphere(
79
+ proxy.apex_height.xyz,
80
+ proxy.direction_cos.xyz,
81
+ proxy.apex_height.w,
82
+ proxy.direction_cos.w,
83
+ vec4<f32>(box_center, box_radius)
84
+ ) || world_cluster_sphere_intersects_aabb(proxy.apex_height.xyz, proxy.source_radius, box_min, box_max);
85
+ }
86
+ `, [
87
+ CLUSTER_LIGHT_PROXY.declaration_chunk,
88
+ chunk_cone_intersects_sphere,
89
+ ]
90
+ );
@@ -0,0 +1,12 @@
1
+ export const WORLD_CLUSTER_LOOKUP_RESOURCE: ShaderResourceDescriptor;
2
+ export const WORLD_CLUSTER_DATA_RESOURCE: ShaderResourceDescriptor;
3
+ /**
4
+ * Lookup helper for reading the world-space light cluster cell corresponding to a texel of cascade
5
+ * `cascade` in the irradiance clipmap tile (`tile_size = resolution + 2 * border`).
6
+ *
7
+ * @type {CodeChunk}
8
+ */
9
+ export const chunk_world_light_cluster_lookup: CodeChunk;
10
+ import { ShaderResourceDescriptor } from "../../shader/resource/ShaderResourceDescriptor.js";
11
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
12
+ //# sourceMappingURL=chunk_world_light_cluster_lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_world_light_cluster_lookup.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/light/world_cluster/chunk_world_light_cluster_lookup.js"],"names":[],"mappings":"AAQA,qEAIE;AAEF,mEAIE;AAEF;;;;;GAKG;AACH,+CAFU,SAAS,CA6BjB;yCAnDuC,mDAAmD;0BADlE,oCAAoC"}
@@ -0,0 +1,56 @@
1
+ import { chunk_grid3d_to_index } from "../../shader/chunk/grid/chunk_grid3d_to_index.js";
2
+ import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
3
+ import { ShaderResourceDescriptor } from "../../shader/resource/ShaderResourceDescriptor.js";
4
+ import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
5
+ import { LIGHT_CLUSTER_METADATA } from "../cluster/LIGHT_CLUSTER_METADATA.js";
6
+ import { LIGHT_CLUSTER_LOOKUP_STRUCT } from "../cluster/shader_cluster_assign_lights.js";
7
+ import { WORLD_LIGHT_CLUSTER_GRID_SIZE } from "./WORLD_LIGHT_CLUSTER.js";
8
+
9
+ export const WORLD_CLUSTER_LOOKUP_RESOURCE = ShaderResourceDescriptor.storageBuffer(
10
+ "world_cluster_lookup",
11
+ LIGHT_CLUSTER_LOOKUP_STRUCT,
12
+ false
13
+ );
14
+
15
+ export const WORLD_CLUSTER_DATA_RESOURCE = ShaderResourceDescriptor.storageBuffer(
16
+ "world_cluster_data",
17
+ WebGPUArray.u32,
18
+ false
19
+ );
20
+
21
+ /**
22
+ * Lookup helper for reading the world-space light cluster cell corresponding to a texel of cascade
23
+ * `cascade` in the irradiance clipmap tile (`tile_size = resolution + 2 * border`).
24
+ *
25
+ * @type {CodeChunk}
26
+ */
27
+ export const chunk_world_light_cluster_lookup = CodeChunk.from(
28
+ //language=WGSL
29
+ `
30
+ const WORLD_LIGHT_CLUSTER_GRID_SIZE: u32 = ${WORLD_LIGHT_CLUSTER_GRID_SIZE}u;
31
+
32
+ fn world_light_cluster_cell_from_local_texel(local_texel: vec3<u32>, tile_size: vec3<u32>) -> vec3<u32> {
33
+ let num = (local_texel * 2u + vec3<u32>(1u)) * WORLD_LIGHT_CLUSTER_GRID_SIZE;
34
+ let den = tile_size * 2u;
35
+ return min(num / den, vec3<u32>(WORLD_LIGHT_CLUSTER_GRID_SIZE - 1u));
36
+ }
37
+
38
+ fn world_light_cluster_metadata_by_texel(
39
+ cascade: u32,
40
+ local_texel: vec3<u32>,
41
+ tile_size: vec3<u32>,
42
+ ) -> ${LIGHT_CLUSTER_METADATA.wgsl_ref} {
43
+ let cell = world_light_cluster_cell_from_local_texel(local_texel, tile_size);
44
+ let index = grid3d_to_index(
45
+ vec3<u32>(cell.xy, cascade * WORLD_LIGHT_CLUSTER_GRID_SIZE + cell.z),
46
+ vec2<u32>(WORLD_LIGHT_CLUSTER_GRID_SIZE)
47
+ );
48
+ return world_cluster_lookup[index];
49
+ }
50
+ `, [
51
+ LIGHT_CLUSTER_METADATA.declaration_chunk,
52
+ chunk_grid3d_to_index,
53
+ ]
54
+ );
55
+
56
+ chunk_world_light_cluster_lookup.requireResource(WORLD_CLUSTER_LOOKUP_RESOURCE);
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Offer the pipelines {@link graph_build_world_light_clusters} dispatches — see {@link PipelineEnquiry}.
3
+ *
4
+ * @param {PipelineEnquiry} enquiry
5
+ */
6
+ export function enquire_build_world_light_clusters_pipelines(enquiry: PipelineEnquiry): void;
7
+ /**
8
+ * Builds the world-space light cluster clipmap over the cascades of the irradiance clipmap.
9
+ *
10
+ * @param {object} options
11
+ * @param {import("../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph} options.graph
12
+ * @param {import("../GPULightCollection.js").GPULightCollection} options.lights
13
+ * @param {number} options.irradiance_clipmap_uniform graph handle of the `IRRADIANCE_CLIPMAP_STRUCT` uniform
14
+ * @param {number} options.cascade_count active cascade count
15
+ * @param {ArrayLike<number>} options.coarsest_min `[x, y, z]` world min of coarsest cascade (including skirt)
16
+ * @param {ArrayLike<number>} options.coarsest_max `[x, y, z]` world max of coarsest cascade (including skirt)
17
+ * @returns {{lookup: number, data: number}}
18
+ */
19
+ export function graph_build_world_light_clusters({ graph, lights, irradiance_clipmap_uniform, cascade_count, coarsest_min, coarsest_max, }: {
20
+ graph: import("../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph;
21
+ lights: import("../GPULightCollection.js").GPULightCollection;
22
+ irradiance_clipmap_uniform: number;
23
+ cascade_count: number;
24
+ coarsest_min: ArrayLike<number>;
25
+ coarsest_max: ArrayLike<number>;
26
+ }): {
27
+ lookup: number;
28
+ data: number;
29
+ };
30
+ export type PipelineEnquiry = import("../../../device/pipeline/PipelineEnquiry.js").PipelineEnquiry;
31
+ //# sourceMappingURL=graph_build_world_light_clusters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph_build_world_light_clusters.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.js"],"names":[],"mappings":"AAoDA;;;;GAIG;AACH,sEAFW,eAAe,QAMzB;AAED;;;;;;;;;;;GAWG;AACH;IARsG,KAAK,EAAhG,OAAO,8DAA8D,EAAE,UAAU;IAClB,MAAM,EAArE,OAAO,0BAA0B,EAAE,kBAAkB;IACrC,0BAA0B,EAA1C,MAAM;IACU,aAAa,EAA7B,MAAM;IACqB,YAAY,EAAvC,UAAU,MAAM,CAAC;IACU,YAAY,EAAvC,UAAU,MAAM,CAAC;IACf;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,CA0H1C;8BA3KY,OAAO,6CAA6C,EAAE,eAAe"}
@@ -0,0 +1,196 @@
1
+ import { BufferResourceDescriptor } from "../../../device/graph/BufferResourceDescriptor.js";
2
+ import { COLLECTION_U32_STRUCT_WRITE } from "../../gpu_primitive/COLLECTION_U32_STRUCT_WRITE.js";
3
+ import { graph_import_buffer } from "../../shader/graph/graph_import_buffer.js";
4
+ import { u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
5
+ import { CLUSTER_LIGHT_PROXY } from "../cluster/CLUSTER_LIGHT_PROXY.js";
6
+ import { LIGHT_CLUSTER_METADATA } from "../cluster/LIGHT_CLUSTER_METADATA.js";
7
+ import {
8
+ shader_world_cluster_assign_lights,
9
+ WORLD_CLUSTER_ASSIGN_WORKGROUP_SIZE,
10
+ } from "./shader_world_cluster_assign_lights.js";
11
+ import {
12
+ shader_world_cluster_cull_point_lights,
13
+ shader_world_cluster_cull_spot_lights,
14
+ } from "./shader_world_cluster_cull_lights.js";
15
+ import {
16
+ WORLD_LIGHT_CLUSTER_CELLS_PER_CASCADE,
17
+ WORLD_LIGHT_CLUSTER_CULL_SETTINGS,
18
+ WORLD_LIGHT_CLUSTER_GRID_SIZE,
19
+ WORLD_LIGHT_CLUSTER_LIGHT_CAPACITY,
20
+ WORLD_LIGHT_CLUSTER_MAX_CASCADES,
21
+ WORLD_LIGHT_CLUSTER_MAX_LIGHTS_PER_CELL,
22
+ } from "./WORLD_LIGHT_CLUSTER.js";
23
+
24
+ /**
25
+ * @typedef {import("../../../device/pipeline/PipelineEnquiry.js").PipelineEnquiry} PipelineEnquiry
26
+ */
27
+
28
+ const CULLED_LIST_DESCRIPTOR = BufferResourceDescriptor.from(
29
+ COLLECTION_U32_STRUCT_WRITE.size + WORLD_LIGHT_CLUSTER_LIGHT_CAPACITY * u32.size,
30
+ GPUBufferUsage.STORAGE,
31
+ 0,
32
+ 16,
33
+ );
34
+
35
+ const PROXIES_DESCRIPTOR = BufferResourceDescriptor.from(
36
+ WORLD_LIGHT_CLUSTER_LIGHT_CAPACITY * CLUSTER_LIGHT_PROXY.aligned_size,
37
+ GPUBufferUsage.STORAGE,
38
+ );
39
+
40
+ const LOOKUP_DESCRIPTOR = BufferResourceDescriptor.from(
41
+ WORLD_LIGHT_CLUSTER_MAX_CASCADES * WORLD_LIGHT_CLUSTER_CELLS_PER_CASCADE * LIGHT_CLUSTER_METADATA.aligned_size,
42
+ GPUBufferUsage.STORAGE,
43
+ );
44
+
45
+ const DATA_DESCRIPTOR = BufferResourceDescriptor.from(
46
+ COLLECTION_U32_STRUCT_WRITE.size
47
+ + WORLD_LIGHT_CLUSTER_MAX_CASCADES * WORLD_LIGHT_CLUSTER_CELLS_PER_CASCADE * WORLD_LIGHT_CLUSTER_MAX_LIGHTS_PER_CELL * u32.size,
48
+ GPUBufferUsage.STORAGE,
49
+ 0,
50
+ 16,
51
+ );
52
+
53
+ /**
54
+ * Offer the pipelines {@link graph_build_world_light_clusters} dispatches — see {@link PipelineEnquiry}.
55
+ *
56
+ * @param {PipelineEnquiry} enquiry
57
+ */
58
+ export function enquire_build_world_light_clusters_pipelines(enquiry) {
59
+ enquiry.compute.push(shader_world_cluster_cull_point_lights.pipeline);
60
+ enquiry.compute.push(shader_world_cluster_cull_spot_lights.pipeline);
61
+ enquiry.compute.push(shader_world_cluster_assign_lights.pipeline);
62
+ }
63
+
64
+ /**
65
+ * Builds the world-space light cluster clipmap over the cascades of the irradiance clipmap.
66
+ *
67
+ * @param {object} options
68
+ * @param {import("../../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph} options.graph
69
+ * @param {import("../GPULightCollection.js").GPULightCollection} options.lights
70
+ * @param {number} options.irradiance_clipmap_uniform graph handle of the `IRRADIANCE_CLIPMAP_STRUCT` uniform
71
+ * @param {number} options.cascade_count active cascade count
72
+ * @param {ArrayLike<number>} options.coarsest_min `[x, y, z]` world min of coarsest cascade (including skirt)
73
+ * @param {ArrayLike<number>} options.coarsest_max `[x, y, z]` world max of coarsest cascade (including skirt)
74
+ * @returns {{lookup: number, data: number}}
75
+ */
76
+ export function graph_build_world_light_clusters({
77
+ graph,
78
+ lights,
79
+ irradiance_clipmap_uniform,
80
+ cascade_count,
81
+ coarsest_min,
82
+ coarsest_max,
83
+ }) {
84
+ const gr_light_data = lights?.buffer_data instanceof GPUBuffer
85
+ ? graph_import_buffer(graph, lights.buffer_data, "world_cluster/lights_database")
86
+ : -1;
87
+
88
+ const cull_data = {
89
+ lights,
90
+ cascade_count,
91
+ cull_settings: {
92
+ coarsest_min: [coarsest_min[0], coarsest_min[1], coarsest_min[2]],
93
+ cascade_count,
94
+ coarsest_max: [coarsest_max[0], coarsest_max[1], coarsest_max[2]],
95
+ pad0: 0,
96
+ },
97
+ light_data: -1,
98
+ culled_lights: -1,
99
+ proxies: -1,
100
+ };
101
+
102
+ const cull_pass = graph.add("World cluster / cull lights", cull_data, (data, resources, context) => {
103
+ if (data.cascade_count <= 0) {
104
+ return;
105
+ }
106
+
107
+ const point_table = data.lights.database.get("light_point");
108
+ const spot_table = data.lights.database.get("light_spot");
109
+ const point_threads = point_table.dispatch_page_count * point_table.descriptor.elements_per_page;
110
+ const spot_threads = spot_table.dispatch_page_count * spot_table.descriptor.elements_per_page;
111
+
112
+ if (point_threads === 0 && spot_threads === 0) {
113
+ return;
114
+ }
115
+
116
+ const settings_buffer = context.encoder.allocateTransientValueBuffer(
117
+ WORLD_LIGHT_CLUSTER_CULL_SETTINGS,
118
+ data.cull_settings,
119
+ GPUBufferUsage.UNIFORM
120
+ );
121
+
122
+ const bindings = {
123
+ settings: settings_buffer,
124
+ light_data: data.light_data !== -1 ? resources.get(data.light_data) : data.lights.buffer_data,
125
+ output_list: resources.get(data.culled_lights),
126
+ proxies: resources.get(data.proxies),
127
+ };
128
+
129
+ if (point_threads > 0) {
130
+ shader_world_cluster_cull_point_lights.dispatchThreads({
131
+ encoder: context.encoder,
132
+ bindings,
133
+ thread_count_x: point_threads,
134
+ });
135
+ }
136
+
137
+ if (spot_threads > 0) {
138
+ shader_world_cluster_cull_spot_lights.dispatchThreads({
139
+ encoder: context.encoder,
140
+ bindings,
141
+ thread_count_x: spot_threads,
142
+ });
143
+ }
144
+ });
145
+
146
+ if (gr_light_data !== -1) {
147
+ cull_data.light_data = cull_pass.read(gr_light_data);
148
+ }
149
+ cull_data.culled_lights = cull_pass.create("World cluster / culled list", CULLED_LIST_DESCRIPTOR);
150
+ cull_data.proxies = cull_pass.create("World cluster / proxies", PROXIES_DESCRIPTOR);
151
+
152
+ const assign_data = {
153
+ cascade_count,
154
+ irradiance_clipmap: -1,
155
+ culled_lights: -1,
156
+ proxies: -1,
157
+ lookup: -1,
158
+ data: -1,
159
+ };
160
+
161
+ const assign_pass = graph.add("World cluster / assign lights", assign_data, (data, resources, context) => {
162
+ if (data.cascade_count <= 0) {
163
+ return;
164
+ }
165
+
166
+ const groups_xy = Math.ceil(WORLD_LIGHT_CLUSTER_GRID_SIZE / WORLD_CLUSTER_ASSIGN_WORKGROUP_SIZE[0]);
167
+ const groups_z = Math.ceil(
168
+ (WORLD_LIGHT_CLUSTER_GRID_SIZE * data.cascade_count) / WORLD_CLUSTER_ASSIGN_WORKGROUP_SIZE[2]
169
+ );
170
+
171
+ shader_world_cluster_assign_lights.dispatch({
172
+ encoder: context.encoder,
173
+ group_count_x: groups_xy,
174
+ group_count_y: groups_xy,
175
+ group_count_z: groups_z,
176
+ bindings: {
177
+ irradiance_clipmap: resources.get(data.irradiance_clipmap),
178
+ culled_lights: resources.get(data.culled_lights),
179
+ proxies: resources.get(data.proxies),
180
+ world_cluster_lookup: resources.get(data.lookup),
181
+ world_cluster_data: resources.get(data.data),
182
+ },
183
+ });
184
+ });
185
+
186
+ assign_data.irradiance_clipmap = assign_pass.read(irradiance_clipmap_uniform);
187
+ assign_data.culled_lights = assign_pass.read(cull_data.culled_lights);
188
+ assign_data.proxies = assign_pass.read(cull_data.proxies);
189
+ assign_data.lookup = assign_pass.create("World cluster / lookup", LOOKUP_DESCRIPTOR);
190
+ assign_data.data = assign_pass.create("World cluster / data", DATA_DESCRIPTOR);
191
+
192
+ return {
193
+ lookup: assign_data.lookup,
194
+ data: assign_data.data,
195
+ };
196
+ }
@@ -0,0 +1,10 @@
1
+ export const WORLD_CLUSTER_ASSIGN_WORKGROUP_SIZE: readonly number[];
2
+ /**
3
+ * Assigns world-space culled point and spot lights to the `8 × 8 × 8` cluster cells of each
4
+ * cascade of the world-space irradiance clipmap.
5
+ *
6
+ * @type {ComputeShader}
7
+ */
8
+ export const shader_world_cluster_assign_lights: ComputeShader;
9
+ import { ComputeShader } from "../../shader/ComputeShader.js";
10
+ //# sourceMappingURL=shader_world_cluster_assign_lights.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shader_world_cluster_assign_lights.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.js"],"names":[],"mappings":"AAoBA,oEAA4E;AAoI5E;;;;;GAKG;AACH,iDAFU,aAAa,CAMpB;8BA9J2B,+BAA+B"}