Hey everyone and welcome to the Maya Learning Channel.
Today I'll be showing you how to create a network of dominoes using MASH dynamics.
Now if you're new to MASH and haven’t had the chance to check out our intro to MASH Dynamics,
you can click the link to it here.
But if you don't have time for that right now don't worry about it,
it’s not required watching to complete this tutorial.
I'm going to start by modeling a domino using a basic cube.
I'm just going to thin it out a bit and then stretch it up two times in Y...
...and then give it a quick coat of black paint.
That’s a good enough,
so now just switch over to the MASH workspace and make a MASH network out of it.
As usual, MASH defaults to a linear distribution,
and we can just add a Dynamics node on top of that.
Of course if you play the animation, these dominoes just keep falling to the floor.
Whoops, I'll just boost the total number of frames.
And then to fix that we’ll bring the ground plane up higher in the Bullet Solver.
I'll just turn off my grid here.
Now I just need something to set off the chain reaction,
so let me quickly animate a sphere to do that.
And then to make the sphere collide, I'll just middle-drag it into the Collider Objects field.
I think I need a few more dominoes
So I'll just go back to the Distribute node and raise it up.
And probably a little more friction so they don’t go sliding all over the place.
There we go; working dominoes in like 5 steps?
Granted, this is also about the least interesting layout possible,
but we can spice that up now using a Curve node.
So using any of your favorite NURBS curves, just draw out a little path.
Now with it still selected, I'll just add a Curve node.
Because we had a curve selected already, that'll place it in the Input Curve field here.
We just need to increase the Step value in order for the dominoes to fill it.
Think of this as the "percentage of the curve to use" value.
But wait, this isn't right. The dominoes kinda sorta follow the rough shape of the curve,
but they're off by quite a bit.
That's because we've still got that linear distribution contributing to it as well,
so we'll just zero that out now.
While I'm at it, I'll also bump up the number of points again.
Well, I'd say that's at least a bit more satisfying, wouldn't you?
But more importantly, look how easily I can play with the domino arrangement now
simply by tweaking the curve.
And if that wasn't enough, you can even include multiple curves too!
Like suppose I wanted to replace the ground plane here with a polygon cube instead,
and then just add it to the list of colliders.
This'll allow me to shift the ground plane down like so,
and then add a new set of dominoes down here.
So I'll just draw a second curve.
Then just middle-drag it to the same Curve node.
I'll need to double the Step value and number of dominoes too since there's two curves now.
Of course, this is just the tip of the iceberg. You could keep adding as many layers as you like.
There is one other cool thing I’d like to show off though,
if you’ll just give me a second to reconfigure my scene.
I'm going to start by deleting my curve on the lower level,
and now I'm modifying this upper curve to skirt the edge of the platform
either by moving or deleting CVs.
Because we're back to one curve, I'll need to reset the Step value
and tweak the number of points again.
Now, an important thing to note is that, by default,
all dynamic MASH networks use the same BulletSolver.
The system is designed this way on purpose so they can interact.
That let's me do something like, say,
create a second MASH network using the same domino...
...then arrange them into a grid.
I'm just going to rename these so they don't get too confusing.
MASH_GRID
and MASH_Curve.
Now I'm going to add a Transform node to move our grid network down to the ground.
By right-clicking here and creating a Controller,
I can actually do that interactively in the Viewport.
Now I'll just expand the grid out.
Finally, I'm going to add just a tiny bit of positional randomness for realism.
Just make sure it's only in X and Z since we don't want dominoes floating in the air.
Maybe just a little bit less actually.
And now I'll make these dynamic too, and match the friction to our other dominoes.
By now it's probably obvious what I'm going to do with this.
I'm going to tip the curve dominoes over the edge of the cube to get the grid going.
So I'm going to need to position them just right.
I also need to pivot the curve dominoes outward so they fall in the right direction.
I'll do that now using an Offset node.
Let's try 45 degrees.
Unlike the Transform node we used earlier, an Offset works on each dominio individually
rather than lumping them all as a group.
Unfortunately, it starts off by offsetting all the dominoes, which isn't what we want.
We only want it to affect these ones along the edge.
Thankfully, like basically everything in MASH,
I can customize this - this time by adding some falloff.
This is a feature available to almost all MASH nodes,
and basically allows you to define an area of effect.
So I'll just open up the Falloff Object section.
And then right-click to create a new one.
You can see our area of effect in the top-left here, represented as a sphere,
but I think a cube would be more appropriate in this case.
Now I'll just move it down to the edge.
So notice how this area has a sort of inner and outer zone.
The inner zone is where the offset is strongest,
and then tapers off towards the outer zone.
Since we want all the dominoes along the edge to face the same direction,
I'm going to go ahead and expand the inner zone.
Now if I just zoom in here, you can clearly see that the dominoes inside the area of effect
have turned 45 degrees while those outside remain straight forward.
I'm just going to shift this over a bit.
And it looks like I could get the dominoes over here a little closer to the edge,
otherwise I risk not setting off the entire chain reaction.
Now I'll just give it a little test spin...
Beauty!
Now that we know it works comes the really cool part.
By adding a Color node, I can put an image on this.
I'll just go over to the Color palette and add a new file.
Then select my image.
Ah nothing appears yet because the dominoes still have an Arnold shader applied.
I need to go back to the default material first.
So just right-click, Existing Material, lambert1.
This colors each domino using Color Per Vertex (or CPV) data.
But it isn't showing up correctly yet because we haven't oriented it.
I'll just do that now using a plane as reference.
So I'll create a new plane...
...and then move and scale it to fit the grid.
Then I'll just go back to the Color node
and middle-drag it into the UV mesh field.
Whoops, looks like it could use a quick turn, so I'll just rotate the reference plane.
There we go.
Now I'll just hide it.
At this point, we're basically done. All we need to do is jazz up the output.
So I'll start with the camera here.
I'll just turn on the Resolution Gate so I know what my render will see.
Then I'll keyframe the camera's position here.
And then here.
Here...
Just keep playing and then hitting 'S' when you find a frame you like.
Once you're done, you'll get something like this.
Cool, now to render.
Before rendering dynamics, it's a good idea to cache them. Caching basically turns dynamic
animation into keyframed animation. While this means that you'll lose the ability to tweak the
dominoes any further, it also takes a heavy load off the CPU during render time
(since it won't have to calculate any physics anymore).
Trust me when I tell you that trade-off is worth it.
To cache the two dynamic networks, we'll just rewind then select one of them and go to
MASH > Utilities > Cache MASH Network.
Then I'll go Export Selection.
And manually set a frame range since the animation is finished by 475.
Then I'll just give it a name and away we go.
Maya will play through the animation again while it's caching.
Once that's done, you'll need to repeat for the GRID network.
However, this time we need to enable UVs and Color Sets, because we used the Color node.
The rest of the steps are the same.
Once the two caches are done we can disable the MASH networks completely.
And instead import the cache files we created in their place.
Just to double-check, these caches should work exactly the same as before.
Sweet. Now we're ready to render in Arnold.
First we'll need a light source.
I'm just going to use a Skydome.
And now I'll hit render.
So this obviously isn't right.
The reason everything is showing up black is because I haven't
set up the grid to properly display in Arnold.
Remember earlier when outputting our caches,
and I made sure to enable those two extra attributes for the grid?
Well that's going to come into play now.
First I'll select my grid dominoes and go to the Arnold section in the Attribute Editor.
Then I'm going to scroll down and turn on this "Export Vertex Colors" attribute.
Remember that the Color node uses CPVs to track which domino should be which color.
Now I'm going to right-click the dominoes and give them a standard Arnold shader.
And finally, rather than choosing a color from the palette,
I'm going to give them our CPV data.
Which I can do with an Arnold Utility called "aiUserDataColor".
In order to know what CPV data to use, we'll need to assign a Color Set.
The default is simply colorSet.
We know this is the right one, because it should match what's in the Color node.
If you had more dominoes with images on them,
you'd have to put them on separate Color Sets.
So now if I render again...
Much better!
Remember though that you only have to do those extra steps when using the Color node.
For all the rest, we can simply re-apply our initial black shader.
Then to render out the entire animation,
go to the Rendering Menu Set and hit Render > Render Sequence.
And once you're done, the final product will look like this.