Skip to content

antzGames/Godot-4.3-Vertex-Animation-Instancing-Demo

Repository files navigation

PLEASE READ

I have made this solution into a new plugin (with 2 demos). This new plugin makes things much easier to use and now supports any size animations.

Please use the plugin at: https://github.com/antzGames/Godot_Vertex_Animation_Textures_Plugin

This is a video explaining the new plugin: https://youtu.be/BIbEaiVOu6k

This project will still exists, but will no longer be updated/supported. Please use the plugin described above.

 

 


Original content below.


 

 

Godot 4.3: Vertex Animation Instancing Demo

An updated Vertex Animation Instancing Demo Project for the Godot Engine v4.3+.

Modified from the Godot 3.3 version found here: https://github.com/yanorax/Godot-VertexAnimation-Demo

Preview

2024-10-2123-20-09-ezgif com-crop

Description

This project demonstrates how to animate a 3D mesh using vertex data generated by the Not Unreal Tools - Vertex Animation Blender add-on, with a vertex shader inside Godot Engine.

New Features

  • Can support many baked in animations (supports a total of 8192 frames).
  • Ability to set a unique animation track per instance.
  • Can assign a unique tint color per instance.
  • A free unused float value for future functionality.
  • Press F3 for debug menu and FPS counter.

Limitations

  • All animations have to be the same number of frames to make the shader simple to use.
  • Number of animation tracks and number of frames per track have to be known.
  • 3D Models must be less than 8192 vertices.
  • total number of frames for all animations must be less than 8192.
  • you can change animation per instance but no blending or transitions.

Blender Add-On Guide

  1. Download the files from Not Unreal Tools - Vertex Animation and install vertex_animation.py in the Blender -> Edit -> Preferences... -> Add-ons -> Install... menu. In the 3D Viewport side bar, you should now have a Not Unreal Tools menu and if selected it will show a Vertex Animation panel.
  2. In Object Mode select the object you want to process, make sure the current animation you want is selected and playable in the Timeline.
  3. Adjust the Frame Start, End and Step values as required. Changing these settings will update corresponding Timeline values.
  4. Click the Process Anim Meshes button. This will create a new object named export_mesh in the Outliner, this is the special mesh that will be animated. In the source .blend file path there will be a newly created folder called vaexport and inside will be two files; normals.png and offsets.exr.
  5. The export_mesh needs to be exported as a glTF file for importing into Godot. Select the export_mesh object in the Outliner and then from the Blender File menu, select Export -> glTF 2.0 (.glb .gltf). Make the following changes to the export options and then click the Export glTF 2.0 button:
    • Include -> Selected Objects (enable)
    • Geometry -> Materials (disable)
    • Animation -> Animation, Shape Keys, Skinning (disable all)
    • Filename -> can rename to anything

install

tool

Godot Import Guide

  1. You should now have 3 files generated from Blender: normals.png, offsets.exr and export_mesh.glb (whichever filename was chosen, this guide will refer to the default name).
  2. Copy the files into the Godot project folder of your choice. Godot will run the import process as soon as it detects the new files. The import settings for each file still need more changes to ensure all of them work properly with the vertex shader.
  3. In the Godot FileSystem dock, select the glTF file (export_mesh.glb) and then click the Import dock (default location is docked along side of the Scene tree). Godot Docs - Importing 3D Scenes
  4. Make the following adjustments and then click the Reimport button. There should be a new file called export_mesh.mesh in the same folder as the glTF file (export_mesh.glb).
    • Meshes:
      • Compress -> (disable)
      • Ensure Tangents -> (disable)
      • Storage -> Files (.res)
    • Animation:
      • Import -> (disable)
  5. Add a MeshInstance or MultiMeshInstance node to the scene. Drag the export_mesh.mesh file into the Mesh parameter slot for a MeshInstance or the Mesh parameter slot inside the MultiMesh for a MultiMeshInstance node. This guide will not cover loading Mesh resources via script.
  6. The import settings for normals.png and offsets.exr will need to be updated after they are added into the shader parameters since Godot will make changes based on what node the image was applied to (3D nodes apply import settings for images used in 3D).
  7. Apply the custom vertex animation shader material to a MeshInstance/MultiMeshInstance. Recommend using the GeometryInstance -> Geometry -> Material Override slot.
  8. Go to the Shader Parameters and click the drop-down arrow and select load for the following parameters:
    • Offset Map -> load offsets.exr
    • Normal Map -> load normals.png
  9. Now find normals.png and offsets.exr in the FileSystem dock, go to Import settings, make the following changes for both files and click the Reimport button:
    • Compress:
      • Mode -> Lossless for normals.png, Uncompressed for offsets.exr
    • Flags:
      • Repeat -> (disable) when changing the current frame using an AnimationPlayer or via script. (enable) when looping animations using shader TIME.
      • Filter -> (disable)
      • Mipmaps -> (disable)
  10. If you are importing more image files such as albedo textures, refer to Godot Docs - Importing Images. For palettes and texture masks, recommend using Lossless compression and disable Filter and Mipmaps, so there is no blending of the colours.

godot

Assets

mage by Kay Lousberg - CC0 License

characterMedium by Kenney - CC0 License

image

About

An updated vertex animation demo for Godot 4.3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published