Hello and welcome back to the Maya Learning Channel everyone.
My name is Matt and today I’m going to show you how to get started with MPM cloth in Maya.
Now for those of you who already use Maya,
you might be familiar with its other cloth system: nCloth. So what’s the difference?
Well, first off, MPM cloth performs faster and more accurately in a variety of situations.
It’s also compatible with other MPM simulations (like particles) right off the bat.
You can cut and shear MPM cloth much more easily than nCloth.
And finally, because MPM cloth is created right in a Bifrost graph,
you can plug and play other compounds or nodes directly into it
to get all sorts of custom behavior that’d be hard to do with nCloth.
So let’s take a look at how it works.
As with any Bifrost project, you’ll need to be running Maya 2018 or later
with the latest Bifrost plug-in enabled.
You can find a link to the Bifrost download page in the description below.
I’m filming this using version 2.0.5.1, but by the time you see it 2.1.0.0 or later should be out,
which contains Viewport quality and overall improvements over what you’ll see here.
Development moves fast so always make sure you’re on the latest version.
Now to demonstrate a basic cloth setup, I’m going to start with a very exciting
– you guessed it – sphere and plane.
I’ll move them into position like so,
then open the Bifrost Graph Editor, and create a new graph.
Now, because MPM in Bifrost is so new at the time of filming this,
there isn’t a “basic_MPM_graph” compound yet.
There is this “tearing_cloth” example compound,
but for now I’m going to ignore that and build my sim from scratch,
starting with a make_mpm_cloth node.
Notice the little orange Bunsen icon here, signifying that the node is experimental.
Again, that just means that the functionality is very new and could change in the future.
First, I need an object from my scene to act as cloth –
so I’ll middle-drag in the plane
and then plug it into the geometry input.
Next, I need to simulate this cloth with a “simulate_mpm” node.
Which I’ll plug my cloth into.
Lastly, I’ll need some default settings for the simulation,
which I can get from an mpm_solver_settings node.
And then I’ll output the resulting cloth_mesh.
Now I’ll go back to the scene,
make sure the Playback Speed is set to “Play Every Frame, Free”,
and then play the simulation.
So thanks to the mpm_solver_settings, we can see gravity acting on our Bifrost object.
Of course, right now it just falls straight through my sphere.
So I’m going to go back to the Bifrost Graph Editor and add a Collider node.
Like I did with the plane before, I’ll middle-drag in the sphere…
…then plug it into the collider.
And now if I play again, the cloth wraps around the sphere!
Congrats, you’ve setup a basic MPM cloth sim!
A few things to note: first off, because this plane is being used as input for the cloth,
I can change its size or resolution…
…and it will affect the cloth, giving me an even nicer result.
Second, I can plug as many objects into this collider as I want.
So if I were to create a few more objects…
…then middle-drag those in...
...and plug them into the same collider.
Thirdly, as I mentioned earlier, building this in Bifrost means it can interact
with other Bifrost components too.
I’ll get into this a little more later in the video.
But for now, let’s continue to explore the cloth itself.
For the next part of this demonstration, I’m going to create a curtain
by rearranging some of these elements.
So first I’m going to pause the graph,
...then move aside my colliders…
…turn the plane 90 degrees on its side...
...stretch it out…
…and finally create a bunch of cubes along the top.
Of course, if I unpause the graph and play the scene now, the curtain falls down again.
To keep it up, I need to fix it to these cubes,
which I can do with a constrain_mpm node.
To speed things up, I’ll just pause my graph again, then feed it my cloth…
…and then middle-drag in the cubes...
...and plug them in as constraint_geometry.
And finally, I’ll plug the result into the simulation.
And now if unpause the graph and play the scene,
you’ll see the curtain stick to the cubes where they intersect.
Unfortunately, the cloth doesn’t look convincingly curtain-like yet.
It’s really stretchy.
There’s a couple of ways to tackle this.
First and foremost, before going too far in any sim (Bifrost or other) always ask yourself:
“Does my overall scene scale makes sense?”
If I check out the solver_settings node, notice how the default setting is 1 unit = 1 meter.
But that would make my curtain over 25 meters long!
That’s a little big, so let's make it 0.1, reducing it to a much more sensible 2.5 meter length.
That also makes the sim speed a whole lot faster.
But while the stretch is fixed, the cloth looks too bouncy now.
I could try playing with the cloth properties,
reducing the Area Preservation to 0 and then slowly increasing the Vibration Speed
to keep the curtain’s shape.
But that just kind of over-stiffens the cloth, while still keeping the bounce.
So instead, let’s undo all that and try an easier strategy.
This time, I’m going to create a drag_influence and plug that into the simulation’s influences.
This simulates an air drag force on the cloth…
…which keeps its flexibility while forcing it to settle faster!
I can control how fast with the Drag value.
Another thing I’m noticing is that the cloth is settling a little too perfectly.
It’s still much too plane-like.
So let’s add a turbulence influence as well.
Just like Drag, this exerts a turbulence force onto the cloth which I can adjust to my liking.
Finally, for an extra bit of fun, I can add a wind_influence as well.
Now a constant gust of wind is fine, but it’d be more realistic if I could randomize this a bit.
At the moment, I don’t know how to do that.
But rather than struggle to figure it out on my own,
I’m going to go up to the Bifrost Browser to find an example of something similar.
In this case, I'll load this cigarette smoke example,
which opens in a new tab.
Here I can see this custom random_magnitude compound plugged into the wind speed,
which I can just copy and paste into my own graph!
I’ll need to adjust the values a little to work with my curtain.
Then I can delete the cigarette graph.
And now I get randomized wind speed.
To keep the wind from switching directions,
I’ll add an “absolute_value” node as well, to keep it positive.
And don’t forget: these guys over here are still colliders too.
So if I animate one of them...
…it deforms the curtain too as it passes through.
But notice the large gap between the collision objects and the curtain.
That's because we changed our scale earlier.
But at this much smaller scale, we also need to reduce the detail size of the simulation
to get more accuracy.
This will cause the simulation to run slower in realtime though,
so it’s a bit of a balancing act between performance and accuracy.
But as you can see, the results are much better.
Or instead of having objects collide with the curtain,
you could animate the constraints themselves…
…to have the curtain pull back and reveal the objects behind it instead.
Or you can even do some combination of the two.
Try playing around and seeing what other fun setups you can create.
For example, you could use this exact same method to create a bandana or skirt.
Just remember: once your low-res sim looks good,
you’ll want to really crank the cloth’s subdivisions and decrease the
mpm_solver_settings’ Detail Size to get the best looking final result.
For now, I’d like to move on to one last quick demonstration.
So in this scene I’ve got a character named Nyra, originally created by Paul Tosca
(you can find a download link for the original model in the description below).
I used Maya's Quick Rig Tool to turn it into an animatable rig…
…then applied animation directly from 2020.1’s Motion Library.
By the way, for tutorials on either of those workflows,
just click the links on your screen or in the description down below.
Finally, I added a cloth simulation that’s very similar to the curtain we just did –
except this time it’s more of a banner constrained on both sides
by these wooden poles.
Now I want Nyra’s sword to slice through the banner.
The first part of this I actually already showed how to do:
I can just middle-drag her katana blade into the graph…
…and plug it in as a collider.
Just like in our curtain example though, I’ll need to decrease the Detail Size
in order for the collisions to evaluate accurately at this scale.
And for the sake of speed, I won’t actually turn on the simulation until right before I need it.
Now to handle the actual cutting of the banner,
I just need to define a type of “Failure” in the make_mpm_cloth node.
There are a few different methods here, but for the best results I recommend
“subdivide and split”.
This takes your original mesh and subdivides it further to get a more convincing “tear”.
I’ll also set the Failure Stretch to 1.25 –
An mpm_cloth basically fails when it stretches beyond a certain threshold.
This value will make it easy to split, but not so easy that it tears under its own weight.
And there you go, it’s just that easy!
To polish things off, you can add body collisions and further tweak the Failure Stretch
to your liking, as well as lighting and rendering of course.
Now, at this point, you should have all the technical skills you need
to make everything from blankets to clothing using mpm_cloth.
But in my next video, I’ll go over some specific tips and tricks to get the most out of your sims.
And as always, if you found this useful, please give us a like and subscribe down below!