Caffeine Abuse - The Blog

Shape blending in ICE using an image sequence

Since you’ll be using ICE to control the blend of the shape keys, make sure there aren’t any shape tracks added to the Animation Mixer and delete the Cluster Shape Combiner operator in the Shape Modeling stack of the object.

Open the scene Blend_Shape_Using_TextureMap.scn. Select the Can object  and from the Get > Property > Texture Map menu choose Texture Map. In the Clip section of the PPG, click the New button and choose New From file from the popup menu. Select the Gradient_Mask.jpg sequence and click OK to load the images. Select the Texture_Projection in the UV Property.

With the Can still selected, press [Alt]+[9] to open an ICE Tree view. From the Create menu choose ICE Tree. Get a Get Data node, open its PPG and enter Self.PointPosition as the Reference. Get another Get Data node, open its PPG and click the Explore button. Expand the Can > Polygon Mesh > Clusters > Can_ShapeKey > Can_ShapeKey branch of the tree and select the positions element. What you want to do is interpolate or blend between the objects current point position and the positions of the shape key. Get a Linear Interpolate node and connect the Value output of Get Self.PointPosition node to its First input.

The shape key does not store the actual point position of the shape,  but the points’ change in position in relation to the initial mesh. To get  the actual positions you need to add the shape to the current point position. Get an Add note and connect the Self.PointPosition to the Value1 input of the Add node and the Get Can.cls.Can_ShapeKey.Can_ShapeKey.positions to the Value2 input. Connect the Result of the Add node to the Second input of the Linear Interpolate node.  Get a Set Data node and enter Self.PointPosition as the Reference in the PPG. Connect the Result output of the Linear Interpolate node to the Self.PointPosition input of the Set Data node. Connect the Set Data node to the Port1 input of the ICETree node.

The blend value of the Liner Interpolation node controls how much influence each of 2 input values will have. A value of 0 means the second value of the Linear Interpolation node will have 0 affect which results in the first value having full affect. With the blend value set to 1, the opposite is true and the second input will have full affect and the first input 0. Instead of setting the blend value for the entire mesh at once, you can set  it per point based on the RGB value of an image sequence. Get a Get Point Texture Map Color node and a Color to Brightness node.  The Color to Brightness node converts the RGB value of the image to a scalar value which in can then be used to control the blending of the Linear Interpolation. Connect the Value output of the Get Point Texture Map Color node to the Color input of the Color to Brightness node. Connect the Brightness output of the Color to Brightness node to the Blend input of the Linear Interpolate node.

The project files used in this tutorial can be found at:  http://dl.dropbox.com/u/3834689/CaffeineAbuse/ShapeBlendingWithICE.zip

ICE_ShapeBlend_img02

While you typically want to set the blend value between zero and one, you can use values above 1 to amplify the affect or negative values to inverse it.

Quick tip
If you want to blend between more than 2 shapes you can use the Blend node instead. Note that the blend node will output the weighted sum of all the inputs, so if you increase the weight of one input you’ll need to equally decrease the weight of the other inputs to avoid double transformation.