MikeRhone
06-29-2010, 11:35 AM
I posted this on my webpage and figured I should probably copy it over to the forums here as well. This was brought up at work the other day, and it seems there is still not an easy solution to control a blendshape via animated textures. I know there are scripts out there that hack it, you could be very sneaky and slow via a scriptjob, or you could delve into the world of softbodies like I do.
Backstory: Back in the day I heard about a cool plugin they wrote to do 'The Mystique Effect' on Xmen 1. The guys at Kolektiv (http://www.kolektiv.com/) released that tool called the samplerDeformer (http://www.youtube.com/watch?v=opmLasBCbaE) in a bundle of plugins called Stroika (Enjoy the free advertizing, guys.) Purchasing and using plugins is not an option for everyone, so I wanted to figure out a way to do it using off-the-shelf Maya. What I came up with was taken from what I know in Maya particles.
Demo scene file located at bottom of page (http://mikerhone.com/tips-for-vfx/66-controlling-blendshapes-with-particles-and-fields.html)
A sneaky trick that I LOVE to use with particles is querying the inputForce of a field as it is applied to particles. Maya's interaction from fields to particles is incredibly simple, but I wont bore you with that right now. All you need to know is this: Any time you connect a field to a particle system, it adds a new perParticle attibute called inputForce[n], where n is the indice of the field. For example:
Create a particle system. Apply a uniform field, a radial field and a turbulence field to the particle system. Every time one of those fields are connected, a new perParticle attribute gets created. In this case:
uniformField1 = inputForce[0]
radialField1 = inputForce[1]
turbulenceFiled1 = inputForce[2]
Make sense?
While this is usually an internal connection only used by the particle systems to transfer vectors from the fields, we can query that information and use it to control any other per particle attributes we want. In this case, we will use a uniform field to control the goal weights of a softbody to 2 goal objects. (IE: Our softBody blend targets)
To replicate the demo scene:
Create a sphere. Name it softBall. Duplicate it and move it off to the side. Name this goal0. Duplicate goal0. Make some changes to goal0 and goal1's shape so you can see the different blendshapes when its working. Select softBall. Go into the Soft/Rigid bodies menu --> Create soft body --> Options. Set the creation options to Make Soft. (You dont want to duplicate or make targets yet). Click create. Select softBallParticle. Shift-select goal0. Go into Particles-->Goal(Options) set weight to 1. Click create. Select softBallParticle. Shift-select goal1. Go into Particles-->Goal(Options) set weight to 1. Click create.
Whew.
Awesome. If you click the play button in the timeline you should see the particles bounce to exactly in the middle of your 2 targets. (Just like a blendShape set to .5) Set the particles conserve to be 0. (This will help make the blends ease in instead of bouncing around) Now that this is done, go into the attribute editor for softBallparticleShape. Under Add Dynamic attributes click on General. In there click on the particle tab, highlight goalWeight0PP and goalWeight1PP. Click ok. You now have access to the particles individual weighting.
Select the softBallparticle node and create a uniform field. Name it inForce0_UNIFORM. On the uniform, set
Magnitude to .001
Attentuation to 0
Volume shape to 'cube'
Direction to X = 0, Y = 1, Z = 0
Scale it up so all of the geometry is inside it. When this uniform field was created, maya automatically linked it up with the particles, and added the attribute inputForce[0] to the particles attribute list.
In the softBallparticleShape, right click on the text area to the right of 'Goal Weight 1 PP1' and choose Creation Expression. Type this:
softBallParticleShape.goalWeight0PP = 0;
softBallParticleShape.goalWeight1PP = 1;
Click Create.
Now click on the radio box that says 'Runtime after dynamics', and type this:
$inf = mag(softBallParticleShape.inputForce[0]) * 1;
if ($inf >=.0001)
{
softBallParticleShape.goalWeight0PP = clamp(0,1,(softBallParticleShape.goalWeight0PP + .1));
softBallParticleShape.goalWeight1PP = clamp(0,1,(1 - softBallParticleShape.goalWeight0PP));
}
else
{
softBallParticleShape.goalWeight0PP = clamp(0,1,(softBallParticleShape.goalWeight0PP - .1));
softBallParticleShape.goalWeight1PP = clamp(0,1,(1 - softBallParticleShape.goalWeight0PP));
}
Now click Create.
That should be about it! Keyframe the uniform field so it moves through where the soft particles are and you should see it slowly morph from one target to the other, depending on wether or not the particles are inside or outside of the uniform field..
Demo scene file located at bottom of page (http://mikerhone.com/tips-for-vfx/66-controlling-blendshapes-with-particles-and-fields.html)
Backstory: Back in the day I heard about a cool plugin they wrote to do 'The Mystique Effect' on Xmen 1. The guys at Kolektiv (http://www.kolektiv.com/) released that tool called the samplerDeformer (http://www.youtube.com/watch?v=opmLasBCbaE) in a bundle of plugins called Stroika (Enjoy the free advertizing, guys.) Purchasing and using plugins is not an option for everyone, so I wanted to figure out a way to do it using off-the-shelf Maya. What I came up with was taken from what I know in Maya particles.
Demo scene file located at bottom of page (http://mikerhone.com/tips-for-vfx/66-controlling-blendshapes-with-particles-and-fields.html)
A sneaky trick that I LOVE to use with particles is querying the inputForce of a field as it is applied to particles. Maya's interaction from fields to particles is incredibly simple, but I wont bore you with that right now. All you need to know is this: Any time you connect a field to a particle system, it adds a new perParticle attibute called inputForce[n], where n is the indice of the field. For example:
Create a particle system. Apply a uniform field, a radial field and a turbulence field to the particle system. Every time one of those fields are connected, a new perParticle attribute gets created. In this case:
uniformField1 = inputForce[0]
radialField1 = inputForce[1]
turbulenceFiled1 = inputForce[2]
Make sense?
While this is usually an internal connection only used by the particle systems to transfer vectors from the fields, we can query that information and use it to control any other per particle attributes we want. In this case, we will use a uniform field to control the goal weights of a softbody to 2 goal objects. (IE: Our softBody blend targets)
To replicate the demo scene:
Create a sphere. Name it softBall. Duplicate it and move it off to the side. Name this goal0. Duplicate goal0. Make some changes to goal0 and goal1's shape so you can see the different blendshapes when its working. Select softBall. Go into the Soft/Rigid bodies menu --> Create soft body --> Options. Set the creation options to Make Soft. (You dont want to duplicate or make targets yet). Click create. Select softBallParticle. Shift-select goal0. Go into Particles-->Goal(Options) set weight to 1. Click create. Select softBallParticle. Shift-select goal1. Go into Particles-->Goal(Options) set weight to 1. Click create.
Whew.
Awesome. If you click the play button in the timeline you should see the particles bounce to exactly in the middle of your 2 targets. (Just like a blendShape set to .5) Set the particles conserve to be 0. (This will help make the blends ease in instead of bouncing around) Now that this is done, go into the attribute editor for softBallparticleShape. Under Add Dynamic attributes click on General. In there click on the particle tab, highlight goalWeight0PP and goalWeight1PP. Click ok. You now have access to the particles individual weighting.
Select the softBallparticle node and create a uniform field. Name it inForce0_UNIFORM. On the uniform, set
Magnitude to .001
Attentuation to 0
Volume shape to 'cube'
Direction to X = 0, Y = 1, Z = 0
Scale it up so all of the geometry is inside it. When this uniform field was created, maya automatically linked it up with the particles, and added the attribute inputForce[0] to the particles attribute list.
In the softBallparticleShape, right click on the text area to the right of 'Goal Weight 1 PP1' and choose Creation Expression. Type this:
softBallParticleShape.goalWeight0PP = 0;
softBallParticleShape.goalWeight1PP = 1;
Click Create.
Now click on the radio box that says 'Runtime after dynamics', and type this:
$inf = mag(softBallParticleShape.inputForce[0]) * 1;
if ($inf >=.0001)
{
softBallParticleShape.goalWeight0PP = clamp(0,1,(softBallParticleShape.goalWeight0PP + .1));
softBallParticleShape.goalWeight1PP = clamp(0,1,(1 - softBallParticleShape.goalWeight0PP));
}
else
{
softBallParticleShape.goalWeight0PP = clamp(0,1,(softBallParticleShape.goalWeight0PP - .1));
softBallParticleShape.goalWeight1PP = clamp(0,1,(1 - softBallParticleShape.goalWeight0PP));
}
Now click Create.
That should be about it! Keyframe the uniform field so it moves through where the soft particles are and you should see it slowly morph from one target to the other, depending on wether or not the particles are inside or outside of the uniform field..
Demo scene file located at bottom of page (http://mikerhone.com/tips-for-vfx/66-controlling-blendshapes-with-particles-and-fields.html)
