@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,27 +1,30 @@
1
- import { RenderPipelineDescriptor } from "../../../descriptor/pipeline/render/RenderPipelineDescriptor.js";
2
1
  import { DepthStencilState } from "../../../descriptor/pipeline/render/DepthStencilState.js";
3
- import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
2
+ import { RenderPipelineDescriptor } from "../../../descriptor/pipeline/render/RenderPipelineDescriptor.js";
4
3
  import { CAMERA_UNIFORM_STRUCT } from "../../camera/CAMERA_UNIFORM_STRUCT.js";
5
4
  import { chunk_sample_volumetrics } from "../../deferred/chunk_sample_volumetrics.js";
6
5
  import { AVBOIT_EXTINCT_TRANSMITTANCE } from "../../rasterize/native/avboit/AVBOIT_CONSTANTS.js";
7
- import { AVBOIT_WARP_STRUCT } from "../../rasterize/native/avboit/AVBOIT_WARP_STRUCT.js";
8
6
  import { AVBOIT_DRAW_TARGETS } from "../../rasterize/native/avboit/avboit_draw_fragment_body.js";
9
- import { chunk_avboit_view_depth_to_virtual } from "../../rasterize/native/avboit/chunk_avboit_view_depth_to_virtual.js";
7
+ import { AVBOIT_WARP_STRUCT } from "../../rasterize/native/avboit/AVBOIT_WARP_STRUCT.js";
10
8
  import { chunk_avboit_footprint_bias } from "../../rasterize/native/avboit/chunk_avboit_footprint_bias.js";
11
9
  import { chunk_avboit_sample_transmittance } from "../../rasterize/native/avboit/chunk_avboit_sample_transmittance.js";
12
- import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
10
+ import { chunk_avboit_view_depth_to_virtual } from "../../rasterize/native/avboit/chunk_avboit_view_depth_to_virtual.js";
13
11
  import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
14
12
  import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
13
+ import { ShaderDescriptor } from "../../shader/ShaderDescriptor.js";
14
+ import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
15
15
  import { SAMPLER_LINEAR_UPSCALE } from "../../texture/SAMPLER_LINEAR_UPSCALE.js";
16
- import { VIEW_UNIFORM_STRUCT } from "../../view/VIEW_UNIFORM_STRUCT.js";
17
16
  import { chunk_view_mip_bias } from "../../view/chunk_view_mip_bias.js";
17
+ import { VIEW_UNIFORM_STRUCT } from "../../view/VIEW_UNIFORM_STRUCT.js";
18
+ import {
19
+ irradiance_clipmap_add_resources
20
+ } from "../../volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_sample.js";
18
21
  import { VOLUMETRICS_METADATA_STRUCT } from "../../volumetrics/VOLUMETRICS_METADATA_STRUCT.js";
19
22
  import { EMITTER_FLAG } from "../data/PARTICLE_EMITTER_STRUCT.js";
20
23
  import { PARTICLE_SOFT_FADE_RANGE } from "../ParticleConstants.js";
21
24
  import { chunk_particle_avboit_contribution } from "./chunk_particle_avboit_contribution.js";
22
- import { chunk_particle_scene_view_depth } from "./chunk_particle_scene_view_depth.js";
23
25
  import { chunk_particle_billboard_vertex } from "./chunk_particle_billboard_vertex.js";
24
26
  import { chunk_particle_lighting } from "./chunk_particle_lighting.js";
27
+ import { chunk_particle_scene_view_depth } from "./chunk_particle_scene_view_depth.js";
25
28
 
26
29
  /**
27
30
  * The particles' AVBOIT draw: the billboard quads at internal resolution, depth-tested against the
@@ -30,28 +33,13 @@ import { chunk_particle_lighting } from "./chunk_particle_lighting.js";
30
33
  *
31
34
  * Per fragment: the atlas sample times the particle colour, the soft-depth fade against the scene
32
35
  * depth, lighting for an emitter flagged `EMITTER_FLAG.LIGHTING` (`chunk_particle_lighting`: the
33
- * froxel irradiance volume: the lights and the indirect lighting), the volumetric fog composite exactly as the
34
- * mesh draw applies it, then the transmittance of everything in front from the integral texture —
35
- * and a fragment the volume already calls extinct is discarded unshaded. An emitter without the
36
- * flag is its own colour, which is what an additive one wants.
37
- *
38
- * What is written depends on how the particle blends:
39
- *
40
- * - **alpha / premultiplied** — a surface: `color += premultiplied × T`, `norm += coverage × T`,
41
- * `extinction += -log(1 - coverage)`, the same three the meshes write, with an untinted
42
- * `T_self = 1 - coverage`; the splat recorded exactly that.
43
- * - **additive** — light: `emission += premultiplied × T`, nothing else. It joins the resolve
44
- * attenuated by what is in front of it and outside the coverage normalization, which is what an
45
- * additive fragment means.
46
- *
47
- * The scene depth is bound twice: as the read-only depth attachment the pipeline tests against, and
48
- * as the texture the soft fade reads. Both are reads, which WebGPU allows within one pass; the pass
49
- * is recorded with the attachment read-only for that reason.
36
+ * world-space irradiance clipmap and cached far-field SH), the volumetric fog composite, then the
37
+ * transmittance of everything in front from the integral texture.
50
38
  */
51
39
 
52
40
  const resources = new ShaderResourceSetDescriptor();
53
41
 
54
- resources.createGroup()
42
+ const group = resources.createGroup()
55
43
  .addUniform("camera", CAMERA_UNIFORM_STRUCT)
56
44
  .addUniform("view", VIEW_UNIFORM_STRUCT)
57
45
  .addStorageBuffer("warp", AVBOIT_WARP_STRUCT)
@@ -67,10 +55,10 @@ resources.createGroup()
67
55
  // volumetrics (composited inline)
68
56
  .addUniform("volumetrics_metadata", VOLUMETRICS_METADATA_STRUCT)
69
57
  .addTexture("tVolumetrics", "float", "3d")
70
- .addTexture("tSTBN_vec3", "float", "3d")
71
- // lighting (chunk_particle_lighting): the froxel irradiance volume, trilinear through sLinear
72
- .addTexture("tIrradianceY", "float", "3d")
73
- .addTexture("tIrradianceCoCg", "float", "3d");
58
+ .addTexture("tSTBN_vec3", "float", "3d");
59
+
60
+ // lighting (chunk_particle_lighting): world-space irradiance clipmap + cached far-field SH fallback
61
+ irradiance_clipmap_add_resources(group, { include_far_field: true });
74
62
 
75
63
  const body = CodeChunk.from(
76
64
  /* language=wgsl */ `
@@ -111,16 +99,11 @@ fn vs_general(@builtin(vertex_index) vi : u32, @builtin(instance_index) ii : u32
111
99
 
112
100
  @fragment
113
101
  fn fs_main(in : ParticleVertexOut) -> ParticleAVBOITDrawOutput {
114
- let screen_uv = in.clip.xy / vec2<f32>(f32(view.width), f32(view.height));
115
- let uv_bias = view_uv_derivative_bias(view.upscale_ratio);
116
- let uv_ddx = dpdx(in.uv) * uv_bias.x;
102
+ let screen_uv = in.clip.xy / vec2<f32>(f32(view.width), f32(view.height));
103
+ let uv_bias = view_uv_derivative_bias(view.upscale_ratio);
104
+ let uv_ddx = dpdx(in.uv) * uv_bias.x;
117
105
  let uv_ddy = dpdy(in.uv) * uv_bias.y;
118
106
 
119
- // a billboard, stretched or not, is built from the camera's right and up and lies in the view plane,
120
- // so its footprint is zero; a horizontal, vertical or world-facing quad seen at an angle runs
121
- // through depth across a voxel (avboit_footprint_bias). An additive particle writes nothing into
122
- // the volume, so nothing of its own is there to occlude it, and takes none. The derivative is
123
- // taken here, in uniform control flow, whatever the blend
124
107
  let footprint = select(
125
108
  avboit_footprint_bias(&warp, fwidth(avboit_view_depth_to_virtual(&warp, in.view_depth))),
126
109
  0.0,
@@ -170,7 +153,7 @@ fn fs_main(in : ParticleVertexOut) -> ParticleAVBOITDrawOutput {
170
153
  chunk_sample_volumetrics,
171
154
  chunk_avboit_view_depth_to_virtual,
172
155
  chunk_avboit_footprint_bias,
173
- chunk_avboit_sample_transmittance,
156
+ chunk_avboit_sample_transmittance,
174
157
  chunk_view_mip_bias,
175
158
  ]);
176
159
 
@@ -53,7 +53,7 @@ export class NSS {
53
53
  * @returns {number}
54
54
  */
55
55
  static recommended_jitter_sequence_size(upscale_ratio: number): number;
56
- static "__#201@#preprocess_tensor_descriptor"(render_w: any, render_h: any): TextureResourceDescriptor;
56
+ static "__#203@#preprocess_tensor_descriptor"(render_w: any, render_h: any): TextureResourceDescriptor;
57
57
  /**
58
58
  * @param {GraphicsContext} graphics
59
59
  */
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_query_depth_from_screen_space_bb.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/depth/chunk_query_depth_from_screen_space_bb.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH,qDAFU,SAAS,CAqDZ;0BA7DmB,6BAA6B"}
1
+ {"version":3,"file":"chunk_query_depth_from_screen_space_bb.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/depth/chunk_query_depth_from_screen_space_bb.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH,qDAFU,SAAS,CAsDZ;0BA7DmB,6BAA6B"}
@@ -1,62 +1,62 @@
1
- import { CodeChunk } from "../../compiler/CodeChunk.js";
2
- import { AABB3_STRUCT } from "../geometry/aabb3/AABB3_STRUCT.js";
3
- import { chunk_min4 } from "../math/chunk_min4.js";
4
- import { chunk_ndc_to_uv } from "../texture/chunk_ndc_to_uv.js";
5
- import { chunk_uv_to_texel_coordinate } from "../texture/chunk_uv_to_texel_coordinate.js";
6
-
7
- /**
8
- * TODO check out this post https://x.com/anki3d/status/1713238150418518023
9
- * @type {CodeChunk}
10
- */
11
- export const chunk_query_depth_from_screen_space_bb = CodeChunk.from(
12
- //language=WGSL
13
- `
14
- fn query_depth_from_screen_space_bb(
15
- pb: ${AABB3_STRUCT.wgsl_ref},
16
- hzb: texture_2d<f32>,
17
- ) -> f32 {
18
- var n_min = saturate( ndc_to_uv(pb.min.xy) );
19
- var n_max = saturate( ndc_to_uv(pb.max.xy) );
20
-
21
- let bb_dim = abs(n_max - n_min);
22
-
23
- let hzb_size_u = textureDimensions(hzb);
24
- let hzb_size_f = vec2<f32>(hzb_size_u);
25
-
26
- let bb_dim_hz = bb_dim * hzb_size_f;
27
-
28
- let longest_edge = max(bb_dim_hz.x, bb_dim_hz.y);
29
-
30
- let mip_level_count = textureNumLevels(hzb);
31
-
32
- let mip_level = min(
33
- u32( ceil(log2( max(longest_edge, 1.0) ) ) ),
34
- mip_level_count - 1
35
- );
36
-
37
- let mip_resolution = hzb_size_u >> vec2(mip_level);
38
-
39
- // sample 4 corners, we know that they fit in a 2x2 footprint at most
40
- let p0 = vec2<u32>((uv_to_texel_coordinate( n_min, mip_resolution)));
41
- let p3 = vec2<u32>((uv_to_texel_coordinate( n_max, mip_resolution)));
42
- let p1 = vec2(p3.x, p0.y);
43
- let p2 = vec2(p0.x, p3.y);
44
-
45
- let d0 = textureLoad(hzb, p0, mip_level).x;
46
- let d1 = textureLoad(hzb, p1, mip_level).x;
47
- let d2 = textureLoad(hzb, p2, mip_level).x;
48
- let d3 = textureLoad(hzb, p3, mip_level).x;
49
-
50
- // value that's most far away from us
51
- let min_depth = min4(d0, d1, d2, d3);
52
-
53
- let depth_delta = pb.max.z - min_depth;
54
-
55
- return depth_delta;
56
- }
57
- `, [
58
- AABB3_STRUCT.declaration_chunk,
59
- chunk_min4,
60
- chunk_uv_to_texel_coordinate,
61
- chunk_ndc_to_uv
62
- ]);
1
+ import { CodeChunk } from "../../compiler/CodeChunk.js";
2
+ import { AABB3_STRUCT } from "../geometry/aabb3/AABB3_STRUCT.js";
3
+ import { chunk_min4 } from "../math/chunk_min4.js";
4
+ import { chunk_ndc_to_uv } from "../texture/chunk_ndc_to_uv.js";
5
+
6
+ /**
7
+ * TODO check out this post https://x.com/anki3d/status/1713238150418518023
8
+ * @type {CodeChunk}
9
+ */
10
+ export const chunk_query_depth_from_screen_space_bb = CodeChunk.from(
11
+ //language=WGSL
12
+ `
13
+ fn query_depth_from_screen_space_bb(
14
+ pb: ${AABB3_STRUCT.wgsl_ref},
15
+ hzb: texture_2d<f32>,
16
+ ) -> f32 {
17
+ var n_min = saturate( ndc_to_uv(pb.min.xy) );
18
+ var n_max = saturate( ndc_to_uv(pb.max.xy) );
19
+
20
+ let bb_dim = abs(n_max - n_min);
21
+
22
+ let hzb_size_u = textureDimensions(hzb);
23
+ let hzb_size_f = vec2<f32>(hzb_size_u);
24
+
25
+ let bb_dim_hz = bb_dim * hzb_size_f;
26
+
27
+ let longest_edge = max(bb_dim_hz.x, bb_dim_hz.y);
28
+
29
+ let mip_level_count = textureNumLevels(hzb);
30
+
31
+ let mip_level = min(
32
+ u32( ceil(log2( max(longest_edge, 1.0) ) ) ),
33
+ mip_level_count - 1
34
+ );
35
+
36
+ let mip_resolution = textureDimensions(hzb, mip_level);
37
+ let mip_resolution_f = vec2<f32>(mip_resolution);
38
+ let max_coord = mip_resolution - vec2(1u);
39
+
40
+ // sample 4 corners, we know that they fit in a 2x2 footprint at most
41
+ let p0 = min(vec2<u32>(n_min * mip_resolution_f), max_coord);
42
+ let p3 = min(vec2<u32>(n_max * mip_resolution_f), max_coord);
43
+ let p1 = vec2(p3.x, p0.y);
44
+ let p2 = vec2(p0.x, p3.y);
45
+
46
+ let d0 = textureLoad(hzb, p0, mip_level).x;
47
+ let d1 = textureLoad(hzb, p1, mip_level).x;
48
+ let d2 = textureLoad(hzb, p2, mip_level).x;
49
+ let d3 = textureLoad(hzb, p3, mip_level).x;
50
+
51
+ // value that's most far away from us
52
+ let min_depth = min4(d0, d1, d2, d3);
53
+
54
+ let depth_delta = pb.max.z - min_depth;
55
+
56
+ return depth_delta;
57
+ }
58
+ `, [
59
+ AABB3_STRUCT.declaration_chunk,
60
+ chunk_min4,
61
+ chunk_ndc_to_uv
62
+ ]);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @type {CodeChunk}
3
+ */
4
+ export const chunk_hash_lowbias32_vec2u: CodeChunk;
5
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
6
+ //# sourceMappingURL=chunk_hash_lowbias32_vec2u.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_hash_lowbias32_vec2u.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/random/lowbias/chunk_hash_lowbias32_vec2u.js"],"names":[],"mappings":"AAGA;;GAEG;AACH,yCAFU,SAAS,CAclB;0BAlByB,gCAAgC"}
@@ -0,0 +1,19 @@
1
+ import { CodeChunk } from "../../../compiler/CodeChunk.js";
2
+ import { chunk_hash_lowbias32 } from "../chunk_hash_lowbias32.js";
3
+
4
+ /**
5
+ * @type {CodeChunk}
6
+ */
7
+ export const chunk_hash_lowbias32_vec2u = CodeChunk.from(
8
+ //language=WGSL
9
+ `
10
+ fn hash_lowbias32_vec2u(v:vec2<u32>) -> u32{
11
+ let combined = v.x * 0x85ebca6bu +
12
+ v.y * 0xc2b2ae35u;
13
+
14
+ return hash_lowbias32(combined);
15
+ }
16
+ `,[
17
+ chunk_hash_lowbias32,
18
+ ]
19
+ )
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_ffx_sssr_get_mip_resolution.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_get_mip_resolution.js"],"names":[],"mappings":"AAEA,0DAOE;0BATwB,6BAA6B"}
1
+ {"version":3,"file":"chunk_ffx_sssr_get_mip_resolution.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_get_mip_resolution.js"],"names":[],"mappings":"AAGA,0DAUE;0BAbwB,6BAA6B"}
@@ -1,10 +1,16 @@
1
- import { CodeChunk } from "../../compiler/CodeChunk.js";
2
-
3
- export const chunk_ffx_sssr_get_mip_resolution = CodeChunk.from(
4
- //language=WGSL
5
- `
6
- fn ffx_sssr_get_mip_resolution(screen_dimensions:vec2<f32>, mip_level:i32) -> vec2<f32>{
7
- return screen_dimensions * pow(0.5, f32(mip_level));
8
- }
9
- `
10
- );
1
+ import { CodeChunk } from "../../compiler/CodeChunk.js";
2
+ import { SCREEN_HZB_RESOURCE } from "./SCREEN_SPACE_RESOURCES.js";
3
+
4
+ export const chunk_ffx_sssr_get_mip_resolution = CodeChunk.from(
5
+ //language=WGSL
6
+ `
7
+ fn ffx_sssr_get_mip_resolution(screen_dimensions:vec2<f32>, mip_level:i32) -> vec2<f32>{
8
+ if (mip_level <= 0) {
9
+ return screen_dimensions;
10
+ }
11
+ return vec2<f32>(textureDimensions(tHZB, mip_level - 1));
12
+ }
13
+ `
14
+ );
15
+
16
+ chunk_ffx_sssr_get_mip_resolution.requireResource(SCREEN_HZB_RESOURCE);
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_ffx_sssr_hierarchical_raymarch.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_hierarchical_raymarch.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,mDAFU,SAAS,CAqGZ;0BAlHmB,6BAA6B"}
1
+ {"version":3,"file":"chunk_ffx_sssr_hierarchical_raymarch.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/screen_space/chunk_ffx_sssr_hierarchical_raymarch.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,mDAFU,SAAS,CAuGZ;0BApHmB,6BAA6B"}
@@ -1,117 +1,118 @@
1
- import { chunk_is_background } from "../depth/chunk_is_background.js";
2
- import { CodeChunk } from "../../compiler/CodeChunk.js";
3
- import { chunk_rcp_v2 } from "../geometry/vec2/chunk_rcp_v2.js";
4
- import { F32_MAX_DEFINITION } from "../math/F32_MAX_DEFINITION.js";
5
- import { chunk_ffx_sssr_advance_ray } from "./chunk_ffx_sssr_advance_ray.js";
6
- import { chunk_ffx_sssr_get_mip_resolution } from "./chunk_ffx_sssr_get_mip_resolution.js";
7
- import { chunk_ffx_sssr_initial_advance_ray } from "./chunk_ffx_sssr_initial_advance_ray.js";
8
- import { chunk_ffx_sssr_load_depth } from "./chunk_ffx_sssr_load_depth.js";
9
-
10
- /**
11
- *
12
- * Requires origin and direction of the ray to be in screen space [0, 1] x [0, 1]
13
- * NOTE: "low occupancy" exit was removed, as WebGPU doesn't have pre-requisite API for it
14
- * @see https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/blob/1bbe66e7ea0d358e84af4471a90aa9c35b583de0/samples/hybridreflections/shaders/ffx_sssr_intersect.h#L110
15
- * @type {CodeChunk}
16
- */
17
- export const chunk_ffx_sssr_hierarchical_raymarch = CodeChunk.from(
18
- //language=WGSL
19
- `
20
- fn ffx_sssr_hierarchical_raymarch(
21
- origin: vec3<f32>,
22
- direction: vec3<f32>,
23
- screen_size: vec2<f32>,
24
- most_detailed_mip: i32,
25
- max_traversal_intersections:u32,
26
- valid_hit: ptr<function, bool>,
27
- _num_iters: ptr<function, u32>,
28
- ) -> vec3<f32> {
29
-
30
- let inv_direction = select( vec3(F32_MAX), 1.0 / direction, abs(direction) > vec3(1.0e-12));
31
-
32
- // Start on mip with highest detail.
33
- var current_mip = most_detailed_mip;
34
-
35
- // Could recompute these every iteration, but it's faster to hoist them out and update them.
36
- var current_mip_resolution = ffx_sssr_get_mip_resolution(screen_size, current_mip);
37
- var current_mip_resolution_inv = 1.0 / (current_mip_resolution);
38
-
39
- // Offset to the bounding boxes uv space to intersect the ray with the center of the next pixel.
40
- // This means we ever so slightly over shoot into the next region.
41
- var uv_offset = 0.005 * exp2(f32(most_detailed_mip)) / screen_size;
42
- uv_offset = select( uv_offset, -uv_offset, direction.xy < vec2(0.0) );
43
-
44
- // Offset applied depending on current mip resolution to move the boundary to the left/right upper/lower border depending on ray direction.
45
- let floor_offset = select(vec2(1.0), vec2(0.0), direction.xy < vec2(0.0)); // TODO can replace with 'step'
46
-
47
- // Initially advance ray to avoid immediate self intersections.
48
- var current_t:f32;
49
- var position:vec3<f32>;
50
-
51
- ffx_sssr_initial_advance_ray(
52
- origin,
53
- direction,
54
- inv_direction,
55
- current_mip_resolution,
56
- current_mip_resolution_inv,
57
- floor_offset,
58
- uv_offset,
59
- &position,
60
- &current_t
61
- );
62
-
63
- var i = 0u;
64
- for (
65
- ;
66
- i < max_traversal_intersections && current_mip >= most_detailed_mip;
67
- i++
68
- ) {
69
-
70
- if (any(position.xy > vec2(1.0, 1.0)) || any(position.xy < vec2(0.0, 0.0))){
71
- // outside of the viewport
72
- break;
73
- }
74
-
75
- if (is_background(position.z)){
76
- // hit sky/background, out of Z bounds basically
77
- break;
78
- }
79
-
80
- let current_mip_position = current_mip_resolution * position.xy;
81
- let surface_z = ffx_sssr_load_depth(vec2<i32>(current_mip_position), current_mip);
82
-
83
- let skipped_tile = ffx_sssr_advance_ray(
84
- origin,
85
- direction,
86
- inv_direction,
87
- current_mip_position,
88
- current_mip_resolution_inv,
89
- floor_offset,
90
- uv_offset,
91
- surface_z,
92
- &position,
93
- &current_t
94
- );
95
-
96
- current_mip += select(-1, 1, skipped_tile );
97
- current_mip_resolution *= select(2.0, 0.5, skipped_tile);
98
- current_mip_resolution_inv *= select(0.5, 2.0, skipped_tile);
99
-
100
- }
101
-
102
- *_num_iters = i;
103
-
104
- *valid_hit = (current_mip <= most_detailed_mip && i > 0);
105
-
106
- return position;
107
- }
108
- `, [
109
- F32_MAX_DEFINITION,
110
- chunk_rcp_v2,
111
- chunk_ffx_sssr_get_mip_resolution,
112
- chunk_ffx_sssr_initial_advance_ray,
113
- chunk_ffx_sssr_advance_ray,
114
- chunk_ffx_sssr_load_depth,
115
- chunk_is_background
116
- ]);
117
-
1
+ import { chunk_is_background } from "../depth/chunk_is_background.js";
2
+ import { CodeChunk } from "../../compiler/CodeChunk.js";
3
+ import { chunk_rcp_v2 } from "../geometry/vec2/chunk_rcp_v2.js";
4
+ import { F32_MAX_DEFINITION } from "../math/F32_MAX_DEFINITION.js";
5
+ import { chunk_ffx_sssr_advance_ray } from "./chunk_ffx_sssr_advance_ray.js";
6
+ import { chunk_ffx_sssr_get_mip_resolution } from "./chunk_ffx_sssr_get_mip_resolution.js";
7
+ import { chunk_ffx_sssr_initial_advance_ray } from "./chunk_ffx_sssr_initial_advance_ray.js";
8
+ import { chunk_ffx_sssr_load_depth } from "./chunk_ffx_sssr_load_depth.js";
9
+
10
+ /**
11
+ *
12
+ * Requires origin and direction of the ray to be in screen space [0, 1] x [0, 1]
13
+ * NOTE: "low occupancy" exit was removed, as WebGPU doesn't have pre-requisite API for it
14
+ * @see https://github.com/GPUOpen-LibrariesAndSDKs/FidelityFX-SDK/blob/1bbe66e7ea0d358e84af4471a90aa9c35b583de0/samples/hybridreflections/shaders/ffx_sssr_intersect.h#L110
15
+ * @type {CodeChunk}
16
+ */
17
+ export const chunk_ffx_sssr_hierarchical_raymarch = CodeChunk.from(
18
+ //language=WGSL
19
+ `
20
+ fn ffx_sssr_hierarchical_raymarch(
21
+ origin: vec3<f32>,
22
+ direction: vec3<f32>,
23
+ screen_size: vec2<f32>,
24
+ most_detailed_mip: i32,
25
+ max_traversal_intersections:u32,
26
+ valid_hit: ptr<function, bool>,
27
+ _num_iters: ptr<function, u32>,
28
+ ) -> vec3<f32> {
29
+
30
+ let inv_direction = select( vec3(F32_MAX), 1.0 / direction, abs(direction) > vec3(1.0e-12));
31
+ let max_mip = i32(textureNumLevels(tHZB));
32
+
33
+ // Start on mip with highest detail.
34
+ var current_mip = min(most_detailed_mip, max_mip);
35
+
36
+ var current_mip_resolution = ffx_sssr_get_mip_resolution(screen_size, current_mip);
37
+ var current_mip_resolution_inv = 1.0 / (current_mip_resolution);
38
+
39
+ // Offset to the bounding boxes uv space to intersect the ray with the center of the next pixel.
40
+ // This means we ever so slightly over shoot into the next region.
41
+ var uv_offset = 0.005 * exp2(f32(most_detailed_mip)) / screen_size;
42
+ uv_offset = select( uv_offset, -uv_offset, direction.xy < vec2(0.0) );
43
+
44
+ // Offset applied depending on current mip resolution to move the boundary to the left/right upper/lower border depending on ray direction.
45
+ let floor_offset = select(vec2(1.0), vec2(0.0), direction.xy < vec2(0.0)); // TODO can replace with 'step'
46
+
47
+ // Initially advance ray to avoid immediate self intersections.
48
+ var current_t:f32;
49
+ var position:vec3<f32>;
50
+
51
+ ffx_sssr_initial_advance_ray(
52
+ origin,
53
+ direction,
54
+ inv_direction,
55
+ current_mip_resolution,
56
+ current_mip_resolution_inv,
57
+ floor_offset,
58
+ uv_offset,
59
+ &position,
60
+ &current_t
61
+ );
62
+
63
+ var i = 0u;
64
+ for (
65
+ ;
66
+ i < max_traversal_intersections && current_mip >= most_detailed_mip;
67
+ i++
68
+ ) {
69
+
70
+ if (any(position.xy > vec2(1.0, 1.0)) || any(position.xy < vec2(0.0, 0.0))){
71
+ // outside of the viewport
72
+ break;
73
+ }
74
+
75
+ if (is_background(position.z)){
76
+ // hit sky/background, out of Z bounds basically
77
+ break;
78
+ }
79
+
80
+ let current_mip_position = current_mip_resolution * position.xy;
81
+ let surface_z = ffx_sssr_load_depth(vec2<i32>(current_mip_position), current_mip);
82
+
83
+ let skipped_tile = ffx_sssr_advance_ray(
84
+ origin,
85
+ direction,
86
+ inv_direction,
87
+ current_mip_position,
88
+ current_mip_resolution_inv,
89
+ floor_offset,
90
+ uv_offset,
91
+ surface_z,
92
+ &position,
93
+ &current_t
94
+ );
95
+
96
+ current_mip = min(current_mip + select(-1, 1, skipped_tile), max_mip);
97
+ if (current_mip >= most_detailed_mip) {
98
+ current_mip_resolution = ffx_sssr_get_mip_resolution(screen_size, current_mip);
99
+ current_mip_resolution_inv = 1.0 / current_mip_resolution;
100
+ }
101
+
102
+ }
103
+
104
+ *_num_iters = i;
105
+
106
+ *valid_hit = (current_mip <= most_detailed_mip && i > 0);
107
+
108
+ return position;
109
+ }
110
+ `, [
111
+ F32_MAX_DEFINITION,
112
+ chunk_rcp_v2,
113
+ chunk_ffx_sssr_get_mip_resolution,
114
+ chunk_ffx_sssr_initial_advance_ray,
115
+ chunk_ffx_sssr_advance_ray,
116
+ chunk_ffx_sssr_load_depth,
117
+ chunk_is_background
118
+ ]);