No announcement yet.

Animated NVIDIA Flex soft body rig

  • Filter
  • Time
  • Show
Clear All
new posts

    [TUTORIAL] 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.

    Click image for larger version

Name:	Fat.png
Views:	1
Size:	180.6 KB
ID:	1171070
    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.

    Click image for larger version

Name:	SelfCollision.png
Views:	1
Size:	322.2 KB
ID:	1171071
    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.

    Click image for larger version

Name:	Shapes.png
Views:	1
Size:	207.7 KB
ID:	1171072
    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.

    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.

    Click image for larger version

Name:	Layout.png
Views:	1
Size:	135.5 KB
ID:	1171074

    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.

    Click image for larger version

Name:	FlexAnimationNotes.png
Views:	1
Size:	305.1 KB
ID:	1171076
    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 ? ( ͡° ͜ʖ ͡°)
    Last edited by ihavenick; 01-27-2016, 01:00 PM. | Free, simple tutorials and news. | My portfolio page


      Wow awesome! Thanks for the tutorial. It's looking very interesting I am struggling on some points, though :/ 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.
      Last edited by Rathren; 01-27-2016, 07:40 PM.


        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.
        Storyteller - An immersive VR audiobook player

        Dungeon Survival - WIP First person dungeon crawler with a focus on survival and environmental gameplay ala roguelikes


          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.
          Attached Files


            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
            ENTER REALITY

            VR Solutions

            Contact us for more informations


              I did as you said it works like a charm
              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.
                  Last edited by DivideByZero; 01-30-2016, 04:12 AM.


                    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.


                    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 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 .
                        Last edited by mhnoni; 02-02-2016, 02:29 PM.


                          Originally posted by mhnoni View Post
                          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 ?
                          I think he meant the regular "Cube" component (which is just a static mesh, yeah).

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

                          thanks a lot .
                          Not totally sure, but I think you're right here.
                          Storyteller - An immersive VR audiobook player

                          Dungeon Survival - WIP First person dungeon crawler with a focus on survival and environmental gameplay ala roguelikes



                            Bone / animation tutorial.

                            Click image for larger version

Name:	Layout2.png
Views:	1
Size:	58.0 KB
ID:	1099841
                            When playing back animations it should be setup like the image above.

                            Click image for larger version

Name:	sphereRig.png
Views:	1
Size:	222.2 KB
ID:	1099840
                            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.

                            Last edited by DivideByZero; 02-04-2016, 05:43 AM.


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