@woosh/meep-engine 3.68.0 → 3.69.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.
- package/CHANGELOG.md +45 -0
- package/editor/ecs/component/editors/ecs/Trail3DEditor.d.ts +2 -17
- package/editor/ecs/component/editors/ecs/Trail3DEditor.d.ts.map +1 -1
- package/editor/ecs/component/editors/ecs/Trail3DEditor.js +3 -18
- package/package.json +1 -1
- package/src/engine/graphics/ecs/trail3d/Trail3D.d.ts +33 -65
- package/src/engine/graphics/ecs/trail3d/Trail3D.d.ts.map +1 -1
- package/src/engine/graphics/ecs/trail3d/Trail3D.js +37 -245
- package/src/engine/graphics/ecs/trail3d/Trail3DFlags.d.ts +0 -4
- package/src/engine/graphics/ecs/trail3d/Trail3DFlags.js +4 -10
- package/src/engine/graphics/ecs/trail3d/seed_trail_stroke.d.ts +13 -10
- package/src/engine/graphics/ecs/trail3d/seed_trail_stroke.d.ts.map +1 -1
- package/src/engine/graphics/ecs/trail3d/seed_trail_stroke.js +28 -37
- package/src/engine/graphics/ecs/trail3d/trail_knot_count.d.ts +10 -0
- package/src/engine/graphics/ecs/trail3d/trail_knot_count.d.ts.map +1 -0
- package/src/engine/graphics/ecs/trail3d/trail_knot_count.js +27 -0
- package/src/engine/graphics/trail/TrailKnots.d.ts +62 -0
- package/src/engine/graphics/trail/TrailKnots.d.ts.map +1 -0
- package/src/engine/graphics/trail/TrailKnots.js +137 -0
- package/src/engine/graphics/trail/tube/TubeXMaterialSpec.d.ts +1 -1
- package/src/engine/graphics/trail/tube/TubeXMaterialSpec.js +1 -1
- package/src/engine/graphics3/EntityRowHold.d.ts +48 -0
- package/src/engine/graphics3/EntityRowHold.d.ts.map +1 -0
- package/src/engine/graphics3/EntityRowHold.js +128 -0
- package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts +6 -2
- package/src/engine/graphics3/GPUParticleEmitterSystem.d.ts.map +1 -1
- package/src/engine/graphics3/GPUParticleEmitterSystem.js +11 -44
- package/src/engine/graphics3/Trail3DSystem.d.ts +69 -35
- package/src/engine/graphics3/Trail3DSystem.d.ts.map +1 -1
- package/src/engine/graphics3/Trail3DSystem.js +380 -81
- package/src/engine/physics/fluid/ecs/FluidObstacle.d.ts +17 -0
- package/src/engine/physics/fluid/ecs/FluidObstacle.d.ts.map +1 -1
- package/src/engine/physics/fluid/ecs/FluidObstacle.js +22 -2
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +6 -5
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts.map +1 -1
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.js +14 -3
- package/src/engine/physics/fluid/obstacle/FLUID_OBSTACLE_RECORD_STRUCT.d.ts +9 -1
- package/src/engine/physics/fluid/obstacle/FLUID_OBSTACLE_RECORD_STRUCT.d.ts.map +1 -1
- package/src/engine/physics/fluid/obstacle/FLUID_OBSTACLE_RECORD_STRUCT.js +11 -1
- package/src/engine/physics/fluid/obstacle/fluid_obstacle_record_create.d.ts +5 -0
- package/src/engine/physics/fluid/obstacle/fluid_obstacle_record_create.d.ts.map +1 -1
- package/src/engine/physics/fluid/obstacle/fluid_obstacle_record_create.js +2 -0
- package/src/engine/physics/fluid/obstacle/fluid_obstacle_write_gpu_record.d.ts +4 -3
- package/src/engine/physics/fluid/obstacle/fluid_obstacle_write_gpu_record.d.ts.map +1 -1
- package/src/engine/physics/fluid/obstacle/fluid_obstacle_write_gpu_record.js +11 -3
- package/src/shade/playground/trails/index.html +50 -0
- package/src/shade/playground/trails/main.d.ts +2 -0
- package/src/shade/playground/trails/main.d.ts.map +1 -0
- package/src/shade/playground/trails/main.js +258 -0
- package/src/shade/renderer/animation/animation_curve_write_keys.d.ts +18 -0
- package/src/shade/renderer/animation/animation_curve_write_keys.d.ts.map +1 -0
- package/src/shade/renderer/animation/animation_curve_write_keys.js +34 -0
- package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts.map +1 -1
- package/src/shade/renderer/deferred/tonemap/ColorGrade.js +13 -36
- package/src/shade/renderer/dynamic/GPUDynamicMeshResidency.js +2 -2
- package/src/shade/renderer/dynamic/chunk_dynamic_mesh_avboit_vertex.d.ts +2 -13
- package/src/shade/renderer/dynamic/chunk_dynamic_mesh_avboit_vertex.d.ts.map +1 -1
- package/src/shade/renderer/dynamic/chunk_dynamic_mesh_avboit_vertex.js +6 -21
- package/src/shade/renderer/dynamic/graph_dynamic_mesh_avboit.d.ts +17 -6
- package/src/shade/renderer/dynamic/graph_dynamic_mesh_avboit.d.ts.map +1 -1
- package/src/shade/renderer/dynamic/graph_dynamic_mesh_avboit.js +38 -178
- package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_draw.d.ts +7 -9
- package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_draw.d.ts.map +1 -1
- package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_draw.js +17 -106
- package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_splat.d.ts +7 -17
- package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_splat.d.ts.map +1 -1
- package/src/shade/renderer/dynamic/shader_dynamic_mesh_avboit_splat.js +18 -118
- package/src/shade/renderer/fluid/forcing/FLUID_FORCING.d.ts +14 -0
- package/src/shade/renderer/fluid/forcing/FLUID_FORCING.d.ts.map +1 -1
- package/src/shade/renderer/fluid/forcing/FLUID_FORCING.js +18 -0
- package/src/shade/renderer/fluid/forcing/FLUID_FORCING_APPLY_STRUCT.d.ts +3 -1
- package/src/shade/renderer/fluid/forcing/FLUID_FORCING_APPLY_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/fluid/forcing/FLUID_FORCING_APPLY_STRUCT.js +4 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +9 -0
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts.map +1 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.js +20 -4
- package/src/shade/renderer/fluid/forcing/chunk_fluid_forcing_cell.d.ts +11 -2
- package/src/shade/renderer/fluid/forcing/chunk_fluid_forcing_cell.d.ts.map +1 -1
- package/src/shade/renderer/fluid/forcing/chunk_fluid_forcing_cell.js +59 -2
- package/src/shade/renderer/fluid/forcing/shader_fluid_forcing_apply.d.ts +4 -1
- package/src/shade/renderer/fluid/forcing/shader_fluid_forcing_apply.d.ts.map +1 -1
- package/src/shade/renderer/fluid/forcing/shader_fluid_forcing_apply.js +367 -341
- package/src/shade/renderer/fluid/mac/shader_fluid_mac_advect_correct.d.ts +6 -2
- package/src/shade/renderer/fluid/mac/shader_fluid_mac_advect_correct.d.ts.map +1 -1
- package/src/shade/renderer/fluid/mac/shader_fluid_mac_advect_correct.js +339 -282
- package/src/shade/renderer/grass/press/shader_grass_press_mark.d.ts +3 -2
- package/src/shade/renderer/grass/press/shader_grass_press_mark.d.ts.map +1 -1
- package/src/shade/renderer/grass/press/shader_grass_press_mark.js +5 -3
- package/src/shade/renderer/rasterize/native/avboit/avboit_unlit_draw.d.ts +49 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_unlit_draw.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_unlit_draw.js +144 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_unlit_splat.d.ts +71 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_unlit_splat.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/avboit_unlit_splat.js +152 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_unlit_varyings.d.ts +21 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_unlit_varyings.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/chunk_avboit_unlit_varyings.js +30 -0
- package/src/shade/renderer/rasterize/native/avboit/graph_avboit_unlit.d.ts +101 -0
- package/src/shade/renderer/rasterize/native/avboit/graph_avboit_unlit.d.ts.map +1 -0
- package/src/shade/renderer/rasterize/native/avboit/graph_avboit_unlit.js +306 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.d.ts +9 -0
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.d.ts.map +1 -1
- package/src/shade/renderer/rasterize/native/avboit/shader_avboit_splat.js +11 -4
- package/src/shade/renderer/trails/GPUTrailAVBOITChannel.d.ts +69 -0
- package/src/shade/renderer/trails/GPUTrailAVBOITChannel.d.ts.map +1 -0
- package/src/shade/renderer/trails/GPUTrailAVBOITChannel.js +129 -0
- package/src/shade/renderer/trails/GPUTrailSystem.d.ts +164 -0
- package/src/shade/renderer/trails/GPUTrailSystem.d.ts.map +1 -0
- package/src/shade/renderer/trails/GPUTrailSystem.js +725 -0
- package/src/shade/renderer/trails/data/TRAIL_DATABASE_SPEC.d.ts +14 -0
- package/src/shade/renderer/trails/data/TRAIL_DATABASE_SPEC.d.ts.map +1 -0
- package/src/shade/renderer/trails/data/TRAIL_DATABASE_SPEC.js +38 -0
- package/src/shade/renderer/trails/data/TRAIL_KNOT.d.ts +66 -0
- package/src/shade/renderer/trails/data/TRAIL_KNOT.d.ts.map +1 -0
- package/src/shade/renderer/trails/data/TRAIL_KNOT.js +154 -0
- package/src/shade/renderer/trails/data/TRAIL_RECORD.d.ts +19 -0
- package/src/shade/renderer/trails/data/TRAIL_RECORD.d.ts.map +1 -0
- package/src/shade/renderer/trails/data/TRAIL_RECORD.js +68 -0
- package/src/shade/renderer/trails/data/TRAIL_STATE.d.ts +18 -0
- package/src/shade/renderer/trails/data/TRAIL_STATE.d.ts.map +1 -0
- package/src/shade/renderer/trails/data/TRAIL_STATE.js +43 -0
- package/src/shade/renderer/trails/graph_trails.d.ts +58 -0
- package/src/shade/renderer/trails/graph_trails.d.ts.map +1 -0
- package/src/shade/renderer/trails/graph_trails.js +155 -0
- package/src/shade/renderer/trails/graph_trails_avboit.d.ts +126 -0
- package/src/shade/renderer/trails/graph_trails_avboit.d.ts.map +1 -0
- package/src/shade/renderer/trails/graph_trails_avboit.js +300 -0
- package/src/shade/renderer/trails/runtime/TrailFadeCurves.d.ts +56 -0
- package/src/shade/renderer/trails/runtime/TrailFadeCurves.d.ts.map +1 -0
- package/src/shade/renderer/trails/runtime/TrailFadeCurves.js +220 -0
- package/src/shade/renderer/trails/runtime/TrailKnotPool.d.ts +49 -0
- package/src/shade/renderer/trails/runtime/TrailKnotPool.d.ts.map +1 -0
- package/src/shade/renderer/trails/runtime/TrailKnotPool.js +162 -0
- package/src/shade/renderer/trails/runtime/TrailParameters.d.ts +52 -0
- package/src/shade/renderer/trails/runtime/TrailParameters.d.ts.map +1 -0
- package/src/shade/renderer/trails/runtime/TrailParameters.js +126 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_frame_transport.d.ts +23 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_frame_transport.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_frame_transport.js +57 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_knot_alpha.d.ts +14 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_knot_alpha.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_knot_alpha.js +40 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_seed.d.ts +18 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_seed.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_seed.js +64 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_segment.d.ts +14 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_segment.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_segment.js +51 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_update.d.ts +48 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_update.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_update.js +197 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_vertex.d.ts +34 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_vertex.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/chunk_trail_vertex.js +111 -0
- package/src/shade/renderer/trails/shaders/shader_trail_avboit.d.ts +24 -0
- package/src/shade/renderer/trails/shaders/shader_trail_avboit.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/shader_trail_avboit.js +78 -0
- package/src/shade/renderer/trails/shaders/shader_trail_avboit_segments.d.ts +23 -0
- package/src/shade/renderer/trails/shaders/shader_trail_avboit_segments.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/shader_trail_avboit_segments.js +130 -0
- package/src/shade/renderer/trails/shaders/shader_trail_draw_args.d.ts +29 -0
- package/src/shade/renderer/trails/shaders/shader_trail_draw_args.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/shader_trail_draw_args.js +78 -0
- package/src/shade/renderer/trails/shaders/shader_trail_seed.d.ts +18 -0
- package/src/shade/renderer/trails/shaders/shader_trail_seed.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/shader_trail_seed.js +79 -0
- package/src/shade/renderer/trails/shaders/shader_trail_update.d.ts +20 -0
- package/src/shade/renderer/trails/shaders/shader_trail_update.d.ts.map +1 -0
- package/src/shade/renderer/trails/shaders/shader_trail_update.js +101 -0
- package/src/engine/graphics/ecs/trail3d/advance_trail.d.ts +0 -18
- package/src/engine/graphics/ecs/trail3d/advance_trail.d.ts.map +0 -1
- package/src/engine/graphics/ecs/trail3d/advance_trail.js +0 -42
- package/src/engine/graphics/ecs/trail3d/seed_trail_tube.d.ts +0 -14
- package/src/engine/graphics/ecs/trail3d/seed_trail_tube.d.ts.map +0 -1
- package/src/engine/graphics/ecs/trail3d/seed_trail_tube.js +0 -75
- package/src/engine/graphics/ecs/trail3d/trail_head_position.d.ts +0 -17
- package/src/engine/graphics/ecs/trail3d/trail_head_position.d.ts.map +0 -1
- package/src/engine/graphics/ecs/trail3d/trail_head_position.js +0 -19
- package/src/engine/graphics/trail/tube/TubeX.d.ts +0 -186
- package/src/engine/graphics/trail/tube/TubeX.d.ts.map +0 -1
- package/src/engine/graphics/trail/tube/TubeX.js +0 -575
- package/src/engine/graphics/trail/tube/simulator/TubeXFixedPhysicsSimulator.d.ts +0 -16
- package/src/engine/graphics/trail/tube/simulator/TubeXFixedPhysicsSimulator.d.ts.map +0 -1
- package/src/engine/graphics/trail/tube/simulator/TubeXFixedPhysicsSimulator.js +0 -34
- package/src/engine/graphics/trail/tube/tube_attributes_spec.d.ts +0 -27
- package/src/engine/graphics/trail/tube/tube_attributes_spec.d.ts.map +0 -1
- package/src/engine/graphics/trail/tube/tube_attributes_spec.js +0 -70
- package/src/engine/graphics3/trail/trail_tube_write_geometry.d.ts +0 -38
- package/src/engine/graphics3/trail/trail_tube_write_geometry.d.ts.map +0 -1
- package/src/engine/graphics3/trail/trail_tube_write_geometry.js +0 -119
|
@@ -1,282 +1,339 @@
|
|
|
1
|
-
import { WebGPUExtensionType } from "../../../descriptor/WebGPUExtensionType.js";
|
|
2
|
-
import { GRID_TILE_SIZE } from "../../shader/chunk/grid/chunk_grid_tile_window.js";
|
|
3
|
-
import { chunk_texture3d_trilinear_interpolate } from "../../shader/chunk/texture/sample/chunk_texture3d_trilinear_corners.js";
|
|
4
|
-
import { ComputeShader } from "../../shader/ComputeShader.js";
|
|
5
|
-
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
6
|
-
import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
|
|
7
|
-
import { f32, u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
|
|
8
|
-
import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
|
|
9
|
-
import { chunk_grid3d_to_index } from "../../shader/chunk/grid/chunk_grid3d_to_index.js";
|
|
10
|
-
import { FLUID_CASCADE_PARENT_STRUCT } from "../coupling/FLUID_CASCADE_PARENT_STRUCT.js";
|
|
11
|
-
import { chunk_fluid_forcing_flags } from "../forcing/FLUID_FORCING.js";
|
|
12
|
-
import { chunk_fluid_cascade_epilogue } from "../coupling/chunk_fluid_cascade_epilogue.js";
|
|
13
|
-
import { chunk_v3_mac_clip_trace } from "./chunk_v3_mac_clip_trace.js";
|
|
14
|
-
import { chunk_v3_mac_face_pinned } from "./chunk_v3_mac_face_pinned.js";
|
|
15
|
-
import { chunk_v3_mac_limit } from "./chunk_v3_mac_lattice_corners.js";
|
|
16
|
-
import {
|
|
17
|
-
chunk_fluid_mac_seam_forward,
|
|
18
|
-
chunk_fluid_mac_seam_solid,
|
|
19
|
-
chunk_fluid_mac_seam_source
|
|
20
|
-
} from "./chunk_fluid_mac_seams.js";
|
|
21
|
-
import { FLUID_MAC_STEP_STRUCT } from "./FLUID_MAC_STEP_STRUCT.js";
|
|
22
|
-
|
|
23
|
-
const resources = new ShaderResourceSetDescriptor();
|
|
24
|
-
|
|
25
|
-
resources.createGroup()
|
|
26
|
-
.addUniform("step", FLUID_MAC_STEP_STRUCT)
|
|
27
|
-
.addUniform("parent", FLUID_CASCADE_PARENT_STRUCT)
|
|
28
|
-
.addTexture("source_u", "unfilterable-float", "3d")
|
|
29
|
-
.addTexture("source_v", "unfilterable-float", "3d")
|
|
30
|
-
.addTexture("source_w", "unfilterable-float", "3d")
|
|
31
|
-
.addTexture("forward_u", "unfilterable-float", "3d")
|
|
32
|
-
.addTexture("forward_v", "unfilterable-float", "3d")
|
|
33
|
-
.addTexture("forward_w", "unfilterable-float", "3d")
|
|
34
|
-
.addTexture("parent_u", "unfilterable-float", "3d")
|
|
35
|
-
.addTexture("parent_v", "unfilterable-float", "3d")
|
|
36
|
-
.addTexture("parent_w", "unfilterable-float", "3d")
|
|
37
|
-
.addTexture("ghost_u", "unfilterable-float", "3d")
|
|
38
|
-
.addTexture("ghost_v", "unfilterable-float", "3d")
|
|
39
|
-
.addTexture("ghost_w", "unfilterable-float", "3d")
|
|
40
|
-
.addStorageBuffer("solid", WebGPUArray.from(u32), false)
|
|
41
|
-
.addStorageBuffer("forcing", WebGPUArray.from(f32), false)
|
|
42
|
-
// the step's confinement force per cell (shader_fluid_mac_curl); read only with step.confinement_dt
|
|
43
|
-
.addStorageBuffer("confinement", WebGPUArray.from(f32), false)
|
|
44
|
-
.addStorageTexture("out_u", "r32float", "3d", "write-only")
|
|
45
|
-
.addStorageTexture("out_v", "r32float", "3d", "write-only")
|
|
46
|
-
.addStorageTexture("out_w", "r32float", "3d", "write-only");
|
|
47
|
-
|
|
48
|
-
/*
|
|
49
|
-
Each component's store is where a face's value is final. The per-face terms that follow the limiter
|
|
50
|
-
(§8 pass 3) go between the correction and the store, in these three functions: the atmosphere
|
|
51
|
-
identity, the vorticity confinement, the relaxation band and the deviation clamp
|
|
52
|
-
(chunk_fluid_cascade_epilogue), then the tick's forcing,
|
|
53
|
-
face keeps the wall's velocity, which the forcing wrote into the
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
let
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
let
|
|
194
|
-
let
|
|
195
|
-
let
|
|
196
|
-
let
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
let
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
)
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
1
|
+
import { WebGPUExtensionType } from "../../../descriptor/WebGPUExtensionType.js";
|
|
2
|
+
import { GRID_TILE_SIZE } from "../../shader/chunk/grid/chunk_grid_tile_window.js";
|
|
3
|
+
import { chunk_texture3d_trilinear_interpolate } from "../../shader/chunk/texture/sample/chunk_texture3d_trilinear_corners.js";
|
|
4
|
+
import { ComputeShader } from "../../shader/ComputeShader.js";
|
|
5
|
+
import { CodeChunk } from "../../shader/compiler/CodeChunk.js";
|
|
6
|
+
import { ShaderResourceSetDescriptor } from "../../shader/resource/ShaderResourceSetDescriptor.js";
|
|
7
|
+
import { f32, u32 } from "../../shader/type/WEBGPU_WGSL_PRIMITIVE_TYPES.js";
|
|
8
|
+
import { WebGPUArray } from "../../shader/type/WebGPUArray.js";
|
|
9
|
+
import { chunk_grid3d_to_index } from "../../shader/chunk/grid/chunk_grid3d_to_index.js";
|
|
10
|
+
import { FLUID_CASCADE_PARENT_STRUCT } from "../coupling/FLUID_CASCADE_PARENT_STRUCT.js";
|
|
11
|
+
import { chunk_fluid_forcing_flags } from "../forcing/FLUID_FORCING.js";
|
|
12
|
+
import { chunk_fluid_cascade_epilogue } from "../coupling/chunk_fluid_cascade_epilogue.js";
|
|
13
|
+
import { chunk_v3_mac_clip_trace } from "./chunk_v3_mac_clip_trace.js";
|
|
14
|
+
import { chunk_v3_mac_face_pinned } from "./chunk_v3_mac_face_pinned.js";
|
|
15
|
+
import { chunk_v3_mac_limit } from "./chunk_v3_mac_lattice_corners.js";
|
|
16
|
+
import {
|
|
17
|
+
chunk_fluid_mac_seam_forward,
|
|
18
|
+
chunk_fluid_mac_seam_solid,
|
|
19
|
+
chunk_fluid_mac_seam_source
|
|
20
|
+
} from "./chunk_fluid_mac_seams.js";
|
|
21
|
+
import { FLUID_MAC_STEP_STRUCT } from "./FLUID_MAC_STEP_STRUCT.js";
|
|
22
|
+
|
|
23
|
+
const resources = new ShaderResourceSetDescriptor();
|
|
24
|
+
|
|
25
|
+
resources.createGroup()
|
|
26
|
+
.addUniform("step", FLUID_MAC_STEP_STRUCT)
|
|
27
|
+
.addUniform("parent", FLUID_CASCADE_PARENT_STRUCT)
|
|
28
|
+
.addTexture("source_u", "unfilterable-float", "3d")
|
|
29
|
+
.addTexture("source_v", "unfilterable-float", "3d")
|
|
30
|
+
.addTexture("source_w", "unfilterable-float", "3d")
|
|
31
|
+
.addTexture("forward_u", "unfilterable-float", "3d")
|
|
32
|
+
.addTexture("forward_v", "unfilterable-float", "3d")
|
|
33
|
+
.addTexture("forward_w", "unfilterable-float", "3d")
|
|
34
|
+
.addTexture("parent_u", "unfilterable-float", "3d")
|
|
35
|
+
.addTexture("parent_v", "unfilterable-float", "3d")
|
|
36
|
+
.addTexture("parent_w", "unfilterable-float", "3d")
|
|
37
|
+
.addTexture("ghost_u", "unfilterable-float", "3d")
|
|
38
|
+
.addTexture("ghost_v", "unfilterable-float", "3d")
|
|
39
|
+
.addTexture("ghost_w", "unfilterable-float", "3d")
|
|
40
|
+
.addStorageBuffer("solid", WebGPUArray.from(u32), false)
|
|
41
|
+
.addStorageBuffer("forcing", WebGPUArray.from(f32), false)
|
|
42
|
+
// the step's confinement force per cell (shader_fluid_mac_curl); read only with step.confinement_dt
|
|
43
|
+
.addStorageBuffer("confinement", WebGPUArray.from(f32), false)
|
|
44
|
+
.addStorageTexture("out_u", "r32float", "3d", "write-only")
|
|
45
|
+
.addStorageTexture("out_v", "r32float", "3d", "write-only")
|
|
46
|
+
.addStorageTexture("out_w", "r32float", "3d", "write-only");
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
Each component's store is where a face's value is final. The per-face terms that follow the limiter
|
|
50
|
+
(§8 pass 3) go between the correction and the store, in these three functions: the atmosphere
|
|
51
|
+
identity, the vorticity confinement, the relaxation band and the deviation clamp
|
|
52
|
+
(chunk_fluid_cascade_epilogue), then the tick's forcing, then the porous obstacles' drag, on every
|
|
53
|
+
face that is not pinned; a pinned face keeps the wall's velocity, which the forcing wrote into the
|
|
54
|
+
persistent faces before the step.
|
|
55
|
+
|
|
56
|
+
The drag of a face is the mean of its two cells' drag over the step, k·dt, a cell without
|
|
57
|
+
FLUID_POROUS_FLAG giving none, toward the velocity of what drags on it, the two cells' weighed by
|
|
58
|
+
their drag. It is taken implicitly, with the face's velocity relative to that, |u − v|, at the step's
|
|
59
|
+
start (the carrier): u ← v + (u − v) / (1 + k·dt·|u − v|), which slows the air toward v and never
|
|
60
|
+
past it, however strong the drag.
|
|
61
|
+
|
|
62
|
+
The confinement of a face is half of each of its two cells' force, which the curl pass wrote
|
|
63
|
+
(shader_fluid_mac_curl) with the half already taken: the CPU's scatter of a cell's force to its six
|
|
64
|
+
faces, gathered. Without confinement step.confinement_dt is 0, no curl pass ran, and the uniform
|
|
65
|
+
branch reads nothing.
|
|
66
|
+
|
|
67
|
+
The forcing (shader_fluid_forcing_apply) is dense over the face lattices and written only on the
|
|
68
|
+
bricks it ran: a face reads it only under FLUID_FORCED_FLAG of the cell that owns it, its own cell,
|
|
69
|
+
or the window's last cell for a +boundary face.
|
|
70
|
+
*/
|
|
71
|
+
const body = CodeChunk.from(
|
|
72
|
+
//language=WGSL
|
|
73
|
+
`
|
|
74
|
+
// whether the forcing was written for the faces of a window-local cell
|
|
75
|
+
fn fluid_mac_cell_forced(cell: vec3<i32>) -> bool {
|
|
76
|
+
let owner = min(cell, vec3<i32>(step.cells.size) - vec3<i32>(1));
|
|
77
|
+
|
|
78
|
+
return (solid[grid3d_to_index(vec3<u32>(owner), step.cells.size.xy)] & FLUID_FORCED_FLAG) != 0u;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
fn fluid_mac_forcing_u(face: vec3<i32>) -> f32 {
|
|
82
|
+
if (!fluid_mac_cell_forced(face)) {
|
|
83
|
+
return 0.0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return forcing[grid3d_to_index(vec3<u32>(face), step.faces_u.size.xy)];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
fn fluid_mac_forcing_v(face: vec3<i32>) -> f32 {
|
|
90
|
+
if (!fluid_mac_cell_forced(face)) {
|
|
91
|
+
return 0.0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let offset = step.faces_u.size.x * step.faces_u.size.y * step.faces_u.size.z;
|
|
95
|
+
|
|
96
|
+
return forcing[offset + grid3d_to_index(vec3<u32>(face), step.faces_v.size.xy)];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
fn fluid_mac_forcing_w(face: vec3<i32>) -> f32 {
|
|
100
|
+
if (!fluid_mac_cell_forced(face)) {
|
|
101
|
+
return 0.0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let offset = step.faces_u.size.x * step.faces_u.size.y * step.faces_u.size.z
|
|
105
|
+
+ step.faces_v.size.x * step.faces_v.size.y * step.faces_v.size.z;
|
|
106
|
+
|
|
107
|
+
return forcing[offset + grid3d_to_index(vec3<u32>(face), step.faces_w.size.xy)];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// a window-local cell's drag over the step and the velocity it drags toward, none beyond the window
|
|
111
|
+
// or where the forcing wrote none
|
|
112
|
+
fn fluid_mac_cell_porous(cell: vec3<i32>) -> vec4<f32> {
|
|
113
|
+
if (any(cell < vec3<i32>(0)) || any(cell >= vec3<i32>(step.cells.size))) {
|
|
114
|
+
return vec4<f32>(0.0);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let index = grid3d_to_index(vec3<u32>(cell), step.cells.size.xy);
|
|
118
|
+
|
|
119
|
+
if ((solid[index] & FLUID_POROUS_FLAG) == 0u) {
|
|
120
|
+
return vec4<f32>(0.0);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// after the three face lattices
|
|
124
|
+
let at = step.faces_u.size.x * step.faces_u.size.y * step.faces_u.size.z
|
|
125
|
+
+ step.faces_v.size.x * step.faces_v.size.y * step.faces_v.size.z
|
|
126
|
+
+ step.faces_w.size.x * step.faces_w.size.y * step.faces_w.size.z
|
|
127
|
+
+ index * FLUID_FORCING_POROUS_WORDS;
|
|
128
|
+
|
|
129
|
+
return vec4<f32>(forcing[at], forcing[at + 1u], forcing[at + 2u], forcing[at + 3u]);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// a face's value slowed by the drag of its two cells, the face's direction axis, its velocity at the
|
|
133
|
+
// step's start carrier
|
|
134
|
+
fn fluid_mac_porous(minus: vec3<i32>, plus: vec3<i32>, axis: vec3<f32>, value: f32, carrier: vec3<f32>) -> f32 {
|
|
135
|
+
let a = fluid_mac_cell_porous(minus);
|
|
136
|
+
let b = fluid_mac_cell_porous(plus);
|
|
137
|
+
|
|
138
|
+
let total = a.x + b.x;
|
|
139
|
+
|
|
140
|
+
if (total <= 0.0) {
|
|
141
|
+
return value;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let wall = (a.yzw * a.x + b.yzw * b.x) * (1.0 / total);
|
|
145
|
+
let along = dot(wall, axis);
|
|
146
|
+
|
|
147
|
+
return along + (value - along) / (1.0 + 0.5 * total * length(carrier - wall));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// a window-local cell's confinement force along one axis, 0 beyond the window
|
|
151
|
+
fn fluid_mac_cell_confinement(cell: vec3<i32>, component: u32) -> f32 {
|
|
152
|
+
let size = step.cells.size;
|
|
153
|
+
|
|
154
|
+
if (any(cell < vec3<i32>(0)) || any(cell >= vec3<i32>(size))) {
|
|
155
|
+
return 0.0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return confinement[component * size.x * size.y * size.z + grid3d_to_index(vec3<u32>(cell), size.xy)];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
fn fluid_mac_confinement_u(face: vec3<i32>) -> f32 {
|
|
162
|
+
if (step.confinement_dt == 0.0) {
|
|
163
|
+
return 0.0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return fluid_mac_cell_confinement(face - vec3<i32>(1, 0, 0), 0u) + fluid_mac_cell_confinement(face, 0u);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
fn fluid_mac_confinement_v(face: vec3<i32>) -> f32 {
|
|
170
|
+
if (step.confinement_dt == 0.0) {
|
|
171
|
+
return 0.0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return fluid_mac_cell_confinement(face - vec3<i32>(0, 1, 0), 1u) + fluid_mac_cell_confinement(face, 1u);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
fn fluid_mac_confinement_w(face: vec3<i32>) -> f32 {
|
|
178
|
+
if (step.confinement_dt == 0.0) {
|
|
179
|
+
return 0.0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return fluid_mac_cell_confinement(face - vec3<i32>(0, 0, 1), 2u) + fluid_mac_cell_confinement(face, 2u);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
fn fluid_mac_correct_store_u(face: vec3<i32>) {
|
|
186
|
+
let source = textureLoad(source_u, grid_tile_window_storage(face, step.faces_u.corner_storage, step.faces_u.period), 0).r;
|
|
187
|
+
|
|
188
|
+
if (v3_mac_face_pinned_u(face)) {
|
|
189
|
+
textureStore(out_u, vec3<u32>(face), vec4<f32>(source, 0.0, 0.0, 0.0));
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
let start = vec3<f32>(face) - vec3<f32>(0.5, 0.0, 0.0);
|
|
194
|
+
let carrier = fluid_mac_face_carrier_u(face, source);
|
|
195
|
+
let travel = carrier * step.dt_over_h;
|
|
196
|
+
let back = v3_mac_clip_trace(start, start - travel);
|
|
197
|
+
let ahead = v3_mac_clip_trace(start, start + travel);
|
|
198
|
+
|
|
199
|
+
let backward = texture3d_trilinear_interpolate(fluid_mac_forward_corners_u(ahead + vec3<f32>(0.5, 0.0, 0.0)));
|
|
200
|
+
let corrected = textureLoad(forward_u, vec3<u32>(face), 0).r + 0.5 * (source - backward);
|
|
201
|
+
let limited = v3_mac_limit(corrected, fluid_mac_source_corners_u(back + vec3<f32>(0.5, 0.0, 0.0)));
|
|
202
|
+
let forced = fluid_mac_epilogue_u(face, limited, fluid_mac_confinement_u(face)) + fluid_mac_forcing_u(face);
|
|
203
|
+
let value = fluid_mac_porous(face - vec3<i32>(1, 0, 0), face, vec3<f32>(1.0, 0.0, 0.0), forced, carrier);
|
|
204
|
+
|
|
205
|
+
textureStore(out_u, vec3<u32>(face), vec4<f32>(value, 0.0, 0.0, 0.0));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
fn fluid_mac_correct_store_v(face: vec3<i32>) {
|
|
209
|
+
let source = textureLoad(source_v, grid_tile_window_storage(face, step.faces_v.corner_storage, step.faces_v.period), 0).r;
|
|
210
|
+
|
|
211
|
+
if (v3_mac_face_pinned_v(face)) {
|
|
212
|
+
textureStore(out_v, vec3<u32>(face), vec4<f32>(source, 0.0, 0.0, 0.0));
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
let start = vec3<f32>(face) - vec3<f32>(0.0, 0.5, 0.0);
|
|
217
|
+
let carrier = fluid_mac_face_carrier_v(face, source);
|
|
218
|
+
let travel = carrier * step.dt_over_h;
|
|
219
|
+
let back = v3_mac_clip_trace(start, start - travel);
|
|
220
|
+
let ahead = v3_mac_clip_trace(start, start + travel);
|
|
221
|
+
|
|
222
|
+
let backward = texture3d_trilinear_interpolate(fluid_mac_forward_corners_v(ahead + vec3<f32>(0.0, 0.5, 0.0)));
|
|
223
|
+
let corrected = textureLoad(forward_v, vec3<u32>(face), 0).r + 0.5 * (source - backward);
|
|
224
|
+
let limited = v3_mac_limit(corrected, fluid_mac_source_corners_v(back + vec3<f32>(0.0, 0.5, 0.0)));
|
|
225
|
+
let forced = fluid_mac_epilogue_v(face, limited, fluid_mac_confinement_v(face)) + fluid_mac_forcing_v(face);
|
|
226
|
+
let value = fluid_mac_porous(face - vec3<i32>(0, 1, 0), face, vec3<f32>(0.0, 1.0, 0.0), forced, carrier);
|
|
227
|
+
|
|
228
|
+
textureStore(out_v, vec3<u32>(face), vec4<f32>(value, 0.0, 0.0, 0.0));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
fn fluid_mac_correct_store_w(face: vec3<i32>) {
|
|
232
|
+
let source = textureLoad(source_w, grid_tile_window_storage(face, step.faces_w.corner_storage, step.faces_w.period), 0).r;
|
|
233
|
+
|
|
234
|
+
if (v3_mac_face_pinned_w(face)) {
|
|
235
|
+
textureStore(out_w, vec3<u32>(face), vec4<f32>(source, 0.0, 0.0, 0.0));
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
let start = vec3<f32>(face) - vec3<f32>(0.0, 0.0, 0.5);
|
|
240
|
+
let carrier = fluid_mac_face_carrier_w(face, source);
|
|
241
|
+
let travel = carrier * step.dt_over_h;
|
|
242
|
+
let back = v3_mac_clip_trace(start, start - travel);
|
|
243
|
+
let ahead = v3_mac_clip_trace(start, start + travel);
|
|
244
|
+
|
|
245
|
+
let backward = texture3d_trilinear_interpolate(fluid_mac_forward_corners_w(ahead + vec3<f32>(0.0, 0.0, 0.5)));
|
|
246
|
+
let corrected = textureLoad(forward_w, vec3<u32>(face), 0).r + 0.5 * (source - backward);
|
|
247
|
+
let limited = v3_mac_limit(corrected, fluid_mac_source_corners_w(back + vec3<f32>(0.0, 0.0, 0.5)));
|
|
248
|
+
let forced = fluid_mac_epilogue_w(face, limited, fluid_mac_confinement_w(face)) + fluid_mac_forcing_w(face);
|
|
249
|
+
let value = fluid_mac_porous(face - vec3<i32>(0, 0, 1), face, vec3<f32>(0.0, 0.0, 1.0), forced, carrier);
|
|
250
|
+
|
|
251
|
+
textureStore(out_w, vec3<u32>(face), vec4<f32>(value, 0.0, 0.0, 0.0));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
@compute @workgroup_size(${GRID_TILE_SIZE.join(', ')})
|
|
255
|
+
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
|
|
256
|
+
let cell = vec3<i32>(id);
|
|
257
|
+
let last = vec3<i32>(step.cells.size) - vec3<i32>(1);
|
|
258
|
+
|
|
259
|
+
// each cell's -x, -y and -z faces
|
|
260
|
+
fluid_mac_correct_store_u(cell);
|
|
261
|
+
fluid_mac_correct_store_v(cell);
|
|
262
|
+
fluid_mac_correct_store_w(cell);
|
|
263
|
+
|
|
264
|
+
// the +boundary face planes, owned by the last tile along each axis
|
|
265
|
+
if (cell.x == last.x) {
|
|
266
|
+
fluid_mac_correct_store_u(cell + vec3<i32>(1, 0, 0));
|
|
267
|
+
}
|
|
268
|
+
if (cell.y == last.y) {
|
|
269
|
+
fluid_mac_correct_store_v(cell + vec3<i32>(0, 1, 0));
|
|
270
|
+
}
|
|
271
|
+
if (cell.z == last.z) {
|
|
272
|
+
fluid_mac_correct_store_w(cell + vec3<i32>(0, 0, 1));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
`, [
|
|
276
|
+
chunk_fluid_mac_seam_source,
|
|
277
|
+
chunk_fluid_mac_seam_forward,
|
|
278
|
+
chunk_fluid_mac_seam_solid,
|
|
279
|
+
chunk_v3_mac_face_pinned,
|
|
280
|
+
chunk_v3_mac_clip_trace,
|
|
281
|
+
chunk_v3_mac_limit,
|
|
282
|
+
chunk_texture3d_trilinear_interpolate,
|
|
283
|
+
chunk_fluid_cascade_epilogue,
|
|
284
|
+
chunk_grid3d_to_index,
|
|
285
|
+
chunk_fluid_forcing_flags,
|
|
286
|
+
]
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
body.addExtension(WebGPUExtensionType.Subgroups);
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* MacCormack's correct pass over one cascade window (GPU_FLUID_CASCADES_PROPOSAL_2026_10_16.md §8,
|
|
293
|
+
* pass 3): every face takes the predicted value corrected by half the round trip's error, limited to
|
|
294
|
+
* the source's corners around its back-trace end, into the transient set the projection works on.
|
|
295
|
+
* Then, on a face that is not pinned, the epilogue (`chunk_fluid_cascade_epilogue`): the atmosphere
|
|
296
|
+
* identity from the step's start to its end, the vorticity confinement when `step.confinement_dt` is
|
|
297
|
+
* not 0 (half of each of the face's two cells' force from `shader_fluid_mac_curl`), the relaxation band
|
|
298
|
+
* toward the parent on rows 2..5 with `step.band`, and the deviation clamp about `v_far` at the step's
|
|
299
|
+
* end; then the tick's forcing (§8
|
|
300
|
+
* pass 4: the divergence is of `velocity_mid + forcing`), on a face whose owning cell carries
|
|
301
|
+
* `FLUID_FORCED_FLAG`; then the drag of the porous obstacles in the face's two cells, under
|
|
302
|
+
* `FLUID_POROUS_FLAG`, taken implicitly. A pinned face is the persistent face, the wall's velocity the
|
|
303
|
+
* forcing wrote.
|
|
304
|
+
*
|
|
305
|
+
* Dispatch and face ownership as {@link shader_fluid_mac_advect_predict}: `(nx / 8, ny / 8, nz / 4)`
|
|
306
|
+
* groups of 8 × 8 × 4, a cell's −x, −y and −z faces, and the +boundary planes from the last tile.
|
|
307
|
+
*
|
|
308
|
+
* Bindings:
|
|
309
|
+
* - `step`: {@link FLUID_MAC_STEP_STRUCT};
|
|
310
|
+
* - `parent`: {@link FLUID_CASCADE_PARENT_STRUCT}, and `parent_u`, `parent_v`, `parent_w` the parent's
|
|
311
|
+
* persistent faces: beyond the window both the source and the predicted field are the parent's
|
|
312
|
+
* identity read at the step's start, as the step's ghosts `ghost_u`, `ghost_v`, `ghost_w` hold it;
|
|
313
|
+
* the band reads the parent itself;
|
|
314
|
+
* - `source_u`, `source_v`, `source_w`: the persistent velocity the predict pass read, toroidal
|
|
315
|
+
* through `step.faces_*`;
|
|
316
|
+
* - `forward_u`, `forward_v`, `forward_w`: what the predict pass wrote, window-local;
|
|
317
|
+
* - `solid`: the window-local solid flags, `array<u32>`, `FLUID_SOLID_FLAG` and `FLUID_FORCED_FLAG`;
|
|
318
|
+
* - `forcing`: the tick's forcing, `array<f32>`, the u faces' lattice, then v's, then w's, each x
|
|
319
|
+
* fastest, then the cells' drag, `FLUID_FORCING_POROUS_WORDS` a cell; a face read only under
|
|
320
|
+
* `FLUID_FORCED_FLAG` and a cell's drag only under `FLUID_POROUS_FLAG`, so a step with no forcing
|
|
321
|
+
* binds anything;
|
|
322
|
+
* - `confinement`: the curl pass's force, `array<f32>` of 3·N, x of every cell, then y, then z, each
|
|
323
|
+
* window-local x fastest; read only when `step.confinement_dt` is not 0, so a step without
|
|
324
|
+
* confinement binds anything;
|
|
325
|
+
* - `out_u`, `out_v`, `out_w`: written, `r32float` 3-D storage textures, window-local.
|
|
326
|
+
*
|
|
327
|
+
* Reads a face: 9 carrier and 9 source texels, 9 predicted, 2 solid flags, 2 for the two trace ends
|
|
328
|
+
* and up to 8 for clips, 2 more flags for the epilogue, 1 more and a forcing word for the forcing, 2
|
|
329
|
+
* confinement words with confinement, and 8 parent texels on a band row. A cell: ~81 texels, ~21
|
|
330
|
+
* flags, 6 confinement words with confinement, ~24 parent texels on the band's four
|
|
331
|
+
* rows.
|
|
332
|
+
*
|
|
333
|
+
* @type {ComputeShader}
|
|
334
|
+
*/
|
|
335
|
+
export const shader_fluid_mac_advect_correct = ComputeShader.from({
|
|
336
|
+
label: "Fluid / MAC advect correct",
|
|
337
|
+
body,
|
|
338
|
+
resources,
|
|
339
|
+
});
|