Godot 4.3: Vertex Animation Instancing Tutorial
https://www.youtube.com/watch?v=IBY1cdlpGXo
GPU instancing for animation in Godot is achieved by using Vertex Animation Textures (VAT) with the MultiMeshInstance3D node. This technique allows for the efficient rendering of thousands of individually animated objects by offloading the animation calculations from the CPU to the GPU.
How GPU Instancing Animation Works in Godot
Standard skeletal animation is typically CPU-intensive, as the CPU calculates bone transformations for each instance. GPU instancing bypasses this by baking the animation data into a texture. A custom shader on the GPU then reads this texture data to determine the vertex positions for each instance, animating the mesh in the shader itself.
Implementation Steps
Implementing this requires a specific workflow involving both external tools (like Blender) and Godot's engine features.
Model and Animate in Blender: Create your 3D model and its animations in Blender.
Export Animation as Texture: Use a specialized Blender add-on, such as the Not Unreal Tools Vertex Animation Blender add-on, to string together animation tracks and export the data as image files (textures) and a single mesh.
Import into Godot: Import the generated mesh and the position/normal textures into your Godot project.
Set up MultiMeshInstance3D:
Add a MultiMeshInstance3D node to your scene.
Assign the exported mesh and create a custom ShaderMaterial.
Create a Custom Shader: Write a vertex shader that reads the animation data from the texture based on per-instance custom data (like animation track and time) and modifies the vertex positions accordingly. A plugin like the Godot Vertex Animation Textures Plugin can provide a pre-made shader and simplify the setup process in the editor.
Instance and Control via Script: Use a script to populate the MultiMeshInstance3D with thousands of instances. You can pass unique data to each instance via "custom data" (e.g., a Vector4 used to specify the current animation track and playback speed) to control individual animations.
This method significantly reduces draw calls and improves performance, allowing for scenes with hundreds or thousands of animated characters that would otherwise lag if using traditional AnimationPlayer or Skeleton3D nodes for every instance. Official documentation on this method can be found in the Godot Docs.