Can I use a ramp to control a blendShape weight??


#1

I´ve noticed that there´s the possibility to attach a texture to control the weight of a blendShape. Graphing the connection I figured out the outAlpha from the ramp (in this case)… is connected and controlling the blendShape. but it only woks when I change the color of the first ramp position.

What I would like to achieve is a non linear blendshape where the darker areas of my ramp would mean not blendshaping and the lighter full blendshaping and the gray anythinh in between.

Is that possible using NO plugins??


#2

I’m pretty sure you’ll need a plugin for that (SOuP maybe?)

But, you can paint blendshape weights, and those painted weights can be animated, and you can import weights from a file Texture, so in a round about way you could achieve some non-linear blend animation. I’ve done it this way before. Its not very flexible though.

David


#3

Hmmm…
I’ve been trying to find the thread that had this info in order to give credit where its due…I tried it out a while back…and it works…but it was a bit slow for me.

Here is an example that shows how to create a blendshape that deforms according to an animated ramp.

Create two polySpheres, deform one, and then create a blendshape
On the base pSphere, attach a Ramp to its shader color
Select the base pSphere and open the expression editor, enter this expression:

int $sizes[] = `polyEvaluate -v BaseBlendShapeNAME`;
 for ($i = 0; $i < $sizes[0] ; $i++)
 {
     float $ptPos[] = `pointPosition BaseBlendShapeNAME.vtx[$i]`;
     float $pos[] = `nearestPointOnMesh  -ip $ptPos[0] $ptPos[1] $ptPos[2] -q -parameterU -parameterV BaseBlendShapeNAME`;    
     float $col[] = `colorAtPoint -o RGB -u $pos[0] -v $pos[1] rampNAME`;
     setAttr blendShape1.it[0].itg[0].tw[$i] $col[0];
 }

BaseBlendShapeNAME is the name of the object that is deformed.
rampNAME is the name of the Ramp that controls the deformation.
blendShape1 is the name of the blendShape node.
The R value of the ramp controls the deformation of the base shape into the blendShape.


#4

Nice one Benjamin. :thumbsup:
I’m playing with it now. Not what you’d call a realtime deformer, but its working. No need to hook up the ramp to your shader either. And seems to be working just as well with a fileTexture.
I have not tried rendering yet, but looking pretty useful so far.

David


#5

here is a little mel-snippet , that i made yesterday , when reading djx’ mentioning , the possibility of setting keys on the blendshape-weights

so this was tested on a sphere with 20x20 - so it iterates through all the 381-weights of the “blendshape1”-node . inputTarget[0] would be the first shape in the blendshape-node … maybe one could create a simple script , in order to simply be able to setKeys on the active blendshape-weights , this way , in order to animate them easily … and it should not be too difficult to achieve :slight_smile:

for ( $i=0;$i<=381;$i++) {

 $actualVal = `getAttr ("blendShape1.inputTarget[0].baseWeights["+$i+"]")`;

 setKeyframe -t 10 -v $actualVal -at ("inputTarget[0].baseWeights["+$i+"]") blendShape1;

 }

you could also set DrivenKeys in order to use a custom-attribute to animate the weights … but welll , ok , it might not be very fast - once you would try to animate lots of blendshapes , with a highpoly-count that way … i guess one would need a special plugin then .

trying the other mel now :wink:


#6

Thanks for the reply Benjamin…

…as you said, a bit slow but it´s definitely working! Thanks again!!


#7

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.