Blend Shapes to Unreal Engine

   74644   34   2
User Avatar
Member
463 posts
Joined: Aug. 2014
Offline
Ok, done.
I did some tests on basic stuff and it looks ok so far, though it might fail on some more complex rigs. I guess there's no other way of finding out than through more and more testing.

Let me just wrap it up, write some instructions on how to install and use it, and put the file somewhere for download. I'll do it tomorrow evening as it's very late here now and I dream of a warm bed and a looong sleep.
User Avatar
Member
1192 posts
Joined: July 2005
Offline
Can't wait! Stuff to do on holiday!
Dragos Stefan
producer + director @ www.dsg.ro
www.dragosstefan.ro
User Avatar
Member
463 posts
Joined: Aug. 2014
Offline
Installation (MS Windows):
You need to install regex Python module first. To do this, first make sure that your PATH environment variable points to “C:\Program Files\Side Effects Software\Houdini 15.0.244.16\python27;”. Double check if it works by typing “python” in the command line. If it launches Python that ships with Houdini, you're good to go.
Download pip installer (get-pip.py) from this URL: https://pip.pypa.io/en/latest/installing/ [pip.pypa.io]
Start command line as an administrator and navigate to directory containing get-pip.py. Type python get-pip.py and wait for it to download and install.
Once it completes, go to “C:\Program Files\Side Effects Software\Houdini 15.0.244.16\python27\Scripts\” and run “pip install regex”.

Now, exit the command line, and go to “%USERPROFILE%\Documents\Houdini15.0” and create “python2.7libs” directory if it doesn't exist yet. Extract contents of the archive into it (you can create a subfolder if you wish to).

Start Houdini and create a new shelf button. Type-in or paste the following text into “script” section:
import blend_shapes_fix
reload(blend_shapes_fix)
blend_shapes_fix.main()

or if you have extracted the script to a subfolder:
import somefolder.blend_shapes_fix
reload(somefolder.blend_shapes_fix)
somefolder.blend_shapes_fix.main()

Just replace “somefolder” with appropriate folder name.
That's it.


Usage:
Set-up your blend shapes network. For now the script supports point normals only so make sure that all your blend shape poses have them. Otherwise the script will fail.
First you need to save your scene as an FBX 2014 ASCII file. Then, select the blendshapes SOP that you wish to export and press the shelf button you have created.
A file chooser window will show up where you need to select the FBX file you have just exported. The script will read and process its contents and save the result in $HIP/test.fbx (the filename and path is hardcoded for now, but you can change it by editing line 79). Load this file in UE4 as skeletal mesh. Make sure to mark “Import Morph Targets” flag.


Known Problems and Limitations:
- When “Normal Input Method” is set to “Import Normals” or “Import Normals and Tangents”, strange artifacts may appear on the mesh (see the image). I will need to investigate this.
- At the moment only point normals are supported and teir presence is mandatory. This is a subject of a future change.
- The script might be slow for larger FBX files. I didn't have time to optimize it.


WARNING!
The script is in a very early, relatively untested version. Therefore it might crash of fail if it meets unexpected FBX structure. I couldn't find any official documentation of FBX so I cannot prevent such things from happening. However, I can fix them. So please report any problems with the script in this thread along with error messages and traceback stacks.
DO NOT USE THE SCRIPT IN PRODUCTION! You use the script at your own risk.

Download
http://download.arturjzarek.com/blend-shapes-fix_v0.5.zip [download.arturjzarek.com]

Attachments:
network.png (33.2 KB)
blend-shapes-fix_known-problems1.jpg (70.9 KB)

User Avatar
Member
1192 posts
Joined: July 2005
Offline
ajz3d
WARNING!
The script is in a very early, relatively untested version. Therefore it might crash of fail if it meets unexpected FBX structure. I couldn't find any official documentation of FBX so I cannot prevent such things from happening. However, I can fix them. So please report any problems with the script in this thread along with error messages and traceback stacks.
DO NOT USE THE SCRIPT IN PRODUCTION! You use the script at your own risk.
Thanks Artur.
I tried it and managed to have a FBX with blendshapes that imports into UE4 (at least version 4.9, 4.10 was crashing on import for some reason).
That's an amazing progress!
Am I correct in assuming that the script doesn't inject the animation for the blendshapes as well? (only the shapes themselves).
Dragos Stefan
producer + director @ www.dsg.ro
www.dragosstefan.ro
User Avatar
Member
463 posts
Joined: Aug. 2014
Offline
digitallysane
Thanks Artur.
I tried it and managed to have a FBX with blendshapes that imports into UE4 (at least version 4.9, 4.10 was crashing on import for some reason).
That's an amazing progress!
Am I correct in assuming that the script doesn't inject the animation for the blendshapes as well? (only the shapes themselves).
I don't have 4.10 installed yet. It might be that UE 4.10's FBX importer is more strict than 4.9's. Due to lack of FBX 2014 examples, I had to base my script on some FBX 2011 files that I had in my archives. If someone could provide several FBX 2014 Maya files with some basic blend shapes, I could analyze the structure and hopefully correct the code so it wouldn't crash 4.10.

To answer your question - yes, currently only shapes are supported. I wanted to make the script work on a basic level first, so blend shapes animation was of very low priority. Also, I have the same problem here - I need some ASCII FBX 2014 examples that include blend shapes animation (FBX 2011 samples I have are not animated).

Ok, downloading 4.10 now. I'm going to take a closer look at what is going on.
User Avatar
Member
463 posts
Joined: Aug. 2014
Offline
Ok, I installed 4.10.1 and imported the same test.fbx file that worked for me in 4.9 and UE didn't crash. So it's probably something about the scene that my script doesn't support. Can you send me the hip file, or if it's NDA, create a similar test scene that also crashes 4.10 on your system?
User Avatar
Member
1192 posts
Joined: July 2005
Offline
I'll try with some more models and get back.
You can find some samples with animated blendshapes when installing the FBX Converter software I suggested before.
Dragos Stefan
producer + director @ www.dsg.ro
www.dragosstefan.ro
User Avatar
Member
463 posts
Joined: Aug. 2014
Offline
I see that there were some improvements to FBX exporter in daily build 15.0.315. Maybe something more will follow?

@Dragos, I'll try this converter after Christmas.
User Avatar
Member
463 posts
Joined: Aug. 2014
Offline
Hi guys,
Any news about blendshapes support for Houdini's native FBX exporter? I haven't followed the changelog for some time, so maybe I missed this feature being added in one of the recent builds.
We'll be rigging a lot of characters next month, this time for Unity engine and we plan to use blendshapes for most of them, so I thought that it wouldn't hurt to ask.
Edited by ajz3d - June 24, 2016 18:59:41
User Avatar
Member
1192 posts
Joined: July 2005
Offline
Hey Artur,

Tried to contact you by PM as well.
Do you have any progress on blendshape animation export?
Dragos Stefan
producer + director @ www.dsg.ro
www.dragosstefan.ro
User Avatar
Member
463 posts
Joined: Aug. 2014
Offline
digitallysane
Hey Artur,

Tried to contact you by PM as well.
Do you have any progress on blendshape animation export?
Hey Dragoș,
Sorry for taking so long to reply, but I was on vacation. No, I haven't touched it since my last post because we've put characters that are using blendshapes off for a later time, probably sometime around late October.
I downloaded the FBX SDK and will play with it a bit. I'll drop a word when I come up with something that is worth mentioning.
User Avatar
Member
1192 posts
Joined: July 2005
Offline
ajz3d
I downloaded the FBX SDK and will play with it a bit. I'll drop a word when I come up with something that is worth mentioning.
Great to hear. Following with interest.
Edited by digitallysane - Sept. 12, 2016 12:23:30
Dragos Stefan
producer + director @ www.dsg.ro
www.dragosstefan.ro
User Avatar
Member
3 posts
Joined: June 2015
Offline
I tried the MDD Blender approach, but while the cache looked and animated perfectly fine in Blender, once imported into UE4, and I tried various settings of the exporter, not only the shading of the asset was broken (weird normals), but blend shapes deformed the geometry in a weird fashion. They not only moved the points to their “blendshaped” positions, but also stretched the whole object in one of the axes.
___________________________________________________________________________________________________________________

Co pero co gorkamu [gorkamu.com] es el mejor
Soy el mejor por eso me llamo Gorkamu [gorkamu.com]
User Avatar
Member
463 posts
Joined: Aug. 2014
Offline
Okay, I skimmed through the FBX SDK 2016 documentation and it looks like using the SDK seems to be a much better idea than my previous attempts with some crazy RegEx hacks.

The documentation provides a pretty nice general information about FBX structure, but I feel it lacks specific examples. Especially regarding BlendShapes and re-using existing data, instead of creating new.

The docs don't click for me. SESI HOM documentation I was able to fully understand after a couple of days, but this one isn't as pretty.

Anyway, I was thinking about the following algorithm:

Search the scene for blendshape SOPs
Remember them in a list and enable "bypass" flag on all of the nodes. This is to avoid exporting blendshapes as point cache because it would complicate everything even more.
Export the whole scene (with bypassed blendshape nodes) to an FBX 2016 file.
For each object:
For each blendshape SOP of a given object:
For each input SOP connected to blendshape SOP:
Export each blendshape SOP input > 1 (input 0 is already stored in the FBX file) to a Wavefront .obj file. As a file name use a conjunction of OBJ node's name, current blendshape SOP name, and name of the first input. All names , like object, blendshape SOPs, input SOPs would need to be unique because otherwise it would complicate things even more than they already are.
--> Switch to FBX SDK Python module.
Pass the list of objects, their blendshape SOPs along with their input SOPs (represented as paths to those exported .obj files).
For each object:
For each blendshape SOP:
For each .obj file related to blendshape SOP (=each blendshape input):
# Now it begins to be tricky, because I don't quite understand yet not only all of the connections required to create blendshapes for a given object, but also the structure it needs to use. But it probably should go something like that:
Create a temporary scene.
Import .obj file.
Find a geometry (by name or some other means?) and remember it for future reference.
Create a shape out of it?
Create an FbxBlenShapeChannel and connect the "shape" to it and the channel itself to current FbxBlendShape object.
Break all connections with "shape's" original scene.
Destroy the temporary scene.
# Note that all animation on blend shapes will be dropped in this solution.
Connect the FbxBlendShape object to the current object.
Save the FBX file.
Destroy the scene.

Well, more-or-less, something like that.

I'll probably be repeating myself, but a simple scene with a cube morphing through different blendshapes and exported from Maya in FBX 2016 format would help me greatly to figure out the relationships between FBX nodes and objects re: blendshapes. Nobody of Houdineers use Maya?

Also, a more complex scene, with multiple blendshapes per object would also be welcome.


TBH, we're beginning to lean towards buying Maya LT subscription for a month or two, just to rig and animate our characters that use blend shapes. My impression of Houdini's FBX exporter is that it is a huge disappointment for GameDev sector when you need to create a fully-featured character asset. And this is a real pity, because the backend - rigging and animation tools, and asset creation in general - are top-notch, the best I've ever experienced.
Edited by ajz3d - Oct. 26, 2016 20:17:03
User Avatar
Member
1192 posts
Joined: July 2005
Offline
https://www.sidefx.com/changelog/ [sidefx.com]
Houdini 15.5.675 FBX export now supports Blend Shapes nodes.
Added an option to force Blend Shape export:

if unchecked, blend shapes nodes will only be exported if no modification
to the geometry is done after them.
if checked, blend shapes nodes will always be exported, and any modification
done to the geometry after them will be ignored.
Added an option to force Skin Deform export:

if unchecked, Deform SOPs found in geometry nodes will only be exported
if no modification to the geometry is done after them.
if checked, Deform SOPs will always be exported, and any modification
done to the geometry after them will be ignored.
Dragos Stefan
producer + director @ www.dsg.ro
www.dragosstefan.ro
  • Quick Links