@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
@@ -1,325 +1,363 @@
1
- import { AbstractTextureAtlas } from "./AbstractTextureAtlas.js";
2
-
3
- class PatchRecord {
4
- /**
5
- *
6
- * @type {AtlasPatch|null}
7
- */
8
- patch = null;
9
-
10
- /**
11
- * When was the patch last used
12
- * @type {number}
13
- */
14
- last_use_time = 0;
15
- }
16
-
17
- /**
18
- * Adding and removing elements to atlas can be costly. It can trigger repack, it may require splatting or cleaning.
19
- * This abstraction allows us to bypass that most of the time by caching unused patches and just reusing them in the future
20
- * if they are requested again.
21
- *
22
- * The caching strategy here is a little unusual. The texture atlas has a certain size, and the cache will use as much of
23
- * the atlas space as it can. Meaning that if there is not much unused space - the cache will be very small
24
- * And if only a small part of the atlas is area is used by "live" patches, the cache can be quite large
25
- */
26
- export class CachingTextureAtlas extends AbstractTextureAtlas {
27
- /**
28
- *
29
- * @type {PatchRecord[]}
30
- * @private
31
- */
32
- __cached_patches = [];
33
-
34
- /**
35
- *
36
- * @param {Object} options
37
- * @param {AbstractTextureAtlas} options.atlas
38
- */
39
- constructor({
40
- atlas
41
- }) {
42
- super();
43
-
44
- /**
45
- *
46
- * @type {TextureAtlas}
47
- * @private
48
- */
49
- this.__atals = atlas;
50
- }
51
-
52
- /**
53
- * Finds an entry in the cache to evict
54
- * @returns {number}
55
- * @private
56
- */
57
- __find_eviction_target() {
58
- let best_date = Infinity;
59
- let best_node = -1;
60
-
61
- const records = this.__cached_patches;
62
- const n = records.length;
63
-
64
- for (let i = 0; i < n; i++) {
65
- const record = records[i];
66
-
67
- const date = record.last_use_time;
68
-
69
- if (date < best_date) {
70
- best_node = i;
71
- best_date = date;
72
- }
73
-
74
- }
75
-
76
- return best_node;
77
- }
78
-
79
- /**
80
- * Finds an entry in the cache that could be replaced with an incoming element
81
- * @private
82
- * @returns {number}
83
- * @param {number} width
84
- * @param {number} height
85
- */
86
- __find_replacement_target(width, height) {
87
- // find the smallest element in area that is least recently used in cache
88
- let best_area = Infinity;
89
- let best_date = Infinity;
90
-
91
- let best_node = -1;
92
-
93
- const records = this.__cached_patches;
94
- const n = records.length;
95
- for (let i = 0; i < n; i++) {
96
- const record = records[i];
97
-
98
- const packing = record.patch.packing;
99
-
100
- const w = packing.x1 - packing.x0;
101
- const h = packing.y1 - packing.y0;
102
-
103
- if (w < width || h < height) {
104
- // too small
105
- continue;
106
- }
107
-
108
- const area = w * h;
109
-
110
- if (area > best_area) {
111
- // prefer smaller patches to evict, as they are cheaper to pull back later on
112
- continue;
113
- }
114
-
115
- const date = record.last_use_time;
116
-
117
- if (date >= best_date) {
118
- // prefer patches that have been in cache the longest (the oldest records)
119
- continue;
120
- }
121
-
122
- // found a better candidate, update
123
-
124
- best_area = area;
125
- best_date = date;
126
-
127
- best_node = i;
128
- }
129
-
130
- return best_node;
131
- }
132
-
133
- /**
134
- * Will evict specified element from cache
135
- * @private
136
- * @param {number} index
137
- */
138
- __evict(index) {
139
- const records = this.__cached_patches;
140
- const record = records[index];
141
-
142
- records.splice(index, 1);
143
- this.__atals.remove(record.patch);
144
- }
145
-
146
- /**
147
- * Evict all cached elements, purging the cache
148
- * @private
149
- */
150
- __evict_all() {
151
- for (let i = this.__cached_patches.length - 1; i >= 0; i--) {
152
- this.__evict(i);
153
- }
154
- }
155
-
156
- /**
157
- * Free up space in cache to accommodate certain area
158
- * @private
159
- * @param {number} width
160
- * @param {number} height
161
- * @returns {boolean} true if enough space was freed up to fit specified area, false otherwise
162
- */
163
- __evict_for(width, height) {
164
- if (this.__cached_patches.length <= 0) {
165
- // nothing to evict
166
- return false;
167
- }
168
-
169
- const target = this.__find_replacement_target(width, height);
170
-
171
- if (target !== -1) {
172
- // evicted just one element
173
- this.__evict(target);
174
- return true;
175
- }
176
-
177
- while (!this.__atals.can_pack(width, height)) {
178
- const victim = this.__find_eviction_target();
179
-
180
- if (victim === -1) {
181
- return false;
182
- }
183
-
184
- this.__evict(victim);
185
- }
186
-
187
- return true;
188
- }
189
-
190
- update() {
191
- try {
192
- this.__atals.update();
193
- } catch (e) {
194
- // failed to perform update
195
-
196
- if (this.__cached_patches.length > 0) {
197
-
198
- // has some caches patches, lets drop them
199
- this.__evict_all();
200
-
201
- // try to update again
202
- this.__atals.update();
203
-
204
- } else {
205
- // just re-throw
206
- throw e;
207
- }
208
- }
209
- }
210
-
211
- /**
212
- *
213
- * @returns {AbstractTextureAtlas}
214
- */
215
- get atlas() {
216
- return this.__atals;
217
- }
218
-
219
- /**
220
- *
221
- * @return {Sampler2D}
222
- */
223
- get sampler() {
224
- return this.__atals.sampler;
225
- }
226
-
227
- reset() {
228
- this.__cached_patches.splice(0, this.__cached_patches.length);
229
- this.__atals.reset();
230
- }
231
-
232
- /**
233
- *
234
- * @param {Sampler2D} sampler
235
- * @returns {number}
236
- * @private
237
- */
238
- __find_cache_record_index(sampler) {
239
- const records = this.__cached_patches;
240
- const n = records.length;
241
- for (let i = 0; i < n; i++) {
242
- if (records[i].patch.sampler === sampler) {
243
- return i;
244
- }
245
- }
246
-
247
- return -1;
248
- }
249
-
250
- /**
251
- *
252
- * @param {AtlasPatch} patch
253
- * @returns {number}
254
- * @private
255
- */
256
- __find_cache_record_index_by_patch(patch) {
257
- const records = this.__cached_patches;
258
- const n = records.length;
259
- for (let i = 0; i < n; i++) {
260
- if (records[i].patch === patch) {
261
- return i;
262
- }
263
- }
264
-
265
- return -1;
266
- }
267
-
268
- add(sampler, padding = 4) {
269
- const existing_patch_index = this.__find_cache_record_index(sampler);
270
-
271
- const records = this.__cached_patches;
272
-
273
- if (existing_patch_index !== -1) {
274
- // cache hit
275
-
276
- const record = records[existing_patch_index];
277
-
278
- // remove from cache
279
- records.splice(existing_patch_index, 1);
280
-
281
- // return patch
282
- return record.patch;
283
- }
284
-
285
- const w = sampler.width + padding * 2;
286
- const h = sampler.height + padding * 2;
287
-
288
- if (records.length > 0 && !this.__atals.can_pack(w, h)) {
289
- // new element will not fit, lets try to evict some cache to try and accommodate it
290
- // note that eviction will purge the entire cache in case that this patch doesn't fit
291
- this.__evict_for(w, h);
292
- }
293
-
294
- return this.__atals.add(sampler, padding);
295
- }
296
-
297
- /**
298
- *
299
- * @param {AtlasPatch} patch
300
- */
301
- remove(patch) {
302
-
303
- // validate presence of patch in the atlas
304
- if (!this.__atals.contains(patch)) {
305
- return false;
306
- }
307
-
308
- const index = this.__find_cache_record_index_by_patch(patch);
309
-
310
- if (index !== -1) {
311
- // already in the cache
312
- return false;
313
- }
314
-
315
- // push to cache, let eviction logic handle the rest
316
- const record = new PatchRecord();
317
-
318
- record.last_use_time = performance.now();
319
- record.patch = patch;
320
-
321
- this.__cached_patches.push(record);
322
-
323
- return true;
324
- }
325
- }
1
+ import { AbstractTextureAtlas } from "./AbstractTextureAtlas.js";
2
+ import { AtlasPatchFlag } from "./AtlasPatchFlag.js";
3
+
4
+ class PatchRecord {
5
+ /**
6
+ *
7
+ * @type {AtlasPatch|null}
8
+ */
9
+ patch = null;
10
+
11
+ /**
12
+ * When was the patch last used
13
+ * @type {number}
14
+ */
15
+ last_use_time = 0;
16
+ }
17
+
18
+ /**
19
+ * Adding and removing elements to atlas can be costly. It can trigger repack, it may require splatting or cleaning.
20
+ * This abstraction allows us to bypass that most of the time by caching unused patches and just reusing them in the future
21
+ * if they are requested again.
22
+ *
23
+ * The caching strategy here is a little unusual. The texture atlas has a certain size, and the cache will use as much of
24
+ * the atlas space as it can. Meaning that if there is not much unused space - the cache will be very small
25
+ * And if only a small part of the atlas is area is used by "live" patches, the cache can be quite large
26
+ */
27
+ export class CachingTextureAtlas extends AbstractTextureAtlas {
28
+ /**
29
+ *
30
+ * @type {PatchRecord[]}
31
+ * @private
32
+ */
33
+ __cached_patches = [];
34
+
35
+ /**
36
+ *
37
+ * @param {Object} options
38
+ * @param {AbstractTextureAtlas} options.atlas
39
+ */
40
+ constructor({
41
+ atlas
42
+ }) {
43
+ super();
44
+
45
+ /**
46
+ *
47
+ * @type {TextureAtlas}
48
+ * @private
49
+ */
50
+ this.__atlas = atlas;
51
+
52
+ if (atlas !== null && atlas !== undefined && atlas.on !== undefined && atlas.on.removed !== undefined) {
53
+ atlas.on.removed.add(this.__handle_patch_removed, this);
54
+ }
55
+ }
56
+
57
+ /**
58
+ * @param {AtlasPatch} patch
59
+ * @private
60
+ */
61
+ __handle_patch_removed(patch) {
62
+ const index = this.__find_cache_record_index_by_patch(patch);
63
+
64
+ if (index !== -1) {
65
+ this.__cached_patches.splice(index, 1);
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Finds an entry in the cache to evict
71
+ * @returns {number}
72
+ * @private
73
+ */
74
+ __find_eviction_target() {
75
+ let best_date = Infinity;
76
+ let best_node = -1;
77
+
78
+ const records = this.__cached_patches;
79
+ const n = records.length;
80
+
81
+ for (let i = 0; i < n; i++) {
82
+ const record = records[i];
83
+
84
+ const date = record.last_use_time;
85
+
86
+ if (date < best_date) {
87
+ best_node = i;
88
+ best_date = date;
89
+ }
90
+
91
+ }
92
+
93
+ return best_node;
94
+ }
95
+
96
+ /**
97
+ * Finds an entry in the cache that could be replaced with an incoming element
98
+ * @private
99
+ * @returns {number}
100
+ * @param {number} width
101
+ * @param {number} height
102
+ */
103
+ __find_replacement_target(width, height) {
104
+ // find the smallest element in area that is least recently used in cache
105
+ let best_area = Infinity;
106
+ let best_date = Infinity;
107
+
108
+ let best_node = -1;
109
+
110
+ const records = this.__cached_patches;
111
+ const n = records.length;
112
+ for (let i = 0; i < n; i++) {
113
+ const record = records[i];
114
+
115
+ if (!record.patch.getFlag(AtlasPatchFlag.Packed)) {
116
+ // removing an unpacked patch does not free a rectangle in the packer
117
+ continue;
118
+ }
119
+
120
+ const packing = record.patch.packing;
121
+
122
+ const w = packing.x1 - packing.x0;
123
+ const h = packing.y1 - packing.y0;
124
+
125
+ if (w < width || h < height) {
126
+ // too small
127
+ continue;
128
+ }
129
+
130
+ const area = w * h;
131
+ const date = record.last_use_time;
132
+
133
+ if (area > best_area || (area === best_area && date >= best_date)) {
134
+ // prefer smaller patches to evict, as they are cheaper to pull back later on;
135
+ // break ties by preferring patches that have been in cache the longest
136
+ continue;
137
+ }
138
+
139
+ // found a better candidate, update
140
+
141
+ best_area = area;
142
+ best_date = date;
143
+
144
+ best_node = i;
145
+ }
146
+
147
+ return best_node;
148
+ }
149
+
150
+ /**
151
+ * Will evict specified element from cache
152
+ * @private
153
+ * @param {number} index
154
+ */
155
+ __evict(index) {
156
+ const records = this.__cached_patches;
157
+ const record = records[index];
158
+
159
+ records.splice(index, 1);
160
+ this.__atlas.remove(record.patch);
161
+ }
162
+
163
+ /**
164
+ * Evict all cached elements, purging the cache
165
+ * @private
166
+ */
167
+ __evict_all() {
168
+ for (let i = this.__cached_patches.length - 1; i >= 0; i--) {
169
+ this.__evict(i);
170
+ }
171
+ }
172
+
173
+ /**
174
+ * Free up space in cache to accommodate certain area
175
+ * @private
176
+ * @param {number} width
177
+ * @param {number} height
178
+ * @returns {boolean} true if enough space was freed up to fit specified area, false otherwise
179
+ */
180
+ __evict_for(width, height) {
181
+ if (this.__cached_patches.length <= 0) {
182
+ // nothing to evict
183
+ return false;
184
+ }
185
+
186
+ const target = this.__find_replacement_target(width, height);
187
+
188
+ if (target !== -1) {
189
+ // evicted just one element
190
+ this.__evict(target);
191
+ return true;
192
+ }
193
+
194
+ while (!this.__atlas.can_pack(width, height)) {
195
+ const victim = this.__find_eviction_target();
196
+
197
+ if (victim === -1) {
198
+ return false;
199
+ }
200
+
201
+ this.__evict(victim);
202
+ }
203
+
204
+ return true;
205
+ }
206
+
207
+ update() {
208
+ if (
209
+ this.__cached_patches.length > 0
210
+ && typeof this.__atlas.needsUpdate === 'function'
211
+ && this.__atlas.needsUpdate()
212
+ && typeof this.__atlas.pack === 'function'
213
+ ) {
214
+ while (!this.__atlas.pack() && this.__cached_patches.length > 0) {
215
+ const victim = this.__find_eviction_target();
216
+
217
+ if (victim === -1) {
218
+ break;
219
+ }
220
+
221
+ this.__evict(victim);
222
+ }
223
+ }
224
+
225
+ try {
226
+ this.__atlas.update();
227
+ } catch (e) {
228
+ // failed to perform update
229
+
230
+ if (this.__cached_patches.length > 0) {
231
+
232
+ // has some cached patches, lets drop them
233
+ this.__evict_all();
234
+
235
+ // try to update again
236
+ this.__atlas.update();
237
+
238
+ } else {
239
+ // just re-throw
240
+ throw e;
241
+ }
242
+ }
243
+ }
244
+
245
+ /**
246
+ *
247
+ * @returns {AbstractTextureAtlas}
248
+ */
249
+ get atlas() {
250
+ return this.__atlas;
251
+ }
252
+
253
+ /**
254
+ *
255
+ * @return {Sampler2D}
256
+ */
257
+ get sampler() {
258
+ return this.__atlas.sampler;
259
+ }
260
+
261
+ reset() {
262
+ this.__cached_patches.splice(0, this.__cached_patches.length);
263
+ this.__atlas.reset();
264
+ }
265
+
266
+ /**
267
+ *
268
+ * @param {Sampler2D} sampler
269
+ * @returns {number}
270
+ * @private
271
+ */
272
+ __find_cache_record_index(sampler) {
273
+ const records = this.__cached_patches;
274
+ const n = records.length;
275
+ for (let i = 0; i < n; i++) {
276
+ if (records[i].patch.sampler === sampler) {
277
+ return i;
278
+ }
279
+ }
280
+
281
+ return -1;
282
+ }
283
+
284
+ /**
285
+ *
286
+ * @param {AtlasPatch} patch
287
+ * @returns {number}
288
+ * @private
289
+ */
290
+ __find_cache_record_index_by_patch(patch) {
291
+ const records = this.__cached_patches;
292
+ const n = records.length;
293
+ for (let i = 0; i < n; i++) {
294
+ if (records[i].patch === patch) {
295
+ return i;
296
+ }
297
+ }
298
+
299
+ return -1;
300
+ }
301
+
302
+ add(sampler, padding = 4) {
303
+ const existing_patch_index = this.__find_cache_record_index(sampler);
304
+
305
+ const records = this.__cached_patches;
306
+
307
+ if (existing_patch_index !== -1) {
308
+ // cache hit
309
+
310
+ const record = records[existing_patch_index];
311
+
312
+ // remove from cache
313
+ records.splice(existing_patch_index, 1);
314
+
315
+ // return patch
316
+ return record.patch;
317
+ }
318
+
319
+ const effective_padding = typeof this.__atlas.compute_padding === 'function'
320
+ ? this.__atlas.compute_padding(sampler, padding)
321
+ : padding;
322
+
323
+ const w = sampler.width + effective_padding * 2;
324
+ const h = sampler.height + effective_padding * 2;
325
+
326
+ if (records.length > 0 && !this.__atlas.can_pack(w, h)) {
327
+ // new element will not fit, lets try to evict some cache to try and accommodate it
328
+ // note that eviction will purge the entire cache in case that this patch doesn't fit
329
+ this.__evict_for(w, h);
330
+ }
331
+
332
+ return this.__atlas.add(sampler, effective_padding);
333
+ }
334
+
335
+ /**
336
+ *
337
+ * @param {AtlasPatch} patch
338
+ */
339
+ remove(patch) {
340
+
341
+ // validate presence of patch in the atlas
342
+ if (!this.__atlas.contains(patch)) {
343
+ return false;
344
+ }
345
+
346
+ const index = this.__find_cache_record_index_by_patch(patch);
347
+
348
+ if (index !== -1) {
349
+ // already in the cache
350
+ return false;
351
+ }
352
+
353
+ // push to cache, let eviction logic handle the rest
354
+ const record = new PatchRecord();
355
+
356
+ record.last_use_time = performance.now();
357
+ record.patch = patch;
358
+
359
+ this.__cached_patches.push(record);
360
+
361
+ return true;
362
+ }
363
+ }