Saturday 4 February 2012

Correctional blendshapes

I always had nightmares creating correctional blendshapes for rigs, having to work on the duplicated default mesh whilst watching the result mesh update (still trying to get over how I ever did this on a single 15" monitor...),
and then I found out how blendshape weights aren't limited from 0 to 1... and less than 0.

Now creating correctional blendshapes is far more enjoyable and takes up much less time, using a very simple setup.

Its actually very basic math (the way I see it anyways)
a + b = c
which therefore means...
b = c - a
so if "a" was a pose, "b" was its correction, and "c" the result of both. Now if you take the pose away from the result, your left with... the correction!

Corrective blendshape wise, you need to put your character into its pose you want to correct,

duplicate the mesh and create the correction ("b"),

duplicate the mesh orginal mesh off again (to get "a")

Then you duplicate the mesh with no deformations on it (as you would creating a normal blendshape), and assign the pose mesh and the corrective mesh ("a" + "b"). You finally want to turn on the correction blend weight to 1, and the pose blend weight to -1.

Your then left with just the correction, which you duplicate off and apply as a corrective blendshape target for you character.

This can be taken so much further to do live pose updates (above is all automated), but I wont go into that yet.

I hope this helps!

7 comments:

  1. I'd argue that your math is slightly off on this one. If you put corrective shapes in the start of deformation chain (blendshape before skinCluster), the equation actually is

    (a+b)*pose_space=c

    which makes

    b = c*inverse_pose_space - a

    The little error can already be seen in your corrective shape screen, where vertices aren't pushing horizontaly away to create a bulge, but are instead shifted down slightly.
    This subtlety is even more important when trying to perfectly hit sculpted corrective shape, especially when your pose space is not only simple joint transform, but also geometric influences and post-skin cluster relax.

    ReplyDelete
    Replies
    1. Ahhh I completely see what you mean there, cheers Viktoras, my mistake.
      How would you go about getting the pose space? Would I feed the mesh info from the end of the chain into the resulting blendshape to create the corrective?

      Delete
    2. The only way that worked for me universally (that is, using any pose-space deformation after blend shape) was "blind guessing" script. You give it:

      1. mesh to edit (blend target);
      2. mesh to look at what happens when blend target is edited (posed rig mesh);
      3. expected result mesh (posed and sculpted mesh).

      then script iteratively makes minor edits to mesh #1 and checks if mesh #2 got any closer to #3, until each vertex meets precision requirements.

      Delete
    3. gotcha.
      So couldn't you apply the "slightly wrong blendshape" (from above a+b=c), and compare resulting meshData to the posed blendshape and re-apply the difference between them to the posed blendshape?

      Delete
  2. Hello Lee and uiron,
    you can use simple matrix math to extract corrective shapes :
    This what chad vernon is doing with its cvShapeInverter ( http://www.chadvernon.com/blog/resources/cvshapeinverter/ )
    "
    #LINE 64 in the __init__.py file
    for i in range(numPoints):
    xPoints[i].x += 1.0
    yPoints[i].y += 1.0
    zPoints[i].z += 1.0

    "
    he builds a matrix then invert it to transform the delta vector into the shape local space.

    I also talk about this on my blog: things are more easy when the shape is deformed by a skinCluster: --Corrective shape extraction from the inverse transformation of a skincluster -- at
    http://circecharacterworks.wordpress.com/2011/03/26/presentation/

    cedric,
    http://circecharacterworks.wordpress.com/

    ReplyDelete
  3. hey cedric, thats great! thanks!
    I still haven't had a spare moment to have a play with this, but it makes sense.
    Some really nice, detailed information on your blog too, really brought a couple of things to light!
    Cheers again!

    ReplyDelete