Search Unity

Blender, MetaMorph, Unity and Shape Keys revisited

Discussion in 'Asset Importing & Exporting' started by gryff, Mar 24, 2013.

  1. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    After several attempts at using the foolish frost's Metamorph scripts, thanks to an example file that Desimus sent me, I have Metamorph and Blender shape keys working.

    I am using the version of the Diff Map exporter that was created by parker for Blender 2.6. LINK

    I have tested the parker script in Blender 2.63 and above - and it does not work. According to Jonathan Williamson @ cgcookie.com, with the introduction of BMesh in Blender 2.63 the were changes made to the shape key functionality which is probably why the scripts fail in these later versions. However, the script works fine in Blender 2.61 and here is a demo video:

    Blender 2.61, Metamorph, Unity 4.0 and Shape Keys/Morphs

    Ty to foolish frost, parker and Desimus

    cheers,

    gryff :)
     
  2. Univia

    Univia

    Joined:
    Feb 9, 2013
    Posts:
    10
    Great vid and congrats. Can you please tell simply the workflow because I'm getting invalid filepath error messages and first try ended blender not responding.
     
  3. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    Couple of questions:

    1. What operating system are you using? There is a known issue of this type with a Mac OS. See this LINK Scroll down to the middleman post (and to see fixes)

    2. What version of Blender are you using? The script in the asset store works with Blender 2.58. parker's script - link in my first post - works with Blender 2.60, 2.61.

    You have to get the right script with the right Blender version.

    cheers,

    gryff :)
     
  4. Univia

    Univia

    Joined:
    Feb 9, 2013
    Posts:
    10
    I'm using win 7 and blender 2.61 with the parker script. First it seemed to do something when importing, then after minute or so blender stopped responding, but it didn't crash so I thought it worked, but it didn't. After that it started to give wrong filepath error, and that's why it would help a lot to know what you do in blender so that it works, because I'm following Metamorph instructions and can't get results.
     
  5. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    Hi Univia. I will layout my set up for the script on my PC - which is very basic.

    a.) An Intel I5 running windows XP
    b.) Blender 2.61.0 r42615 - the 32bit version which I downloaded as a zip file - NOT the executable
    c.) the "parker" version of Metamorph script for Blender 2.6

    Installation of Blender and the Diff_Map script - see images screen_capture 1 and 2

    1.) I created a directory on my D drive called Blender 2.61
    2.) Unzipped the Blender files to that directory
    3.) Unzipped the parker file on my external HD and copy and pasted the "io_export_diffmap.py" file to the "scripts/addons" directory of Blender 2.61

    Activating the Diff_Map script:

    1.) Started Blender 2.61 and opened the User Preferences window from the Blender File menu. Under Addons/Import-Export found the addon and put a check mark in box, then clicked the button "Save As Default.

    I did NOT use the Install Addon Button to install the Diff_Map addon

    So, possible differences:

    1.) I'm using Windows XP.
    2.) I'm running the 32bit version of Blender 2.61 that was installed manually (from the zip file)
    3.) The addon was installed manually - no use of Blender's install code.

    I have just repeated the above with Blender 2.62.0 r44162 which I have just downloaded from the Blender archives. Ran a test with my male figure - worked fine with Blender 2.62.

    screen_capture1

    screen_capture2

    Hope that helps

    cheers,

    gryff :)
     
  6. Univia

    Univia

    Joined:
    Feb 9, 2013
    Posts:
    10
    Hi gryff and thank you x 3 for the help, I had also the...

    a. zipped 2.61 blender with parker's script and
    b.installed the addons by checking the boxes and saving as default, and
    c. Intel I5 running windows 7

    I tried also the 2.58 blender but couln't get the mhx importer to enable the mhx lip sync tool which I need to use with papagayo. Now I installed the blender 2.61 exe version and got the same wrong filepath error, so may be the reason is different OS versions or what I do in blender which is;

    1. import the makehuman mhx model
    2. load the papagayo moho .dat
    3. select the model to go object mode, and
    4. export the diffmaps and animations
    5. in the Export Diff v.1.1.2 dialog I use default settings, and give the same name to the file that is in the Export Diff v.1.1.2 settings

    2 pictures, inside blender and export
    http://www.use.com/0bfcda032f94d974c71b

    I wish I could use Tagarela, but for some reason it keeps asking to assign an audio which I already have assigned, and I never get to the editor.
     
  7. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    Univia, can you post your file you are trying to animate somewhere - so I can try the export and checkout your settings?

    cheers,

    gryff :)
     
  8. Univia

    Univia

    Joined:
    Feb 9, 2013
    Posts:
    10
  9. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    Wow!

    Couple of initial thoughts

    1. Your model has ~14600 verts my human male has ~7900 verts
    2. Your model has ~64 shape keys my human was done with just one shape key (+ the Basis key which does not get exported)
    3. When I export the shape key from my model, it takes over 2 minutes to create that one tga file and the animation text file

    So you have almost twice the vertices and 64 shape keys - it would take well over two hours on my PC to create all the .tga files for your liz model.

    Are you pushing Blender/Metamorph into some extreme case ?

    Will be back with more later tonight or tomorrow. Just need to find a simple blend file that I used for experimentation so that you can try using it to export from.

    cheers,

    gryff :)
     
  10. Univia

    Univia

    Joined:
    Feb 9, 2013
    Posts:
    10
    It was just for testing purposes for the lipsync and for the game I would reduce the polycount. I need some sort of lipsync to have conversations similar to Unreal II: The awakening
    http://www.youtube.com/watch?v=9dJjdkiYZW4

    and then try to figure out how to do it in unity, may be with RAIN indie, and or trying to learn some scripting why I'm reading java for dummies and watching those Learn scripting videos.

    I just added decimate modifier and reduced the animation to 5 frames, but got the same wrong filepath message again. I noticed earlier in the zipped blender 2.61 that it had in the object data panel vertex color map too but it didn't work then either. Great if you can upload some of your file for testing, cya.
     
  11. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    I think that is very doable Univia. You don't need 64 shape keys for that kind of lipsyncing.

    I have found my test blend file - I will package it up with the DiffMaps I get, the fbx file for Unity and the animation script I use in Unity V4. Will post it tomorrow.

    cheers,

    gryff :)
     
  12. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    Univia, as promised earlier in the thread here is a simple head model set of files. It includes:

    1. The blend file saved from Blender 2.61.
    2. The exported .fbx file (Blender 2.61)
    3. The two exported DiffMaps for the two shape keys and the animation .txt file (Blender 2.61)
    4. The two scripts I used to animate the mouth - Metamorph and humanshapekey (which triggers the animation)
    5. A .psd image that shows the settings for the two scripts on the imported .fbx file

    The animation is run in Unity 4. Blender and the "parker" script for DiffMap export from Blender were installed as described above on a PC running Windows XP.

    By a simple mixing of two mouth keys one can simulate a number of phonemes. A few more shape keys can be added - blinking, smiling, raising an eyebrow to give some more animation to the face.

    http://dl.dropbox.com/u/70260871/metamorph_demo_files.zip

    The "parker" script does not work in Blender 2.63 and above

    cheers,

    gryff :)
     
  13. Univia

    Univia

    Joined:
    Feb 9, 2013
    Posts:
    10
    Thank you again gryff, I am now playing with the file and noticed you had two uv maps in the object data tab uvmap box, UVMapp and DiffMap, whereas I had only UVTex, and in the DiffMap exporter there is UVTex and Shapekey, but then again it's a different version of the exporter and has Export shapekeys and Export animations checkboxs, but no matter what I do I get the invalid filepath error so i have to fix that somehow before I can proceed. I'll try your head in unity asap.
     
  14. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    The two UV maps are to try and improve the accuracy and and resolution of the DiffMap texture. Take the whole humanoid I used in the video - only some vertices are influenced by the shape keys (those on the face).. There is no need to give lots of space to vertices that are not being moved. Here are the maps for the model I used in the video:

    First the DiffMap: http://dl.dropbox.com/u/70260871/DiffMap.png

    The Full Body Texture: http://dl.dropbox.com/u/70260871/UVMap_texture.png

    In the DiffMap most of the body, which does not move using Shape keys, is downsized and tucked in the corner, the face vertices take up most of the map.


    Not sure what you mean by that. For Blender 2.61 use the parker version of the exporter script:

    http://dl.dropbox.com/u/8451123/io_export_diffmap.py

    For Blender 2.58 use the foolish frost version of the script available at the asset store otherwise you will get that path error.

    I would be inclined to reinstall both Blender 2.61 and the parker script as I outlined above.

    cheers,

    gryff :)
     
  15. Univia

    Univia

    Joined:
    Feb 9, 2013
    Posts:
    10
    Ooh I'm sorry, I was reading MetaMorph manual while writing that and forgot to mention that the Exporter in the image is different version.
    http://rezzable.com/metamorph/manuals/blender-diffmaps

    So I am using Blender 2.61 and the parker script, but it didn't work for me for some reason with zipped or installable version of blender 2.61, and that I have to solve somehow or try to get the Tagarela to work. Cheers.
     
  16. Univia

    Univia

    Joined:
    Feb 9, 2013
    Posts:
    10
    Phew, I finally got your head demo set up in unity and it's working, but the animation is distorted probably because i resized the head in the editor because it was so small, and later realized to make it bigger in import settings, and then I had to make it smaller again and it may have affected the animation, just quessing. I still haven't figured out why I can't get the exporter working but I'm sure I'll find a way;)
     
  17. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    Well I'm glad the parts worked in Unity.

    I build stuff in blender using blender units. When you import the fbx you have to set the "scale factor" to 1. A standard default cube in blender is 2 blender units and when exported to Unity is correct when compared to the Unity cube .

    Also, I'm using Unity 4 . No idea what the impact of scaling in the Transform properties would be - but those vertices are very close together around the mouth, which is another reason I use second DiffMap for the face face vertices then are taking up most of the UVs as they are the ones in motion for the shape keys

    One other thought on the DiffMap export, if it is a Windows 7 issue, can you not run Blender in a "Windows XP mode"

    cheers,

    gryff :)
     
  18. Univia

    Univia

    Joined:
    Feb 9, 2013
    Posts:
    10
    That didn't even cross my mind until you told me but no, it didn't work with xp sp2 or sp3 compatibility mode, so it's still a bit of a mystery to me why it won't run. Let us not fall in despair:-D. Maybe a few hours rest is in place for me now. Happy easter gryff:D
     
  19. legendre

    legendre

    Joined:
    Mar 18, 2013
    Posts:
    2
    Hi,
    I hope you can help me. Having tried metamorph with Blender versions from 2.49 to 2.66a, you have no idea how delighted I was when I came across this trail. Well, I now seem to be at the point that Univia reported "invalid file path". I would like to test this with your demo files but I cannot access the files. Do you think you can make your demo files available again please. Many thanks!!!
    I'm using Win 7, 64. Blender 2.61 (exe installation), metamorph Blender plugin (installed add-on).
    $metamorph_exportdiff.JPG
     
  20. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    Hi legendre - will be glad to help.

    The files are still in my dropbox and at the dropbox website - so I do not know why you can not access them. So please try again.

    If it still does not work, send me a private notification with an email address that you use - and I will send them that way.

    A few things I should point out -
    1. I use Windows XP,
    2. I do NOT use the executable version of Blender but rather the zip file installations -allows me to easily install multiple versions of Blender - and of course the 32bit version of Blender.
    3. Foolish Frost's orginal script worked in Blender 2.58 but not in 2.6 versions.
    4. Get the "parker" scripts - they work in Blender 2.61 and 2.62. They will not work in 2.63 and above as the functionality of shape keys changed with the introduction of the BMesh functionality.
    5. I am using Unity 4.0

    I am happy to help you with Metamorph.

    cheers, gryff :)
     
    Last edited: Apr 27, 2013
  21. Pauls

    Pauls

    Joined:
    Nov 12, 2012
    Posts:
    46
    Hi gryff, thanks for the great topic, I was wondering if you had once experienced some troubles when trying the package with Unity 4 (4.1.2f1) ?

    I have got 81 errors such as :

    Did you just download this package : http://rezzable.com/metamorph/downloads
    Double click on the package, and once in Unity 4, click play and it works?
    Thanks
     
  22. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    Actually Pauls, I started initially with Unity 3.5 - played the demo in that. So, I've not tried the moon demo in Unity 4.0.

    However, my stuff works quite happily in Unity 4.0 - as the video I posted above shows - even added the 700+ frame animation of the two dancing girls to add a little animation stress - see if it hampered the morphing.

    So, tomorrow I will try the moon demo in Unity 4.0 and report back.

    I've spent a little time with this morph effect - so I'm willing to help others get it going.

    cheers gryff :)
     
  23. Pauls

    Pauls

    Joined:
    Nov 12, 2012
    Posts:
    46
    Thanks gryff, OK, I might be doing something wrong, I tried with Unity 3.5 but I am not so sure how it works, if it is necessary or not to use the timeline in Blender to have the shapekeys effect, or just by setting the shapekeys with the right name in the shape keys area is enough... I have got no error, but it seems that in Unity my example does not work as good as the demo ;-) Anyway, I will try again. Cheers
     
  24. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    @Pauls: actually you can do both. Take a look at the play script for Moon demo of metamorphs (called PlayMoon Demo.js ? if I remember correctly)

    The functions "mm_Morph_Add" and "mm_Morph_Remove" allow you to apply and remove shapekeys, that you define in the Metamorph script, at will - so if you want to make your character look angry for a while just add/remove the appropriate shape key with a little script.

    On the other hand, if you want to add an animation - say for lipsyncing - then use the shape key editor window of the dopesheet in blender to create an animation using the blender timeline - just as you would use the action editor for bone animation. When you use the DiffMap exporter in this case it also creates an metamorph animation file for you in a .txt format. This can be played using the function "mm_Animate_Play". You can mix bone and shapekey animation on one timeline - see the eye (with bones) and mouth (with shapekeys) movement in my demo

    The "metamorph.js" script is a library of the functions you can use.

    cheers, gryff :)
     
  25. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    @Pauls:

    As promised I created a new project in Unity 4.0 and loaded it with just the 1-Metamorph scene and assets - I ran into two problems

    1. "All compile errors must be fixed before you can enter play mode"

    The errors are in a function called "mm_SetShape_Set" in the PlayMoon DEMO script. To fix REM out the lines:

    This function is supposed to be able to permanently set the mesh with a particular morph and is not called by the script.

    2. The second problem is with the "sing" and "melt" bone based animation. Although defined in the Animations tab of the import settings for Charon they are not recognised when called by the PlayMoon DEMO script and infact in the console this message is displayed:

    A quick search found this is not unknown in Unity 4 - although I do not know how it can be fixed. Anyway it relates only to the bone based animation of the moon guy (arms, jaw etc.)

    Once error #1 was fixed all the morph stuff seemed to run fine. So I'm not sure where your 81 errors came from :(

    cheers, gryff :)
     
  26. Pauls

    Pauls

    Joined:
    Nov 12, 2012
    Posts:
    46
    Alright, thanks for the answer
     
  27. Desimus

    Desimus

    Joined:
    Nov 15, 2012
    Posts:
    6
    Glad to see you got it working!
     
  28. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    Well, you helped me Desimus - now I am trying to help others. Seem to have got one person on their way to using Metamorph.

    Success

    Now I'm trying to setup a simple lipsync system using Shape Keys in Blender as doing it with bones adds a lot of bones to an armature

    TY to you again, cheers, gryff :)
     
  29. boddole

    boddole

    Joined:
    Sep 18, 2013
    Posts:
    35
    First off, this tool is great. Second, I was wondering if there was someone or some way to "batch create" or otherwise speed up the process of setting up each individual element used in the script. I've got some water animations with key shapes, and they are all hundreds of key shapes each, setting each one manually is driving me crazy.
     
  30. boogie77

    boogie77

    Joined:
    Oct 8, 2013
    Posts:
    8
    Sorry for reviving this old thread thanx for sharing.
    I'm running Bender 2.61 with the Parker script as suggested here.
    am able to get the Moon demo's DiffMaps (TGAs) exported, but the animation (TXT) file just says
    Both Export ShapeKeys Export Animations are checked at the exporter.
    Am pretty new to Blender and animation, suspect there's something I'm missing - is there something I should highlight/select a certain something in the NLA or Dopesheet before I click export?

    Been all over google youtube looking at animation tutorials to try find out what I'm missing, but to no avail.

    Any help will be appreciated please!

    cheers,

    boogie
     

    Attached Files:

  31. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    boogie, can you post your blend file so I can take a look (hard to tell from the single image).

    Ohh, and no need to apologise - the little video I posted has steadily averaged 2-3 views a day since May. So if I can help - happy to do so.

    cheers, gryff :)
     
  32. boogie77

    boogie77

    Joined:
    Oct 8, 2013
    Posts:
    8
    Hi Gryff,

    Reading your past posts watching your youtube video had been really helpful for me over the past week or so, so I wanna thank you for all that!

    My blender file is attached. - It's really just the moon demo, but I've uploaded it just in case I've changed anything without knowing.
    It's at https://www.dropbox.com/s/xkh9d403roagdft/Charon.blend

    cheers,

    boogie
     
  33. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    boogie, a quick test on my coffee break - I get the same result :(

    Will look at it in more detail later today.

    cheers, gryff :)
     
  34. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    Ok boogie back to my spare time ;-)

    As I said above I got the same animation text file result as you, and actually if you look at the diffmap images they are all the same too - just plain grey. So the whole thing is not functioning.

    I previously gave a link to a simpler file of a head that I am using for testing :

    http://dl.dropbox.com/u/70260871/metamorph_demo_files.zip See more info on page 1 of this thread.

    Below you will find some images of the Dopesheet and Shapekey Editor from the Charon.blend and my blender file (human_head_2j.blend) included in the .zip file link above.

    Charon1 shows the way the Dopesheet window looks when Charon.blend is first loaded

    Charon2 shows the way the Dopesheet looks when you click on the word Dopesheet and Change it to Shapekey Editor. Note there seem to be no keys.

    The third image shows my layout with both the Dopesheet and the ShapeKey editor visible. My ShapeKeyEditor panel has the keys!

    The Charon.blend file was created with Blender 2.56 - not sure of what may have changed when going to blender 2.60-2.62, but the absence of those keys in the ShapeKey Editor suggests a problem. Maybe the "parker" script looks for keys in the ShapeKey Editor.

    So my suggestion is to use my files for testing see what happens - and let me know.

    cheers, gryff :)
     

    Attached Files:

  35. boogie77

    boogie77

    Joined:
    Oct 8, 2013
    Posts:
    8
    Weirdness... :eek:
    I'ma try again with a fresh download of moon soon as I get back to my computer later post the results
     
  36. boogie77

    boogie77

    Joined:
    Oct 8, 2013
    Posts:
    8
    Thanx Gryff,
    So I loaded up your files on blender 2.61, they exported without any problems whatsoever.
    Having done that, pondering on what u said about the shape-key editor, I went back to my files, n tried putting shape-key animations in them. they exported with more sensible looking animation (.txt) files.

    Furthering on your hypothesis about the editor's shape-keys' frames disappearing with files created from 2.56 and opened with somewhere between 2.60 2.62, I suspect (not sure if this makes sense) that the morphs are somehow being stored as animations instead. - i.e., for example, the lower lip's Z-position that might have been stored as -5(main animation) + -2(shape)=-7 may end up as -7 + 0 =-7.

    One observation I made is when flexing each shape-key individually, from neutral until fully flexed position, and then back again, its corresponding column registers the flex accordingly. - and rows correspond to frames. - What I don't understand is why this information is necessary.

    I'ma try importing into Unity next. Most of my project was developed using Unity 4, so hopefully this will still work. I hear I have to select Legacy for it to treat fbx animations like in Unity 3.5.
     
  37. gryff

    gryff

    Joined:
    Apr 17, 2012
    Posts:
    360
    Good :)

    Yes, it does exactly that. However it only adds keys for shape keys that are changed - take a look at the the last image above - one key frame is empty for the "wide" shape key ie the value did not change. If you change one by accident you can always "box select" just that key frame and delete it.

    Yes in Unity 4 you need to use the "legacy" rigging system if you have rigged based animation too.

    As for why the difference - I don't know boogie. They have been making regular changes to Blender and things break (eg you need the "parker" script with Blender 2.60-2.62).

    if you looked at my second YouTube video - that animation used two shape keys. I looked at a facerig the other day - it had 8 bones for the lips alone!

    Let me know how things go.

    Ohh and sorry for the delay in replying - you had two posts in a row and I did not think you had responded. :eek:

    cheers, gryff :)
     
  38. boogie77

    boogie77

    Joined:
    Oct 8, 2013
    Posts:
    8
    Hey Gryff,
    Many thanx for all your help so far! :D
    I've managed to get it running with some deformations.
    I suspect it might be a problem with Blender.
    Will update once I sort things out.
    cheers,
    boogie