Tuesday, February 28, 2012

Geo caching for easier animation

Some students of mine were doing things that suggested geo-caching to me and I just used this on a job, so I was all like "wooohooo!". And then I made this video.
Basically talks about the general idea of geo-caching and then I show one example of what I used this on recently. General gist of it: Maya, Geometry, Cached.
Slightly less general gist: You'd use this to lighten some of the processing load in your scene, either by allowing you to eliminate heavy rigs or allowing you to use light version of your characters (i.e. just geo) for multiple instances of an animation. Basically baking animation into the geo itself for use later in various ways. So check it:

Edit/Addendum - Totally did not get back around to the bit about why the eyes and teeth didn't come along for the ride in the geo cache! Oops. That's Ok. The reading will do you good.
Here's the deal. . . geo won't get written to the cache (at least the default Maya cache) if it doesn't have something driving the shape node itself (like skinning or other deformers). Simply translating or rotating the geo won't cut it since that stuff operates on the transform node and leaves the shape node to rest a bit. Soooo. . . since I usually connect things like eyes and gums/teeth into the rig via some combo of parenting to groups and constraining those groups (it's easy, clean), when I try to include those in the cache, they sit completely still, unaffected by caching party going on around them. So the easiest way around that is to just bind them to a joint, either existing or created just for that purpose. If you do it carefully, you won't even have to weight them (bind them separately from the rest of the geo, just to one selected joint). But they'll then be included in the caching. The other option is to set up some kind of follicle system on your cache-catching rig, the simple one, whereby you'd use follicles or rivets to stick things like the eyes and teeth to the cache-animated geo. A bit wonkier, but whatever gets ya through the night, amiright?


  1. Hey Zeth, I've been watching your videos for about 2 years now, and I thought it was about time to say thanks for all the great work you do with these lessons.

    It really annoys me when people doing videos like "maya hair in 2 minutes" gets lots of views, and great videos like yours get passed out.

    You are doing a big contribution to the comunnity so please keep doing this!

    PS: Sorry if my english is not very good.

  2. Ha! your english is fine!
    Thanks for the kind words. I actually like 2 minute tutorials, as I don't always have time for a long epic video. But I also like learning WHY things work, and I tend to blather on, so I've ended doing things more long form. Glad it's appreciated (sometimes). . .
    But thanks for watching em!


  3. Hi Zeth,

    Alternatively you can hook up the non-deformed mesh to a dummy polyUnite node which tricks maya into thinking the shape is cacheable. You have to do this via script though... I apologise for the formatting in advance ;)

    global proc gks_meshCache()
    string $sel[] = `ls -sl`;
    string $selShape[] = `ls -sl -dag -lf`;
    int $selCount = size($sel);

    if ($selCount < 1)
    error "Please select at least one mesh.";

    for ($i = 0; $i < $selCount; $i++)
    string $cacheObj[] = `polyCube -ch 0 -n ($sel[$i] + "_cache_geo")`;
    string $unite = `createNode polyUnite -n ($sel[$i] + "_" + $cacheObj[0] + "_polyUnite")`;
    connectAttr -f ($selShape[$i] + ".worldMatrix") ($unite + ".inputMat[0]");
    connectAttr -f ($selShape[$i] + ".worldMesh") ($unite + ".inputPoly[0]");
    connectAttr -f ($unite + ".output") ($cacheObj[0] + ".inMesh");

  4. @Geoff3d-

    Ooooh. That's a clever trick. . . So you're creating a cube, tricking that into thinking it's the orig, clean geo and then pumping the selected object's "cache" into that? Overriding the shape node? I'm not even sure what's happening there, but it's pretty cool. Can you explain a bit more what's going on there? Thanks!


  5. Hi Zeth!
    Great tutorial! Learned a lot from this! Thx for sharing. Appreciated! About the addendum; I have a rig from an external partner and I would like to export the cache without selecting all the parts, since I certainly will forget some parts. How do I select all geometry at once? When I select the rig-control, I get an error that I can only export geometry. Any advice on this? Thx!

    1. Lucas-
      Thanks! You can mask the selection to exclude everything but geo, or you can use a display layer, or if it's neatly tucked away in groups in your rig node you can do it from the outliner, or you could write a lil script to select nothing but the geo under the selected node (which is what I would do. Shouldn't be more than a few lines, just filter through the children of the master ctrl and if it's geo, either select-add it or put it in a list and then select the list once you're done.) With the script you can then re-use it for any rig that you might want to use. Let me know if you need help with that, I've written a bunch of similar things and can dig em up.


  6. hey! great tutorial! is it possible to get the randomize mel scripts you have in the toolbar? and the other useful scripts?