Animated NVIDIA Flex soft body rig

I was testing flex and found an interesting way to rig a animatable softbody skeletal mesh. I already mentioned it a bit here already. Rather than standard skinning, this method is more like taking a rubber model and putting a metal armature inside. Some reasons why you might want to try this is as follows.

Fat.png
The soft body will animate to create a jiggle effect and applies self collision e.g middle image shows fat being moved due to raised leg.

SelfCollision.png
Another example of self collision is the fold on the arm on the right image (looks better when animated). It also maintains volume so it creates muscle like effects and it’s easier to model complex areas like the shoulders and hip without extra helper bones.

Shapes.png
It was easier to setup than skinning. The image above shows the shapes used (can ignore the spheres, empty objects). It’s probably hard to see but the pelvis is a cube rotated by 45 degrees on two axis.

This character should also interact with other flex objects like water and cloth (but I have had some issues).

For this tutorial I used the flex sample project and the SK_Troll_Poison model from the free “Infinity Blade: Adversaries” assets. The model is low poly (~2,300 triangles) and demonstrates bulky muscle areas and fat.

Setup:
To create the softbody export the SK_Troll_Poison model as fbx. I exported it from the animation editor, then opened it in blender, removed the rig, scaled it down to 1% and exported it as an fbx. Make sure the imported static mesh is the same size as the skeletal mesh.

Convert the static mesh to a flex soft body using the flexSoftContainer container (described in sample project docs). Make sure to include “Attach to Rigids” and “Phase/Self Collide”. Create a scene containing the soft body and skeletal mesh at the same location. Also watch out of any existing collisions e.g move the player start out of the way. I based the material on the flexBaconMat. Check to make sure that the soft body falls correctly.

Do the following for each bone you want to map. Create an empty actor and name it the same as the bone and tick “Actor hidden in game”. Then drag and drop in on to SK_Troll_Poison. Select the matching bone to attach it to. Change to local space and add shapes to each bone actor. Move the shapes to get something that looks like the earlier shapes image. Just a rough layout will probably be fine. The belly has no shape overlapping it so it jiggles. Make sure that “Visible” and “Actor hidden in game” are both unchecked on the SK_Troll_Poison.

Layout.png

Testing the rig.

Setup the above right image structure. Run the game and try rotating each bone.

Animating the rig.

Setup the above left image structure. Run the game and change “Animation mode” to “Use animation asset” on SK_Troll_Poison. Tick “Visible” then “Actor hidden in game” on the SK_Troll_Poison. Try changing the animations. Avoid setting the animation when editing or it could lose the default pose. The default pose is required at the start to bind the soft body to the shapes.

I changed the soft body cluster radius from 30 to 20 to improve raising the arm.

FlexAnimationNotes.png
Most animations look like the image on the left. If the character intersects itself then it can appear like the right image (fixes itself when the next animation starts). The right image was from the attack overhead animation.

Soo we have better breast animation ? ( ͡° ͜ʖ ͡°)

Wow awesome! Thanks for the tutorial. It’s looking very interesting :slight_smile: I am struggling on some points, though :confused: It would be great if you could upload this project so we can use it as an example. Of cause only if that’s ok with you.

This is awesome.

Where are the sample project docs located (for flexSoftContainer)? I looked at the Gameworks branch on Github but didn’t see it there.

After I finished building the engine I found index.html in the UnrealEngine-FleX/FlexProject/Documentation folder. Maybe it doesn’t display in GitHud (generated with project?). FlexSoftContainer should be the same asset that’s used by the bacon mesh.

I probably won’t upload my sample. Instead I’ll show a simple 15 minute detailed example. It probably duplicates some of what I’ve already said but hopefully it’s easier to follow.

Start a new scene and move “Player start” out of the way and move the ground down. I also like to add a sky light. Add SK_Troll_Poison to the stage and zero the position. Import the attached FlexTroll.fbx, add it to the stage and zero the position (they should overlap). Double click FlexTroll in content browser to open the editor. Scroll down to the Flex setting. Set “Flex Asset” to “Flex Soft Asset” then expand it. Set “Container Template” to “flexSoftContainer”. Tick “Attach to Rigids” and “Phase/Self Collide”. Now select the FlexTroll mesh in the stage. Find “Actor/Convert Actor” and select “Flex Actor”. Run the game and FlexTroll should fall to the ground.

Add an “Empty Actor” to the stage and rename it PelvisActor. Drag it on to SK_Troll_Poison and select b_MF_Pelvis for the attach to bone. Select PelvisActor and click “Add Component” to add a cube. With the cube select set the follow transforms:
location: 0,0,0
rotation: 45, 45, 0
scale: 0.4, 0.4, 0.4

Now run the game again. The FlexTroll will be stuck to the pelvis. Create another empty actor call ThighActor and attach it to the SK_Troll_Poison/b_MF_Thigh_L bone. Add a cylinder component as set the follow transforms on the selected capsule.
location: 30,0,0
rotation: 0, 90, 0
scale: 0.4, 0.4, 0.6

Select SK_Troll_Poison and untick “Rendering/Visible”. You might also want to untick “Rendering/Actor Hidden in Game” on PelvisActor and ThighActor.

Run the game and select ThighActor. Try rotating the bone in local space. It should move the soft body mesh.

To test animations run the game again and select SK_Troll_Poison. Set “Animation Mode” to “Use Animation Asset” and also set “Anim to Play”. It will snap to the start pose but not animate. Set “Rendering/visible” to true and pick another animation and it should work. Then tick “Actor Hidden in Game” on SK_Troll_Poison.

Very interesting and very usefull for ( auto ) corrective shapes…I’ll try it asap, very curious to see what else can be done with it :wink:

I did as you said it works like a charm :slight_smile:
Here an fast viedo of cause it looks goofy since there is only Pelvis and thight.

Does someone else lose material on the flex object when you start playing?

It looks like the soft bodies require a special material. I just duplicated flexBaconMat and changed the texture.

Just thought I’d post some videos.

It looks like you could simulate muscles by having a muscle mesh in the compressed state. Then attach bones to the ends and stretch it into position when the game starts. All the muscles above are part of a single soft body. I’m not an artist so the anatomy is probably all wrong.

I think the soft bodies are just meshes attached to Flex particles. It might be possible to wait for the muscles to stretch to the default pose and then run the particle / mesh linking code. Then the original troll mesh could be skinned to the muscles. It might even be ok to delete the original muscle meshes (only need the Flex particles). I’m not really sure how to do this so I’d appreciate any suggestions.

I might try adding some bones to key points on the surface of the mesh e.g biceps. Then I could use the vertex index to bake the surface bones to the muscle animation. This means Flex could be used to create more realistic characters and the converted bone animation could be used in a game that doesn’t support Flex.

Hi and thank you for investigate on this way that could be the new way maybe, is posible that you create a unique post/web or some thing else in where you store all?. I really apretiate your energy to explain all but is some complicated to follow.

Thanks!

PD: I know that I do not pay you XD, but I suppose that there are many in my situation.

I was thinking about setting up a website for tutorials, projects or random ideas. It’s a bit time consuming and I don’t have much content so I probably won’t.

My first post wasn’t very clear, the second one with the attached FlexTroll.zip should be easier to follow. Video tutorials would probably be better but they take more time to create.

HI thanks for the great idea of your tutorial but its complicated at least for me as most of the people here are new like me thats why they ask for video tutorial or the project files , and yes video can take some time but i’m not sure why you can’t upload the project which is very useful to check the setting and get the idea in easy way ,as i stuck in too many way some of them :

  1. “click “Add Component” to add a cube” what type of cube you will add ? an static cube with flex rigid body enabled or just normal static mesh ?

2."Change to local space and add shapes to each bone actor " you mean attach it to the socket ?

thanks a lot .

I think he meant the regular “Cube” component (which is just a static mesh, yeah).

Not totally sure, but I think you’re right here.

Bone / animation tutorial.

Layout2.png
When playing back animations it should be setup like the image above.

sphereRig.png
I was just trying a skinny character. It looks like stretched spheres work better. You should also be able to use a ragdoll but I couldn’t get it to work.

Thanks a lot guys now it make a lot of sense .

That’s F-ing awesome!

Damnit, times like these I feel dumb.

Been showcasing this since october 2015,basicly works on everything thats mesh or even bound particle based Flex Enabled Soft bodies in unreal 4.10 - YouTube all started with a blobby muk testing lol,all i got to say is great job overall rly like the idea of muscle simulation:) atm im working on a real blob character actually using both the fluid particles + the softbody simulation since both are particle based anyway these work pretty good togehter,ill post some picture once it reaches a state ,im happy with and i hope for an update on ur side (rly liked the sneak peek into ur ideas)

A combination of fluid and soft bodies sounds super cool. After seeing your example I thought I’d try making a mold and filling it with a high viscosity liquid. Then I could remove the mold and maybe it would fall like jelly. As you can see in the videos it didn’t really work.

I’m currently taking a break from FleX. The last thing I checked was how to attached the character mesh to the muscles. UFlexAssetSoft::ReImport() calls flexExt.h, flexExtCreateSoftMeshSkinning(). The particles look like they are attached to the mesh using bones and GPU skinning (FFlexGPUVertexFactory). I haven’t tried it but I could wait for the muscle to move into place and take a snapshot of the bones to import into blender. In blender the character mesh could be skinned to the soft body bones and exported back into UE4. Then when the game runs I could just update the skeletal mesh bones to match the soft body bones.

Completely off topic, but I’m currently interested in physics characters. Here’s a test video I made using the infinity blade SK_Greater_Spider. The physics is just driven by the animation. I was surprised at how well the character can move using just the animations.

Biped characters still need some kind of balance system. It looks like it can get enough torque to do jumps.

@DivideByZero - That’s awesome!

How do you set it up to drive the physics bodies with the animation, anyway?

Also, I’ve known about and wanted to set something like this up for years but it was never terribly feasible for me: http://graphics.cs.williams.edu/papers/DynamoVGS06/

Might give you some ideas how to do a good balancing system.

I was really excited when I finally got the physics to match the animations. For anyone who hasn’t tried this, some of the main issues are a lack of torque, the joints separating and it’s really difficult to control. The main problems with control are that motors don’t take into account internal forces (e.g moving the forearm will require a counter torque on the upper arm) and external forces (gravity, collisions). Normally you would create PD controllers and try tweaking the values to reduce effects like oscillations.

I read a GDC paper called “Practical Physics for Articulated Characters” and it talks about using Featherstone for physics.
I tried a few options that support Featherstone.

  • Simbody: Great for muscle simulation and it’s easy to integrate into UE4. Has an odd method to handle collisions e.g center of triangles, so a cube needs to be high poly to avoid passing through it.
  • DART: Mainly for robotics. I wasn’t able to get it working in UE4.
  • Bullet: I got it working in UE4 but I couldn’t get stable results.

I think you really need a good understanding of robotics and physics if you want to use Featherstone. It was all a bit beyond me, even the beginner stuff like jacobian matrices is a nightmare. I was about to give up when I found a really easy answer. PhysX already has its own solution for articulations. It is marked as experimental but the results are great. You can tell it what percentage of internal and external forces you want to counter then just set a target pose. And it also prevents the joints from separating. There aren’t any existing components that I know of so you need to access the PhysX SDK directly. Because it can handle internal / external forces it makes controlling the character from an animation really easy. If you counter all internal and external forces you could pick a fixed pose and drop the character on the ground and it will look like one fixed rigid body (as seen in the biped clip, no bending knees). It’s also really easy to match the animations, I just set the target pose to the same value as the animation pose.

Thanks for the link to the balancing method. I actually tried this a couple of months ago but I couldn’t seem to get it to work. I’m thinking I might try SIMBICON or some of the training examples I’ve seen.