CalculateTangentsForMesh running very slow

Hi, I am using a procedural mesh (only 5K vertices) which has vertex animation (540 frames). Now for each frame I want to precompute the normals and tangents and I use UKismetProceduralMeshLibrary::CalculateTangentsForMesh which works great. The problem is that its very very low and it takes over 10 secs to compute 540 frames. I was in DebugGame Editor config but switched to Development Editor but still its slow. Are the usual floating point fpu acceleration off or something ? And will the Shipping configuration speed up things ?


I’m having the same issue. Did you manage to resolve it?

I too am working on a terrain generator using the PMC classes and am facing the same issues.

On a 512 X 512 mesh of a single mesh section it takes a full two minutes to calculate tangents and normals, even in a multithreaded setup.

This is happening on slightly below mid-range hardware, i7 3610, 16GB RAM and GTX 660M laptop.

That’s really just not feasible, even for a single load operation at beginning of game.

Would appreciate insight into this Unreal staff!

My current idea is to just split up the mesh into sections of 64X64 (as they seem to calculate fast enough) and generate those over frames.


Roll my own tangents and normal calculation code.

Which I would not prefer seeing as I find it hard to believe that I could write this sort of code better than the folks at Epic. =)

I eventually used my own tangent generation code which proved fast but with less functionality, did the job though.

Hey - I’ve looked at the implementation of the function and the problem is, that it has an exponential runtime, depending on the number of vertices in your MeshSection.

You can kind of mitigate the problem by limiting the number of Vertices in each MeshSection and create multiple MeshSections, for example: Instead of one MeshSection with 10.000 Vertices, you make 10 MeshSections with 1000 Vertices.

Problem: The more MeshSections you have, the worse the runtime performance is, because of the increased number of draw calls :confused:

Thanks for sharing your findings!

Looks more and more like a self-written tangents/normals solution is the only one that will work. I’ve seen lots of people do it by now so clearly it must work.