Search Unity

Rigify to Unity

Discussion in 'Assets and Asset Store' started by Dantus, May 27, 2011.

  1. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Rigify to Unity is my first submission for the Unity Asset Store.

    I hope this is going to be useful for several Blender users. All kinds of productive feedback is highly welcome!

    Important: Rigs generated with Rigify are not usable with Mecanim out of the box!
    This post explains how Rigify can be used in combination with Mecanim:
    http://forum.unity3d.com/threads/23...expect/page3?p=1579373&viewfull=1#post1579373

     
    Last edited: Feb 20, 2015
    andreiagmu and twobob like this.
  2. DavidB

    DavidB

    Joined:
    Dec 13, 2009
    Posts:
    530
    I can't believe I missed this post... all I can say is this is absolutely fantastic thank you for making it available!

    I do have a question though..... the generated rigs possess DEF and ORG variants of all points on the rig. Are both required? Also where was the naming scheme for this defined in the script? For some reason I can't see it.... (my head is swimming with all of the rigging info I've looked up today though!)

    Thanks!
     
  3. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I don't know if both are required. As you see ORG is only used to create a hierarchy, I doubt it is there for anything else. I've put it on my TODO list to check it out.
    The script first goes through the whole hierarchy and remembers all the needed ones. The parents of those nodes are also needed of course, which is the reason why you get those ORGs. After that step it removes all the truly unneeded ones.
    Maybe you understand the script a little bit better with this explanation.
     
  4. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    After several tests, I decided to leave it as it is now. It would be possible to make a new hierarchy withouth the ORGs. The consequence of that would, that all animation clips would need to be updated accordingly. As I don't have time at the moment to seriously work on that, I have to say, I won't do it now. Keep in mind, that it is a free extension.
    If you see that as a critical part for your work, you may explain me the reasons and we could try to find a solution.
     
  5. DavidB

    DavidB

    Joined:
    Dec 13, 2009
    Posts:
    530
    I was just attempting to use existing bvh motion capture data with a rigify rigged model from blender. But this is impossible unless you can obtain the same bone name hierarchy. I found another way to get mocap data to a model though.
     
  6. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    If you can code and are interested in spending time on that, we may collaborate for that task. But as I already wrote, I can not spend a lot of time on that at the moment. The code base for that already exists, so tell me if you are interested.
     
  7. DavidB

    DavidB

    Joined:
    Dec 13, 2009
    Posts:
    530
    Things are likely going to be a bit tight for a week or so for me, but I'll have a gander at the code. I'm not a programming genius, but I'm not a novice either. I'll see what I can come up with and post back here :D
     
  8. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    Hey guys, thanks for working on this, I was just wondering if you had any updates.

    It works great for me but like said, it would be a little better if it recreated the hierarchy without the ORG bones in.
    Actually the ORG bones look like they might better in some cases, eg low detail models where twist bones are not needed in every limb bone but I have to admit I'm still learning blender so haven't quite worked how only use the ORG bones (although I think I'm close with the deform tags in the bone properties!)

    Anway thanks again, really great to see work like this!
     
    Last edited: Jul 21, 2011
  9. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Removing the ORG bones as such is not very difficult. The difficult part is, that all animations need to be recalculated by the script as well. It is unlikely that I will do that in the near future, as I don't see it as very important.
     
  10. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    I the only reason I thought it would be a good idea is to make it more optimized, but maybe it's ok as the org bones don't have any skinning data?

    Anway thanks for the quick and clear reply. Script is very useful already!
     
  11. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    If any one is looking at this thinking the org bones (basically the meta rig layout) would be idea for game use, you can go though in blender and untick deform from the bone properties on all the DEF_ prefixed bones and tick deform on the one properties on all the ORG_prefixed bones to get almost the minimum number of bones.

    Thanks Dantus!
     
  12. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Didn't know that! I will definitely give it a try, even if I am not yet sure if I understand you correctly :)

    EinknarF, I am glad that you find it useful!
     
  13. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    It's basically this http://dl.dropbox.com/u/1693140/blenderdeform.jpg setting. It looks like, as you said, the org bones are just used to move the DEF bones, that probably stand for deform and are the only bones being used to deform the mesh. Turning it off on these bones and turning it on on the ORG bones gives a more game friendly rig with little effort and thanks to your script unity dosen't bother with the extra unweighted bones.

    Every time I've done it, I've manually deleted the Vertex groups for the bones from object data (triangle with dots) GUI before re parenting it so that step might be required if your getting any problems.

    edit: it is ofc possible to leave the def bones you want still in there, like forearm twist. I'm not really in a position to say how much better this whole process be for performance in most cases so maybe not worth doing for everything...
     
    Last edited: Jul 22, 2011
  14. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Now I see your point. I was unsure because you did not mention any kind of weight painting. What you describe should definitely work. It even allows you to have a nice workflow. That's very nice!
    From a performance point of view, I don't think there is a difference at all. The number of bones that are moved is always the same, so I don't think you can even measure the difference.
    The advantage of your solution is, that you can do things like simple animations in Unity without too many problems. Without that, it would be horrible for only to make a winking arm animation that does not stretch the arm length. I also assume that e.g. the Locomotion System will not work without your modification.
     
    Last edited: Aug 4, 2011
  15. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
  16. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    It's fairly simple to use the ORG bones instead of the DEF bones. In scripts\addons\rigify\generate.py change:

    Code (csharp):
    1.  
    2. if obj.data.bones[bone].name.startswith(DEF_PREFIX):
    3.  
    to:

    Code (csharp):
    1.  
    2. if obj.data.bones[bone].name.startswith(ORG_PREFIX):
    3.  
    Then continue on as normal and when you parent armature to the mesh then the ORG bones will be used instead of the DEF bones. If you want you can delete the DEF bones in Blender, but it won't hurt anything to leave them in there as this Unity import script will remove them upon import.
     
  17. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    This sounds very interesting! I haven't tested it yet and need to check it in-depth.

    If I understand you correctly, it doesn't influence the workflow that much. It would be awesome if it could be integrated into Rigify!
    What do you think, would that make sense as default behaviour or would a special "game rig" option make more sense?
     
  18. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    I think the best way would be either a "Game Rig" checkbox or a separate "Generate Game Rig" button. My Blender UI scripting experience is limited to adding a button that runs a function, so I'd have to do some research on how to do the checkbox method. I don't think that making it the default in rigify is the way to go, as having the twist bones in the DEF rig might be useful for some people.
     
  19. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I personally think a check box would be more elegant. We'll see, I should have some time in this or the next week for testing. The UI shouldn't be a big deal at the end. As you know there are quite a few very friendly Blender developers out there :).
     
  20. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Hey niosop. I tested it in depth and I have to say it is pretty impressive for such a small change :). I would like to make your idea production ready, such that it can be merged with the official Rigify. Are you interested in a collaboration?
     
  21. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    Sure, will send you a PM now.
     
  22. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
  23. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Ratings and reviews are highly welcome in the Asset Store :)
     
  24. WarpZone

    WarpZone

    Joined:
    Oct 29, 2007
    Posts:
    326
    I'm always a big fan of anything that makes a pipeline less destructive! :) Testing...
     
  25. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    That's exactly the point.
    I fear it won't work with Mecanim due to the bone hierarchy of Rigify. I spent some time to work on that but it quickly turned out to be a major undertaking.
     
  26. Game-Dragon

    Game-Dragon

    Joined:
    Nov 16, 2012
    Posts:
    34
    This is really cool. Does this also work with the Locomotion system? Locomotion + auto rigging would be simply amazing.
     
  27. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Welcome to the forum!

    Unfortunately no. The reason is that the hierarchy of the bones is modified in Rigify. I tried to find some workaround for it, but this is not a trivial task. So far it does not work.
     
  28. Proportion1

    Proportion1

    Joined:
    Jan 6, 2013
    Posts:
    35
    hey bro nice asset. ive found on my model that the upper arm and the upper leg go all wierd due to there being 2 deformation bones on the one bone. i dont know if im the only one getting this but is there any ideas how to fix it?
     
  29. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Make sure that only the deform bones are marked as such in Blender. Then you should have no problem. If you follow the video tutorial step by step there are quite some explanations.
     
  30. Proportion1

    Proportion1

    Joined:
    Jan 6, 2013
    Posts:
    35
    oh sorry i didnt explain myself (i was sleepy). if i use blender animations as per the tutorial it all works fine :D. what is going wrong is when u place a rigify character into mecanim, 4 bones dont animate correctly because they seem to be in the incorrect hierarchy position. the 4 bones that seem out of place are:

    DEF-thigh_L_01
    DEF-thigh_R_01
    DEF-upper_arm_L_01
    DEF-upper_arm_R_01

    i checked the rig in blender and these 4 bones also look like they are in the incorrect spots, however the animations work fine in blender. so i was wondering if there was a way to move these 4 bones in the hierarchy so that the rig will work fine with mecanim?

    EDIT

    hey, soz i just re-parented (no constraints) the 4 bones so that they are childs of the ORG-thigh and ORG upper arm. it didnt break the animations and it all works fine with my current blender animations.

    it also could have been because i was using an older version of rigify.
     
    Last edited: Jan 7, 2013
  31. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Cool, I expected it is not possible to get the Rigify armatures to work with Mecanim, because it requires the strict hierarchy that can not be provided by Rigify.
     
  32. Proportion1

    Proportion1

    Joined:
    Jan 6, 2013
    Posts:
    35
    ya all good. sintel is now boss at parkour just like in the unity demos.
     
  33. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Awesome :D
     
  34. TheBigE

    TheBigE

    Joined:
    Dec 30, 2010
    Posts:
    30
    Hi
    I've downloaded Rigify to Unity 1.2 and when I import my blend file I still see the full rigify bones structure inside unity...moreover I don't see the option for this add on under Window above the toolbar...I use Unity 4

    Thank u in advance
     
  35. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I just made a quick test. It works for me without any issues. I downloaded it directly from the Asset Store, then I could open the configuration window under Window->Blender->Rigify to Unity... . Further after the extraction of the example models, the one which contains Rigify in the name was properly imported and all the unneeded bones were removed.
    You may try to download Rigify to Unity 1.2.1 and see if something is changed. Make sure you don't edit any of the files, rename folders or move the around in your project. If you start with an empty project and import it, there should be no issue at all, so you should get it to work in any project.
     
  36. Etfaks

    Etfaks

    Joined:
    Jan 3, 2013
    Posts:
    4
    The program is exactly what I have been looking for, but I have some issues in using it at the moment. When I import it with rigify in the file name, it slows Unity down to 1-2 fps and I get errors about/from mecanim. It might be my rigging as I deleted a finger from the standard rigify metarig or something. Any help is greatly appreciated

    below is a link to my character blender file:
    https://dl.dropbox.com/u/12463542/Dwarf_Proto13rigify.blend
     
  37. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I am also getting the error messages. It appears to me that you made a mistake in your animation. It seems you have keyframed some of the WGT objects, whereas you should only do that with the bones. If you get rid of that, there should be no more slow down.
     
  38. Etfaks

    Etfaks

    Joined:
    Jan 3, 2013
    Posts:
    4
    I have been looking around but havent been able to locate and delete the keyframes, how would one go about doing this?
     
  39. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Sorry, it is not necessarily a keyframe you have set and indeed I couldn't find any as well, but I hate the way Blender hides that kind of information sometimes... You have created some kind of link between the unneeded parts the the needed parts. As Rigify to Unity removes the unneeded parts, Mecanim starts to complain, because it still has those links. Unfortunately I have absolutely no idea what you did or how you can remove it.
     
  40. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    Any tips for getting the loading speed down? It's taking a long time loading my animation heavy blend files in unity, I think because of the complexity of the rig in the background.
     
  41. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I assume with loading time you mean the time for the import. Rigify to Unity itself is very fast and usually you won't even notice that it does anything. The remaining time is the conversion of the blend file to an fbx and then the actual import to Unity. As all those steps are needed, there is no way around it.
     
  42. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I have updated the description in the Asset Store and the first post of this thread with the following clarification:

     
    twobob likes this.
  43. ComboMash

    ComboMash

    Joined:
    Sep 14, 2012
    Posts:
    5
    AnomalusUndrdog likes this.
  44. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Thanks for the info, I wasn't aware of that article!
     
  45. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    in light of that article, any chance you'll be updating r2u?
     
  46. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Unfortunately it doesn't change anything. The article describes that several manual modifications are needed. Those ones can't be automated in general, such that it will also work with future versions. The advantage of Rigify is that you can easily animate in Blender. With the described steps in the article, you loose that as far as I understand it.
    I tried something like that in the past but run into one major issue. My goal was that I wanted to leave the generated rig untouched in Blender and adjust it during the import into Unity. It was pretty straight forward, but all the animations were broken because of it. From my point of view it would end up exactly like that again, because the underlying idea is identical.
     
  47. danzhor

    danzhor

    Joined:
    Sep 7, 2013
    Posts:
    8
    Hello,
    if there is still anybody who is interested in making rigify compatible with mecanim, you can check video(embeded in comment below). There is a link in description to a script which makes it possible. Nothing complicated, but I didn't find a way to do it during the import time (which is the Rigify to Unity script doing), so you have to use it in blender.

    Dantus, I hope it is not a problem that I've put this link here... and if you actually find it useful in some way and will be able to use it within your addon, feel free to use it there...
     
    Last edited: Nov 1, 2013
  48. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I have absolutely no problem with productive ideas like yours! Rigify to Unity was created to help people bring their animations and rigs as easily as possible to Unity. We probably agree both that Rigify is just awesome, but unfortunately it doesn't work with Mecanim.
    What I absolutely hate is links to videos, because they should be embedded!


    What you are doing can't be done during the Unity import. This step has to be done within Blender, because you are not using the actual deform rig, but the org one. In the Unity manual there is even another explanation about how this could be done:
    http://docs.unity3d.com/Documentation/Manual/BlenderAndRigify.html

    There is one point I don't get in your video and also not in the Unity manual: Why do you destroy the whole rig?
    The actual value of Rigify is the rig! It is so comfortable to animate with it. By deleting the wgt, you destroy the rig and you are taking the comfort out of Rigify. You are destroying the animation workflow. Let's assume you have created an animation, you do all your steps, now you find out that you would like to adjust the animation or add another one. Well, that's not anymore possible, because you destroyed the rig.
    The major advantage of Rigify to Unity was or is that you are getting a non-destructive workflow. Create everything in Blender without funky deletions, save it and in Unity you are only going to get the necessary parts (with a few exceptions). With that you can go back and forth as you wish!
    With any other solution I have seen so far, you had to be careful not to save your .blend file when the funky deletions were made because you could not go back anymore.

    I really like your approach and I think there is a way to use your idea in combination with Rigify to Unity to get a non-destructive workflow! Let's assume we have created a Rigify rig, we are running your script and delete or rename the DEF bones to something else. Then we rename the ORG bones to DEF. Already with those steps, we are pretty much done. Rigify to Unity will get rid of the WGT stuff and also the original DEF bones if they are still around.
    What prevented me from already doing something like that is the special cases for the DEF bones that you took care of one by one. I love general approaches and as Rigify allows you to not only create a human rig, but a lot more, this approach will unfortunately not work in general.

    If I had a little more time, I would love it to create a patch for Rigify with a game rig option, that would directly do those steps and as a consequence it would also work in combination with Rigify to Unity within a non-destructive workfow.

    Thanks again for pointing me to the video!
     
  49. danzhor

    danzhor

    Joined:
    Sep 7, 2013
    Posts:
    8
    Thank you a lot for the comments...
    I'm really sorry about the link, I didn't realize it (I'm quite new to this forum)... will redo it if it's needed (or maybe will remove it completely as you posted it).

    About destroying the WGT... you are right, I'm doing it only for the export part (I've saved blend file and doing export to FBX withouth WGT)... as I don't want to have it all there (quite a bunch of them)... your addon will be good for this, that's for sure... maybe I should explained it better in that video :/

    I have to say that I'm beginner in blender, just learning and I like rigify as it provides really nice rig (I'm using it for human-like bodies, didn't think about others). As I was thinking how to get it into mecanim I figured out this approach, but I had still the strange feeling that I'm probably missing something with the DEF bones and why they are setup like that. So it's good to know now, that there are other uses of rigify, not just human-like rig. Maybe when I will get more experience with it and will see all the possibilities I will try to find a different approach :)

    anyway... once more thanks for your reply and good info.
     
    Last edited: Nov 1, 2013
  50. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    Dantus, I'm interested in this add-on, but I had two questions. I have several characters that have already been weight-painted. I suppose I can deal with deleting my own rig and replacing it with a rig from your add-on, but ...

    (1) I really hope I don't have to rename the weight vertex groups, and can choose to rename your rig's Mecanim-bones instead? If so, then I think I can even migrate my characters to the new rig without having to update any Mecanim or scripts that depend on my old rig's naming.

    (2) Are you able to handle adding extra bones and allowing those extras through the export to Mecanim? Hair, skirts, toolbelt accessories all rely on extra bones.