Robust method to import skinned fbx models?

I am looking for a better way to import skinned fbx models into MonoGame. I have followed the XNA SkinnedMesh example that has been talked about here, and I can load the “Dude” model through the content pipeline. It seems like this only works for very specific versions and/or styles of skinned models. It doesn’t seem to work with the latest Blender at all. Is there a better solution? Three things I am considering:
a. Trying to fiddle with all of my fbx models to get them into a format that works with my existing code.
b. Looking at some of the other skinned mesh packages for MonoGame. BetterSkinnedMesh?
c. Using the UkooLabs.FbxSharpie package to load the model and then writing my own code to put the animations in the proper format for MonoGame.
Has anyone tried any of these options before? I don’t want to duplicate effort.

Autodesk have a free FBX converter that handles batch conversion.

I just use that rather than spending ages messing with code.

If I ever get to the point where this fails, I will be joining you looking for an alternative.

Stainless - Thanks for the suggestion. I’ll try the Autodesk converter for now. I feel like MonoGame is being held back by this issue. If we could drag-n-drop animated 3D models into our games it would make MonoGame awesome.

@Matt_Dean I gave up trying to get FBX’s to work correctly. I would consider switching to GLTF. Blender supports exporting GLTF 2.0, and VPenades put together a decent loader which seems to work well with Monogame. He has a Monogame example / sample somewhere as well on github.

If you just want something that works with FBX files from Blender, try following my post on Aether.Extras. There is also a video example for modeling, texturing, rigging, and animating in Blender, specifically for use in MonoGame

Here is his monogame example.


Your better off converting fbx to gltf if you use it. Their is more then one.

The big problem with this is it doesn’t have a pbr shader and you cant really use a custom shader also you can’t of course use other types of models like fbx.

Though alot can be manually hacked in but its a lot of work and pbr iss doable with dx9 however not with basic effect which is what his app is sort of forcing.

On the flip side the fbx batch converter doesn’t work on every model.

The problem is that assimp is used to load fbx under the hood for the pipeline and assimp has a lot of settings to tweek models when importing that can’t be accessed thru the pipeline, which those settings are needed to tweek load certain models.
Nkasts ather model loader is one option here there are a couple others around as well.

Going the third route is what i did and made my own model class and model loader thru the assimp nuget.
Assimp’s .net nugets support for gltf is also not very good yet either.
I have been working on a separate model loader and pbr shader of my own on an off (stuck on that really) for some time but its no were in a ready state.

That’s awesome that you’re adding pbr shader stuff to it. Your FBX code seems to handle anything I throw at it which is amazing. In a way, I can’t wait to finish my current project and get back into the animation programming and shader stuff. ;p

I wanted to say thanks to everyone who replied to this thread. It was nice having some guidance.

I ended up using the vpenades/SharpGLTF library for my skinned models. I chose that over the “.fbx” solutions because I liked the idea of an open file format. I am also not sure how much AutoDesk intends to support the “.fbx” format in the future.

The overall process was quite simple. I loaded each of my skinned models into Blender and saved them as “.glb” files. I then included them in my project as “content”. The vpenades/SharpGLTF library took care of the rest. I hadn’t planned on any custom shaders for this project, so that wasn’t a deal breaker for me.

I should also mention that I didn’t stop using the MonoGame Pipeline Tool entirely. I still use it for everything except skinned models: sound effects, fonts, static models, etc.

1 Like

Ya i didn’t post the new version up on github because it’s just missing so much still in relation to gltf and a lot of it is hacked in to let it work with pbr (which my shader isn’t working right yet, pbr is pretty complicated to get working a lot of stuff needed to support it is missing as well in monogame and assimp .net).
GLTF is heavily linked to Pbr techniques as seen by their example model page of which i only have about half of them even working with hack arounds.

1 Like

PBR is awesome feature to have for a full engine.
Btw - I made a slightly modified version of your animation engine for FBX (and added the normal-mapping and a thingy to make animation blending easy). I was able to export the regular model from 3D studio right into it. I had to program to build my own tangents though cuz for some reason the ones made by assimp weren’t working right. Right now, I’m doing the bitangent calculation right on the shader (with reorthogonalize step). I also used monogame skineffect shader as a guide and added 3 lights and fog support.
It works really well - I’m quite excited now that I got the normal-mapping to work right. (My old normal-mapping tactic only works on things that don’t move - WorldInverseTranspose was missing)
I might stick to simpler tricks for main character but PBR looks tempting for level design - especially for a more realistic(looking) game (altho not realistic in the sense of being other-worldly ;p )
Oya - I don’t know if you can tell from this pic, but the normal-maps work good (best when mip-mapping is on):
NormalMapFBX_sml

2 Likes

The eyes look amazingly good.

Vpnades is working on getting his loader and model runtime into monogame i was helping prototyping but it’s pretty much all him at this point, im too far behind on his changes to keep up and have to much real life todo stuff. I don’t really have the time right now to help much other then give advice on the shader stuff. He’s working like a madman on it though.

So maybe well actually get a pbr shader into monogame itself eventually.

1 Like

Cool - that’s interesting news, and PBR is always a juicy option for ppl working on ambitious projects. Btw - I found your documentation really useful to understand everything. I finally properly understand how it all works.
I hear ya - I have little free time too. If I find time, I have my sights set on an anime-hair-specular shader (a particular hair shading style that’s like using a dodge-brush on highlights).
Eventually XD … In the mean time I gotta shovel and fix stuff. Fun fun. ;p

Here’s the messiest project i should never post considering this is a fully experimental project don’t expect anything pretty. It’s also fat as hell as it’s packed with test models it probably wieghs in at half a gig zipped.

However im sure your version is cleaned up by now and maybe you can cherry pick out the pbr shader i have in here or any little changes i made to get certain types of models working and add it to yours.
The ibl in this is really nothing of the sort only the point lights are actually PBR the env map is sort of cheated in as a fake pbr like its resembles it but its not really the real ibl has a couple extra maps.

If all goes well in the upcoming month or so i won’t need to come back to this and clean it up or finish it.
Still this version loads the Fbx files pretty well so it might be worth doing that at some point if Assimp ever gets its shit together. That’s mostly why this is such a mess its got hack after hack to make it work.

https://drive.google.com/file/d/1_9LC5HXssRrNKX6d9y8zSMKfyWq6VaG-/view?usp=sharing

Just one note if you do dl it …

model.animationSpeedMultiplier = 1; // fbx’s
model.animationSpeedMultiplier = 10; // glb’s are fuxered up

Your kid model is in there still too i think both the old versions to flip the roughness and metalness for fbx models that don’t have those settings naturally hit the keys 1 or 2. I think to change those values.

1 Like

I uploaded the tutorial I made about loading FBX using code based on your code and shader based on Monogame’s. I forgot to mention how to control playback speed but I suppose ppl will figure it out. ;p
(first 30 mins is just setup - has 3 parts to it):

I was suggesting to ppl to blend the results of the shader matrices of 2 updated animations to blend. I’m thinking now it might be ideal to use motion-mixer and put animation clips on 1 timeline (with some padding) and then mix them using frame offsets (since the same number frames apply to blendable animations).
I was thinking of adding soft-shadows for the simple version. A more advanced version - maybe ray-tracing (or semi-faked dynamic radiosity) is the future [so I’ve heard]? PBR shader stuff is still a bit outside my knowledge bracket but I’d like to get into it if I end up making a Silent Hill inspired type game. I was already planning to play with environment mapping stuff when I find some free time.

1 Like