Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to bake skinned Meshes with their current animated pose #8120

Closed
smix8 opened this issue Oct 14, 2023 · 2 comments
Closed

Add option to bake skinned Meshes with their current animated pose #8120

smix8 opened this issue Oct 14, 2023 · 2 comments

Comments

@smix8
Copy link

smix8 commented Oct 14, 2023

Describe the project you are working on

Godot things. Spooky things.

Describe the problem or limitation you are having in your project

The feature is frequently required for gameplay or visual effects like e.g. "left behind meshes" with skinned and animated meshes.

Godot's current only option to achieve this is to duplicate the entire mesh including skeleton and animation and pausing the animation playback at the exact time to keep the pose.

Just thinking about this as the only option causes severe performance trauma to every game dev.

I added this feature for my custom builds but I am making this proposal because I think this should be a core feature in Godot available for everyone.

skinned_mesh_baking
Spooky .... spooky

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Unity has a BakeMesh function in the SkinnedMeshRenderer for this exact purpose.

This function bakes the current animated pose of a mesh to a different mesh "freezing" the pose in place without the need for a skeleton or animation going forward.

Since the animated mesh is turned into a "normal" mesh it can also be used with x-amount of other functions that only work on the base mesh ignoring any animated pose.

Godot could provide the same functionality, preferably on the MeshInstance3D because it holds the skeleton animated mesh.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The MeshInstance3D gets a new function e.g. bake_mesh_from_current_skeleton_pose().

This function collects the current skeleton bone transforms from the skeleton that the MeshInstance3D uses.
Then it loops over the surfaces of the mesh that the MeshInstance3D uses and xforms the required mesh arrays.
The result gets applied to the "bake" Mesh that is provided as a parameter.

var bake_mesh: ArrayMesh = ArrayMesh.new()

MeshInstance3D.bake_mesh_from_current_skeleton_pose(bake_mesh)

If this enhancement will not be used often, can it be worked around with a few lines of script?

No, and baking meshes like this is also performance heavy so scripts are not the right place.

Is there a reason why this should be core and not an add-on in the asset library?

Both animation and rendering are part of core.
Scripts are too slow for this with more complex meshes.
Plenty of common gameplay and visual effects require to bake skinned and animated meshes at runtime.

@emberlightstudios
Copy link

emberlightstudios commented May 1, 2024

Is there no way to get the posed mesh with a shader?

@akien-mga akien-mga added this to the 4.4 milestone Sep 4, 2024
@akien-mga
Copy link
Member

Implemented by godotengine/godot#85018.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants