Bake skinned mesh animations to 2D textures
Bake skinned mesh animations to 2D textures!
Animation Rig
fieldColor Mode
LDR
exports as a .png
and clamps colors in a 0 - 1 range, as well as rounds colors to the nearest 1/255thHDR
(highly recommended) exports as a .exr
and does not clamp or round colors* (*it's possible that it does, but the range is extended far beyond LDR)Bake All
if you want to bake all animations into a Texture2DArray. Jump to Bake All if you enable this.FPS Capture
based on how you exported the animation from your tool of choice. 30 or 60 is recommended for animation exportClip to Bake
Bake Scale
to how large you want your baked animation to be, compared to the original sizeMin Capture Frame
and Max Capture Frame
to determine the range of frames to be baked into the textureAnimations
: How many animations will be baked. This is always 1 unless you bake all animationsFPS Capture
, Min Capture Frame
, Max Capture Frame
, and the duration of Clip to Bake
Frames to bake
and the mesh's vertex countPixels to fill
.Bake All
, the tool will bake all textures into a Texture2DArray asset.FPS Capture
and Bake Scale
, both detailed above.Result texture size
now has a 3d dimensions, relating to how many elements the Texture2DArray will have. No matter how small an individual texture can be normally, the result will be the maximum size required.Mesh
to copy with the new UVsUV Layer
you want to set. If you've already got UVs on that layer, a warning will appearMesh Scale
to scale the mesh. It's recommended to set this, even if you're scaling the mesh via shader. Setting it properly will reduce the chance of render bounds being incorrect.AnimationTexture
float TimeOffset
: How many seconds the animation will be offset byfloat4 VertexIDUV
: The UVs for whichever channel you selected when you baked the mesh in UV Mapperfloat ColorMode
: LDR textures should use 0, HDR textures should use 1float FramesPerSecond
: The FPS you baked the texture atfloat AnimationFrames
: How many frames are in the baked animationTexture2D TexIn
: The baked animation texturefloat2 TexSize
: The texture's pixel dimensionsfloat Scaler
: The inverse of what you want to scale the mesh by. 0.5 doubles the mesh size, 2 halves itfloat VertexCount
: The vertex count of the meshSamplerState TexSampler
: The sampler state used to sample the texture. Filtering should be Pointout float3 PosOut
: The resulting vertex positionsAnimationTexturev2
Texture2DArray textures
: The Texture2DArray created when Bake All
is enabled in Texture Creatorfloat3 vertexPositions
: The original vertex positionsfloat time
: The current time. It's not calculated in the method, resulting in more customizabilityfloat4 vertexIdUv
: The UVs for whichever channel you selected when you baked the mesh in UV Mapperint vertexCount
: The vertex count of the meshint framesPerSecond
: The FPS you baked the texture atfloat scaler
: The inverse of what you want to scale the mesh by. 0.5 doubles the mesh size, 2 halves itint textureSize
: The pixel dimensions of the Texture2DArray. Only one is necessary, since the x and y values of the texture are always the same.float4 lerper
: With the provided configuration, this lerps between texture layers. x, y, and z lerp texture layers, while w lerps from texture layers to the original meshint4 index
: The indices of the texture layers you want to sampleint4 frames
: The frame count of each texture layer animation you want to sampleSamplerState samplerState
: The sampler state the sample the textures with. The Filter should be set to Pointout float3 positionOut
: The resulting vertex positionsAvailable in the Unity Package Manager