Soft / Rigid Body Simulation Including Keyframe Animated Objects in Maya

By Maya, Motion Graphics, Simulation

In this tutorial you can learn how to simulate interactions between soft and rigid objects and how to include keyframe animated elements in the simulation.

We will use the Bullet engine which is in most cases faster than Maya’s nDynamics engine. It ships with the Maya 2017 installation. To activate Bullet, go to > Windows > Settings / Preferences > Plug-in Manager and at “bullet.mll” make both ticks.

If you like to work in a visually pleasing environment it is recommended to set up your lighting and Viewport 2.0 as described in this tutorial.

Start with a groundplane > Create > Polygon Primitives > Plane and scale it. Bring in the first collision object with > Create > Polygon Primitives > Cube and RMB >Assign New Material. Move it up. Switch the UI mode to “FX” and you should now have Bullet in Maya’s menu.


To start with the Bullet simulation select the cube and > Bullet > Active Rigid Body.


Press Play and the Cube falls through the ground. To include the groundplane in the simulation select it and > Bullet > Passive Rigid Body. Now the cube should stop on the ground. You can rotate the cube at it’s initial position to make the collision more interesting. Before you make changes in your scene always go back to Frame 1 with the |<< button at the playbar. If your simulations runs too fast go to > Windows > Settings / Preferences > Preferences > Time Slider or click on the gear icon below the playbar. Change the Max Playback Speed to Real-time.


Now let’s add a sphere and make it soft. Soft body simulations calculate bending and stretching between polygons and the default sphere’s different polygon sizes delivers not the best topology here. Instead > Create > Polygon Primitives > Cube, hit “3” key and then > Modify > Convert > Smooth Mesh Preview to Polygons. Alternatively the Soccer Ball and the Platonic Polygon Primitives have also a good polygon layout.


Increase the subdivision by repeating the last steps: hit “3” key again and > Modify > Convert > Smooth Mesh Preview to Polygons. Now add the rounded cube to the simulation with > Bullet > Soft Body.


When you now hit play the objects interact with each other. In the Attribute Editor at the bulletSoftBodyShape you can tweak the softness and interaction details. It is recommended to switch on Generate Bend Constraints and Enable Shape and Volume Matching. By increasing the Pressure the shape becomes more stable.


If your soft body slips through the ground, select the bulletSolver object in the Outliner and in the Attribute Editor under Solver Properties activate Ground Plane. If that doesn’t help increase the Internal Fixed Frame Rate to 120 Hz.


Now > Create > Polygon Primitives > Pyramid to bring in the third object. To move objects in other directions than downwards following gravity, you can give rigid bodies an initial velocity. In the Attribute Editor > BulletRigidBodyShape > Initial Conditions you could add Initial Velocity in x direction and let it rotate around z axis for instance by changing the values there.


If you want to have more control over the animation it is also possible to mix keyframed objects with the simulation. The important thing is, that you turn the pyramid into a rigid body before adding keframes. Select the pyramid and > Bullet > Active Rigid Body. Then you can animate it. Go to Frame 1, place the pyramid at the desired position, hit “S” key, go to the next position in the timeline, move the object, hit “S” key and so on. With the pyramid selected then go to the > Attribute Editor > bulletRigidBodyShape tab and switch Body Type to Kinematic RigidBody. This tells the Bullet engine that the pyramid comes with it’s own animation. The Collider Shape Type needs to be set to “hull”, otherwise the Bullet engine would internally work with the default simplified box shape representation. With “Collider Shape Margin” you can adjust the padding around the shape.


When you go back |<< and press play all objects should now interact with each other.


If you want to have more granular control over the simulation especially with soft bodies or if you like to apply different force fields you can alternatively simulate with Maya’s nDynamics engine. It is slower than the Bullet engine but can be more precise. The handling is similar like with Bullet, you find the tools in the FX interface under the nCloth and Field/Solvers menu.

Advanced Maya Viewport 2.0 Setup

By 3D Basics, Maya, Shaders & Texturing

In this tutorial you can learn how to set up 3-point lighting, some shading basics, and how to tweak Viewport 2.0 – Maya’s built in realtime renderer. Along the way you will find some useful tips how to set up a project and organize objects in the Outliner.

Viewport 2.0 Tutorial Result

I used the free plant model “Dandelion” from xfrog.com (direct download here), the HDR panorama “05-16_Day_C” from noemotionhdrs.net and a photo-scanned low-poly ground model which you can download here. But any other assets can be used to follow this tutorial.

Set up a new project with > File > Project Window. Click “New”, type in a name in “Current Project” and change the Location if appropriate. As soon as you hit “Accept” Maya automatically creates a set of folders on your drive.


Copy the downloaded files to the newly created sourceimages directory. Back in Maya go to > File > Save Scene As … type a name and save the file to the “scenes” directory. The idea behind the Project folder is, that files associated with the Maya scene like texture maps are stored in one place. If you or someone else want to work with this project on another computer then you just copy the complete project folder containing sourceimages, scenes, etc. to the new place. To switch the project in Maya choose > File > Set Project, navigate to the project folder you want to work with and hit “Set”.


Now > File > Import the Maya file “GC17_3.mb”. The plant should approximately cover the base grid. It consists of 24 lines in x and z direction with a distance of 1 cm (Maya’s default units are centimeters). 24 x 24 cm is a good size for this plant. The scaling can be changed anytime, but for lighting, simulation or when you want to exchange models within a team it is recommended to work with the proper measures right from the start. If you prefer a clean workspace you can go to > Display and uncheck > Grid.


The dandelion model already comes with textures and alpha masks. To make them visible select > Shading > Hardware Texturing or switch on the tiny checkerboard icon above the Viewport. You can also use the “6” and “5” key to switch texturing on and off.


When you zoom in to inspect the leaves you can see that the texture is only visible on one side.


To find out why you can open > Windows > Outliner and select the geometry, then > Display > Normals to make their direction visible. You can see that without lights in the scene only the outward facing Normals will be shaded (as long as the Ambient Color of the material is black).


Select > Display > Normals again to hide them. Switch on the light bulb icon above the Viewport or select > Lighting > Use All Lights. Since there are no lights in the scene, everything becomes black. You can also use the “7” and “6” key to switch the light mode on and off.


Let’s start with > Create > Lights > Ambient Light. It evenly illuminates all surfaces without any shadow. Not quite realistic but we will use it later to slightly brighten the shadows. Changing it’s position or rotation does not affect its direction or strength.


To bring in shadows we need a ground object. Go to > File > Import … and select the downloaded “BeachRocks.obj” from the sourceimages folder. A Material with the scanned texture will be automatically created, just change the Ambient Color to black in the Attribute Editor. Move around the plant on the ground to a nice spot. To center the view select the plant and hit the “F” key, then adjust your viewing angle further.


Let’s start the Three-Point Lighting with a black scene. Select the ambient light in the Outliner and hit the “H” key to hide it for now. Begin with the the Key Light, it represents the dominant light source, such as the sun, a window, or ceiling light. Select > Create > Lights > Directional Light. The Key light should be rotated 15-45 degrees above (seen from side view) and 15-45 degrees beside (seen from top view) to the camera’s viewing axis. Changing the position of a Directional Light has no effect. Switch on the Shadows icon above the Viewport or make a tick at > Lighting > Shadows. The Key Light defines the most visible lighting and shadows in the scene. In the Attribute Editor increase the Intensity accordingly. Also switch on “Use Depth Map Shadows”, maximize the Resolution and change the Filter Size to 20 to improve the shadow quality. You will notice that the shadow does not match the blossom. By default Viewport 2.0 works with OpenGl which does not consider alpha masks in materials. On Windows computers it is possible to use DirectX for even better realtime shading effects, different shader set ups are then required.


To soften and extend the illumination provided by the key light and to make more of the subject visible, we add a Fill Light. It can simulate light scattered from the sky (other than the sun), secondary light sources such as table lamps, or reflected and bounced light. If necessary, you may add several of them to a scene. Hide all lights in the Outliner with “H” and > Create > Lights > Spot Light. For better handling use the Scale Tool to make the light cone visible. Scaling does not change the light intensity of Spot- or Directional Lights (only Area Lights are affected). Seen from the top view, the Fill Light should come from a generally opposite angle than the Key Light – to fill it’s shadows. It can be raised to the subject’s height, but should be lower than the Key Light. The intensity of the Fill Light should be less than 50% of the Key Light. Since the Intensity of the Key Light is already 2.5 we can leave it at 1. Tick here also “Use Depth Map Shadows”, maximize the Resolution and change the Filter Size to 20 to improve the shadow quality. Changing the color of the Fill Light makes the scene look a little bit more interesting.


To highlight the edge of the objects and to help visually separate them from the background let’s add the Rim Light or Back Light. Place a Spot Light behind your subject, opposite from the camera. Tick here also “Use Depth Map Shadows”, maximize the Resolution and change the Filter Size to 20 to improve the shadow quality. To add some variation I changed the color to a colder tone.


Now the Three-Point Lighting set is complete. Switch on Key, Fill and Back Light in the Outliner. Let’s clean up the Outliner in the meantime. Rename the lights according to their function and > Create > Empty Group. MMB drag the Lights into the Null Object, create others for the cameras and the geometry. To hide the Groups in the Outliner you can select > Show > Objects > Sets and > Invert Shown.


Now you can collapse the groups with unused scene elements or hide them from the Viewport with the “H” key.


To make the material of the plant appear a little bit more lightweight, just increase the Translucence value in all plant shaders slightly.


The shadows in some parts are quite dark – unlike in reality where almost always diffuse light is around. By using the Ambient Light with a very low intensity we can fake that effect here.


The ground texture looks a bit overexposed compared to the plant, so let’s adjust that. Select the object and in the Attribute Editor click on the Input icon next to the Color slider.


You will be directed to the Texture attributes where you can decrease the Exposure.


For the sky background create a sphere with a radius of 250 cm. It should enclose the ground but be not bigger, otherwise the quality of the shadows might become too poor (the anti aliasing of the lights is calculated relative to the dimension of the whole scene). With the sphere selected RMB > Assign New Material >Maya > Surface > Lambert.


Click on the checkerboard icon next to the Color slider.


The “Create Render Node” Windows pops up. Select > 2D Textures > File.


In the Attribute Editor click on the folder icon and select the downloaded HDR image in the sourceimages folder (the low-res version is fine). Since the sky panorama is in HDR format (High Dynamic Range) the Color Space needs to be changed to RAW (without color correction). Reduce the Exposure to -1 for now, you can fine tune it later.


The Normals of the Sphere are pointing outwards by default, but we need them inwards here. To flip the direction  select > Mesh Display > Reverse. In the Shape tab of the Attribute Editor switch off “Casts Shadows” and “Receive Shadows”.


To prevent the lights affecting the intensity of the background go to the material settings in the Attribute Manager and maximize the Ambient Color and disable Diffuse. Then the material becomes a kind of self-illuminating. You can quickly test the effect by selecting the Light group in the Outliner. When you hit the “H” key to hide all lights in the scene, everything becomes black – except the Background Sphere.


Now let’s tweak the Hardware Render Settings. In the Viewport go to > Renderer > Viewport 2.0  > Options, enable Screen-space Ambient Occlusion and maximize Samples, Radius and Filter. Ambient Occlusion adds a shadow effect at overlapping or angular surface areas. It does not work well with the alpha mask of the dandelion here, so we need to reduce the Amount to 0.3. In other scenes higher values should work fine. To add some more finesse adjust the Hardware Fog settings and activate the atmospheric effect in the Viewport at > Shading > Hardware Fog.


In the last step let’s add Depth of Field blur to the scene. Make sure that your custom camera is the active camera. In the Viewport select > Panels > Perspective > (Camera Name). In the Shape tab of your custom camera make a tick at Depth of Field and change the Focus Distance according to the distance from the camera to the focus object. Activate >Shading > Depth of Field or the small icon above the Viewport.