Search code examples
three.jsmorphing

Increase number of maximum assigned morph targets on a mesh


I have a mesh with 17 morph targets plus morph normals. I wand to assign a least about 10 of them at the same time. Now i realized that three.js supports only 8 morph targets at a time, with morph normals only 4.

Found this thread on github. Interestingly it's not a day old. So far no related question appeared here, so i ask.

I wonder if it's anyhow possible to increase the maximum number. Maybe by overriding the underlying shaders.

And why is this limited at all and not the max number of morphed vertices, which would make more sense for performance.


Solution

  • Most graphics cards support only 16 vertex attributes. Because three.js computes morph targets on the GPU, it needs to allocate those 16 attributes so that things like position, normals, skinning, and vertex colors also have attributes available. This is the reason three.js has a limit of 8 attributes available for morph targets — the other 8 are allocated elsewhere. Technically it would be possible to modify three.js and change that — say, to get up to 15 morph targets and 1 position attribute — but that's probably too complex for an SO answer.