Profile Picture

exporting morphs

Posted By Ellessarr 6 Years Ago
Rated 5 stars based on 2 votes.
1
2
3
4
5

Author
Message
creationsmaxo
creationsmaxo
Posted 4 Years Ago
View Quick Profile
New Member

New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)New Member (3 reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 1, Visits: 16
While exporting morph could greatly help many devs fast-forwarding in the development of their game(s) project(s), I got to point out that there are also a TON of possible ways of handling morphs which, in most cases, also means the morph can't be just "made and done" universally. Because of that, the current "best" way of handling morphs is to use CC3 (or iClone) as a base, then modify the pre-result through a 3D software like blender, Maya or 3Ds Max (yeah yeah, I know).

For example, you don't morph the whole body in any game engine as that's simply a huge waste of CPU over the Vector3 calculation prior to the rendering pipeline (done through the GPU). You usually use a mix of in-engine mesh manipulation (cloth for example) with an armature-based rig (bones) with "some" parts done done with a morph (face). Obviously, there are exceptions, but that's the general way of handling it. You usually try to minimize the morphed area to as few vertex as possible because the cost of a morphed vertex is at least 3x bigger than that of a skinned vertex (make it 4x if it's a skinned + morphed vertex). Bones are still highly used for anything "repetitive" and general.

To make it work, you got to think of thinks as tools and steps and not just whole-solutions. Having some knowledge in using mesh data in the game engine is also an HUGE plus.
In my case, I use CC3 initially for building 4 version of a character (per gender) with 1 single base (same amount and IDs in the vertex), rig only one of those (no morph yet) in Blender, export the 3 non-rigged + 1 rigged into Unity.
In Unity, I generate each character as a brand new skinned mesh, by generating the same vertex values (vertex position, triangles order, UVs, etc.) as each of the 4 variances, but by multiplying the value based on a Vector2(x,y) where X is the value between variance A and B, and y is between C and D. Then, I apply the same weight values as I registered one of the 4 variance on each vertex by their Vertex IDs. (Remember, each of the 4 variances used the same base, meaning they got the same vertex in the same order as well as the same UVs, but just placed differently in their vertex positions.)

This allow an quite simple flow and same you a LOT on performances when it comes on creating character as you don't really have a skinned + morph mesh, but just a skinned mesh generate morphed purely once via script.

What about morph movements then like some lips-sync? You can use a old-fashioned bone-based mouth animation or... generate your own blend shapes!
With unity, you can add new blend shapes Link to the Unity Document about adding Blendshapes.

To add a blend shape, use the code shown in the link above twice with the same (yet unique) string name (called shapeName in the link's declaration above).
The weight is basically where, on a 0-100% value, the blend shape is located where so, yeah, you can add multiple "shapes" in line. (It has to be added in the proper order, so you can't add a blend shape at 25% if you added on at 50%.
You can literally take the each of the "blendshape" source (which are regular mesh) and feed their data to the AddBlendShapeFrame() call.

I know I make it sound simple, but it's not necessary that simple. To add proper blend shapes through script on a pre-morphed-now-regular-skinned-mesh, you got to take into account the morphed mesh, hence you have to generate the same morphed data (like mouth animation) for each of the variances, then as you add the blend shape, you got to multiply the value by each of the variants the same way as the regular non-blend-shapped way explained above. At the same time, using this method can be used for specific characters who needs it and avoid the waste on characters that don't need a proper morph.
In my explanation above about having 4 variants, I'm usually using that for having A and B as age-variance of a skinny version while C and D are the muscular version of the same age-variance.
mark.jsday
mark.jsday
Posted 4 Years Ago
View Quick Profile
New Member

New Member (43 reputation)New Member (43 reputation)New Member (43 reputation)New Member (43 reputation)New Member (43 reputation)New Member (43 reputation)New Member (43 reputation)New Member (43 reputation)New Member (43 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 10, Visits: 79
I agree exporting of blendshapes/morphs is a vital part of character creation in a game.

I was able with a basic script able to take morphs from CC3 into Unity without any issue.

CC3 Steps
1.  Choose a base character  e.g. cc3 female base
2.  Reset the morphs to ensure all are default
3.  Export out a clean base character (fbx) to unity folder  e.g. cc3_base.fbx
4.  Dial in a morph e.g. abdomen to 100
5.  Export out a base character (fbx) to unity folder e.g. cc3_base_abdomen_100.fbx

Unity Steps
1.  Create an empty game object and reset its transform (e.g. call it blendshapes)
2.  Attach the following component script to it
3.  Assign the body mesh from the Base character to the source property
4.  Assign the body mesh from the Base_Abdomen_100 to the target property
5.  Play 

Notes

This works with morphs that don't resize the character in height.
To achieve morphs that change the height you will have to do something
like
a.  Calc delta pos of the base bone positions and the morph bone positions
b.   In the LateUpdate()
      {
          Calculate new bone positions from blendshape weights
          Calculate bind poses for new bone positions
          Create new mesh
          Assign bind poses to the new mesh
          Assign new mesh to character shared mesh
          Update the animator
      }

Make sure on import of the fbx to unity to set Read/Write in import settings.


Result
You will notice that the blendshape on the base character skinned mesh renderer will show the blendshape "test" with the slider working

Hope it helps
Mark


using UnityEngine;public class BlendShape : MonoBehaviour{    public SkinnedMeshRenderer source;    public SkinnedMeshRenderer target;    // Start is called before the first frame update    void Start()    {        Vector3[] verts = new Vector3[target.sharedMesh.vertexCount];        source.sharedMesh.ClearBlendShapes();        target.sharedMesh.ClearBlendShapes();        // Calculate delta verts from source to target        for (int i = 0; i < verts.Length; i++)            verts[i] = target.sharedMesh.vertices[i] - source.sharedMesh.vertices[i];        source.sharedMesh.AddBlendShapeFrame("test", 1, verts, null, null);        source.sharedMesh.RecalculateNormals();        source.sharedMesh.RecalculateTangents();    }}
SeanPollman
SeanPollman
Posted 4 Years Ago
View Quick Profile
Senior Member

Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 31, Visits: 129
joao.henriques (4/27/2021)
There is no tutorial since its not possible to achieve with real illusion software. If you need this kind of basic features you will need a different pipeline. 


This is actually not true, it is possible, I've done it, it's just unreasonably tedious. about 20 actoions per morph, and required 3d software like blender to remerge them all, the end result isnt even something that can be considered a reallusion basemesh, but has near-identical morphs. 
joao.henriques
joao.henriques
Posted 4 Years Ago
View Quick Profile
Senior Member

Senior Member (474 reputation)Senior Member (474 reputation)Senior Member (474 reputation)Senior Member (474 reputation)Senior Member (474 reputation)Senior Member (474 reputation)Senior Member (474 reputation)Senior Member (474 reputation)Senior Member (474 reputation)

Group: Forum Members
Last Active: 4 Months Ago
Posts: 31, Visits: 1.7K
There is no tutorial since its not possible to achieve with real illusion software. If you need this kind of basic features you will need a different pipeline. 
amazinde
amazinde
Posted 4 Years Ago
View Quick Profile
Senior Member

Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)

Group: Forum Members
Last Active: 2 Years Ago
Posts: 16, Visits: 67
Is there a tutorial on how to do it? I can't find anything and I need this Bad!
amazinde
amazinde
Posted 4 Years Ago
View Quick Profile
Senior Member

Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)Senior Member (385 reputation)

Group: Forum Members
Last Active: 2 Years Ago
Posts: 16, Visits: 67
I am having a hard time with this process, is there a tutorial on how to do this?
SeanPollman
SeanPollman
Posted 4 Years Ago
View Quick Profile
Senior Member

Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)Senior Member (352 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 31, Visits: 129
der_kenshin (2/9/2021)
Hi everybody
It's already an older post but here I found a workaround to get them into the engine.

https://forum.reallusion.com/472137/WIP-Custom-Morph-Tool-morphing-during-runtime

Greetz

Neat, do you plan to let us know how? it would be quite useful, and hopefully not terribly tedious. 
der_kenshin
der_kenshin
Posted 4 Years Ago
View Quick Profile
Senior Member

Senior Member (387 reputation)Senior Member (387 reputation)Senior Member (387 reputation)Senior Member (387 reputation)Senior Member (387 reputation)Senior Member (387 reputation)Senior Member (387 reputation)Senior Member (387 reputation)Senior Member (387 reputation)

Group: Forum Members
Last Active: 2 Years Ago
Posts: 9, Visits: 116
Hi everybody
It's already an older post but here I found a workaround to get them into the engine.

https://forum.reallusion.com/472137/WIP-Custom-Morph-Tool-morphing-during-runtime

Greetz
garrettg11
garrettg11
Posted 5 Years Ago
View Quick Profile
Veteran Member

Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)

Group: Forum Members
Last Active: 2 Years Ago
Posts: 39, Visits: 560
Also, one of the comments on the video was:

"But this is only good for facial morphs not body morphs. So if i wanted to use corrective morph shapes for like elbow and other joints since CC3 doesn't seem to do a good at skinning weights, therefore when arms bend they look rubbery not realistic. Is there a way to get around this, or would we have to re paint skin weights in a separate DCC?"


This is descriptive of a significant problem with CC3+ figures in Unity that I have observed and am not happy about, which, it would be SUPER if there was something to deal with that.
garrettg11
garrettg11
Posted 5 Years Ago
View Quick Profile
Veteran Member

Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)Veteran Member (640 reputation)

Group: Forum Members
Last Active: 2 Years Ago
Posts: 39, Visits: 560
Well I took some time to try her tutorial steps https://www.youtube.com/watch?v=nZXQs2TVDE4

It doesn't work. But I could not even take the steps as far as Unity, since the morph slider steps gave me a slider that instead of applying the face expression I had setup it shrinks the whole body in a strange way which I found while testing it in cc3. And there is no point to try to test that in unity.

Also on the tutorial video there are many comments about it not working or various alternate steps but more saying it doesn't work. Or that they take it all the way to unity and the morph doesn't work there also.

I also tried some alternate paths by following the CC3 manual and creating a saved iavatar first to use in these steps:
https://manual.reallusion.com/Character_Creator_3/ENU/3/Content/Character_Creator_3/3/06_Customizing_Morphing_Sliders/Morphing_Current_Character.htm
That flow produced a slider that had no effect.

So, unfortunately I don't have all day to experiment and guess as to what the work around should be if there is one. Maybe RL can produce a proper tutorial and check for bugs in their app?


1
2
3
4
5



Reading This Topic