Search Unity

Blender for editing, importing and exporting FBX files?

Discussion in 'Asset Importing & Exporting' started by eses, Oct 14, 2015.

  1. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Hi there,

    I'm thinking about evaluating Blender a bit more for editing animation data.

    [more info]
    Target use would be importing, editing and exporting skeleton data, and possibly bring "rigged" meshes into Blender from other software or Unity, skinned to similar skeletons then export them as base character rig into Unity. I'm not interested about exporting/importing plain geometry at all when talking in scope of this post.

    So far my experiences with Blender are not that good but that's another discussion. I wrote a couple of simple python scripts to help make editing of object feel bit more standard. However, now that I'd like to find out a bit more about subjects of this post heading, I don't seem to be able to find much information about typical workflow related topics.

    I'm using latest version of Blender 2.76.

    I'd like to hear opinion from someone who has actually done this.
    Please no evangelism and marketing Blender.

    1. Importing FBX data to Blender
    I could use BVH and other formats in theory but in reality I'd need to be able to use FBX to import humanoid skeleton structure + animation clip data into Blender.
    So far based on quick testing, Blender's internal FBX importer plugin seems to do lousy job importing file. It creates extra garbage nodes (nubs) and it can't align all the bones properly.
    I tried various settings, result is either better looking skeleton with broken animation (auto align bone orientation + Force Connect Children) or the other way around.

    2. Exporting FBX skeletons back and forth
    Is it possible to export *standard FBX* data that was imported first into Blender back to where ever it came from, like back to Unity, and retain the structure, names, and axis alignment, so that animation data still works without some tedious in-between manual step.
    I haven't tried this yet as I didn't even get the importing part working. I most likely might be creating skeletons in Blender too, but that's another discussion.

    3. Retargeting / animation transfer
    Is it possible to do anykind of retargeting in Blender? I'm not talking about manually copying some animation curves from node to node, but proper retargeting based something like locations of joints are matched to other rigs joint locations and bones are aligned to fit to pose.
    I suspect this isn't doable as I didn't find anything about this. It would also require some sort of support for transforming source skeleton to match target skeleton also.
    There seems to be very little information about this in general and for example, Blender Artists forum seems to focus more on rendering and modeling only, and discussions there seem to be lacking info about animation and rigging for production, it seems.

    So in essence I'd be interested to know if someone has managed to create this kind of round
    trip workflow for Unity-Blender-Unity.
    [edit] Above sounds bit incorrect, what I meant was that I'd be able to work with FBX data, take some FBX data that already is in use in Unity or created/modified in some software, then bring it to Blender, edit, go back to other software if needed, then back to Blender and then export to Unity.

    I'm not asking about hand holding and step by step tutorials, but more like pointers how I could do something like that, or clear no answer, that it's not doable without tons of custom coding or something similar.

    Also any links to actually helpful articles and tutorials would be greatly appreciated.

    Thanks in advance!
     
    Last edited: Oct 14, 2015
  2. Cygon4

    Cygon4

    Joined:
    Sep 17, 2012
    Posts:
    382
    1. Importing FBX data to Blender

    I've imported hundreds of FBX files into Blender using the BOS FBX importer, which is a Blender Add-On that relies on the official Autodesk FBX SDK. So far it has never failed me and preserves the mesh, materials, skeleton and weight painting.

    It does not import animations, however. I usually don't bother since I re-rig my models anyway (to make use of Blender's Rigify or by appending my own Rigify-based animal rig), but if I absolutely want an animation, I first try it via Collada (export model with animation tracks as Collada, make sure bone names fit, import into Blender, delete everything except actions, append 'Actions' to FBX-imported model). Fallback is a BVH exporter I found here in the Unity Asset Store.

    One slight itch is that FBX generally results in a triangle mesh (not quads). Blender can restore quads via Alt+J, but it does sometimes come up with different quads than the original model had.

    2. Exporting FBX skeletons back and forth

    Blender's own FBX exporter is excellent. I generally always use .blend files directly with Unity (though Unity's import process is actually calling Blender to export to FBX, then importing the .fbx file). Static models (without Armatures) are usually oriented wrongly by 90° on the X axis. I compensate this by rotating the model -90°, baking, rotating back 90° and everything is fine. Rigged models are always oriented correctly.

    If you use complex rigs in Blender (eg. Rigify) which contain handle bones & helper bones, you can configure the FBX exporter to only export deformation bones.

    3. Retargeting / animation transfer

    Not a problem if the Armatures are compatible. Animation tracks are called 'Actions' in Blender. Actions merely contain keyframes for bones by name. Thus, if the model has bones with the same name, the Action will use then.

    Keyframes can contain any of either translation, rotation and scale channels, thus it's even possible to retarget to models of different sizes as long as no translation channel is present in the keyframes.

    Fixing mismatching bone names... well, you may laugh, but I have sometimes 'corrected' such things using a hex editor + string search (and so has Blender's Project Durian team :D).

    Advanced tip: Blender allows .blend files to be linked (load content from another .blend file). I always store my 'Actions' in separate .blend files (eg. humanoid_locomotion.blend, humanoid_fighting.blend, etc.) that contain a generic skeleton. The actual models are their own files (eg. john_doe.blend, jane_doe.blend).

    These libraries are a bit moody, though. Sometimes I can't pose my linked rig if the base file hasn't been saved with the rig in pose mode, sometimes I still can't pose and have to switch forth or back between Blender 2.72 and Blender 2.75 to make it work. In short, it takes some field experience to work with libraries.
     
    Last edited: Oct 15, 2015
  3. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Hi and thanks for extensive reply.

    Importing
    BOS FBX - I was already aware of this and had downloaded it but didn't find any information so I didn't install it as I first wanted to try built-in tools. Now that you mentioned it, I installed it and did quick test import, seems like it imports meshes quite OK by default.There isn't that much any settings (maybe a config file?)
    It imported Mixamo beta default character without messing it up too much: Skeleton, meshes and skinning too, but it didn't line up skeleton properly, there is a slight offset in depth (along Blender y-axis).
    It would be interesting to find out a bit more what's going on with that, and I'm a bit suspicious about Mixamo skeleton too, it might not be a perfect candidate for testing.

    About Collada

    I also already have tried Collada. I went to FBX Converter and exported clip to DAE file. Seems like animation data imported into Blender much more better than Blender internal FBX. However it adds extra step I'd like to avoid.
    I've not yet tested how Collada animation data would match to BOS / Blender FBX importer skeleton. But it's good to know that you've managed to do it. I haven't done anything with actions yet, so I'm quite oblivious about whole process, but I guess the process is explained somewhere.

    BVH
    I've also been eyeballing this: https://www.assetstore.unity3d.com/en/#!/content/9634. So it works for you - I was bit suspicious as there was so little information available. I guess it would be only good for exporting motion only?

    Rigify

    Is there any good intro to rigify? So far based on quick glance, I have an impression it's a custom skeleton with some sort of export features to Unity.

    Blender's own FBX exporter
    I'm aware of this 90 degree stuff, but it's quite easy to fix for static objects like you said. I also noticed that with what limited FBX export tests I did yesterday, blend file animation data too looked a little bit less mangled compared to what I managed to get out of Blender FBX exporter :).
    However, I was under impression that for that to work, Blender must be installed in system? That's why I'd like to use FBX files - do they actually need some installed software not sure.

    animation transfer
    So it's possible to copy animation. Good to hear that it's possible, but there isn't actual position data based matching to a arbitrary humanoid skeleton based on position data? That's what I suspected, maybe asking too much for free software.

    Exporting
    So, thank you for this info, yet so far I've no idea about this workflow. Maybe I can import skeleton (maybe using BOS importer if nothing else works), then load animation data somehow into it using appending data from Collada imported data or Blender FBX imported data like you mentioned, then being able to take that animation data only back to Unity.

    The fact that I'd like to use animations from Blender on already defined skeleton, that might not be from Blender will cause problems. So far this round trip hasn't worked for me.

    Seems like at least blender FBX default settings for import or export won't import data untouched, so that when exported, or used as blend file, it won't animate properly on original FBX file created rig in Unity, some axis if not all were flipped...

    I wish there was some sort of guide how to setup this kind of import / export workflow.I think it might be possible to import, then export the data like I want but not sure if I've got time to figure this out. Too bad, since I bet there might be many more users for Blender! Maybe so individuals do have such workflow going on, but keep it to themselves :).

    I'll probably have to compare axis of imported bones and FBX file to figure out what's going on, once I have time for that. Blender joint orientation seems to be Y-axis along bone and x-axis a secondary axis (bend), so not sure what is going on.
     
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    hey @eses have you looked into akeytsu?
    https://www.nukeygara.com/
    I know it's not blender based, but this looks like it could be something you could use in place of blenders animation pipeline.
    I've only looked at the training material, but it seems like it could be picked up and used in a lot less time, with a lot less "work around" processes.
    This would allow you to import rigged characters (from blender or Unity), with or without animation data, tweak/add animations onto the rig, and re-export - with the same names, mesh, skinning data, and the beta is free.
    There is a thread here in the forums about it. Really looks like a good tool for people who don't own Max, Maya or Motionbuilder.
     
  5. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    theANMATOR2b: yes, I'm aware of it, did a little bit of testing too when beta was released, but I didn't quite like it. There were many issues but I don't want to bash them as it's mostly personal preferences and I just first watched the videos then tested it... it might turn out to be a nice product and kinda like the whole concept. Maybe I'll have to test it again.
     
  6. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    If you are really into animation rigging, and bi-directional import export for final use in Unity I think the best option is probably motionbuilder.
    I personally don't use it because I already have too much expensive software to keep up with, and I'm comfortable with using Max for the purposes you stated, especially since it supports cat, biped, bones, and all mocap data types.

    The other option is Maya LT which has that new animation retargeting system built in. It seems to be very retargeting friendly and the low price is a steal imo.

    Not sure about blender for an all around bi-directional animation retargeting and rigging tool. But I applaud your desire to stick with one tool and work through the issues related to animation and rigging retargeting. It's a bear!

    Good luck.
     
  7. Honorsoft

    Honorsoft

    Joined:
    Oct 31, 2016
    Posts:
    81
    Sorry to bump an old post, but I read all the posts here and got some great information, but I could still use some help now in 2018, and I could also offer some more recent feedback advice too. I am an experienced programmer and have more recent additions to the information posted here so far in case anyone is still learning to rig 3D models for Unity.
    Eses wasn't sure if you needed any external software installed to use/export FBX's in Unity. You don't. FBX's are basically ZIP files in disguise. Some versions of FBX can even be opened by ZIP software. The newer ones (including the formats used by Unity) can not, but are basically 'encrypted' and compiled files that are packed together like a zip file, containing mesh and skeletal data along with any embedded media such as (but not limited to) textures.

    Also, Rigify was mentioned briefly, and the description was accurate: "it's a custom skeleton with some sort of export features to Unity". But it does work really well with Unity's mecanim system, and once you learn how to use it, it can be one of the easier ways to make a rigged humanoid mesh in Blender for Unity, especially if you are new to 3D modelling. I find Blender really hard to learn, but I do have other great 3D software I use for Unity, but Blender seems to be the best of all the cheapest options for those on a budget, like myself. I had successful results using Rigify to rig a character to use in Unity before, but it can be complicated (as Blender usually is) and I keep having to look up how to do it again. But Rigify helps if you don't know all the different bones required by Unity and their proper names.

    Which brings me to the one that has given me the best results, Mixamo. So far, especially if you're on a budget, is the EASIEST, quickest, and most 'compatible-with-Unity' 3D model exporter out there today in 2018. Mixamo is from the Adobe company, and they deserve credit for a great FREE site. They actually have a specific FBX export format specifically for Unity. Mixamo is online 3D software (free Adobe account required) that doesn't have model editing, but does have importing, exporting, adjustable animations for viewing and downloading, and much more. Some great features that the Mixamo site had are gone now, but it's still a great place for Unity-vompatible resources. I should mention that it is only great at humanoid models (doesn't have to be in T-Pose, but recommended), and has trouble with any models with any protruding shapes like tails, capes or horns.

    If you are doing any rigging for non-humanoid models (like a horse or spider) then it is better (cheaper) to use Blender3D. Either Rigify, or you can just create the required bones one-by-one in Blender if you know how they need to be positioned.

    ***The reason I found this page is because I still needed reminding on the proper settings and method to export the FBX in Blender to Unity. I have the axis right, Y-up, Z-forward, but I seem to have tr