Jump to content

[SOLVED] Blend Shape on Rigged Model


photo

Recommended Posts

Hi,

 

I have some difficulty to play with the setTarget of ObjectMeshSkinned.

I have a Face with one surface and for this surface I have three target :

Surface 0 => man_meshshape

                 => Target 3

                 =>             (0)  man_meshshape

                 =>             (1)  eye_blink_left

                 =>             (2)  eye_blink_right

 

I will be able to close the left eye or the right eye using :

 

// Blink Left

mesh.setTarget(0,1,0,1.0,0);

mesh.setTarget(1,1,0,-k,0);

mesh.setTarget(2,1,1,k,0);

 

// Blink Right

mesh.setTarget(0,1,0,1.0,0);

mesh.setTarget(2,1,0,-k,0);

mesh.setTarget(1,1,2,k,0);

 

But I want blink both eye, I am not sure to understand how I can do that.

 

Any suggestion ?

 

Thank you :)

 

Link to comment

Hi Anthony! :)

 

To blend these animations, you should create 5 morph targets by using the setNumTargets() function.

To clarify this:

1. morph target for "bind pose", when there is no interpolation

2. target for interpolation of the bind pose and the right eye

3. target for interpolation of the bind pose and the left eye

4. target for right eye blinking

5. target for left eye blinking

 

And your code should be the following:

mesh.setTarget(0,1,0,1.0f,0);
mesh.setTarget(1,1,0,-k,0);
mesh.setTarget(2,1,0,-k,0);
mesh.setTarget(3,1,1,k,0);
mesh.setTarget(4,1,2,k,0);

We have a tutorial on Adding morph targets here https://developer.unigine.com/en/docs/1.0/tutorials/morph/

Also, the skinned_07 sample can be useful, it is located in data/samples/objects/skinned_07

 

Hope, it'll help you :)

Don't hesitate to ask, if something isn't clear :)

 

Link to comment

does the morph targets supports more than two blending animiations?

Does the total weight have to be less than or equal to 1? 

we tested a mesh with a lot of different blendshapes (more than 3), but when we enable three blendshapes, it is ok.

However, if we enable four or more blendshapes, the mesh itself will scale based on the total weight.

 

Is this a bug or is there any way we can work around this problem?

Link to comment

ianyyin

 

we tested a mesh with a lot of different blendshapes (more than 3), but when we enable three blendshapes, it is ok.
However, if we enable four or more blendshapes, the mesh itself will scale based on the total weight.

If you can provide us minimal test scene for reproduction it could really help us in investigation and finding the real cause of this behavior. Please, don't hesitate to create a separate thread for it.

 

Thank you!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Hi silent,

 

I checked the manual, it says up to 7 active morph target per surface, so it means only 7 targets could be enabled for one surface? that may be the cause for this behaviour.?

Link to comment

I tested with a standard model, with about 73 blendshapes, and the code is very simple, just like below:

 

If I comment out 

//mesh.setTarget(4,1,0,-k1,0);

//mesh.setTarget(8,1,4,k1,0);

 

It is ok.

 

Otherwise, it will scale based on the total weight for these targets.

 

Also, enable only 7 active targets are not enough for most of the facial animation. A lot of complex facial expressions have more than 7 active morph targets with different weights.

Is there any plan for Unigine to support more targets in one surface?

 

 

 

 
// Calculate weights of targets
float k0 = clamp(sin(i), 0.0f, 1.0f);
float k1 = clamp(cos(i), 0.0f, 1.0f);
 
 
 
mesh.setTarget(0,1,0,1.0f,0);
 
mesh.setTarget(1,1,0,-k0,0);
mesh.setTarget(2,1,0,-k1,0);
mesh.setTarget(3,1,0,-k0,0);
mesh.setTarget(4,1,0,-k1,0);
 
mesh.setTarget(5,1,1,k0,0);
mesh.setTarget(6,1,2,k1,0);
mesh.setTarget(7,1,3,k0,0);
mesh.setTarget(8,1,4,k1,0);
 
 
// Change the argument of sin() and cos() functions
i = i + 0.01;
 

 

Link to comment

Hi! :)

 

 

does the morph targets supports more than two blending animiations?

Does the total weight have to be less than or equal to 1? 

we tested a mesh with a lot of different blendshapes (more than 3), but when we enable three blendshapes, it is ok.

However, if we enable four or more blendshapes, the mesh itself will scale based on the total weight.

 

Is this a bug or is there any way we can work around this problem?

Morph targets support more than two animations blending, as you can see :)

About weights: you should take into account that is used to get expected result (when the weight is equal to 1 that means the end of interpolation). To show you the difference:

post-1513-0-91582500-1426687694_thumb.png

As you can see in the picture above, I've created a blend shape in Maya.

And when I set the range of the weight (0;1) the result will be the following:

post-1513-0-34281500-1426675302_thumb.png

If I set the range (0;5) the result will be:

post-1513-0-56105300-1426675917_thumb.png

It is definitely NOT the blend shape that we created in Maya, right?). The final position of the vertex has been multiplied by 5.

To recap: if you set the weight more than you'll get a result which you didn't create in 3d editor.

 

Go further:

Unfortunately, the max number of active morph targets is 7. They were added in alpha version as demonstration and now we are working on increasing this number (and it surely will be increased). Probably, the large number of morph targets will be available in the next SDK update and for sure in the stable version (soon).

 

About model scaling:

In you code you create more than 7 morph targets, and it seems like "extra" targets have influence on the scale of the model. Don't get upset about this behavior, we will increase the number of morph targets soon. Sorry for inconvenience.

 

If you have the same weights for different blend shapes, you can do the following:

// Set targets with parameters
mesh.setTarget(0,1,0,1.0f,0);

mesh.setTarget(1,1,0,-k0 * 4,0);

mesh.setTarget(2,1,5,k0,0);
mesh.setTarget(3,1,6,k0,0);
mesh.setTarget(4,1,7,k0,0);
mesh.setTarget(5,1,4,k0,0);

As you can see, I multiplied the -k0 weight by 4, because I have 4 targets with the same weight.

 

If you have any question, don't hesitate to ask! :)

 

 

  • Like 1
Link to comment
  • 4 weeks later...

About the number of target do you have more information about the max number in the next SDK ?. 

 

Currently I am doing some lips tracking movement and with 7 Target the result is not accurate at all. At least 14 will be a minimum to have something better but ideally 30 Target will be good.

 

Tony

Link to comment
  • 2 weeks later...
  • 2 months later...

Hello,

 

is there any news on the morph target topic?

 

Our current project needs morphing and we would be more than happy to see this limitation beeing resolved.

 

Thx.
Werner

Link to comment

Hi,

 

Same here, hope to get the limitation issue resolved in the stable 2.0 release, otherwise morphing is useless with the current limitation.

 

Thanks,

Ian

Link to comment
×
×
  • Create New...