@woosh/meep-engine 3.11.1 → 3.11.2

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 (73) hide show
  1. package/package.json +1 -1
  2. package/src/engine/ecs/storage/populateEngineSerializationRegistry.d.ts.map +1 -1
  3. package/src/engine/ecs/storage/populateEngineSerializationRegistry.js +294 -290
  4. package/src/engine/graphics3/ParticipatingMedia.d.ts +111 -0
  5. package/src/engine/graphics3/ParticipatingMedia.d.ts.map +1 -0
  6. package/src/engine/graphics3/ParticipatingMedia.js +203 -0
  7. package/src/engine/graphics3/ParticipatingMediaSerializationAdapter.d.ts +34 -0
  8. package/src/engine/graphics3/ParticipatingMediaSerializationAdapter.d.ts.map +1 -0
  9. package/src/engine/graphics3/ParticipatingMediaSerializationAdapter.js +73 -0
  10. package/src/engine/graphics3/ParticipatingMediaSystem3.d.ts +87 -0
  11. package/src/engine/graphics3/ParticipatingMediaSystem3.d.ts.map +1 -0
  12. package/src/engine/graphics3/ParticipatingMediaSystem3.js +184 -0
  13. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  14. package/src/shade/playground/volumetrics_froxel/README.md +104 -1
  15. package/src/shade/playground/volumetrics_froxel/index.html +20 -1
  16. package/src/shade/playground/volumetrics_froxel/main.d.ts.map +1 -1
  17. package/src/shade/playground/volumetrics_froxel/main.js +298 -0
  18. package/src/shade/playground/volumetrics_froxel/measure.d.ts +119 -0
  19. package/src/shade/playground/volumetrics_froxel/measure.d.ts.map +1 -0
  20. package/src/shade/playground/volumetrics_froxel/measure.js +559 -0
  21. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  22. package/src/shade/renderer/Renderer.js +22 -18
  23. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  24. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.d.ts +14 -13
  25. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.d.ts.map +1 -1
  26. package/src/shade/renderer/shadow/map/shader/chunk_shadowmap_sample_point2.js +133 -129
  27. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts.map +1 -1
  28. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +480 -315
  29. package/src/shade/renderer/volumetrics/NOTES.md +649 -8
  30. package/src/shade/renderer/volumetrics/ParticipatingMediaVolume.d.ts +5 -0
  31. package/src/shade/renderer/volumetrics/ParticipatingMediaVolume.d.ts.map +1 -1
  32. package/src/shade/renderer/volumetrics/ParticipatingMediaVolume.js +21 -2
  33. package/src/shade/renderer/volumetrics/SceneVolumetrics.d.ts +26 -0
  34. package/src/shade/renderer/volumetrics/SceneVolumetrics.d.ts.map +1 -1
  35. package/src/shade/renderer/volumetrics/SceneVolumetrics.js +64 -21
  36. package/src/shade/renderer/volumetrics/VOLUMETRICS_METADATA_STRUCT.d.ts.map +1 -1
  37. package/src/shade/renderer/volumetrics/VOLUMETRICS_METADATA_STRUCT.js +84 -28
  38. package/src/shade/renderer/volumetrics/VOLUMETRICS_SUN_SHADOW_RESOLUTION.d.ts +98 -0
  39. package/src/shade/renderer/volumetrics/VOLUMETRICS_SUN_SHADOW_RESOLUTION.d.ts.map +1 -0
  40. package/src/shade/renderer/volumetrics/VOLUMETRICS_SUN_SHADOW_RESOLUTION.js +111 -0
  41. package/src/shade/renderer/volumetrics/build_volumetrics_sun_shadow_transform.d.ts +84 -0
  42. package/src/shade/renderer/volumetrics/build_volumetrics_sun_shadow_transform.d.ts.map +1 -0
  43. package/src/shade/renderer/volumetrics/build_volumetrics_sun_shadow_transform.js +252 -0
  44. package/src/shade/renderer/volumetrics/chunk_integrate_optical_depth.js +75 -75
  45. package/src/shade/renderer/volumetrics/chunk_volumetrics_local_light_shadow.d.ts +43 -0
  46. package/src/shade/renderer/volumetrics/chunk_volumetrics_local_light_shadow.d.ts.map +1 -0
  47. package/src/shade/renderer/volumetrics/chunk_volumetrics_local_light_shadow.js +145 -0
  48. package/src/shade/renderer/volumetrics/chunk_volumetrics_sample_froxel_extinction.d.ts +20 -0
  49. package/src/shade/renderer/volumetrics/chunk_volumetrics_sample_froxel_extinction.d.ts.map +1 -0
  50. package/src/shade/renderer/volumetrics/chunk_volumetrics_sample_froxel_extinction.js +48 -0
  51. package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_optical_depth.d.ts +38 -0
  52. package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_optical_depth.d.ts.map +1 -0
  53. package/src/shade/renderer/volumetrics/chunk_volumetrics_sun_optical_depth.js +107 -0
  54. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts +4 -1
  55. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts.map +1 -1
  56. package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +577 -471
  57. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.d.ts.map +1 -1
  58. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js +64 -13
  59. package/src/shade/renderer/volumetrics/shader_volumetrics_build_sun_shadow_volume.d.ts +8 -0
  60. package/src/shade/renderer/volumetrics/shader_volumetrics_build_sun_shadow_volume.d.ts.map +1 -0
  61. package/src/shade/renderer/volumetrics/shader_volumetrics_build_sun_shadow_volume.js +174 -0
  62. package/src/shade/wgsl/emulator/CPUBitmapData.d.ts +25 -0
  63. package/src/shade/wgsl/emulator/CPUBitmapData.d.ts.map +1 -1
  64. package/src/shade/wgsl/emulator/CPUBitmapData.js +33 -0
  65. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +2221 -2215
  66. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  67. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +1297 -1117
  68. package/src/shade/wgsl/emulator/cpu_texture_gather.d.ts +69 -0
  69. package/src/shade/wgsl/emulator/cpu_texture_gather.d.ts.map +1 -0
  70. package/src/shade/wgsl/emulator/cpu_texture_gather.js +148 -0
  71. package/src/shade/wgsl/emulator/cpu_texture_sample.d.ts +16 -0
  72. package/src/shade/wgsl/emulator/cpu_texture_sample.d.ts.map +1 -1
  73. package/src/shade/wgsl/emulator/cpu_texture_sample.js +176 -172
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Name of the texture holding cascade `index` of the sun's optical-depth volume.
3
+ *
4
+ * Generated rather than written out because the cascade count is a constant and everything that
5
+ * touches the structure — this chunk, the lighting pass's resource set, the frame graph — has to
6
+ * agree with it. A name spelled by hand in one of those places is the way a fourth cascade turns
7
+ * into a silent black frame.
8
+ *
9
+ * @param {number} index
10
+ * @returns {string}
11
+ */
12
+ export function volumetrics_sun_shadow_texture_name(index: number): string;
13
+ /**
14
+ * Optical depth of the participating medium between a world position and the sun, in one fetch.
15
+ *
16
+ * Same quantity `integrate_optical_depth` returns for a directional light, and deliberately the
17
+ * same signature shape, so the two are interchangeable at the call site. What it does not expose is
18
+ * how the answer was produced: the caller passes a world position and gets an integral back, and
19
+ * whether that came from a light-aligned prefix scan, a Fourier basis or a march is not its
20
+ * business. Swapping the representation should not touch `shader_volumetrics_build_lighting`.
21
+ *
22
+ * Cascades are selected on **view depth**, not on containment in each box. The two agree — every
23
+ * box is sized from the bounding sphere of the sub-frustum out to that depth, so a froxel at or
24
+ * inside it is inside the box — and only the first gives a scalar to blend along. It also makes the
25
+ * branch uniform across a workgroup: the lighting pass dispatches one froxel slice per workgroup in
26
+ * z, and a slice is a surface of constant depth.
27
+ *
28
+ * The `saturate` in each lookup is a statement about the domain rather than a clamp that fires.
29
+ * Selection has already established the position is inside the cascade it reads; outside, the
30
+ * sensible reading of a clamped fetch is still the right one, since the outermost box's faces sit
31
+ * in empty space and the value there is the column's total.
32
+ *
33
+ * @see shader_volumetrics_build_sun_shadow_volume, build_volumetrics_sun_shadow_transform
34
+ * @type {CodeChunk}
35
+ */
36
+ export const chunk_volumetrics_sun_optical_depth: CodeChunk;
37
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
38
+ //# sourceMappingURL=chunk_volumetrics_sun_optical_depth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_volumetrics_sun_optical_depth.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/volumetrics/chunk_volumetrics_sun_optical_depth.js"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,2DAHW,MAAM,GACJ,MAAM,CAIlB;AAkDD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,kDAFU,SAAS,CAkBjB;0BAzGwB,iCAAiC"}
@@ -0,0 +1,107 @@
1
+ import { CAMERA_UNIFORM_STRUCT } from "../camera/CAMERA_UNIFORM_STRUCT.js";
2
+ import { CodeChunk } from "../shader/compiler/CodeChunk.js";
3
+ import { VOLUMETRICS_SUN_SHADOW_CASCADE_COUNT } from "./VOLUMETRICS_SUN_SHADOW_RESOLUTION.js";
4
+
5
+ /**
6
+ * Name of the texture holding cascade `index` of the sun's optical-depth volume.
7
+ *
8
+ * Generated rather than written out because the cascade count is a constant and everything that
9
+ * touches the structure — this chunk, the lighting pass's resource set, the frame graph — has to
10
+ * agree with it. A name spelled by hand in one of those places is the way a fourth cascade turns
11
+ * into a silent black frame.
12
+ *
13
+ * @param {number} index
14
+ * @returns {string}
15
+ */
16
+ export function volumetrics_sun_shadow_texture_name(index) {
17
+ return `tSunShadowCascade${index}`;
18
+ }
19
+
20
+ /**
21
+ * Fraction of a cascade's range at which it starts handing over to the next one out.
22
+ *
23
+ * The two cascades do not agree where they meet — that is the entire point of having two, one is
24
+ * more accurate than the other — so a hard switch is a visible edge at a fixed view depth, which is
25
+ * to say a ring around the screen that the 0.95-blend froxel TAA would smear rather than remove.
26
+ * Cascaded shadow maps blend across a band for the same reason.
27
+ *
28
+ * @type {number}
29
+ */
30
+ const CASCADE_BLEND_START = 0.9;
31
+
32
+ function cascade_lookup(index) {
33
+ return `
34
+ fn volumetrics_sun_optical_depth_cascade_${index}(position_ws: vec3<f32>) -> vec3<f32> {
35
+
36
+ let uvw = (volumetrics_metadata.sun_shadow_ws_to_uvw[${index}] * vec4<f32>(position_ws, 1.0)).xyz;
37
+
38
+ return textureSampleLevel(${volumetrics_sun_shadow_texture_name(index)}, sLinear, saturate(uvw), 0.0).rgb;
39
+ }`;
40
+ }
41
+
42
+ function cascade_selection() {
43
+ const lines = [];
44
+
45
+ for (let index = 0; index < VOLUMETRICS_SUN_SHADOW_CASCADE_COUNT - 1; index++) {
46
+ lines.push(`
47
+ {
48
+ let far = volumetrics_metadata.sun_shadow_cascade_far[${index}];
49
+ let blend_start = far * ${CASCADE_BLEND_START};
50
+
51
+ if (view_depth < blend_start) {
52
+ return volumetrics_sun_optical_depth_cascade_${index}(position_ws);
53
+ }
54
+
55
+ if (view_depth < far) {
56
+ return mix(
57
+ volumetrics_sun_optical_depth_cascade_${index}(position_ws),
58
+ volumetrics_sun_optical_depth_cascade_${index + 1}(position_ws),
59
+ (view_depth - blend_start) / (far - blend_start)
60
+ );
61
+ }
62
+ }`);
63
+ }
64
+
65
+ return lines.join("\n");
66
+ }
67
+
68
+ /**
69
+ * Optical depth of the participating medium between a world position and the sun, in one fetch.
70
+ *
71
+ * Same quantity `integrate_optical_depth` returns for a directional light, and deliberately the
72
+ * same signature shape, so the two are interchangeable at the call site. What it does not expose is
73
+ * how the answer was produced: the caller passes a world position and gets an integral back, and
74
+ * whether that came from a light-aligned prefix scan, a Fourier basis or a march is not its
75
+ * business. Swapping the representation should not touch `shader_volumetrics_build_lighting`.
76
+ *
77
+ * Cascades are selected on **view depth**, not on containment in each box. The two agree — every
78
+ * box is sized from the bounding sphere of the sub-frustum out to that depth, so a froxel at or
79
+ * inside it is inside the box — and only the first gives a scalar to blend along. It also makes the
80
+ * branch uniform across a workgroup: the lighting pass dispatches one froxel slice per workgroup in
81
+ * z, and a slice is a surface of constant depth.
82
+ *
83
+ * The `saturate` in each lookup is a statement about the domain rather than a clamp that fires.
84
+ * Selection has already established the position is inside the cascade it reads; outside, the
85
+ * sensible reading of a clamped fetch is still the right one, since the outermost box's faces sit
86
+ * in empty space and the value there is the column's total.
87
+ *
88
+ * @see shader_volumetrics_build_sun_shadow_volume, build_volumetrics_sun_shadow_transform
89
+ * @type {CodeChunk}
90
+ */
91
+ export const chunk_volumetrics_sun_optical_depth = CodeChunk.from(
92
+ //language=WGSL
93
+ `
94
+ ${Array.from({ length: VOLUMETRICS_SUN_SHADOW_CASCADE_COUNT }, (_, index) => cascade_lookup(index)).join("\n")}
95
+
96
+ fn volumetrics_sun_optical_depth(position_ws: vec3<f32>) -> vec3<f32> {
97
+
98
+ // view space looks down -Z
99
+ let view_depth = -(camera.view_matrix * vec4<f32>(position_ws, 1.0)).z;
100
+ ${cascade_selection()}
101
+
102
+ return volumetrics_sun_optical_depth_cascade_${VOLUMETRICS_SUN_SHADOW_CASCADE_COUNT - 1}(position_ws);
103
+ }
104
+ `, [
105
+ CAMERA_UNIFORM_STRUCT.declaration_chunk,
106
+ ]
107
+ );
@@ -9,12 +9,15 @@
9
9
  * @param {number} light_cluster_parameters
10
10
  * @param {number} shadowmap_atlas
11
11
  * @param {number[]} volumetric_resolution
12
+ * @param {number[]} sun_shadow_resolution voxel counts of one Q-04 sun optical-depth cascade;
13
+ * `[1, 1, 1]` when the froxels are marching instead, which keeps the passes in the graph without
14
+ * doing any work
12
15
  * @param {number} volumetrics_metadata
13
16
  * @param {number} [taa_history] imported previous-frame accumulated scattering volume
14
17
  * @param {number} [taa_output] imported destination for this frame's accumulated scattering volume
15
18
  * @param {GPUCameraContext} [camera_previous] previous-frame camera, for temporal reprojection
16
19
  */
17
- export function graph_build_volumetrics({ graph, camera, lights, view, light_cluster_data, light_cluster_lookup, light_cluster_parameters, shadowmap_atlas, volumetric_resolution, volumetrics_metadata, taa_history, taa_output, camera_previous, }: FrameGraph): {
20
+ export function graph_build_volumetrics({ graph, camera, lights, view, light_cluster_data, light_cluster_lookup, light_cluster_parameters, shadowmap_atlas, volumetric_resolution, sun_shadow_resolution, volumetrics_metadata, taa_history, taa_output, camera_previous, }: FrameGraph): {
18
21
  lut_transmittance: any;
19
22
  lut_multiple_scattering: any;
20
23
  lut_aerial: any;
@@ -1 +1 @@
1
- {"version":3,"file":"graph_build_volumetrics.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/volumetrics/graph_build_volumetrics.js"],"names":[],"mappings":"AA6SA;;;;;;;;;;;;;;;GAeG;AACH;;;;;EA0JC"}
1
+ {"version":3,"file":"graph_build_volumetrics.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/volumetrics/graph_build_volumetrics.js"],"names":[],"mappings":"AAyYA;;;;;;;;;;;;;;;;;;GAkBG;AACH;;;;;EAqKC"}