Community Tutorial: Baking out vertex animation in editor with AnimToTexture

I have only tested this on the UE5 mannequin and noticed a slight difference in lighting / normals. I can’t speak to the level of precision you should expect. In the material you’re using BlendAngleCorrectedNormals to integrate the baked rotations?

I am a little spoiled here with high end A6000 GPU. A 1070 is getting pretty old at this point, so you’ll have to adjust expectations for your content. You can work with lower res meshes. WPO will also invalidate your virtual shadow maps, so there’s an added cost there. You should consider some sort of system where you have LODs or a different material with no WPO in the distance. You can also adjust Lumen settings to have a lower quality or fade out at a shorter distance. There is a big rabbit hole of GPU profiling and optimizations you’ll likely be going down.

Okay, thank you. I thought vertex animation is very cheap (even in old hardware :grinning:)

On the topic of fixing the shadow artifacts related to Virtual Shadow Maps:
Firstly you can test if it is caused by shadow maps by using the console command r.Shadow.Virtual.Cache 0 and seeing if this removes the artifacts.

If you go to the docs on Virtual Shadow Maps it says:

Geometry that can be deformed using Skeletal animation, or materials using World Position Offset or Pixel Depth Offset always invalidates cached pages every frame. By definition, these cases must also be non-Nanite — which is more expensive — and therefore it is extremely important to ensure that these features are used carefully and bounds are kept under control.

It seems the main issue is that auto generated bounds are not fully containing the mesh after the vertex anims are applied. So you need to extend the mesh bounds fully contain the mesh with Vertex Anims.

To fix this:

  1. Run your game and enable the console command: r.Shadow.Virtual.Cache.DrawInvalidatingBounds 1
  2. Open your static mesh and adjust the Postive Bounds Extension until it contains the mesh (is there a better way to adjust the bounds?)
  3. Shouldn’t have any shadow issues if the bounds are applied correctly

See video below:

I don’t know about the performance considerations of what I have described here. It says in the docs that “materials using World Position Offset always invalidates cached pages” and I assume extending the bounds of the mesh will worsen the performance.

If anyone knows a better solution to this, please let me know.

My vertex animated meshes seem to have a lot of TAA ghosting. Is there a way to fix that?

I have made a pull request exposing the plugin outside the engine (as currently you cannot access the Blueprint Library and some other core structs): https://github.com/EpicGames/UnrealEngine/pull/10705

Thanks for the guide, but it is very hard to process. At first glance it looks well written, with illustrative examples, but the structure is very complex. I felt like I was watching the movie Tenet. The guide lacks step by step instructions. Hope to see more structured and simple tutorials from you <3

I updated the vat tool to work with 5.3 and added some qol changes. I also got lods working without too much effort. I will post a video of that soon as well as upload a sample project. https://youtu.be/-DMjIppWRlg?si=M8tXCGDy5DRX1k8q

1 Like

You can recalculate the displaced vert normals in the shader.

I have tried this plugin and I can get the animation textures work, but there is still one issue which can stumble others, so I want to leave a message here for the record.

When I make a static mesh from the skeletal mesh in UE, the static mesh is getting an extra “lightmap” UV channel. This lightmap channel persists even if I disable “generate lightmap UVs” in the details. If I set the lightmap UV channel in the Data Assets, the utility BP will complain that UV channel is being occupied by lightmap and refuse to execute. My only solution is to export the static mesh, add an empty UV channel in Maya, and export it back to UE.

I tried to add a new UV channel with UE’s modeling tool, but the resultant animation is a mess.

You can try adding another step during the Editor Utility process to add a UV channel. Might need to expose a BP function to do this though.

DataAsset->StaticMesh->AddUVChannel(0);

I was using 5.2, and it seems to have been fixed for 5.3, as long as I disable “generating lightmap UV” in the utility BP.

Native plugins helps a lot!
Nearly has a question,my original animation sample frame is 30.But convert to vertex animation not smooth.I already use the high Precision,Enforce the power of two about the texture,and try bone and vertex two method,but still same result.
raise the sample rate should work,but when I raise it more than the original animation’s sample rate(30),the bake animation not complete because it still keep same num frames in bake result.
Then I check the code about “UAnimToTextureBPLibrary::AnimationToTexture”,I think when setting(DA)'s sample rate difference with original animation,the bake result’s animation’s frame not change and won’t complete.
I don’t know am I right or any method to improve my bake result,I am using 5.4.

I am getting some really funk results here:


Maybe someone has an idea what went wrong here?

found my error! It was the UV channel for shadows from lightmass.

1 Like

In case you want to try the AnimToTexture helpers with 5.4.3, I’ve opened a PR to make the widget work with 5.4.3: Make EUW VAT 5.4.3 compatible by tomaaron · Pull Request #14 · kromond/AnimToTextureHelpers · GitHub

It would be great if there was a tutorial for integrating this with Niarara to make crowds moving around. I think they do this in the matrix demo in order to have so many people at once, but I’ve never been able to work out how its actually set up

@ruigol That’s been on the back of my mind since the very beginning, but I didn’t have enough Niagara skills to get it working. Once you have a static mesh, you can easily add it to a particle system. There’s are 2D and 3D fluid systems for Niagara, so it would be relatively straightforward to get a prototype working if you’ve got the skills.

Matrix Demo, aka City Sample, did use this for background characters and swapped to skeletal meshes up close. It was part of the Mass AI system, not Niagara. It’s all in the project, but it’s yet another complicated system to learn. I haven’t bothered with it yet.

Ah I see, the mass ai system worked well for me but having ‘characters’ walk around quickly became a performance nightmare, but if it can move static meshes then this could be a great solution, ill have to test it out