Skip to content

A tool to bake VAT (Vertex Animation Texture) from AnimationClip with sample shaders for Unity.

License

Notifications You must be signed in to change notification settings

fuqunaga/VatBaker

Repository files navigation

VatBaker

A tool to bake VAT (Vertex Animation Texture) from AnimationClip with sample shaders for Unity.

Installation

Edit > ProjectSettings... > Package Manager > Scoped Registries

Enter the following and click the Save button.

"name": "fuqunaga",
"url": "https://registry.npmjs.com",
"scopes": [ "ga.fuquna" ]

Window > Package Manager

Select MyRegistries in Packages:

Select VatBaker and click the Install button

Usage

  1. Window > VatBaker
  2. Set a GamObject with Animation and SkinnedMeshRenderer.
  3. (Optional) Set other parameters.
  4. Push the Bake button.
  5. Assets are created under Assets/VatBakerOutput and a VAT GameObject is put in the hierarchy.

Use VAT on your shader

Use VAT functions at the vertex shader.

#include `Packages/ga.fuquna.vatbaker/Shader/vat.hlsl`

vertex shader

float animationTime = CalcVatAnimationTime(<baseTime[sec]>);
float vertexPositionLocal = GetVatPosition(vertexId, animationTime);
float vertexNormalLocal = GetVatNormal(vertexId, animationTime);

See VatUnlit.shader, VatSurfaceStandard.shader

Set material properties for VAT.

Property name Value
_VatPositionTex Assets/VatBakderOutput/*/*.posTex.asset
_VatNormalTex Assets/VatBakderOutput/*/*.normTex.asset
_VatAnimFps Baked animation fps
_VatAnimLength Baked animation length[sec]

It is recommended to duplicate the material under Assets/VatBakerOutput and change the shader so that the original property values can be used as they are.

Example Asset

Reference