@woosh/meep-engine 3.53.0 → 3.54.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 (194) 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/graphics/texture/atlas/SpriteAtlasFill.d.ts +12 -0
  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/graphics/texture/atlas/sprite_atlas_border.d.ts +52 -0
  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/playground/foliage_wind/foliage_world.d.ts +6 -0
  68. package/src/shade/playground/foliage_wind/foliage_world.d.ts.map +1 -1
  69. package/src/shade/playground/foliage_wind/foliage_world.js +602 -593
  70. package/src/shade/playground/foliage_wind/index.html +260 -254
  71. package/src/shade/playground/foliage_wind/main.js +275 -263
  72. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  73. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  74. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
  75. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  76. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  77. package/src/shade/renderer/geometry/sdf/GPUGeometrySDFManager.js +1 -1
  78. package/src/shade/renderer/hiz/HierarchicalZBuffer.d.ts +3 -3
  79. package/src/shade/renderer/hiz/HierarchicalZBuffer.d.ts.map +1 -1
  80. package/src/shade/renderer/hiz/HierarchicalZBuffer.js +350 -294
  81. package/src/shade/renderer/hiz/generate_downsampler_code.d.ts +0 -2
  82. package/src/shade/renderer/hiz/generate_downsampler_code.d.ts.map +1 -1
  83. package/src/shade/renderer/hiz/generate_downsampler_code.js +99 -100
  84. package/src/shade/renderer/hiz/hzb_pick_alignment.d.ts +15 -0
  85. package/src/shade/renderer/hiz/hzb_pick_alignment.d.ts.map +1 -0
  86. package/src/shade/renderer/hiz/hzb_pick_alignment.js +148 -0
  87. package/src/shade/renderer/hiz/hzb_plan_reduction_steps.d.ts +28 -0
  88. package/src/shade/renderer/hiz/hzb_plan_reduction_steps.d.ts.map +1 -0
  89. package/src/shade/renderer/hiz/hzb_plan_reduction_steps.js +58 -0
  90. package/src/shade/renderer/hiz/shader_hzb_reduce_any.d.ts +5 -5
  91. package/src/shade/renderer/hiz/shader_hzb_reduce_any.d.ts.map +1 -1
  92. package/src/shade/renderer/hiz/shader_hzb_reduce_any.js +57 -67
  93. package/src/shade/renderer/hiz/shader_hzb_reduce_mip0_clip.d.ts +3 -3
  94. package/src/shade/renderer/hiz/shader_hzb_reduce_mip0_clip.d.ts.map +1 -1
  95. package/src/shade/renderer/hiz/shader_hzb_reduce_mip0_clip.js +111 -112
  96. package/src/shade/renderer/hiz/shader_hzb_spd.d.ts +5 -0
  97. package/src/shade/renderer/hiz/shader_hzb_spd.d.ts.map +1 -0
  98. package/src/shade/renderer/hiz/shader_hzb_spd.js +160 -0
  99. package/src/shade/renderer/light/GPULightCollection.d.ts +8 -0
  100. package/src/shade/renderer/light/GPULightCollection.d.ts.map +1 -1
  101. package/src/shade/renderer/light/GPULightCollection.js +67 -0
  102. package/src/shade/renderer/light/environment/FAR_FIELD_IRRADIANCE_SH_RESOURCE.d.ts +7 -0
  103. package/src/shade/renderer/light/environment/FAR_FIELD_IRRADIANCE_SH_RESOURCE.d.ts.map +1 -0
  104. package/src/shade/renderer/light/environment/FAR_FIELD_IRRADIANCE_SH_RESOURCE.js +13 -0
  105. package/src/shade/renderer/light/environment/shader_project_far_field_irradiance_sh.d.ts +10 -0
  106. package/src/shade/renderer/light/environment/shader_project_far_field_irradiance_sh.d.ts.map +1 -0
  107. package/src/shade/renderer/light/environment/shader_project_far_field_irradiance_sh.js +72 -0
  108. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.d.ts +39 -0
  109. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.d.ts.map +1 -0
  110. package/src/shade/renderer/light/world_cluster/WORLD_LIGHT_CLUSTER.js +90 -0
  111. package/src/shade/renderer/light/world_cluster/chunk_world_light_cluster_lookup.d.ts +12 -0
  112. package/src/shade/renderer/light/world_cluster/chunk_world_light_cluster_lookup.d.ts.map +1 -0
  113. package/src/shade/renderer/light/world_cluster/chunk_world_light_cluster_lookup.js +56 -0
  114. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.d.ts +31 -0
  115. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.d.ts.map +1 -0
  116. package/src/shade/renderer/light/world_cluster/graph_build_world_light_clusters.js +196 -0
  117. package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.d.ts +10 -0
  118. package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.d.ts.map +1 -0
  119. package/src/shade/renderer/light/world_cluster/shader_world_cluster_assign_lights.js +163 -0
  120. package/src/shade/renderer/light/world_cluster/shader_world_cluster_cull_lights.d.ts +4 -0
  121. package/src/shade/renderer/light/world_cluster/shader_world_cluster_cull_lights.d.ts.map +1 -0
  122. package/src/shade/renderer/light/world_cluster/shader_world_cluster_cull_lights.js +137 -0
  123. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  124. package/src/shade/renderer/particles/GPUParticleSystem.d.ts.map +1 -1
  125. package/src/shade/renderer/particles/GPUParticleSystem.js +4 -3
  126. package/src/shade/renderer/particles/graph_particles_avboit.d.ts +4 -3
  127. package/src/shade/renderer/particles/graph_particles_avboit.d.ts.map +1 -1
  128. package/src/shade/renderer/particles/graph_particles_avboit.js +28 -11
  129. package/src/shade/renderer/particles/shaders/chunk_particle_lighting.d.ts +9 -13
  130. package/src/shade/renderer/particles/shaders/chunk_particle_lighting.d.ts.map +1 -1
  131. package/src/shade/renderer/particles/shaders/chunk_particle_lighting.js +25 -20
  132. package/src/shade/renderer/particles/shaders/shader_particle_avboit_draw.d.ts.map +1 -1
  133. package/src/shade/renderer/particles/shaders/shader_particle_avboit_draw.js +21 -38
  134. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  135. package/src/shade/renderer/shader/chunk/depth/chunk_query_depth_from_screen_space_bb.d.ts.map +1 -1
  136. package/src/shade/renderer/shader/chunk/depth/chunk_query_depth_from_screen_space_bb.js +62 -62
  137. package/src/shade/renderer/shader/chunk/random/lowbias/chunk_hash_lowbias32_vec2u.d.ts +6 -0
  138. package/src/shade/renderer/shader/chunk/random/lowbias/chunk_hash_lowbias32_vec2u.d.ts.map +1 -0
  139. package/src/shade/renderer/shader/chunk/random/lowbias/chunk_hash_lowbias32_vec2u.js +19 -0
  140. package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_get_mip_resolution.d.ts.map +1 -1
  141. package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_get_mip_resolution.js +16 -10
  142. package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_hierarchical_raymarch.d.ts.map +1 -1
  143. package/src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_hierarchical_raymarch.js +118 -117
  144. package/src/shade/renderer/texture/atlas/GPUTileAtlas3D.d.ts +41 -7
  145. package/src/shade/renderer/texture/atlas/GPUTileAtlas3D.d.ts.map +1 -1
  146. package/src/shade/renderer/texture/atlas/GPUTileAtlas3D.js +162 -58
  147. package/src/shade/renderer/volumetrics/GPUSceneVolumetrics.js +1 -1
  148. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts +10 -12
  149. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts.map +1 -1
  150. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +583 -606
  151. package/src/shade/renderer/volumetrics/chunk_volumetrics_froxel_sample.d.ts +24 -0
  152. package/src/shade/renderer/volumetrics/chunk_volumetrics_froxel_sample.d.ts.map +1 -0
  153. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi_sample.d.ts.map +1 -1
  154. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts +1 -1
  155. package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +640 -640
  156. package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.d.ts +113 -0
  157. package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.d.ts.map +1 -0
  158. package/src/shade/renderer/volumetrics/irradiance_clipmap/GPUIrradianceClipmap.js +484 -0
  159. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.d.ts +50 -0
  160. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.d.ts.map +1 -0
  161. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP.js +60 -0
  162. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.d.ts +25 -0
  163. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.d.ts.map +1 -0
  164. package/src/shade/renderer/volumetrics/irradiance_clipmap/IRRADIANCE_CLIPMAP_STRUCT.js +47 -0
  165. package/src/shade/renderer/volumetrics/irradiance_clipmap/IrradianceCascadePlacement.d.ts +74 -0
  166. package/src/shade/renderer/volumetrics/irradiance_clipmap/IrradianceCascadePlacement.d.ts.map +1 -0
  167. package/src/shade/renderer/volumetrics/irradiance_clipmap/IrradianceCascadePlacement.js +173 -0
  168. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.d.ts +26 -0
  169. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.d.ts.map +1 -0
  170. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.js +83 -0
  171. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_local_light.d.ts +31 -0
  172. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_local_light.d.ts.map +1 -0
  173. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_local_light.js +113 -0
  174. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.d.ts +121 -0
  175. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.d.ts.map +1 -0
  176. package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.js +356 -0
  177. package/src/shade/renderer/volumetrics/irradiance_clipmap/shader_irradiance_clipmap_build.d.ts +16 -0
  178. package/src/shade/renderer/volumetrics/irradiance_clipmap/shader_irradiance_clipmap_build.d.ts.map +1 -0
  179. package/src/shade/renderer/volumetrics/irradiance_clipmap/shader_irradiance_clipmap_build.js +191 -0
  180. package/src/shade/renderer/volumetrics/shader_volumetrics_classify_froxels.d.ts +16 -0
  181. package/src/shade/renderer/volumetrics/shader_volumetrics_classify_froxels.d.ts.map +1 -0
  182. package/src/shade/renderer/volumetrics/shader_volumetrics_lighting_regimes.d.ts +23 -0
  183. package/src/shade/renderer/volumetrics/shader_volumetrics_lighting_regimes.d.ts.map +1 -0
  184. package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
  185. package/src/shade/renderer/wind/GPUSceneWind.js +1 -1
  186. package/src/engine/graphics3/decal/DecalAtlasFill.js +0 -32
  187. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_froxel_centre_ws.js +0 -49
  188. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.js +0 -50
  189. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi_sample.js +0 -105
  190. package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.js +0 -80
  191. package/src/shade/renderer/volumetrics/gi/shader_volumetrics_gi.js +0 -51
  192. package/src/shade/renderer/volumetrics/gi/volumetrics_gi_resources.js +0 -39
  193. package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.js +0 -121
  194. package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.js +0 -237
@@ -1,39 +0,0 @@
1
- import { CAMERA_RESOURCE } from "../../camera/CAMERA_RESOURCE.js";
2
- import { ShaderResourceDescriptor } from "../../shader/resource/ShaderResourceDescriptor.js";
3
- import { ShaderResourceGroupDescriptor } from "../../shader/resource/ShaderResourceGroupDescriptor.js";
4
- import { VOLUMETRICS_METADATA_RESOURCE } from "../VOLUMETRICS_RESOURCES.js";
5
-
6
- /**
7
- * The froxel GI's luma volume, as its modules write it (`chunk_volumetrics_gi`).
8
- * @type {ShaderResourceDescriptor}
9
- */
10
- export const VOLUMETRICS_GI_Y_RESOURCE = ShaderResourceDescriptor.storageTexture("tGIY", "rgba16float", "3d", "write-only");
11
-
12
- /**
13
- * The froxel GI's chroma volume, as its modules write it (`chunk_volumetrics_gi`).
14
- * @type {ShaderResourceDescriptor}
15
- */
16
- export const VOLUMETRICS_GI_COCG_RESOURCE = ShaderResourceDescriptor.storageTexture("tGICoCg", "rgba16float", "3d", "write-only");
17
-
18
- /**
19
- * The bindings every froxel GI module has, whatever its mode reads: where the froxels are, and the
20
- * two volumes it writes (`chunk_volumetrics_gi`). rgba16float for both, because rg16float is not a
21
- * storage format without texture-formats-tier1.
22
- *
23
- * @returns {ShaderResourceGroupDescriptor}
24
- */
25
- export function volumetrics_gi_resource_group() {
26
- return new ShaderResourceGroupDescriptor()
27
- .add(VOLUMETRICS_METADATA_RESOURCE)
28
- .add(CAMERA_RESOURCE)
29
- .add(VOLUMETRICS_GI_Y_RESOURCE)
30
- .add(VOLUMETRICS_GI_COCG_RESOURCE);
31
- }
32
-
33
- /**
34
- * Workgroup shape of every froxel GI module, `[x, y, z]` in froxels: flat in z like the lighting
35
- * pass, and 64 invocations.
36
- *
37
- * @type {number[]}
38
- */
39
- export const VOLUMETRICS_GI_WORKGROUP_RESOLUTION = [8, 8, 1];
@@ -1,121 +0,0 @@
1
- import { TextureResourceDescriptor } from "../../device/graph/TextureResourceDescriptor.js";
2
- import { ShaderSwitchSet } from "../shader/compiler/ShaderSwitchSet.js";
3
- import { SHADOWMAP_COMPARE_SAMPLER_DESCRIPTOR } from "../shadow/map/SHADOWMAP_COMPARE_SAMPLER_DESCRIPTOR.js";
4
- import { STATIC_GRAPHICS_ENGINE_ASSETS } from "../STATIC_GRAPHICS_ENGINE_ASSETS.js";
5
- import { DEFAULT_RENDER_TARGET_VIEW_DESCRIPTOR } from "../texture/DEFAULT_RENDER_TARGET_VIEW_DESCRIPTOR.js";
6
- import { graph_build_froxel_gi } from "./gi/graph_build_froxel_gi.js";
7
- import { shader_volumetrics_build_irradiance } from "./shader_volumetrics_build_irradiance.js";
8
-
9
- /**
10
- * The froxel irradiance volume (`chunk_volumetrics_irradiance_sh`), what lit particles are lit by: the
11
- * froxel GI stage (`gi/graph_build_froxel_gi`), then every light with its shadow on top of it
12
- * (`shader_volumetrics_build_irradiance`).
13
- *
14
- * Nothing here reads the fog. The volume is the same with or without participating media, and the
15
- * two passes run only when something reads what they write — the frame graph culls them otherwise,
16
- * which is the frame with no lit particle in it.
17
- *
18
- * @param {Object} options
19
- * @param {import("../../../engine/graphics/render/frame_graph/FrameGraph.js").FrameGraph} options.graph
20
- * @param {import("../camera/GPUCameraContext.js").GPUCameraContext} options.camera
21
- * @param {import("../view/GPUViewContext.js").GPUViewContext} options.view
22
- * @param {import("../light/GPULightCollection.js").GPULightCollection} options.lights
23
- * @param {number} options.light_cluster_data
24
- * @param {number} options.light_cluster_lookup
25
- * @param {number} options.light_cluster_parameters
26
- * @param {number} options.shadowmap_atlas
27
- * @param {number} options.volumetrics_metadata where the froxels are
28
- * @param {number[]} options.resolution the froxel grid
29
- * @param {ShaderSwitchSet} [options.shader_switches] the renderer's; the GI that starts the volume and the
30
- * lights' pass are built for them
31
- * @param {import("../global_illumination/brick4/Brick4LightMap.js").Brick4LightMap} [options.brick4] the scene's,
32
- * while Brick4 runs
33
- * @param {import("../global_illumination/lpv/GPULightProbeVolume.js").GPULightProbeVolume} [options.lpv] the
34
- * scene's, while LPV runs
35
- * @returns {{Y: number, CoCg: number}} handles of the volume: luma SH2, and chroma in `.rg`
36
- */
37
- export function graph_build_froxel_irradiance({
38
- graph,
39
- camera,
40
- view,
41
- lights,
42
- light_cluster_data,
43
- light_cluster_lookup,
44
- light_cluster_parameters,
45
- shadowmap_atlas,
46
- volumetrics_metadata,
47
- resolution,
48
- shader_switches = ShaderSwitchSet.EMPTY,
49
- brick4,
50
- lpv,
51
- }) {
52
-
53
- const gi = graph_build_froxel_gi({
54
- graph,
55
- shader_switches,
56
- brick4,
57
- lpv,
58
- scene_ctx: view.scene,
59
- camera,
60
- volumetrics_metadata,
61
- resolution,
62
- });
63
-
64
- const data = {};
65
-
66
- const pass = graph.add(shader_volumetrics_build_irradiance.descriptor.label, data, (data, resources, context) => {
67
- const output_Y = resources.get(data.irradiance_Y);
68
- const output_CoCg = resources.get(data.irradiance_CoCg);
69
-
70
- // The blue noise the sample is jittered by. Fetched here rather than when the pass is
71
- // recorded: the engine's assets arrive at startup, and this is when the pass needs them.
72
- const tSTBN_vec3 = context.graphics.textures.obtain(STATIC_GRAPHICS_ENGINE_ASSETS.stbn_vec3);
73
-
74
- shader_volumetrics_build_irradiance.variant(shader_switches).dispatchThreads({
75
- encoder: context.encoder,
76
- thread_count_x: output_Y.width,
77
- thread_count_y: output_Y.height,
78
- thread_count_z: output_Y.depth,
79
- bindings: {
80
- volumetrics_metadata: resources.get(data.volumetrics_metadata),
81
- camera: camera.buffer.buffer,
82
- view: view.uniform_buffer.buffer,
83
- tSTBN_vec3: tSTBN_vec3.obtainView(),
84
- tGIY: resources.get(data.gi_Y).obtainView(),
85
- tGICoCg: resources.get(data.gi_CoCg).obtainView(),
86
- tIrradianceY: output_Y.obtainView(DEFAULT_RENDER_TARGET_VIEW_DESCRIPTOR),
87
- tIrradianceCoCg: output_CoCg.obtainView(DEFAULT_RENDER_TARGET_VIEW_DESCRIPTOR),
88
-
89
- light_data: lights.buffer_data,
90
- cluster_parameters: resources.get(data.light_cluster_parameters),
91
- cluster_lookup: resources.get(data.light_cluster_lookup),
92
- cluster_data: resources.get(data.light_cluster_data),
93
- shadowmapAtlas: resources.get(data.shadowmap_atlas).obtainView(),
94
- sCompareLinear: context.graphics.samplers.obtain(SHADOWMAP_COMPARE_SAMPLER_DESCRIPTOR),
95
- },
96
- });
97
- });
98
-
99
- data.volumetrics_metadata = pass.read(volumetrics_metadata);
100
- data.gi_Y = pass.read(gi.Y);
101
- data.gi_CoCg = pass.read(gi.CoCg);
102
- data.light_cluster_data = pass.read(light_cluster_data);
103
- data.light_cluster_lookup = pass.read(light_cluster_lookup);
104
- data.light_cluster_parameters = pass.read(light_cluster_parameters);
105
- data.shadowmap_atlas = pass.read(shadowmap_atlas);
106
-
107
- const volume = (label) => pass.create(label, TextureResourceDescriptor.from({
108
- resolution,
109
- dimension: "3d",
110
- format: "rgba16float",
111
- usage: GPUTextureUsage.STORAGE_BINDING | GPUTextureUsage.TEXTURE_BINDING
112
- }));
113
-
114
- data.irradiance_Y = volume("Froxel Irradiance Y");
115
- data.irradiance_CoCg = volume("Froxel Irradiance CoCg");
116
-
117
- return {
118
- Y: data.irradiance_Y,
119
- CoCg: data.irradiance_CoCg,
120
- };
121
- }
@@ -1,237 +0,0 @@
1
- import { CAMERA_UNIFORM_STRUCT } from "../camera/CAMERA_UNIFORM_STRUCT.js";
2
- import { chunk_light_cluster_counts } from "../light/cluster/chunk_light_cluster_counts.js";
3
- import { chunk_light_cluster_metadata_by_position } from "../light/cluster/chunk_light_cluster_metadata_by_position.js";
4
- import { LIGHT_CLUSTER_LOOKUP_STRUCT } from "../light/cluster/shader_cluster_assign_lights.js";
5
- import { chunk_cluster_depth_from_z_slice } from "../light/cluster/chunk_cluster_depth_from_z_slice.js";
6
- import { chunk_camera_ray_from_uv } from "../shader/chunk/geometry/ray/chunk_camera_ray_from_uv.js";
7
- import { RAY_STRUCT } from "../shader/chunk/geometry/ray/RAY_STRUCT.js";
8
- import { chunk_stbn_sample_vec3 } from "../shader/chunk/noise/chunk_stbn_sample_vec3.js";
9
- import {
10
- chunk_directional_lights_iteration_mask
11
- } from "../shader/chunk/light/io/chunk_directional_lights_iteration_mask.js";
12
- import {
13
- chunk_get_directional_light_info_by_index
14
- } from "../shader/chunk/light/io/chunk_get_directional_light_info_by_index.js";
15
- import {
16
- chunk_get_point_light_info_by_index
17
- } from "../shader/chunk/light/io/chunk_get_point_light_info_by_index.js";
18
- import { chunk_get_spot_light_info_by_index } from "../shader/chunk/light/io/chunk_get_spot_light_info_by_index.js";
19
- import {
20
- METRO_L1_IRRADIANCE_STRUCT
21
- } from "../shader/chunk/spherical_harmonics/l1i/chunk_convert_to_irradiance_sh.js";
22
- import { chunk_texel_coordinate_to_uv } from "../shader/chunk/texture/chunk_texel_coordinate_to_uv.js";
23
- import { chunk_uv_to_texel_coordinate } from "../shader/chunk/texture/chunk_uv_to_texel_coordinate.js";
24
- import { CodeChunk } from "../shader/compiler/CodeChunk.js";
25
- import { ComputeShader } from "../shader/ComputeShader.js";
26
- import { ShaderResourceSetDescriptor } from "../shader/resource/ShaderResourceSetDescriptor.js";
27
- import { vec3f } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
28
- import { WebGPUArray } from "../shader/type/WebGPUArray.js";
29
- import { chunk_shadowmap_get_light_visibility } from "../shadow/map/shader/chunk_shadowmap_get_light_visibility.js";
30
- import { SHADOWMAP_COMPARE_SAMPLER_DESCRIPTOR } from "../shadow/map/SHADOWMAP_COMPARE_SAMPLER_DESCRIPTOR.js";
31
- import { VIEW_UNIFORM_STRUCT } from "../view/VIEW_UNIFORM_STRUCT.js";
32
- import { chunk_volumetrics_irradiance_sh } from "./chunk_volumetrics_irradiance_sh.js";
33
- import { chunk_volumetrics_local_light_shadow } from "./chunk_volumetrics_local_light_shadow.js";
34
- import { chunk_camera_ray_planar_depth_scale } from "./chunk_camera_ray_planar_depth_scale.js";
35
- import { chunk_volumetrics_column_jitter } from "./chunk_volumetrics_column_jitter.js";
36
- import { VOLUMETRICS_METADATA_STRUCT } from "./VOLUMETRICS_METADATA_STRUCT.js";
37
-
38
- /**
39
- * Workgroup shape of this pass, `[x, y, z]` in froxels, stated to the `@workgroup_size` below and
40
- * read back out of it by the dispatch. Flat in z and 64 invocations, for the reasons the fog's
41
- * lighting pass gives (`VOLUMETRICS_LIGHTING_WORKGROUP_RESOLUTION`): it walks the same light
42
- * clusters, and those are farthest apart along depth.
43
- *
44
- * @type {number[]}
45
- */
46
- export const VOLUMETRICS_IRRADIANCE_WORKGROUP_RESOLUTION = [8, 8, 1];
47
-
48
- /**
49
- * The most point lights, and separately spot lights, of a froxel's cluster cell this pass adds, each with
50
- * its shadow tap. Chosen, not derived. Past it the rest of that type's list in the cell goes unshaded: the highest ids, except within one 32-light window where the GPU's lane order decides (PROPOSAL_HIERARCHICAL, I.6).
51
- * @type {number}
52
- */
53
- export const VOLUMETRICS_IRRADIANCE_LIGHT_BUDGET = 32;
54
-
55
- const resources = new ShaderResourceSetDescriptor();
56
-
57
- // The froxel irradiance volume (chunk_volumetrics_irradiance_sh): luma SH2 in one, chroma in the .rg
58
- // of the other. rgba16float for both, because rg16float is not a storage format without
59
- // texture-formats-tier1. It starts from what the froxel GI stage (gi/) wrote to tGIY / tGICoCg.
60
- resources.createGroup()
61
- .addUniform("volumetrics_metadata", VOLUMETRICS_METADATA_STRUCT)
62
- .addUniform("camera", CAMERA_UNIFORM_STRUCT)
63
- .addUniform("view", VIEW_UNIFORM_STRUCT)
64
- .addTexture("tSTBN_vec3", "unfilterable-float", "3d")
65
- .addTexture("tGIY", "float", "3d")
66
- .addTexture("tGICoCg", "float", "3d")
67
- .addStorageTexture("tIrradianceY", "rgba16float", "3d", "write-only")
68
- .addStorageTexture("tIrradianceCoCg", "rgba16float", "3d", "write-only");
69
-
70
- // Lighting information
71
- resources.createGroup()
72
- .addStorageBuffer("light_data", WebGPUArray.u32)
73
- // clusters
74
- .addUniform("cluster_parameters", vec3f)
75
- .addStorageBuffer("cluster_lookup", LIGHT_CLUSTER_LOOKUP_STRUCT)
76
- .addStorageBuffer("cluster_data", WebGPUArray.u32)
77
- // shadows
78
- .addTexture("shadowmapAtlas", "depth")
79
- .addSampler("sCompareLinear", "comparison", SHADOWMAP_COMPARE_SAMPLER_DESCRIPTOR);
80
-
81
- const body = CodeChunk.from(
82
- //language=WGSL
83
- `
84
- @compute @workgroup_size(${VOLUMETRICS_IRRADIANCE_WORKGROUP_RESOLUTION.join(",")})
85
- fn main(
86
- @builtin(global_invocation_id) voxel : vec3<u32>
87
- ){
88
- let resolution = textureDimensions(tIrradianceY);
89
-
90
- if (any(voxel >= resolution)) {
91
- return;
92
- }
93
-
94
- // The fog lighting pass's sample, taken the same way (shader_volumetrics_build_lighting, where
95
- // the irradiance was written until it had a pass of its own): one point per froxel per frame,
96
- // jittered across the slab in depth by the column jitter and the blue noise, and in xy by the
97
- // blue noise. Never a fixed point. A particle spans many froxels and reads them trilinearly, and
98
- // a lattice of samples that never moves shows on it as seams wherever neighbouring texels
99
- // disagree — beside a light, along a shadow edge. Moved every frame, the lattice is resolved by
100
- // the main TAA, which the particles are drawn ahead of.
101
- let near_far = camera.clip_near_far;
102
- let curve = volumetrics_metadata.froxel_cluster_parameters;
103
-
104
- let z_jitter = volumetrics_column_jitter(voxel.xy, view.frame_index);
105
-
106
- let z0 = max(near_far.x, cluster_depth_from_z_slice(f32(voxel.z) + z_jitter, curve, f32(resolution.z)));
107
- let z1 = min(near_far.y, cluster_depth_from_z_slice(f32(voxel.z + 1u) + z_jitter, curve, f32(resolution.z)));
108
-
109
- // the lighting pass's offset and temporal axis, so the two passes ask about the same point
110
- const STBN_DECORRELATION_OFFSET = vec2<u32>(37u, 71u);
111
-
112
- let noise = stbn_sample_vec3(vec3(voxel.xy + STBN_DECORRELATION_OFFSET, view.frame_index + voxel.z));
113
-
114
- // interpolate the cubes, then take the cube root: uniform in world-space volume across the slab
115
- let view_depth = pow(mix(z0 * z0 * z0, z1 * z1 * z1, noise.z), 0.333333);
116
-
117
- let tile_uv = saturate(texel_coordinate_to_uv(vec2<f32>(voxel.xy) + (noise.xy - 0.5), resolution.xy));
118
- let view_ray = camera_ray_from_uv(tile_uv, camera);
119
-
120
- // view_depth is planar, so step the ray by the planar-to-distance scale
121
- let position_ws = view_ray.origin
122
- + view_ray.direction * (view_depth * camera_ray_planar_depth_scale(view_ray.direction, camera));
123
-
124
- let view_pixel_coord = uv_to_texel_coordinate(tile_uv, vec2(view.width, view.height));
125
-
126
- var irradiance: ${METRO_L1_IRRADIANCE_STRUCT.wgsl_ref};
127
-
128
- // Each light as the surfaces around the froxel receive it: its colour and its shadow, and no
129
- // medium on the way in. The deferred and forward paths light meshes by exactly this, and a lit
130
- // particle beside a lit log has to agree with it — the fog is composited over both afterwards.
131
-
132
- var directional_bits = directional_lights_iteration_mask(&light_data);
133
- while (directional_bits != 0u) {
134
- let directional_index = countTrailingZeros(directional_bits);
135
- directional_bits &= ~(1u << directional_index);
136
-
137
- let sun = get_directional_light_info_by_index(&light_data, directional_index);
138
-
139
- let shadow_term = shadowmap_get_directional_light_visibility(
140
- &light_data,
141
- directional_index,
142
- position_ws,
143
- // toward-camera, the deferred cascade-blend convention; view_ray runs camera->scene
144
- -view_ray.direction,
145
- sun.direction
146
- );
147
-
148
- irradiance = volumetrics_irradiance_sh_add(irradiance, shadow_term * sun.color, sun.direction);
149
- }
150
-
151
- let cluster_metadata = light_cluster_metadata_by_position(
152
- view_pixel_coord,
153
- view_depth,
154
- vec2(view.width, view.height)
155
- );
156
-
157
- let cluster_offset = cluster_metadata.offset;
158
- let point_count = light_cluster_count_point(cluster_metadata.counts);
159
- let spot_count = light_cluster_count_spot(cluster_metadata.counts);
160
-
161
- // Budget: VOLUMETRICS_IRRADIANCE_LIGHT_BUDGET
162
- for (var j = 0u; j < min(point_count, ${VOLUMETRICS_IRRADIANCE_LIGHT_BUDGET}u); j++) {
163
- let light_index = cluster_data[cluster_offset + j];
164
- let direct_light = get_point_light_info_by_index(&light_data, light_index, position_ws);
165
-
166
- if (all(direct_light.color == vec3(0.0))) {
167
- continue;
168
- }
169
-
170
- let shadow_term = volumetrics_point_light_shadow(&light_data, light_index, position_ws);
171
-
172
- irradiance = volumetrics_irradiance_sh_add(irradiance, shadow_term * direct_light.color, direct_light.direction);
173
- }
174
-
175
- // Budget: VOLUMETRICS_IRRADIANCE_LIGHT_BUDGET
176
- for (var k = 0u; k < min(spot_count, ${VOLUMETRICS_IRRADIANCE_LIGHT_BUDGET}u); k++) {
177
- let light_index = cluster_data[cluster_offset + point_count + k];
178
- let direct_light = get_spot_light_info_by_index(&light_data, light_index, position_ws);
179
-
180
- if (all(direct_light.color == vec3(0.0))) {
181
- continue;
182
- }
183
-
184
- let shadow_term = volumetrics_spot_light_shadow(&light_data, light_index, position_ws);
185
-
186
- irradiance = volumetrics_irradiance_sh_add(irradiance, shadow_term * direct_light.color, direct_light.direction);
187
- }
188
-
189
- // What the renderer's indirect lighting gives this froxel, in the same encoding; the lights add
190
- // to it. Written by the froxel GI module the mode selects, which is all this pass knows of GI.
191
- irradiance.Y += textureLoad(tGIY, voxel, 0);
192
- irradiance.CoCg += textureLoad(tGICoCg, voxel, 0).xy;
193
-
194
- // nothing filters this volume, so nothing downstream would stop an Inf or a NaN here
195
- let stored = volumetrics_irradiance_sh_storable(irradiance);
196
-
197
- textureStore(tIrradianceY, voxel, stored.Y);
198
- textureStore(tIrradianceCoCg, voxel, vec4<f32>(stored.CoCg, 0.0, 0.0));
199
- }
200
- `, [
201
- METRO_L1_IRRADIANCE_STRUCT.declaration_chunk,
202
- RAY_STRUCT.declaration_chunk,
203
- chunk_volumetrics_column_jitter,
204
- chunk_cluster_depth_from_z_slice,
205
- chunk_stbn_sample_vec3,
206
- chunk_texel_coordinate_to_uv,
207
- chunk_uv_to_texel_coordinate,
208
- chunk_camera_ray_from_uv,
209
- chunk_camera_ray_planar_depth_scale,
210
-
211
- chunk_light_cluster_metadata_by_position,
212
- chunk_light_cluster_counts,
213
- chunk_directional_lights_iteration_mask,
214
- chunk_get_directional_light_info_by_index,
215
- chunk_get_point_light_info_by_index,
216
- chunk_get_spot_light_info_by_index,
217
- chunk_shadowmap_get_light_visibility,
218
- chunk_volumetrics_local_light_shadow,
219
- chunk_volumetrics_irradiance_sh,
220
- ]
221
- );
222
-
223
- /**
224
- * The froxel irradiance volume (`chunk_volumetrics_irradiance_sh`): what a lit particle standing in a
225
- * froxel is lit by. Starts from the froxel GI stage's volume and adds every directional, point and
226
- * spot light with its shadow, at a point jittered through the froxel every frame.
227
- *
228
- * Its own pass, not a by-product of the fog's lighting pass: particle lighting needs no medium, so it
229
- * runs whether or not the scene has any fog, and the frame graph culls it when nothing reads it.
230
- *
231
- * @type {ComputeShader}
232
- */
233
- export const shader_volumetrics_build_irradiance = ComputeShader.from({
234
- label: "Volumetrics / build irradiance",
235
- resources,
236
- body,
237
- });