@woosh/meep-engine 3.81.0 → 3.82.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 +42 -0
- package/build/bundle-worker-terrain.js +1 -1
- package/editor/ecs/component/editors/common/BitFlagsEditor.d.ts.map +1 -1
- package/editor/ecs/component/editors/common/BitFlagsEditor.js +11 -0
- package/editor/prototypeEditorShell.d.ts.map +1 -1
- package/editor/prototypeEditorShell.js +4 -1
- package/package.json +1 -1
- package/src/engine/graphics/ecs/mesh-v2/MESH_MORPH_EVENT_CHANGE.d.ts +13 -0
- package/src/engine/graphics/ecs/mesh-v2/MESH_MORPH_EVENT_CHANGE.d.ts.map +1 -0
- package/src/engine/graphics/ecs/mesh-v2/MESH_MORPH_EVENT_CHANGE.js +12 -0
- package/src/engine/graphics/ecs/mesh-v2/MeshMorph.d.ts +64 -0
- package/src/engine/graphics/ecs/mesh-v2/MeshMorph.d.ts.map +1 -0
- package/src/engine/graphics/ecs/mesh-v2/MeshMorph.js +89 -0
- package/src/engine/graphics/ecs/mesh-v2/MeshSkin.d.ts +1 -1
- package/src/engine/graphics/ecs/mesh-v2/MeshSkin.js +1 -1
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometryFlags.d.ts +1 -0
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometryFlags.js +10 -3
- package/src/engine/graphics/ecs/mesh-v2/mesh_morph_announce_change.d.ts +14 -0
- package/src/engine/graphics/ecs/mesh-v2/mesh_morph_announce_change.d.ts.map +1 -0
- package/src/engine/graphics/ecs/mesh-v2/mesh_morph_announce_change.js +21 -0
- package/src/engine/graphics3/HairSystem.js +1 -1
- package/src/engine/graphics3/MeshMorphSystem.d.ts +48 -0
- package/src/engine/graphics3/MeshMorphSystem.d.ts.map +1 -0
- package/src/engine/graphics3/MeshMorphSystem.js +355 -0
- package/src/engine/graphics3/MeshSkinSystem.js +2 -2
- package/src/engine/graphics3/MeshSystem.d.ts +2 -1
- package/src/engine/graphics3/MeshSystem.d.ts.map +1 -1
- package/src/engine/graphics3/MeshSystem.js +2 -1
- package/src/engine/graphics3/ShadedGeometrySystem.d.ts +1 -1
- package/src/engine/graphics3/ShadedGeometrySystem.js +2 -2
- package/src/engine/graphics3/prefab/Prefab.d.ts +14 -0
- package/src/engine/graphics3/prefab/Prefab.d.ts.map +1 -1
- package/src/engine/graphics3/prefab/Prefab.js +16 -0
- package/src/engine/graphics3/prefab/prefab_compile.d.ts.map +1 -1
- package/src/engine/graphics3/prefab/prefab_compile.js +8 -1
- package/src/engine/graphics3/prefab/prefab_instantiate.d.ts +3 -2
- package/src/engine/graphics3/prefab/prefab_instantiate.d.ts.map +1 -1
- package/src/engine/graphics3/prefab/prefab_instantiate.js +17 -4
- package/src/engine/graphics3/prefab/prefab_place.d.ts +27 -9
- package/src/engine/graphics3/prefab/prefab_place.d.ts.map +1 -1
- package/src/engine/graphics3/prefab/prefab_place.js +69 -13
- package/src/engine/graphics3/register_clips.d.ts.map +1 -1
- package/src/engine/graphics3/register_clips.js +8 -2
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/shade/playground/hair_skinned/skinned_hair.js +2 -2
- package/src/shade/playground/skinned_blas_refit/verify_clone_leaves.js +1 -1
- package/src/shade/playground/skinned_blas_refit/verify_instance_bounds.js +1 -1
- package/src/shade/playground/skinned_blas_refit/verify_skinned_blas_refit.js +1 -1
- package/src/shade/playground/skinned_mesh_soup/main.js +1 -1
- package/src/shade/playground/skinned_mesh_soup/verify_clone_vertices.js +2 -2
- package/src/shade/renderer/Renderer.js +2 -2
- package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcousticProbes.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
- package/src/shade/renderer/animation/ANIMATION_DATABASE_SPEC.d.ts +5 -0
- package/src/shade/renderer/animation/ANIMATION_DATABASE_SPEC.d.ts.map +1 -1
- package/src/shade/renderer/animation/ANIMATION_DATABASE_SPEC.js +19 -0
- package/src/shade/renderer/animation/ANIMATION_MORPH_STRUCT.d.ts +8 -0
- package/src/shade/renderer/animation/ANIMATION_MORPH_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/animation/ANIMATION_MORPH_STRUCT.js +19 -0
- package/src/shade/renderer/animation/ANIMATION_MORPH_WEIGHT_STRUCT.d.ts +6 -0
- package/src/shade/renderer/animation/ANIMATION_MORPH_WEIGHT_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/animation/ANIMATION_MORPH_WEIGHT_STRUCT.js +13 -0
- package/src/shade/renderer/animation/GPUAnimationManager.d.ts +71 -0
- package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
- package/src/shade/renderer/animation/GPUAnimationManager.js +559 -9
- package/src/shade/renderer/animation/ShadeAnimationChannel.d.ts +23 -2
- package/src/shade/renderer/animation/ShadeAnimationChannel.d.ts.map +1 -1
- package/src/shade/renderer/animation/ShadeAnimationChannel.js +43 -2
- package/src/shade/renderer/animation/ShadeAnimationClip.d.ts +9 -3
- package/src/shade/renderer/animation/ShadeAnimationClip.d.ts.map +1 -1
- package/src/shade/renderer/animation/ShadeAnimationClip.js +67 -3
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.d.ts +3 -2
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.d.ts.map +1 -1
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationAdapter.js +6 -3
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationUpgrader_0_1.d.ts +14 -0
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationUpgrader_0_1.d.ts.map +1 -0
- package/src/shade/renderer/animation/ShadeAnimationClipSerializationUpgrader_0_1.js +49 -0
- package/src/shade/renderer/animation/ShadeAnimationProperty.d.ts +12 -0
- package/src/shade/renderer/animation/ShadeAnimationProperty.d.ts.map +1 -0
- package/src/shade/renderer/animation/ShadeAnimationProperty.js +30 -0
- package/src/shade/renderer/animation/Skin.d.ts +1 -1
- package/src/shade/renderer/animation/Skin.js +1 -1
- package/src/shade/renderer/animation/deformation/DEFORMATION_BINDING_STRUCT.d.ts +26 -0
- package/src/shade/renderer/animation/deformation/DEFORMATION_BINDING_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/animation/{skinning/SKINNING_BINDING_STRUCT.js → deformation/DEFORMATION_BINDING_STRUCT.js} +33 -8
- package/src/shade/renderer/animation/{skinning/GPUMeshSkinningContext.d.ts → deformation/GPUMeshDeformationContext.d.ts} +60 -17
- package/src/shade/renderer/animation/deformation/GPUMeshDeformationContext.d.ts.map +1 -0
- package/src/shade/renderer/animation/{skinning/GPUMeshSkinningContext.js → deformation/GPUMeshDeformationContext.js} +458 -55
- package/src/shade/renderer/animation/{skinning/bounds_refresh/shader_skinned_mesh_bounds_refresh.d.ts → deformation/bounds_refresh/shader_deformed_mesh_bounds_refresh.d.ts} +2 -2
- package/src/shade/renderer/animation/deformation/bounds_refresh/shader_deformed_mesh_bounds_refresh.d.ts.map +1 -0
- package/src/shade/renderer/animation/{skinning/bounds_refresh/shader_skinned_mesh_bounds_refresh.js → deformation/bounds_refresh/shader_deformed_mesh_bounds_refresh.js} +3 -3
- package/src/shade/renderer/animation/deformation/bounds_refresh/shader_geometry_sphere_derive.d.ts.map +1 -0
- package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_geometry_sphere_derive.js +2 -2
- package/src/shade/renderer/animation/deformation/bounds_refresh/shader_meshlet_bounds_reduce.d.ts.map +1 -0
- package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_meshlet_bounds_reduce.js +2 -2
- package/src/shade/renderer/animation/deformation/bounds_refresh/shader_meshlet_bounds_scatter.d.ts.map +1 -0
- package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_meshlet_bounds_scatter.js +2 -2
- package/src/shade/renderer/animation/morph/shader_meshlet_apply_morph.d.ts +24 -0
- package/src/shade/renderer/animation/morph/shader_meshlet_apply_morph.d.ts.map +1 -0
- package/src/shade/renderer/animation/morph/shader_meshlet_apply_morph.js +257 -0
- package/src/shade/renderer/animation/morph/shader_morph_weights_resolve.d.ts +18 -0
- package/src/shade/renderer/animation/morph/shader_morph_weights_resolve.d.ts.map +1 -0
- package/src/shade/renderer/animation/morph/shader_morph_weights_resolve.js +75 -0
- package/src/shade/renderer/animation/shader_animation_apply.d.ts.map +1 -1
- package/src/shade/renderer/animation/shader_animation_apply.js +3 -1
- package/src/shade/renderer/animation/skinning/shader_meshlet_apply_skinning.d.ts.map +1 -1
- package/src/shade/renderer/animation/skinning/shader_meshlet_apply_skinning.js +31 -7
- package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +7 -7
- package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
- package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
- package/src/shade/renderer/geometry/GPUGeometryManager.d.ts +8 -1
- package/src/shade/renderer/geometry/GPUGeometryManager.d.ts.map +1 -1
- package/src/shade/renderer/geometry/GPUGeometryManager.js +18 -1
- package/src/shade/renderer/geometry/bvh/GPUBLASRefitBatch.d.ts +1 -1
- package/src/shade/renderer/geometry/bvh/GPUBLASRefitBatch.js +1 -1
- package/src/shade/renderer/geometry/meshlet/GPUMeshletManager.d.ts +9 -0
- package/src/shade/renderer/geometry/meshlet/GPUMeshletManager.d.ts.map +1 -1
- package/src/shade/renderer/geometry/meshlet/GPUMeshletManager.js +30 -2
- package/src/shade/renderer/geometry/meshlet/MeshletBatch.d.ts +27 -0
- package/src/shade/renderer/geometry/meshlet/MeshletBatch.d.ts.map +1 -1
- package/src/shade/renderer/geometry/meshlet/MeshletBatch.js +85 -6
- package/src/shade/renderer/geometry/meshlet/meshlet_payload_collapse.d.ts +5 -1
- package/src/shade/renderer/geometry/meshlet/meshlet_payload_collapse.d.ts.map +1 -1
- package/src/shade/renderer/geometry/meshlet/meshlet_payload_collapse.js +8 -3
- package/src/shade/renderer/geometry/meshlet_geometry_build_from_geometry.d.ts +13 -0
- package/src/shade/renderer/geometry/meshlet_geometry_build_from_geometry.d.ts.map +1 -1
- package/src/shade/renderer/geometry/meshlet_geometry_build_from_geometry.js +47 -4
- package/src/shade/renderer/geometry/morph/MESHLET_MORPH_LAYOUT.d.ts +51 -0
- package/src/shade/renderer/geometry/morph/MESHLET_MORPH_LAYOUT.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/MESHLET_MORPH_LAYOUT.js +60 -0
- package/src/shade/renderer/geometry/morph/MESHLET_MORPH_NORMAL_EXPONENT.d.ts +12 -0
- package/src/shade/renderer/geometry/morph/MESHLET_MORPH_NORMAL_EXPONENT.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/MESHLET_MORPH_NORMAL_EXPONENT.js +11 -0
- package/src/shade/renderer/geometry/morph/MeshletMorphTargets.d.ts +73 -0
- package/src/shade/renderer/geometry/morph/MeshletMorphTargets.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/MeshletMorphTargets.js +130 -0
- package/src/shade/renderer/geometry/morph/MeshletMorphTargetsSerializationAdapter.d.ts +34 -0
- package/src/shade/renderer/geometry/morph/MeshletMorphTargetsSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/MeshletMorphTargetsSerializationAdapter.js +126 -0
- package/src/shade/renderer/geometry/morph/MorphedGeometry.d.ts +50 -0
- package/src/shade/renderer/geometry/morph/MorphedGeometry.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/MorphedGeometry.js +81 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_build.d.ts +22 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_build.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_build.js +375 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_read.d.ts +25 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_read.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_read.js +134 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_validate.d.ts +15 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_validate.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/meshlet_morph_targets_validate.js +110 -0
- package/src/shade/renderer/geometry/morph/morphed_geometry_build.d.ts +22 -0
- package/src/shade/renderer/geometry/morph/morphed_geometry_build.d.ts.map +1 -0
- package/src/shade/renderer/geometry/morph/morphed_geometry_build.js +32 -0
- package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_cluster.d.ts.map +1 -1
- package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_cluster.js +2 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSceneHolds.js +3 -3
- package/src/shade/renderer/hair/GPUHairSystem.js +1 -1
- package/src/shade/renderer/loader/SceneNode.d.ts +20 -1
- package/src/shade/renderer/loader/SceneNode.d.ts.map +1 -1
- package/src/shade/renderer/loader/SceneNode.js +142 -114
- package/src/shade/renderer/loader/gltf/load_gltf.d.ts +1 -0
- package/src/shade/renderer/loader/gltf/load_gltf.d.ts.map +1 -1
- package/src/shade/renderer/loader/gltf/load_gltf.js +214 -30
- package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
- package/src/shade/renderer/loader/mtf/MTFMorphBinding.d.ts +41 -0
- package/src/shade/renderer/loader/mtf/MTFMorphBinding.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTFMorphBinding.js +60 -0
- package/src/shade/renderer/loader/mtf/MTFMorphBindingSerializationAdapter.d.ts +31 -0
- package/src/shade/renderer/loader/mtf/MTFMorphBindingSerializationAdapter.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/MTFMorphBindingSerializationAdapter.js +108 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts +3 -0
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/MTF_PACKAGE_VERSION.js +4 -1
- package/src/shade/renderer/loader/mtf/mtf_export.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/mtf_export.js +7 -0
- package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts +6 -3
- package/src/shade/renderer/loader/mtf/mtf_read_scene.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/mtf_read_scene.js +43 -3
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts +2 -0
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/mtf_serialization_registry.js +9 -0
- package/src/shade/renderer/loader/mtf/mtf_write.d.ts +3 -1
- package/src/shade/renderer/loader/mtf/mtf_write.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/mtf_write.js +20 -1
- package/src/shade/renderer/object_property/ObjectType.d.ts +1 -0
- package/src/shade/renderer/object_property/ObjectType.js +8 -0
- package/src/shade/renderer/object_property/chunk_write_object_property.d.ts +6 -7
- package/src/shade/renderer/object_property/chunk_write_object_property.d.ts.map +1 -1
- package/src/shade/renderer/object_property/chunk_write_object_property.js +13 -7
- package/src/shade/renderer/object_property/chunk_write_object_property_morph_weight.d.ts +17 -0
- package/src/shade/renderer/object_property/chunk_write_object_property_morph_weight.d.ts.map +1 -0
- package/src/shade/renderer/object_property/chunk_write_object_property_morph_weight.js +38 -0
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/scene/GPUSceneContext.d.ts +5 -6
- package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
- package/src/shade/renderer/scene/GPUSceneContext.js +17 -20
- package/src/shade/renderer/scene/MESH_INSTANCE_METADATA_STRUCT.d.ts +1 -1
- package/src/shade/renderer/scene/MESH_INSTANCE_METADATA_STRUCT.d.ts.map +1 -1
- package/src/shade/renderer/scene/MESH_INSTANCE_METADATA_STRUCT.js +2 -2
- package/src/shade/renderer/scene/chunk_mesh_flags.js +3 -3
- package/src/shade/renderer/scene/movers/graph_scene_movers.d.ts +1 -1
- package/src/shade/renderer/scene/movers/graph_scene_movers.d.ts.map +1 -1
- package/src/shade/renderer/scene/movers/graph_scene_movers.js +20 -13
- package/src/shade/renderer/scene/movers/shader_scene_deformed_movers.d.ts +25 -0
- package/src/shade/renderer/scene/movers/shader_scene_deformed_movers.d.ts.map +1 -0
- package/src/shade/renderer/scene/movers/{shader_scene_skinned_movers.js → shader_scene_deformed_movers.js} +28 -18
- package/src/shade/renderer/scene/movers/shader_scene_movers.d.ts +1 -1
- package/src/shade/renderer/scene/movers/shader_scene_movers.js +2 -2
- package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts +13 -13
- package/src/shade/renderer/scene/rows/GPUSceneRows.d.ts.map +1 -1
- package/src/shade/renderer/scene/rows/GPUSceneRows.js +30 -30
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_lattice_position.d.ts +17 -0
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_lattice_position.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_lattice_position.js +78 -0
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_position.d.ts +2 -1
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_position.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/geometry/meshlet/chunk_read_meshlet_position.js +10 -54
- package/src/shade/renderer/shadow/vsm/VSMPageManager.d.ts.map +1 -1
- package/src/shade/renderer/shadow/vsm/VSMPageManager.js +33 -163
- package/src/shade/renderer/texture/virtual/README.md +12 -4
- package/src/shade/renderer/texture/virtual/VTLodBiasController.d.ts +116 -0
- package/src/shade/renderer/texture/virtual/VTLodBiasController.d.ts.map +1 -0
- package/src/shade/renderer/texture/virtual/VTLodBiasController.js +301 -0
- package/src/shade/renderer/texture/virtual/VirtualTextureManager.d.ts +8 -3
- package/src/shade/renderer/texture/virtual/VirtualTextureManager.d.ts.map +1 -1
- package/src/shade/renderer/texture/virtual/VirtualTextureManager.js +110 -20
- package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
- package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
- package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts.map +0 -1
- package/src/shade/renderer/animation/skinning/SKINNING_BINDING_STRUCT.d.ts +0 -22
- package/src/shade/renderer/animation/skinning/SKINNING_BINDING_STRUCT.d.ts.map +0 -1
- package/src/shade/renderer/animation/skinning/bounds_refresh/shader_geometry_sphere_derive.d.ts.map +0 -1
- package/src/shade/renderer/animation/skinning/bounds_refresh/shader_meshlet_bounds_reduce.d.ts.map +0 -1
- package/src/shade/renderer/animation/skinning/bounds_refresh/shader_meshlet_bounds_scatter.d.ts.map +0 -1
- package/src/shade/renderer/animation/skinning/bounds_refresh/shader_skinned_mesh_bounds_refresh.d.ts.map +0 -1
- package/src/shade/renderer/scene/movers/shader_scene_skinned_movers.d.ts +0 -24
- package/src/shade/renderer/scene/movers/shader_scene_skinned_movers.d.ts.map +0 -1
- /package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_geometry_sphere_derive.d.ts +0 -0
- /package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_meshlet_bounds_reduce.d.ts +0 -0
- /package/src/shade/renderer/animation/{skinning → deformation}/bounds_refresh/shader_meshlet_bounds_scatter.d.ts +0 -0
|
@@ -13,20 +13,34 @@ import {
|
|
|
13
13
|
WORKGROUP_SIZE as BOUNDS_SCATTER_WORKGROUP_SIZE,
|
|
14
14
|
} from "./bounds_refresh/shader_meshlet_bounds_scatter.js";
|
|
15
15
|
import {
|
|
16
|
-
|
|
16
|
+
shader_deformed_mesh_bounds_refresh,
|
|
17
17
|
WORKGROUP_SIZE as MESH_BOUNDS_REFRESH_WORKGROUP_SIZE,
|
|
18
|
-
} from "./bounds_refresh/
|
|
18
|
+
} from "./bounds_refresh/shader_deformed_mesh_bounds_refresh.js";
|
|
19
19
|
import {
|
|
20
|
-
|
|
21
|
-
} from "./
|
|
20
|
+
DEFORMATION_BINDING_STRUCT
|
|
21
|
+
} from "./DEFORMATION_BINDING_STRUCT.js";
|
|
22
22
|
import {
|
|
23
23
|
shader_meshlet_apply_skinning
|
|
24
|
-
} from "
|
|
24
|
+
} from "../skinning/shader_meshlet_apply_skinning.js";
|
|
25
25
|
import {
|
|
26
26
|
MESHLET_METADATA_STRUCT
|
|
27
27
|
} from "../../geometry/meshlet/encoding/MESHLET_METADATA_STRUCT.js";
|
|
28
28
|
import { GPUBLASRefitBatch } from "../../geometry/bvh/GPUBLASRefitBatch.js";
|
|
29
|
+
import { MESHLET_MORPH_RANGE_WORDS } from "../../geometry/morph/MESHLET_MORPH_LAYOUT.js";
|
|
29
30
|
import { row_of_entity } from "../../scene/rows/GPUSceneRows.js";
|
|
31
|
+
import { shader_meshlet_apply_morph } from "../morph/shader_meshlet_apply_morph.js";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Written in a binding's morph words for a mesh with no morph targets.
|
|
35
|
+
* @type {number}
|
|
36
|
+
*/
|
|
37
|
+
const NO_MORPH_SECTION = 0xFFFFFFFF;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Zero rows: a morph target set's section is data the pool holds, with no meshlet rows of its own.
|
|
41
|
+
* @type {ArrayBuffer}
|
|
42
|
+
*/
|
|
43
|
+
const NO_ROWS = new ArrayBuffer(0);
|
|
30
44
|
|
|
31
45
|
/**
|
|
32
46
|
* @typedef {import("../../../device/ShadeGPUCommandContext.js").ShadeGPUCommandContext} ShadeGPUCommandContext
|
|
@@ -35,6 +49,7 @@ import { row_of_entity } from "../../scene/rows/GPUSceneRows.js";
|
|
|
35
49
|
* @typedef {import("../../geometry/MeshletGeometry.js").MeshletGeometry} MeshletGeometry
|
|
36
50
|
* @typedef {import("../../geometry/GPUGeometryMetadata.js").GPUGeometryMetadata} GPUGeometryMetadata
|
|
37
51
|
* @typedef {import("../GPUAnimationManager.js").GPUAnimationManager} GPUAnimationManager
|
|
52
|
+
* @typedef {import("../../geometry/morph/MeshletMorphTargets.js").MeshletMorphTargets} MeshletMorphTargets
|
|
38
53
|
*/
|
|
39
54
|
|
|
40
55
|
/**
|
|
@@ -82,13 +97,13 @@ const MESHLET_VERTEX_COUNT_BYTE_OFFSET = MESHLET_METADATA_STRUCT.get('vertex_cou
|
|
|
82
97
|
const MESHLET_STRIDE_BYTES = MESHLET_METADATA_STRUCT.aligned_size;
|
|
83
98
|
|
|
84
99
|
/**
|
|
85
|
-
* Per-scene container for the
|
|
100
|
+
* Per-scene container for the deformation subsystem's state. Owned by
|
|
86
101
|
* {@link GPUSceneContext}; receives the scene's
|
|
87
102
|
* {@link GPUGeometryManager} so it can allocate per-instance geometry
|
|
88
|
-
* clones for
|
|
89
|
-
* against those clones.
|
|
103
|
+
* clones for deformed entities and route the morph and skinning compute
|
|
104
|
+
* passes against those clones.
|
|
90
105
|
*
|
|
91
|
-
* **Everything here is addressed by entity.** A
|
|
106
|
+
* **Everything here is addressed by entity.** A deformed entity is one whose mesh row draws a
|
|
92
107
|
* per-instance clone of its geometry, and its mesh row is `entity + 1` — the same row its
|
|
93
108
|
* transform holds — so a binding never has to be told where its mesh went.
|
|
94
109
|
*
|
|
@@ -96,19 +111,19 @@ const MESHLET_STRIDE_BYTES = MESHLET_METADATA_STRUCT.aligned_size;
|
|
|
96
111
|
* 1. Geometry clones — {@link obtain_clone} makes an entity's per-instance copy of its source
|
|
97
112
|
* geometry when its mesh row is written, and {@link release_clone} gives it back when the
|
|
98
113
|
* row goes.
|
|
99
|
-
* 2.
|
|
100
|
-
* produces one binding record linking its clone's vertex region
|
|
101
|
-
* back to the source's data
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
114
|
+
* 2. Binding bookkeeping — each entity bound to a skin ({@link bind}), to morph targets
|
|
115
|
+
* ({@link bind_morph}) or to both produces one binding record linking its clone's vertex region
|
|
116
|
+
* back to the source's data, to the skin's matrix range and to the morph target set's section and
|
|
117
|
+
* the entity's weights.
|
|
118
|
+
* 3. Per-frame dispatch — `update(cmd_ctx)` uploads any new bindings, dispatches the morph pass
|
|
119
|
+
* over the meshlets a target touches, then the skinning pass over the skinned bindings, both
|
|
120
|
+
* writing the cloned vertex regions in place, then the bounds chain and the BLAS refits over all
|
|
121
|
+
* of them.
|
|
105
122
|
*
|
|
106
|
-
* The CPU-side binding records
|
|
107
|
-
*
|
|
108
|
-
* manager. Resolution happens at upload time via
|
|
109
|
-
* `animation_manager.get_skin_matrix_offset(skin_id)`.
|
|
123
|
+
* The CPU-side binding records name the skin and the morph by id rather than by their rows, because
|
|
124
|
+
* the rows are the animation manager's. Resolution happens at upload time.
|
|
110
125
|
*/
|
|
111
|
-
export class
|
|
126
|
+
export class GPUMeshDeformationContext {
|
|
112
127
|
|
|
113
128
|
/** @type {GPUDevice} */
|
|
114
129
|
#device;
|
|
@@ -138,19 +153,65 @@ export class GPUMeshSkinningContext {
|
|
|
138
153
|
*/
|
|
139
154
|
#skin_by_entity = new Map();
|
|
140
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Which morph each entity is bound to, and the target set its weights index. Populated by
|
|
158
|
+
* {@link bind_morph}; like {@link #skin_by_entity}, it outlives the clone.
|
|
159
|
+
*
|
|
160
|
+
* @type {Map<number, {morph_id: number, targets: MeshletMorphTargets}>}
|
|
161
|
+
*/
|
|
162
|
+
#morph_by_entity = new Map();
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Each morph target set bound to any entity, uploaded once into the meshlet payload pool as a
|
|
166
|
+
* record of its own and held by every binding that names it. Keyed by the set itself: placements
|
|
167
|
+
* of one prefab share the instance.
|
|
168
|
+
*
|
|
169
|
+
* @type {Map<MeshletMorphTargets, {record: object, holds: number, unfollow: function(): void}>}
|
|
170
|
+
*/
|
|
171
|
+
#morph_sections = new Map();
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* `(binding_index, meshlet_local)` pairs the morph pass dispatches over: one per meshlet of a
|
|
175
|
+
* bound mesh that a morph target touches. `null` until the first such meshlet.
|
|
176
|
+
*
|
|
177
|
+
* @type {GPUBuffer|null}
|
|
178
|
+
*/
|
|
179
|
+
#morph_lookup_buffer = null;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Capacity of {@link #morph_lookup_buffer} in pairs.
|
|
183
|
+
*
|
|
184
|
+
* @type {number}
|
|
185
|
+
*/
|
|
186
|
+
#morph_lookup_capacity = 0;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Pairs in {@link #morph_lookup_buffer}: the morph pass's workgroup count.
|
|
190
|
+
*
|
|
191
|
+
* @type {number}
|
|
192
|
+
*/
|
|
193
|
+
#morph_pair_count = 0;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Pairs at the head of `dispatch_lookup` that belong to skinned bindings, which the upload puts
|
|
197
|
+
* first: the skinning pass's workgroup count. The bounds chain takes every pair.
|
|
198
|
+
*
|
|
199
|
+
* @type {number}
|
|
200
|
+
*/
|
|
201
|
+
#skinned_pair_count = 0;
|
|
202
|
+
|
|
141
203
|
/**
|
|
142
204
|
* One CPU record per `(entity, clone)` binding registered via
|
|
143
205
|
* {@link #register_binding}. Resolved into GPU bytes at upload
|
|
144
|
-
* time —
|
|
145
|
-
* {@link GPUAnimationManager#get_skin_matrix_offset},
|
|
146
|
-
* entity is its own meshes-table row, `entity + 1`.
|
|
206
|
+
* time — the entity's skin, if any, becomes `skin_matrix_offset` via
|
|
207
|
+
* {@link GPUAnimationManager#get_skin_matrix_offset}, its morph, if any, becomes its weight
|
|
208
|
+
* run and its set's section address, and the entity is its own meshes-table row, `entity + 1`.
|
|
147
209
|
*
|
|
148
210
|
* `source_record` and `clone_record` are the pool's records for the two batches; the two
|
|
149
211
|
* offsets are copies of theirs, re-read whenever either record announces a move
|
|
150
212
|
* (COMPACTION_PLAN_2026_09_16 §5), and `unfollow` is how the binding stops listening.
|
|
151
213
|
*
|
|
152
214
|
* @type {{
|
|
153
|
-
* skin_id: number,
|
|
154
215
|
* entity: number,
|
|
155
216
|
* source_record: object,
|
|
156
217
|
* clone_record: object,
|
|
@@ -373,7 +434,7 @@ export class GPUMeshSkinningContext {
|
|
|
373
434
|
}
|
|
374
435
|
|
|
375
436
|
/**
|
|
376
|
-
* The binding records the skinning pass reads — one {@link
|
|
437
|
+
* The binding records the skinning pass reads — one {@link DEFORMATION_BINDING_STRUCT} per bound
|
|
377
438
|
* {@link SkinnedMesh}, in {@link #bindings} order. `null` until the first binding has been
|
|
378
439
|
* registered and uploaded.
|
|
379
440
|
*
|
|
@@ -479,11 +540,8 @@ export class GPUMeshSkinningContext {
|
|
|
479
540
|
|
|
480
541
|
this.#skin_by_entity.set(entity, skin_id);
|
|
481
542
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
if (entry !== undefined) {
|
|
485
|
-
this.#try_register_binding(entity, entry);
|
|
486
|
-
}
|
|
543
|
+
// a morph may have bound the entity first: its binding is made again, skinned
|
|
544
|
+
this.#rebind(entity);
|
|
487
545
|
}
|
|
488
546
|
|
|
489
547
|
/**
|
|
@@ -505,6 +563,10 @@ export class GPUMeshSkinningContext {
|
|
|
505
563
|
* it — its vertices freeze at whatever the last skinning pass
|
|
506
564
|
* wrote.
|
|
507
565
|
*
|
|
566
|
+
* A mesh that is morphed too goes on being morphed, from its source again: the morph pass writes only
|
|
567
|
+
* the meshlets a target touches, so the clone is copied from the source first rather than leaving the
|
|
568
|
+
* rest in the last skinned pose.
|
|
569
|
+
*
|
|
508
570
|
* No-op if the mesh isn't bound.
|
|
509
571
|
*
|
|
510
572
|
* @param {number} entity
|
|
@@ -513,12 +575,181 @@ export class GPUMeshSkinningContext {
|
|
|
513
575
|
if (!this.#skin_by_entity.has(entity)) return;
|
|
514
576
|
this.#skin_by_entity.delete(entity);
|
|
515
577
|
|
|
578
|
+
this.#drop_skin(entity);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* The skin of `entity` is gone from {@link #skin_by_entity}: its binding is made again without it, and
|
|
583
|
+
* a morphed mesh's clone goes back to its source for the morph pass to work from.
|
|
584
|
+
*
|
|
585
|
+
* @param {number} entity
|
|
586
|
+
*/
|
|
587
|
+
#drop_skin(entity) {
|
|
588
|
+
this.#rebind(entity);
|
|
589
|
+
|
|
590
|
+
const entry = this.#clones.get(entity);
|
|
591
|
+
|
|
592
|
+
if (entry !== undefined && this.#morph_by_entity.has(entity)) {
|
|
593
|
+
this.#geometries.recopy_clone(entry.clone);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Bind an entity's mesh to morph targets: `targets` is the set its weights index, built against the
|
|
599
|
+
* geometry its mesh row draws, and `morph_id` the animation manager's registration of its weights.
|
|
600
|
+
* The morph pass runs over the meshlets a target touches as soon as the entity has a clone, before
|
|
601
|
+
* or after this call, and before the skin pass if the entity is skinned too.
|
|
602
|
+
*
|
|
603
|
+
* One morph per mesh: re-binding with a different id is refused, {@link unbind_morph} first.
|
|
604
|
+
* Binding again with the same id is a no-op.
|
|
605
|
+
*
|
|
606
|
+
* @param {number} entity
|
|
607
|
+
* @param {number} morph_id
|
|
608
|
+
* @param {MeshletMorphTargets} targets
|
|
609
|
+
*/
|
|
610
|
+
bind_morph(entity, morph_id, targets) {
|
|
611
|
+
assert.isNonNegativeInteger(entity, 'entity');
|
|
612
|
+
assert.isNonNegativeInteger(morph_id, 'morph_id');
|
|
613
|
+
assert.defined(targets, 'targets');
|
|
614
|
+
assert.equal(targets.isMeshletMorphTargets, true, 'targets.isMeshletMorphTargets !== true');
|
|
615
|
+
|
|
616
|
+
const existing = this.#morph_by_entity.get(entity);
|
|
617
|
+
|
|
618
|
+
if (existing !== undefined) {
|
|
619
|
+
assert.equal(existing.morph_id, morph_id, `entity ${entity} is already bound to morph ${existing.morph_id}; unbind_morph before rebinding`);
|
|
620
|
+
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
this.#acquire_morph_section(targets);
|
|
625
|
+
|
|
626
|
+
this.#morph_by_entity.set(entity, { morph_id, targets });
|
|
627
|
+
|
|
628
|
+
this.#rebind(entity);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* The morph an entity is bound to, or -1.
|
|
633
|
+
*
|
|
634
|
+
* @param {number} entity
|
|
635
|
+
* @returns {number}
|
|
636
|
+
*/
|
|
637
|
+
get_morph_id(entity) {
|
|
638
|
+
const morph = this.#morph_by_entity.get(entity);
|
|
639
|
+
|
|
640
|
+
return morph === undefined ? -1 : morph.morph_id;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Drop an entity's morph targets. A skinned mesh goes on being skinned, from its source again; a mesh
|
|
645
|
+
* with no skin freezes at the last shape the morph pass wrote, as an unbound skin does.
|
|
646
|
+
*
|
|
647
|
+
* No-op if the mesh has no morph.
|
|
648
|
+
*
|
|
649
|
+
* @param {number} entity
|
|
650
|
+
*/
|
|
651
|
+
unbind_morph(entity) {
|
|
652
|
+
const morph = this.#morph_by_entity.get(entity);
|
|
653
|
+
|
|
654
|
+
if (morph === undefined) {
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
this.#morph_by_entity.delete(entity);
|
|
659
|
+
|
|
660
|
+
this.#rebind(entity);
|
|
661
|
+
|
|
662
|
+
this.#release_morph_section(morph.targets);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Drop the morph from every entity bound to `morph_id`. Called by
|
|
667
|
+
* {@link GPUAnimationManager#unregister_morph} so the weight rows it frees are named by no binding
|
|
668
|
+
* when the next upload runs.
|
|
669
|
+
*
|
|
670
|
+
* @param {number} morph_id
|
|
671
|
+
*/
|
|
672
|
+
unbind_all_by_morph(morph_id) {
|
|
673
|
+
for (const [entity, morph] of Array.from(this.#morph_by_entity)) {
|
|
674
|
+
if (morph.morph_id === morph_id) {
|
|
675
|
+
this.unbind_morph(entity);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* What an entity deforms by changed: drop its binding, and register it again if a skin or a morph is
|
|
682
|
+
* still bound. A fresh binding takes its new place in the dispatch order and its side-buffer slices.
|
|
683
|
+
*
|
|
684
|
+
* @param {number} entity
|
|
685
|
+
*/
|
|
686
|
+
#rebind(entity) {
|
|
516
687
|
for (let i = this.#bindings.length - 1; i >= 0; i--) {
|
|
517
688
|
if (this.#bindings[i].entity === entity) {
|
|
518
689
|
this.#drop_binding_at(i);
|
|
519
690
|
break;
|
|
520
691
|
}
|
|
521
692
|
}
|
|
693
|
+
|
|
694
|
+
const entry = this.#clones.get(entity);
|
|
695
|
+
|
|
696
|
+
if (entry !== undefined) {
|
|
697
|
+
this.#try_register_binding(entity, entry);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* One more hold on a morph target set's section: uploaded into the meshlet payload pool on the first,
|
|
703
|
+
* a record of its own with no meshlet rows, followed so that a move of it re-keys the bindings.
|
|
704
|
+
*
|
|
705
|
+
* @param {MeshletMorphTargets} targets
|
|
706
|
+
*/
|
|
707
|
+
#acquire_morph_section(targets) {
|
|
708
|
+
let section = this.#morph_sections.get(targets);
|
|
709
|
+
|
|
710
|
+
if (section === undefined) {
|
|
711
|
+
const record = this.#geometries.meshlets.add_batch({
|
|
712
|
+
isMeshletBatch: true,
|
|
713
|
+
count: 0,
|
|
714
|
+
data_buffer: targets.data,
|
|
715
|
+
metadata_buffer: NO_ROWS,
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
const follow = () => {
|
|
719
|
+
this.#bindings_dirty = true;
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
record.changed.add(follow);
|
|
723
|
+
|
|
724
|
+
section = {
|
|
725
|
+
record,
|
|
726
|
+
holds: 0,
|
|
727
|
+
unfollow: () => record.changed.remove(follow),
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
this.#morph_sections.set(targets, section);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
section.holds++;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Give back a hold from {@link #acquire_morph_section}; the last one returns the section to the pool.
|
|
738
|
+
*
|
|
739
|
+
* @param {MeshletMorphTargets} targets
|
|
740
|
+
*/
|
|
741
|
+
#release_morph_section(targets) {
|
|
742
|
+
const section = this.#morph_sections.get(targets);
|
|
743
|
+
|
|
744
|
+
if (section === undefined || --section.holds > 0) {
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
section.unfollow();
|
|
749
|
+
|
|
750
|
+
this.#morph_sections.delete(targets);
|
|
751
|
+
|
|
752
|
+
this.#geometries.meshlets.remove_batch(section.record);
|
|
522
753
|
}
|
|
523
754
|
|
|
524
755
|
/**
|
|
@@ -536,16 +767,11 @@ export class GPUMeshSkinningContext {
|
|
|
536
767
|
* @param {number} skin_id
|
|
537
768
|
*/
|
|
538
769
|
unbind_all_by_skin(skin_id) {
|
|
539
|
-
for (
|
|
540
|
-
const b = this.#bindings[i];
|
|
541
|
-
if (b.skin_id === skin_id) {
|
|
542
|
-
this.#drop_binding_at(i);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
for (const [entity, bound] of this.#skin_by_entity) {
|
|
770
|
+
for (const [entity, bound] of Array.from(this.#skin_by_entity)) {
|
|
547
771
|
if (bound === skin_id) {
|
|
548
772
|
this.#skin_by_entity.delete(entity);
|
|
773
|
+
|
|
774
|
+
this.#drop_skin(entity);
|
|
549
775
|
}
|
|
550
776
|
}
|
|
551
777
|
}
|
|
@@ -700,8 +926,7 @@ export class GPUMeshSkinningContext {
|
|
|
700
926
|
* @param {{clone: GPUGeometryMetadata, source: MeshletGeometry}} entry
|
|
701
927
|
*/
|
|
702
928
|
#try_register_binding(entity, entry) {
|
|
703
|
-
|
|
704
|
-
if (skin_id === undefined) return;
|
|
929
|
+
if (!this.#skin_by_entity.has(entity) && this.#morph_applying(entity, entry) === undefined) return;
|
|
705
930
|
// The binding's presence in #bindings is the source of truth
|
|
706
931
|
// for "already registered". Cheap O(bindings) scan; bindings
|
|
707
932
|
// are O(skinned-mesh-count).
|
|
@@ -709,7 +934,7 @@ export class GPUMeshSkinningContext {
|
|
|
709
934
|
if (this.#bindings[i].entity === entity) return;
|
|
710
935
|
}
|
|
711
936
|
|
|
712
|
-
this.#register_binding(entity, entry
|
|
937
|
+
this.#register_binding(entity, entry);
|
|
713
938
|
}
|
|
714
939
|
|
|
715
940
|
/**
|
|
@@ -769,11 +994,15 @@ export class GPUMeshSkinningContext {
|
|
|
769
994
|
// and the pool says so; the binding list is dirty for that too.
|
|
770
995
|
this.#refresh_bindings_from_records();
|
|
771
996
|
|
|
997
|
+
// skinned bindings first, so the skinning pass dispatches the head of the lookup
|
|
998
|
+
this.#bindings.sort((a, b) => Number(this.#skin_by_entity.has(b.entity)) - Number(this.#skin_by_entity.has(a.entity)));
|
|
999
|
+
|
|
772
1000
|
this.#upload_bindings();
|
|
773
1001
|
|
|
774
1002
|
// None of these reads anything outside the binding list, so a scene edit that left
|
|
775
1003
|
// the list alone cannot have moved them.
|
|
776
1004
|
this.#upload_dispatch_lookup();
|
|
1005
|
+
this.#upload_morph_lookup();
|
|
777
1006
|
this.#upload_prev_position_offsets();
|
|
778
1007
|
this.#refit_batch.set_entries(this.#bindings.map(binding => ({
|
|
779
1008
|
// the identity the clone's BLAS is registered under, and the row skinning deforms
|
|
@@ -788,6 +1017,36 @@ export class GPUMeshSkinningContext {
|
|
|
788
1017
|
const binding_count = this.#bindings.length;
|
|
789
1018
|
const max_workgroups = this.#device.limits.maxComputeWorkgroupsPerDimension;
|
|
790
1019
|
|
|
1020
|
+
// ── Morph: the meshlets a target touches, into the clones ──
|
|
1021
|
+
//
|
|
1022
|
+
// Before the skinning, which reads a touched meshlet back from the clone and the side buffer.
|
|
1023
|
+
// WebGPU runs the two in order, so that is the whole of the dependency.
|
|
1024
|
+
const morph_pairs = this.#morph_pair_count;
|
|
1025
|
+
const morph_weights = this.#animation_manager.morph_weights_buffer;
|
|
1026
|
+
|
|
1027
|
+
if (morph_pairs > 0 && morph_weights !== null) {
|
|
1028
|
+
for (let offset = 0; offset < morph_pairs; offset += max_workgroups) {
|
|
1029
|
+
shader_meshlet_apply_morph.dispatch({
|
|
1030
|
+
encoder: cmd_ctx,
|
|
1031
|
+
group_count_x: Math.min(max_workgroups, morph_pairs - offset),
|
|
1032
|
+
bindings: {
|
|
1033
|
+
dispatch_offset: offset,
|
|
1034
|
+
meshlet_data: meshlets.buffer_data,
|
|
1035
|
+
meshlet_metadata: meshlets.buffer_metadata,
|
|
1036
|
+
morph_weights,
|
|
1037
|
+
prev_morph_weights: this.#animation_manager.prev_morph_weights_buffer,
|
|
1038
|
+
deformation_bindings: this.#bindings_buffer,
|
|
1039
|
+
morph_lookup: this.#morph_lookup_buffer,
|
|
1040
|
+
prev_position_offsets: this.#prev_position_offsets_buffer,
|
|
1041
|
+
prev_positions: this.#prev_positions_buffer,
|
|
1042
|
+
scene_database: this.#scene_context.scene_database_buffer,
|
|
1043
|
+
},
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
const skinned_pairs = this.#skinned_pair_count;
|
|
1049
|
+
|
|
791
1050
|
// ── Skinning: deform the cloned vertex regions ────────────
|
|
792
1051
|
//
|
|
793
1052
|
// WebGPU's `dispatchWorkgroups` is capped at the device's
|
|
@@ -802,8 +1061,8 @@ export class GPUMeshSkinningContext {
|
|
|
802
1061
|
// keeps indexing a flat `dispatch_lookup` table. The encoded
|
|
803
1062
|
// cost grows linearly in sub-dispatch count, but the GPU
|
|
804
1063
|
// work is identical to a single huge dispatch.
|
|
805
|
-
for (let offset = 0; offset <
|
|
806
|
-
const this_chunk = Math.min(max_workgroups,
|
|
1064
|
+
for (let offset = 0; offset < skinned_pairs; offset += max_workgroups) {
|
|
1065
|
+
const this_chunk = Math.min(max_workgroups, skinned_pairs - offset);
|
|
807
1066
|
shader_meshlet_apply_skinning.dispatch({
|
|
808
1067
|
encoder: cmd_ctx,
|
|
809
1068
|
group_count_x: this_chunk,
|
|
@@ -921,7 +1180,7 @@ export class GPUMeshSkinningContext {
|
|
|
921
1180
|
{
|
|
922
1181
|
const total_workgroups = Math.ceil(binding_count / MESH_BOUNDS_REFRESH_WORKGROUP_SIZE);
|
|
923
1182
|
if (total_workgroups > 0) {
|
|
924
|
-
|
|
1183
|
+
shader_deformed_mesh_bounds_refresh.dispatch({
|
|
925
1184
|
encoder: cmd_ctx,
|
|
926
1185
|
group_count_x: total_workgroups,
|
|
927
1186
|
bindings: {
|
|
@@ -981,7 +1240,33 @@ export class GPUMeshSkinningContext {
|
|
|
981
1240
|
* @param {{clone: GPUGeometryMetadata, source: MeshletGeometry}} entry
|
|
982
1241
|
* @param {number} skin_id
|
|
983
1242
|
*/
|
|
984
|
-
|
|
1243
|
+
/**
|
|
1244
|
+
* The morph bound to `entity` when its targets were built against the geometry the entity's clone is
|
|
1245
|
+
* copied from, `undefined` otherwise. A mesh row that came to draw another geometry keeps its morph
|
|
1246
|
+
* binding — the weights are the entity's — but targets laid out over the old meshlets would write the
|
|
1247
|
+
* new clone's vertices out of place, so the clone goes unmorphed until the targets fit it again.
|
|
1248
|
+
*
|
|
1249
|
+
* @param {number} entity
|
|
1250
|
+
* @param {{clone: GPUGeometryMetadata, source: MeshletGeometry}} entry
|
|
1251
|
+
* @returns {{morph_id: number, targets: MeshletMorphTargets}|undefined}
|
|
1252
|
+
*/
|
|
1253
|
+
#morph_applying(entity, entry) {
|
|
1254
|
+
const morph = this.#morph_by_entity.get(entity);
|
|
1255
|
+
|
|
1256
|
+
if (morph === undefined) {
|
|
1257
|
+
return undefined;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
const built_against = morph.targets.geometry;
|
|
1261
|
+
|
|
1262
|
+
if (built_against === entry.source || (built_against !== null && built_against.equals(entry.source))) {
|
|
1263
|
+
return morph;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
return undefined;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
#register_binding(entity, entry) {
|
|
985
1270
|
const clone_metadata = entry.clone;
|
|
986
1271
|
|
|
987
1272
|
const source_metadata = this.#geometries.get_metadata(entry.source);
|
|
@@ -994,7 +1279,6 @@ export class GPUMeshSkinningContext {
|
|
|
994
1279
|
const clone_record = clone_metadata.meshlets;
|
|
995
1280
|
|
|
996
1281
|
const binding = {
|
|
997
|
-
skin_id,
|
|
998
1282
|
entity,
|
|
999
1283
|
source_record,
|
|
1000
1284
|
clone_record,
|
|
@@ -1009,8 +1293,14 @@ export class GPUMeshSkinningContext {
|
|
|
1009
1293
|
prev_position_vertex_offset: 0,
|
|
1010
1294
|
prev_position_vertex_count: 0,
|
|
1011
1295
|
unfollow: undefined,
|
|
1296
|
+
// the morph the morph pass applies to this clone, or none: see #morph_applying
|
|
1297
|
+
morph: this.#morph_applying(entity, entry),
|
|
1012
1298
|
};
|
|
1013
1299
|
|
|
1300
|
+
if (binding.morph === undefined && this.#morph_by_entity.has(entity)) {
|
|
1301
|
+
console.warn(`entity ${entity} draws a geometry its morph targets were not built against; it is drawn unmorphed`);
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1014
1304
|
// The pool moves batches — on a rebuild, and per frame once it sweeps — and announces
|
|
1015
1305
|
// a move through the record. What this binding uploaded names the old rows; mark the
|
|
1016
1306
|
// list and let `update` re-read both records and re-key the table before the pass. The
|
|
@@ -1088,12 +1378,23 @@ export class GPUMeshSkinningContext {
|
|
|
1088
1378
|
const first_row = binding.clone_meshlet_metadata_offset;
|
|
1089
1379
|
const base_vertex_offset = binding.prev_position_vertex_offset;
|
|
1090
1380
|
|
|
1381
|
+
// A mesh with no skin is written by the morph pass alone, and only where a target touches it.
|
|
1382
|
+
// Its other meshlets keep the sentinel: the velocity pass moves them rigidly with the mesh,
|
|
1383
|
+
// which is what they do.
|
|
1384
|
+
const morph_only = !this.#skin_by_entity.has(binding.entity);
|
|
1385
|
+
const morph = binding.morph;
|
|
1386
|
+
const ranges = morph_only ? new Uint32Array(morph.targets.data) : null;
|
|
1387
|
+
|
|
1091
1388
|
let cumulative_vertex_offset = 0;
|
|
1092
1389
|
|
|
1093
1390
|
for (let i = 0; i < binding.meshlet_count; i++) {
|
|
1094
1391
|
const vc = view.getUint32(i * MESHLET_STRIDE_BYTES + MESHLET_VERTEX_COUNT_BYTE_OFFSET, true);
|
|
1095
1392
|
|
|
1096
|
-
|
|
1393
|
+
const written = !morph_only || ranges[i * MESHLET_MORPH_RANGE_WORDS + 1] !== 0;
|
|
1394
|
+
|
|
1395
|
+
this.#prev_position_offsets_cpu[first_row + i] = written
|
|
1396
|
+
? (base_vertex_offset + cumulative_vertex_offset) * 3
|
|
1397
|
+
: PREV_POSITION_OFFSET_INVALID;
|
|
1097
1398
|
|
|
1098
1399
|
cumulative_vertex_offset += vc;
|
|
1099
1400
|
}
|
|
@@ -1162,7 +1463,7 @@ export class GPUMeshSkinningContext {
|
|
|
1162
1463
|
|
|
1163
1464
|
// 3 × u32 per vertex (each u32 carries an f32 bit pattern).
|
|
1164
1465
|
this.#prev_positions_buffer = this.#device.createBuffer({
|
|
1165
|
-
label: '
|
|
1466
|
+
label: 'GPUMeshDeformationContext/PrevPositions',
|
|
1166
1467
|
size: new_capacity * 3 * 4,
|
|
1167
1468
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
|
|
1168
1469
|
});
|
|
@@ -1203,7 +1504,7 @@ export class GPUMeshSkinningContext {
|
|
|
1203
1504
|
}
|
|
1204
1505
|
|
|
1205
1506
|
this.#prev_position_offsets_buffer = this.#device.createBuffer({
|
|
1206
|
-
label: '
|
|
1507
|
+
label: 'GPUMeshDeformationContext/PrevPositionOffsets',
|
|
1207
1508
|
size: new_capacity * 4,
|
|
1208
1509
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
1209
1510
|
});
|
|
@@ -1239,7 +1540,7 @@ export class GPUMeshSkinningContext {
|
|
|
1239
1540
|
*/
|
|
1240
1541
|
#upload_bindings() {
|
|
1241
1542
|
const binding_count = this.#bindings.length;
|
|
1242
|
-
const struct_size =
|
|
1543
|
+
const struct_size = DEFORMATION_BINDING_STRUCT.aligned_size;
|
|
1243
1544
|
|
|
1244
1545
|
if (binding_count > this.#bindings_capacity) {
|
|
1245
1546
|
let new_capacity = Math.max(this.#bindings_capacity, BINDINGS_INITIAL_CAPACITY);
|
|
@@ -1252,7 +1553,7 @@ export class GPUMeshSkinningContext {
|
|
|
1252
1553
|
}
|
|
1253
1554
|
|
|
1254
1555
|
this.#bindings_buffer = this.#device.createBuffer({
|
|
1255
|
-
label: '
|
|
1556
|
+
label: 'GPUMeshDeformationContext/Bindings',
|
|
1256
1557
|
size: new_capacity * struct_size,
|
|
1257
1558
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
1258
1559
|
});
|
|
@@ -1266,15 +1567,23 @@ export class GPUMeshSkinningContext {
|
|
|
1266
1567
|
// the entity is the row, in the meshes table as in the transforms table
|
|
1267
1568
|
const mesh_instance_index = row_of_entity(b.entity);
|
|
1268
1569
|
|
|
1570
|
+
const skin_id = this.#skin_by_entity.get(b.entity);
|
|
1571
|
+
const morph = b.morph;
|
|
1572
|
+
|
|
1269
1573
|
write_gpu_typed_buffer({
|
|
1270
|
-
skin_matrix_offset: this.#animation_manager.get_skin_matrix_offset(
|
|
1271
|
-
skin_matrix_count: this.#animation_manager.get_skin_joint_count(
|
|
1574
|
+
skin_matrix_offset: skin_id === undefined ? 0 : this.#animation_manager.get_skin_matrix_offset(skin_id),
|
|
1575
|
+
skin_matrix_count: skin_id === undefined ? 0 : this.#animation_manager.get_skin_joint_count(skin_id),
|
|
1272
1576
|
source_meshlet_metadata_offset: b.source_meshlet_metadata_offset,
|
|
1273
1577
|
clone_meshlet_metadata_offset: b.clone_meshlet_metadata_offset,
|
|
1274
1578
|
meshlet_count: b.meshlet_count,
|
|
1275
1579
|
clone_geometry_index: b.clone_geometry_index,
|
|
1276
1580
|
mesh_instance_index,
|
|
1277
|
-
|
|
1581
|
+
morph_section: morph === undefined
|
|
1582
|
+
? NO_MORPH_SECTION
|
|
1583
|
+
: this.#morph_sections.get(morph.targets).record.data.offset,
|
|
1584
|
+
morph_weights_first: morph === undefined ? 0 : this.#animation_manager.get_morph_weights_first(morph.morph_id),
|
|
1585
|
+
morph_weight_count: morph === undefined ? 0 : this.#animation_manager.get_morph_weight_count(morph.morph_id),
|
|
1586
|
+
}, DEFORMATION_BINDING_STRUCT, data, i * struct_size);
|
|
1278
1587
|
}
|
|
1279
1588
|
|
|
1280
1589
|
this.#device.queue.writeBuffer(this.#bindings_buffer, 0, data);
|
|
@@ -1299,7 +1608,7 @@ export class GPUMeshSkinningContext {
|
|
|
1299
1608
|
}
|
|
1300
1609
|
|
|
1301
1610
|
this.#dispatch_lookup_buffer = this.#device.createBuffer({
|
|
1302
|
-
label: '
|
|
1611
|
+
label: 'GPUMeshDeformationContext/DispatchLookup',
|
|
1303
1612
|
// 8 bytes per pair (two u32s).
|
|
1304
1613
|
size: new_capacity * 8,
|
|
1305
1614
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
@@ -1309,17 +1618,98 @@ export class GPUMeshSkinningContext {
|
|
|
1309
1618
|
|
|
1310
1619
|
const data = new Uint32Array(total * 2);
|
|
1311
1620
|
let cursor = 0;
|
|
1621
|
+
let skinned_pairs = 0;
|
|
1312
1622
|
for (let b = 0; b < this.#bindings.length; b++) {
|
|
1313
1623
|
const binding = this.#bindings[b];
|
|
1314
1624
|
for (let m = 0; m < binding.meshlet_count; m++) {
|
|
1315
1625
|
data[cursor++] = b;
|
|
1316
1626
|
data[cursor++] = m;
|
|
1317
1627
|
}
|
|
1628
|
+
if (this.#skin_by_entity.has(binding.entity)) {
|
|
1629
|
+
skinned_pairs += binding.meshlet_count;
|
|
1630
|
+
}
|
|
1318
1631
|
}
|
|
1319
1632
|
|
|
1633
|
+
// the bindings are ordered skinned first, so these are the head of the table
|
|
1634
|
+
this.#skinned_pair_count = skinned_pairs;
|
|
1635
|
+
|
|
1320
1636
|
this.#device.queue.writeBuffer(this.#dispatch_lookup_buffer, 0, data);
|
|
1321
1637
|
}
|
|
1322
1638
|
|
|
1639
|
+
/**
|
|
1640
|
+
* Build the morph pass's `(binding_index, meshlet_local)` pairs, one per meshlet of a bound mesh
|
|
1641
|
+
* that its morph target set has blocks for, and upload them (growing the buffer if needed). A
|
|
1642
|
+
* meshlet no target touches is never dispatched.
|
|
1643
|
+
*/
|
|
1644
|
+
#upload_morph_lookup() {
|
|
1645
|
+
let pairs = 0;
|
|
1646
|
+
|
|
1647
|
+
for (let b = 0; b < this.#bindings.length; b++) {
|
|
1648
|
+
const morph = this.#bindings[b].morph;
|
|
1649
|
+
|
|
1650
|
+
if (morph === undefined) {
|
|
1651
|
+
continue;
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
const ranges = new Uint32Array(morph.targets.data);
|
|
1655
|
+
|
|
1656
|
+
for (let m = 0; m < this.#bindings[b].meshlet_count; m++) {
|
|
1657
|
+
if (ranges[m * MESHLET_MORPH_RANGE_WORDS + 1] !== 0) {
|
|
1658
|
+
pairs++;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
this.#morph_pair_count = pairs;
|
|
1664
|
+
|
|
1665
|
+
if (pairs === 0) {
|
|
1666
|
+
return;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
if (pairs > this.#morph_lookup_capacity) {
|
|
1670
|
+
let capacity = Math.max(this.#morph_lookup_capacity, DISPATCH_LOOKUP_INITIAL_CAPACITY);
|
|
1671
|
+
|
|
1672
|
+
while (capacity < pairs) {
|
|
1673
|
+
capacity *= 2;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
if (this.#morph_lookup_buffer !== null) {
|
|
1677
|
+
this.#morph_lookup_buffer.destroy();
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
this.#morph_lookup_buffer = this.#device.createBuffer({
|
|
1681
|
+
label: 'GPUMeshDeformationContext/MorphLookup',
|
|
1682
|
+
size: capacity * 8,
|
|
1683
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
1684
|
+
});
|
|
1685
|
+
|
|
1686
|
+
this.#morph_lookup_capacity = capacity;
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
const data = new Uint32Array(pairs * 2);
|
|
1690
|
+
|
|
1691
|
+
let cursor = 0;
|
|
1692
|
+
|
|
1693
|
+
for (let b = 0; b < this.#bindings.length; b++) {
|
|
1694
|
+
const morph = this.#bindings[b].morph;
|
|
1695
|
+
|
|
1696
|
+
if (morph === undefined) {
|
|
1697
|
+
continue;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
const ranges = new Uint32Array(morph.targets.data);
|
|
1701
|
+
|
|
1702
|
+
for (let m = 0; m < this.#bindings[b].meshlet_count; m++) {
|
|
1703
|
+
if (ranges[m * MESHLET_MORPH_RANGE_WORDS + 1] !== 0) {
|
|
1704
|
+
data[cursor++] = b;
|
|
1705
|
+
data[cursor++] = m;
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
this.#device.queue.writeBuffer(this.#morph_lookup_buffer, 0, data);
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1323
1713
|
/**
|
|
1324
1714
|
* Release this context's buffers, and give back what it holds in the shared geometry manager,
|
|
1325
1715
|
* which outlives it: every clone's vertex region, and every binding's watch on the batch records
|
|
@@ -1333,6 +1723,19 @@ export class GPUMeshSkinningContext {
|
|
|
1333
1723
|
binding.unfollow();
|
|
1334
1724
|
}
|
|
1335
1725
|
|
|
1726
|
+
for (const section of this.#morph_sections.values()) {
|
|
1727
|
+
section.unfollow();
|
|
1728
|
+
this.#geometries.meshlets.remove_batch(section.record);
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
this.#morph_sections.clear();
|
|
1732
|
+
this.#morph_by_entity.clear();
|
|
1733
|
+
|
|
1734
|
+
if (this.#morph_lookup_buffer !== null) {
|
|
1735
|
+
this.#morph_lookup_buffer.destroy();
|
|
1736
|
+
this.#morph_lookup_buffer = null;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1336
1739
|
this.#bindings.length = 0;
|
|
1337
1740
|
this.#total_meshlet_count = 0;
|
|
1338
1741
|
|