How fuqunaga/vatbaker works
Based on our analysis of the provided file tree and README, VatBaker is a Unity package that assists users in baking Vertex Animation Textures (VAT) from AnimationClip data. It integrates with the Unity Editor to provide a tool window and editor scripts that trigger the baking process. In short, it is a plugin that combines editor interaction, data processing, and runtime shader support.
Main Components
• Unity Editor Integration – This includes the custom Editor Window (accessible at Window > VatBaker) and supporting scripts (e.g., VatBakerWindowForAnimation.cs, VatBakerCore.cs). They capture user input, trigger the baking process, and interface with Unity's AnimationClip and SkinnedMeshRenderer.
• VAT Baking Processor – The core algorithm that processes AnimationClips to produce vertex animation data. This component is responsible for transforming mesh animations into texture data. It reads input parameters set in the Editor Tools and then writes output assets.
• Output Assets Repository – Once baking is complete, assets (including position textures, normal textures, and prefabs) are written under the Assets/VatBakerOutput folder.
• Shader & Runtime Integration – In the Packages area (Packages/ga.fuquna.vatbaker/Shader) you have shader files (Vat.hlsl, VatSurfaceStandard.shader, VatUnlit.shader) that are used to apply the baked VAT to meshes at runtime. These shader components integrate with the material properties required for proper VAT display.
• Unity Engine Environment – The overall environment that handles everything from scene management, rendering, and asset management (this is implicit but important to show as the platform on which VatBaker runs).
Relationships and Interactions
• The Editor Window (part of the Editor tooling) receives user settings (e.g., selection of GameObjects, AnimationClips, baking parameters) and passes these to the VAT Baking Processor.
• The VAT Baking Processor interacts directly with Unity’s asset database to generate and store the output texture assets in Assets/VatBakerOutput.
• The output assets are then meant to be consumed by runtime scenes. The shaders, when used on materials, reference these textures using specific property names (_VatPositionTex, _VatNormalTex, etc.) and use VAT functions (through vat.hlsl) to fetch animation data during rendering.
• The entire package is managed by the Unity Package Manager, which makes it available as a dependency within the Unity project.
Architectural Patterns & Design Principles
• Separation of Concerns – The project clearly separates editor functionalities (in the Editor folder) from runtime functionalities (under Runtime and Shader folders). This separation improves maintainability.
• Plugin/Modular Architecture – As a Unity package, VatBaker is designed to be plugged into any Unity project, keeping its own isolated namespaces and scripts.
• Data Transformation Pipeline – The workflow begins with data capture from the scene (AnimationClip/SkinnedMeshRenderer) and ends with baked texture output, effectively forming a pipeline from input to output.
Relevant Technologies, Frameworks, & Dependencies
• Unity Engine – Core game engine APIs for asset/scene management.
• Unity Editor Scripting – Custom Editor Windows and editor tools to enable an interactive user interface.
• HLSL/Shader Graph – For shader files that interface with the baked VAT data.
• Node-based Package Management – The structure in Packages/ga.fuquna.vatbaker indicates dependency management via npm-style scoped registries (as per the README's installation guide).
Additional Details
• Configuration files as minor nodes to indicate version control and CI/CD (such as items under .github/workflows and package manifest files).
• Adding external references (links to the VAT animation technique and references provided in the README) as annotations.