Python + Shader
Vertex Shader ANIMATION Tool
Maya tool to export vertex animation as textures and use them in vertex shader.

Source code and demo files can be download from Github page.

introduction

In most of current game engines, skinned bone animation is the main method to animate meshes. However, there are many situations that we may need to import more general vertex animations from Maya or 3dsMax. One workaround is to create tons of bone joints that means heavily drawback the performance since the vertex movements all rely on CPU computing. (Game engines also have limitation on the number of joints).

In order to build more engaging game environment, sometimes the crowed and environment animation is required. In that case, the CPU skinning animation would also significantly affect the performance. Vertex shader animation is commonly used in current game industry to save the CPU animation computations. The most common way is to create a simple vertex animation and hard-code them into the specific shader programs.

I am working on a tool chain which the artist can direction export their vertex animation into data texture. The textures can be read by one shader program to rebuild the animation. I hope it can boost the efficiency of the pipeline and offer more possibilities of game animations.

Animation in Maya

Animation in Unity with Vertex shader

Problems & Challenges:

In Maya: Get the vertex animation data in maya. Figure out a way to efficiently encode the data and store it into texture(s).

In Shader: Precisely read out data from the texture and apply them in the vertex shader.
1. The data needed to be sufficient to represent the animation.
2. Need to figure out a way to efficiently encode and save the data into the texture picture(s).
In the vertex shader, all the vertex should read the data at the same logic. All the vertices need to use a same mapping method to figure out the location(data fetch UV) of their own data in the texture.

tips:

1.Since the textures are storing exact data, only point sampling mode (no filter) can get the correct data.

2.Maya doesn’t store the per-vertex tangent data (only per-face-per-vertex tangent), so I need to calculate the per-vertex tangent in the python code. ( That’s the main reason to slow down the export process, and if there is no normal map used, it can be turn off.)

3. Maya python can directly use pyside image to manipulate the image data. Consider the image as a list and direct write color as byte data will be faster than pixel manipulation.

During this project, I also come out a way to use pyside to build up UI through a list of element. For pyside color manipulation thanks to Nathan Horne’s blog http://nathanhorne.com/, it is very inspiring.