# Dynamic Morph Target

**URL:** <https://forum.babylonjs.com/t/dynamic-morph-target/54744>\
**Category:** Feature requests\
**Tags:** morph, dynamic-texture, morph-targets\
**Created:** [November 14, 2024, 2:44am UTC](https://forum.babylonjs.com/t/dynamic-morph-target/54744 "2024-11-14T02:44:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kzhsw](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kzhsw](https://forum.babylonjs.com/u/kzhsw)\
**Post date:** [November 14, 2024, 2:44am UTC](https://forum.babylonjs.com/t/dynamic-morph-target/54744/1 "2024-11-14T02:44:46Z")

</div>

Version: 7.33.0

## Background

Currently (7.33.0) there is no way to update vertex data in a `MorphTarget` after being added to a `MorphTargetManager` and rendered. Because in `synchronize()`, the only method that uploads `MorphTarget` data to gpu, it only checks the texture size to update, not data inside eash `MorphTarget`.

> <https://github.com/BabylonJS/Babylon.js/blob/58ca18ab6404b74393271be047de64ecd1dd2726/packages/dev/core/src/Morph/morphTargetManager.ts#L442>

## Proposal

Add a `MorphTargetManager#forceUpdate` method that rebuilds the texture data, and upload it to GPU via `RawTexture2DArray#update`, to avoid disposal and recreation of GPU resources. When underlying data being updated, user should know it, and choose to update the texture or not.

Example here:

> **[Babylon.js Playground](https://playground.babylonjs.com/#7SXD2Y%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

## Alternatives

1. Dispose the `MorphTargetManager` and recreate it, resulting in disposal and recreation of GPU resources, might hurt performance in some cases.
2. Add a dirty check in `MorphTargetManager`, when a `MorphTarget` being updated, mark the `MorphTargetManager` as dirty, and check it in `MorphTargetManager#synchronize()`, this would cause extra rendering overhead, making performance of existing static morph target worse.
3. Add a `DynamicMorphTargetManager` extends `MorphTargetManager`, with dirty checks above.
