convertToUVN and convertFromUVN

So I have previous posts about translateUVN and twistUVN deformers which transform points along a nurbs surface. The work perfectly fine but they get bogged down by the unfortunate fact that the MFnNurbsSurface class in the Maya API is not multithreadable. As I outlined in my earlier posts we can kind of avoid that bottleneck by making the deformer get prebound to the surface instead of being a spacial deformer (so during evaluation we never have to use the costly closestPoint method), and by putting multiple weight maps on one deformer (so we can do far fewer nurbs calculations than we would if we had multiple translateUVN deformers each with a single weightMap). However even with all that optimization (plus a lot of smaller code improvements) the UVN deformers aren't fast enough to be used willy-nilly.


However, this past weekend I made a breakthrough. If you're using several UVN deformers on the same nurbsSurface you could get some major speed boosts by only having the bind step and nurbs sampling step occur once, instead of per deformer. I was able to accomplish this by having a deformer at the front of my chain that remapped from XYZ space to UVN space using the bindData we calculate once, and assigned those UVN coordinates to the vertices. So what you ended up with was a section of your mesh that had been "unwrapped" and moved to origin.


The result looks kind of like this:

Which might remind you of that .gif from "The Art of Moving Points":

Or if you're one of the other people who are as obsessed with this stuff it may remind you of this patent from Blue Sky studios:

https://patentimages.storage.googleapis.com/21/96/1b/e798006513c092/WO2016149444A1.pdf


We then have a second deformer that remaps that flattened mesh back into the original 3d mesh. In between the convertToUVN and convertFromUVN deformers you can use any deformer you want, and then when you "convert from UVN" the points will behave like they are sliding along the nurbsSurface. You could use a skinCluster, blendShape, or any other defomer on that unwrapped mesh and it would perform those deformations "on the nurbs surface".


I know I'm being sort of vague, mostly because I like to keep this posts short unless someone reaches out asking for details.


The real secret sauce comes from being able to perform deformations before "converting to UVN" an keeping those deformations intact. I was able to do this by storing the an offset for each point (relative to the surface) when the convertToUVN deformer evaluates, and passing that offset pointArray to the convertFromUVN deformer so they can be re-applied after sliding along the surface. None of the deformers between the convertToUVN and convertFromUNV need those offsets.


For the curious, this was twice as fast as using the nurbs surface on each brow deformer.



Featured Posts
Recent Posts
Archive
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square

jonahrnhrt@gmail.com

630 - 725 - 8969

jonah-reinhart.com