@woosh/meep-engine 3.74.0 → 3.75.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 (161) hide show
  1. package/CHANGELOG.md +20 -19
  2. package/package.json +1 -1
  3. package/src/core/geom/2d/hilbert/v2_hilbert_encode.d.ts +11 -0
  4. package/src/core/geom/2d/hilbert/v2_hilbert_encode.d.ts.map +1 -0
  5. package/src/core/geom/2d/hilbert/v2_hilbert_encode.js +46 -0
  6. package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts +6 -0
  7. package/src/engine/graphics/render/frame_graph/FrameGraph.d.ts.map +1 -1
  8. package/src/engine/graphics/render/frame_graph/FrameGraph.js +9 -0
  9. package/src/engine/graphics3/GPUAcousticSystem.d.ts +29 -32
  10. package/src/engine/graphics3/GPUAcousticSystem.d.ts.map +1 -1
  11. package/src/engine/graphics3/GPUAcousticSystem.js +87 -162
  12. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  13. package/src/engine/sound/ecs/audio/AudioEmitterSystem.d.ts.map +1 -1
  14. package/src/engine/sound/ecs/audio/AudioEmitterSystem.js +35 -17
  15. package/src/engine/sound/ecs/audio/LiveEmitterSet.d.ts.map +1 -1
  16. package/src/engine/sound/ecs/audio/LiveEmitterSet.js +2 -3
  17. package/src/engine/sound/simulation/AcousticSimulator.d.ts +7 -0
  18. package/src/engine/sound/simulation/AcousticSimulator.d.ts.map +1 -1
  19. package/src/engine/sound/simulation/AcousticSimulator.js +27 -0
  20. package/src/engine/sound/simulation/README.md +121 -107
  21. package/src/engine/sound/sopra/README.md +8 -3
  22. package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.d.ts +2 -2
  23. package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.d.ts.map +1 -1
  24. package/src/engine/sound/sopra/definition/effect/AcousticReverbEffect.js +4 -3
  25. package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.d.ts +118 -0
  26. package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.d.ts.map +1 -0
  27. package/src/engine/sound/sopra/runtime/AcousticReverbConvolution.js +472 -0
  28. package/src/engine/sound/sopra/runtime/AcousticReverbLines.d.ts +166 -0
  29. package/src/engine/sound/sopra/runtime/AcousticReverbLines.d.ts.map +1 -0
  30. package/src/engine/sound/sopra/runtime/AcousticReverbLines.js +447 -0
  31. package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.d.ts +69 -113
  32. package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.d.ts.map +1 -1
  33. package/src/engine/sound/sopra/runtime/AcousticReverbNetwork.js +143 -491
  34. package/src/engine/sound/sopra/runtime/AcousticSpeakers.d.ts +102 -0
  35. package/src/engine/sound/sopra/runtime/AcousticSpeakers.d.ts.map +1 -0
  36. package/src/engine/sound/sopra/runtime/AcousticSpeakers.js +232 -0
  37. package/src/engine/sound/sopra/runtime/BusGraph.d.ts +17 -3
  38. package/src/engine/sound/sopra/runtime/BusGraph.d.ts.map +1 -1
  39. package/src/engine/sound/sopra/runtime/BusGraph.js +55 -5
  40. package/src/engine/sound/sopra/runtime/EventInstance.d.ts +8 -6
  41. package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -1
  42. package/src/engine/sound/sopra/runtime/EventInstance.js +113 -105
  43. package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.d.ts +13 -0
  44. package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.d.ts.map +1 -0
  45. package/src/engine/sound/sopra/runtime/acoustic_reverb_decay.js +15 -0
  46. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.d.ts.map +1 -1
  47. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +4 -6
  48. package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.d.ts.map +1 -1
  49. package/src/shade/playground/skinned_blas_refit/diff_traced_against_rasterized.js +4 -5
  50. package/src/shade/playground/skinned_blas_refit/main.d.ts.map +1 -1
  51. package/src/shade/playground/skinned_blas_refit/main.js +6 -12
  52. package/src/shade/playground/skinned_mesh_soup/main.d.ts.map +1 -1
  53. package/src/shade/playground/skinned_mesh_soup/main.js +1 -2
  54. package/src/shade/playground/vgeo_scene/README.md +12 -2
  55. package/src/shade/playground/vgeo_scene/main.js +1 -1
  56. package/src/shade/playground/volumetrics_froxel/README.md +191 -191
  57. package/src/shade/playground/volumetrics_froxel/measure.d.ts +3 -3
  58. package/src/shade/playground/volumetrics_froxel/measure.d.ts.map +1 -1
  59. package/src/shade/playground/volumetrics_froxel/measure.js +11 -13
  60. package/src/shade/playground/vsm/main.d.ts.map +1 -1
  61. package/src/shade/playground/vsm/main.js +5 -6
  62. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  63. package/src/shade/renderer/Renderer.js +31 -8
  64. package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.d.ts +28 -0
  65. package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.d.ts.map +1 -0
  66. package/src/shade/renderer/acoustics/ACOUSTIC_LISTENER_RESOURCES.js +42 -0
  67. package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.d.ts +58 -0
  68. package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.d.ts.map +1 -0
  69. package/src/shade/renderer/acoustics/ACOUSTIC_PROBE_DATABASE_SPEC.js +108 -0
  70. package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
  71. package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +161 -0
  72. package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts.map +1 -0
  73. package/src/shade/renderer/acoustics/GPUAcousticProbes.js +760 -0
  74. package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
  75. package/src/shade/renderer/acoustics/acoustic_listener_order.d.ts +12 -0
  76. package/src/shade/renderer/acoustics/acoustic_listener_order.d.ts.map +1 -0
  77. package/src/shade/renderer/acoustics/acoustic_listener_order.js +56 -0
  78. package/src/shade/renderer/acoustics/chunk_acoustic_direct.d.ts.map +1 -1
  79. package/src/shade/renderer/acoustics/chunk_acoustic_direct.js +5 -0
  80. package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.d.ts +57 -0
  81. package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.d.ts.map +1 -0
  82. package/src/shade/renderer/acoustics/chunk_acoustic_direct_cone.js +314 -0
  83. package/src/shade/renderer/acoustics/chunk_acoustic_finite.d.ts +15 -0
  84. package/src/shade/renderer/acoustics/chunk_acoustic_finite.d.ts.map +1 -0
  85. package/src/shade/renderer/acoustics/chunk_acoustic_finite.js +21 -0
  86. package/src/shade/renderer/acoustics/chunk_acoustic_gather.js +1 -1
  87. package/src/shade/renderer/acoustics/chunk_acoustic_lean.d.ts +27 -0
  88. package/src/shade/renderer/acoustics/chunk_acoustic_lean.d.ts.map +1 -0
  89. package/src/shade/renderer/acoustics/chunk_acoustic_lean.js +42 -0
  90. package/src/shade/renderer/acoustics/chunk_acoustic_listener.d.ts +80 -0
  91. package/src/shade/renderer/acoustics/chunk_acoustic_listener.d.ts.map +1 -0
  92. package/src/shade/renderer/acoustics/chunk_acoustic_listener.js +274 -0
  93. package/src/shade/renderer/acoustics/chunk_acoustic_partials.d.ts +2 -2
  94. package/src/shade/renderer/acoustics/chunk_acoustic_partials.js +2 -2
  95. package/src/shade/renderer/acoustics/chunk_acoustic_phonon.d.ts +7 -0
  96. package/src/shade/renderer/acoustics/chunk_acoustic_phonon.d.ts.map +1 -1
  97. package/src/shade/renderer/acoustics/chunk_acoustic_phonon.js +24 -1
  98. package/src/shade/renderer/acoustics/chunk_acoustic_resample.js +1 -1
  99. package/src/shade/renderer/acoustics/chunk_acoustic_reservoir.js +1 -1
  100. package/src/shade/renderer/acoustics/chunk_acoustic_through.d.ts +43 -0
  101. package/src/shade/renderer/acoustics/chunk_acoustic_through.d.ts.map +1 -0
  102. package/src/shade/renderer/acoustics/chunk_acoustic_through.js +153 -0
  103. package/src/shade/renderer/acoustics/chunk_acoustic_trace.d.ts +3 -1
  104. package/src/shade/renderer/acoustics/chunk_acoustic_trace.d.ts.map +1 -1
  105. package/src/shade/renderer/acoustics/chunk_acoustic_trace.js +10 -1
  106. package/src/shade/renderer/acoustics/shader_acoustic_combine.d.ts +7 -3
  107. package/src/shade/renderer/acoustics/shader_acoustic_combine.d.ts.map +1 -1
  108. package/src/shade/renderer/acoustics/shader_acoustic_combine.js +22 -6
  109. package/src/shade/renderer/acoustics/shader_acoustic_coupling.d.ts +14 -0
  110. package/src/shade/renderer/acoustics/shader_acoustic_coupling.d.ts.map +1 -0
  111. package/src/shade/renderer/acoustics/shader_acoustic_coupling.js +102 -0
  112. package/src/shade/renderer/acoustics/shader_acoustic_listener.d.ts +12 -0
  113. package/src/shade/renderer/acoustics/shader_acoustic_listener.d.ts.map +1 -0
  114. package/src/shade/renderer/acoustics/shader_acoustic_listener.js +80 -0
  115. package/src/shade/renderer/acoustics/shader_acoustic_receive.d.ts.map +1 -1
  116. package/src/shade/renderer/acoustics/shader_acoustic_receive.js +27 -6
  117. package/src/shade/renderer/acoustics/shader_acoustic_room.d.ts +11 -0
  118. package/src/shade/renderer/acoustics/shader_acoustic_room.d.ts.map +1 -0
  119. package/src/shade/renderer/acoustics/shader_acoustic_room.js +111 -0
  120. package/src/shade/renderer/acoustics/shader_acoustic_source.d.ts +18 -0
  121. package/src/shade/renderer/acoustics/shader_acoustic_source.d.ts.map +1 -0
  122. package/src/shade/renderer/acoustics/shader_acoustic_source.js +130 -0
  123. package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
  124. package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
  125. package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
  126. package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
  127. package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
  128. package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.d.ts +2 -2
  129. package/src/shade/renderer/geometry/virtual/build/level/VGeoFrontier.js +2 -2
  130. package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.d.ts +5 -2
  131. package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.d.ts.map +1 -1
  132. package/src/shade/renderer/geometry/virtual/build/level/VGeoLevelOptions.js +5 -2
  133. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts +9 -2
  134. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.d.ts.map +1 -1
  135. package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_group_step.js +48 -12
  136. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.d.ts +0 -22
  137. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.d.ts.map +1 -1
  138. package/src/shade/renderer/geometry/virtual/format/read/VGeoContainerReader.js +0 -42
  139. package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.d.ts +2 -18
  140. package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.d.ts.map +1 -1
  141. package/src/shade/renderer/geometry/virtual/format/read/VGeoReadOptions.js +2 -19
  142. package/src/shade/renderer/geometry/virtual/format/read/vgeo_page_worker_serve.d.ts.map +1 -1
  143. package/src/shade/renderer/geometry/virtual/format/read/vgeo_page_worker_serve.js +0 -1
  144. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts +5 -4
  145. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.d.ts.map +1 -1
  146. package/src/shade/renderer/geometry/virtual/runtime/GPUVirtualGeometryRuntime.js +3 -1
  147. package/src/shade/renderer/geometry/virtual/runtime/VGeoFeedbackLoop.d.ts.map +1 -1
  148. package/src/shade/renderer/geometry/virtual/runtime/VGeoFeedbackLoop.js +3 -1
  149. package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.d.ts.map +1 -1
  150. package/src/shade/renderer/geometry/virtual/runtime/VGeoPageFetcher.js +0 -1
  151. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts +60 -14
  152. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.d.ts.map +1 -1
  153. package/src/shade/renderer/geometry/virtual/runtime/VGeoViewCut.js +75 -39
  154. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts +0 -9
  155. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.d.ts.map +1 -1
  156. package/src/shade/renderer/global_illumination/probe_clipmap/brick/GPUSceneBrickClipmap.js +45 -17
  157. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +7 -3
  158. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts.map +1 -1
  159. package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +43 -7
  160. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  161. package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Rays the listener sends a frame, each to its first hit: enough that the room's area, volume and absorption read as
3
+ * sums over many surfaces, and few enough to be 32 workgroups. Chosen.
4
+ * @type {number}
5
+ */
6
+ export const ACOUSTIC_LISTENER_RAYS: number;
7
+ /** What a listener ray found. */
8
+ export const ACOUSTIC_LISTENER_MISS: 0;
9
+ export const ACOUSTIC_LISTENER_HIT: 1;
10
+ export const ACOUSTIC_LISTENER_UNRESOLVED: 2;
11
+ /**
12
+ * The cosine a hit's surface is taken to face its ray by at the least: the sine of a ray's own cone, `2/√N` (the cap of
13
+ * `4π/N` steradians has `cos a = 1 − 2/N`). A ray cannot tell a surface met at a grazing angle under its own spread from
14
+ * one met at that spread, and `1/cos` past it would make one ray an unbounded area. Derived.
15
+ * @type {number}
16
+ */
17
+ export const ACOUSTIC_LISTENER_COS_FLOOR: number;
18
+ /**
19
+ * One of the listener's rays, as the room and every source's coupling read it.
20
+ *
21
+ * @type {WebGPUStruct}
22
+ */
23
+ export const ACOUSTIC_LISTENER_HIT_STRUCT: WebGPUStruct;
24
+ /**
25
+ * One of the listener's rays to its first hit, and what the room's sums take of it.
26
+ *
27
+ * ```wgsl
28
+ * fn acoustic_listener_ray(listener: vec3<f32>, i: u32, fallback: vec4<u32>, cascade_count: u32, atlas_shift: u32) -> AcousticListenerHit
29
+ * fn acoustic_listener_sums(listener: vec3<f32>, hit: AcousticListenerHit) -> array<vec4<f32>, 3>
30
+ * fn acoustic_listener_reflection(hit: AcousticListenerHit, source: vec3<f32>, radius: f32, jitter: f32, fallback: vec4<u32>, cascade_count: u32, atlas_shift: u32) -> vec3<f32>
31
+ * ```
32
+ *
33
+ * Ray `i` of {@link ACOUSTIC_LISTENER_RAYS} leaves along point `i` of a Fibonacci sphere, the same every frame. Its hit
34
+ * stands for the piece of surface its solid angle `4π/N` covers there, `r²·(4π/N) / max(cos θ, floor)`
35
+ * ({@link ACOUSTIC_LISTENER_COS_FLOOR}; a hit whose field gives no normal faces its ray), and for the cone of room before
36
+ * it, `r³·(4π/N) / 3`. A ray that leaves into open air hits nothing; one through space not built yet is unresolved.
37
+ *
38
+ * The sums: `(rays, escaped, volume, area)`, a ray unresolved counted as escaped, so energy into space not known is
39
+ * lost rather than assumed back; `(area × absorption per band, 0)`; and the lean, `(area × (1 − ᾱ) × direction,
40
+ * area × (1 − ᾱ))`, where the room's reflecting surface lies as the listener sees it (a hit where the listener stands
41
+ * has no direction).
42
+ *
43
+ * A hit's first-order reflection of a source (`acoustic_listener_reflection`) is what the listener hears of the source
44
+ * off that piece of surface, as a ratio to the source's free-field direct energy at 1 m: the surface takes
45
+ * `cos θ_s / (4π r_s²)` of a unit power, keeps `1 − α` of it and sends it on by Lambert's `1/π`, and the listener sees
46
+ * the piece under the ray's solid angle `4π/N`, so the listener's own distance and angle cancel:
47
+ * `4 (1 − α) cos θ_s / (N r_s²)`, `r_s` bounded by the source's sphere, times what the walls between the surface and
48
+ * the source let through, per band (`acoustic_through` from just off the surface to the sphere, its interval read at
49
+ * points offset by `jitter`, each wall its transmission), so a source behind a wall lights the listener's room as the
50
+ * wall lets it. Nothing where the source stands behind the surface or the path does not resolve; `4(1 − α)/(N r²)`,
51
+ * `r_s` held to the sphere's radius `r`, where the sphere holds the
52
+ * hit.
53
+ *
54
+ * @type {CodeChunk}
55
+ */
56
+ export const chunk_acoustic_listener: CodeChunk;
57
+ /**
58
+ * The room the listener's rays add up to, by statistical room acoustics.
59
+ *
60
+ * ```wgsl
61
+ * fn acoustic_room(counts: vec4<f32>, absorbed: vec3<f32>, air: vec3<f32>) -> AcousticRoom
62
+ * fn acoustic_reverb_orders(absorption: vec3<f32>, air: vec3<f32>, mfp: f32) -> vec3<f32>
63
+ * ```
64
+ *
65
+ * `counts` is `(rays, escaped, volume, area)` summed. The room's mean free path is Kosten's `4V/S`. A ray that left is
66
+ * a direction sound leaves by: its share `e` of the rays is a share of each reflection lost, so the absorption a
67
+ * reflection meets is `α = e + (1 − e)·ᾱ`, `ᾱ` the hits' area-weighted mean. Then Eyring with the air's `m`: the
68
+ * energy falls by `1 − α` a reflection and `e^(−m·mfp)` a free path, a time constant (its centre time) of
69
+ * `τ = mfp / (c (−ln(1 − α) + m·mfp))`; and the diffuse field stands to the direct sound at 1 m as `16π(1 − α) / A`,
70
+ * `A = S (−ln(1 − α) + m·mfp)` Eyring's absorption area with the air's `4mV`. A room no ray hit has no reverb.
71
+ *
72
+ * `acoustic_reverb_orders`: what the first order of reflections becomes with every order after, each losing `1 − α`
73
+ * at its reflection and the air's share over its free path: `1 / (1 − (1 − α)·e^(−m·mfp))`, `1/α` without air.
74
+ *
75
+ * @type {CodeChunk}
76
+ */
77
+ export const chunk_acoustic_room: CodeChunk;
78
+ import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
79
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
80
+ //# sourceMappingURL=chunk_acoustic_listener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_acoustic_listener.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/acoustics/chunk_acoustic_listener.js"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,qCAFU,MAAM,CAE2B;AAE3C,iCAAiC;AACjC,uCAAwC;AACxC,sCAAuC;AACvC,6CAA8C;AAE9C;;;;;GAKG;AACH,0CAFU,MAAM,CAEgF;AAEhG;;;;GAIG;AACH,2CAFU,YAAY,CAeI;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,sCAFU,SAAS,CA0GZ;AAEP;;;;;;;;;;;;;;;;;;;GAmBG;AACH,kCAFU,SAAS,CA6DE;6BAzQQ,gCAAgC;0BAFnC,iCAAiC"}
@@ -0,0 +1,274 @@
1
+ import {
2
+ BRICK_TRACE_STEPS,
3
+ chunk_brick_clipmap_trace
4
+ } from "../global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js";
5
+ import { chunk_sphere_fibonacci_point } from "../shader/chunk/geometry/sphere/chunk_sphere_fibonacci_point.js";
6
+ import { PI_DECLARATION } from "../shader/chunk/math/PI_DECLARATION.js";
7
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
8
+ import { f32, u32, vec3f } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
9
+ import { WebGPUStruct } from "../shader/type/WebGPUStruct.js";
10
+ import { ACOUSTIC_SPEED_OF_SOUND } from "./ACOUSTICS.js";
11
+ import { chunk_acoustic_direct } from "./chunk_acoustic_direct.js";
12
+ import { chunk_acoustic_phonon } from "./chunk_acoustic_phonon.js";
13
+ import { chunk_acoustic_through } from "./chunk_acoustic_through.js";
14
+ import { chunk_acoustic_trace } from "./chunk_acoustic_trace.js";
15
+ import { chunk_brick_acoustics } from "./chunk_brick_acoustics.js";
16
+
17
+ /**
18
+ * Rays the listener sends a frame, each to its first hit: enough that the room's area, volume and absorption read as
19
+ * sums over many surfaces, and few enough to be 32 workgroups. Chosen.
20
+ * @type {number}
21
+ */
22
+ export const ACOUSTIC_LISTENER_RAYS = 2048;
23
+
24
+ /** What a listener ray found. */
25
+ export const ACOUSTIC_LISTENER_MISS = 0;
26
+ export const ACOUSTIC_LISTENER_HIT = 1;
27
+ export const ACOUSTIC_LISTENER_UNRESOLVED = 2;
28
+
29
+ /**
30
+ * The cosine a hit's surface is taken to face its ray by at the least: the sine of a ray's own cone, `2/√N` (the cap of
31
+ * `4π/N` steradians has `cos a = 1 − 2/N`). A ray cannot tell a surface met at a grazing angle under its own spread from
32
+ * one met at that spread, and `1/cos` past it would make one ray an unbounded area. Derived.
33
+ * @type {number}
34
+ */
35
+ export const ACOUSTIC_LISTENER_COS_FLOOR = Math.sqrt(1 - (1 - 2 / ACOUSTIC_LISTENER_RAYS) ** 2);
36
+
37
+ /**
38
+ * One of the listener's rays, as the room and every source's coupling read it.
39
+ *
40
+ * @type {WebGPUStruct}
41
+ */
42
+ export const ACOUSTIC_LISTENER_HIT_STRUCT = WebGPUStruct.from({
43
+ /** where it hit, world metres */
44
+ position: vec3f,
45
+ /** metres from the listener */
46
+ distance: f32,
47
+ /** the surface's absorption per band */
48
+ absorption: vec3f,
49
+ /** the surface it stands for, square metres: its solid angle times `r²/cos`; 0 for a ray that hit nothing */
50
+ area: f32,
51
+ /** the surface's normal, out of the solid */
52
+ normal: vec3f,
53
+ /** ACOUSTIC_LISTENER_MISS, _HIT or _UNRESOLVED */
54
+ kind: u32,
55
+ }, 'AcousticListenerHit');
56
+
57
+ /**
58
+ * One of the listener's rays to its first hit, and what the room's sums take of it.
59
+ *
60
+ * ```wgsl
61
+ * fn acoustic_listener_ray(listener: vec3<f32>, i: u32, fallback: vec4<u32>, cascade_count: u32, atlas_shift: u32) -> AcousticListenerHit
62
+ * fn acoustic_listener_sums(listener: vec3<f32>, hit: AcousticListenerHit) -> array<vec4<f32>, 3>
63
+ * fn acoustic_listener_reflection(hit: AcousticListenerHit, source: vec3<f32>, radius: f32, jitter: f32, fallback: vec4<u32>, cascade_count: u32, atlas_shift: u32) -> vec3<f32>
64
+ * ```
65
+ *
66
+ * Ray `i` of {@link ACOUSTIC_LISTENER_RAYS} leaves along point `i` of a Fibonacci sphere, the same every frame. Its hit
67
+ * stands for the piece of surface its solid angle `4π/N` covers there, `r²·(4π/N) / max(cos θ, floor)`
68
+ * ({@link ACOUSTIC_LISTENER_COS_FLOOR}; a hit whose field gives no normal faces its ray), and for the cone of room before
69
+ * it, `r³·(4π/N) / 3`. A ray that leaves into open air hits nothing; one through space not built yet is unresolved.
70
+ *
71
+ * The sums: `(rays, escaped, volume, area)`, a ray unresolved counted as escaped, so energy into space not known is
72
+ * lost rather than assumed back; `(area × absorption per band, 0)`; and the lean, `(area × (1 − ᾱ) × direction,
73
+ * area × (1 − ᾱ))`, where the room's reflecting surface lies as the listener sees it (a hit where the listener stands
74
+ * has no direction).
75
+ *
76
+ * A hit's first-order reflection of a source (`acoustic_listener_reflection`) is what the listener hears of the source
77
+ * off that piece of surface, as a ratio to the source's free-field direct energy at 1 m: the surface takes
78
+ * `cos θ_s / (4π r_s²)` of a unit power, keeps `1 − α` of it and sends it on by Lambert's `1/π`, and the listener sees
79
+ * the piece under the ray's solid angle `4π/N`, so the listener's own distance and angle cancel:
80
+ * `4 (1 − α) cos θ_s / (N r_s²)`, `r_s` bounded by the source's sphere, times what the walls between the surface and
81
+ * the source let through, per band (`acoustic_through` from just off the surface to the sphere, its interval read at
82
+ * points offset by `jitter`, each wall its transmission), so a source behind a wall lights the listener's room as the
83
+ * wall lets it. Nothing where the source stands behind the surface or the path does not resolve; `4(1 − α)/(N r²)`,
84
+ * `r_s` held to the sphere's radius `r`, where the sphere holds the
85
+ * hit.
86
+ *
87
+ * @type {CodeChunk}
88
+ */
89
+ export const chunk_acoustic_listener = CodeChunk.from(
90
+ //language=WGSL
91
+ `
92
+ const ACOUSTIC_LISTENER_RAYS = ${ACOUSTIC_LISTENER_RAYS}u;
93
+ const ACOUSTIC_LISTENER_MISS = ${ACOUSTIC_LISTENER_MISS}u;
94
+ const ACOUSTIC_LISTENER_HIT = ${ACOUSTIC_LISTENER_HIT}u;
95
+ const ACOUSTIC_LISTENER_UNRESOLVED = ${ACOUSTIC_LISTENER_UNRESOLVED}u;
96
+ const ACOUSTIC_LISTENER_COS_FLOOR = ${ACOUSTIC_LISTENER_COS_FLOOR};
97
+
98
+ fn acoustic_listener_ray(listener: vec3<f32>, i: u32, fallback: vec4<u32>, cascade_count: u32, atlas_shift: u32) -> ${ACOUSTIC_LISTENER_HIT_STRUCT.wgsl_ref} {
99
+ var out: ${ACOUSTIC_LISTENER_HIT_STRUCT.wgsl_ref};
100
+
101
+ let direction = sphere_fibonacci_point(f32(i), f32(ACOUSTIC_LISTENER_RAYS));
102
+ let hit = acoustic_trace(listener, direction, 0.0, 3.4e38, cascade_count, atlas_shift, ${BRICK_TRACE_STEPS}u);
103
+
104
+ out.position = listener;
105
+ out.kind = ACOUSTIC_LISTENER_MISS;
106
+
107
+ if (hit.kind == BRICK_TRACE_UNRESOLVED) {
108
+ out.kind = ACOUSTIC_LISTENER_UNRESOLVED;
109
+ return out;
110
+ }
111
+
112
+ if (hit.kind == BRICK_TRACE_MISS || hit.slot == BRICK_CLIPMAP_EMPTY_INSIDE) {
113
+ return out;
114
+ }
115
+
116
+ let r = length(hit.position - listener);
117
+
118
+ // a field flat where the hit stands gives no normal: the surface is taken to face the ray, the least area it can be
119
+ let normal = select(-direction, hit.normal, dot(hit.normal, hit.normal) > 0.0);
120
+ let facing = max(abs(dot(normal, direction)), ACOUSTIC_LISTENER_COS_FLOOR);
121
+ let solid = 4.0 * PI / f32(ACOUSTIC_LISTENER_RAYS);
122
+
123
+ out.position = hit.position;
124
+ out.distance = r;
125
+ out.absorption = brick_acoustics_read(hit.slot, fallback).absorption;
126
+ out.area = solid * r * r / facing;
127
+ out.normal = normal;
128
+ out.kind = ACOUSTIC_LISTENER_HIT;
129
+
130
+ return out;
131
+ }
132
+
133
+ fn acoustic_listener_sums(listener: vec3<f32>, hit: ${ACOUSTIC_LISTENER_HIT_STRUCT.wgsl_ref}) -> array<vec4<f32>, 3> {
134
+ var sums: array<vec4<f32>, 3>;
135
+
136
+ // a ray into open air leaves; so, as far as anything known says, does one into space not built yet: the energy
137
+ // it stands for is lost, never assumed back
138
+ if (hit.kind != ACOUSTIC_LISTENER_HIT) {
139
+ sums[0] = vec4<f32>(1.0, 1.0, 0.0, 0.0);
140
+ return sums;
141
+ }
142
+
143
+ let solid = 4.0 * PI / f32(ACOUSTIC_LISTENER_RAYS);
144
+ let r = hit.distance;
145
+ let kept = 1.0 - (hit.absorption.x + hit.absorption.y + hit.absorption.z) / 3.0;
146
+
147
+ // a hit where the listener stands, inside a surface's shell, has no direction and no area
148
+ let direction = select(vec3<f32>(0.0), (hit.position - listener) / r, r > 0.0);
149
+
150
+ sums[0] = vec4<f32>(1.0, 0.0, solid * r * r * r / 3.0, hit.area);
151
+ sums[1] = vec4<f32>(hit.area * hit.absorption, 0.0);
152
+ sums[2] = vec4<f32>(hit.area * kept * direction, hit.area * kept);
153
+
154
+ return sums;
155
+ }
156
+
157
+ fn acoustic_listener_reflection(hit: ${ACOUSTIC_LISTENER_HIT_STRUCT.wgsl_ref}, source: vec3<f32>, radius: f32, jitter: f32, fallback: vec4<u32>, cascade_count: u32, atlas_shift: u32) -> vec3<f32> {
158
+ if (hit.kind != ACOUSTIC_LISTENER_HIT) {
159
+ return vec3<f32>(0.0);
160
+ }
161
+
162
+ let kept = (vec3<f32>(1.0) - hit.absorption) * (4.0 / f32(ACOUSTIC_LISTENER_RAYS));
163
+ let leaving = acoustic_vertex_offset(hit.position, hit.normal, cascade_count);
164
+ let span = source - leaving;
165
+ let distance = length(span);
166
+
167
+ if (!(distance > radius)) {
168
+ return kept / max(radius * radius, 1e-6);
169
+ }
170
+
171
+ let facing = dot(span, hit.normal) / distance;
172
+
173
+ if (!(facing > 0.0)) {
174
+ return vec3<f32>(0.0);
175
+ }
176
+
177
+ // to the source's sphere, through what walls stand between, each taking its transmission; a path that does not
178
+ // resolve answers nothing
179
+ let through = acoustic_through(leaving, leaving + span * ((distance - radius) / distance), jitter, fallback, cascade_count, atlas_shift);
180
+
181
+ return through.xyz * kept * facing / (distance * distance);
182
+ }
183
+ `, [
184
+ PI_DECLARATION,
185
+ ACOUSTIC_LISTENER_HIT_STRUCT.declaration_chunk,
186
+ chunk_brick_clipmap_trace,
187
+ chunk_acoustic_trace,
188
+ chunk_acoustic_direct,
189
+ chunk_acoustic_through,
190
+ chunk_acoustic_phonon,
191
+ chunk_brick_acoustics,
192
+ chunk_sphere_fibonacci_point,
193
+ ]);
194
+
195
+ /**
196
+ * The room the listener's rays add up to, by statistical room acoustics.
197
+ *
198
+ * ```wgsl
199
+ * fn acoustic_room(counts: vec4<f32>, absorbed: vec3<f32>, air: vec3<f32>) -> AcousticRoom
200
+ * fn acoustic_reverb_orders(absorption: vec3<f32>, air: vec3<f32>, mfp: f32) -> vec3<f32>
201
+ * ```
202
+ *
203
+ * `counts` is `(rays, escaped, volume, area)` summed. The room's mean free path is Kosten's `4V/S`. A ray that left is
204
+ * a direction sound leaves by: its share `e` of the rays is a share of each reflection lost, so the absorption a
205
+ * reflection meets is `α = e + (1 − e)·ᾱ`, `ᾱ` the hits' area-weighted mean. Then Eyring with the air's `m`: the
206
+ * energy falls by `1 − α` a reflection and `e^(−m·mfp)` a free path, a time constant (its centre time) of
207
+ * `τ = mfp / (c (−ln(1 − α) + m·mfp))`; and the diffuse field stands to the direct sound at 1 m as `16π(1 − α) / A`,
208
+ * `A = S (−ln(1 − α) + m·mfp)` Eyring's absorption area with the air's `4mV`. A room no ray hit has no reverb.
209
+ *
210
+ * `acoustic_reverb_orders`: what the first order of reflections becomes with every order after, each losing `1 − α`
211
+ * at its reflection and the air's share over its free path: `1 / (1 − (1 − α)·e^(−m·mfp))`, `1/α` without air.
212
+ *
213
+ * @type {CodeChunk}
214
+ */
215
+ export const chunk_acoustic_room = CodeChunk.from(
216
+ //language=WGSL
217
+ `
218
+ const ACOUSTIC_ROOM_SPEED_OF_SOUND = ${ACOUSTIC_SPEED_OF_SOUND};
219
+
220
+ struct AcousticRoom {
221
+ energy: vec3<f32>,
222
+ centre: vec3<f32>,
223
+ /** the absorption a reflection meets, escapes counted as absorbed; 1 where no ray hit anything */
224
+ absorption: vec3<f32>,
225
+ }
226
+
227
+ fn acoustic_room(counts: vec4<f32>, absorbed: vec3<f32>, air: vec3<f32>) -> AcousticRoom {
228
+ var room: AcousticRoom;
229
+
230
+ let rays = counts.x;
231
+ let escaped = counts.y;
232
+ let volume = counts.z;
233
+ let area = counts.w;
234
+
235
+ room.absorption = vec3<f32>(1.0);
236
+
237
+ if (!(rays > escaped) || !(area > 0.0) || !(volume > 0.0)) {
238
+ return room;
239
+ }
240
+
241
+ let e = escaped / rays;
242
+ let mfp = 4.0 * volume / area;
243
+
244
+ for (var b = 0u; b < 3u; b++) {
245
+ let alpha = e + (1.0 - e) * absorbed[b] / area;
246
+ let kept = 1.0 - alpha;
247
+
248
+ room.absorption[b] = alpha;
249
+
250
+ if (!(kept > 0.0)) {
251
+ continue;
252
+ }
253
+
254
+ let loss = -log(kept);
255
+ let rate = loss + air[b] * mfp;
256
+
257
+ // a room that loses nothing rings without end, which no tail holds: no decay measured
258
+ if (!(rate > 0.0)) {
259
+ continue;
260
+ }
261
+
262
+ room.centre[b] = mfp / (ACOUSTIC_ROOM_SPEED_OF_SOUND * rate);
263
+ room.energy[b] = 16.0 * PI * kept / (area * rate);
264
+ }
265
+
266
+ return room;
267
+ }
268
+
269
+ fn acoustic_reverb_orders(absorption: vec3<f32>, air: vec3<f32>, mfp: f32) -> vec3<f32> {
270
+ let lost = vec3<f32>(1.0) - (vec3<f32>(1.0) - absorption) * exp(-air * mfp);
271
+
272
+ return select(vec3<f32>(0.0), vec3<f32>(1.0) / lost, lost > vec3<f32>(0.0));
273
+ }
274
+ `, [PI_DECLARATION]);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Words of a receiver part's sums, as vec4s: the direct points' energy and how many resolved; per stratum, the early
3
- * energy and how many lanes answered, the late energy, the late moment, the early and the late lean; then whether the
4
- * receiver stands inside a solid, which part 0 writes.
3
+ * energy and how many lanes answered, the late energy, the late moment, the early and the late lean each with its
4
+ * answers' energies squared; then whether the receiver stands inside a solid, which part 0 writes.
5
5
  * @type {number}
6
6
  */
7
7
  export const ACOUSTIC_PARTIAL_VEC4S: number;
@@ -6,8 +6,8 @@ import { ACOUSTIC_GATHER_STRATA } from "./ACOUSTICS.js";
6
6
 
7
7
  /**
8
8
  * Words of a receiver part's sums, as vec4s: the direct points' energy and how many resolved; per stratum, the early
9
- * energy and how many lanes answered, the late energy, the late moment, the early and the late lean; then whether the
10
- * receiver stands inside a solid, which part 0 writes.
9
+ * energy and how many lanes answered, the late energy, the late moment, the early and the late lean each with its
10
+ * answers' energies squared; then whether the receiver stands inside a solid, which part 0 writes.
11
11
  * @type {number}
12
12
  */
13
13
  export const ACOUSTIC_PARTIAL_VEC4S = 1 + 5 * ACOUSTIC_GATHER_STRATA + 1;
@@ -23,6 +23,12 @@ export const ACOUSTIC_PHONON_FLAG_VERTEX: number;
23
23
  * @type {number}
24
24
  */
25
25
  export const ACOUSTIC_PHONON_FLAG_FIRST: number;
26
+ /**
27
+ * A phonon's flag: its last flight has no answer yet (a march that spent its steps, or space not built yet), so it
28
+ * still stands where it was gathered when it got there. Cleared when a flight lands or the phonon is lost.
29
+ * @type {number}
30
+ */
31
+ export const ACOUSTIC_PHONON_FLAG_HELD: number;
26
32
  /**
27
33
  * A sound particle of the ring (GPU acoustics design, "Phonons"; no-lag revision, "Paths re-checked every frame"):
28
34
  * where it stands, how far it has flown, how much of its energy is left per band, where it goes next, and its first
@@ -73,6 +79,7 @@ export const ACOUSTIC_COHORTS_RESOURCE: ShaderResourceDescriptor;
73
79
  * fn acoustic_unit_unpack(word: u32) -> vec3<f32>
74
80
  * fn acoustic_phonon_alive(p: AcousticPhonon) -> bool
75
81
  * fn acoustic_phonon_is_vertex(p: AcousticPhonon) -> bool
82
+ * fn acoustic_phonon_gatherable(p: AcousticPhonon) -> bool
76
83
  * fn acoustic_phonon_is_first(p: AcousticPhonon) -> bool
77
84
  * fn acoustic_phonon_scattering(p: AcousticPhonon) -> f32
78
85
  * fn acoustic_phonon_emit(listener: vec3<f32>, direction: vec3<f32>) -> AcousticPhonon
@@ -1 +1 @@
1
- {"version":3,"file":"chunk_acoustic_phonon.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/acoustics/chunk_acoustic_phonon.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,oCAFU,MAAM,CAE0B;AAE1C;;;;;;GAMG;AACH,kCAFU,MAAM,CAEqB;AAErC;;;;GAIG;AACH,0CAFU,MAAM,CAE6B;AAE7C;;;GAGG;AACH,yCAFU,MAAM,CAE4B;AAE5C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qCAFU,YAAY,CAeD;AAErB;;;GAGG;AACH,8CAFU,wBAAwB,CAEwH;AAE1J;;;GAGG;AACH,wCAFU,wBAAwB,CAE4G;AAE9I;;;;GAIG;AACH,8CAFU,wBAAwB,CAEuG;AAEzI;;;GAGG;AACH,wCAFU,wBAAwB,CAE2F;AAE7H;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,oCAFU,SAAS,CAgKZ;6BA/RsB,gCAAgC;yCAHpB,gDAAgD;0BAD/D,iCAAiC"}
1
+ {"version":3,"file":"chunk_acoustic_phonon.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/acoustics/chunk_acoustic_phonon.js"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH,oCAFU,MAAM,CAE0B;AAE1C;;;;;;GAMG;AACH,kCAFU,MAAM,CAEqB;AAErC;;;;GAIG;AACH,0CAFU,MAAM,CAE6B;AAE7C;;;GAGG;AACH,yCAFU,MAAM,CAE4B;AAE5C;;;;GAIG;AACH,wCAFU,MAAM,CAE2B;AAE3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qCAFU,YAAY,CAeD;AAErB;;;GAGG;AACH,8CAFU,wBAAwB,CAEwH;AAE1J;;;GAGG;AACH,wCAFU,wBAAwB,CAE4G;AAE9I;;;;GAIG;AACH,8CAFU,wBAAwB,CAEuG;AAEzI;;;GAGG;AACH,wCAFU,wBAAwB,CAE2F;AAE7H;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,oCAFU,SAAS,CA8KZ;6BArTsB,gCAAgC;yCAHpB,gDAAgD;0BAD/D,iCAAiC"}
@@ -9,6 +9,7 @@ import { chunk_uv_octahedral_unit_encode } from "../shader/chunk/geometry/octahe
9
9
  import { chunk_get_cosine_weighted_sample } from "../shader/chunk/geometry/ray/chunk_get_cosine_weighted_sample.js";
10
10
  import { chunk_pcg3d } from "../shader/chunk/random/pcg/chunk_pcg3d.js";
11
11
  import { chunk_acoustic_trace } from "./chunk_acoustic_trace.js";
12
+ import { chunk_acoustic_finite } from "./chunk_acoustic_finite.js";
12
13
  import { CodeChunk } from "../shader/compiler/CodeChunk.js";
13
14
  import { ShaderResourceDescriptor } from "../shader/resource/ShaderResourceDescriptor.js";
14
15
  import { f32, u32, vec3f, vec4f } from "../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
@@ -46,6 +47,13 @@ export const ACOUSTIC_PHONON_FLAG_VERTEX = 1;
46
47
  */
47
48
  export const ACOUSTIC_PHONON_FLAG_FIRST = 2;
48
49
 
50
+ /**
51
+ * A phonon's flag: its last flight has no answer yet (a march that spent its steps, or space not built yet), so it
52
+ * still stands where it was gathered when it got there. Cleared when a flight lands or the phonon is lost.
53
+ * @type {number}
54
+ */
55
+ export const ACOUSTIC_PHONON_FLAG_HELD = 4;
56
+
49
57
  /**
50
58
  * A sound particle of the ring (GPU acoustics design, "Phonons"; no-lag revision, "Paths re-checked every frame"):
51
59
  * where it stands, how far it has flown, how much of its energy is left per band, where it goes next, and its first
@@ -114,6 +122,7 @@ export const ACOUSTIC_COHORTS_RESOURCE = ShaderResourceDescriptor.storageBuffer(
114
122
  * fn acoustic_unit_unpack(word: u32) -> vec3<f32>
115
123
  * fn acoustic_phonon_alive(p: AcousticPhonon) -> bool
116
124
  * fn acoustic_phonon_is_vertex(p: AcousticPhonon) -> bool
125
+ * fn acoustic_phonon_gatherable(p: AcousticPhonon) -> bool
117
126
  * fn acoustic_phonon_is_first(p: AcousticPhonon) -> bool
118
127
  * fn acoustic_phonon_scattering(p: AcousticPhonon) -> f32
119
128
  * fn acoustic_phonon_emit(listener: vec3<f32>, direction: vec3<f32>) -> AcousticPhonon
@@ -147,6 +156,7 @@ export const chunk_acoustic_phonon = CodeChunk.from(
147
156
  `
148
157
  const ACOUSTIC_PHONON_FLAG_VERTEX = ${ACOUSTIC_PHONON_FLAG_VERTEX}u;
149
158
  const ACOUSTIC_PHONON_FLAG_FIRST = ${ACOUSTIC_PHONON_FLAG_FIRST}u;
159
+ const ACOUSTIC_PHONON_FLAG_HELD = ${ACOUSTIC_PHONON_FLAG_HELD}u;
150
160
  const ACOUSTIC_PHONON_FLOOR = ${ACOUSTIC_PHONON_FLOOR};
151
161
  const ACOUSTIC_LOBE_DRAWS = ${ACOUSTIC_LOBE_DRAWS}u;
152
162
 
@@ -166,6 +176,14 @@ fn acoustic_phonon_is_vertex(p: ${ACOUSTIC_PHONON_STRUCT.wgsl_ref}) -> bool {
166
176
  return ((p.surface >> 16u) & ACOUSTIC_PHONON_FLAG_VERTEX) != 0u;
167
177
  }
168
178
 
179
+ /**
180
+ * a vertex a receiver may gather this frame: one it reached in its last flight. A held phonon still stands on the
181
+ * vertex it was gathered at when it got there; gathered again, the vertex would count once for every frame it is held
182
+ */
183
+ fn acoustic_phonon_gatherable(p: ${ACOUSTIC_PHONON_STRUCT.wgsl_ref}) -> bool {
184
+ return acoustic_phonon_alive(p) && acoustic_phonon_is_vertex(p) && ((p.surface >> 16u) & ACOUSTIC_PHONON_FLAG_HELD) == 0u;
185
+ }
186
+
169
187
  fn acoustic_phonon_is_first(p: ${ACOUSTIC_PHONON_STRUCT.wgsl_ref}) -> bool {
170
188
  return ((p.surface >> 16u) & ACOUSTIC_PHONON_FLAG_FIRST) != 0u;
171
189
  }
@@ -221,6 +239,7 @@ fn acoustic_phonon_fly(
221
239
 
222
240
  if (hit.kind == BRICK_TRACE_UNRESOLVED) {
223
241
  next.resume = hit.t;
242
+ next.surface |= ACOUSTIC_PHONON_FLAG_HELD << 16u;
224
243
 
225
244
  return next;
226
245
  }
@@ -263,7 +282,10 @@ fn acoustic_phonon_fly(
263
282
 
264
283
  next.energy = p.energy * exp(-air * segment) * (vec3<f32>(1.0) - surface.absorption) * kept;
265
284
 
266
- if (all(next.energy < vec3<f32>(ACOUSTIC_PHONON_FLOOR))) {
285
+ // under the floor, or past what a float holds: a lobe that leaves almost nothing above the surface draws above it
286
+ // rarely and carries the rest with it, without bound as its axis turns into the surface. Such a phonon is lost, not
287
+ // carried on as a number nothing can sum
288
+ if (all(next.energy < vec3<f32>(ACOUSTIC_PHONON_FLOOR)) || !acoustic_finite3(next.energy)) {
267
289
  next.energy = vec3<f32>(0.0);
268
290
 
269
291
  return next;
@@ -294,6 +316,7 @@ fn acoustic_phonon_fly(
294
316
  chunk_brick_clipmap_trace,
295
317
  chunk_brick_clipmap_window,
296
318
  chunk_acoustic_trace,
319
+ chunk_acoustic_finite,
297
320
  chunk_brick_acoustics,
298
321
  chunk_uv_octahedral_unit_encode,
299
322
  chunk_uv_octahedral_unit_decode,
@@ -77,7 +77,7 @@ fn acoustic_candidate_weight(
77
77
  aim: vec3<f32>,
78
78
  direct_distance: f32,
79
79
  ) -> f32 {
80
- if (!acoustic_phonon_alive(phonon) || !acoustic_phonon_is_vertex(phonon)) {
80
+ if (!acoustic_phonon_gatherable(phonon)) {
81
81
  return 0.0;
82
82
  }
83
83
 
@@ -158,7 +158,7 @@ fn acoustic_bring(
158
158
 
159
159
  out.resolved = true;
160
160
 
161
- if (!acoustic_phonon_alive(p) || !acoustic_phonon_is_vertex(p)) {
161
+ if (!acoustic_phonon_gatherable(p)) {
162
162
  return out;
163
163
  }
164
164
 
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Samples a ray reads between its first wall and its last: as many as a 0.5 m wall's half voxels at the finest
3
+ * cascade, so one wall's interval is read as finely as the tracer reads a surface. Chosen.
4
+ * @type {number}
5
+ */
6
+ export const ACOUSTIC_THROUGH_SAMPLES: number;
7
+ /**
8
+ * The walls between a ray's first and its last, read at a fixed number of points; and what reaches a point from
9
+ * another through what stands between, by a trace from each end and that reading between them.
10
+ *
11
+ * ```wgsl
12
+ * fn acoustic_window_reach(origin: vec3<f32>, direction: vec3<f32>, distance: f32, cascade_count: u32) -> f32
13
+ * fn acoustic_through_interval(origin: vec3<f32>, direction: vec3<f32>, front: f32, back: f32, jitter: f32, shell: f32, back_passing: vec3<f32>, fallback: vec4<u32>, cascade_count: u32, atlas_shift: u32) -> vec4<f32>
14
+ * fn acoustic_through(origin: vec3<f32>, end: vec3<f32>, jitter: f32, fallback: vec4<u32>, cascade_count: u32, atlas_shift: u32) -> vec4<f32>
15
+ * ```
16
+ *
17
+ * `acoustic_window_reach`: how far along the ray, up to `distance`, it stays a voxel inside the coarsest window.
18
+ *
19
+ * `acoustic_through_interval`: the ray stands in a wall at `front` and in a wall at `back`. Between them the field is
20
+ * read at {@link ACOUSTIC_THROUGH_SAMPLES} points, stratified with `jitter` in [0, 1): a point counts as open where the
21
+ * field stands half a voxel of its cascade or more outside a surface, the tracer's own hit rule, and at least `shell`,
22
+ * so the seam where two solids meet stays one wall, and so does the gap a trace's hit stands off a face by. Every solid run after an open one is one more wall, taking the transmission of the brick there
23
+ * (`brick_acoustics_read`, `fallback` for a cell deep inside a solid, which holds no record), and the wall at `back`,
24
+ * past an open run, `back_passing`. The answer is `(what those walls pass per band, the walls after the first)`, or
25
+ * `w` −1 where a point stands in space not built yet. Where nothing was open the two walls are one.
26
+ *
27
+ * `acoustic_through`: a trace from `origin` toward `end` (`acoustic_trace`): one that reaches it is clear, 1. Otherwise
28
+ * it met the first wall, which takes its transmission, and a trace back toward it, from `end` or from where the path
29
+ * leaves the coarsest window if `end` lies past it (nothing beyond is known to stand), meets the last. One that meets
30
+ * nothing leaves the first wall alone. The interval between is read as above, `shell` the half voxel of the coarser
31
+ * cascade the two hits stood in; every wall multiplies, however many there are.
32
+ *
33
+ * A wall thinner than the samples' spacing, or a gap narrower, may fall between two of them: read with a different
34
+ * jitter by each ray, the rays that carry a quantity between them read it, on the mean, near the walls' share of the
35
+ * interval. Two traces of `BRICK_TRACE_STEPS` steps between them and the samples are all a ray costs, however many
36
+ * walls stand between. A trace that spends its steps, or a sample in space not built yet, has no answer: `w` 0. An
37
+ * answer is `(energy per band, 1)`.
38
+ *
39
+ * @type {CodeChunk}
40
+ */
41
+ export const chunk_acoustic_through: CodeChunk;
42
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
43
+ //# sourceMappingURL=chunk_acoustic_through.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_acoustic_through.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/acoustics/chunk_acoustic_through.js"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,uCAFU,MAAM,CAE0B;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qCAFU,SAAS,CAoGZ;0BA/ImB,iCAAiC"}