How to play an FBX animation?

My second week working with Flax engine now, so please bear with me if the question is trivial or is already answered elsewhere. I could not find any samples or clear answer in the documentation though.

I am currently getting into the animation system, and as a test I got a free FBX from the asset store here:

So, importing this into Flax is a bit confusing to me. The only way I could get this to work is by making a copy of the fbx. I named one spider_skinned.fbx and the other spider_animation.fbx.

I then imported each one as the type indicated in the name.

So, two questions:

1. First of all, is this the correct way to import the animation? It seems strange to me that I have to duplicate the fbx in order to extract data from the same model in two different ways, and it doubles the files to manage after editing the fbx. So I assume I am doing something wrong here.

I then set up an animation graph, spider_graph, adding a animation node to it and connected the bone node to the Animation Node bone input. This plays the animation stored in the FBX correctly.

Now, all the animations are stored in this FBX, which is a very common way to store animations, and I wanted to start with the walking animation. This animation is stored in frames 1-31 in this model. Which leads to the next question:

2. How do I set this up so that I can play a walking animation by looping the walking frames 1-31? The only way I have found so far is to make a new FBX with only this animation in it. But that would absolutely explode the number of files in my project. Say I got 100 FBX files in total, each with 6 animations. that is 600 files, times two (to account for the issue in question 1), 1200 files. So, to update 100 animations, I need to update 1200 files, plus split them all manually for each new asset I add?

That is a huge overhead, but I hope I am just doing this wrong. Is there a better way? :sweat_smile:

I will try to be brief but it is a large topic question.

I think you are finding out that Unity is the actual odd one in animations. Some very old animation systems also use the single animation then determine what frames to use. I have been using Unity since 2012 then some light bulb turned on in my head when my daughter and I were modding Bethesda games and wondering why all of their animations were individual. Some Unity folks provided 1 animation per FBX, others provided all animations in one FBX but the animations were solo, then others would provide the animation in a frames string like you explained. Unity handles each with some minor issues. Like having to extract the .anim from the file for the all animations in one FBX as example. UE4/5 also uses singular animations (1 animation per FBX is best). Flax is also using this method. O3DE and Stride as well for that matter.

I still suck at animations, but I am getting better. I still have trouble with Blender animations. I just donā€™t get it. :joy: 2024 Cascadeur is a dream come true (I have spent A LOT of money on animation tools iClone5 then 6 then 7, Akeytsu, DAZ). Easy enough for even me to use and get great results. All animations are singular. I am finding, skip all the animation blending ā€˜In Engineā€™ and do it in the tool. 2024 Cascadeur does it all with ease and super smooth. You get what you see. No tool quirks and engine timing issues when the CPU gets bogged down by the multitude of other things happening.

I think you just need to restructure how your animation workflow is done. Just like I did. Fortunately, it also works even better with Unity (I currently still use v5.6.7 Pro).

Using a good folder structure will help a lot and cut down on the large number of assets. Basically importing and using smaller groups. This works in any engine too.
Insects\Spiders\SpiderAā€¦Bā€¦C
Insects\Spiders\Animations <= Spiders ā€˜shouldā€™ all share the same skeleton.
Insects\Spiders\Audio
Insects\Spiders\SpiderA\Mesh
Insects\Spiders\SpiderA\Texture

I am still getting used to how Flax does the animation controller. From what I am seeing it is going to be important to be able to play an animation by ā€˜Tagā€™ or ā€˜Numberā€™ then use that Tag or Number/Code in an array to play the animation. I did this in Unity and works great. Still have not gotten this to work in UE4/5 but I know it is possible with custom C++.

Flax might be able to do this although the example is rather poor.

We need to be able to set the animation that the drop down is doing via script variable which then sets the parameter. Not obvious at all in the example given. Maybe not possible? Needs reverse engineering for sure.

Cheers
O.

1 Like

Thank you for your insight, and yes, the fact that all animations share the same skeletons helps a lot, I didnt consider this. Good point.

I suppose my biggest worry is the artists workflow, say he needs to modify the model, then if the model has 6 animations he would need to apply the change to 6 different files? But maybe this is just why its called ā€œworkā€ :sweat_smile:

Anyway, thanks for confirming the method I found is the official way to deal with animations in Flax

Another thing, how do you store the source models in the project? I ask since the import pipeline is quite different from Unity, and I am not sure what is considered best practice.

Once a fbx is dragged into the content window, its converted into a flax file. From my understanding it still keeps a reference to the original fbx file (the location it was dragged in from), so if you do a reimport it will catch that one.

At the moment what I do is I drag the fbx into the Flax Engines context folder using the windows file explorer. Then the content folder will store the fbx. I then drag the fbx into the same folder through the editor windows content, triggering the conversion.

This way I get both the source and the converted model in the same folder, make sure that the project is not relying on external files that would disappear if the project is copied to another machine. And the fbx would be in the logical place where you would look since the actual model flax uses lives there.

However, I am not sure if this is best practice?

Actually, I have the same question about textures and I suppose any file that is converted into the flax format. The Unity approach is quite logical here, it is neat that you can simply edit a PSD in the project folder for example then it is automatically converted to a texture. The best workflow for resources needing conversion in Flax is not as clear to me though.

Artists workflow should be no different. This is what I found to be universal between all rendering engines. If you follow this one general ruleā€¦1 File = 1 Import. Donā€™t combo group things into the import file (ie FBX). You will have troubles later. Also means donā€™t use Blender/External materials or packing textures in the export file. Keep everything separate in one folder. This is also easy to FreeFileSync to a NAS drive or team share. Side note, never have more than 65,535 verts in one 3D asset import (all engines are still 16bit vertex arraysā€¦for good reason). With the 1 File = 1 Import you can check for this much easier then only need to fix one file.
(ie D:\Engine Prep\Insects\Spiders)

I agree that Unity has some nice cheats because of how it stores the actual files then when saving the .meta file picks that up and adjusts the internal file. You should steer away from this since it is mostly Unity specific. Move towards a more universal approach.

When ready for engine import copy the file types the engine can use.
(ie D:\Engine Ready\Insects\Spiders)

Two different thoughts on folder systems. There are benefits to both systems so there is no right answer. I have used both and I prefer the 2nd.

::-----------------------::
Bethesda approach (some others also use this style):
Replace Data with Content for Flax. Same thing.
Data>Materials> All Materials are in these sub folders. (ie Materials>Spiders)
Data>Meshes> All Meshes are in these sub folders. (ie Meshes>Spiders)
Data>Textures> All Textures are in these sub folders. (ie Textures>Spiders)
Content>Prefabs>Spiders (ie use these for dragging into and/or script spawns)
ā€¦similar for Audio, Scriptsā€¦etc.

Benefit is work well for texture sharing and keeps file types logical.
Drawback is that linking up various items in engine takes A LOT more clicking. Flaxā€™s Content Manager with how the folder system works (in actual practice) does not work well with this. The folders auto expand far too easily and then too much scrolling. Once the asset is linked in though it does not change. So only some additional mouse work during asset linking and set up.

::-----------------------::
Explicit Asset Hierarchy (My preferred workflow):
Content>Insects>Spiders>SpiderSkeleton
Content>Insects>Spiders>Animations (only if the spiders all have the same skeleton)
Content>Insects>Spiders>Sounds (only if the spiders all have the same audio files)
Content>Insects>Spiders>SpiderA (material, mesh, texture, animations, audio are all in this one folder)
Content>Insects>Spiders>SpiderB (same)
Content>Insects>Spiders>SpiderC (same)

Benefit is this makes the artist workflow much easier and keeping track of art assets is much better.
Drawback is that you will end up with identical textures (typically) for some things. Does not happen a lot but sharing textures with this method is much hard to keep track of as the project gets larger. Sounds are similar in that larger spiders could have deeper or slightly modified audio using Audacity. Easy work to change with a filter then export for a different sounding spider.

::-----------------------::
Order of Exporting then Importing Skeletal/Bone Meshes for animations.

Import the Textures and set up the Materials:
Content>Insects>Spiders>SpiderA

  • Textures, Diffuse and other PBR if necessary (ie SpiderA_DF)
  • Textures, Normals (ie SpiderA_NM). Make sure you know what Normals format you are using and stay with it. Most Normals are in OpenGL. If making from GIMP or xNormal they will be in OpenGL. Flax and Unreal use DirectX and need the Green Channel Inverted. Flax v1.9 has this option now and seems to be working. There is a material function for Flax I made and posted here on the forums that you should make and use as a back up.
  • PNG for either RGB and RGBA
  • Content>Insects>Spiders>SpiderA> SpiderA_MM (Master Material). Materials in Flax are enjoyable to make. Mostly Keep It Simple Stupid but you can do all sorts of cool things similar to Unreal. Far easier to make than Unity.
  • Content>Insects>Spiders>SpiderA> SpiderA_MI (Material Instance. Tie this to the Spider). You can make a number of Spider varieties by adding more MI and changing the DF (ColorMap) (ie SpiderA1_MI). The Sky is the limit. Flax handles this with ease.

Import the Meshes:

  • Content>Insects>SpidersSkeleton Spider_SK.fbx <= Spider Skeletal Mesh FBX. gLTF still has issues. Obviously this only applies to models than have bones.
  • Content>Insects>SpiderA > SpiderA_SK.fbx <= Spider A will use the above Spider_SK skeleton.
  • Content>Insects>SpiderA > SpiderA_SM.fbx <= This would be for a Spider that does not have any animations. SK = Skeletal Mesh SM = Static Mesh

All imported assets are more like UE4/5. The asset is converted by the importer as a .flax (Flax Asset). This is very similar to the .uasset. It is the entire file. Unity has meta data and keeps a duplicate of the Raw file and then an internally formatted asset that Unity syncs with the .meta file. This breaks a lot but Unity has a nifty tool to rebuild these. Does a nice job. So Flax does not need this meta data. What you see is what it really is.

When you need to edit something and make changes. Change it in Engine Prepā€¦same procedure but delete the file in Flax then import and link back up where needed. Obviously needing an update on something like a base skeleton will mess up the entire chain that depends upon it. Sometimes it happensā€¦with lots of grumbling. :rofl: Wellā€¦sheeeeeeet. Why did I not think of that?! :rofl:

Rinse and Repeat the above for anythingā€¦Door, Wall, Chair, Table, Appleā€¦same same same. Also makes for super easy testing to make sure your imports and objects are working.

::-----------------------::
Textures.
I use GIMP 2.10 for everything. 98% of normal maps are excellent as well with the old 2.8 normal map filter plugin (free). There is one included in 2.10 but it is not quite as good. Same with the PS normal map plugin. It is actually terrible. xNormal makes excellent maps so I use that for 3D assets requiring normal maps from actual 3D art (ie character bodies, high rez baked normals etc.).

GIMP has excellent PNG exports of the .xcf files. Even at compression level 9 the results are amazing. There are no artifacts with both RGB and RGBA. GIMP automatically adds the Alpha channel if adding the Alpha to any of the layers when exporting. PNG is lossless (like TGA) and saves a lot of disk space (unlike TGA, PSD). PSD is both a texture file as well as a layered file format. You should not use them directly importing. Also GIMP xcf files have no trouble with enormous file sizes. Great for texture libraries. PSD is only good for 2GB then needs PSB(?) for the larger files. And it really struggles to use them. I have not used PS since 2019 so it may be better now.

::-----------------------::
Now you can try out the animations to see how the mesh is deforming (with Blendshapes/Morph Targets) with your textures and normals. If looks goodā€¦next! :joy:

::-----------------------::
Flax imports PNG (both RGB and RGBA) very cleanly to the internal DirectX format. JPG also does well but it has quality losses when changing texture scaling. For about the same file size why not use PNG.

::-----------------------::
I hope that helps explain some things. If you want to dig into more exact details give me a PM and we can discuss. I am happy to help. Been down this same path a few times now in a number of engines.

Cheers
O.

1 Like

Thanks for your thorough post with your insight and experience. So, if I understand you correctly you suggest a structure akin to this:

ProjectRoot
ā”œā”€ā”€ Content        (Flax-managed assets: .flax files for models, materials, animations)
ā”œā”€ā”€ Source         (Scripts and source code)
ā”œā”€ā”€ SourceFiles    (Raw assets: original FBX, PSD, PNG, etc.)

Then whenever something is updated in sourceFiles, such as a PNG, then manually drag it over to the corresponding content folder to trigger the flax import, if I got you workflow recommendation right.

I suppose that is a more neat way than keeping the sourcefiles together with flax converted files, as the Content folder is a special folder that should have machine generated flax files only.

In my case I will probably source most of the assets from various asset stores, no budget for my own art team, so it will be a bit ā€œlifeā€™s like a box of chocolateā€ kind of scenario, I will never know what I will get. :sweat_smile:

But hopefully it wont be that hard to standardize files from the wild and keep things tidy and neat.

1 Like

Unity Asset Storeā€¦Box of Chocolates. :rofl: :rofl: :rofl: I totally understand this. Some are amazing and some areā€¦wellā€¦grumbles. :joy: I am 100% sure I can make this work! grumbles.

Side note!! The Epic Fab Marketplace might be a great place for a Flax Marketplace option. I have a huge Builderā€™s Kit with several build options (packs) that I want to provide a good source ready for Flax (also Unity and UE4ā€¦same place.).

Yes, but I would probably stay away from the SourceFiles in the ProjectRoot. Keep the project separated from your actual source files. Technically you can but again this is a Unity thing and is different.

The Flax Project structure (No Source Files. Not even a Resources folder like Unity has.)

Maybe an option for you is to make a SourceFiles in the Flax Projects? You end up with the same thing but the source files are not in the Project/Root.
D:\Flax
D:\Flax\Launcher
D:\Flax\Flax_1.9
D:\Flax Projects
D:\Flax Projects\FlaxSamples
D:\Flax Projects\Genesys <= my framework built on top of Flax. Your framework/project.
D:\Flax Projects\SourceFiles <= Your raw source files set up for Flax and ready for importing.

I delete the previous asset just prior to updating it. All engines complain a little (UE4/5 a lot) when removing something that something else is using. Then I drag it in the Flax UI and the import triggers. Fix what I broke then check that something in my tester scene. Have not had any Flax issues at all. To be honest here, Flax breaks less than all of them and rarely complains. :joy:

Flax has a Reimport option but it seems to be only with the asset that exists in Flax as a .flax. It is for reconfiguring the Flax Asset and not really for changing to your newly changed replacer. I could be wrong but well over 10,000 assets and many changes to them are proving my theory correct.

1 Like